Skip to content
Merged
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
5 changes: 2 additions & 3 deletions bellows/ezsp/v12/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,10 @@
"checkKeyContext": (
0x0110,
{
"config": t.uint8_t,
"minAcksNeeded": t.uint8_t,
"context": t.SecurityManagerContextV12,
},
{
"status": t.EmberStatus,
"status": t.sl_Status,
},
),
"childId": (
Expand Down
9 changes: 9 additions & 0 deletions bellows/ezsp/v13/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@
},
),
# The following commands are redefined because `SecurityManagerContext` changed
"checkKeyContext": (
0x0110,
{
"context": t.SecurityManagerContextV13,
},
{
"status": t.sl_Status,
},
),
"exportKey": (
0x0114,
{
Expand Down
214 changes: 214 additions & 0 deletions bellows/ezsp/v14/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,201 @@ class GetTokenDataRsp(Struct):
"context": t.SecurityManagerContextV13,
},
),
"exportLinkKeyByEui": (
0x010D,
{
"eui64": t.EUI64,
},
{
"status": t.sl_Status,
"context": t.SecurityManagerContextV13,
"plaintext_key": t.KeyData,
"key_data": t.SecurityManagerAPSKeyMetadata,
},
),
"exportTransientKeyByIndex": (
0x0112,
{
"index": t.uint8_t,
},
{
"status": t.sl_Status,
"context": t.SecurityManagerContextV13,
"plaintext_key": t.KeyData,
"key_data": t.SecurityManagerAPSKeyMetadata,
},
),
"exportTransientKeyByEui": (
0x0113,
{
"eui64": t.EUI64,
},
{
"status": t.sl_Status,
"context": t.SecurityManagerContextV13,
"plaintext_key": t.KeyData,
"key_data": t.SecurityManagerAPSKeyMetadata,
},
),
"getApsKeyInfo": (
0x010C,
{
"context_in": t.SecurityManagerContextV13,
},
{
"status": t.sl_Status,
"key_data": t.SecurityManagerAPSKeyMetadata,
"context": t.SecurityManagerContextV13,
},
),
"importKey": (
0x0115,
{
"context": t.SecurityManagerContextV13,
"key": t.KeyData,
},
{
"status": t.sl_Status,
"context": t.SecurityManagerContextV13,
},
),
"findAndRejoinNetwork": (
0x0021,
{
"haveCurrentNetworkKey": t.Bool,
"channelMask": t.uint32_t,
"reason": t.uint8_t,
"nodeType": t.EmberNodeType,
},
{
"status": t.sl_Status,
},
),
# Replaces `setAddressTableRemoteEui64` and `setAddressTableRemoteNodeId`
"setAddressTableInfo": (
0x005C,
{
"index": t.uint8_t,
"eui64": EUI64,
"nwk": NWK,
},
{
"status": t.sl_Status,
},
),
"setPowerDescriptor": (
0x0016,
{
"descriptor": t.uint16_t,
},
{
"status": t.sl_Status,
},
),
"clearStoredBeacons": (
0x003C,
{},
{
"status": t.sl_Status,
},
),
# These three still respond with a single byte, not an `sl_Status`
"sendPanIdUpdate": (
0x0057,
{
"newPan": t.EmberPanId,
},
{
"status": t.Bool,
},
),
"readAttribute": (
0x0108,
{
"endpoint": t.uint8_t,
"cluster": t.uint16_t,
"attributeId": t.uint16_t,
"mask": t.uint8_t,
"manufacturerCode": t.uint16_t,
},
{
"status": t.EmberStatus,
"dataType": t.uint8_t,
"data": t.LVBytes,
},
),
"writeAttribute": (
0x0109,
{
"endpoint": t.uint8_t,
"cluster": t.uint16_t,
"attributeId": t.uint16_t,
"mask": t.uint8_t,
"manufacturerCode": t.uint16_t,
"overrideReadOnlyAndDataType": t.Bool,
"justTest": t.Bool,
"dataType": t.uint8_t,
"data": t.LVBytes,
},
{
"status": t.EmberStatus,
},
),
# `lastHopLqi` and `lastHopRssi` were replaced with `packetInfo`
"macPassthroughMessageHandler": (
0x0097,
{},
{
"messageType": t.EmberMacPassthroughType,
"packetInfo": t.SlRxPacketInfo,
"messageContents": t.LVBytes,
},
),
"macFilterMatchMessageHandler": (
0x0046,
{},
{
"filterIndexMatch": t.uint8_t,
"legacyPassthroughType": t.EmberMacPassthroughType,
"packetInfo": t.SlRxPacketInfo,
"messageContents": t.LVBytes,
},
),
"incomingBootloadMessageHandler": (
0x0092,
{},
{
"longId": t.EUI64,
"packetInfo": t.SlRxPacketInfo,
"messageContents": t.LVBytes,
},
),
"zllNetworkFoundHandler": (
0x00B6,
{},
{
"networkInfo": t.EmberZllNetwork,
"isDeviceInfoNull": t.Bool,
"deviceInfo": t.EmberZllDeviceInfoRecord,
"packetInfo": t.SlRxPacketInfo,
},
),
"zllAddressAssignmentHandler": (
0x00B8,
{},
{
"addressInfo": t.EmberZllAddressAssignment,
"packetInfo": t.SlRxPacketInfo,
},
),
"rawTransmitCompleteHandler": (
0x0098,
{},
{
"messageContents": t.LVBytes,
"status": t.sl_Status,
},
),
"getAddressTableInfo": (
0x005E,
{
Expand Down Expand Up @@ -177,3 +372,22 @@ class GetTokenDataRsp(Struct):
COMMANDS[name] = (command_id, tx_schema, rx_schema)

del COMMANDS["getAddressTableRemoteEui64"]
del COMMANDS["setAddressTableRemoteEui64"]

# Removed in v14. Their frame IDs were reused, either right away or in later versions
del COMMANDS["getNextBeacon"] # 0x0004 is now `getStoredBeacon`
del COMMANDS["proxyBroadcast"] # 0x0037 is now `setNumBeaconsToStore`
del COMMANDS["sendMulticastWithAlias"] # 0x003A is now `setupDelayedJoin`
del COMMANDS["getFirstBeacon"] # 0x003D
del COMMANDS["setAddressTableRemoteNodeId"] # 0x005D
del COMMANDS["getAddressTableRemoteNodeId"] # 0x005F
del COMMANDS["incomingSenderEui64Handler"] # 0x0062

# Removed in v14
del COMMANDS["sendRawMessage"] # Now the name of 0x0051, `sendRawMessageExtended`
del COMMANDS["setLongUpTime"]
del COMMANDS["setHubConnectivity"]
del COMMANDS["isUpTimeLong"]
del COMMANDS["isHubConnected"]
del COMMANDS["setParentClassificationEnabled"]
del COMMANDS["getParentClassificationEnabled"]
13 changes: 11 additions & 2 deletions bellows/ezsp/v18/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,20 @@
{
"filterValueMatch": t.uint16_t, # Was `filterIndexMatch: uint8_t`
"legacyPassthroughType": t.EmberMacPassthroughType,
"lastHopLqi": t.uint8_t,
"lastHopRssi": t.int8s,
"packetInfo": t.SlRxPacketInfo,
"messageContents": t.LVBytes,
},
),
"getTokenCount": (
0x0100,
{},
{
"count": t.uint32_t, # Was `uint8_t`
},
),
# NOTE: `getTokenInfo` (0x0101) is left as-is. Simplicity SDK 2025.12 widened the
# `size` field of its token info to `uint32_t` without an EZSP version bump, so
# firmware built from SiSDK 2025.6.x (also EZSP v18) still sends a single byte.
# Added in Simplicity SDK 2025.12.0
"setPendingNetworkUpdateChannel": (
0x003D,
Expand Down
11 changes: 11 additions & 0 deletions bellows/ezsp/v19/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,15 @@
},
{},
),
# The token info `size` field is a `uint32_t` since Simplicity SDK 2025.12
"getTokenInfo": (
0x0101,
{
"index": t.uint8_t,
},
{
"status": t.sl_Status,
"token_info": t.SlZigbeeTokenInfo,
},
),
}
14 changes: 14 additions & 0 deletions bellows/types/struct.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,20 @@ class EmberTokenInfo(EzspStruct):
arraySize: basic.uint8_t


