Skip to content

Commit 8c30638

Browse files
authored
Fix NimBLEHIDDevice output report returning incorrect characteristic. (#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.
1 parent 87a710c commit 8c30638

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/NimBLEHIDDevice.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,11 @@ NimBLECharacteristic* NimBLEHIDDevice::getInputReport(uint8_t reportId) {
176176
* @param [in] reportId Output report ID, the same as in report map for output object related to the characteristic.
177177
* @return A pointer to the output report characteristic.
178178
* @details This will create the characteristic if not already created.
179+
* @note The output report characteristic is optional and should only be created after the input report characteristic.
179180
*/
180181
NimBLECharacteristic* NimBLEHIDDevice::getOutputReport(uint8_t reportId) {
181-
NimBLECharacteristic* outputReportChr = m_hidSvc->getCharacteristic(inputReportChrUuid);
182+
// Same uuid as input so this needs to be the second instance
183+
NimBLECharacteristic* outputReportChr = m_hidSvc->getCharacteristic(inputReportChrUuid, 1);
182184
if (outputReportChr == nullptr) {
183185
outputReportChr =
184186
m_hidSvc->createCharacteristic(inputReportChrUuid,

0 commit comments

Comments
 (0)