Skip to content

feat: include radio stats in MQTT status messages#169

Open
Kpa-clawbot wants to merge 1 commit intorightup:mainfrom
Kpa-clawbot:feat/radio-stats-in-status
Open

feat: include radio stats in MQTT status messages#169
Kpa-clawbot wants to merge 1 commit intorightup:mainfrom
Kpa-clawbot:feat/radio-stats-in-status

Conversation

@Kpa-clawbot
Copy link
Copy Markdown

Summary

Adds periodic MQTT status messages that include radio and device statistics, enabling downstream monitoring tools to track repeater health in real time.

What

  • MQTT status publishing: The repeater now publishes a retained status message to <base_topic>/<node_name>/status every 5 minutes (configurable via mqtt.status_interval).
  • Last Will and Testament: Sets an MQTT LWT so the broker automatically publishes an "offline" status when the repeater disconnects unexpectedly.
  • Radio stats collection: Gathers uptime, noise floor, TX airtime, and placeholder fields for RX airtime and receive errors.

Message Format

{
  "status": "online",
  "origin": "<node_name>",
  "origin_id": "<node_id>",
  "stats": {
    "uptime_secs": 3600,
    "noise_floor": -95,
    "tx_air_secs": 42,
    "rx_air_secs": 0,
    "recv_errors": 0
  }
}

The format is compatible with meshcoretomqtt status messages, so tools like CoreScope can consume pyMC_Repeater status alongside other MeshCore nodes without any changes.

Configuration

mqtt:
  status_interval: 300  # seconds, set to 0 to disable

Notes

  • rx_air_secs and recv_errors are currently hardcoded to 0 since pyMC_Repeater doesn't track those metrics yet. They're included so consumers can distinguish "not tracked" from "field missing".
  • battery_mv is omitted (only relevant on embedded boards).

Adds noise_floor, tx_air_secs, rx_air_secs, recv_errors, and battery_mv
to the MQTT status message under a 'stats' key.

This enables downstream tools like CoreScope to display RF health metrics
(noise floor charts, airtime monitoring, jammer detection) for observers
running pyMC_Repeater.

The stats format matches meshcoretomqtt's output for compatibility.

Changes:
- MQTTHandler: add LWT (Last Will) for offline detection, add
  publish_status() for retained status messages
- StorageCollector: add get_device_stats() to gather radio metrics,
  add publish_status() convenience method
- RepeaterHandler (engine.py): publish status periodically (default
  every 5 minutes, configurable via mqtt.status_interval)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant