Unverified Commit 2cde8bd7 authored by Earle F. Philhower, III's avatar Earle F. Philhower, III Committed by GitHub

Avoid deadlock BT/LE HID send when disconnected (#2252)

Fixes #2251

The 2-phase send could get out of whack if transmission was attempted when
no device was connected. Clear things up so if things aren't connected,
then no data gets set as pending.
parent 99b32b84
......@@ -178,11 +178,13 @@ public:
while (connected() && _needToSend) {
/* noop busy wait */
}
_needToSend = true;
_sendReport = rpt;
_sendReportLen = len;
__lockBluetooth();
hids_device_request_can_send_now_event(_con_handle);
if (connected()) {
_needToSend = true;
_sendReport = rpt;
_sendReportLen = len;
hids_device_request_can_send_now_event(_con_handle);
}
__unlockBluetooth();
while (connected() && _needToSend) {
/* noop busy wait */
......
......@@ -142,12 +142,14 @@ public:
}
bool send(int id, void *rpt, int len) {
_needToSend = true;
_sendReportID = id;
_sendReport = rpt;
_sendReportLen = len;
__lockBluetooth();
hid_device_request_can_send_now_event(getCID());
if (connected()) {
_needToSend = true;
_sendReportID = id;
_sendReport = rpt;
_sendReportLen = len;
hid_device_request_can_send_now_event(getCID());
}
__unlockBluetooth();
while (connected() && _needToSend) {
/* noop busy wait */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment