From 1b6e6692c0ee84f9c33230ac42d6fe7f905d5a4c Mon Sep 17 00:00:00 2001 From: Daniel Pavel Date: Mon, 3 Dec 2012 15:07:07 +0200 Subject: [PATCH] maintain notification flags when pairing in command-line --- app/solaar_cli.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/solaar_cli.py b/app/solaar_cli.py index f6ea5705..390cdf7a 100644 --- a/app/solaar_cli.py +++ b/app/solaar_cli.py @@ -184,7 +184,12 @@ def pair_device(receiver, args): from logitech.unifying_receiver import base base.events_hook = _events_handler - receiver.enable_notifications() + # check if it's necessary to set the notification flags + notifications = receiver.request(0x8100) + if notifications: + notifications = ord(notifications[:1]) + ord(notifications[1:2]) + ord(notifications[2:3]) + if not notifications: + receiver.enable_notifications() receiver.set_lock(False, timeout=20) print ("Pairing: turn your new device on (timing out in 20 seconds).") @@ -195,8 +200,8 @@ def pair_device(receiver, args): if event: _events_handler(event) - receiver.set_lock() - receiver.enable_notifications(False) + if not notifications: + receiver.enable_notifications(False) base.events_hook = None if r_status.new_device: