Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions bellows/ezsp/v13/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,29 @@
"number_of_entries": t.uint8_t,
},
),
# Redefined: EmberZNet 7.x serializes EmberGpAddress as applicationId,
# an 8-byte id union, then endpoint, which the inherited schema predates.
"gpepIncomingMessageHandler": (
0x00C5,
{},
{
"status": t.uint8_t,
"gpdLink": t.uint8_t,
"sequenceNumber": t.uint8_t,
"applicationId": t.uint8_t,
"gpdIdUnion": t.FixedList[t.uint8_t, 8],
"endpoint": t.uint8_t,
"gpdfSecurityLevel": t.uint8_t,
"gpdfSecurityKeyType": t.uint8_t,
"autoCommissioning": t.Bool,
"bidirectionalInfo": t.uint8_t,
"gpdSecurityFrameCounter": t.uint32_t,
"gpdCommandId": t.uint8_t,
"mic": t.uint32_t,
"proxyTableIndex": t.uint8_t,
"gpdCommandPayload": t.LVBytes,
},
),
# The following commands are redefined because `SecurityManagerContext` changed
"exportKey": (
0x0114,
Expand Down
19 changes: 19 additions & 0 deletions tests/test_ezsp_v13.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,3 +227,22 @@ async def test_factory_reset(ezsp_f) -> None:
assert ezsp_f.tokenFactoryReset.mock_calls == [
call(excludeOutgoingFC=False, excludeBootCounter=False)
]


def test_gpep_incoming_message_handler_rx(ezsp_f):
"""Test receiving a gpepIncomingMessageHandler frame from an EmberZNet 7.x NCP."""
ezsp_f(
b"\x03\x01\x80\xc5\x00"
+ bytes.fromhex("7fdbc1009eea43009eea43000002010000c116000010153064adff00")
)
assert ezsp_f._handle_callback.call_count == 1
name, args = ezsp_f._handle_callback.call_args[0]
assert name == "gpepIncomingMessageHandler"
assert args[3] == 0x00 # applicationId: source ID addressing
assert bytes(args[4][:4]) == bytes.fromhex("9eea4300") # sourceId 0x0043EA9E
assert args[6] == 0x02 # gpdfSecurityLevel: full frame counter + MIC
assert args[7] == 0x01 # gpdfSecurityKeyType
assert args[10] == 0x16C1 # gpdSecurityFrameCounter
assert args[11] == 0x10 # gpdCommandId
assert args[13] == 0xFF # proxyTableIndex: not in proxy table
assert args[14] == b"" # gpdCommandPayload