@@ -55,7 +55,7 @@ def get_auth_header(self):
5555 auth_header .extend (client_id_field )
5656 # Total packet length: 28 bytes
5757
58- # Unknown prefix field (2-byte static prefix, 4-byte length prefix, 64 unknown bytes)
58+ # Unknown prefix field (2-byte prefix, 4-byte length prefix, 64 unknown bytes)
5959 # fmt: off
6060 unknown_prefix_field = [
6161 0x01 , 0x08 , # Static prefix (2 bytes)
@@ -66,19 +66,20 @@ def get_auth_header(self):
6666 # Total packet length: 98 bytes
6767
6868 # Connection ID length field (4-byte length prefix)
69- connection_id_length_prefix = [
69+ # fmt: off
70+ conn_id_length_prefix = [
7071 0x00 , 0x00 , 0x00 , 0x10 ,
7172 ]
7273 # fmt: on
73- auth_header .extend (connection_id_length_prefix )
74+ auth_header .extend (conn_id_length_prefix )
7475 # Total packet length: 102 bytes
7576
7677 # Connection ID field (UTF-8-encoded, 16 bytes)
77- connection_id = self .target .path .split ("/" )[- 1 ].split ("__" )[0 ]
78- _LOGGER .debug ("Connection ID: %s" , connection_id )
79- connection_id_field = connection_id .encode ("utf-8" )[:16 ]
80- _LOGGER .debug ("Connection ID frame : %s (%d)" , connection_id_field , len (connection_id_field ))
81- auth_header .extend (connection_id_field )
78+ conn_id = self .target .path .split ("/" )[- 1 ].split ("__" )[0 ]
79+ _LOGGER .debug ("Connection ID: %s" , conn_id )
80+ conn_id_field = conn_id .encode ("utf-8" )[:16 ]
81+ _LOGGER .debug ("Connection ID field : %s (%d)" , conn_id_field , len (conn_id_field ))
82+ auth_header .extend (conn_id_field )
8283 # Total packet length: 118 bytes
8384
8485 # Trailer (static 4-byte trailer)
@@ -116,7 +117,7 @@ def is_serving(self):
116117
117118 async def feed (self ):
118119 """Connect to and stream from the target server."""
119- ready = True # For now assume the command is ready, skip the polling
120+ ready = True # For now assume the command is ready, skip the polling
120121 while not ready :
121122 # Poll the command API to check if the device is ready
122123 response = await api .request_command_status (
@@ -129,7 +130,7 @@ async def feed(self):
129130 state_condition = commands .get ("state_condition" )
130131 if state_condition not in ("new" , "running" ):
131132 raise RuntimeError (
132- f"Command { self .command_id } is not new or running: { state_condition } "
133+ f"Command { self .command_id } is { state_condition } "
133134 )
134135 state_stage = commands .get ("state_stage" )
135136 if state_stage in ("vs" , "lv" ):
@@ -290,7 +291,7 @@ async def send(self):
290291
291292 # fmt: off
292293 keepalive_packet = [
293- # [1-byte msgtype, 4-byte sequence (increasing) , 4-byte payload length]
294+ # [1-byte msgtype, 4-byte sequence, 4-byte payload length]
294295 0x0A , * sequence_bytes , 0x00 , 0x00 , 0x00 , 0x00 , # 9-byte header
295296 # no payload, just the header
296297 ]
0 commit comments