Andrew Leech 2025-05-12 05:53:39 +00:00 zatwierdzone przez GitHub
commit bb6b75ee6f
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: B5690EEEBB952194
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)