Skip to content

Commit 1020023

Browse files
Avoid infinite loop in BLE HID send (#1834)
If the BLE connection is severed, don't wait for the needToSend flag to clear in the HID::send routine since it may never actually clear unless the BLE connection is restored. Partial #1817
1 parent a475c44 commit 1020023

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

libraries/HID_Bluetooth/src/PicoBluetoothBLEHID.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,10 @@ class PicoBluetoothBLEHID_ {
252252
}
253253

254254
bool send(void *rpt, int len) {
255-
//wait for another report to be sent
256-
while (_needToSend);
255+
// Wait for another report to be sent
256+
while (connected() && _needToSend) {
257+
/* noop busy wait */
258+
}
257259
_needToSend = true;
258260
_sendReport = rpt;
259261
_sendReportLen = len;

0 commit comments

Comments
 (0)