diff --git a/BTD.cpp b/BTD.cpp index 8151e9d7..a2c91003 100755 --- a/BTD.cpp +++ b/BTD.cpp @@ -354,7 +354,17 @@ void BTD::HCI_event_task() { } break; - case EV_INQUIRY_COMPLETE: // We don't use this for anything + case EV_INQUIRY_COMPLETE: + if(inquiry_counter >= 5) { + inquiry_counter = 0; +#ifdef DEBUG + Notify(PSTR("\r\nCouldn't find Wiimote")); +#endif + connectToWii = false; + pairWithWii = false; + hci_state = HCI_SCANNING_STATE; + } + inquiry_counter++; break; case EV_INQUIRY_RESULT: diff --git a/BTD.h b/BTD.h index 8b079762..7dd4a6f6 100755 --- a/BTD.h +++ b/BTD.h @@ -243,7 +243,8 @@ private: uint8_t hci_state; //current state of bluetooth hci connection uint16_t hci_counter; // counter used for bluetooth hci reset loops uint8_t hci_num_reset_loops; // this value indicate how many times it should read before trying to reset - uint16_t hci_event_flag; // hci flags of received bluetooth events + uint16_t hci_event_flag; // hci flags of received bluetooth events + uint8_t inquiry_counter; uint8_t hcibuf[BULK_MAXPKTSIZE];//General purpose buffer for hci data uint8_t l2capinbuf[BULK_MAXPKTSIZE];//General purpose buffer for l2cap in data