Skip to content

Commit 7d012c1

Browse files
NicoHoodcmaglie
authored andcommitted
[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.
1 parent 1f318b0 commit 7d012c1

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

libraries/HID/HID.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,11 @@ void HID_::AppendDescriptor(HIDSubDescriptor *node)
8888

8989
int HID_::SendReport(uint8_t id, const void* data, int len)
9090
{
91-
int ret = 0;
92-
ret += USB_Send(pluggedEndpoint, &id, 1);
93-
ret += USB_Send(pluggedEndpoint | TRANSFER_RELEASE, data, len);
94-
return ret;
91+
auto ret = USB_Send(pluggedEndpoint, &id, 1);
92+
if(ret >= 0){
93+
ret += USB_Send(pluggedEndpoint | TRANSFER_RELEASE, data, len);
94+
}
95+
return ret;
9596
}
9697

9798
bool HID_::setup(USBSetup& setup)

0 commit comments

Comments
 (0)