Commit Graph
104 Commits
Author SHA1 Message Date
bonaminandClaude Sonnet 4.6 ee73d4d2c4 docs: add feature catalog and working rules to README
Establishes the production workflow:
- docs/features/feature-catalog.md: index + detail entries for all 23
  known features (F-001 through F-023), seeded from git history and
  current uncommitted changes
- docs/README.md: replaced loose notes with enforced Working Rules
  section (feature catalog mandate, commit discipline, session startup)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-30 09:52:01 +03:00
bonaminandClaude Sonnet 4.6 ed1123283b feat: boot-phase OTA, RS485 variant, async melody download, HAL guards
- bootOtaCheck() runs at top of setup() before any task/timer; streams
  firmware to flash on update, reboots, otherwise returns immediately
- New bespoke-rs485-v1 build env + Rs485OutputManager for Waveshare 16CH
  Modbus RTU relay; vesper.hpp renamed vesper-std.hpp, env renamed accordingly
- Player: permanent melodyDownloadTaskFn task; fast path (built-in/SD) before
  async download; uid accepted as alias for pid
- CommunicationRouter: HAS_UART guards throughout so UART transport compiles
  out when Serial2 is claimed by Modbus
- OTAManager: stack 8KB→16KB, pinned to Core 1, HTTPClient recreated per
  retry, download timeout 30s→60s
- FileManager: heap guard before SSL alloc; watchdog log cleanup
- ConfigManager: OTA fallback URLs http (no TLS for firmware servers)
- agnus.hpp: HAS_UART 1 added
- provisioning/nvs_agnus_lab_device.csv added
- Version bumped to v2.0.1

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-18 20:48:26 +03:00
bonaminandClaude Sonnet 4.6 a4d071d5d5 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>
2026-03-17 17:02:01 +02:00
bonaminandClaude Sonnet 4.6 37b65cc15a feat: HAL variant system, OTA improvements, NVS migration scaffold
- Add variants/vesper.hpp and variants/agnus.hpp with HAS_SD_CARD, HAS_RTC,
  HAS_PCF8574, OUTPUT_COUNT_MAX, HW_FAMILY capability flags
- Add agnus-v1 and agnus-mini-v1 PlatformIO environments with -include injection
- Add src/NvsMigration/ scaffold for future NVS schema versioning
- FirmwareHandler: OTA flow improvements and header updates
- OTAManager: FastAPI integration, semver handling improvements
- ConfigManager: refactoring groundwork for NVS-only variant support
- CommunicationRouter: minor fix
- provisioning/nvs_lab_device.csv: fix hw_type to VS, update device id fields
- docs/dev/ota-telemetry-api.md: update API spec

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-15 11:39:11 +02:00
bonaminandClaude Sonnet 4.6 d4d8b1c380 docs: add per-subsystem README files
Add inline documentation for all src/ subsystems covering purpose,
responsibilities, public API, and usage notes.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-14 22:16:03 +02:00
bonaminandClaude Sonnet 4.6 d4bd990e53 feat: semver versioning, FastAPI OTA integration, health alerts via MQTT
- Version.hpp: extract FW_VERSION from main.cpp into shared header
- OTAManager: replace uint16_t version with SemVer struct; update API URLs
  to new FastAPI backend (/api/firmware/{hw_type}/{channel}/latest);
  add postDownloadTelemetry() and postFlashTelemetry() for fleet visibility
- ConfigManager: remove fwVersion from DeviceConfig (always read from
  FW_VERSION constant); saveDeviceConfig/loadDeviceConfig are now no-ops;
  fallbackServerUrl replaced with fallbackServerUrls[2] array
- HealthMonitor: add AlertCallback + setAlertCallback() firing on state
  transitions (including CLEARED on recovery)
- CommunicationRouter: wire HealthMonitor alert callback on begin();
  add publishAlert() and publishInfo() for MQTT status topics
- MQTTDriver: add _alertsTopic + _infoTopic; add publishDirect() for
  absolute topic publishing; migrate heartbeat to JsonDocument
- ResponseBuilder, ClientManager, BellEngine: StaticJsonDocument /
  DynamicJsonDocument → JsonDocument; remove dead notifyBellsFired()
