Skip to content

Commit

Permalink
BLESession: Override unknown handle with known handle
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
kawasaki committed Nov 14, 2021
1 parent f8ce9e3 commit 80b99f8
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions pyscrlink/scratch_link.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,8 +424,13 @@ def add_handle(self, serviceId, charId, handle):
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)
Expand Down

0 comments on commit 80b99f8

Please sign in to comment.