From 6fdc8dcbb3ee14bbbb105c54d7e9263c5d1ae890 Mon Sep 17 00:00:00 2001 From: Shin'ichiro Kawasaki Date: Sat, 16 May 2020 17:09:54 +0900 Subject: [PATCH] BLESession.handle_request: Fix startNotification KeyError The value 'startNotification' is optional for the "read" request. However, bluepy-scratch-link expects Scratch always set the value in the requests. This may cause KeyError. Signed-off-by: Shin'ichiro Kawasaki --- scratch_link.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scratch_link.py b/scratch_link.py index 9cb541a..d39066a 100755 --- a/scratch_link.py +++ b/scratch_link.py @@ -512,7 +512,7 @@ class BLESession(Session): self.lock.release() message = base64.standard_b64encode(b).decode('ascii') res['result'] = { 'message': message, 'encode': 'base64' } - if params['startNotifications'] == True: + if params.get('startNotifications') == True: logger.debug(f"start notification for {chara_id}") service = self.perip.getServiceByUUID(UUID(service_id)) chas = service.getCharacteristics(forUUID=chara_id)