Less aggressive checking
This commit is contained in:
@@ -140,7 +140,7 @@ _DEVICE = {
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
_wifi_reconnect_delay_s = 5
|
||||
_wifi_check_interval_ms = 5000
|
||||
_wifi_check_interval_ms = 30000
|
||||
_last_wifi_check = 0
|
||||
_wifi_sta = None
|
||||
|
||||
@@ -306,6 +306,7 @@ _target_value = GAUGE_MIN
|
||||
_last_rezero_ms = None # set to ticks_ms() in main()
|
||||
client_ref = None
|
||||
_mqtt_connected = False
|
||||
_last_mqtt_check = 0
|
||||
|
||||
|
||||
def _publish(topic, payload, retain=False):
|
||||
@@ -432,8 +433,17 @@ def connect_mqtt():
|
||||
return client
|
||||
|
||||
|
||||
_mqtt_check_interval_ms = 30000
|
||||
_last_mqtt_check = 0
|
||||
|
||||
|
||||
def check_mqtt():
|
||||
global client_ref, _mqtt_connected
|
||||
global client_ref, _mqtt_connected, _last_mqtt_check
|
||||
now = utime.ticks_ms()
|
||||
if utime.ticks_diff(now, _last_mqtt_check) < _mqtt_check_interval_ms:
|
||||
return _mqtt_connected
|
||||
_last_mqtt_check = now
|
||||
|
||||
if client_ref is None:
|
||||
return False
|
||||
|
||||
|
||||
Reference in New Issue
Block a user