|
2 | 2 | appscreen.clean() |
3 | 3 |
|
4 | 4 | import lvgl as lv |
5 | | -import ota.update |
6 | | -from esp32 import Partition |
7 | 5 | import urequests |
8 | 6 | import ujson |
9 | | -import ota.status |
10 | | -import network |
11 | 7 | import time |
12 | 8 | import _thread |
13 | 9 |
|
@@ -41,7 +37,10 @@ def update_with_lvgl(url): |
41 | 37 | global install_button, status_label |
42 | 38 | install_button.add_flag(lv.obj.FLAG.HIDDEN) # or change to cancel button? |
43 | 39 | status_label.set_text("Update in progress.\nNavigate away to cancel.") |
| 40 | + import ota.update |
| 41 | + import ota.status |
44 | 42 | ota.status.status() |
| 43 | + from esp32 import Partition |
45 | 44 | current_partition = Partition(Partition.RUNNING) |
46 | 45 | print(f"Current partition: {current_partition}") |
47 | 46 | next_partition = current_partition.get_next_update() |
@@ -112,7 +111,9 @@ def show_update_info(): |
112 | 111 | status_label.set_text("Checking for OS updates...") |
113 | 112 | # URL of the JSON file |
114 | 113 | url = "http://demo.lnpiggy.com:2121/osupdate.json" # Adjust if the actual JSON URL differs |
| 114 | + print(f"osudpate.py: fetching {url}") |
115 | 115 | try: |
| 116 | + print("doing urequests.get()") |
116 | 117 | # Download the JSON |
117 | 118 | response = urequests.get(url) |
118 | 119 | # Check if request was successful |
@@ -146,10 +147,18 @@ def show_update_info(): |
146 | 147 | status_label = lv.label(appscreen) |
147 | 148 | status_label.align(lv.ALIGN.TOP_LEFT,0,NOTIFICATION_BAR_HEIGHT) |
148 | 149 |
|
149 | | -if not network.WLAN(network.STA_IF).isconnected(): |
| 150 | +network_connected = True |
| 151 | +try: |
| 152 | + import network |
| 153 | + network_connected = network.WLAN(network.STA_IF).isconnected() |
| 154 | +except Exception as e: |
| 155 | + print("Warning: could not check WLAN status:", str(e)) |
| 156 | + |
| 157 | +if not network_connected: |
150 | 158 | status_label.set_text("Error: WiFi is not connected.") |
151 | 159 | time.sleep(10) |
152 | 160 | else: |
| 161 | + print("Showing update info...") |
153 | 162 | show_update_info() |
154 | 163 |
|
155 | 164 | print("osupdate.py finished") |
0 commit comments