From 0a6fabafd68be350ef678918ef3dcea60f1509e6 Mon Sep 17 00:00:00 2001 From: "Earle F. Philhower, III" Date: Tue, 28 Oct 2025 14:10:15 -0700 Subject: [PATCH] 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. --- libraries/BluetoothHIDMaster/src/BluetoothHIDMaster.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/BluetoothHIDMaster/src/BluetoothHIDMaster.cpp b/libraries/BluetoothHIDMaster/src/BluetoothHIDMaster.cpp index 045b68ddc..221dde4fe 100644 --- a/libraries/BluetoothHIDMaster/src/BluetoothHIDMaster.cpp +++ b/libraries/BluetoothHIDMaster/src/BluetoothHIDMaster.cpp @@ -231,12 +231,12 @@ bool BluetoothHIDMaster::connectBLE(const uint8_t *addr, int addrType) { // GAP connection running async. Wait for HCI connect uint32_t now = millis(); while (millis() - now < 5000) { - if (_hci.connected()) { + if (_hid_host_descriptor_available) { break; } delay(25); } - if (!_hci.connected()) { + if (!_hid_host_descriptor_available) { gap_connect_cancel(); return false; }