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
17 changes: 17 additions & 0 deletions tests/api/test_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,23 @@ async def test_handling_known_bad_command_parsing(connected_znp, caplog):
assert repr(bad_frame) in caplog.messages[0]


async def test_handling_zdo_default_error_rsp(connected_znp, caplog):
znp, _ = connected_znp

# Z-Stack sends a failed Simple_Desc_rsp (here INVALID_EP from 0xDED6) as a
# default error response, sharing its ID with `ZDO.StateChangeInd`
frame = GeneralFrame(
header=t.CommandHeader(
id=0xC0, subsystem=t.Subsystem.ZDO, type=t.CommandType.AREQ
),
data=b"\xd6\xde\x82",
)

caplog.set_level(logging.WARNING)
assert znp.frame_received(frame) is False
assert not caplog.records


async def test_handling_unknown_bad_command_parsing(connected_znp):
znp, _ = connected_znp

Expand Down
7 changes: 7 additions & 0 deletions zigpy_znp/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -859,6 +859,13 @@ def frame_received(self, frame: GeneralFrame) -> bool | None:
LOGGER.warning("Failed to parse broken %s as %s", frame, command_cls)
return False

# Z-Stack reports a failed Simple_Desc_rsp as a "default error" response
# (`MtZdoDef_rsp`, `NWK + Status`) with the same ID as `StateChangeInd`.
# The full response is also received as a `ZDO.MsgCbIncoming` callback.
if command_cls == c.ZDO.StateChangeInd.Callback and len(frame.data) == 3:
LOGGER.debug("Ignoring Z-Stack default ZDO error response %s", frame)
return False

raise

LOGGER.debug("Received command: %s", command)
Expand Down