chore(release): beta-1.03
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -3,6 +3,9 @@ import gc
|
||||
import utime
|
||||
|
||||
from hello import broadcast_hello_udp
|
||||
from wifi_sta import try_reconnect
|
||||
|
||||
_UDP_HELLO_ATTEMPT = 0
|
||||
|
||||
|
||||
async def presets_loop(presets, wdt):
|
||||
@@ -21,11 +24,26 @@ async def presets_loop(presets, wdt):
|
||||
|
||||
|
||||
async def udp_hello_loop_after_http_ready(sta_if, settings, wdt, runtime_state):
|
||||
"""Broadcast hello at startup-fast cadence, then slower cadence."""
|
||||
"""UDP hello on cadence; if STA drops, one reconnect campaign per iteration."""
|
||||
global _UDP_HELLO_ATTEMPT
|
||||
await asyncio.sleep(1)
|
||||
started_ms = utime.ticks_ms()
|
||||
while True:
|
||||
if runtime_state.hello:
|
||||
try:
|
||||
wifi_ok = sta_if.isconnected()
|
||||
except Exception:
|
||||
wifi_ok = False
|
||||
if not wifi_ok:
|
||||
ssid = settings.get("ssid") or ""
|
||||
if ssid:
|
||||
try_reconnect(sta_if, ssid, settings.get("password") or "", wdt)
|
||||
try:
|
||||
wifi_ok = sta_if.isconnected()
|
||||
except Exception:
|
||||
wifi_ok = False
|
||||
if wifi_ok and runtime_state.hello:
|
||||
_UDP_HELLO_ATTEMPT += 1
|
||||
print("UDP hello broadcast attempt", _UDP_HELLO_ATTEMPT)
|
||||
try:
|
||||
broadcast_hello_udp(
|
||||
sta_if,
|
||||
@@ -37,5 +55,5 @@ async def udp_hello_loop_after_http_ready(sta_if, settings, wdt, runtime_state):
|
||||
except Exception as ex:
|
||||
print("UDP hello broadcast failed:", ex)
|
||||
elapsed_ms = utime.ticks_diff(utime.ticks_ms(), started_ms)
|
||||
interval_s = 5 if elapsed_ms < 60000 else 60
|
||||
interval_s = 10 if elapsed_ms < 120000 else 30
|
||||
await asyncio.sleep(interval_s)
|
||||
|
||||
Reference in New Issue
Block a user