feat: add telemetry request command and move SELF_INFO to optional events

This commit is contained in:
Louis King
2025-08-19 23:06:23 +01:00
parent 9f49979a6a
commit 31c727cab0
5 changed files with 20 additions and 6 deletions
+7 -2
View File
@@ -72,13 +72,13 @@ The bridge supports configurable event subscriptions:
- `CONTACT_MSG_RECV`, `CHANNEL_MSG_RECV` (messages)
- `DEVICE_INFO`, `BATTERY`, `NEW_CONTACT` (device info)
- `ADVERTISEMENT`, `TRACE_DATA` (network diagnostics)
- `TELEMETRY_RESPONSE`, `SELF_INFO`, `CHANNEL_INFO` (device details)
- `TELEMETRY_RESPONSE`, `CHANNEL_INFO` (device details)
**Additional Events**:
- `CONNECTED`, `DISCONNECTED` (connection status, can be noisy)
- `LOGIN_SUCCESS`, `LOGIN_FAILED` (authentication)
- `MESSAGES_WAITING` (notifications)
- `CONTACTS` (contact list updates)
- `CONTACTS`, `SELF_INFO` (contact and device information)
### Auto-Fetch Restart Feature
@@ -129,6 +129,7 @@ The bridge supports bidirectional communication via MQTT commands. Send commands
| `ping` | Ping a node | `destination` | `meshcore.commands.ping()` |
| `send_advert` | Send device advertisement | None (optional: `flood`) | `meshcore.commands.send_advert()` |
| `send_trace` | Send trace packet for routing diagnostics | None (optional: `auth_code`, `tag`, `flags`, `path`) | `meshcore.commands.send_trace()` |
| `send_telemetry_req` | Request telemetry data from a node | `destination` | `meshcore.commands.send_telemetry_req()` |
**Command Examples**:
```json
@@ -200,6 +201,10 @@ mosquitto_pub -h localhost -t "meshcore/command/send_trace" -m '{}'
# Send trace packet with routing path
mosquitto_pub -h localhost -t "meshcore/command/send_trace" \
-m '{"auth_code": 12345, "path": "23,5f,3a"}'
# Request telemetry data from a node
mosquitto_pub -h localhost -t "meshcore/command/send_telemetry_req" \
-m '{"destination": "node123"}'
```
## Development Guidelines
+6 -1
View File
@@ -223,7 +223,6 @@ If no events are specified, the bridge subscribes to these default events:
- `ADVERTISEMENT` - Device advertisement broadcasts
- `TRACE_DATA` - Network trace information
- `TELEMETRY_RESPONSE` - Telemetry data responses
- `SELF_INFO` - Own device information
- `CHANNEL_INFO` - Channel configuration details
### Additional Supported Events
@@ -234,6 +233,7 @@ You can also subscribe to these additional event types:
- `LOGIN_FAILED` - Failed authentication
- `MESSAGES_WAITING` - Pending messages notification
- `CONTACTS` - Contact list updates
- `SELF_INFO` - Own device information
### Configuration Examples
@@ -384,6 +384,10 @@ mosquitto_pub -h localhost -t "meshcore/command/send_advert" \
# Send trace packet (basic routing diagnostics)
mosquitto_pub -h localhost -t "meshcore/command/send_trace" -m '{}'
# Request telemetry data from a node
mosquitto_pub -h localhost -t "meshcore/command/send_telemetry_req" \
-m '{"destination": "node123"}'
# Send trace packet with routing path through specific repeaters
mosquitto_pub -h localhost -t "meshcore/command/send_trace" \
-m '{"auth_code": 12345, "path": "23,5f,3a"}'
@@ -413,6 +417,7 @@ The bridge supports these MeshCore commands via MQTT:
| `ping` | Ping a node | `destination` | `{"destination": "node123"}` |
| `send_advert` | Send device advertisement | None (optional: `flood`) | `{}` or `{"flood": true}` |
| `send_trace` | Send trace packet for routing diagnostics | None (optional: `auth_code`, `tag`, `flags`, `path`) | `{}` or `{"auth_code": 12345, "path": "23,5f,3a"}` |
| `send_telemetry_req` | Request telemetry data from a node | `destination` | `{"destination": "node123"}` |
### Topic Examples
- `meshcore/message/channel/0` - Channel 0 messages
-1
View File
@@ -89,7 +89,6 @@ class MeshCoreConfig(BaseModel):
"ADVERTISEMENT",
"TRACE_DATA",
"TELEMETRY_RESPONSE",
"SELF_INFO",
"CHANNEL_INFO",
],
description="List of MeshCore event types to subscribe to",
+7
View File
@@ -343,6 +343,13 @@ class MeshCoreWorker:
auth_code=auth_code, tag=tag, flags=flags, path=path
)
elif command_type == "send_telemetry_req":
destination = command_data.get("destination")
if not destination:
self.logger.error("send_telemetry_req requires 'destination' field")
return
result = await self.meshcore.commands.send_telemetry_req(destination)
else:
self.logger.warning(f"Unknown command type: {command_type}")
return
-2
View File
@@ -29,7 +29,6 @@ class TestConfigurableEvents:
"ADVERTISEMENT",
"TRACE_DATA",
"TELEMETRY_RESPONSE",
"SELF_INFO",
"CHANNEL_INFO",
]
@@ -214,7 +213,6 @@ class TestConfigurableEvents:
"ADVERTISEMENT",
"TRACE_DATA",
"TELEMETRY_RESPONSE",
"SELF_INFO",
"CHANNEL_INFO",
]
assert config.meshcore.events == expected_events