separation of production and development
environments Adding new migrations for renaming and adding fields to the database schema persistent uuid for simclient
This commit is contained in:
@@ -142,9 +142,22 @@ def send_discovery(client, client_id, hardware_token, ip_addr):
|
||||
logging.info(f"Discovery-Nachricht gesendet: {discovery_msg}")
|
||||
|
||||
|
||||
def get_persistent_uuid(uuid_path="/data/client_uuid.txt"):
|
||||
# Prüfe, ob die Datei existiert
|
||||
if os.path.exists(uuid_path):
|
||||
with open(uuid_path, "r") as f:
|
||||
return f.read().strip()
|
||||
# Generiere neue UUID und speichere sie
|
||||
new_uuid = str(uuid.uuid4())
|
||||
os.makedirs(os.path.dirname(uuid_path), exist_ok=True)
|
||||
with open(uuid_path, "w") as f:
|
||||
f.write(new_uuid)
|
||||
return new_uuid
|
||||
|
||||
|
||||
def main():
|
||||
global discovered
|
||||
client_id = str(uuid.uuid4())
|
||||
client_id = get_persistent_uuid()
|
||||
hardware_token = get_hardware_token()
|
||||
ip_addr = get_ip()
|
||||
client = mqtt.Client(protocol=mqtt.MQTTv311, callback_api_version=2)
|
||||
|
||||
Reference in New Issue
Block a user