bluekitchen / btstack

Dual-mode Bluetooth stack, with small memory footprint.
http://bluekitchen-gmbh.com
Other
1.74k stars 618 forks source link

Can't find a way to listen for HID reports in BLE device application #521

Closed mohamed-AARAB closed 1 year ago

mohamed-AARAB commented 1 year ago

I seem to not find an event (to use in the packet handler) related to receiving an HID report from the host as BLE HID device.

I can send the HID reports to the host. But I'm also trying to receive the HID reports from the host to then send them over USB to the device, which is a keyboard.

It seems counterintuitive if there is another way of doing it other than an event in the packet handler.

mringwal commented 1 year ago

Hi Mohamed. The Get Report and Set Report functionality in HID over GATT (HOG) isn't implemented currently. Yes, the stack could emit events for Set Report on Output or Feature reports. Our Classic HID implementation has callbacks for set/get report, this would be other option.

Adding these features is on our TODO list. Could you use Classic HID for now? Please get in touch directly if this is for a commercial project,

mohamed-AARAB commented 1 year ago

Thanks for the reply.

Answering your question, I started with HID over Bluetooth classic, but I switched afterwards to BLE (HID over GATT) to benefit from the power saving aspect of it.

I wonder if there is a low level way of receiving those HID reports.

mringwal commented 1 year ago

Do you have any numbers on energy for LE vs. Classic? Using sniff subrating, classic shouldn't be that bad, my old Apple Keyboard did run for months on 2 x AA batteries.

If you really want to, you can hack the hids_device.c implementation and just forward the Set Report there somehow. We'll add it eventually.

mohamed-AARAB commented 1 year ago

I don't have numbers on the energy consumption between Bluetooth LE and classic.

But I think I will go back to using Bluetooth classic using sniff subrating as you said, keeping an eye on the BLE implementation on your library.

mohamed-AARAB commented 1 year ago

Thanks a lot, I really appreciate your help.