|
@@ -15,6 +15,7 @@ def taskCheck():
|
|
|
"""
|
|
"""
|
|
|
time_sleep = 10
|
|
time_sleep = 10
|
|
|
count = 0
|
|
count = 0
|
|
|
|
|
+ config = getConfig()
|
|
|
while True:
|
|
while True:
|
|
|
if getConfig().runTask:
|
|
if getConfig().runTask:
|
|
|
try:
|
|
try:
|
|
@@ -24,9 +25,16 @@ def taskCheck():
|
|
|
print('MQTT 正常', getConfig().mqtt.host, getConfig().mqtt.port,getConfig().mqtt.subTopic)
|
|
print('MQTT 正常', getConfig().mqtt.host, getConfig().mqtt.port,getConfig().mqtt.subTopic)
|
|
|
if getConfig().mqtt.clientId is "":
|
|
if getConfig().mqtt.clientId is "":
|
|
|
print("设备未绑定")
|
|
print("设备未绑定")
|
|
|
- utils.send_ping()
|
|
|
|
|
|
|
+ utils.send_ping()
|
|
|
|
|
+ else:
|
|
|
|
|
+ # 有变化就上报一次
|
|
|
|
|
+ if config != getConfig():
|
|
|
|
|
+ print("上报数据")
|
|
|
|
|
+ utils.reportConfig()
|
|
|
|
|
+ config = getConfig()
|
|
|
|
|
+ else:
|
|
|
|
|
+ utils.send_ping()
|
|
|
count = 0
|
|
count = 0
|
|
|
- # time_sleep = 60
|
|
|
|
|
else:
|
|
else:
|
|
|
print('MQTT 未连接', getConfig().mqtt.host, getConfig().mqtt.port,getConfig().mqtt.subTopic)
|
|
print('MQTT 未连接', getConfig().mqtt.host, getConfig().mqtt.port,getConfig().mqtt.subTopic)
|
|
|
utils.connectMQTT(time_sleep)
|
|
utils.connectMQTT(time_sleep)
|
|
@@ -38,7 +46,6 @@ def taskCheck():
|
|
|
# 没有客户的id表示没被绑定
|
|
# 没有客户的id表示没被绑定
|
|
|
if not utils.getStatus() or not getConfig().mqttStatus or getConfig().mqtt.clientId is "":
|
|
if not utils.getStatus() or not getConfig().mqttStatus or getConfig().mqtt.clientId is "":
|
|
|
count += 1
|
|
count += 1
|
|
|
- time_sleep = 10
|
|
|
|
|
# 连接失败开启热点
|
|
# 连接失败开启热点
|
|
|
utils.openAp()
|
|
utils.openAp()
|
|
|
startHttpServer()
|
|
startHttpServer()
|
|
@@ -46,7 +53,7 @@ def taskCheck():
|
|
|
closeHttpServer()
|
|
closeHttpServer()
|
|
|
utils.closeAp()
|
|
utils.closeAp()
|
|
|
|
|
|
|
|
- if count > 20:
|
|
|
|
|
|
|
+ if count > 60:
|
|
|
machine.reset()
|
|
machine.reset()
|
|
|
except Exception as e:
|
|
except Exception as e:
|
|
|
print(f"连接失败:未知错误 - {e}")
|
|
print(f"连接失败:未知错误 - {e}")
|