aboutsummaryrefslogtreecommitdiff
path: root/libraries
diff options
context:
space:
mode:
authorNico <NicoHood@users.noreply.github.com>2015-10-27 08:06:21 +0100
committerCristian Maglie <c.maglie@arduino.cc>2015-10-30 12:58:14 +0100
commit7d012c11b8318be19b13acd483fdea81ee3ce540 (patch)
tree15a610813bab7f612821febb9147dcdea1a99655 /libraries
parent1f318b08d4caf73f2b31faa42ef54de33b046f8e (diff)
[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.
Diffstat (limited to 'libraries')
-rw-r--r--libraries/HID/HID.cpp9
1 files changed, 5 insertions, 4 deletions
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)