Discovery missing effects

This commit is contained in:
2026-04-21 23:34:17 +02:00
parent c57e0d8ae2
commit ffd807ff45

View File

@@ -889,12 +889,20 @@ def connect_mqtt():
for attempt in range(3):
gc.collect()
try:
_wifi_sta = network.WLAN(network.STA_IF)
if _wifi_sta.isconnected():
_wifi_sta.active(False)
utime.sleep_ms(100)
_wifi_sta.active(True)
utime.sleep_ms(200)
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:
try:
if client_ref.sock:
@@ -1350,7 +1358,7 @@ def main():
info("=" * 48)
gc.collect()
connect_wifi(WIFI_SSID, WIFI_PASSWORD, force_reconnect=True)
connect_wifi(WIFI_SSID, WIFI_PASSWORD)
mqtt_attempts = 0
while True:
@@ -1363,7 +1371,7 @@ def main():
if mqtt_attempts % 3 == 0:
log_err("WiFi may be stale — forcing reconnect...")
try:
connect_wifi(WIFI_SSID, WIFI_PASSWORD, force_reconnect=True)
connect_wifi(WIFI_SSID, WIFI_PASSWORD)
except Exception as we:
log_err(f"WiFi reconnect failed: {we}")
utime.sleep_ms(5000)