diff options
author | Florian Didron <fd@librem.one> | 2019-12-04 18:50:52 +0900 |
---|---|---|
committer | Florian Didron <fdidron@users.noreply.github.com> | 2019-12-06 08:20:51 +0900 |
commit | f7408111c74e037f863224027e362f9e386644e0 (patch) | |
tree | e2f732e7e20c1fe64291fe2a323d60af1db87c2e /tmk_core/protocol | |
parent | 15d3efd5d1b11030cc454d7adf3c7e35c8fa8c42 (diff) |
fix: chibios handle disconnections gracefully
Diffstat (limited to 'tmk_core/protocol')
-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 |