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 41.1
edited by Hunter
on 2023/03/17 18:05
Change comment: There is no comment for this version

Summary

Details

Page properties
Content
... ... @@ -474,6 +474,25 @@
474 474  
475 475  == **2.1 V-Box connect with test server(General Example)** ==
476 476  
477 +The following example is trying to publish to the topic "testtopic/test/no1/7890", and subscribe the topic "testtopic/test/no1/123456".
478 +
479 +And the JSON message is like follows:
480 +
481 +{{code language="JSON"}}
482 +{
483 + "timestamp": 1631152760,
484 + "messageId": 1,
485 + "event": "test_data",
486 + "mfrs": "HMI/box",
487 + "data":
488 + {
489 + "id" : 1436217747670454274,
490 + "waterlevel" : 48,
491 + "temperture" : 23
492 + }
493 +}
494 +{{/code}}
495 +
477 477  {{code language="lua"}}
478 478  --MQTT configuration table
479 479  local MQTT_CFG={}
... ... @@ -541,6 +541,11 @@
541 541   g_mq:subscribe(SUBSCRIBE_TOPIC, 0)
542 542  end
543 543  
563 +--Offline callback function
564 +function mqtt_msg_offline(cause)
565 + print("mqtt offline, cause:", cause)
566 +end
567 +
544 544  -- Received message callback function
545 545  function mqtt_msg_callback(topic, msg)
546 546   print("topic:", topic)