feat: multi-board HAL guards, RFRemote subsystem, Player/OTA improvements

Multi-board variant support:
- variants/vesper.hpp: enable HAS_RF=1, define RF_RX_PIN=22
- variants/agnus.hpp: enable HAS_RF=1, RF_RX_PIN=22, correct HAS_RTC=0
- main.cpp, Player, HealthMonitor, OTAManager, ConfigManager: wrap all
  RTC/SD/RF-dependent code in #if HAS_RTC / HAS_SD_CARD / HAS_RF guards
  so Agnus builds cleanly without those peripherals

RFRemote subsystem (new):
- src/RFRemote/: RF receiver driver (GPIO RF_RX_PIN) + command handler
- Registered with HealthMonitor and CommunicationRouter when HAS_RF=1

Player improvements:
- uid -> pid rename throughout (Player, BuiltInMelodies, api-reference)
- loadMelodyInRAM() now returns bool
- playerControlTaskFn task added — defers stop/pause/resume out of
  timer callback (Tmr Svc) to avoid stack overflows
- setDependencies() accepts nullptr FileManager for SD-less boards

OTAManager:
- Consume download_url from server metadata response instead of
  constructing firmware path locally
- HTTP redirect following enabled (setFollowRedirects)
- HAS_RTC guards on TimeKeeper references

platformio.ini:
- Add rc-switch library for RF remote support
- Remove BOARD_TYPE/BOARD_NAME/BOARD_VERSION flags (moved to variant headers)
- MQTT_SECRET placeholders only — no secrets in source

