protocol: handle error code 0x7
Deprecated, but still exists on the Slate so let's wrap the connect attempt so we throw the right error. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
02ca3a7058
commit
c466c7d431
|
@ -436,6 +436,7 @@ class DeviceError(ProtocolError):
|
||||||
INVALID_STATE = 0x2
|
INVALID_STATE = 0x2
|
||||||
READ_ONLY_PARAM = 0x3
|
READ_ONLY_PARAM = 0x3
|
||||||
COMMAND_NOT_SUPPORTED = 0x4
|
COMMAND_NOT_SUPPORTED = 0x4
|
||||||
|
AUTHORIZATION_ERROR = 0x7
|
||||||
|
|
||||||
def __init__(self, errorcode, *args, **kwargs):
|
def __init__(self, errorcode, *args, **kwargs):
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
@ -611,6 +612,28 @@ class MsgConnectSpark(Msg):
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
|
|
||||||
|
class MsgConnectSlate(Msg):
|
||||||
|
interaction = Interactions.CONNECT
|
||||||
|
opcode = 0xe6
|
||||||
|
protocol = ProtocolVersion.SLATE
|
||||||
|
|
||||||
|
def __init__(self, uuid, *args, **kwargs):
|
||||||
|
super().__init__(*args, **kwargs)
|
||||||
|
self.uuid = uuid
|
||||||
|
self.args = [int(i) for i in binascii.unhexlify(uuid)]
|
||||||
|
if len(self.args) != 6:
|
||||||
|
raise ValueError('UUID must be 6 bytes long')
|
||||||
|
|
||||||
|
def _handle_reply(self, reply):
|
||||||
|
try:
|
||||||
|
super()._handle_reply(reply)
|
||||||
|
except DeviceError as e:
|
||||||
|
# Same as spark but we get 0x7 as error code
|
||||||
|
if e.errorcode == DeviceError.ErrorCode.AUTHORIZATION_ERROR:
|
||||||
|
raise AuthorizationError()
|
||||||
|
raise e
|
||||||
|
|
||||||
|
|
||||||
class MsgGetName(Msg):
|
class MsgGetName(Msg):
|
||||||
'''
|
'''
|
||||||
.. attribute:: name
|
.. attribute:: name
|
||||||
|
|
Loading…
Reference in New Issue