From cb066ff5682fa980c5272e96bf44b9df2daba702 Mon Sep 17 00:00:00 2001 From: Fredrik Orderud Date: Sun, 12 Jan 2025 19:07:49 +0100 Subject: [PATCH] Change SendReport & sendDate "id" values from 16 to 8bits The underlying HID_::sendReport method is anyhow only transmitting the first byte of the "id" field, so the content of the second byte is currently ignored. One can then just as well change the "id" argument type from 16 to 8bits. Update the HIDPowerDevice_::sendDate the same way, since it's just passing on the "id" argument to HID_::sendReport. --- src/HID/HID.cpp | 2 +- src/HID/HID.h | 2 +- src/HIDPowerDevice.cpp | 4 ++-- src/HIDPowerDevice.h | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/HID/HID.cpp b/src/HID/HID.cpp index e9b969a..54e8d6f 100644 --- a/src/HID/HID.cpp +++ b/src/HID/HID.cpp @@ -166,7 +166,7 @@ bool HID_::LockFeature(uint16_t id, bool lock) { } -int HID_::SendReport(uint16_t id, const void* data, int len) +int HID_::SendReport(uint8_t id, const void* data, int len) { auto ret = USB_Send(HID_TX, &id, 1); if (ret < 0) return ret; diff --git a/src/HID/HID.h b/src/HID/HID.h index bb55aa2..379e506 100644 --- a/src/HID/HID.h +++ b/src/HID/HID.h @@ -115,7 +115,7 @@ class HID_ : public PluggableUSBModule public: HID_(void); int begin(void); - int SendReport(uint16_t id, const void* data, int len); + int SendReport(uint8_t id, const void* data, int len); int SetFeature(uint16_t id, const void* data, int len); bool LockFeature(uint16_t id, bool lock); diff --git a/src/HIDPowerDevice.cpp b/src/HIDPowerDevice.cpp index 5217e04..66c96df 100755 --- a/src/HIDPowerDevice.cpp +++ b/src/HIDPowerDevice.cpp @@ -249,12 +249,12 @@ void HIDPowerDevice_::setSerial(const char* s) { void HIDPowerDevice_::end(void) { } -int HIDPowerDevice_::sendDate(uint16_t id, uint16_t year, uint8_t month, uint8_t day) { +int HIDPowerDevice_::sendDate(uint8_t id, uint16_t year, uint8_t month, uint8_t day) { uint16_t bval = (year - 1980)*512 + month * 32 + day; return HID().SendReport(id, &bval, sizeof (bval)); } -int HIDPowerDevice_::sendReport(uint16_t id, const void* bval, int len) { +int HIDPowerDevice_::sendReport(uint8_t id, const void* bval, int len) { return HID().SendReport(id, bval, len); } diff --git a/src/HIDPowerDevice.h b/src/HIDPowerDevice.h index 888b860..e4be454 100755 --- a/src/HIDPowerDevice.h +++ b/src/HIDPowerDevice.h @@ -121,8 +121,8 @@ class HIDPowerDevice_ { void end(void); - int sendDate(uint16_t id, uint16_t year, uint8_t month, uint8_t day); - int sendReport(uint16_t id, const void* bval, int len); + int sendDate(uint8_t id, uint16_t year, uint8_t month, uint8_t day); + int sendReport(uint8_t id, const void* bval, int len); int setFeature(uint16_t id, const void* data, int len);