Skip to content

Commit 1a968db

Browse files
committed
aioble/device: Add DeviceConnection.indicate_service_changed().
1 parent cdd260f commit 1a968db

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

micropython/bluetooth/aioble/aioble/device.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,10 @@ async def exchange_mtu(self, mtu=None):
274274
await self._mtu_event.wait()
275275
return self.mtu
276276

277+
def indicate_service_changed(self, handle_start=None, handle_end=None):
278+
from .server import indicate_service_changed
279+
indicate_service_changed(self._conn_handle, handle_start, handle_end)
280+
277281
# Wait for a connection on an L2CAP connection-oriented-channel.
278282
async def l2cap_accept(self, psm, mtu, timeout_ms=None):
279283
from .l2cap import accept

micropython/bluetooth/aioble/aioble/server.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,3 +282,17 @@ def register_services(*services):
282282
for descriptor in characteristic.descriptors:
283283
descriptor._register(service_handles[n])
284284
n += 1
285+
286+
287+
# Send indication on the service changed characteristic.
288+
# Targets specific connection if provided, else sends to all connected and/or bonded devices.
289+
# Flags specific changed characteristics if provided else all will be indicated.
290+
def indicate_service_changed(conn_handle=None, changed: List[Characteristic] = None):
291+
handle_start = 0x0000
292+
handle_end = 0xFFFF
293+
if changed:
294+
print(_registered_characteristics)
295+
handles = sorted([c._value_handle for c in changed])
296+
handle_start = handles[0] - 1 # def handle is one less than value_handle
297+
handle_end = handles[-1]
298+
ble.gap_indicate_service_changed(conn_handle, handle_start, handle_end)

0 commit comments

Comments
 (0)
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