From 78900afca5ebf3d9096cd9725d235e7d254c5788 Mon Sep 17 00:00:00 2001 From: Daniel Flanagan <37907774+FlantasticDan@users.noreply.github.com> Date: Wed, 15 Feb 2023 22:51:24 -0800 Subject: [PATCH] aioble: Add short name support to scan results. Signed-off-by: Damien George --- micropython/bluetooth/aioble-central/manifest.py | 2 +- micropython/bluetooth/aioble/aioble/central.py | 5 +++-- micropython/bluetooth/aioble/manifest.py | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/micropython/bluetooth/aioble-central/manifest.py b/micropython/bluetooth/aioble-central/manifest.py index beec5046..128c9064 100644 --- a/micropython/bluetooth/aioble-central/manifest.py +++ b/micropython/bluetooth/aioble-central/manifest.py @@ -1,4 +1,4 @@ -metadata(version="0.2.0") +metadata(version="0.2.1") require("aioble-core") diff --git a/micropython/bluetooth/aioble/aioble/central.py b/micropython/bluetooth/aioble/aioble/central.py index 46da907a..adfc9729 100644 --- a/micropython/bluetooth/aioble/aioble/central.py +++ b/micropython/bluetooth/aioble/aioble/central.py @@ -33,6 +33,7 @@ _SCAN_RSP = const(4) _ADV_TYPE_FLAGS = const(0x01) _ADV_TYPE_NAME = const(0x09) +_ADV_TYPE_SHORT_NAME = const(0x08) _ADV_TYPE_UUID16_INCOMPLETE = const(0x2) _ADV_TYPE_UUID16_COMPLETE = const(0x3) _ADV_TYPE_UUID32_INCOMPLETE = const(0x4) @@ -187,9 +188,9 @@ class ScanResult: yield payload[i + 2 : i + payload[i] + 1] i += 1 + payload[i] - # Returns the value of the advertised name, otherwise empty string. + # Returns the value of the complete (or shortened) advertised name, if available. def name(self): - for n in self._decode_field(_ADV_TYPE_NAME): + for n in self._decode_field(_ADV_TYPE_NAME, _ADV_TYPE_SHORT_NAME): return str(n, "utf-8") if n else "" # Generator that enumerates the service UUIDs that are advertised. diff --git a/micropython/bluetooth/aioble/manifest.py b/micropython/bluetooth/aioble/manifest.py index a1463ca0..071e8181 100644 --- a/micropython/bluetooth/aioble/manifest.py +++ b/micropython/bluetooth/aioble/manifest.py @@ -3,7 +3,7 @@ # code. This allows (for development purposes) all the files to live in the # one directory. -metadata(version="0.2.0") +metadata(version="0.2.1") # Default installation gives you everything. Install the individual # components (or a combination of them) if you want a more minimal install.