Remove message type from device properties message

M1nd3r/thp5
M1nd3r 2 months ago
parent 3ecb8d85a7
commit 480bd0bc44

@ -2,19 +2,30 @@ from trezor import protobuf
class Message:
def __init__(
self,
message_data: bytes,
) -> None:
self.data = message_data
def to_bytes(self):
return self.data
class MessageWithType(Message):
def __init__(
self,
message_type: int,
message_data: bytes,
) -> None:
self.type = message_type
self.data = message_data
super().__init__(message_data)
def to_bytes(self):
return self.type.to_bytes(2, "big") + self.data
class MessageWithId(Message):
class MessageWithId(MessageWithType):
def __init__(
self,
message_type: int,

@ -6,7 +6,8 @@ def getPacketHandler(
channel: ChannelContext, packet: bytes
): # TODO is the packet bytes or BufferType?
if channel.get_management_session_state is ChannelState.TH1: # TODO is correct
return handler_TH_1
# return handler_TH_1
pass
def handler_TH_1(packet):

@ -60,7 +60,7 @@ _ERROR_UNALLOCATED_SESSION = (
def get_device_properties() -> Message:
return Message(1000, _ENCODED_PROTOBUF_DEVICE_PROPERTIES)
return Message(_ENCODED_PROTOBUF_DEVICE_PROPERTIES)
def get_channel_allocation_response(nonce: bytes, new_cid: int) -> bytes:

Loading…
Cancel
Save