From 6062c2aff700042739a4f1b76c66c20362f151df Mon Sep 17 00:00:00 2001 From: c1328 <112856305+c1328@users.noreply.github.com> Date: Thu, 5 Feb 2026 22:44:52 +0100 Subject: [PATCH] Implement channel database and argument parsing Added channel database and command line argument handling for channel selection. --- mqtt-json-parse.py => mqtt-json-decryptor.py | 36 +++++++++++++------- 1 file changed, 24 insertions(+), 12 deletions(-) rename mqtt-json-parse.py => mqtt-json-decryptor.py (84%) diff --git a/mqtt-json-parse.py b/mqtt-json-decryptor.py similarity index 84% rename from mqtt-json-parse.py rename to mqtt-json-decryptor.py index bbeb27d..714dab2 100644 --- a/mqtt-json-parse.py +++ b/mqtt-json-decryptor.py @@ -1,23 +1,35 @@ +import sys import json import time import logging import paho.mqtt.client as mqtt from meshtastic_mqtt_json import MeshtasticMQTT -# --- CONFIGURATION --- -LOCAL_BROKER = "mqtt" -LOCAL_PORT = 1883 -LOCAL_USER = "" -LOCAL_PASS = "" +# --- CHANNEL DATABASE --- +# Add all your channels here +CHANNELS = { + "Puig": {"index": 0, "key": "BASE64_KEY_1"}, + "Default": {"index": 1, "key": "BASE64_KEY_2"}, + "Privat": {"index": 2, "key": "BASE64_KEY_3"} +} -# Channel Details -CHANNEL_NAME = "" # Name of the channel (e.g., "Puig") -CHANNEL_INDEX = 0 # Channel index on the hardware (usually 0) -CHANNEL_KEY = "" # Base64 encryption key -REGION = "EU_868" +# Get channel name from command line argument +if len(sys.argv) < 2 or sys.argv[1] not in CHANNELS: + print(f"Usage: python3 decryptor.py ") + print(f"Available channels: {', '.join(CHANNELS.keys())}") + sys.exit(1) -# Path Configuration for ioBroker Monitoring -ENCRYPTED_ROOT = f"msh/{REGION}/2/e/" +CHANNEL_NAME = sys.argv[1] +CHANNEL_INDEX = CHANNELS[CHANNEL_NAME]["index"] +CHANNEL_KEY = CHANNELS[CHANNEL_NAME]["key"] + +# --- REST OF CONFIGURATION --- +LOCAL_BROKER = "mqtt" +LOCAL_PORT = 1883 +LOCAL_USER = "user" +LOCAL_PASS = "pass" +REGION = "EU_868" +ENCRYPTED_ROOT = f"msh/{REGION}/2/e/" SERVICE_BASE_PATH = f"service/Decryptor/{CHANNEL_NAME}" # --- LOGGING SETUP ---