diff options
author | Damien George <damien@micropython.org> | 2025-07-20 21:38:03 +1000 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2025-07-31 11:02:41 +1000 |
commit | a9b038a57e2ca730dd95e79fc89491d0d1154e6e (patch) | |
tree | d735f0b885b7da0b75dbf072b070099b62254644 | |
parent | 6a8c45b6c4683fa2dc68cab62219b0edad4dd15d (diff) |
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>
-rw-r--r-- | examples/bluetooth/ble_advertising.py | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/examples/bluetooth/ble_advertising.py b/examples/bluetooth/ble_advertising.py index 2fe17d640..f0b97d7f5 100644 --- a/examples/bluetooth/ble_advertising.py +++ b/examples/bluetooth/ble_advertising.py @@ -79,12 +79,9 @@ 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): - services.append(bluetooth.UUID(u)) + 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 |