Split MQTT events into dedicated topics
Some checks failed
Build and Push EVS Bridge Image / docker (push) Has been cancelled
Some checks failed
Build and Push EVS Bridge Image / docker (push) Has been cancelled
This commit is contained in:
@@ -60,8 +60,10 @@ Then upload firmware.
|
|||||||
## 4) MQTT topics
|
## 4) MQTT topics
|
||||||
|
|
||||||
- Status/events published by bridge:
|
- Status/events published by bridge:
|
||||||
- `evs/<device_id>/status` (JSON)
|
- `evs/<device_id>/status` (connection/start/stop/disconnect)
|
||||||
- includes `type: "vad_segment"` when a speech segment is finalized
|
- `evs/<device_id>/mic_level` (mic telemetry)
|
||||||
|
- `evs/<device_id>/vad_segment` (finalized speech segments)
|
||||||
|
- reserved for next steps: `evs/<device_id>/transcript`, `evs/<device_id>/stt_error`
|
||||||
- Playback input to device:
|
- Playback input to device:
|
||||||
- `evs/<device_id>/play_pcm16le`
|
- `evs/<device_id>/play_pcm16le`
|
||||||
- payload options:
|
- payload options:
|
||||||
|
|||||||
@@ -91,9 +91,24 @@ class BridgeState:
|
|||||||
def publish_status(self, device_id: str, payload: dict) -> None:
|
def publish_status(self, device_id: str, payload: dict) -> None:
|
||||||
if not self.mqtt_client:
|
if not self.mqtt_client:
|
||||||
return
|
return
|
||||||
|
msg_type = str(payload.get("type", "status"))
|
||||||
|
retain = MQTT_STATUS_RETAIN
|
||||||
|
if msg_type == "mic_level":
|
||||||
|
topic = f"{MQTT_BASE_TOPIC}/{device_id}/mic_level"
|
||||||
|
retain = False
|
||||||
|
elif msg_type == "vad_segment":
|
||||||
|
topic = f"{MQTT_BASE_TOPIC}/{device_id}/vad_segment"
|
||||||
|
retain = False
|
||||||
|
elif msg_type == "transcript":
|
||||||
|
topic = f"{MQTT_BASE_TOPIC}/{device_id}/transcript"
|
||||||
|
retain = False
|
||||||
|
elif msg_type == "stt_error":
|
||||||
|
topic = f"{MQTT_BASE_TOPIC}/{device_id}/stt_error"
|
||||||
|
retain = False
|
||||||
|
else:
|
||||||
topic = f"{MQTT_BASE_TOPIC}/{device_id}/status"
|
topic = f"{MQTT_BASE_TOPIC}/{device_id}/status"
|
||||||
try:
|
try:
|
||||||
self.mqtt_client.publish(topic, json.dumps(payload), qos=0, retain=MQTT_STATUS_RETAIN)
|
self.mqtt_client.publish(topic, json.dumps(payload), qos=0, retain=retain)
|
||||||
except Exception:
|
except Exception:
|
||||||
log.exception("mqtt publish failed")
|
log.exception("mqtt publish failed")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user