Changes for page 2 Script
Last modified by Devin Chen on 2025/12/10 10:32
From version 10.1
edited by Devin Chen
on 2025/11/05 09:32
on 2025/11/05 09:32
Change comment:
There is no comment for this version
To version 7.1
edited by Devin Chen
on 2025/10/30 13:45
on 2025/10/30 13:45
Change comment:
There is no comment for this version
Summary
-
Page properties (1 modified, 0 added, 0 removed)
-
Attachments (0 modified, 0 added, 3 removed)
Details
- Page properties
-
- Content
-
... ... @@ -31,7 +31,7 @@ 31 31 32 32 When the alarm condition is released,then send an "alarm release" sms. 33 33 34 -Re al-timetags setting34 +Registers setting 35 35 [[image:1757401730077-284.png]] 36 36 37 37 Script is as below: ... ... @@ -590,7 +590,7 @@ 590 590 591 591 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. 592 592 593 -**Re al-time tagsconfiguration**593 +**Register configuration** 594 594 595 595 [[image:1757043722849-910.png]] 596 596 ... ... @@ -599,8 +599,11 @@ 599 599 (% style="text-align:center" %) 600 600 [[image:1757043900216-610.png||height="412" width="439"]] 601 601 602 + 602 602 **Script** 603 603 605 + 606 + 604 604 {{code language="lua"}} 605 605 function time.main() 606 606 ... ... @@ -635,77 +635,6 @@ 635 635 (% style="text-align:center" %) 636 636 [[image:1757044137457-543.png||height="468" width="708"]] 637 637 638 -== **1.13 JSON encoding and decoding** == 639 - 640 -This demo shows how to encode tag values into JSON format and decode the JSON to assign data to new tags. 641 - 642 -**Real-time tags configuration** 643 - 644 -(% style="text-align:center" %) 645 -[[image:PixPin_2025-11-05_09-21-33.png]] 646 - 647 -(% class="wikigeneratedid" %) 648 -**Script configuration** 649 - 650 -(% style="text-align:center" %) 651 -[[image:PixPin_2025-11-05_09-23-03.png||height="376" width="400"]] 652 - 653 -(% class="wikigeneratedid" %) 654 -**Script** 655 - 656 -{{code language="lua"}} 657 -function json_test.main() 658 - 659 --- Load JSON module for encoding and decoding JSON data 660 -local json = require("json") 661 - 662 --- Read values from different types of address tags 663 -local a = addr_getbit("@bit") -- Read a bit (boolean) value 664 -local b = addr_getword("@word") -- Read a word (integer) value 665 -local c = addr_getfloat("@floating number") -- Read a floating point value 666 -local d = addr_getstring("@string",10) -- Read a string value with max length 10 667 -local e = json.null -- JSON null value constant 668 - 669 --- Encode the data into JSON format 670 -local jsondata = json.encode({ 671 - bit = a or 0, -- Bit value with default 0 672 - word = b or 0, -- Word value with default 0 673 - float = c or 0, -- Float value with default 0 674 - str = d or 0, -- String value with default 0 675 - {none= e} -- Nested table with null value 676 - }) 677 -print("json encode:", jsondata) -- Print the encoded JSON data 678 -print(".......................") 679 - 680 --- Decode the JSON string back to Lua table 681 -local data = json.decode(jsondata) 682 - 683 --- Check if decoding was successful and print the results 684 -if type(data) == 'table' then 685 - print("json decode:") 686 - -- Iterate through all key-value pairs in the decoded table 687 - for k, v in pairs(data) do 688 - print(k, v) 689 - end 690 -end 691 --- Write the decoded values back to corresponding address tags 692 -addr_setbit("@bit_copy", data["bit"] or 0) -- Write bit value 693 -addr_setword("@word_copy", data["word"] or 0) -- Write word value 694 -addr_setfloat("@floating number_copy", data["float"] or 0) -- Write float value 695 -addr_setstring("@string_copy", data["str"], 10) -- Write string value 696 - 697 -print("-----------------------") 698 - 699 -end 700 -{{/code}} 701 - 702 -(% class="wikigeneratedid" %) 703 -**Result** 704 - 705 -(% style="text-align:center" %) 706 -[[image:1762306008662-362.png||height="485" width="1228"]] 707 - 708 - 709 709 = **2 Third part server** = 710 710 711 711 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.
- 1762306008662-362.png
-
- Author
-
... ... @@ -1,1 +1,0 @@ 1 -XWiki.DevinChen - Size
-
... ... @@ -1,1 +1,0 @@ 1 -66.9 KB - Content
- PixPin_2025-11-05_09-21-33.png
-
- Author
-
... ... @@ -1,1 +1,0 @@ 1 -XWiki.DevinChen - Size
-
... ... @@ -1,1 +1,0 @@ 1 -65.8 KB - Content
- PixPin_2025-11-05_09-23-03.png
-
- Author
-
... ... @@ -1,1 +1,0 @@ 1 -XWiki.DevinChen - Size
-
... ... @@ -1,1 +1,0 @@ 1 -60.9 KB - Content