Files
project-vesper/docs
bonaminandClaude Opus 5.5 cec4db4894 fix(MQTT): self-recovering supervisor, LWT payload fix, QoS 0 publishes (F-071, F-072)
Device went cloud-silent after days of uptime while WebSocket kept working;
last thing on status/heartbeat was garbage. Causes and fixes:

- LWT payload was a dangling pointer: setWill() stores the raw char*, begin()
  passed a temporary String. The broker published freed heap as the Will on
  the unclean drop. Now held in _willPayload.
- Reconnect/stabilisation/heartbeat timers each xTaskCreate()d a short-lived
  task with the result ignored; one failed allocation ended the one-shot
  reconnect chain for good. Replaced by one persistent supervisor task that
  polls WiFi.status() itself, reconnects with backoff (cap now 60 s), sends
  the heartbeat, and force-resets the client when a connect attempt is stuck
  for 30 s or the heartbeat PUBACK is missing for 20 s.
- New mqtt.status command (all transports) exposes connect/disconnect
  counters, last reasons and forced resets for post-mortems over WebSocket.

Latency (F-072): AsyncMqttClient holds its queue behind every QoS 1 PUBACK
and only resumes on the ~500 ms poll, so each QoS 1 message cost RTT + up to
500 ms. All publishes are now QoS 0 except the heartbeat (liveness probe);
cleanSession=true on both ends meant QoS 1 never gave redelivery. WiFi modem
sleep disabled on connect to remove DTIM-induced RX delays.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-15 21:07:14 +03:00
..

Project Vesper — Documentation

Bell automation firmware for ESP32 (Kincony KC868-A6).


Reference

File Description
reference/api-reference.md Firmware API v2 — all commands, transports, envelope format
reference/firmware-variants.md PlatformIO environments, partition tables, build flags, OTA URLs
reference/api-reference-v1-legacy.md Old v1 API (pre-refactor) — kept for historical reference

Architecture

File Description
architecture/communication-refactor-plan.md Full design doc for the v2 Communication subsystem (CommandBus, Handlers, Transports)
architecture/legacy-response-adapter.md LegacyResponseAdapter — v2→v1 reply translation for the v1→v2 migration window (temporary, with removal steps)

Features

File Description
features/feature-catalog.md Feature catalog — index + details for every feature on the device
features/heartbeat.md MQTT heartbeat — retained 30s status publish (detail doc, also in catalog as F-008)

Development

File Description
dev/platformio-commands.md PlatformIO CLI reference
dev/common-commands.md Common v1 command snippets (scratch/lab use)
dev/features-scratch.md Feature notes and todo scratch pad

Other

File Description
roadmap.md Product roadmap
SentDevices/ Records of deployed devices

Working Rules (enforced in every session)

Context

This is ESP32 firmware (C++/Arduino/PlatformIO) for a bell automation controller.
It is maintained by a single developer over a long time, with AI assistance.
That means both of us can forget what was built weeks ago — so we need hard process rules to compensate.

Rules — non-negotiable

1. Feature catalog is mandatory.
Every feature added or changed must be logged in docs/features/feature-catalog.md.
Format: a short one-line entry in the index at the top, plus a detailed section below.
This is the single source of truth for "what does this device actually do?"

2. Commit every meaningful step.
Nothing stays uncommitted for long. Each logical unit of work (a fix, a feature, a refactor) gets its own commit with a clear message. Stacked uncommitted changes are a liability — they blur what changed and why.

3. Commit messages are descriptive.
fix(InputManager): add medium-press tier at 5s for WiFi-only reset
is better than fix button. The message must make sense to a reader in 6 months who has never seen this codebase.

4. Feature catalog entry before (or with) the commit.
When committing a feature or significant fix, the catalog entry is part of the same commit or committed immediately after. Never leave a feature undocumented.

5. At the start of every session, check what is uncommitted.
Before writing any new code, surface any dirty working tree and deal with it first — commit, discard, or document why it stays pending.

Feature catalog location

docs/features/feature-catalog.md

What counts as a "feature" for the catalog

  • Any new user-facing behaviour (commands, button gestures, network modes, playback options)
  • Any significant internal mechanism a future developer would need to know (e.g. two-tier factory reset, NTP UTC correction, builtin melody aliases)
  • Bug fixes that change observable behaviour (e.g. default version fallback changed from 2→1)

What does NOT need a catalog entry

  • Pure refactors with no behaviour change
  • Log message tweaks
  • Doc-only commits

6. Console API Reference is mandatory. Any new command/API endpoint, or a change to an existing one's contents/response/errors, must be reflected in the console's live API Reference page — not just in docs/reference/api-reference.md. The two are separate files in separate repos and neither auto-syncs from the other; both must be updated by hand in the same change.

Console API Reference location

C:\development\bellsystems-cp\frontend\src\pages\engineering\developer\ApiReferencePage.jsx

This is a different repo (bellsystems-cp, the backend/console repo) from this firmware repo (project-vesper) — open it directly by path, it will not show up in a search scoped to this repo.

How to update it

Commands are grouped into a NAMESPACES array. Each entry is { id, label, description, commands: [...] } — one entry per namespace (e.g. system, clock, relay, ota, firmware, network, or root for commands with no prefix). Find the matching namespace (or add a new one) and add/edit a command object in its commands array with these fields:

Field Required Meaning
cmd yes Full command name, e.g. "clock.set_time"
handler yes The C++ handler class that services it, e.g. "ClockHandler"
transports yes Array/label of which transports accept it — usually ['All']; narrow it if the command is transport-restricted (e.g. identify is WebSocket-only, ping is unavailable on RTC-less variants)
description yes What the command does, plus any caveats (rejection conditions, variant restrictions, blocking behaviour)
contents yes (null if none) Array of request fields, or null if the command takes no contents body
contents[].field yes Field name as it appears in the JSON contents object
contents[].type yes Wire type: string, int, bool, int[], object, etc.
contents[].required yes true/false — whether the field is mandatory. If a command requires "at least one of" a set of optional fields, say so in notes on each and add an error entry for the all-missing case
contents[].notes yes What the field means, valid ranges/values, 0-based vs 1-based indexing (call this out explicitly — this API mixes both), defaults, and interactions with other fields
response yes Exact success wire-format JSON as a string, matching the real { "status": "SUCCESS", "type": "<cmd>", "message"/"data": ... } envelope the firmware actually sends
errors yes ([] if none) Array of { message, condition } — message is the exact error string the firmware emits, condition is when it fires. Should cover every CommandResult::err() path in the handler
example yes One or more realistic full request JSON payloads ({ "v": 2, "cmd": "...", "contents": {...} }), as a string
warning yes (null if none) Set for anything destructive or irreversible (reboot, factory reset, rollback) — short caller-facing warning string

When adding a new namespace, also check UART_WHITELIST near the top of the file — if the command should be reachable over UART, add its name there too (UART only accepts whitelisted commands).

Keep docs/reference/api-reference.md (this repo) and the console page in sync — update both in the same change whenever a command is added or changed.