Added new HOST_STATE_WaitForDeviceRemoval host state machine state for non-blocking...
[pub/USBasp.git] / Demos / Host / Incomplete / BluetoothHost / BluetoothHost.c
index b8e87cb..3222b77 100644 (file)
@@ -139,14 +139,11 @@ void Bluetooth_Management_Task(void)
                                LEDs_SetAllLEDs(LEDS_LED1);\r
 \r
                                /* Wait until USB device disconnected */\r
-                               while (USB_IsConnected);\r
+                               USB_HostState = HOST_STATE_WaitForDeviceRemoval;\r
                                break;\r
                        }\r
 \r
                        puts_P(PSTR("Bluetooth Dongle Detected.\r\n"));\r
-                               \r
-                       /* Select the control pipe for the request transfer */\r
-                       Pipe_SelectPipe(PIPE_CONTROLPIPE);\r
 \r
                        /* Set the device configuration to the first configuration (rarely do devices use multiple configurations) */\r
                        if ((ErrorCode = USB_Host_SetDeviceConfiguration(1)) != HOST_SENDCONTROL_Successful)\r
@@ -158,7 +155,7 @@ void Bluetooth_Management_Task(void)
                                LEDs_SetAllLEDs(LEDS_LED1);\r
 \r
                                /* Wait until USB device disconnected */\r
-                               while (USB_IsConnected);\r
+                               USB_HostState = HOST_STATE_WaitForDeviceRemoval;\r
                                break;\r
                        }\r
                                \r
@@ -181,7 +178,7 @@ void Bluetooth_Management_Task(void)
                                LEDs_SetAllLEDs(LEDS_LED1);\r
 \r
                                /* Wait until USB device disconnected */\r
-                               while (USB_IsConnected);\r
+                               USB_HostState = HOST_STATE_WaitForDeviceRemoval;\r
                                break;\r
                        }\r
 \r
@@ -189,9 +186,5 @@ void Bluetooth_Management_Task(void)
 \r
                        USB_HostState = HOST_STATE_Ready;\r
                        break;\r
-               case HOST_STATE_Ready:\r
-                       /* Do nothing, Bluetooth stack will take care of enumeration */\r
-                       \r
-                       break;\r
        }\r
 }\r