From 81dccc89fccb74d9f7b4d4beec2ffe8adbd1f065 Mon Sep 17 00:00:00 2001 From: Logan Cusano Date: Mon, 29 Dec 2025 19:02:20 -0500 Subject: [PATCH] Implement metadata capture --- app/c2_main.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/app/c2_main.py b/app/c2_main.py index 31aaff8..35e98da 100644 --- a/app/c2_main.py +++ b/app/c2_main.py @@ -49,6 +49,7 @@ def on_connect(client, userdata, flags, rc): print(f"Brain connected to MQTT Broker with result code {rc}") client.subscribe("nodes/+/checkin") client.subscribe("nodes/+/status") + client.subscribe("nodes/+/metadata") def on_message(client, userdata, msg): if MAIN_LOOP: @@ -109,6 +110,20 @@ async def handle_message(msg): if node_id in ACTIVE_NODES_CACHE: ACTIVE_NODES_CACHE[node_id].update(data) + elif event_type == "metadata": + # Handle call start/end metadata events + print(f"Metadata received from {node_id}: {payload.get('event')}") + + doc_data = { + "node_id": node_id, + "received_at": timestamp, + "event_type": payload.get("event"), + "node_timestamp": payload.get("timestamp"), + **payload.get("metadata", {}) + } + + await async_firestore(db.collection("metadata").add, doc_data) + except Exception as e: print(f"Error processing MQTT message from {node_id}: {e}") traceback.print_exc()