From f21af42131082c17ea2da5dddf36cdd7efab8ade Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Thu, 22 Aug 2019 11:51:38 +1000 Subject: [PATCH] protocol: on the spark treat a general error during connect as wrong uuid Signed-off-by: Peter Hutterer --- tuhi/protocol.py | 8 +++++++- tuhi/wacom.py | 9 +++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/tuhi/protocol.py b/tuhi/protocol.py index 887b08d..24f0e52 100644 --- a/tuhi/protocol.py +++ b/tuhi/protocol.py @@ -602,7 +602,13 @@ class MsgConnectSpark(Msg): if len(self.args) != 6: raise ValueError('UUID must be 6 bytes long') - # uses the default 0xb3 handler + def _handle_reply(self, reply): + try: + super()._handle_reply(reply) + except DeviceError as e: + if e.errorcode == DeviceError.ErrorCode.GENERAL_ERROR: + raise AuthorizationError() + raise e class MsgGetName(Msg): diff --git a/tuhi/wacom.py b/tuhi/wacom.py index a821c42..8b6db19 100644 --- a/tuhi/wacom.py +++ b/tuhi/wacom.py @@ -395,12 +395,9 @@ class WacomRegisterHelper(WacomProtocolLowLevelComm): # expected try: self.p.execute(Interactions.CONNECT, uuid) - except tuhi.protocol.DeviceError as e: - if e.errorcode == tuhi.protocol.DeviceError.ErrorCode.GENERAL_ERROR: - # this is expected - pass - else: - raise e + except AuthorizationError: + # this is expected + pass # The "press button now command" on the spark self.p.execute(Interactions.REGISTER_PRESS_BUTTON)