Docs:
- docs/architecture/codebase-refactor-plan.md: new migration strategy doc
- docs/reference/api-reference.md: updated for pid, note_assignments, download_url
- Remove stale docs: ota-telemetry-api.md, platformio-commands.md, firmware-variants.md

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-17 17:02:01 +02:00
co-authored by Claude Sonnet 4.6
parent 37b65cc15a
commit a4d071d5d5
31 changed files with 2431 additions and 891 deletions
+167 -7
View File
@@ -2,7 +2,7 @@
> Command reference for the Vesper Bell Automation System.
> Firmware v2 command bus architecture — all transports, all handlers.
> Last updated: 2026-03-01
> Last updated: 2026-03-16
---
@@ -122,10 +122,22 @@ WebSocket clients must send `identify` immediately after connecting, or they wil
`action` values: `"play"`, `"stop"`, `"pause"`, `"unpause"`
```json
{ "v": 2, "cmd": "playback", "contents": { "action": "play", "melody_uid": "ABC123" } }
{ "v": 2, "cmd": "playback", "contents": { "action": "play", "pid": "ormilia_1_8", "speed": 200, "total_duration": 60000, "note_assignments": [1,2,3,4,5,6,0,0,0,0,0,0,0,0,0,0] } }
{ "v": 2, "cmd": "playback", "contents": { "action": "stop" } }
```
| Field | Type | Required | Notes |
|---|---|---|---|
| `action` | string | yes | `"play"` or `"stop"` |
| `pid` | string | yes (play) | Playback ID. Checked against built-in library first, then SD card, then downloaded via `download_url`. |
| `download_url` | string | no | URL to download the melody binary if not found locally. |
| `speed` | int | no | ms per beat. Default 500. |
| `total_duration` | int | no | Total playback ms. `0` = play to natural end. |
| `segment_duration` | int | no | Duration per loop segment (ms). Used with `continuous_loop`. |
| `pause_duration` | int | no | Pause between segments (ms). |
| `continuous_loop` | bool | no | Loop with pause/resume segments. |
| `note_assignments` | int[16] | no | Bell mapping (0-indexed note → 1-indexed output, 0 = unused). |
---
## Relay Namespace — `RelayHandler`
@@ -620,7 +632,7 @@ List all built-in melodies compiled into the firmware.
| | |
|---|---|
| Returns | `[{ "name": "...", "uid": "..." }, ...]` |
| Returns | `[{ "name": "...", "pid": "..." }, ...]` |
```json
{ "v": 2, "cmd": "files.list_builtin" }
@@ -672,19 +684,166 @@ Set log verbosity per output channel. Level 0 = off, 5 = verbose.
### `log.set_serial`
```json
{ "v": 2, "cmd": "log.set_serial", "contents": { "level": 3 } }
{ "v": 2, "cmd": "log.set_serial", "contents": { "level": 0 } }
```
### `log.set_sd`
```json
{ "v": 2, "cmd": "log.set_sd", "contents": { "level": 2 } }
{ "v": 2, "cmd": "log.set_sd", "contents": { "level": 0 } }
```
### `log.set_mqtt`
```json
{ "v": 2, "cmd": "log.set_mqtt", "contents": { "level": 1 } }
{ "v": 2, "cmd": "log.set_mqtt", "contents": { "level": 0 } }
```
---
## RF Remote Namespace — `RFRemoteHandler`
> Available on hardware variants with `HAS_RF=1` (e.g. Vesper, Vesper+).
> All commands are silently rejected on variants without RF hardware.
The RF subsystem uses a **slot model**: up to 16 independent slots, each binding one RF trigger code to a complete playback action. Slots are blank by default — nothing is pre-seeded. Program them over MQTT after flashing.
### Slot object
| Field | Type | Required | Notes |
|---|---|---|---|
| `slot` | int | yes | Slot index, 0–15 |
| `rf_code` | uint32 | yes | Raw 433 MHz code that triggers this slot. Must be non-zero. |
| `pid` | string | yes (play) | Playback ID. Checked against built-in library first, then SD card. Use `files.list_builtin` or `files.list` for valid PIDs. |
| `speed` | int | no | ms per beat. Default 500. |
| `duration` | int | no | Total playback ms. Default 30000. `0` = play to natural end. |
| `note_assignments` | int[16] | no | Bell mapping array (0-indexed note → 1-indexed bell output, 0 = unused). Default all zeros. |
| `is_stop` | bool | no | If `true`, receiving this code calls force-stop (single press, no long-press required). `pid`/`speed`/`duration` ignored. Default `false`. |
**`note_assignments` example:** A melody written for 6 bells played on 3 physical bells, doubled:
```json
"note_assignments": [1, 2, 3, 1, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
```
---
### `rf.set_slot`
Program one slot, or multiple slots in a single command.
| | |
|---|---|
| Handler | RFRemoteHandler |
| Transports | All |
| Persists | NVS namespace `rf` (survives reboot) |
**Single slot:**
```json
{
"v": 2,
"cmd": "rf.set_slot",
"contents": {
"slot": 0,
"rf_code": 9274392,
"pid": "vesper_fst_1_4",
"speed": 500,
"duration": 60000,
"note_assignments": [1, 2, 3, 4, 5, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
"is_stop": false
}
}
```
**Multiple slots (batch):**
```json
{
"v": 2,
"cmd": "rf.set_slot",
"contents": {
"slots": [
{ "slot": 0, "rf_code": 9274392, "pid": "vesper_fst_1_4", "speed": 500, "duration": 60000, "note_assignments": [1,2,3,4,5,6,0,0,0,0,0,0,0,0,0,0] },
{ "slot": 1, "rf_code": 9274388, "pid": "doxology_1_4", "speed": 500, "duration": 60000 },
{ "slot": 7, "rf_code": 9274385, "is_stop": true }
]
}
}
```
Returns:
```json
{ "status": "SUCCESS", "type": "rf.set_slot", "payload": "3 slot(s) programmed" }
```
---
### `rf.clear_slot`
Clear a single slot, or all slots.
| | |
|---|---|
| Required | `slot` — int (0–15) or string `"all"` |
```json
{ "v": 2, "cmd": "rf.clear_slot", "contents": { "slot": 3 } }
{ "v": 2, "cmd": "rf.clear_slot", "contents": { "slot": "all" } }
```
---
### `rf.get_slots`
Return the full slot table (all 16 slots).
| | |
|---|---|
| Contents | *(none)* |
| Returns | `{ "enabled": bool, "slots": [ { slot object } × 16 ] }` |
Each entry includes an `"empty": true/false` field. Empty slots have `rf_code: 0` and all other fields at their defaults.
```json
{ "v": 2, "cmd": "rf.get_slots" }
```
Example response excerpt:
```json
{
"status": "SUCCESS",
"type": "rf.get_slots",
"data": {
"enabled": true,
"slots": [
{
"slot": 0,
"empty": false,
"rf_code": 9274392,
"pid": "vesper_fst_1_4",
"speed": 500,
"duration": 60000,
"is_stop": false,
"note_assignments": [1, 2, 3, 4, 5, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
},
{ "slot": 1, "empty": true, "rf_code": 0, ... },
...
]
}
}
```
---
### `rf.enable`
Enable or disable RF reception at runtime.
| | |
|---|---|
| Required | `enabled` (bool) |
```json
{ "v": 2, "cmd": "rf.enable", "contents": { "enabled": true } }
{ "v": 2, "cmd": "rf.enable", "contents": { "enabled": false } }
```
---
@@ -799,7 +958,7 @@ On recovery:
Published on significant device state changes. `type` identifies the event; `payload` is event-specific.
```json
{ "type": "playback_started", "payload": { "melody_uid": "ABC123" } }
{ "type": "playback_started", "payload": { "pid": "ormilia_1_8" } }
{ "type": "playback_stopped", "payload": {} }
```
@@ -870,3 +1029,4 @@ If a client sends `"v": 1` (or omits `v`), the `LegacyAdapter` translates the ol
| `log` | `set_serial`, `set_sd`, `set_mqtt` |
| `mqtt` | `enable`, `disable` |
| `telemetry` | `get_strikes`, `reset_strikes`, `get_loads` |
| `rf` | `set_slot`, `clear_slot`, `get_slots`, `enable` *(HAS_RF variants only)* |