diff --git a/CHANGELOG.md b/CHANGELOG.md index e417c170..7d8ac289 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +0.1.1 +===== +- OSUpdate: check update depending on current hardware identifier + 0.1.0 ===== - Update to MicroPython 1.25.1 and LVGL 9.3 diff --git a/internal_filesystem/boot.py b/internal_filesystem/boot.py index 851090e4..078ac102 100644 --- a/internal_filesystem/boot.py +++ b/internal_filesystem/boot.py @@ -11,6 +11,9 @@ import lvgl as lv import task_handler import mpos.ui +import mpos.info + +mpos.info.set_hardware_id("waveshare-esp32-s3-touch-lcd-2") # Pin configuration SPI_BUS = 2 diff --git a/internal_filesystem/boot_fri3d-2024.py b/internal_filesystem/boot_fri3d-2024.py index 919d1a46..368ed38a 100644 --- a/internal_filesystem/boot_fri3d-2024.py +++ b/internal_filesystem/boot_fri3d-2024.py @@ -10,6 +10,9 @@ import lvgl as lv import task_handler import mpos.ui +import mpos.info + +mpos.info.set_hardware_id("fri3d-2024") # Pin configuration SPI_BUS = 2 diff --git a/internal_filesystem/boot_unix.py b/internal_filesystem/boot_unix.py index d9744115..e2a134a2 100644 --- a/internal_filesystem/boot_unix.py +++ b/internal_filesystem/boot_unix.py @@ -9,6 +9,9 @@ sys.path.append('lib/') import mpos.ui import mpos.clipboard +import mpos.info + +mpos.info.set_hardware_id("linux-desktop") # Same as Waveshare ESP32-S3-Touch-LCD-2 TFT_HOR_RES=320 diff --git a/internal_filesystem/builtin/apps/com.micropythonos.about/assets/about.py b/internal_filesystem/builtin/apps/com.micropythonos.about/assets/about.py index 62367b3c..b0e0b0f9 100644 --- a/internal_filesystem/builtin/apps/com.micropythonos.about/assets/about.py +++ b/internal_filesystem/builtin/apps/com.micropythonos.about/assets/about.py @@ -10,6 +10,8 @@ class About(Activity): screen.set_style_border_width(0, 0) screen.set_flex_flow(lv.FLEX_FLOW.COLUMN) screen.set_style_pad_all(mpos.ui.pct_of_display_width(2), 0) + label0 = lv.label(screen) + label0.set_text(f"Hardware ID: {mpos.info.get_hardware_id()}") label1 = lv.label(screen) label1.set_text(f"MicroPythonOS version: {mpos.info.CURRENT_OS_VERSION}") label2 = lv.label(screen) diff --git a/internal_filesystem/builtin/apps/com.micropythonos.osupdate/META-INF/MANIFEST.JSON b/internal_filesystem/builtin/apps/com.micropythonos.osupdate/META-INF/MANIFEST.JSON index 2c95c00f..b19addad 100644 --- a/internal_filesystem/builtin/apps/com.micropythonos.osupdate/META-INF/MANIFEST.JSON +++ b/internal_filesystem/builtin/apps/com.micropythonos.osupdate/META-INF/MANIFEST.JSON @@ -3,10 +3,10 @@ "publisher": "MicroPythonOS", "short_description": "Operating System Updater", "long_description": "Updates the operating system in a safe way, to a secondary partition. After the update, the device is restarted. If the system starts up successfully, it is marked as valid and kept. Otherwise, a rollback to the old, primary partition is performed.", -"icon_url": "https://apps.micropythonos.com/apps/com.micropythonos.osupdate/icons/com.micropythonos.osupdate_0.0.4_64x64.png", -"download_url": "https://apps.micropythonos.com/apps/com.micropythonos.osupdate/mpks/com.micropythonos.osupdate_0.0.4.mpk", +"icon_url": "https://apps.micropythonos.com/apps/com.micropythonos.osupdate/icons/com.micropythonos.osupdate_0.0.5_64x64.png", +"download_url": "https://apps.micropythonos.com/apps/com.micropythonos.osupdate/mpks/com.micropythonos.osupdate_0.0.5.mpk", "fullname": "com.micropythonos.osupdate", -"version": "0.0.4", +"version": "0.0.5", "category": "osupdate", "activities": [ { diff --git a/internal_filesystem/builtin/apps/com.micropythonos.osupdate/assets/osupdate.py b/internal_filesystem/builtin/apps/com.micropythonos.osupdate/assets/osupdate.py index d563406c..2c25e6e7 100644 --- a/internal_filesystem/builtin/apps/com.micropythonos.osupdate/assets/osupdate.py +++ b/internal_filesystem/builtin/apps/com.micropythonos.osupdate/assets/osupdate.py @@ -51,7 +51,13 @@ class OSUpdate(Activity): def show_update_info(self): self.status_label.set_text("Checking for OS updates...") - url = "https://updates.micropythonos.com/osupdate.json" + hwid = mpos.info.get_hardware_id() + if (hwid == "waveshare-esp32-s3-touch-lcd-2"): + infofile = "osupdate.json" + # Device that was first supported did not have the hardware ID in the URL, so it's special: + else: + infofile = f"osupdate_{hwid}.json" + url = f"https://updates.micropythonos.com/{infofile}" print(f"OSUpdate: fetching {url}") try: print("doing requests.get()") @@ -71,6 +77,7 @@ class OSUpdate(Activity): print("Changelog:", changelog) self.handle_update_info(version, download_url, changelog) else: + self.status_label.set_text(f"Error: {response.status_code} while checking\nfile: {infofile}\nat: {url}") print("Failed to download JSON. Status code:", response.status_code) # Close response response.close() diff --git a/internal_filesystem/lib/mpos/info.py b/internal_filesystem/lib/mpos/info.py index 0e81e19a..0304d1da 100644 --- a/internal_filesystem/lib/mpos/info.py +++ b/internal_filesystem/lib/mpos/info.py @@ -1 +1,11 @@ CURRENT_OS_VERSION = "0.1.0" + +# Unique string that defines the hardware, used by OSUpdate and the About app +_hardware_id = "missing-hardware-info" + +def set_hardware_id(value): + global _hardware_id + _hardware_id = value + +def get_hardware_id(): + return _hardware_id