Implement channel database and argument parsing

Added channel database and command line argument handling for channel selection.
This commit is contained in:
c1328
2026-02-05 22:44:52 +01:00
committed by GitHub
parent 204be1227d
commit 6062c2aff7

View File

@@ -1,23 +1,35 @@
import sys
import json import json
import time import time
import logging import logging
import paho.mqtt.client as mqtt import paho.mqtt.client as mqtt
from meshtastic_mqtt_json import MeshtasticMQTT from meshtastic_mqtt_json import MeshtasticMQTT
# --- CONFIGURATION --- # --- CHANNEL DATABASE ---
LOCAL_BROKER = "mqtt" # Add all your channels here
LOCAL_PORT = 1883 CHANNELS = {
LOCAL_USER = "<username>" "Puig": {"index": 0, "key": "BASE64_KEY_1"},
LOCAL_PASS = "<password>" "Default": {"index": 1, "key": "BASE64_KEY_2"},
"Privat": {"index": 2, "key": "BASE64_KEY_3"}
}
# Channel Details # Get channel name from command line argument
CHANNEL_NAME = "<channel>" # Name of the channel (e.g., "Puig") if len(sys.argv) < 2 or sys.argv[1] not in CHANNELS:
CHANNEL_INDEX = 0 # Channel index on the hardware (usually 0) print(f"Usage: python3 decryptor.py <channel_name>")
CHANNEL_KEY = "<key>" # Base64 encryption key print(f"Available channels: {', '.join(CHANNELS.keys())}")
REGION = "EU_868" sys.exit(1)
# Path Configuration for ioBroker Monitoring CHANNEL_NAME = sys.argv[1]
ENCRYPTED_ROOT = f"msh/{REGION}/2/e/" 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}" SERVICE_BASE_PATH = f"service/Decryptor/{CHANNEL_NAME}"
# --- LOGGING SETUP --- # --- LOGGING SETUP ---