Repository navigation
reserve the attach-protocol wire format for the sensor-sync bus - #13
Merged
Merged
Conversation
4 of 6 tasks
aphelps-claude-bot
left a comment
Collaborator
Author
There was a problem hiding this comment.
Self-review (bot) of the shared wire-format reservation at head 56d4c56.
Wire-format discipline verified against the code:
- The header gains only numbers and packed payload structs that both sides parse off the wire (
RouterAdvert/NodeAttach/AttachAck,SS_HOP_UNREACHABLE, msgType 2/3/4) — no selection, membership, or timer logic leaked in. The membership table and route selection live inesp-now-router/src/router_attach.has the banner says. - msgType 2/3/4 collide with nothing (SNAPSHOT=0, BEACON=1), and the edge rejects every non-snapshot type via
ss_parse_header'smsgType != SENSOR_SYNC_MSG_SNAPSHOTcheck — confirmed at head, so the new control frames cannot reach edge dispatch.
Cross-repo note: RouterAdvert.leaderTerm's field comment calls it a "stale-advert guard", but the router-side selection never reads it — see the companion review on aphelps/esp-now-router#2 for the fix options; whichever way that lands, this comment should match.
One scope finding inline (medium).
aphelps-claude-bot
left a comment
Collaborator
Author
There was a problem hiding this comment.
Re-review (bot) of 56d4c56..627ea13 — one docs commit.
- Prior medium (scope: edge side not implemented, docs silent about it) — addressed. The new SENSOR_SYNC.md paragraph states the reservation explicitly, and its claim is verified against head:
ss_parse_headeracceptsSENSOR_SYNC_MSG_SNAPSHOTalone (themsgType != SENSOR_SYNC_MSG_SNAPSHOTreject), so edges do ignore msgType 2–4 and the handshake runs router-to-router as described. - Prior cross-repo note (
RouterAdvert.leaderTermdocumented as a "stale-advert guard" but never consulted) — resolved on the other side. esp-now-router#2's64dc581now gates route selection onleaderTermviass_seq_newer, so this header's comment is accurate as written; no change needed here. - New (introduced by the companion router commit): the
NodeAttach.routerIdwildcard comment is now wrong — inline, minor.
aphelps-claude-bot
left a comment
Collaborator
Author
There was a problem hiding this comment.
Re-review (bot) of 627ea13..c88a3c46 — a single comment line, the fix for the prior minor.
- Prior minor (
NodeAttach.routerIdcomment still documented the removed0 = any routerwildcard) — fixed. The comment now reads "must name one router, never 0", which matches router behaviour at esp-now-router08bd6e2on both sides of the wire: the receiver admits an attach only whenn.routerId == selfId(no wildcard branch remains inattachHandleFrame), and the sender can only emit an attach while a route is held (sendAttachis reached only withroute.routerId != 0), so 0 is never put on the wire either. Wire contract and implementation agree.
Nothing else in the range; clean.
1 task done
aphelps
approved these changes
Jul 30, 2026
aphelps-claude-bot
force-pushed
the
m3c-attach-failover
branch
from
July 30, 2026 07:26
c88a3c4 to
ad3fd26
Compare
Add the msgType numbers and payload structs for the router attach handshake (RouterAdvert, NodeAttach, AttachAck) so both sides of the mesh agree on the format. The logic that uses them lives in the esp-now-router repo; this repo only reserves the format, and ss_parse_header still accepts snapshots alone, so a WLED edge ignores these frames rather than acting on them. Reserving the numbers here keeps a future edge client from colliding with them.
aphelps-claude-bot
force-pushed
the
m3c-attach-failover
branch
from
July 30, 2026 07:26
ad3fd26 to
e9df738
Compare
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.
Part of aphelps/WLED_dev#23 in the parent repo.
Summary
The backbone router gains an attach protocol: routers advertise their distance to the timebase leader, nodes bind to the one they rank best, and the router acks with a membership lease. Three of those frames cross between the router firmware and the WLED edge, so their numbers and payload layouts have to be agreed here rather than in the router repo.
Adds to
sensor_sync_protocol.h:SENSOR_SYNC_MSG_ROUTER_ADV(2),SENSOR_SYNC_MSG_ATTACH(3),SENSOR_SYNC_MSG_ATTACH_ACK(4).RouterAdvert{leaderId, leaderTerm, hopCost, memberCount},NodeAttach{routerId},AttachAck{nodeId, leaseMs}, andSS_HOP_UNREACHABLE.SNAPSHOTis the only type that travels multi-hop; everything above it is a single-hop control frame consumed by whichever node hears it.The selection and membership logic stays in the router repo (
esp-now-router/src/router_attach.h) — the edge never calls it. Only the wire format is shared, matching howrouter_relay.h/router_election.hare already split.Additive only. No existing header or payload field moves,
ss_parse_headerstill accepts onlySNAPSHOT, and the wire version stays 5 — existing devices interoperate unchanged.SENSOR_SYNC.mdis updated in the same change, per its own maintenance rule.Submodule PRs
Test plan
Automated:
make test(from theWLED_devsuper-repo) — the ampworks dispatch + ring suites still pass against the changed headerpio run -e ampworkscd esp-now-router && pio run -e wt32-eth01— the router builds against the same headercd esp-now-router && pio test -e native— relay / election / attach host suites all passNo manual testing for this PR on its own; the hardware verification is tracked on the parent PR.