Socket-transport cmd space (off_14 ids) from live capture: 1101/1307/1705/1707 + host_probe3

This commit is contained in:
kfj001 committed 2026-10-16 00:14:42 +00:00
1 parent 2cdc274fe3
commit 213a0518d6
7 files changed
+401 -60

No files matched your search

+22 -2
View File
@@ -13,6 +13,7 @@ from franklinwh_agate_client.protocol import (
CommunicationCmd,
CommunicationObject,
SequenceNumber,
socket_cmd_type,
SocketFrameDecoder,
decrypt_data,
decrypt_request,
@@ -38,6 +39,25 @@ def _apower_json(snno=1, time_stamp=1792105196):
return env.to_json_string()
class TestSocketCmdSpace(unittest.TestCase):
def test_socket_ids(self):
self.assertEqual(socket_cmd_type(CommunicationCmd.QUERY_DEVICE_INFO), 1101)
self.assertEqual(socket_cmd_type(CommunicationCmd.DEVICE_APOWER_INFO), 1307)
self.assertEqual(socket_cmd_type(CommunicationCmd.BMS), 1705)
self.assertEqual(socket_cmd_type(CommunicationCmd.EMS), 1707)
def test_direct_request_uses_socket_id(self):
env = direct_connect_request(CommunicationCmd.DEVICE_APOWER_INFO, SN)
self.assertEqual(env.cmd_type, 1307)
self.assertTrue(env.to_json_string().startswith('{"cmdType":1307,'))
def test_discovery_shape_like_capture(self):
env = direct_connect_request(CommunicationCmd.QUERY_DEVICE_INFO, "")
body = env.to_json_string()
self.assertTrue(body.startswith(
'{"cmdType":1101,"equipNo":"00000000",'))
class TestSecretKey(unittest.TestCase):
def test_real_sn_key(self):
self.assertEqual(generate_secret_key(SN), "1c")
@@ -126,7 +146,7 @@ class TestCipher(unittest.TestCase):
def test_header_len_matches(self):
a, _ = split_envelope(_apower_json())
self.assertEqual(header_len_for(0x19, SN), len(a))
self.assertEqual(header_len_for(1307, SN), len(a))
def test_stream_is_absolute_index_plus_n(self):
a, b = split_envelope(_apower_json())
@@ -141,7 +161,7 @@ class TestCipher(unittest.TestCase):
wire = encrypt_object(body, generate_secret_key(SN))
self.assertEqual(
decrypt_request(wire, generate_secret_key(SN),
cmd_type=0x19, equip_no=SN),
cmd_type=1307, equip_no=SN),
body,
)