- docs: reorganise into architecture/, dev/, features/, reference/

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-14 22:15:27 +02:00
bonaminandClaude Sonnet 4.6 c3dc0a79bc refactor(comms): clean up Communication folder structure
- Delete dead code: CommandHandler (700-line God Class) and
  HTTPRequestHandler — both replaced by new architecture in Stage 4
- Create Drivers/ group for the three low-level protocol drivers,
  mirroring the Transport/ pattern:
    MQTTAsyncClient    → Drivers/MQTTDriver    (class: MQTTDriver)
    WebSocketServer    → Drivers/WebSocketDriver (class: WebSocketDriver)
    UARTCommandHandler → Drivers/UARTDriver    (class: UARTDriver)
- Update all includes and type references across CommunicationRouter,
  all three Transport wrappers, and MQTTHandler
- Add -std=gnu++14 + build_unflags to platformio.ini so std::make_unique
  compiles on ESP32 (required by CommunicationRouter::registerHandlers)

Build: passing

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-28 23:22:50 +02:00
bonaminandClaude Sonnet 4.6 682c604abe feat(comms): Stages 3–6 — transport layer, router simplification, legacy adapter, WebServerTransport
## Stage 3 — Transport Layer
- MQTTTransport: wraps MQTTAsyncClient, implements ITransport
- WebSocketTransport: wraps WebSocketServer + ClientManager; broadcastToMasters/Secondary
- HTTPTransport: first-class HTTP identity (no more 0xFFFFFFFF fake WS client); registers
  POST /api/command, GET /api/ping, GET /api/status; reply lambda captures AsyncWebServerRequest*
- UARTTransport: wraps UARTCommandHandler; UART whitelist enforced before dispatch

## Stage 4 — CommunicationRouter simplification
- Router now owns CommandBus + 4 transports; registerHandlers() wires all 10 domain handlers
- Old CommandHandler marked DEPRECATED on disk, no longer called
- HTTPRequestHandler no longer instantiated (replaced by HTTPTransport)
- ResponseBuilder::fromResult() factory method added
- main.cpp: all setXxxReference() calls moved before begin(); HealthMonitor + OutputManager wired

## Stage 5 — Legacy Adapter
- LegacyAdapter.hpp/cpp: 35 v1→v2 command mappings (simple 1:1, action-based, boolean splits)
- CommandBus::dispatch() applies translation when envelope.version == 1

## Stage 6 — WebServerTransport (4th transport, absorbs SettingsWebServer)
- WebServerTransport implements ITransport; registered in CommunicationRouter::begin()
- GET /settings: HTML settings page (PROGMEM template unchanged)
- POST /api/set-mode: routes network.set_config {permanent_ap_mode} through CommandBus
- POST /api/reboot: routes system.restart through CommandBus
- NetworkHandler::handleSetConfig: handles permanent_ap_mode field independently
- SettingsWebServer member removed from CommunicationRouter; src/SettingsWebServer/ is dead
  code, deletable in a follow-up PR once SettingsPage.h is moved

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-28 22:54:43 +02:00
bonaminandClaude Sonnet 4.6 f6107e2cfe feat(comms): Stage 2 — all 10 domain handlers implemented
Adds the complete set of v2 command handlers. Old CommandHandler is
untouched — handlers are standalone and not yet wired to anything.

Handlers added:
  PlaybackHandler  — playback (1 dependency)
  LoggingHandler   — log.set_serial/sd/mqtt
  FileHandler      — files.list/list_builtin/download/delete
  TelemetryHandler — telemetry.get_strikes/reset_strikes/get_loads
  RelayHandler     — relay.set_durations/set_outputs/get_config/test_output
  FirmwareHandler  — firmware.status/commit/rollback + ota.update/custom
  NetworkHandler   — network.info/status/set_config
  MQTTHandler      — mqtt.enable/disable
  SystemHandler    — ping/identify + system.* commands (8 total)
  ClockHandler     — 16 clock.* commands

Notable fixes vs. original CommandHandler:
  - clock.set_timings now sets pulseDuration/pauseDuration correctly
    (original called updateClockOutputs — was a bug)
  - system.restart uses a deferred FreeRTOS task (no blocking delay)
  - relay.test_output safety-gated: player must be fully stopped
  - Timekeeper class name (lowercase k) corrected throughout

Two compile-time fixes applied during build:
  - JsonVariantConst → const_cast<JsonDocument&>().as<JsonVariant>()
    (ConfigManager methods take non-const JsonVariant)
  - class TimeKeeper → class Timekeeper (actual class name in header)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-28 22:16:34 +02:00
bonaminandClaude Sonnet 4.6 6294044569 feat(comms): Stage 1 — CommandBus scaffolding (headers + skeleton)
Adds the core data structures and interfaces for the comms refactor.
No behaviour change — old CommandHandler is completely untouched.

New files:
  CommandEnvelope.hpp   — universal message wrapper (transport + command + reply lambda)
  CommandResult.hpp     — standardised return type with ok/err/info factories
  ICommandHandler.hpp   — interface every domain handler will implement
  ITransport.hpp        — interface every transport layer will implement
  CommandBus.hpp/.cpp   — registry + dispatcher (std::map, O(log n) lookup)

Two minor corrections vs. plan:
  std::unordered_map → std::map (Arduino String has no std::hash)
  LOG_WARN → LOG_WARNING (codebase macro name)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-28 22:04:51 +02:00
bonamin 30d660268f refactor: Fixed the file hierarchy and switched to platform.io 2026-02-28 21:57:42 +02:00
bonaminandClaude Sonnet 4.6 ab1e4f2e6d Merge feature/subsystem-logging into main
- Per-subsystem log tags across all firmware modules
- PlatformIO migration (ESP32-S3, env:vesper-v1)
- Manufacturing automation plan docs added
- .gitignore updated for PlatformIO build artifacts

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-26 17:32:31 +02:00
bonaminandClaude Sonnet 4.6 3877d27dae feat: Migrate firmware to PlatformIO (ESP32-S3, vesper-v1 env)
Replaces Arduino IDE with PlatformIO as the build system. Entry point
moved from vesper.ino to src/main.cpp. All library dependencies are now
declared in platformio.ini and downloaded automatically via lib_deps.

Board: Kincony KC868-A6 (ESP32-S3, 4MB flash) → env:vesper-v1
Future variants Vesper+ and Vesper Pro are pre-configured but commented out.

Compatibility fixes applied for this framework version:
- Removed ETH.h dependency (Ethernet was disabled in v138)
- Watchdog init updated to IDF v4 API (esp_task_wdt_init signature)
- ETH.linkUp() check removed from OTAManager

Also adds .pio/ to .gitignore and commits the manufacturing plan docs.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-26 17:31:53 +02:00
bonaminandClaude Sonnet 4.6 fe6b1d871a feat: Add per-subsystem log tags to all firmware modules
Refactored logging system to require a TAG as first argument on all
LOG_* macros, enabling per-subsystem log filtering and cleaner output.
Each subsystem now defines its own TAG (e.g. "BellEngine", "Player").
Also overhauled Logging.hpp/cpp with improved level control and output.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-26 17:31:28 +02:00
bonamin c656835d8e Fix LCD Communicaiton infinite looping upon failed commands 2026-02-10 18:45:41 +02:00
bonamin 980de08584 Fix Infinite Loop Bug, Melody Download crashes and dwnld skip if melody is builin. 2026-02-04 17:00:27 +02:00
bonamin 9c314d88cf Fixed Infinite Play bug
When Infinite Play was set once, it was never reset.
2026-02-03 15:46:47 +02:00
bonamin 53c55d2726 Added Sync Time to LCD, Fixed UTC Timestamp issues 2026-01-28 10:28:05 +02:00
bonamin 094b1a9620 Added UART as a communication interface option. 2026-01-19 21:24:35 +02:00
bonamin 11b98166d1 Fixed OTA problems, Clock Alerts and MQTT Logs. V151 2026-01-19 19:02:25 +02:00
bonamin 7e279c6e45 Added delay to NTP to let WiFi catch up before time request 2026-01-07 21:46:26 +02:00
bonamin eb6e0f0e5c Added Global Mutex for SD IOPS, and changed OTA to write directly to Flash 2026-01-07 21:04:33 +02:00
bonamin 7adc1fec34 Changed OTA to write Directly to flash 2026-01-07 15:46:20 +02:00
bonamin 51b7722e1d Removed Ethernet, added default WiFi (mikrotik AP) and fixed various Clock bugs. 2026-01-07 01:06:45 +02:00
bonamin 9f07e9ea39 Fixed a getter method in CommandHandler.cpp (player is playing) 2026-01-06 21:09:20 +02:00
bonamin 3d184773c1 Added Extra Heartbeat Metrics and Separated HTML Page 2025-12-29 20:38:52 +02:00
bonamin 953b5bd07d Added Reboot and Manual FW Update commands 2025-12-29 20:12:54 +02:00
bonamin db57b355b9 Added HTTP-API support, Standalone AP Support and Built-in Melodies 2025-12-28 21:49:49 +02:00
bonamin 0f0b67cab9 Added MQTT Logs, and improved OTA and NTP to Async 2025-12-28 18:39:13 +02:00
bonamin 8d397c6dd5 Reverted Websocket Code to previous commit 2025-12-26 10:02:41 +02:00
bonamin 7d9bc42078 Websocket Fix, Added Clock NTP Sync, Updated MQTT IP 2025-12-26 09:33:24 +02:00
bonamin b04590d270 Added MQTT Heartbeat and changed Firware Versioning System 2025-12-03 18:22:17 +02:00
bonamin a7f1bd1667 Added Telemetry data report to the App 2025-10-31 21:10:38 +02:00
bonamin f286abb023 Updates to BellEngine, ClientManager, ConfigManager, and Telemetry Logging 2025-10-30 22:42:01 +02:00
bonamin c9f1e8e4ae Fixed Single-loop mode playing multiple times on fast speeds. 2025-10-29 08:55:36 +02:00
bonamin 06891e8d82 Fixed issue with Bell Assignments 2025-10-26 11:08:19 +02:00
bonamin d1835beff5 Added Set Log Level Commands 2025-10-23 09:34:44 +03:00
bonamin 470d7bfacc Fixed Indexing on Bell Output Assignments 2025-10-18 18:43:51 +03:00
bonamin cc0bec97b5 Added Network Info Command 2025-10-15 12:44:10 +03:00
bonamin d6f105319d fixed WiFi not setting Hostname 2025-10-14 19:14:59 +03:00
bonamin fce760ebe0 Removed Firmware Load from SD during boot 2025-10-13 17:50:25 +03:00
bonamin 956786321a Fixed MQTT and WS Routing - w/o SSL 2025-10-13 17:34:54 +03:00
bonamin f696984cd1 Complete Rebuild, with Subsystems for each component. RTOS Tasks. (help by Claude) 2025-10-01 12:42:00 +03:00
bonamin 104c1d04d4 Stop tracking build folder and ignore it 2025-10-01 12:33:30 +03:00
bonamin 101f9e7135 MAJOR update. More like a Backup before things get Crazy
Added Websocket Support
Added Universal Message Handling for both MQTT and WS
Added Timekeeper Class, that handles Physical Clock and Scheduling
Added Bell Assignment Settings, Note to Bell mapping
2025-09-05 19:27:13 +03:00
bonamin c1fa1d5e57 Added basic WebSocket Functionality 2025-07-12 18:14:40 +03:00
bonamin 516eeab751 Added basic Logger with 4 modes. 2025-01-26 18:02:39 +02:00
bonamin 7dd6f81264 Added basic Scheduling Functionality
A JSON message can now be received on:
'vesper/DEV_ID/control/addSchedule"
Each message, must hold a "file" and "data".
The file is the month's name in 3 letter mode (eg jan, feb, mar)
The data is an entry for each day of the month.
Each day can be an array containing multiple items.
2025-01-26 14:02:15 +02:00
bonamin 84534025f4 Added Separate Timings for each Relay
The setting is saved on a file in:
/settings/relayTimings.json

Then during bootup, it's read and restored. 
Settings can be set via MQTT command on Topic: 
vesoer/*dev-id*/control/settings/relayTimers
using a json format. 
{ "b1":50, b2...}
where b1 is Bell 1, b2 Bell 2, etc..
2025-01-21 11:42:23 +02:00
bonamin a33f626dde Added initial Melody Playback Ability
Now, controlled via MQTT a Playback of a melody can Start, Stop, Pause 
etc. 

Settings like speed, total duration, pauses etc can be set.
2025-01-19 21:15:07 +02:00