We have explained some content about the Bluetooth protocol stack. We know that the Bluetooth protocol stack is widely used in embedded systems. So today we will mainly explain some commands about the initialization status of the Bluetooth protocol stack.
At startup, it takes some time to fully load and initialize the Bluetooth protocol stack. You can use BTH_NAMEDEVENT_STACK_INITED to check the protocol stack initialization, which is defined in % _ WINCEROOT % \ Public \ Common \ Sdk \ Inc \ Bt_api.h. To open this naming event, you must use the OpenEvent function.
- // Determine whether the Protocol Stack has been initialized
- 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)
- {
- // Handle errors
- }