Changes for page 2 Script

Last modified by Devin Chen on 2025/06/06 14:03

From version 39.1
edited by Hunter
on 2023/03/17 15:50
Change comment: There is no comment for this version
To version 38.1
edited by Hunter
on 2023/03/17 14:43
Change comment: There is no comment for this version

Summary

Details

Page properties
Content
... ... @@ -515,13 +515,9 @@
515 515  --initialize mqtt
516 516  function mqtt_init()
517 517   print(string.format("mqtt init mqtt_url:%s mqtt_clientid:%s", MQTT_URL, MQTT_CLIENT_ID))
518 - if g_mq then
519 - mqtt.close() --Close mqtt object
520 - end
521 521   g_mq, err = mqtt.create(MQTT_URL, MQTT_CLIENT_ID) -- create mqtt object,and declare it as a global variable
522 522   if g_mq then
523 523   g_mq:on("message", mqtt_msg_callback) -- Register a callback for receiving messages
524 - g_mq:on("offline", mqtt_msg_offline) -- Register a callback for offline
525 525   print("mqtt init success")
526 526   else
527 527   print("mqtt init failed:", err)
... ... @@ -579,11 +579,9 @@
579 579   if g_mq:isconnected() then
580 580   send_data()
581 581   else
582 - --if exceed 5 sec not connect, reconnect once
583 - if os.time() - LAST_TIME > 5 then
578 + --if exceed 20 sec not connect, reconnect once
579 + if os.time() - LAST_TIME > 20 then
584 584   LAST_TIME = os.time()
585 - --reinitial the mqtt object
586 - mqtt_init()
587 587   --connect to mqtt or reconnect
588 588   mqtt_connect()
589 589   end