OSUpdate: check update depending on current hardware identifier

This commit is contained in:
Thomas Farstrike
2025-10-13 19:22:22 +02:00
parent cc5c039906
commit ac1ff411c5
8 changed files with 36 additions and 4 deletions
+4
View File
@@ -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
+3
View File
@@ -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
+3
View File
@@ -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
+3
View File
@@ -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
@@ -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)
@@ -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": [
{
@@ -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()
+10
View File
@@ -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