class SlZigbeeTokenInfo(EzspStruct):
# Information of a token in the token table
# NVM3 key of the token
nvm3Key: named.NV3KeyId
# Token is a counter type
isCnt: named.Bool
# Token is an indexed token
isIdx: named.Bool
# Size of the token, widened from `uint8_t` in Simplicity SDK 2025.12
size: basic.uint32_t
# Array size of the token
arraySize: basic.uint8_t


class EmberTokTypeStackZllData(EzspStruct):
# Public API for ZLL stack data token.
# Token bitmask.
Expand Down
23 changes: 23 additions & 0 deletions tests/test_ezsp_v12.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import pytest

import bellows.ezsp.v12
import bellows.types as t

from tests.common import mock_ezsp_commands

Expand All @@ -28,3 +29,25 @@ def test_ezsp_frame_rx(ezsp_f):
assert ezsp_f._handle_callback.call_count == 1
assert ezsp_f._handle_callback.call_args[0][0] == "version"
assert ezsp_f._handle_callback.call_args[0][1] == [0x01, 0x02, 0x1234]


def test_check_key_context(ezsp_f) -> None:
"""`checkKeyContext` takes a security manager context and returns an `sl_status_t`."""
context = t.SecurityManagerContextV12(
core_key_type=t.SecurityManagerKeyType.APP_LINK,
key_index=0,
derived_type=t.SecurityManagerDerivedKeyTypeV12.NONE,
eui64=t.EUI64.convert("01:02:03:04:05:06:07:08"),
multi_network_index=0,
flags=t.SecurityManagerContextFlags.EUI_IS_VALID,
psa_key_alg_permission=0,
)
_, tx_schema, rx_schema = ezsp_f.COMMANDS["checkKeyContext"]

