Heerkog / MicroPythonBLEHID

Human Interface Device (HID) over Bluetooth Low Energy (BLE) GATT library for MicroPython.
GNU General Public License v3.0
236 stars 32 forks source link

Incorrect descriptor flags? #19

Open QuirkyCort opened 3 months ago

QuirkyCort commented 3 months ago

In lines 836 to 837...

                (UUID(0x2A4D), F_READ_NOTIFY, ((UUID(0x2908), F_READ),)),
                (UUID(0x2A4D), F_READ_WRITE, ((UUID(0x2908), F_READ),)),     

...the descriptor flags are set to F_READ, which is equivalent to bluetooth.FLAG_READ, which is 0x02. But that's a descriptor, and value for a descriptor read flag should be 0x01 (see https://docs.silabs.com/bluetooth/6.0.0/bluetooth-stack-api/sl-bt-gattdb-characteristic-properties and https://docs.silabs.com/bluetooth/6.2.0/bluetooth-stack-api/sl-bt-gattdb-descriptor-properties for a list of the characteristic and descriptor flags).

I've tested on 1.19.1 and 1.23.0 (both on ESP32), and found that oddly enough, a descriptor flag of 0x01 (Read) works on 1.19.1 but not on 1.23.0, while a descriptor flag of 0x02 (Write) works on 1.23.0 but not on 1.19.1. Using 0x03 (read and write) works on both.

I don't know much about Bluetooth, so I can't even begin to guess why this is so.

Heerkog commented 3 months ago

You're correct. I found the same behavior on Micropython v1.23 and hence changed it to a 'faulty' but working value.

I will open an issue in the Micropython repository. Thanks!

Heerkog commented 3 months ago

https://github.com/micropython/micropython/issues/15627

Heerkog commented 2 months ago

I have updated the descriptor to ATT_F_READ_WRITE to be more correct.