From 882f4c09f6b4f7fc0b24567a65c31568298ac735 Mon Sep 17 00:00:00 2001 From: andre Date: Wed, 12 Nov 2025 08:33:16 +0000 Subject: [PATCH] Upload files to "/" --- .gitignore | 2 ++ SYSTEMDATA.DAT | Bin 0 -> 1024 bytes boot.py | 71 +++++++++++++++++++++++++++++++++++++++++++++++++ version.txt | 1 + wifi.dat | Bin 0 -> 1024 bytes 5 files changed, 74 insertions(+) create mode 100644 .gitignore create mode 100644 SYSTEMDATA.DAT create mode 100644 boot.py create mode 100644 version.txt create mode 100644 wifi.dat diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f117114 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +wifi.dat +SYSTEMDATA.DAT diff --git a/SYSTEMDATA.DAT b/SYSTEMDATA.DAT new file mode 100644 index 0000000000000000000000000000000000000000..06d7405020018ddf3cacee90fd4af10487da3d20 GIT binary patch literal 1024 ScmZQz7zLvtFd70QH3R?z00031 literal 0 HcmV?d00001 diff --git a/boot.py b/boot.py new file mode 100644 index 0000000..bc6ef72 --- /dev/null +++ b/boot.py @@ -0,0 +1,71 @@ +import network, urequests, machine, os, time +import wifi_manager + +SERVER_BASE = "https://github.com/TelegraphCommunicationSystem/Telegraph/archive/refs/tags/0.0.1.zip" # URL deines Servers +VERSION_URL = "https://git.bogner.systems/andre/test/raw/branch/main/version.txt" +LOCAL_VERSION_FILE = "version.txt" + +def connect_wifi(): + wlan = wifi_manager.get_connection() + if wlan is None: + print("Could not initialize the network connection.") + return False + print(wlan) + if wlan.isconnected(): + print("Network already connected.") + return True + +def get_local_version(): + try: + with open(LOCAL_VERSION_FILE, "r") as f: + return f.read().strip() + except: + return "0.0" + +def get_remote_version(): + try: + r = urequests.get(VERSION_URL) + if r.status_code == 200: + version = r.text.strip() + r.close() + print(f"Serverversion: {version}") + return version + except Exception as e: + print("Fehler beim Abrufen der Serverversion:", e) + return None + +def download_file(filename): + try: + url = SERVER_BASE + "/" + filename + r = urequests.get(url) + if r.status_code == 200: + with open(filename, "w") as f: + f.write(r.text) + print(f"{filename} aktualisiert.") + r.close() + except Exception as e: + print("Fehler beim Download:", e) + +def check_for_update(): + local_v = get_local_version() + remote_v = get_remote_version() + if not remote_v: + print("Keine Verbindung oder Version nicht gefunden.") + return + if remote_v != local_v: + print(f"Neue Version gefunden: {remote_v}") + for file in ["main.py", "utils.py"]: # Dateien, die aktualisiert werden sollen + download_file(file) + with open(LOCAL_VERSION_FILE, "w") as f: + f.write(remote_v) + print("Update abgeschlossen. Neustart...") + time.sleep(2) + machine.reset() + else: + print("Software ist aktuell.") + +if connect_wifi(): + check_for_update() + +# Wenn kein Update, dann normales Starten +#import main diff --git a/version.txt b/version.txt new file mode 100644 index 0000000..8a9ecc2 --- /dev/null +++ b/version.txt @@ -0,0 +1 @@ +0.0.1 \ No newline at end of file diff --git a/wifi.dat b/wifi.dat new file mode 100644 index 0000000000000000000000000000000000000000..06d7405020018ddf3cacee90fd4af10487da3d20 GIT binary patch literal 1024 ScmZQz7zLvtFd70QH3R?z00031 literal 0 HcmV?d00001