BLESession: Override unknown handle with known handle

Unknown handle "13" was recorded in debug log for the Git Hub issue #26.
As a debug trial, replace the unknown handle with the known handle.

Signed-off-by: Shin'ichiro Kawasaki <kawasaki@juno.dti.ne.jp>
This commit is contained in:
Shin'ichiro Kawasaki
2021-06-20 21:31:18 +09:00
parent f8ce9e3089
commit 80b99f84a1

View File

@@ -424,8 +424,13 @@ class BLESession(Session):
def handleNotification(self, handle, data):
logger.debug(f"BLE notification: {handle} {data}")
if handle not in self.handles:
logger.error(f"Notification with unknown {handle}")
return
logger.error(f"Notification with unknown handle: {handle}")
keys = list(self.handles.keys())
if keys and len(keys) == 1:
logger.debug(f"Debug: override {handle} with {keys[0]}")
handle = keys[0]
else:
return
params = self.handles[handle].copy()
params['message'] = base64.standard_b64encode(data).decode('ascii')
self.session.notify('characteristicDidChange', params)