Fix TemperatureDataLogger - sample tick timer wasn't being initialized in the correct...
[pub/USBasp.git] / Demos / Host / Incomplete / BluetoothHost / Lib / BluetoothHCICommands.c
index b4720e5..c4cd5d6 100644 (file)
@@ -72,7 +72,6 @@ static bool Bluetooth_GetNextHCIEventHeader(void)
        }\r
          \r
        Pipe_Read_Stream_LE(&HCIEventHeader, sizeof(HCIEventHeader));\r
-         \r
        Pipe_Freeze();\r
 \r
        return true;\r
@@ -81,11 +80,14 @@ static bool Bluetooth_GetNextHCIEventHeader(void)
 static void Bluetooth_DiscardRemainingHCIEventParameters(void)\r
 {\r
        Pipe_SelectPipe(BLUETOOTH_EVENTS_PIPE);\r
-       \r
        Pipe_Unfreeze();\r
+\r
        Pipe_Discard_Stream(HCIEventHeader.ParameterLength);\r
        Pipe_ClearIN();\r
+\r
        Pipe_Freeze();\r
+       \r
+       HCIEventHeader.ParameterLength = 0;\r
 }\r
 \r
 void Bluetooth_ProcessHCICommands(void)\r
@@ -329,6 +331,10 @@ void Bluetooth_ProcessHCICommands(void)
                                                         \r
                                        Bluetooth_HCIProcessingState = Bluetooth_Conn_SendPINCode;\r
                                }\r
+                               else if (HCIEventHeader.EventCode == EVENT_COMMAND_COMPLETE)\r
+                               {\r
+                                       BT_DEBUG("(HCI) >> Command Complete", NULL);\r
+                               }\r
                                \r
                                BT_DEBUG("(HCI) -- Unread Event Param Length: %d", HCIEventHeader.ParameterLength);\r
 \r
@@ -393,17 +399,6 @@ void Bluetooth_ProcessHCICommands(void)
                               sizeof(Bluetooth_DeviceConfiguration.PINCode));\r
                        \r
                        Bluetooth_SendHCICommand(&PINCodeRequestParams, sizeof(PINCodeRequestParams));\r
-               \r
-                       do\r
-                       {\r
-                               while (!(Bluetooth_GetNextHCIEventHeader()))\r
-                               {                               \r
-                                       if (USB_HostState == HOST_STATE_Unattached)\r
-                                         return;\r
-                               }\r
-\r
-                               Bluetooth_DiscardRemainingHCIEventParameters();\r
-                       } while (HCIEventHeader.EventCode != EVENT_COMMAND_COMPLETE);\r
 \r
                        Bluetooth_HCIProcessingState     = Bluetooth_PrepareToProcessEvents;\r
                        break;\r