diff --git a/app/node_main.py b/app/node_main.py index cb2485f..592f107 100644 --- a/app/node_main.py +++ b/app/node_main.py @@ -212,6 +212,7 @@ async def mqtt_lifecycle_manager(): if response.status_code == 200: data = response.json() + LOGGER.debug(f"Response from OP25 API: {data}") current_tgid = 0 current_meta = {} @@ -246,9 +247,11 @@ async def mqtt_lifecycle_manager(): if current_tgid != last_tgid: if last_tgid != 0: + LOGGER.debug(f"Switching TGID: {last_tgid} -> {current_tgid}") payload = {"node_id": NODE_ID, "timestamp": now.isoformat(), "event": "call_end", "metadata": last_metadata} client.publish(f"nodes/{NODE_ID}/metadata", json.dumps(payload), qos=0) + LOGGER.debug(f"Call Start: TGID {current_tgid} ({current_meta.get('alpha_tag')})") payload = {"node_id": NODE_ID, "timestamp": now.isoformat(), "event": "call_start", "metadata": current_meta} client.publish(f"nodes/{NODE_ID}/metadata", json.dumps(payload), qos=0) last_tgid = current_tgid @@ -256,16 +259,20 @@ async def mqtt_lifecycle_manager(): elif last_tgid != 0: if potential_end_time is None: + LOGGER.debug(f"Signal lost for TGID {last_tgid}. Starting debounce.") potential_end_time = now elif (now - potential_end_time).total_seconds() > DEBOUNCE_SECONDS: + LOGGER.debug(f"Call End (Debounce expired): TGID {last_tgid}") payload = {"node_id": NODE_ID, "timestamp": now.isoformat(), "event": "call_end", "metadata": last_metadata} client.publish(f"nodes/{NODE_ID}/metadata", json.dumps(payload), qos=0) last_tgid = 0 last_metadata = {} potential_end_time = None + else: + LOGGER.debug(f"OP25 API returned status: {response.status_code}") - except Exception: - pass # OP25 might be restarting or busy + except Exception as e: + LOGGER.warning(f"Metadata watcher error: {e}") await asyncio.sleep(0.25)