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 43.1
edited by Hunter
on 2023/03/30 16:33
Change comment: There is no comment for this version

Summary

Details

Page properties
Content
... ... @@ -447,6 +447,20 @@
447 447  end
448 448  {{/code}}
449 449  
450 +== **1.9 High-Low Byte Switch** ==
451 +
452 +The following example is converting the floating number from order 1234 to order 3412. About which high-low word order corresponding to which value, please refer to the [[Address operation table>>doc:V-BOX.V-Net.Manual.04 Lua Script.01 Lua Functions.WebHome]].
453 +
454 +{{code language="lua"}}
455 +function highLowByteSwitch(floatNumber)
456 + addr_setfloat("@W_0#HDW23036",floatNumber,0,2)
457 + local newFloat = addr_getfloat("@W_0#HDW23036")
458 + local formattedFloat = string.format("%.2f",newFloat)
459 + print("The formatted float value is the : "..formattedFloat)
460 + return formattedFloat
461 +end
462 +{{/code}}
463 +
450 450  = **2 V-Box connect with third part server** =
451 451  
452 452  V-Box have two mode.One is for V-Net,User need to use WECON server to store data.We call this V-NET platform.
... ... @@ -474,6 +474,25 @@
474 474  
475 475  == **2.1 V-Box connect with test server(General Example)** ==
476 476  
491 +The following example is trying to publish to the topic "testtopic/test/no1/7890", and subscribe the topic "testtopic/test/no1/123456".
492 +
493 +And the JSON message is like follows:
494 +
495 +{{code language="JSON"}}
496 +{
497 + "timestamp": 1631152760,
498 + "messageId": 1,
499 + "event": "test_data",
500 + "mfrs": "HMI/box",
501 + "data":
502 + {
503 + "id" : 1436217747670454274,
504 + "waterlevel" : 48,
505 + "temperture" : 23
506 + }
507 +}
508 +{{/code}}
509 +
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  
577 +--Offline callback function
578 +function mqtt_msg_offline(cause)
579 + print("mqtt offline, cause:", cause)
580 +end
581 +
544 544  -- Received message callback function
545 545  function mqtt_msg_callback(topic, msg)
546 546   print("topic:", topic)