From c113611765278b2fc8dcf8b2f2c3513b35a69b39 Mon Sep 17 00:00:00 2001 From: Jim Mussared Date: Wed, 12 Apr 2023 00:48:31 +1000 Subject: [PATCH] aioble: Fix descriptor flag handling. Removes the workaround for micropython/issues/6864. Sets the default flags for discovered descriptors to be WRITE, so that d.write() will implicitly set response=True. Signed-off-by: Jim Mussared --- micropython/bluetooth/aioble-client/manifest.py | 2 +- micropython/bluetooth/aioble-server/manifest.py | 2 +- micropython/bluetooth/aioble/aioble/client.py | 2 +- micropython/bluetooth/aioble/aioble/server.py | 8 ++------ micropython/bluetooth/aioble/manifest.py | 2 +- 5 files changed, 6 insertions(+), 10 deletions(-) diff --git a/micropython/bluetooth/aioble-client/manifest.py b/micropython/bluetooth/aioble-client/manifest.py index eb79c6d33..163cbe23d 100644 --- a/micropython/bluetooth/aioble-client/manifest.py +++ b/micropython/bluetooth/aioble-client/manifest.py @@ -1,4 +1,4 @@ -metadata(version="0.2.0") +metadata(version="0.3.0") require("aioble-core") diff --git a/micropython/bluetooth/aioble-server/manifest.py b/micropython/bluetooth/aioble-server/manifest.py index a9676204d..fc51154f8 100644 --- a/micropython/bluetooth/aioble-server/manifest.py +++ b/micropython/bluetooth/aioble-server/manifest.py @@ -1,4 +1,4 @@ -metadata(version="0.2.0") +metadata(version="0.3.0") require("aioble-core") diff --git a/micropython/bluetooth/aioble/aioble/client.py b/micropython/bluetooth/aioble/aioble/client.py index a205e0a3b..ccde03527 100644 --- a/micropython/bluetooth/aioble/aioble/client.py +++ b/micropython/bluetooth/aioble/aioble/client.py @@ -439,7 +439,7 @@ class ClientDescriptor(BaseClientCharacteristic): def __init__(self, characteristic, dsc_handle, uuid): self.characteristic = characteristic - super().__init__(dsc_handle, _FLAG_READ | _FLAG_WRITE_NO_RESPONSE, uuid) + super().__init__(dsc_handle, _FLAG_READ | _FLAG_WRITE, uuid) def __str__(self): return "Descriptor: {} {} {}".format(self._value_handle, self.properties, self.uuid) diff --git a/micropython/bluetooth/aioble/aioble/server.py b/micropython/bluetooth/aioble/aioble/server.py index 76374a36d..b6cc4a3c2 100644 --- a/micropython/bluetooth/aioble/aioble/server.py +++ b/micropython/bluetooth/aioble/aioble/server.py @@ -38,9 +38,6 @@ _FLAG_WRITE_CAPTURE = const(0x10000) -_FLAG_DESC_READ = const(1) -_FLAG_DESC_WRITE = const(2) - _WRITE_CAPTURE_QUEUE_LIMIT = const(10) @@ -307,14 +304,13 @@ class Descriptor(BaseCharacteristic): def __init__(self, characteristic, uuid, read=False, write=False, initial=None): characteristic.descriptors.append(self) - # Workaround for https://github.com/micropython/micropython/issues/6864 flags = 0 if read: - flags |= _FLAG_DESC_READ + flags |= _FLAG_READ if write: + flags |= _FLAG_WRITE self._write_event = asyncio.ThreadSafeFlag() self._write_data = None - flags |= _FLAG_DESC_WRITE self.uuid = uuid self.flags = flags diff --git a/micropython/bluetooth/aioble/manifest.py b/micropython/bluetooth/aioble/manifest.py index 071e81814..4c0edbb57 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.1") +metadata(version="0.3.1") # Default installation gives you everything. Install the individual # components (or a combination of them) if you want a more minimal install.