Share via


Bluetooth Stack Status

A version of this page is also available for

Windows Embedded CE 6.0 R3

4/8/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.

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