micropython-lib icon indicating copy to clipboard operation
micropython-lib copied to clipboard

Aioble - Discover duplicated or unrelated descriptors

Open steveli777 opened this issue 3 years ago • 1 comments

When I tried to discover the descriptors, I found the return descriptors are incorrect, I am based on the master branch. Attached is a modified "temp_client.py" file, I tried to get the descriptor on service (0x1805) and characteristic (0x2a2b). But I got many unrelated descriptors. For example:

  • 0x2803
  • 0x2800
  • 0x2a0f
  • 0x2803

test_aioble.zip

steveli777 avatar Feb 24 '22 23:02 steveli777

@steveli777 I have a fix for this which I will try and get into MicroPython v1.20.

The issue is in the way characteristic discovery works in the BLE spec. When you query for characteristics, it only gives you the start handle of each, and it's up to you to infer the end handle.

NimBLE does not do this for us (although btstack does), and in the case where you're not querying every characteristic (e.g. a uuid filter) you do not have enough information at the layer above to do this inference.

Fortunately (?) though, as per the spec, filtering-by-uuid is actually implemented entirely host-side (!!!) so there's actually no benefit to getting NimBLE to do the uuid filtering and we can do that in MicroPython's bindings instead and then implement the end-handle inference ourselves. This might actually reduce code size a bit.

The next step is to provide a way to pass this to Python, and I think what we'll do is replace the existing definition handle ("def_handle") that is passed to the IRQ and replace that with the end handle. (The definition handle is not useful for anything, none of our other APIs use it).

jimmo avatar Aug 05 '22 00:08 jimmo