Skip to content

Conversation

@agessaman
Copy link

@agessaman agessaman commented Nov 8, 2025

This adds command codes that return the same data as stats-core, stats-radio, and stats-packets do on repeaters and room servers. The responses are formatted in json, the same as the other devices.

  • Added new commands for retrieving statistics: CMD_GET_STATS_CORE, CMD_GET_STATS_RADIO, and CMD_GET_STATS_PACKETS.
  • Added matching response handling methods to format and send statistics data.
  • Updated MyMesh constructor to initialize new member variables for managing statistics.
  • Included StatsFormatHelper for formatting statistics replies.

These could be useful statistics to gather periodically to display device utilization in a client app. They would also definitely be useful for providing network metrics using a companion device as an observer device.

I have a parallel PR for meshcore_py ready to go that accesses these codes:

INFO:meshcore:Found device: 00DDF382-9A5E-F28A-7589-7493F94BF0C6: MeshCore-HOWL
INFO:meshcore:BLE Connection started
Connected successfully!

Fetching core statistics...
📊 Core Statistics:
{
  "battery_mv": 4012,
  "uptime_secs": 1203,
  "errors": 0,
  "queue_len": 0
}

Fetching radio statistics...
📡 Radio Statistics:
{
  "noise_floor": -83,
  "last_rssi": -44,
  "last_snr": 12.25,
  "tx_air_secs": 0,
  "rx_air_secs": 38
}

Fetching packet statistics...
📦 Packet Statistics:
{
  "recv": 127,
  "sent": 2,
  "flood_tx": 2,
  "direct_tx": 0,
  "flood_rx": 126,
  "direct_rx": 1
}

Disconnecting...
Disconnected.

@agessaman agessaman force-pushed the companion-stats branch 3 times, most recently from a528908 to bd29312 Compare November 9, 2025 04:53
- Introduced new commands for retrieving statistics: CMD_GET_STATS_CORE, CMD_GET_STATS_RADIO, and CMD_GET_STATS_PACKETS.
- Implemented corresponding response handling methods to format and send statistics data.
- Updated MyMesh constructor to initialize new member variables for managing statistics.
- Included StatsFormatHelper for formatting statistics replies.
Updated formatStatsReply method to use new member variables for statistics handling.
Removed excess variable creation
…tting for consistency with other companion commands. Added documentation of frame structure with code examples.
@agessaman
Copy link
Author

Updated to use binary frames to be consistent with other companion commands at Liam's suggestion.

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