Skip to content

Commit 0a6faba

Browse files
BLE HID pairing completed only with HID descriptor
Related to #3221 Delay the `connectBLE` success until we have a HID descriptor from the BLE remote device. This takes longer but guarantees we can get those HID messages, and eliminates potential race conditions where the HCI comes up fast but the GATT setup takes its sweet old time.
1 parent 03cc990 commit 0a6faba

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

libraries/BluetoothHIDMaster/src/BluetoothHIDMaster.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,12 +231,12 @@ bool BluetoothHIDMaster::connectBLE(const uint8_t *addr, int addrType) {
231231
// GAP connection running async. Wait for HCI connect
232232
uint32_t now = millis();
233233
while (millis() - now < 5000) {
234-
if (_hci.connected()) {
234+
if (_hid_host_descriptor_available) {
235235
break;
236236
}
237237
delay(25);
238238
}
239-
if (!_hci.connected()) {
239+
if (!_hid_host_descriptor_available) {
240240
gap_connect_cancel();
241241
return false;
242242
}

0 commit comments

Comments
 (0)