assert t.serialize_dict((), {"context": context}, tx_schema) == bytes.fromhex(
"04" "00" "00" "0807060504030201" "00" "02" "00000000"
)
assert t.deserialize_dict(b"\x00\x00\x00\x00", rx_schema) == (
{"status": t.sl_Status.OK},
b"",
)
22 changes: 22 additions & 0 deletions tests/test_ezsp_v13.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,3 +227,25 @@ async def test_factory_reset(ezsp_f) -> None:
assert ezsp_f.tokenFactoryReset.mock_calls == [
call(excludeOutgoingFC=False, excludeBootCounter=False)
]


def test_check_key_context(ezsp_f) -> None:
"""`checkKeyContext` takes a security manager context and returns an `sl_status_t`."""
context = t.SecurityManagerContextV13(
core_key_type=t.SecurityManagerKeyType.APP_LINK,
key_index=0,
derived_type=t.SecurityManagerDerivedKeyTypeV13.NONE,
eui64=t.EUI64.convert("01:02:03:04:05:06:07:08"),
multi_network_index=0,
flags=t.SecurityManagerContextFlags.EUI_IS_VALID,
psa_key_alg_permission=0,
)
_, tx_schema, rx_schema = ezsp_f.COMMANDS["checkKeyContext"]

assert t.serialize_dict((), {"context": context}, tx_schema) == bytes.fromhex(
"04" "00" "0000" "0807060504030201" "00" "02" "00000000"
)
assert t.deserialize_dict(b"\x00\x00\x00\x00", rx_schema) == (
{"status": t.sl_Status.OK},
b"",
)
Loading
Loading