Check status byte in HCI Authentication Complete Event

If paring fails simply disconnect
This commit is contained in:
Kristian Sloth Lauszus 2016-02-09 12:10:12 +01:00
parent 9eed52026b
commit 0cdde7afe9

View file

@ -589,6 +589,7 @@ void BTD::HCI_event_task() {
break;
case EV_AUTHENTICATION_COMPLETE:
if(!hcibuf[2]) { // Check if paring was successful
if(pairWithWii && !connectToWii) {
#ifdef DEBUG_USB_HOST
Notify(PSTR("\r\nPairing successful with Wiimote"), 0x80);
@ -600,6 +601,14 @@ void BTD::HCI_event_task() {
#endif
connectToHIDDevice = true; // Used to indicate to the BTHID service, that it should connect to this device
}
} else {
#ifdef DEBUG_USB_HOST
Notify(PSTR("\r\nParing Failed: "), 0x80);
D_PrintHex<uint8_t > (hcibuf[2], 0x80);
#endif
hci_disconnect(hci_handle);
hci_state = HCI_DISCONNECT_STATE;
}
break;
/* We will just ignore the following events */
case EV_NUM_COMPLETE_PKT: