1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-18 21:48:13 +00:00

chore(core): remove unused session_id from codec_v1

[no changelog]
This commit is contained in:
M1nd3r 2024-11-14 15:42:46 +01:00 committed by Petr Sedláček
parent cce2335965
commit e434aabc77
4 changed files with 10 additions and 18 deletions

View File

@ -360,7 +360,7 @@ if __debug__:
global DEBUG_CONTEXT global DEBUG_CONTEXT
DEBUG_CONTEXT = ctx = context.Context(iface, 0, WIRE_BUFFER_DEBUG) DEBUG_CONTEXT = ctx = context.Context(iface, WIRE_BUFFER_DEBUG)
if storage.layout_watcher: if storage.layout_watcher:
try: try:
@ -385,9 +385,8 @@ if __debug__:
msg_type = f"{msg.type} - unknown message type" msg_type = f"{msg.type} - unknown message type"
log.debug( log.debug(
__name__, __name__,
"%s:%x receive: <%s>", "%d receive: <%s>",
ctx.iface.iface_num(), ctx.iface.iface_num(),
ctx.sid,
msg_type, msg_type,
) )

View File

@ -56,7 +56,7 @@ EXPERIMENTAL_ENABLED = False
def setup(iface: WireInterface) -> None: def setup(iface: WireInterface) -> None:
"""Initialize the wire stack on passed USB interface.""" """Initialize the wire stack on passed USB interface."""
loop.schedule(handle_session(iface, codec_v1.SESSION_ID)) loop.schedule(handle_session(iface))
def wrap_protobuf_load( def wrap_protobuf_load(
@ -109,9 +109,8 @@ async def _handle_single_message(ctx: context.Context, msg: codec_v1.Message) ->
msg_type = f"{msg.type} - unknown message type" msg_type = f"{msg.type} - unknown message type"
log.debug( log.debug(
__name__, __name__,
"%s:%x receive: <%s>", "%d receive: <%s>",
ctx.iface.iface_num(), ctx.iface.iface_num(),
ctx.sid,
msg_type, msg_type,
) )
@ -190,8 +189,8 @@ async def _handle_single_message(ctx: context.Context, msg: codec_v1.Message) ->
return msg.type in AVOID_RESTARTING_FOR return msg.type in AVOID_RESTARTING_FOR
async def handle_session(iface: WireInterface, session_id: int) -> None: async def handle_session(iface: WireInterface) -> None:
ctx = context.Context(iface, session_id, WIRE_BUFFER) ctx = context.Context(iface, WIRE_BUFFER)
next_msg: codec_v1.Message | None = None next_msg: codec_v1.Message | None = None
# Take a mark of modules that are imported at this point, so we can # Take a mark of modules that are imported at this point, so we can

View File

@ -15,8 +15,6 @@ _REP_INIT = ">BBBHL" # marker, magic, magic, wire type, data length
_REP_INIT_DATA = const(9) # offset of data in the initial report _REP_INIT_DATA = const(9) # offset of data in the initial report
_REP_CONT_DATA = const(1) # offset of data in the continuation report _REP_CONT_DATA = const(1) # offset of data in the continuation report
SESSION_ID = const(0)
class CodecError(Exception): class CodecError(Exception):
pass pass

View File

@ -60,9 +60,8 @@ class Context:
(i.e., wire, debug, single BT connection, etc.) (i.e., wire, debug, single BT connection, etc.)
""" """
def __init__(self, iface: WireInterface, sid: int, buffer: bytearray) -> None: def __init__(self, iface: WireInterface, buffer: bytearray) -> None:
self.iface = iface self.iface = iface
self.sid = sid
self.buffer = buffer self.buffer = buffer
def read_from_wire(self) -> Awaitable[codec_v1.Message]: def read_from_wire(self) -> Awaitable[codec_v1.Message]:
@ -95,9 +94,8 @@ class Context:
if __debug__: if __debug__:
log.debug( log.debug(
__name__, __name__,
"%s:%x expect: %s", "%d expect: %s",
self.iface.iface_num(), self.iface.iface_num(),
self.sid,
expected_type.MESSAGE_NAME if expected_type else expected_types, expected_type.MESSAGE_NAME if expected_type else expected_types,
) )
@ -115,9 +113,8 @@ class Context:
if __debug__: if __debug__:
log.debug( log.debug(
__name__, __name__,
"%s:%x read: %s", "%d read: %s",
self.iface.iface_num(), self.iface.iface_num(),
self.sid,
expected_type.MESSAGE_NAME, expected_type.MESSAGE_NAME,
) )
@ -131,9 +128,8 @@ class Context:
if __debug__: if __debug__:
log.debug( log.debug(
__name__, __name__,
"%s:%x write: %s", "%d write: %s",
self.iface.iface_num(), self.iface.iface_num(),
self.sid,
msg.MESSAGE_NAME, msg.MESSAGE_NAME,
) )