examples/bluetooth/ble_advertising.py: Fix decoding UUIDs.
The UUID32 case was incorrect: first, the "<d" should have been "<I", and second, the UUID constructor treats integer arguments as UUID16. So this UUID32 case needs to pass in the actual data bytes. And then it's simpler to just make all cases pass in the data bytes. Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
parent
6a8c45b6c4
commit
a9b038a57e
1 changed files with 3 additions and 6 deletions
|
|
@ -79,11 +79,8 @@ def decode_name(payload):
|
|||
|
||||
def decode_services(payload):
|
||||
services = []
|
||||
for u in decode_field(payload, _ADV_TYPE_UUID16_COMPLETE):
|
||||
services.append(bluetooth.UUID(struct.unpack("<h", u)[0]))
|
||||
for u in decode_field(payload, _ADV_TYPE_UUID32_COMPLETE):
|
||||
services.append(bluetooth.UUID(struct.unpack("<d", u)[0]))
|
||||
for u in decode_field(payload, _ADV_TYPE_UUID128_COMPLETE):
|
||||
for code in (_ADV_TYPE_UUID16_COMPLETE, _ADV_TYPE_UUID32_COMPLETE, _ADV_TYPE_UUID128_COMPLETE):
|
||||
for u in decode_field(payload, code):
|
||||
services.append(bluetooth.UUID(u))
|
||||
return services
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue