Skip to content

refactor(firmware): name the comment-only protocol values so the client sync can read them #346

Closed

Description

@mottihoresh

Why

The client's npm run sync (SkyHawkClient/scripts/sync-a4ec.ts) imports firmware protocol values by parsing named declarations: enum class X : T { … } (parseEnum) and constexpr T NAME = … (constexprNum). Values written that way are generated into the client and never hand-typed (e.g. NodeHealthFlag → NODE_HEALTH_FLAGS).

Nine protocol facts exist in firmware only as comments, bare literals or a format string, so the sync can't see them and the client hand-types them. The SkyHawkClient structure rewrite (milestone v1.0.0) requires every hardware value to come from the sync.

Scope

Add named declarations for these, no change to any byte on the wire and no behaviour change:

# Value Where it lives today (d29433a)
1 Gateway reports itself as node 0 PanelBridge.cpp:92 emitRow(0, …); CANProtocol.h:357/373 comment
2 _NODE_STATUS row field widths / hex length 28 PanelBridge.cpp:72 snprintf format
3 Heartbeat flag bits: bit0 BOFF, bit1 EPVF CANProtocol.h:52 comment, CANProtocol.cpp:436 bit math
4 ESR split: low byte TEC, high byte REC CANProtocol.h:55 comment, CANProtocol.cpp:439
5 Die temp "unavailable" = INT8_MIN (0x80) CANProtocol.h:82 comment, PanelBridge.cpp:66
6 _NODE_TELEM framing (18 hex) NodeStatus.h:36-41 comment, PanelBridge.cpp:115 format
7 TELEM page body layouts (offsets, units) NodeStatus.h:92-100 doc comment
8 NTC "unavailable" = INT16_MIN NodeStatus.h:96-97 comment
9 Calibration payload field offsets (HELLO_ACK, CAL_DATA, SESSION_ACK, NACK, RAW, COMMIT) AxisCal.h structs + SimGateway.cpp _put16 writers

Shape is up to the PR, e.g. enum class HeartbeatFlag : uint8_t { BOFF = 0x01, EPVF = 0x02 }, constexpr int8_t DIE_TEMP_UNAVAILABLE = INT8_MIN, constexpr uint8_t GATEWAY_NODE_ID = 0, offset constants per payload. Firmware code should use the new names where it currently uses the literals.

Done when

  • Named declarations added; firmware builds; compiled frames byte-identical
  • FirmwarePlan / TechSpec / docs/ updated where they quote these values (same PR)
  • check_doc_refs.py clean
  • Client follow-up: the SkyHawkClient rewrite's sync step reads them (tracked in the client's R1 issue)

Notes

Metadata

Metadata

Assignees

No one assigned

    Labels

    firmwareFirmware implementation workpriority: mediumWanted and scoped; not blocking today

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions