-
-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Creating an HID output report doesn't work #279
Comments
@afpineda Any thoughts? |
Hi, @TheCrypt0. This is the way the API is intended to work: documented here.
You can not assign the same report ID to two different reports (input and output).
If you need to read and write from/to the very same report, you should create it as a feature report. |
Let me rectify my previous answer in some way.
Even if that is true, we should not judge how the library is used. |
Thank you for the reply! So saying:
Means the BLE HID standard doesn't "allow" it to happen and we should have 2 report IDs, one for sending the keystrokes and the other to receive back the LEDs statues? Please correct me if I'm wrong, I'm reading a book about BLE but I'm far from what you guys know. Is it possible that the ESP32-BLE-CompositeHID project is getting this wrong? (Btw happy new year 🎉 to y'all) |
Yes: create an input report, let' say ID 1, for sending the keystrokes, and an output report, let's say ID 2, to receive LED states.
Yes, but in an indirect way. You cannot declare a report ID twice in the HID descriptor. You cannot declare a single report as both input and output. If your device was working prior to version 2.1.0, please post your HID descriptor. Maybe I am wrong. Check your HID descriptor first. I recommend to use waratah to avoid mistakes. Additional note: you could also inspect the HID descriptor from a commercial keyboard to learn how it works. |
After looking at the hid descriptor you pointed, I definetly was wrong. |
I have submitted a PR to the h2zero/NimBLE-Arduino project. |
I tested your PR in a local project but unfortunately it doesn't work on my side. After the first call to I can confirm and tested that the function I managed to make it work with this ugly hack: NimBLECharacteristic* NimBLEHIDDevice::getOutputReport(uint8_t reportId) {
// NimBLECharacteristic* outputReportChr = locateReportCharacteristicByIdAndType(reportId, 0x02);
// UGLY HACK: force outputReportChr to nullptr
NimBLECharacteristic* outputReportChr = nullptr;
if (outputReportChr == nullptr) {
outputReportChr =
m_hidSvc->createCharacteristic(inputReportChrUuid,
NIMBLE_PROPERTY::READ | NIMBLE_PROPERTY::WRITE | NIMBLE_PROPERTY::WRITE_NR |
NIMBLE_PROPERTY::READ_ENC | NIMBLE_PROPERTY::WRITE_ENC);
NimBLEDescriptor* outputReportDsc = outputReportChr->createDescriptor(
featureReportDscUuid,
NIMBLE_PROPERTY::READ | NIMBLE_PROPERTY::WRITE | NIMBLE_PROPERTY::READ_ENC | NIMBLE_PROPERTY::WRITE_ENC);
uint8_t desc1_val[] = {reportId, 0x02};
outputReportDsc->setValue(desc1_val, 2);
}
return outputReportChr;
} // getOutputReport Hope this helps. (btw: I checked my Logitech keyboard and I can confirm it has both the output and input report in the same Report ID) NVM, found the issue in NimBLECharacteristic* NimBLEHIDDevice::locateReportCharacteristicByIdAndType(uint8_t reportId, uint8_t reportType) {
NimBLECharacteristic* candidate = m_hidSvc->getCharacteristic(inputReportChrUuid, 0);
for (uint16_t i = 1; (candidate != nullptr) && (i != 0); i++) {
NimBLEDescriptor* dsc = candidate->getDescriptorByUUID(featureReportDscUuid);
NimBLEAttValue desc1_val_att = dsc->getValue();
const uint8_t* desc1_val = desc1_val_att.data();
//reportType = desc1_val[1]; <----- REMOVE THIS
if ((desc1_val[0] == reportId) && (desc1_val[1] == reportType)) return candidate;
candidate = m_hidSvc->getCharacteristic(inputReportChrUuid, i);
}
return nullptr;
} |
Yes. It is. We lack a set of test units. |
@TheCrypt0 This should be resolved in aae70df please close this issue if it is resolved. |
Hi,
I have a firmware that should emulate a BLE keyboard (and receive back the LEDs status for caps lock, num lock, etc.) but after updating to version
2.0.2
, I cannot attach the callbacks to the output report anymore becausegetOutputReport
returnsnullptr
.The setup is very similar to this (taken from https://github.dev/Mystfit/ESP32-BLE-CompositeHID ):
By debugging the code, it's clear where the code fails:
Here's how the same function was in version
1.4.x
.Do you know if this is something fixable from my part or it needs an update to the library? Thank you, I really appreciate your support.
The text was updated successfully, but these errors were encountered: