diff options
author | Florian Didron <fd@librem.one> | 2019-12-04 18:50:52 +0900 |
---|---|---|
committer | Drashna Jael're <drashna@live.com> | 2019-12-05 16:03:55 -0800 |
commit | 0f319b48e62d53bcb0c0601a723893afd1c93505 (patch) | |
tree | e2f732e7e20c1fe64291fe2a323d60af1db87c2e | |
parent | 9620bdbf007dd1a056f464d8825539a7d556a618 (diff) |
fix: chibios handle disconnections gracefully
-rw-r--r-- | tmk_core/protocol/chibios/usb_main.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/tmk_core/protocol/chibios/usb_main.c b/tmk_core/protocol/chibios/usb_main.c index 57b9d74d38..0acb78c9ad 100644 --- a/tmk_core/protocol/chibios/usb_main.c +++ b/tmk_core/protocol/chibios/usb_main.c @@ -869,7 +869,12 @@ void raw_hid_task(void) { #endif #ifdef WEBUSB_ENABLE -void webusb_send(uint8_t *data, uint8_t length) { chnWrite(&drivers.webusb_driver.driver, data, length); } +void webusb_send(uint8_t *data, uint8_t length) { + if(chnWriteTimeout(&drivers.webusb_driver.driver, data, length, TIME_IMMEDIATE) != length){ + webusb_state.paired = false; + webusb_state.pairing = false; + } +} __attribute__((weak)) void webusb_receive_kb(uint8_t *data, uint8_t length) { // Users should #include "raw_hid.h" in their own code |