Reverted a lot of cruft

This commit is contained in:
2026-04-21 23:40:26 +02:00
parent ffd807ff45
commit af42a1c4de

View File

@@ -561,6 +561,7 @@ def connect_wifi(ssid, password, timeout_s=15, force_reconnect=False):
last_error = None last_error = None
for attempt in range(_WIFI_CONNECT_ATTEMPTS): for attempt in range(_WIFI_CONNECT_ATTEMPTS):
info(f"WiFi connecting to '{ssid}' (attempt {attempt + 1}/{_WIFI_CONNECT_ATTEMPTS}) ...") info(f"WiFi connecting to '{ssid}' (attempt {attempt + 1}/{_WIFI_CONNECT_ATTEMPTS}) ...")
_reset_wifi_interface()
try: try:
_wifi_sta.connect(ssid, password) _wifi_sta.connect(ssid, password)
deadline = utime.time() + timeout_s deadline = utime.time() + timeout_s
@@ -600,7 +601,7 @@ def check_wifi():
log_err("WiFi lost connection — attempting reconnect...") log_err("WiFi lost connection — attempting reconnect...")
try: try:
ip = connect_wifi(WIFI_SSID, WIFI_PASSWORD, timeout_s=15, force_reconnect=True) ip = connect_wifi(WIFI_SSID, WIFI_PASSWORD, timeout_s=15)
info(f"WiFi reconnected! IP:{ip}") info(f"WiFi reconnected! IP:{ip}")
except Exception as e: except Exception as e:
log_err(f"WiFi reconnect failed: {e}") log_err(f"WiFi reconnect failed: {e}")
@@ -889,20 +890,6 @@ def connect_mqtt():
for attempt in range(3): for attempt in range(3):
gc.collect() gc.collect()
try: try:
import usocket
s = usocket.socket(usocket.AF_INET, usocket.SOCK_STREAM)
s.settimeout(3)
try:
s.connect((MQTT_BROKER, MQTT_PORT))
info(" broker port reachable")
except Exception as e:
warn(f" broker unreachable: {e}")
try:
s.close()
except Exception:
pass
del usocket
gc.collect()
if client_ref is not None: if client_ref is not None:
try: try:
if client_ref.sock: if client_ref.sock: