diff --git a/micropython/bluetooth/aioble/aioble/device.py b/micropython/bluetooth/aioble/aioble/device.py index 93819bc1e..85d5521e0 100644 --- a/micropython/bluetooth/aioble/aioble/device.py +++ b/micropython/bluetooth/aioble/aioble/device.py @@ -284,6 +284,10 @@ async def exchange_mtu(self, mtu=None, timeout_ms=1000): await self._mtu_event.wait() return self.mtu + def indicate_service_changed(self, changed: List[Characteristic] = None): + from .server import indicate_service_changed + indicate_service_changed(self._conn_handle, changed) + # Wait for a connection on an L2CAP connection-oriented-channel. async def l2cap_accept(self, psm, mtu, timeout_ms=None): from .l2cap import accept diff --git a/micropython/bluetooth/aioble/aioble/server.py b/micropython/bluetooth/aioble/aioble/server.py index 5d5d7399b..229d6292b 100644 --- a/micropython/bluetooth/aioble/aioble/server.py +++ b/micropython/bluetooth/aioble/aioble/server.py @@ -338,3 +338,17 @@ def register_services(*services): for descriptor in characteristic.descriptors: descriptor._register(service_handles[n]) n += 1 + + +# Send indication on the service changed characteristic. +# Targets specific connection if provided, else sends to all connected and/or bonded devices. +# Flags specific changed characteristics if provided else all will be indicated. +def indicate_service_changed(conn_handle=None, changed: List[Characteristic] = None): + handle_start = 0x0000 + handle_end = 0xFFFF + if changed: + print(_registered_characteristics) + handles = sorted([c._value_handle for c in changed]) + handle_start = handles[0] - 1 # def handle is one less than value_handle + handle_end = handles[-1] + ble.gap_indicate_service_changed(conn_handle, handle_start, handle_end) pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy