Files
project-vesper/docs/reference/api-reference.md
T
bonaminandClaude Sonnet 4.6 399b4d056c feat(heartbeat): add rssi to heartbeat payload
WiFi signal strength (dBm) now included in every heartbeat message.
Docs updated: MQTTDriver README, api-reference, heartbeat feature doc.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-13 02:10:41 +03:00

22 KiB
Raw Blame History

Vesper Firmware — API Reference (v2)

Command reference for the Vesper Bell Automation System. Firmware v2 command bus architecture — all transports, all handlers. Last updated: 2026-03-16


Overview

Message Envelope

Every command sent to Vesper uses this JSON envelope:

{
  "v": 2,
  "cmd": "namespace.command",
  "contents": { ... }
}
Field Type Notes
v int Protocol version. 2 = current. Omit or set 1 for legacy (LegacyAdapter runs).
cmd string namespace.command format (e.g. relay.set_durations).
contents object Command payload. May be omitted if command takes no fields.

Response Envelope

{
  "status": "SUCCESS" | "ERROR",
  "type": "command_name",
  "payload": { ... }
}

payload is command-specific. On error, payload typically contains a "message" string.


Transports

Transport Address Direction Notes
MQTT vesper/{device_id}/control Inbound commands Responses go to vesper/{device_id}/data
MQTT vesper/{device_id}/data Outbound responses + events Command replies and bell overload notifications
MQTT vesper/{device_id}/status/heartbeat Outbound, retained, QoS 1 Heartbeat every 30s; server updates last_seen
MQTT vesper/{device_id}/status/alerts Outbound, QoS 1 Subsystem state-change events (published on change only)
MQTT vesper/{device_id}/status/info Outbound, QoS 0 General device state events (playback, reboot reason, etc.)
WebSocket ws://{device_ip}/ws Bidirectional Requires identify on connect
HTTP http://{device_ip}/... REST Web console endpoints
UART Hardware serial Bidirectional Restricted — whitelist only (see below)
UDP Port 32101 Discovery broadcast Passive — device announces itself

UART Whitelist

Only the following commands are accepted over UART (LCD/button slave board). All others are silently dropped.

ping
playback
clock.pause
clock.resume
system.get_time

WebSocket — Client Identification

WebSocket clients must send identify immediately after connecting, or they will not receive targeted responses:

{ "v": 2, "cmd": "identify", "contents": { "device_type": "master" } }

device_type: "master" (app/console) or "secondary" (slave board).


Command Reference


ping

Handler SystemHandler
Transports All
Contents (none)
Returns { "status": "SUCCESS", "type": "pong" }
{ "v": 2, "cmd": "ping" }

identify

Handler SystemHandler
Transports WebSocket only
Contents device_type (required)
{ "v": 2, "cmd": "identify", "contents": { "device_type": "master" } }

playback

Handler PlaybackHandler
Transports All
Contents action (required) + melody fields

action values: "play", "stop", "pause", "unpause"

{ "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


relay.set_durations

Set strike duration (ms) for one or more bell channels. Partial updates accepted — omitted channels are unchanged.

Required At least one bell entry
Contents { "bells": { "0": 95, "2": 110 } }
{
  "v": 2,
  "cmd": "relay.set_durations",
  "contents": { "bells": { "0": 95, "1": 100, "2": 110 } }
}

relay.set_outputs

Map bell channels to physical relay outputs. Partial updates accepted.

Required At least one bell entry
Contents { "bells": { "0": 2, "1": 3 } }
{
  "v": 2,
  "cmd": "relay.set_outputs",
  "contents": { "bells": { "0": 2, "1": 3, "2": 4 } }
}

relay.get_config

Read current bell durations and output assignments.

Required (none)
Returns { "durations": { "0": 95, ... }, "outputs": { "0": 2, ... } }
{ "v": 2, "cmd": "relay.get_config" }

relay.test_output

Fire a specific relay for a caller-specified duration. Safety-gated: Player must be stopped.

Required output (int), duration_ms (int)
Notes Both fields required — no defaults. Typical range: 85–140 ms.
{
  "v": 2,
  "cmd": "relay.test_output",
  "contents": { "output": 2, "duration_ms": 95 }
}

Clock Namespace — ClockHandler


clock.set_outputs

Set which relay outputs the clock strikes use.

Required At least one of c1, c2
Contents { "c1": 4, "c2": 5 } — partial OK

clock.set_timings

Set clock strike timing configuration. Partial updates accepted.


clock.set_alerts

Configure hourly/quarter alert behavior. Partial updates accepted.


clock.set_backlight

Configure backlight behavior. Partial updates accepted.


clock.set_silence

Configure silence period (quiet hours). Partial updates accepted.


clock.set_time

Set the RTC time.

Required timestamp (Unix epoch, int)
Optional timezone_offset (int, seconds), dst_offset (int, seconds)
{
  "v": 2,
  "cmd": "clock.set_time",
  "contents": { "timestamp": 1740000000, "timezone_offset": 7200 }
}

clock.set_face

Set the physical analog clock face position.

Required hour (int), minute (int)
{ "v": 2, "cmd": "clock.set_face", "contents": { "hour": 10, "minute": 10 } }

clock.set_timezone

Set timezone independently of RTC time.

Required gmt_offset_sec (int)
Optional dst_offset_sec (int), timezone_name (string)
{
  "v": 2,
  "cmd": "clock.set_timezone",
  "contents": { "gmt_offset_sec": 7200, "dst_offset_sec": 3600, "timezone_name": "Europe/Athens" }
}

clock.get_timezone

Read current timezone settings.

Returns { "gmt_offset_sec": 7200, "dst_offset_sec": 3600, "timezone_name": "..." }

clock.sync_ntp

Force an immediate NTP time sync.

Required (none)

clock.enable / clock.disable

Enable or disable clock strike output.

{ "v": 2, "cmd": "clock.enable" }
{ "v": 2, "cmd": "clock.disable" }

clock.pause / clock.resume

Pause or resume clock updates.

{ "v": 2, "cmd": "clock.pause" }
{ "v": 2, "cmd": "clock.resume" }

clock.get_face

Read current analog clock face position.

Returns { "clock_hour", "clock_minute", "last_sync_time", "next_output_is_c1" }

clock.get_config

Read full clock configuration (outputs, timings, alerts, backlight, silence, enabled state).


System Namespace — SystemHandler


system.status

Get current device status: player state, strike counters, projected run time.

{ "v": 2, "cmd": "system.status" }

system.get_time

Get current RTC time.

Returns { "local_timestamp", "utc_timestamp", "year", "month", "day", "hour", "minute", "second", "rtc_available" }
{ "v": 2, "cmd": "system.get_time" }

system.get_settings

Get full ConfigManager JSON dump (all saved settings).

{ "v": 2, "cmd": "system.get_settings" }

system.get_device_info

Get device identity and runtime stats.

Returns { "uid", "hw_type", "hw_version", "fw_version", "uptime_ms", "free_heap", "min_free_heap" }
{ "v": 2, "cmd": "system.get_device_info" }

system.health

Get full HealthMonitor report — all subsystem states, warnings, critical failures.

{ "v": 2, "cmd": "system.health" }

system.factory_reset

Reset all settings to factory defaults.

Warning: Non-reversible. All saved configuration is wiped.

{ "v": 2, "cmd": "system.factory_reset" }

system.restart

Reboot the device. Response is sent before reboot (2s delay).

{ "v": 2, "cmd": "system.restart" }

Firmware Namespace — FirmwareHandler


firmware.status

Get firmware validation state.

Returns { "validation_state", "version", "boot_count", "can_commit", "can_rollback" }
{ "v": 2, "cmd": "firmware.status" }

firmware.commit

Commit the current firmware as permanent (marks OTA slot as valid).

{ "v": 2, "cmd": "firmware.commit" }

firmware.rollback

Roll back to the previous firmware. Device reboots.

{ "v": 2, "cmd": "firmware.rollback" }

OTA Namespace — FirmwareHandler


ota.status

Get OTA update status.

Returns { "current_version", "available_version", "channel", "update_available", "last_check", "progress" }
{ "v": 2, "cmd": "ota.status" }

ota.check

Check for available updates.

Optional channel (string, default "stable")
{ "v": 2, "cmd": "ota.check", "contents": { "channel": "beta" } }

ota.update

Trigger OTA update from VPS. Device may reboot.

Optional channel (string, default "stable")
{ "v": 2, "cmd": "ota.update", "contents": { "channel": "stable" } }

ota.custom

Flash firmware from a custom URL.

Required firmware_url (string)
Optional checksum (string), file_size (int), version (string)
{
  "v": 2,
  "cmd": "ota.custom",
  "contents": {
    "firmware_url": "http://example.com/firmware.bin",
    "checksum": "abc123",
    "version": "142"
  }
}

Network Namespace — NetworkHandler


network.info

Get IP/gateway/DNS.

Returns { "ip", "gateway", "dns" }
{ "v": 2, "cmd": "network.info" }

network.status

Get full connection state.

Returns { "connected", "state", "type", "ip", "rssi", "ap_mode" }
{ "v": 2, "cmd": "network.status" }

network.set_config

Update network configuration. Partial updates accepted. Returns restart_required flag.

Required At least one field
Optional hostname, useStaticIP, ip, gateway, subnet, dns1, dns2
Notes Static IP requires ip + gateway + subnet together
{
  "v": 2,
  "cmd": "network.set_config",
  "contents": { "hostname": "vesper-lab", "useStaticIP": false }
}

Files Namespace — FileHandler


files.list

List melody files on the SD card.

Returns Array of SD card melody file objects
{ "v": 2, "cmd": "files.list" }

files.list_builtin

List all built-in melodies compiled into the firmware.

Returns [{ "name": "...", "pid": "..." }, ...]
{ "v": 2, "cmd": "files.list_builtin" }

files.download

Download a melody from the server to the SD card.

Required melodys_uid (string)
{ "v": 2, "cmd": "files.download", "contents": { "melodys_uid": "ABC123" } }

files.delete

Delete a melody from the SD card.

Required name (string)
{ "v": 2, "cmd": "files.delete", "contents": { "name": "westminster.mel" } }

Log Namespace — LoggingHandler

Set log verbosity per output channel. Level 0 = off, 5 = verbose.

Level Meaning
0 None
1 Error
2 Warning
3 Info
4 Debug
5 Verbose

log.set_serial

{ "v": 2, "cmd": "log.set_serial", "contents": { "level": 0 } }

log.set_sd

{ "v": 2, "cmd": "log.set_sd", "contents": { "level": 0 } }

log.set_mqtt

{ "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:

"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:

{
  "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):

{
  "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:

{ "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"
{ "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.

{ "v": 2, "cmd": "rf.get_slots" }

Example response excerpt:

{
  "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)
{ "v": 2, "cmd": "rf.enable", "contents": { "enabled": true } }
{ "v": 2, "cmd": "rf.enable", "contents": { "enabled": false } }

MQTT Namespace — MQTTHandler

mqtt.enable / mqtt.disable

Enable or disable MQTT connectivity.

{ "v": 2, "cmd": "mqtt.enable" }
{ "v": 2, "cmd": "mqtt.disable" }

Telemetry Namespace — TelemetryHandler


telemetry.get_strikes

Get strike counts per bell channel.

Returns { "strikes": { "0": 1234, "1": 567, ... } }
{ "v": 2, "cmd": "telemetry.get_strikes" }

telemetry.reset_strikes

Reset strike counters. Omit bell to reset all channels; include it to reset one.

Optional bell (int) — channel index
{ "v": 2, "cmd": "telemetry.reset_strikes" }
{ "v": 2, "cmd": "telemetry.reset_strikes", "contents": { "bell": 2 } }

telemetry.get_loads

Get heat load per bell channel, cooling status, and overload flags.

Returns { "loads": { "0": 42.5, ... }, "cooling_active": false, "overloaded": [2, 5] }
{ "v": 2, "cmd": "telemetry.get_loads" }

MQTT Events (Unsolicited)

These messages are published by the device without a request. See mqtt-events.md for the full AsyncAPI-compatible reference.

Topic When QoS Retained Format
vesper/{id}/status/heartbeat Every 30s 1 yes Heartbeat envelope
vesper/{id}/status/alerts On subsystem state change only 1 no Alert envelope
vesper/{id}/status/info On device state change 0 no Info envelope
vesper/{id}/data Any command response / bell overload 0 no Standard response envelope

Heartbeat Payload

{
  "status": "INFO",
  "type": "heartbeat",
  "payload": {
    "device_id": "PV-26B18-VS01R-X7KQA",
    "firmware_version": "142",
    "timestamp": "Uptime: 5h 23m 45s",
    "ip_address": "10.0.0.3",
    "gateway": "10.0.0.1",
    "uptime_ms": 19425000,
    "rssi": -62
  }
}

Subscribe to vesper/+/status/heartbeat to discover all online devices.

Alert Payload (vesper/{id}/status/alerts)

Published only when a subsystem state changes. The server should store the active alert set per device and update the display in place rather than appending a log entry.

{ "subsystem": "FileManager", "state": "WARNING", "msg": "ConfigManager health check failed" }

On recovery:

{ "subsystem": "FileManager", "state": "CLEARED" }

state values: WARNING | CRITICAL | FAILED | CLEARED

Info Payload (vesper/{id}/status/info)

Published on significant device state changes. type identifies the event; payload is event-specific.

{ "type": "playback_started", "payload": { "pid": "ormilia_1_8" } }
{ "type": "playback_stopped", "payload": {} }

Legacy Compatibility (v1)

If a client sends "v": 1 (or omits v), the LegacyAdapter translates the old cmd + action pair to a v2 command before dispatch. No code changes needed on the client side during transition.

v1 cmd v1 action v2 cmd
ping — ping
identify — identify
playback — playback
file_manager list_melodies files.list
file_manager download_melody files.download
file_manager delete_melody files.delete
relay_setup set_timings relay.set_durations
relay_setup set_outputs relay.set_outputs
clock_setup set_outputs clock.set_outputs
clock_setup set_timings clock.set_timings
clock_setup set_alerts clock.set_alerts
clock_setup set_backlight clock.set_backlight
clock_setup set_silence clock.set_silence
clock_setup set_rtc_time clock.set_time
clock_setup set_physical_clock_time clock.set_face
clock_setup pause_clock_updates clock.pause
clock_setup resume_clock_updates clock.resume
clock_setup set_enabled + enabled=true clock.enable
clock_setup set_enabled + enabled=false clock.disable
system_info report_status system.status
system_info get_device_time system.get_time
system_info get_clock_time clock.get_face
system_info get_firmware_status firmware.status
system_info network_info network.info
system_info get_full_settings system.get_settings
system_info sync_time_to_lcd system.get_time (LCD now uses request/response)
system status system.status
system reset_defaults system.factory_reset
system commit_firmware firmware.commit
system rollback_firmware firmware.rollback
system get_firmware_status firmware.status
system set_network_config network.set_config
system set_serial_log_level log.set_serial
system set_sd_log_level log.set_sd
system set_mqtt_log_level log.set_mqtt
system set_mqtt_enabled + enabled=true mqtt.enable
system set_mqtt_enabled + enabled=false mqtt.disable
system restart system.restart
system reboot system.restart
system force_update ota.update
system custom_update ota.custom

Quick Reference

Namespace Commands
(root) ping, identify, playback
relay set_durations, set_outputs, get_config, test_output
clock set_outputs, set_timings, set_alerts, set_backlight, set_silence, set_time, set_face, set_timezone, get_timezone, sync_ntp, enable, disable, pause, resume, get_face, get_config
system status, get_time, get_settings, get_device_info, health, factory_reset, restart
firmware status, commit, rollback
ota status, check, update, custom
network info, status, set_config
files list, list_builtin, download, delete
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)