mirror of
https://github.com/ipnet-mesh/meshcore-mqtt.git
synced 2026-05-07 22:04:44 +02:00
refactor: move CONNECTED/DISCONNECTED events from default to optional
This commit is contained in:
@@ -70,12 +70,12 @@ The bridge supports configurable event subscriptions:
|
||||
|
||||
**Default Events**:
|
||||
- `CONTACT_MSG_RECV`, `CHANNEL_MSG_RECV` (messages)
|
||||
- `CONNECTED`, `DISCONNECTED` (connection status)
|
||||
- `LOGIN_SUCCESS`, `LOGIN_FAILED` (authentication)
|
||||
- `DEVICE_INFO`, `BATTERY`, `NEW_CONTACT` (device info)
|
||||
- `ADVERTISEMENT`, `TRACE_DATA` (network diagnostics)
|
||||
|
||||
**Additional Events**:
|
||||
- `CONNECTED`, `DISCONNECTED` (connection status, can be noisy)
|
||||
- `TELEMETRY`, `POSITION`
|
||||
- `ROUTING`, `ADMIN`, `USER`
|
||||
- `TEXT_MESSAGE_RX`, `TEXT_MESSAGE_TX`
|
||||
|
||||
@@ -217,8 +217,6 @@ The bridge can subscribe to various MeshCore event types. You can configure whic
|
||||
If no events are specified, the bridge subscribes to these default events:
|
||||
- `CONTACT_MSG_RECV` - Contact messages received
|
||||
- `CHANNEL_MSG_RECV` - Channel messages received
|
||||
- `CONNECTED` - Device connection events
|
||||
- `DISCONNECTED` - Device disconnection events
|
||||
- `LOGIN_SUCCESS` - Successful authentication
|
||||
- `LOGIN_FAILED` - Failed authentication
|
||||
- `DEVICE_INFO` - Device information updates
|
||||
@@ -229,6 +227,8 @@ If no events are specified, the bridge subscribes to these default events:
|
||||
|
||||
### Additional Supported Events
|
||||
You can also subscribe to these additional event types:
|
||||
- `CONNECTED` - Device connection events (can be noisy)
|
||||
- `DISCONNECTED` - Device disconnection events (can be noisy)
|
||||
- `TELEMETRY` - Telemetry data
|
||||
- `POSITION` - Position/GPS updates
|
||||
- `USER` - User-related events
|
||||
@@ -297,9 +297,14 @@ The bridge publishes to these topics based on configured MeshCore events:
|
||||
- Subscribe to all direct messages: `{prefix}/message/direct/+`
|
||||
- Subscribe to messages from specific node: `{prefix}/message/direct/{specific_pubkey_prefix}`
|
||||
|
||||
**Trace Topic Subscription Patterns:**
|
||||
- Subscribe to all trace responses: `{prefix}/traceroute/+`
|
||||
- Subscribe to specific trace tag: `{prefix}/traceroute/12345`
|
||||
|
||||
Where:
|
||||
- `{channel_idx}` is the numeric channel identifier (e.g., 0, 1, 2)
|
||||
- `{pubkey_prefix}` is the sender's 6-byte public key prefix (hex encoded, e.g., `a1b2c3d4e5f6`)
|
||||
- `{tag}` is the trace identifier (32-bit integer, e.g., 12345)
|
||||
|
||||
**Other Published Topics:**
|
||||
- `{prefix}/login` - Authentication status from LOGIN_SUCCESS/LOGIN_FAILED events
|
||||
@@ -387,6 +392,16 @@ mosquitto_pub -h localhost -t "meshcore/command/send_trace" -m '{}'
|
||||
# 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"}'
|
||||
|
||||
# Send trace with specific tag for tracking responses
|
||||
mosquitto_pub -h localhost -t "meshcore/command/send_trace" \
|
||||
-m '{"tag": 67890, "path": "a0,b1,c2"}'
|
||||
|
||||
# Subscribe to all trace responses
|
||||
mosquitto_sub -h localhost -t "meshcore/traceroute/+"
|
||||
|
||||
# Subscribe to specific trace tag responses
|
||||
mosquitto_sub -h localhost -t "meshcore/traceroute/67890"
|
||||
```
|
||||
|
||||
### Available MeshCore Commands
|
||||
@@ -412,7 +427,7 @@ The bridge supports these MeshCore commands via MQTT:
|
||||
- `meshcore/battery` - Battery level updates
|
||||
- `meshcore/device_info` - Device specifications and capabilities
|
||||
- `meshcore/advertisement` - Device advertisement broadcasts
|
||||
- `meshcore/traceroute` - Network trace responses
|
||||
- `meshcore/traceroute/{tag}` - Network trace responses (tag-specific)
|
||||
- `meshcore/command/send_msg` - Send message command (subscribed)
|
||||
- `meshcore/command/ping` - Ping command (subscribed)
|
||||
- `meshcore/command/send_trace` - Send trace packet command (subscribed)
|
||||
|
||||
@@ -83,8 +83,6 @@ class MeshCoreConfig(BaseModel):
|
||||
default=[
|
||||
"CONTACT_MSG_RECV",
|
||||
"CHANNEL_MSG_RECV",
|
||||
"CONNECTED",
|
||||
"DISCONNECTED",
|
||||
"LOGIN_SUCCESS",
|
||||
"LOGIN_FAILED",
|
||||
"DEVICE_INFO",
|
||||
|
||||
@@ -373,7 +373,13 @@ class MQTTWorker:
|
||||
elif event_name == "ADVERTISEMENT":
|
||||
return f"{self.config.mqtt.topic_prefix}/advertisement"
|
||||
elif event_name == "TRACE_DATA":
|
||||
return f"{self.config.mqtt.topic_prefix}/traceroute"
|
||||
# Extract tag from trace data for topic path
|
||||
trace_tag = "unknown"
|
||||
if hasattr(event_data, "payload") and event_data.payload:
|
||||
trace_tag = event_data.payload.get("tag", "unknown")
|
||||
elif hasattr(event_data, "attributes") and event_data.attributes:
|
||||
trace_tag = event_data.attributes.get("tag", "unknown")
|
||||
return f"{self.config.mqtt.topic_prefix}/traceroute/{trace_tag}"
|
||||
|
||||
# Fallback for unknown event types
|
||||
return f"{self.config.mqtt.topic_prefix}/event"
|
||||
|
||||
@@ -23,8 +23,6 @@ class TestConfigurableEvents:
|
||||
expected_events = [
|
||||
"CONTACT_MSG_RECV",
|
||||
"CHANNEL_MSG_RECV",
|
||||
"CONNECTED",
|
||||
"DISCONNECTED",
|
||||
"LOGIN_SUCCESS",
|
||||
"LOGIN_FAILED",
|
||||
"DEVICE_INFO",
|
||||
@@ -54,8 +52,6 @@ class TestConfigurableEvents:
|
||||
valid_events = [
|
||||
"CONTACT_MSG_RECV",
|
||||
"CHANNEL_MSG_RECV",
|
||||
"CONNECTED",
|
||||
"DISCONNECTED",
|
||||
"LOGIN_SUCCESS",
|
||||
"LOGIN_FAILED",
|
||||
"MESSAGES_WAITING",
|
||||
@@ -216,8 +212,6 @@ class TestConfigurableEvents:
|
||||
expected_events = [
|
||||
"CONTACT_MSG_RECV",
|
||||
"CHANNEL_MSG_RECV",
|
||||
"CONNECTED",
|
||||
"DISCONNECTED",
|
||||
"LOGIN_SUCCESS",
|
||||
"LOGIN_FAILED",
|
||||
"DEVICE_INFO",
|
||||
|
||||
Reference in New Issue
Block a user