Repository navigation
Conversation
startup_reset() replaced the protocol object with v4 on every attempt but left _ezsp_version at whatever a failed attempt had negotiated. On the retry, version() then saw the stick's version equal to the stale one and never switched back from v4 framing, so later replies were misparsed and startup timed out. This happens with zigbeed over TCP when its reset takes longer than the startup wait (seen at ~4 s): ZHA's form/restore flows hang. Use _switch_protocol_version(v4) so the version and protocol object agree.
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
zigpy-review-bot
left a comment
There was a problem hiding this comment.
Review
Looks good to me, no blockers.
startup_reset() previously rebuilt only the protocol object, so after a failed attempt that had already negotiated a newer version, _ezsp_version stayed stale and version() skipped _switch_protocol_version(). _switch_protocol_version(v4.EZSPv4.VERSION) resets the version and the object together, and it is the same call reset() already makes ("Always switch back to protocol v4 after a reset"), so the two paths are now consistent.
Verified in a worktree at 9f71434: tests/test_ezsp.py passes (88 passed), and test_ezsp_connect_retry_resets_protocol_version fails with the old one-line v4.EZSPv4(...) construction, so the test does exercise the bug.
The PR description matches the diff.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #774 +/- ##
=======================================
Coverage 99.59% 99.59%
=======================================
Files 64 64
Lines 4417 4417
=======================================
Hits 4399 4399
Misses 18 18 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
startup_reset()replaces the protocol object withEZSPv4on every attempt, but leaves_ezsp_versionat whatever a failed attempt had already negotiated. On the retry,version()sendsdesiredProtocolVersionwith the stale version, sees the stick answer with that same version, and skips_switch_protocol_version(). The protocol object stays v4, so later replies are framed for the wrong version and startup times out.When it happens
zigbeedover TCP (socket://host:port) when its startup reset takes longer thanNETWORK_COORDINATOR_STARTUP_RESET_WAIT. Seen with zigbeed 7.3.3 (EZSP 12) on an Aqara Panel Hub S1 Plus, whose reset answer takes about 4 s. The first attempt negotiates v12 and then fails, and every retry is stuck on v4 framing. In ZHA, form new network and restore backup hang. Monkeypatching the one line below makes both work.Change
Use
self._switch_protocol_version(v4.EZSPv4.VERSION)at the start of each attempt, so the version and the protocol object always agree.Tests
test_ezsp_connect_retry_resets_protocol_version: the first attempt switches to v12 and fails, and the retry must start at v4 with anEZSPv4object. It fails without the fix.pytest tests: 767 passed.