aioble/device: Add DeviceConnection.indicate_service_changed().

pull/467/head
Andrew Leech 2021-10-08 17:06:21 +11:00
rodzic 5b496e944e
commit 484c5ef1de
2 zmienionych plików z 18 dodań i 0 usunięć

Wyświetl plik

@ -284,6 +284,10 @@ class DeviceConnection:
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

Wyświetl plik

@ -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)