diff --git a/libraries/HID_Bluetooth/src/PicoBluetoothBLEHID.h b/libraries/HID_Bluetooth/src/PicoBluetoothBLEHID.h index 996f292..f251bfc 100644 --- a/libraries/HID_Bluetooth/src/PicoBluetoothBLEHID.h +++ b/libraries/HID_Bluetooth/src/PicoBluetoothBLEHID.h @@ -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 */ diff --git a/libraries/HID_Bluetooth/src/PicoBluetoothHID.h b/libraries/HID_Bluetooth/src/PicoBluetoothHID.h index 2285095..ae0fa05 100644 --- a/libraries/HID_Bluetooth/src/PicoBluetoothHID.h +++ b/libraries/HID_Bluetooth/src/PicoBluetoothHID.h @@ -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 */