Skip to content

Commit

Permalink
Fix NimBLEHIDDevice output report returning incorrect characteristic. (
Browse files Browse the repository at this point in the history
…#805)

The input and output report characteristics share the same UUID and the `getOutputReport` was returning the input report characteristic.
This change will return the correct characteristic by finding it with the index parameter.
  • Loading branch information
h2zero authored Dec 15, 2024
1 parent 87a710c commit 8c30638
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/NimBLEHIDDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,11 @@ NimBLECharacteristic* NimBLEHIDDevice::getInputReport(uint8_t reportId) {
* @param [in] reportId Output report ID, the same as in report map for output object related to the characteristic.
* @return A pointer to the output report characteristic.
* @details This will create the characteristic if not already created.
* @note The output report characteristic is optional and should only be created after the input report characteristic.
*/
NimBLECharacteristic* NimBLEHIDDevice::getOutputReport(uint8_t reportId) {
NimBLECharacteristic* outputReportChr = m_hidSvc->getCharacteristic(inputReportChrUuid);
// Same uuid as input so this needs to be the second instance
NimBLECharacteristic* outputReportChr = m_hidSvc->getCharacteristic(inputReportChrUuid, 1);
if (outputReportChr == nullptr) {
outputReportChr =
m_hidSvc->createCharacteristic(inputReportChrUuid,
Expand Down

0 comments on commit 8c30638

Please sign in to comment.