-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix tag encoding, wrap in struct and parse StatusReport
- Loading branch information
Showing
5 changed files
with
221 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
[["receive", 277634700589145, ["fd98:bbab:bd61:8040:14ae:fe13:c814:3bc2", 58700, 0, 0], "BAAAAHseHgbighJRIqWzsAUgIGgAABUwASCFzR7wiM4L8C3VEpSXe5UK/1tjpinMKPaEtLYTbkR9kyUCLh4kAwAoBDUFJQH0ASUCLAElA6APJAQSJAULJgYAAAQBJAcBGBg="], ["receive", 277634706760287, ["fd98:bbab:bd61:8040:14ae:fe13:c814:3bc2", 58700, 0, 0], "BAAAAHweHgbighJRIqWzsAVAIGgAAAEAAAAAAAIA"], ["receive", 277634708186275, ["::ffff:192.168.0.37", 53917, 0, 0], "BAAAAH0eHgahFRe9xqs9aAUgIWgAABUwASAQJZk9pu15Dip5poydFQr50ZInKaRJg9hFd7lFMiV0QCUCLx4kAwAoBDUFJQH0ASUCLAElA6APJAQSJAULJgYAAAQBJAcBGBg="], ["receive", 277634727394981, ["::ffff:192.168.0.37", 53917, 0, 0], "BAAAAH4eHgahFRe9xqs9aAVAIWgAAAEAAAAAAAIA"], ["receive", 277635098871160, ["::ffff:192.168.0.37", 53917, 0, 0], "BAAAAH4eHgahFRe9xqs9aAVAIWgAAAEAAAAAAAIA"], ["receive", 277635109360371, ["fd98:bbab:bd61:8040:14ae:fe13:c814:3bc2", 58700, 0, 0], "BAAAAHweHgbighJRIqWzsAVAIGgAAAEAAAAAAAIA"], ["receive", 277635473211167, ["::ffff:192.168.0.37", 53917, 0, 0], "BAAAAH4eHgahFRe9xqs9aAVAIWgAAAEAAAAAAAIA"], ["receive", 277635519678001, ["fd98:bbab:bd61:8040:14ae:fe13:c814:3bc2", 58700, 0, 0], "BAAAAHweHgbighJRIqWzsAVAIGgAAAEAAAAAAAIA"], ["receive", 277636049081875, ["::ffff:192.168.0.37", 53917, 0, 0], "BAAAAH4eHgahFRe9xqs9aAVAIWgAAAEAAAAAAAIA"], ["receive", 277636061715619, ["fd98:bbab:bd61:8040:14ae:fe13:c814:3bc2", 58700, 0, 0], "BAAAAHweHgbighJRIqWzsAVAIGgAAAEAAAAAAAIA"], ["receive", 277637055974480, ["::ffff:192.168.0.37", 53917, 0, 0], "BAAAAH4eHgahFRe9xqs9aAVAIWgAAAEAAAAAAAIA"], ["receive", 277637087415383, ["fd98:bbab:bd61:8040:14ae:fe13:c814:3bc2", 58700, 0, 0], "BAAAAHweHgbighJRIqWzsAVAIGgAAAEAAAAAAAIA"]] | ||
[["receive", 357657266155036, ["fd98:bbab:bd61:8040:642:1aff:fe0c:9f2a", 45867, 0, 0], "BAAAAObOzQyqpsS5iZt1AwUg70sAABUwASBHe5PONLiOU6V4DJ7DZkokBgIvtdAKtWjuE8CDoN8dPyUCVUQkAwAoBDUFJQH0ASUCLAElA6APJAQRJAULJgYAAAMBJAcBGBg="], ["receive", 357657273325183, ["fd98:bbab:bd61:8040:642:1aff:fe0c:9f2a", 45867, 0, 0], "BAAAAOfOzQyqpsS5iZt1AwUi70sAABUwAUEEZZRPQKxRLWkU0CZwUU4AJT0cfikv2BmIiAUNWeFqLcoZSI8ULSVK5Re/dNmunfoSd7YojNkgN6L+GJ3TN7ad/xg="], ["receive", 357657652704410, ["fd98:bbab:bd61:8040:642:1aff:fe0c:9f2a", 45867, 0, 0], "BAAAAOfOzQyqpsS5iZt1AwUi70sAABUwAUEEZZRPQKxRLWkU0CZwUU4AJT0cfikv2BmIiAUNWeFqLcoZSI8ULSVK5Re/dNmunfoSd7YojNkgN6L+GJ3TN7ad/xg="], ["receive", 357658002105028, ["fd98:bbab:bd61:8040:642:1aff:fe0c:9f2a", 45867, 0, 0], "BAAAAOfOzQyqpsS5iZt1AwUi70sAABUwAUEEZZRPQKxRLWkU0CZwUU4AJT0cfikv2BmIiAUNWeFqLcoZSI8ULSVK5Re/dNmunfoSd7YojNkgN6L+GJ3TN7ad/xg="], ["receive", 357658622312059, ["fd98:bbab:bd61:8040:642:1aff:fe0c:9f2a", 45867, 0, 0], "BAAAAOfOzQyqpsS5iZt1AwUi70sAABUwAUEEZZRPQKxRLWkU0CZwUU4AJT0cfikv2BmIiAUNWeFqLcoZSI8ULSVK5Re/dNmunfoSd7YojNkgN6L+GJ3TN7ad/xg="], ["receive", 357659576369391, ["fd98:bbab:bd61:8040:642:1aff:fe0c:9f2a", 45867, 0, 0], "BAAAAOfOzQyqpsS5iZt1AwUi70sAABUwAUEEZZRPQKxRLWkU0CZwUU4AJT0cfikv2BmIiAUNWeFqLcoZSI8ULSVK5Re/dNmunfoSd7YojNkgN6L+GJ3TN7ad/xg="]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
from circuitmatter import StatusReport, GeneralCode, ProtocolId | ||
|
||
|
||
def test_example1(): | ||
report = StatusReport() | ||
report.general_code = GeneralCode.FAILURE | ||
report.protocol_id = ProtocolId.BDX | ||
report.protocol_code = 0x52 | ||
|
||
buffer = bytearray(10) | ||
assert report.encode_into(buffer) == 8 | ||
assert buffer[:8] == bytes.fromhex("01 00 02 00 00 00 52 00") | ||
|
||
|
||
def test_example1_decode(): | ||
report = StatusReport() | ||
report.decode(bytes.fromhex("01 00 02 00 00 00 52 00")) | ||
|
||
assert report.general_code == GeneralCode.FAILURE | ||
assert report.protocol_id == ProtocolId.BDX | ||
assert report.protocol_code == 0x52 | ||
|
||
|
||
def test_example2(): | ||
report = StatusReport() | ||
report.general_code = GeneralCode.SUCCESS | ||
report.protocol_id = 0xFFF1AABB | ||
report.protocol_code = 0 | ||
|
||
buffer = bytearray(10) | ||
assert report.encode_into(buffer) == 8 | ||
assert buffer[:8] == bytes.fromhex("00 00 BB AA F1 FF 00 00") | ||
|
||
|
||
def test_example2_decode(): | ||
report = StatusReport() | ||
report.decode(bytes.fromhex("00 00 BB AA F1 FF 00 00")) | ||
|
||
assert report.general_code == GeneralCode.SUCCESS | ||
assert report.protocol_id == 0xFFF1AABB | ||
assert report.protocol_code == 0 | ||
|
||
|
||
def test_protocol_data_example(): | ||
report = StatusReport() | ||
report.general_code = GeneralCode.FAILURE | ||
report.protocol_id = 0xFFF1AABB | ||
report.protocol_code = 9921 | ||
report.protocol_data = [0x55, 0x66, 0xEE, 0xFF] | ||
|
||
buffer = bytearray(20) | ||
assert report.encode_into(buffer) == 12 | ||
assert buffer[:12] == bytes.fromhex("01 00 BB AA F1 FF C1 26 55 66 EE FF") | ||
|
||
|
||
def test_protocol_data_example_decode(): | ||
report = StatusReport() | ||
report.decode(bytes.fromhex("01 00 BB AA F1 FF C1 26 55 66 EE FF")) | ||
|
||
assert report.general_code == GeneralCode.FAILURE | ||
assert report.protocol_id == 0xFFF1AABB | ||
assert report.protocol_code == 9921 | ||
assert report.protocol_data == b"\x55\x66\xee\xff" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters