Reverted a lot of cruft
This commit is contained in:
19
gauge.py
19
gauge.py
@@ -883,8 +883,6 @@ def _subscribe_all(c):
|
|||||||
|
|
||||||
def connect_mqtt():
|
def connect_mqtt():
|
||||||
global client_ref, _mqtt_connected
|
global client_ref, _mqtt_connected
|
||||||
from umqtt.robust import MQTTClient
|
|
||||||
gc.collect()
|
|
||||||
info(f"Connecting to MQTT broker {MQTT_BROKER}:{MQTT_PORT} ...")
|
info(f"Connecting to MQTT broker {MQTT_BROKER}:{MQTT_PORT} ...")
|
||||||
last_error = None
|
last_error = None
|
||||||
for attempt in range(3):
|
for attempt in range(3):
|
||||||
@@ -892,8 +890,6 @@ def connect_mqtt():
|
|||||||
try:
|
try:
|
||||||
if client_ref is not None:
|
if client_ref is not None:
|
||||||
try:
|
try:
|
||||||
if client_ref.sock:
|
|
||||||
client_ref.sock.settimeout(2)
|
|
||||||
client_ref.disconnect()
|
client_ref.disconnect()
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
@@ -910,18 +906,11 @@ def connect_mqtt():
|
|||||||
client.connect()
|
client.connect()
|
||||||
client_ref = client
|
client_ref = client
|
||||||
_mqtt_connected = True
|
_mqtt_connected = True
|
||||||
gc.collect()
|
info(f"MQTT connected client_id={MQTT_CLIENT_ID}")
|
||||||
info(f"MQTT connected client_id={MQTT_CLIENT_ID} heap {gc.mem_free()} bytes")
|
|
||||||
return
|
return
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
last_error = e
|
last_error = e
|
||||||
log_err(f"MQTT connect attempt {attempt + 1} failed: {type(e).__name__}: {e}")
|
log_err(f"MQTT connect attempt {attempt + 1} failed: {type(e).__name__}: {e}")
|
||||||
try:
|
|
||||||
if client.sock:
|
|
||||||
client.sock.settimeout(2)
|
|
||||||
client.sock.close()
|
|
||||||
except Exception:
|
|
||||||
pass
|
|
||||||
gc.collect()
|
gc.collect()
|
||||||
utime.sleep_ms(1000)
|
utime.sleep_ms(1000)
|
||||||
|
|
||||||
@@ -971,12 +960,6 @@ def check_mqtt():
|
|||||||
return True
|
return True
|
||||||
except Exception as e2:
|
except Exception as e2:
|
||||||
log_err(f"MQTT reconnect attempt {attempt + 1} failed: {e2}")
|
log_err(f"MQTT reconnect attempt {attempt + 1} failed: {e2}")
|
||||||
try:
|
|
||||||
if client_ref.sock:
|
|
||||||
client_ref.sock.settimeout(2)
|
|
||||||
client_ref.sock.close()
|
|
||||||
except Exception:
|
|
||||||
pass
|
|
||||||
gc.collect()
|
gc.collect()
|
||||||
utime.sleep_ms(2000)
|
utime.sleep_ms(2000)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user