Partager via


Bluetooth Stack Status (Windows Embedded CE 6.0)

1/6/2010

You can check the initialization status of the Bluetooth stack by using the symbolic define BTH_NAMEDEVENT_STACK_INITED, defined in %_WINCEROOT%\Public\Common\Sdk\Inc\Bt_api.h. To open this named event, use the OpenEvent function.

During boot time, the Bluetooth Protocol Stack takes time to fully load and initialize.

For more Windows Embedded CE information, see Bluetooth Protocol Stack.

The following example code how to open the named event, BTH_NAMEDEVENT_STACK_INITED, to check the status of the Bluetooth stack.

// Make sure BT stack is up
BOOL fStackUp = FALSE;
for (int i = 0 ; i < 100 ; ++i) 
{
  HANDLE hBthStackInited = OpenEvent (EVENT_ALL_ACCESS, FALSE, BTH_NAMEDEVENT_STACK_INITED);
  if (hBthStackInited) 
  {
    DWORD dwRes = WaitForSingleObject (hBthStackInited, INFINITE);
    CloseHandle (hBthStackInited);
    if (WAIT_OBJECT_0 == dwRes) 
    {
      fStackUp = TRUE;
      break;
    }
  }
  Sleep (1000);
}
if (! fStackUp) 
{
  // Perform error handling.
}

See Also

Other Resources

Bluetooth Application Development