MQTT trouble,still
This commit is contained in:
13
gauge.py
13
gauge.py
@@ -28,6 +28,12 @@ import gc
|
||||
from umqtt.robust import MQTTClient
|
||||
from machine import UART
|
||||
|
||||
# Activate WiFi driver before any heavy heap allocation so it can claim its
|
||||
# contiguous DRAM block before the Python heap fragments the address space.
|
||||
gc.collect()
|
||||
network.WLAN(network.STA_IF).active(True)
|
||||
gc.collect()
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Logging
|
||||
# ---------------------------------------------------------------------------
|
||||
@@ -530,7 +536,9 @@ _WIFI_CONNECT_ATTEMPTS = 3
|
||||
def _reset_wifi_interface():
|
||||
global _wifi_sta
|
||||
_wifi_sta = network.WLAN(network.STA_IF)
|
||||
_wifi_sta.active(True)
|
||||
if not _wifi_sta.active():
|
||||
_wifi_sta.active(True)
|
||||
utime.sleep_ms(500)
|
||||
try:
|
||||
_wifi_sta.disconnect()
|
||||
except Exception:
|
||||
@@ -1301,10 +1309,13 @@ def apply_motion_defaults():
|
||||
|
||||
|
||||
def main():
|
||||
gc.collect()
|
||||
info("=" * 48)
|
||||
info("Gauge MQTT controller starting")
|
||||
info(f"Heap free: {gc.mem_free()} bytes")
|
||||
info("=" * 48)
|
||||
|
||||
gc.collect()
|
||||
connect_wifi(WIFI_SSID, WIFI_PASSWORD, force_reconnect=False)
|
||||
|
||||
mqtt_attempts = 0
|
||||
|
||||
Reference in New Issue
Block a user