From 755f23fdfab9437325a1ba541549e46d9995b1f7 Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Tue, 1 Nov 2022 21:36:31 +0100 Subject: [PATCH] Ignore the first byte of the BLE packets The first byte of the BLE packets does no longer contain the size of the payload. Since BLE supports variable sized packets, we can simply ignore this byte and obtain the payload size from the BLE packet size. --- src/uwatec_smart.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/uwatec_smart.c b/src/uwatec_smart.c index 38774bb..d5df3db 100644 --- a/src/uwatec_smart.c +++ b/src/uwatec_smart.c @@ -310,6 +310,7 @@ uwatec_smart_usbhid_receive (uwatec_smart_device_t *device, dc_event_progress_t { dc_status_t rc = DC_STATUS_SUCCESS; dc_device_t *abstract = (dc_device_t *) device; + dc_transport_t transport = dc_iostream_get_transport(device->iostream); unsigned char buf[PACKETSIZE_USBHID_RX]; size_t nbytes = 0; @@ -364,9 +365,11 @@ uwatec_smart_usbhid_receive (uwatec_smart_device_t *device, dc_event_progress_t * * It may be just an oddly implemented sequence number. Whatever. */ - unsigned int len = buf[0]; - if (len + 1 > transferred) - len = transferred-1; + unsigned int len = transferred - 1; + if (transport == DC_TRANSPORT_USBHID) { + if (len > buf[0]) + len = buf[0]; + } HEXDUMP (abstract->context, DC_LOGLEVEL_DEBUG, "rcv", buf + 1, len);