Changes for page 2 Script

Last modified by Devin Chen on 2025/12/10 10:32

From version 1.1
edited by Wecon
on 2025/09/03 21:04
Change comment: Imported from XAR
To version 4.1
edited by Devin Chen
on 2025/09/09 11:11
Change comment: There is no comment for this version

Summary

Details

Page properties
Author
... ... @@ -1,1 +1,1 @@
1 -XWiki.Wecon
1 +XWiki.DevinChen
Content
... ... @@ -29,8 +29,11 @@
29 29  
30 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. Script is as below:
32 +When the alarm condition is released,then send an  "alarm release" sms.
33 +\\[[image:1757387490907-390.png]]
33 33  
35 +Script is as below:
36 +
34 34  {{code language="lua"}}
35 35  function sms.main()
36 36  ------send condition------
... ... @@ -50,11 +50,16 @@
50 50  ------send sms & output Y0------
51 51  if timer > 5 then
52 52   if tag == 0 then
53 - send_sms_ira("19859254700","alarm trigger")
56 + --send SMS to 2 recipients
57 + send_sms_ira("198****4700","alarm trigger")
58 + local id = send_sms_ira("187****3130","alarm trigger")
59 + --get the SMS state from ID
60 + local state = sms_get_state(id)
61 + addr_setword("@state",state)
54 54   addr_setbit("@Tag",1)
55 55   end
56 56  elseif tag == 1 then
57 -send_sms_ira("19859254700","alarm release")
65 +send_sms_ira("198****4700","alarm release")
58 58  addr_setbit("@Tag",0)
59 59  end
60 60  end
... ... @@ -560,6 +560,58 @@
560 560  end
561 561  {{/code}}
562 562  
571 +== **1.12 Get UTC timestamp and local timezone timestamp** ==
572 +
573 +This demo shows how to obtain UTC standard time from the V-Box and get the local time based on the device's time zone.
574 +
575 +**Register configuration**
576 +
577 +[[image:1757043722849-910.png]]
578 +
579 +**Script configuration**
580 +
581 +(% style="text-align:center" %)
582 +[[image:1757043900216-610.png||height="412" width="439"]]
583 +
584 +
585 +**Script**
586 +
587 +
588 +
589 +{{code language="lua"}}
590 +function time.main()
591 +
592 + --Get Coordinated Universal Time
593 + local timestamp = os.time()
594 + local utcTimeTable = os.date("!*t", timestamp)
595 + local utcTimestamp = os.time(utcTimeTable)
596 + local formattedTime = os.date("%Y-%m-%d %H:%M:%S", utcTimestamp)
597 +
598 + print("UTC: " ..formattedTime)
599 +
600 + --Calculate the local time at the device's location
601 + local utc_7Timestamp = os.time(utcTimeTable) + 25200 -- Enter the corresponding number of seconds based on the time difference,used UTC+7 as an example..
602 + local formattedTime1 = os.date("%Y-%m-%d %H:%M:%S", utc_7Timestamp)
603 + print("UTC+7: " .. formattedTime1)
604 +
605 +
606 + --Assign the decomposed timestamp to the specified register
607 + addr_setword("@UTC+7_Second",os.date("%S", utc_7Timestamp))
608 + addr_setword("@UTC+7_Minute",os.date("%M", utc_7Timestamp))
609 + addr_setword("@UTC+7_Hour",os.date("%H", utc_7Timestamp))
610 + addr_setword("@UTC+7_Day",os.date("%d", utc_7Timestamp))
611 + addr_setword("@UTC+7_Month",os.date("%m", utc_7Timestamp))
612 + addr_setword("@UTC+7_Year",os.date("%Y", utc_7Timestamp))
613 + print("--------------------------------------")
614 +
615 +end
616 +{{/code}}
617 +
618 +**Result**
619 +
620 +(% style="text-align:center" %)
621 +[[image:1757044137457-543.png||height="468" width="708"]]
622 +
563 563  = **2 Third part server** =
564 564  
565 565  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.
1757043722849-910.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.DevinChen
Size
... ... @@ -1,0 +1,1 @@
1 +74.4 KB
Content
1757043900216-610.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.DevinChen
Size
... ... @@ -1,0 +1,1 @@
1 +62.9 KB
Content
1757044137457-543.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.DevinChen
Size
... ... @@ -1,0 +1,1 @@
1 +99.4 KB
Content
1757387490907-390.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.DevinChen
Size
... ... @@ -1,0 +1,1 @@
1 +47.9 KB
Content