From 7d012c11b8318be19b13acd483fdea81ee3ce540 Mon Sep 17 00:00:00 2001 From: Nico Date: Tue, 27 Oct 2015 08:06:21 +0100 Subject: [PHID] send data if report ID was sent successful If the first sending was not successful it is better to abort. Then we get a return value of -1 (instead of -2 if the 2nd call will also fail) and we do not need to block even longer, with another timeout. --- libraries/HID/HID.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'libraries/HID') diff --git a/libraries/HID/HID.cpp b/libraries/HID/HID.cpp index 3a42699..8adf1a9 100644 --- a/libraries/HID/HID.cpp +++ b/libraries/HID/HID.cpp @@ -88,10 +88,11 @@ void HID_::AppendDescriptor(HIDSubDescriptor *node) int HID_::SendReport(uint8_t id, const void* data, int len) { - int ret = 0; - ret += USB_Send(pluggedEndpoint, &id, 1); - ret += USB_Send(pluggedEndpoint | TRANSFER_RELEASE, data, len); - return ret; + auto ret = USB_Send(pluggedEndpoint, &id, 1); + if(ret >= 0){ + ret += USB_Send(pluggedEndpoint | TRANSFER_RELEASE, data, len); + } + return ret; } bool HID_::setup(USBSetup& setup) -- cgit v1.2.3-18-g5258