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 <kawasaki@juno.dti.ne.jp>
This commit is contained in:
Shin'ichiro Kawasaki
2020-05-16 17:09:54 +09:00
parent 1ca2e910fb
commit 6fdc8dcbb3

View File

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