bluekitchen / btstack

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

hid_host: allow MAX_ATTRIBUTE_VALUE_SIZE to be configurable/dynamic #534

Closed shuffle2 closed 1 year ago

shuffle2 commented 1 year ago

Is your feature request related to a problem? Please describe. I'm trying to use hid_host to connect to a device which has a large HID Report Descriptor ("report map") in a SDP attribute. It is larger than the currently hardcoded max size in btstack of 300 bytes.

Describe the solution you'd like MAX_ATTRIBUTE_VALUE_SIZE should be configurable (as other sizes throughout btstack already are), possibly optionally supporting dynamic allocations if HAVE_MALLOC is defined.

Describe alternatives you've considered The current way to fix this error is to manually edit btstack source code to change the value of MAX_ATTRIBUTE_VALUE_SIZE.

An alternative fix could be to just use a new, higher constant size value. However it doesn't seem like a good solution.

Another solution could be to allow the application to directly control/own this buffer in some way, instead of putting the control within hid_host at all.

mringwal commented 1 year ago

Good point, too. The SDP parser supports arbitrary chunking and the hid descriptor ends up in the larger/user provided HID descriptor storage. So there's no technically reason to limit it by MAX_ATTRIBUTE_VALUE_SIZ. We'll have a look into this.

mringwal commented 1 year ago

Please have a look at the latest commits on develop. The state machine isn't trivial, but the HID Descriptor is not limited by a fixed array anymore.

shuffle2 commented 1 year ago

Thanks! The new logic looks good to me. I did leave some comments though