Repository navigation
Telink: start the NWK frame counter above what stock firmware reached - #557
Open
patapovich wants to merge 1 commit into
Open
patapovich wants to merge 1 commit into
patapovich wants to merge 1 commit into
Conversation
A device updated from the stock Tuya firmware restarts its outgoing NWK frame counter from zero. Neighbouring routers still on stock Tuya firmware keep the old, much higher counter, acknowledge our frames at the MAC level and drop them as replays instead of forwarding them, so the device keeps losing the coordinator for minutes at a time (romasku#255). Raise the counter once to 0x10000000 right after zb_init() restores it from flash.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #255
Problem
After the update from the stock Tuya firmware, the device's outgoing NWK frame counter starts again from zero. Routers still running stock Tuya firmware remember the much higher counter the stock firmware had reached for this device. NWK security is checked hop by hop, so these routers acknowledge our frames at the MAC level and then drop them as replays instead of forwarding them. This matches the sniffer observation reported in #255.
Seen on an AVATTO ZDMS16-2 (router) with about ten stock Tuya routers around it:
Fix
Right after
zb_init()restores the counter from flash, raise it to0x10000000if it is lower, and save it. This happens once per device, and the counter only grows from there.0x10000000is far above what a stock firmware reaches in years (a few million frames per year from link status and routed traffic), and it still leaves about 3.7·10⁹ frames of headroom.Testing
Same device in the same place, updated custom→custom without re-pairing. During the first ~10 minutes, while routes settled, there were two short gaps. In the following 22 minutes (pings every 30 s) no command failed, one timeout was recovered by a retry, and replies now also arrive relayed through stock routers. Before the change there were outages of several minutes every few minutes.
The change is Telink-only (Silabs has no Tuya migration path) and cannot run in the stub test HAL.