From 091650d0a19b1f60b1a2a8aa0b7d06e34accaaf6 Mon Sep 17 00:00:00 2001 From: Kristian Lauszus Date: Mon, 8 Oct 2012 15:32:42 +0200 Subject: [PATCH] Exit if inquiry finished --- BTD.cpp | 12 +++++++++++- BTD.h | 3 ++- 2 files changed, 13 insertions(+), 2 deletions(-) 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