set shipment state

This commit is contained in:
Robert Martin
2020-01-28 23:53:03 +09:00
parent ed847601cf
commit 0aa9baf9db
3 changed files with 48 additions and 12 deletions
+15 -3
View File
@@ -31,8 +31,12 @@ class InputReport:
# battery level + connection info
self.data[3] = 0x8E
# ACK byte for subcmd reply
self.data[14] = 0x82
def set_ack(self, ack):
"""
ACK byte for subcmd reply
TODO
"""
self.data[14] = ack
def set_button_status(self):
"""
@@ -86,9 +90,14 @@ class InputReport:
def __bytes__(self):
return bytes(self.data)
def sub_0x8_shipment(self):
# reply to sub command ID
self.data[15] = 0x08
class SubCommand(Enum):
REQUEST_DEVICE_INFO = auto()
SET_SHIPMENT_STATE = auto()
NOT_IMPLEMENTED = auto()
@@ -100,8 +109,11 @@ class OutputReport:
def get_sub_command(self):
print('subcommand:', self.data[11])
if self.data[11] == 0x02:
sub_command_byte = self.data[11]
if sub_command_byte == 0x02:
return SubCommand.REQUEST_DEVICE_INFO
elif sub_command_byte == 0x08:
return SubCommand.SET_SHIPMENT_STATE
else:
return None