From 9169ca6543f6c1d0f8df6adffded56f8faf812ff Mon Sep 17 00:00:00 2001 From: Jim Mussared Date: Fri, 23 Jul 2021 15:13:50 +1000 Subject: [PATCH] aioble: Add support for write-with-update. This allows a server to write a characteristic and automatically notify/indicate all subscribed clients. Signed-off-by: Jim Mussared --- micropython/bluetooth/aioble/README.md | 2 +- micropython/bluetooth/aioble/aioble/server.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/micropython/bluetooth/aioble/README.md b/micropython/bluetooth/aioble/README.md index 5d4208c0..dd2318ee 100644 --- a/micropython/bluetooth/aioble/README.md +++ b/micropython/bluetooth/aioble/README.md @@ -3,7 +3,7 @@ aioble This library provides an object-oriented, asyncio-based wrapper for MicroPython's [ubluetooth](https://docs.micropython.org/en/latest/library/ubluetooth.html) API. -**Note**: aioble requires MicroPython v1.15 or higher. +**Note**: aioble requires MicroPython v1.17 or higher. Features -------- diff --git a/micropython/bluetooth/aioble/aioble/server.py b/micropython/bluetooth/aioble/aioble/server.py index c037cc83..f87e4732 100644 --- a/micropython/bluetooth/aioble/aioble/server.py +++ b/micropython/bluetooth/aioble/aioble/server.py @@ -88,12 +88,12 @@ class BaseCharacteristic: else: return ble.gatts_read(self._value_handle) - # Write value to local db. - def write(self, data): + # Write value to local db, and optionally notify/indicate subscribers. + def write(self, data, send_update=False): if self._value_handle is None: self._initial = data else: - ble.gatts_write(self._value_handle, data) + ble.gatts_write(self._value_handle, data, send_update) # Wait for a write on this characteristic. Returns the connection that did # the write, or a tuple of (connection, value) if capture is enabled for