Improve bridge routing logs and stabilize control portal MQTT reconnect
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:
@@ -42,6 +42,7 @@ MQTT_BASE_TOPIC = os.getenv("MQTT_BASE_TOPIC", "evs")
|
||||
MQTT_TTS_TOPIC = os.getenv("MQTT_TTS_TOPIC", f"{MQTT_BASE_TOPIC}/+/play_pcm16le")
|
||||
MQTT_STATUS_RETAIN = getenv_bool("MQTT_STATUS_RETAIN", True)
|
||||
DEVICE_PAIR_MAP_JSON = os.getenv("DEVICE_PAIR_MAP", "").strip()
|
||||
WS_TX_CHUNK_BYTES = int(os.getenv("WS_TX_CHUNK_BYTES", "1024"))
|
||||
|
||||
HA_WEBHOOK_URL = os.getenv("HA_WEBHOOK_URL", "").strip()
|
||||
SAVE_SESSIONS = getenv_bool("SAVE_SESSIONS", True)
|
||||
@@ -118,7 +119,11 @@ class BridgeState:
|
||||
if not session:
|
||||
return False
|
||||
try:
|
||||
await session.ws.send(pcm_data)
|
||||
if not pcm_data:
|
||||
return True
|
||||
chunk_size = max(128, WS_TX_CHUNK_BYTES)
|
||||
for i in range(0, len(pcm_data), chunk_size):
|
||||
await session.ws.send(pcm_data[i : i + chunk_size])
|
||||
return True
|
||||
except Exception:
|
||||
log.exception("ws send to device failed")
|
||||
@@ -457,8 +462,18 @@ async def handle_binary_message(device_id: str, session: DeviceSession, data: by
|
||||
if ECHO_ENABLED:
|
||||
target_device = paired_output_device(device_id)
|
||||
ok = await state.send_binary_to_device(target_device, data)
|
||||
if not ok and target_device != device_id:
|
||||
log.debug("paired output device not connected: src=%s target=%s", device_id, target_device)
|
||||
if ok:
|
||||
if target_device != device_id:
|
||||
log.info(
|
||||
"audio routed: src=%s -> target=%s bytes=%s",
|
||||
device_id,
|
||||
target_device,
|
||||
len(data),
|
||||
)
|
||||
else:
|
||||
log.debug("audio echo self: device=%s bytes=%s", device_id, len(data))
|
||||
elif target_device != device_id:
|
||||
log.warning("paired output device not connected: src=%s target=%s", device_id, target_device)
|
||||
|
||||
|
||||
def parse_device_id(path: str) -> str:
|
||||
|
||||
Reference in New Issue
Block a user