Skip to content

Commit

Permalink
Fix EZSP v8 changeSourceRouteHandler (#624)
Browse files Browse the repository at this point in the history
* Move `incomingNetworkStatusHandler` to v8 as well

* Base v9 commands on v8

* Fix unit tests

* Do not disconnect when a frame cannot be parsed, log it instead

* Add a unit test
  • Loading branch information
puddly committed May 2, 2024
1 parent f1e9128 commit 4f4adaf
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 681 deletions.
5 changes: 4 additions & 1 deletion bellows/ezsp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,10 @@ def frame_received(self, data: bytes) -> None:
LOGGER.debug("Ignoring empty frame")
return

self._protocol(data)
try:
self._protocol(data)
except Exception:
LOGGER.warning("Failed to parse frame, ignoring")

async def get_board_info(
self,
Expand Down
8 changes: 6 additions & 2 deletions bellows/ezsp/v8/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
),
"counterRolloverHandler": (0x00F2, (), (t.EmberCounterType,)),
"delayTest": (0x009D, (t.uint16_t,), ()),
"getLibraryStatus": (0x0001, (t.uint8_t,), (t.EmberLibraryStatus,)),
"getLibraryStatus": (0x0001, (t.EmberLibraryId,), (t.EmberLibraryStatus,)),
"getXncpInfo": (0x0013, (), (t.EmberStatus, t.uint16_t, t.uint16_t)),
"customFrame": (0x0047, (t.LVBytes,), (t.EmberStatus, t.LVBytes)),
"customFrameHandler": (0x0054, (), (t.LVBytes,)),
Expand Down Expand Up @@ -311,7 +311,11 @@
(),
(t.EmberNodeId, t.EUI64, t.uint8_t, t.int8s, t.LVList[t.EmberNodeId]),
),
"changeSourceRouteHandler": (0x00C4, (), (t.EmberNodeId, t.EmberNodeId, t.Bool)),
"incomingNetworkStatusHandler": (
0x00C4,
(),
tuple({"errorCode": t.EmberStackError, "target": t.EmberNodeId}.values()),
),
"setSourceRoute": (
0x00AE,
(t.EmberNodeId, t.LVList[t.EmberNodeId]),
Expand Down
2 changes: 2 additions & 0 deletions bellows/ezsp/v8/types/named.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
EmberJoinDecision,
EmberKeyStatus,
EmberKeyStructBitmask,
EmberLibraryId,
EmberLibraryStatus,
EmberMacPassthroughType,
EmberMessageDigest,
Expand All @@ -36,6 +37,7 @@
EmberSignature283k1Data,
EmberSignatureData,
EmberSmacData,
EmberStackError,
EmberStatus,
EmberZdoConfigurationFlags,
EmberZllKeyIndex,
Expand Down

0 comments on commit 4f4adaf

Please sign in to comment.