Changes for page 2 Script

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

From version 43.1
edited by Hunter
on 2023/03/30 16:33
Change comment: There is no comment for this version
To version 56.1
edited by Theodore Xu
on 2023/08/24 17:12
Change comment: There is no comment for this version

Summary

Details

Page properties
Author
... ... @@ -1,1 +1,1 @@
1 -XWiki.Hunter
1 +XWiki.AiXia
Content
... ... @@ -27,25 +27,19 @@
27 27  
28 28  == **1.4 Short message** ==
29 29  
30 -When the alarm condition is reached: temp1 > 5 & temp2 >10 & temp3 < 20(lasts more than 5 seconds) , then send an "alarm trigger" sms.
30 +The following demo shows that when the alarm condition is reached: temp1 > 5 & temp2 >10 & temp3 < 20(lasts more than 5 seconds) , then send an "alarm trigger" sms.
31 31  
32 -When the alarm condition is released,then send an "alarm release" sms.
32 +When the alarm condition is released,then send an  "alarm release" sms. Script is as below:
33 33  
34 -(% style="text-align:center" %)
35 -[[image:1645535936750-316.png||height="385" width="400" class="img-thumbnail"]]
36 -
37 -Script is as below:
38 -
39 -(% class="box infomessage" %)
40 -(((
34 +{{code language="lua"}}
41 41  function sms.main()
42 -~-~-~-~-~-~-send condition~-~-~-~-~-~-
36 +------send condition------
43 43  local temp1 = addr_getword("@Temperature1")
44 44  local temp2 = addr_getword("@Temperature2")
45 45  local temp3 = addr_getword("@Temperature3")
46 46  local timer = addr_getword("@Timer")
47 47  local tag = addr_getbit("@Tag")
48 -~-~-~-~-~-~-lasting time~-~-~-~-~-~-
42 +------lasting time------
49 49  if temp1 > 5 and temp2 > 10 and temp3 < 20 then
50 50   timer = timer + 1
51 51   addr_setword("@Timer",timer)
... ... @@ -53,7 +53,7 @@
53 53   timer = 0
54 54   addr_setword("@Timer",timer)
55 55  end
56 -~-~-~-~-~-~-send sms & output Y0~-~-~-~-~-~-
50 +------send sms & output Y0------
57 57  if timer > 5 then
58 58   if tag == 0 then
59 59   send_sms_ira("19859254700","alarm trigger")
... ... @@ -64,7 +64,7 @@
64 64  addr_setbit("@Tag",0)
65 65  end
66 66  end
67 -)))
61 +{{/code}}
68 68  
69 69  == **1.5 Telegram notification** ==
70 70  
... ... @@ -145,7 +145,7 @@
145 145  
146 146  This example shows how to use the LINE Notify to send message into LINE group. When monitoring bit "@test" changes, it will trigger and send the message. Please replace with your own Token.
147 147  
148 -{{code}}
142 +{{code language="lua"}}
149 149  local tempBit = 0
150 150  local tempWord = 0
151 151  
... ... @@ -449,7 +449,7 @@
449 449  
450 450  == **1.9 High-Low Byte Switch** ==
451 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]].
446 +The following example is converting the floating number from order 1234 to order 3412, and formating output the number with 2 decimal point. 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||anchor="H2Addressoperation"]].
453 453  
454 454  {{code language="lua"}}
455 455  function highLowByteSwitch(floatNumber)
... ... @@ -461,6 +461,23 @@
461 461  end
462 462  {{/code}}
463 463  
458 +== **1.10 Read 64bits Unsigned Value** ==
459 +
460 +In our built-in function library doesn't have the function for reading 64-bit unsigned format value, so the following function is for solve this. But if the number is greater 2^53, the precision will be lost. So the final result will be a little bit different from the original value.
461 +
462 +{{code language="lua"}}
463 +function addr_getquatra(address)
464 + local highAddress = addr_newnoaddr(address,2)
465 + local low32 = addr_getdword(address)
466 + local high32 = addr_getdword(highAddress)
467 + --print("the low number is "..low32)
468 + --print("the high number is "..high32)
469 + local formatVal = string.format("%64.0f",2^32*high32+low32)
470 + print("the format value is ".. formatVal)
471 + return formatVal
472 +end
473 +{{/code}}
474 +
464 464  = **2 V-Box connect with third part server** =
465 465  
466 466  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.
... ... @@ -486,7 +486,7 @@
486 486  (% class="wikigeneratedid" %)
487 487  Tool link: **[[MQTT.fx>>http://mqttfx.jensd.de/index.php/download]]**
488 488  
489 -== **2.1 V-Box connect with test server(General Example)** ==
500 +== **2.1 Test server(General Example)** ==
490 490  
491 491  The following example is trying to publish to the topic "testtopic/test/no1/7890", and subscribe the topic "testtopic/test/no1/123456".
492 492  
... ... @@ -510,6 +510,7 @@
510 510  {{code language="lua"}}
511 511  --MQTT configuration table
512 512  local MQTT_CFG={}
524 +--if there is no need the username and password, please put them as ""
513 513  MQTT_CFG.username = "weconsupport"
514 514  MQTT_CFG.password = "123456"
515 515  MQTT_CFG.netway = 0
... ... @@ -549,7 +549,7 @@
549 549  function mqtt_init()
550 550   print(string.format("mqtt init mqtt_url:%s mqtt_clientid:%s", MQTT_URL, MQTT_CLIENT_ID))
551 551   if g_mq then
552 - mqtt.close() --Close mqtt object
564 + mqtt.close(g_mq) --Close mqtt object
553 553   end
554 554   g_mq, err = mqtt.create(MQTT_URL, MQTT_CLIENT_ID) -- create mqtt object,and declare it as a global variable
555 555   if g_mq then
... ... @@ -634,7 +634,7 @@
634 634  end
635 635  {{/code}}
636 636  
637 -== **2.2 V-Box connect with customer server:grouprobotinfo.com** ==
649 +== **2.2 Customer server:grouprobotinfo.com** ==
638 638  
639 639  This demo does not use SSL certification. Script is as below
640 640  
... ... @@ -775,7 +775,7 @@
775 775  end
776 776  {{/code}}
777 777  
778 -== **2.3 V-Box connect with Azure platform** ==
790 +== **2.3 Azure platform** ==
779 779  
780 780  In this demo,V-Box connects with Azure by SSL certification.
781 781  
... ... @@ -906,8 +906,14 @@
906 906  end
907 907  )))
908 908  
909 -== **2.4 How to configure the Huawei platform?(✎Note: Huawei IOT DA function is only in China area.If you want this function,you need to use chinese mobile to register)** ==
921 +== **2.4 Huawei platform** ==
910 910  
923 +
924 +
925 +{{info}}
926 +**✎Note**:**Huawei IOT DA function is only in China area.If you want this function,you need to use chinese mobile to register**
927 +{{/info}}
928 +
911 911  1.Register a account: [[https:~~/~~/www.huaweicloud.com/intl/en-us/s/JUlPVERNJQ>>https://www.huaweicloud.com/intl/en-us/s/JUlPVERNJQ]]
912 912  
913 913  2.log in the Huawei IOTDA
... ... @@ -1176,7 +1176,7 @@
1176 1176  (% style="text-align:center" %)
1177 1177  [[image:1624506666650-161.png||height="547" width="1000" class="img-thumbnail"]]
1178 1178  
1179 -== **2.6 V-Box connect with AWS platform** ==
1197 +== **2.6 AWS platform** ==
1180 1180  
1181 1181  === **Log in AWS** ===
1182 1182  
... ... @@ -1241,7 +1241,7 @@
1241 1241  [[image:image-20220709165402-11.png]]
1242 1242  
1243 1243  
1244 -=== **Test with MQTT.fx tool** ===
1262 +=== **MQTT.fx tool** ===
1245 1245  
1246 1246  Click “View Setting” to get the “Broker Adress”
1247 1247  
... ... @@ -1269,7 +1269,7 @@
1269 1269  
1270 1270  [[image:image-20220709165402-18.png]]
1271 1271  
1272 -=== **Configurate in CloudTool** ===
1290 +=== **CloudTool** ===
1273 1273  
1274 1274  Copy the same setting in MQTT.fx to MQTT configuration
1275 1275