Changes for page 01 Lua Functions

Last modified by Theodore Xu on 2023/10/26 10:51

From version 5.7
edited by Stone Wu
on 2022/07/12 09:20
Change comment: (Autosaved)
To version 5.18
edited by Stone Wu
on 2022/07/12 10:00
Change comment: (Autosaved)

Summary

Details

Page properties
Content
... ... @@ -106,8 +106,6 @@
106 106  
107 107  (((
108 108  = **2 Address operation** =
109 -
110 -
111 111  )))
112 112  
113 113  |=16-bit data formal|=HLword|=32-bit data formal|=HLword|= 64-bit data formal|=HLword
... ... @@ -140,20 +140,17 @@
140 140  43218765
141 141  )))|10
142 142  
143 -* If HLword enters any other value, it will be treated as invalid.
141 + Table 2-1
144 144  
145 - Demo:  Reads a 32-bit floating-point number at position D0 of PLC
143 +(% class="box errormessage" %)
144 +(((
145 +**✎Note: **If HLword enters any other value, it will be treated as invalid.
146 +)))
146 146  
148 +== **addr_getshort(string addr[, number type, number hlword])** ==
147 147  
150 +**Function:** Read 16-bit signed decimal address
148 148  
149 -[[image:企业微信截图_20210506180640.png||height="301" width="600" class="img-thumbnail"]]
150 -
151 -== **2.1 addr_getshort(string addr[, number type, number hlword])** ==
152 -
153 -**Function:**
154 -
155 -Read 16-bit signed decimal address
156 -
157 157  **Parameters:**
158 158  
159 159  //addr//: address
... ... @@ -171,13 +171,11 @@
171 171  Failed: multi
172 172  
173 173  (((
174 -== **2.2 addr_setshort(string addr, number num[, number type, number hlword])** ==
169 +== **addr_setshort(string addr, number num[, number type, number hlword])** ==
175 175  )))
176 176  
177 -**Function:**
172 +**Function:** Write 16-bit signed decimal address
178 178  
179 -Write 16-bit signed decimal address
180 -
181 181  **Parameters:**
182 182  
183 183  //addr//: address
... ... @@ -195,13 +195,11 @@
195 195  Failed: multi
196 196  
197 197  (((
198 -== **2.3 addr_getword(string addr[, number type, number hlword])** ==
191 +== **addr_getword(string addr[, number type, number hlword])** ==
199 199  )))
200 200  
201 -**Function:**
194 +**Function:** Read 16-bit unsigned decimal address
202 202  
203 -Read 16-bit unsigned decimal address
204 -
205 205  **Parameters:**
206 206  
207 207  //addr//: address
... ... @@ -217,13 +217,11 @@
217 217  Failed: multi
218 218  
219 219  (((
220 -== **2.4 addr_setword(string addr, number num[, number type, number hlword])** ==
211 +== **addr_setword(string addr, number num[, number type, number hlword])** ==
221 221  )))
222 222  
223 -**Function:**
214 +**Function:**Write 16-bit unsigned decimal address
224 224  
225 -Write 16-bit unsigned decimal address
226 -
227 227  **Parameters:**
228 228  
229 229  //addr//: address
... ... @@ -241,13 +241,11 @@
241 241  Failed: multi
242 242  
243 243  (((
244 -== **2.5 addr_getint(string addr[, number type, number hlword])** ==
233 +== **addr_getint(string addr[, number type, number hlword])** ==
245 245  )))
246 246  
247 -**Function:**
236 +**Function:** Read 32-bit signed decimal address
248 248  
249 -Read 32-bit signed decimal address
250 -
251 251  **Parameters:**
252 252  
253 253  //addr//: address
... ... @@ -263,13 +263,11 @@
263 263  Failed: multi
264 264  
265 265  (((
266 -== **2.6 addr_setint(string addr, number num[, number type, number hlword])** ==
253 +== **addr_setint(string addr, number num[, number type, number hlword])** ==
267 267  )))
268 268  
269 -**Function:**
256 +**Function:** Write 32-bit signed decimal address
270 270  
271 -Write 32-bit signed decimal address
272 -
273 273  **Parameters:**
274 274  
275 275  //addr//: address
... ... @@ -287,13 +287,11 @@
287 287  Failed: multi
288 288  
289 289  (((
290 -== **2.7 addr_getdword(string addr[, number type, number hlword])** ==
275 +== **addr_getdword(string addr[, number type, number hlword])** ==
291 291  )))
292 292  
293 -**Function:**
278 +**Function:** Read 32-bit unsigned decimal address
294 294  
295 -Read 32-bit unsigned decimal address
296 -
297 297  **Parameters:**
298 298  
299 299  //addr//: address
... ... @@ -309,13 +309,11 @@
309 309  Failed: multi
310 310  
311 311  (((
312 -== **2.8 addr_setdword(string addr, number num[, number type, number hlword])** ==
295 +== **addr_setdword(string addr, number num[, number type, number hlword])** ==
313 313  )))
314 314  
315 -**Function:**
298 +**Function:** Write 32-bit unsigned decimal address
316 316  
317 -Write 32-bit unsigned decimal address
318 -
319 319  **Parameters:**
320 320  
321 321  //addr//: address
... ... @@ -333,13 +333,11 @@
333 333  Failed: multi
334 334  
335 335  (((
336 -== **2.9 addr_getbit(string addr[, number type])** ==
317 +== **addr_getbit(string addr[, number type])** ==
337 337  )))
338 338  
339 -**Function:**
320 +**Function:** Read a bit of the register address
340 340  
341 -Read a bit of the register address
342 -
343 343  **Parameters:**
344 344  
345 345  //addr//: address
... ... @@ -355,13 +355,11 @@
355 355  Failed: multi
356 356  
357 357  (((
358 -== **2.10 addr_setbit(string addr, number num[, number type])** ==
337 +== **addr_setbit(string addr, number num[, number type])** ==
359 359  )))
360 360  
361 -**Function:**
340 +**Function:** Write a bit of the register address
362 362  
363 -Write a bit of the register address
364 -
365 365  **Parameters:**
366 366  
367 367  //addr//: address
... ... @@ -379,13 +379,11 @@
379 379  Failed: multi
380 380  
381 381  (((
382 -== **2.11 addr_getfloat(string addr[, number type, number hlword])** ==
359 +== **addr_getfloat(string addr[, number type, number hlword])** ==
383 383  )))
384 384  
385 -**Function:**
362 +**Function:** Read 32-bit floating address
386 386  
387 -Read 32-bit floating address
388 -
389 389  **Parameters:**
390 390  
391 391  //addr//: address
... ... @@ -401,13 +401,11 @@
401 401  Failed: multi
402 402  
403 403  (((
404 -== **2.12 addr_setfloat(string addr, number num[, number type, number hlword])** ==
379 +== **addr_setfloat(string addr, number num[, number type, number hlword])** ==
405 405  )))
406 406  
407 -**Function:**
382 +**Function:** Write 32-bit floating address
408 408  
409 -Write 32-bit floating address
410 -
411 411  **Parameters:**
412 412  
413 413  //addr//: address
... ... @@ -425,13 +425,11 @@
425 425  Failed: multi
426 426  
427 427  (((
428 -== **2.13 addr_getdouble(string addr[, number type, number hlword])** ==
401 +== **addr_getdouble(string addr[, number type, number hlword])** ==
429 429  )))
430 430  
431 -**Function:**
404 +**Function:** Read 64-bit floating address
432 432  
433 -Read 64-bit floating address
434 -
435 435  **Parameters:**
436 436  
437 437  //addr//: address
... ... @@ -447,13 +447,11 @@
447 447  Failed: multi
448 448  
449 449  (((
450 -== **2.14 addr_setdouble(string addr, number num[, number type, number hlword])** ==
421 +== **addr_setdouble(string addr, number num[, number type, number hlword])** ==
451 451  )))
452 452  
453 -**Function:**
424 +**Function:** Write 64-bit floating address
454 454  
455 -Write 64-bit floating address
456 -
457 457  **Parameters:**
458 458  
459 459  addr: address
... ... @@ -471,13 +471,11 @@
471 471  Failed: multi
472 472  
473 473  (((
474 -== **2.15 addr_getstring(string addr, number length[, number type, number hlbyte])** ==
443 +== **addr_getstring(string addr, number length[, number type, number hlbyte])** ==
475 475  )))
476 476  
477 -**Function:**
446 +**Function:** Read the specified length string from address
478 478  
479 -Read the specified length string from address
480 -
481 481  **Parameters:**
482 482  
483 483  //addr//: address
... ... @@ -495,13 +495,11 @@
495 495  Failed: multi
496 496  
497 497  (((
498 -== **2.16 addr_setstring(string addr, string str[, number type, number hlbyte])** ==
465 +== **addr_setstring(string addr, string str[, number type, number hlbyte])** ==
499 499  )))
500 500  
501 -**Function:**
468 +**Function:** Write the specified length string to address
502 502  
503 -Write the specified length string to address
504 -
505 505  **Parameters:**
506 506  
507 507  //addr//: address
... ... @@ -519,13 +519,11 @@
519 519  Failed: multi
520 520  
521 521  (((
522 -== **2.17 addr_bmov(string dst, string src, number length)** ==
487 +== **addr_bmov(string dst, string src, number length)** ==
523 523  )))
524 524  
525 -**Function:**
490 +**Function:** Copy data from source address to destination address
526 526  
527 -Copy data from source address to destination address
528 -
529 529  **Parameters:**
530 530  
531 531  //dst//: destination address
... ... @@ -541,13 +541,11 @@
541 541  **Failed: multi**
542 542  
543 543  (((
544 -== **2.18 addr_fill(string addr, number num, number length)** ==
507 +== **addr_fill(string addr, number num, number length)** ==
545 545  )))
546 546  
547 -**Function:**
510 +**Function:** Write the same value to consecutive addresses
548 548  
549 -Write the same value to consecutive addresses
550 -
551 551  **Parameters:**
552 552  
553 553  //addr//: address
... ... @@ -563,13 +563,11 @@
563 563  Failed: multi
564 564  
565 565  (((
566 -== **2.19 addr_newnoaddr(string addr, number offset)** ==
527 +== **addr_newnoaddr(string addr, number offset)** ==
567 567  )))
568 568  
569 -**Function:**
530 +**Function:** Offset address value relative to //addr//
570 570  
571 -Offset address value relative to //addr//
572 -
573 573  **Parameters:**
574 574  
575 575  //addr//: address
... ... @@ -583,13 +583,11 @@
583 583  Failed: multi
584 584  
585 585  (((
586 -== **2.20 addr_newstataddr(string addr, number offset)** ==
545 +== **addr_newstataddr(string addr, number offset)** ==
587 587  )))
588 588  
589 -**Function:**
548 +**Function:** Offset station number relative to //addr //station number
590 590  
591 -Offset station number relative to //addr //station number
592 -
593 593  **Parameters:**
594 594  
595 595  //addr//: address
... ... @@ -602,12 +602,10 @@
602 602  
603 603  Failed: multi
604 604  
605 -== **2.21 addr_gethex64(string addr[, number type, number hlword])** ==
562 +== **addr_gethex64(string addr[, number type, number hlword])** ==
606 606  
607 -**Function:**
564 +**Function:** Read 64-bit hexadecimal numbers
608 608  
609 -Read 64-bit hexadecimal numbers
610 -
611 611  **Parameters:**
612 612  
613 613  //addr//: address
... ... @@ -622,12 +622,10 @@
622 622  
623 623  Failed: multi
624 624  
625 -== **2.22 addr_sethex64(string addr, number num[, number type, number hlword])** ==
580 +== **addr_sethex64(string addr, number num[, number type, number hlword])** ==
626 626  
627 -**Function:**
582 +**Function:** Write 64-bit hexadecimal addresses
628 628  
629 -Write 64-bit hexadecimal addresses
630 -
631 631  **Parameters:**
632 632  
633 633  //addr//: address
... ... @@ -648,11 +648,11 @@
648 648  
649 649  Operations on the serial port such as read, write, etc. must use ':' for full mode calls, ie operations on an open serial object.
650 650  
651 -**Serial port name and mode:**
604 +**Serial port name and mode**
652 652  
653 653  The serial port configured in the communication configuration window cannot be configured again using the script. RS232 and RS458 (or RS422) can be used simultaneously, but RS422 and RS485 are mutually exclusive.For example, when the communication port is configured with COM1-485, the script can only open COM1-232, but not COM1-485/422. Similarly, when the communication port is configured with COM2-485, the script can only open COM2-232, but not COM2-485.
654 654  
655 -Attempting to use a script to open a serial port in an unsupported mode will result in an error directly, as below
608 +Attempting to use a script to open a serial port in an unsupported mode will result in an error directly, as below.
656 656  
657 657  |(((
658 658  local setup = {
... ... @@ -674,13 +674,11 @@
674 674  1. When the data bit is 8, the maximum value of data transmission is 255 (0xFF), which supports the transmission of any character.
675 675  
676 676  (((
677 -== **3.1 serial.open(table setup)** ==
630 +== **serial.open(table setup)** ==
678 678  )))
679 679  
680 -**Function:**
633 +**Function:** Enable one serial port
681 681  
682 -Enable one serial port
683 -
684 684  **Parameters:**
685 685  
686 686  //Setup// is a Lua table; it needs to contain the following fields
... ... @@ -714,17 +714,13 @@
714 714  Failed: multi
715 715  
716 716  (((
717 -== **3.2 serial.close(serial obj)** ==
668 +== **serial.close(serial obj)** ==
718 718  )))
719 719  
720 -**Function:**
671 +**Function:** Disable the serial port
721 721  
722 -Disable the serial port
673 +**Parameters: **//Obj //is the object returned by serial.open
723 723  
724 -**Parameters:**
725 -
726 -//Obj //is the object returned by serial.open
727 -
728 728  **Return:**
729 729  
730 730  Succeed: true
... ... @@ -732,13 +732,11 @@
732 732  Failed: multi
733 733  
734 734  (((
735 -== **3.3 serial:read(number bytes[, number timeout])** ==
682 +== **serial:read(number bytes[, number timeout])** ==
736 736  )))
737 737  
738 -**Function:**
685 +**Function:** Read the specified byte length serial port data
739 739  
740 -Read the specified byte length serial port data
741 -
742 742  **Parameters:**
743 743  
744 744  //bytes//: number of bytes
... ... @@ -752,15 +752,13 @@
752 752  Failed: multi
753 753  
754 754  (((
755 -== **3.4 serial:write(string data)** ==
700 +== **serial:write(string data)** ==
756 756  )))
757 757  
758 -**Function:**
703 +**Function:** Write the specified byte length to serial port data
759 759  
760 -Write the specified byte length to serial port data
705 +**Parameters: **
761 761  
762 -**Parameters:**
763 -
764 764  //data//: serial port data
765 765  
766 766  **Return:**
... ... @@ -770,13 +770,11 @@
770 770  Failed: multi
771 771  
772 772  (((
773 -== **3.5 serial:flush([number flag])** ==
716 +== **serial:flush([number flag])** ==
774 774  )))
775 775  
776 -**Function:**
719 +**Function:** Clear the serial port buffer
777 777  
778 -Clear the serial port buffer
779 -
780 780  **Parameters:**
781 781  
782 782  //[flag=2]// clear option: 0: read, 1: write, 2: read-write
... ... @@ -788,17 +788,13 @@
788 788  Failed: multi
789 789  
790 790  (((
791 -== **3.6 serial:close()** ==
732 +== **serial:close()** ==
792 792  )))
793 793  
794 -**Function:**
735 +**Function:** Close the serial port object
795 795  
796 -Close the serial port object
737 +**Parameters:** None
797 797  
798 -**Parameters:**
799 -
800 -None
801 -
802 802  **Return:**
803 803  
804 804  Succeed: true
... ... @@ -815,12 +815,10 @@
815 815  
816 816  **QoS value:**
817 817  
818 -0: Only push messages once, messages may be lost or duplicated. It can be used for environmental sensor data, it doesn't matter if lose a record, because there will be a second push message soon. This method is mainly used for normal APP push, but if the user smart device is not connected when the message is pushed, the message will be discarded, and the smart device will not be received when it is networked again.
755 +* 0: Only push messages once, messages may be lost or duplicated. It can be used for environmental sensor data, it doesn't matter if lose a record, because there will be a second push message soon. This method is mainly used for normal APP push, but if the user smart device is not connected when the message is pushed, the message will be discarded, and the smart device will not be received when it is networked again.
756 +* 1: The message is delivered at least once, but the message may be delivered repeatedly.
757 +* 2: The message was delivered exactly once. This level can be used in a billing system. In a billing system, repeated or missing messages can lead to incorrect results. This highest quality message push service can also be used for instant messaging APP pushes, ensuring that users only receive messages once.
819 819  
820 -1: The message is delivered at least once, but the message may be delivered repeatedly.
821 -
822 -2: The message was delivered exactly once. This level can be used in a billing system. In a billing system, repeated or missing messages can lead to incorrect results. This highest quality message push service can also be used for instant messaging APP pushes, ensuring that users only receive messages once.
823 -
824 824  **Retain flag:**
825 825  
826 826  0: not reserved;
... ... @@ -828,13 +828,11 @@
828 828  1: reserved
829 829  
830 830  (((
831 -== **4.1 mqtt.create(string serverurl, string clientid)** ==
766 +== **mqtt.create(string serverurl, string clientid)** ==
832 832  )))
833 833  
834 -**Function:**
769 +**Function:** Create an MQTT object
835 835  
836 -Create an MQTT object
837 -
838 838  **Parameters:**
839 839  
840 840  //serverurl //Server url
... ... @@ -856,17 +856,13 @@
856 856  Failed: multi
857 857  
858 858  (((
859 -== **4.2 mqtt.close(mqtt obj)** ==
792 +== **mqtt.close(mqtt obj)** ==
860 860  )))
861 861  
862 -**Function:**
795 +**Function:** Close the specified MQTT object (if the connected server will be disconnected automatically)
863 863  
864 -Close the specified MQTT object (if the connected server will be disconnected automatically)
797 +**Parameters: **//Obj //ithe objeced returned by mqtt.create
865 865  
866 -**Parameters:**
867 -
868 -//Obj //is the objeced returned by mqtt.create
869 -
870 870  **Return:**
871 871  
872 872  Succeed: true
... ... @@ -874,32 +874,25 @@
874 874  Failed: multi
875 875  
876 876  (((
877 -== **4.3 mqtt:connect(table conn[, table lwt, table cart])** ==
806 +== **mqtt:connect(table conn[, table lwt, table cart])** ==
878 878  )))
879 879  
880 -**Function:**
809 +**Function:**Establish a connection to the server
881 881  
882 -Establish a connection to the server
883 -
884 884  **Parameters:**
885 885  
886 886  //conn //is a Lua table and needs to contain the following fields
887 887  
888 -//string conn.username//, user name
815 +* //string conn.username//, user name
816 +* //string conn.password//, password
817 +* //number [conn.netway=0]//, networking method, if set error number will use Ethernet method
818 +** 0: Ethernet
819 +** 1: WIFI
820 +** 2: 4G
821 +** 3: 2G
822 +* //number [conn.keepalive=60]//, keep connected heartbeat interval, in seconds
823 +* //number [conn.cleansession=1]//, empty the session as described below:
889 889  
890 -//string conn.password//, password
891 -
892 -//number [conn.netway=0]//, networking method, if set error number will use Ethernet method
893 -
894 -* 0: Ethernet
895 -* 1: WIFI
896 -* 2: 4G
897 -* 3: 2G
898 -
899 -//number [conn.keepalive=60]//, keep connected heartbeat interval, in seconds
900 -
901 -//number [conn.cleansession=1]//, empty the session as described below:
902 -
903 903  This function is used to control the behavior when connecting and disconnecting, and the client and server will retain the session information. This information is used to guarantee "at least once" and "accurately once" delivery, as well as the subject of the client subscription, the user can choose to keep or ignore the session message, set as follows:
904 904  
905 905  * 1 (Empty): If a session exists and is 1, the previous session messages on the client and server are emptied.
... ... @@ -907,14 +907,11 @@
907 907  
908 908  //lwt// (Last Will and Testament) is a Lua table and needs to contain the following fields
909 909  
910 -//string lwt.topic//, topic
832 +* //string lwt.topic//, topic
833 +* //string lwt.message//, message
834 +* //number [lwt.qos=0]//, qos value
835 +* //number [lwt.retain=0]//, retain flag
911 911  
912 -//string lwt.message//, message
913 -
914 -//number [lwt.qos=0]//, qos value
915 -
916 -//number [lwt.retain=0]//, retain flag
917 -
918 918  **Return:**
919 919  
920 920  Succeed: true
... ... @@ -922,17 +922,13 @@
922 922  Failed: multi
923 923  
924 924  (((
925 -== **4.4 mqtt:disconnect([number timeout])** ==
844 +== **mqtt:disconnect([number timeout])** ==
926 926  )))
927 927  
928 -**Function:**
847 +**Function:** Disconnect from the MQTT server
929 929  
930 -Disconnect from the MQTT server
849 +**Parameters: **//[timeout=10000] //Disconnect waiting timeout, in milliseconds
931 931  
932 -**Parameters:**
933 -
934 -//[timeout=10000] //Disconnect waiting timeout, in milliseconds
935 -
936 936  **Return:**
937 937  
938 938  Succeed: true
... ... @@ -940,17 +940,13 @@
940 940  Failed: multi
941 941  
942 942  (((
943 -== **4.5 mqtt:isconnected()** ==
858 +== **mqtt:isconnected()** ==
944 944  )))
945 945  
946 -**Function:**
861 +**Function:** Test whether or not a client is currently connected to the MQTT server
947 947  
948 -Test whether or not a client is currently connected to the MQTT server
863 +**Parameters:** None
949 949  
950 -**Parameters:**
951 -
952 -None
953 -
954 954  **Return:**
955 955  
956 956  Succeed: true ~-~-Connected
... ... @@ -958,13 +958,11 @@
958 958  Failed: false ~-~- Unconnected and other unknowns
959 959  
960 960  (((
961 -== **4.6 mqtt:subscribe(string topic, number qos)** ==
872 +== **mqtt:subscribe(string topic, number qos)** ==
962 962  )))
963 963  
964 -**Function:**
875 +**Function: **Subscribe to the topic (before the subscription, the user must first call the connect method to connect to the server)
965 965  
966 -Subscribe to the topic (before the subscription, the user must first call the connect method to connect to the server)
967 -
968 968  **Parameters:**
969 969  
970 970  //topic//, topic name
... ... @@ -978,13 +978,11 @@
978 978  Failed: multi
979 979  
980 980  (((
981 -== **4.7 mqtt:unsubscribe(string topic)** ==
890 +== **mqtt:unsubscribe(string topic)** ==
982 982  )))
983 983  
984 -**Function:**
893 +**Function:** Unsubscribe topic
985 985  
986 -Unsubscribe topic
987 -
988 988  **Parameters:**
989 989  
990 990  //topic//, topic name
... ... @@ -996,13 +996,11 @@
996 996  Failed: multi
997 997  
998 998  (((
999 -== **4.8 mqtt:publish(string topic, string message, number qos, number retain[, number timeout])** ==
906 +== **mqtt:publish(string topic, string message, number qos, number retain[, number timeout])** ==
1000 1000  )))
1001 1001  
1002 -**Function:**
909 +**Function:** Publish message
1003 1003  
1004 -Publish message
1005 -
1006 1006  **Parameters:**
1007 1007  
1008 1008  //topic//, topic name
... ... @@ -1022,17 +1022,13 @@
1022 1022  Failed: multi
1023 1023  
1024 1024  (((
1025 -== **4.9 mqtt:close()** ==
930 +== **mqtt:close()** ==
1026 1026  )))
1027 1027  
1028 -**Function:**
933 +**Function:** Close the mqtt object (the connection to the server will be automatically disconnected)
1029 1029  
1030 -Close the mqtt object (the connection to the server will be automatically disconnected)
935 +**Parameters:** None
1031 1031  
1032 -**Parameters:**
1033 -
1034 -None
1035 -
1036 1036  **Return:**
1037 1037  
1038 1038  Succeed: true
... ... @@ -1040,13 +1040,11 @@
1040 1040  Failed: multi
1041 1041  
1042 1042  (((
1043 -== **4.10 mqtt:on(string method, function callback)** ==
944 +== **mqtt:on(string method, function callback)** ==
1044 1044  )))
1045 1045  
1046 -**Function:**
947 +**Function:** Register event callback function
1047 1047  
1048 -Register event callback function
1049 -
1050 1050  **Parameters:**
1051 1051  
1052 1052  //method//, It can be message/arrived/offline, these 3 types of events
... ... @@ -1059,20 +1059,17 @@
1059 1059  
1060 1060  Parameter:
1061 1061  
1062 -//Topic//, topic name
961 +* //Topic//, topic name
962 +* //Message//, content
1063 1063  
1064 -//Message//, content
964 +**2."arrived" is published by publish, this function will be called after the publication arrives**
1065 1065  
1066 -**2.**"arrived" is published by publish, this function will be called after the publication arrives
1067 -
1068 1068  //Callback// prototype~:// function ()//
1069 1069  
1070 -Parameter:
968 +Parameter: None
1071 1071  
1072 -None
970 +**3.This function will be called after the "offline" connection is lost**
1073 1073  
1074 -**3.**This function will be called after the "offline" connection is lost
1075 -
1076 1076  //Callback// prototype~:// function (string cause)//
1077 1077  
1078 1078  Parameter:
... ... @@ -1086,17 +1086,13 @@
1086 1086  Failed: multi
1087 1087  
1088 1088  (((
1089 -== **4.11 mqtt:setup_cfg()** ==
985 +== **mqtt:setup_cfg()** ==
1090 1090  )))
1091 1091  
1092 -**Function:**
988 +**Function:** Cloud mode interface, to obtain MQTT information configured by the cloud platform
1093 1093  
1094 -Cloud mode interface, to obtain MQTT information configured by the cloud platform
990 +**Parameters:** None
1095 1095  
1096 -**Parameters:**
1097 -
1098 -None
1099 -
1100 1100  **Return:**
1101 1101  
1102 1102  //serverurl, clientid, conn, lwt, cart //(5 returns, respectively, server address, client ID, connection table, last word table, certificate table)
... ... @@ -1114,39 +1114,27 @@
1114 1114  Lua only has a table data structure, so all arrays and key-value objects of json will be returned as a table.
1115 1115  
1116 1116  (((
1117 -== **5.1 json.encode( lua_object )** ==
1009 +== **json.encode( lua_object )** ==
1118 1118  )))
1119 1119  
1120 -**Function:**
1012 +**Function: **Convert lua data type to json string
1121 1121  
1122 -Convert lua data type to json string
1014 +**Parameters: **Lua data type (including boolean, number, string, table)
1123 1123  
1124 -**Parameters:**
1016 +**Return:** Json format string
1125 1125  
1126 -Lua data type (including boolean, number, string, table)
1127 -
1128 -**Return:**
1129 -
1130 -Json format string
1131 -
1132 1132  (((
1133 -== **5.2 json.decode(string json_string)** ==
1019 +== **json.decode(string json_string)** ==
1134 1134  )))
1135 1135  
1136 -**Function:**
1022 +**Function:** Convert json string to lua data type
1137 1137  
1138 -Convert json string to lua data type
1024 +**Parameters: **//json_string//, string of json data structure
1139 1139  
1140 -**Parameters:**
1026 +**Return: **Lua data type
1141 1141  
1142 -//json_string//, string of json data structure
1143 -
1144 -**Return:**
1145 -
1146 -Lua data type
1147 -
1148 1148  (((
1149 -== **5.3 json.null** ==
1029 +== **json.null** ==
1150 1150  )))
1151 1151  
1152 1152  **Function:**
... ... @@ -1153,32 +1153,24 @@
1153 1153  
1154 1154  This method is used when assembling json data, which is equivalent to null in json. If the user directly uses json.null() to return the address of the function, it must be valid with the use of encode.
1155 1155  
1156 -**Parameters:**
1036 +**Parameters:** None
1157 1157  
1158 -None
1038 +**Return: **None
1159 1159  
1160 -**Return:**
1161 -
1162 -None
1163 -
1164 1164  = **6 Cloud mode** =
1165 1165  
1166 1166  The cloud interface is only used in cloud mode, and V-NET mode is not available.
1167 1167  
1168 1168  (((
1169 -== **6.1 bns_get_alldata()** ==
1045 +== **bns_get_alldata()** ==
1170 1170  )))
1171 1171  
1172 -**Function:**
1048 +**Function:** Obtain all monitoring points (point table) data configured by the end user
1173 1173  
1174 -Obtain all monitoring points (point table) data configured by the end user
1050 +**✎Note: **Assuming there are timing scripts A and B with a period of 1 second, if this function is called in script A, the data will not be obtained if called in script B
1175 1175  
1176 -Note: Assuming there are timing scripts A and B with a period of 1 second, if this function is called in script A, the data will not be obtained if called in script B
1052 +**Parameters:** None
1177 1177  
1178 -**Parameters:**
1179 -
1180 -None
1181 -
1182 1182  **Return:**
1183 1183  
1184 1184  Succeed: table two-dimensional array, the structure is as follows
... ... @@ -1208,13 +1208,11 @@
1208 1208  Failed: //table// empty table
1209 1209  
1210 1210  (((
1211 -== **6.2 bns_get_config(string from)** ==
1083 +== **bns_get_config(string from)** ==
1212 1212  )))
1213 1213  
1214 -**Function:**
1086 +**Function:** Obtain custom configuration parameters with the specified from type
1215 1215  
1216 -Obtain custom configuration parameters with the specified from type
1217 -
1218 1218  **parameter:**
1219 1219  
1220 1220  from type, there are the following two categories, the string must be all lowercase
... ... @@ -1232,13 +1232,11 @@
1232 1232  Failed~:// table// empty table
1233 1233  
1234 1234  (((
1235 -== **6.3 bns_get_data(string name, string data)** ==
1105 +== **bns_get_data(string name, string data)** ==
1236 1236  )))
1237 1237  
1238 -**Function:**
1108 +**Function:**write data to the name of the monitoring point
1239 1239  
1240 -write data to the name of the monitoring point
1241 -
1242 1242  **parameter:**
1243 1243  
1244 1244  //name //The name of the monitoring point
... ... @@ -1252,7 +1252,7 @@
1252 1252  Failed: nil
1253 1253  
1254 1254  (((
1255 -== **6.4 bns_get_data(string name)** ==
1123 +== **bns_get_data(string name)** ==
1256 1256  )))
1257 1257  
1258 1258  **Function:**
... ... @@ -1270,17 +1270,13 @@
1270 1270  Failed: nil
1271 1271  
1272 1272  (((
1273 -== **6.5 bns_get_datadesc()** ==
1141 +== **bns_get_datadesc()** ==
1274 1274  )))
1275 1275  
1276 -**Function:**
1144 +**Function: **Obtain all configured communication ports and monitoring point information
1277 1277  
1278 -Obtain all configured communication ports and monitoring point information
1146 +**Parameters:** None
1279 1279  
1280 -**Parameters:**
1281 -
1282 -None
1283 -
1284 1284  **Return:**
1285 1285  
1286 1286  Succeed: table three-dimensional array, the structure is as follows
... ... @@ -1333,17 +1333,13 @@
1333 1333  Failed~:// table// empty table
1334 1334  
1335 1335  (((
1336 -== **6.6 bns_get_machineinfo()** ==
1200 +== **bns_get_machineinfo()** ==
1337 1337  )))
1338 1338  
1339 -**Function:**
1203 +**Function:** get machine information
1340 1340  
1341 -get machine information
1205 +**Parameters:** None
1342 1342  
1343 -**Parameters:**
1344 -
1345 -None
1346 -
1347 1347  **Return:**
1348 1348  
1349 1349  Succeed: 3 string type results (model, machine code, software version)
... ... @@ -1351,13 +1351,11 @@
1351 1351  Failed: nil
1352 1352  
1353 1353  (((
1354 -== **6.7 bns_get_groupdata(string name)** ==
1214 +== **bns_get_groupdata(string name)** ==
1355 1355  )))
1356 1356  
1357 -**Function:**
1217 +**Function:** Get all monitoring point data under the specified group name
1358 1358  
1359 -Get all monitoring point data under the specified group name
1360 -
1361 1361  **parameter:**
1362 1362  
1363 1363  //Name  // group name
... ... @@ -1369,17 +1369,13 @@
1369 1369  Failed: //table// empty table
1370 1370  
1371 1371  (((
1372 -== **6.8 bns_get_groupdesc()** ==
1230 +== **bns_get_groupdesc()** ==
1373 1373  )))
1374 1374  
1375 -**Function:**
1233 +**Function:** Get all group information
1376 1376  
1377 -Get all group information
1235 +**Parameters:** None
1378 1378  
1379 -**Parameters:**
1380 -
1381 -None
1382 -
1383 1383  **Return:**
1384 1384  
1385 1385  Succeed: //table// two-dimensional array, the structure is as follows
... ... @@ -1393,17 +1393,13 @@
1393 1393  Failed: //table  // empty table
1394 1394  
1395 1395  (((
1396 -== **6.9 bns_get_onecache(string msg)** ==
1250 +== **bns_get_onecache(string msg)** ==
1397 1397  )))
1398 1398  
1399 -**Function:**
1253 +**Function:** Save a message to the cache file, which can be stored after power failure. Store up to 2000 items, delete the old and save the new in a rolling manner when it is full.
1400 1400  
1401 -Save a message to the cache file, which can be stored after power failure. Store up to 2000 items, delete the old and save the new in a rolling manner when it is full.
1255 +**Parameters: **//msg// String
1402 1402  
1403 -**Parameters:**
1404 -
1405 -//msg// String
1406 -
1407 1407  **Return:**
1408 1408  
1409 1409  Succeed: true
... ... @@ -1411,17 +1411,13 @@
1411 1411  Failed: nil
1412 1412  
1413 1413  (((
1414 -== **6.10 bns_get_allcache()** ==
1264 +== **bns_get_allcache()** ==
1415 1415  )))
1416 1416  
1417 -**Function:**
1267 +**Function:** Get all the cached content (once the internal cache file will be emptied)
1418 1418  
1419 -Get all the cached content (once the internal cache file will be emptied)
1269 +**Parameters:** None
1420 1420  
1421 -**Parameters:**
1422 -
1423 -None
1424 -
1425 1425  **Return:**
1426 1426  
1427 1427  Succeed: //table// one-dimensional array
... ... @@ -1449,194 +1449,232 @@
1449 1449  Network communication includes Http request interface, this document does not provide interface description, please refer to the online document for how to use it.
1450 1450  
1451 1451  (((
1452 -== **7.1 http request** ==
1298 +== **http request** ==
1453 1453  )))
1454 1454  
1455 1455  [[http:~~/~~/w3.impa.br/~~~~diego/software/luasocket/http.html#request>>url:http://w3.impa.br/~~diego/software/luasocket/http.html#request]]
1456 1456  
1457 -(((
1458 -= **8 Internal register** =
1459 -)))
1303 +== **https request** ==
1460 1460  
1461 -The internal registers of the box are divided into bit addresses and word addresses, which can be accessed in two ways (taking HDW as an example):
1305 +Example
1462 1462  
1463 -**~1. **Access by word, prefix @W_HDW,
1307 +{{code language="LUA"}}
1308 +local json = require("json")
1464 1464  
1465 -For example: @W_HDW0 represents the first word of the system data area, @W_HDW1 represents the second word of the system data area.
1310 +local https = require("https")
1466 1466  
1467 -**2. **Access in bit mode, the prefix is @B_HDX, the number in front of "." indicates the number of the word, and the number behind is the bit number of the word.
1312 +functions https_demo.main()
1468 1468  
1469 -For example: @B_HDX1020.12, its meaning is to access the system data area in bit mode, the specific location is the 13th bit of the 1020th word.
1314 +local url = "https://XXXXXXXXXXXXXXXXXXXXXXXXXX"
1470 1470  
1471 -**✎Note: **
1316 +local body = {}
1472 1472  
1473 -**~1. **The address in @B_HDX is taken from the word in @W_HDW, so pay special attention when using the address.
1318 +body["XXXXXX"] = "XXXXX"
1474 1474  
1475 -For example, @B_HDX1020.12 is to access the 13th bit of the 1020th word. The value of this bit is the same as the word obtained by @W_HDW001020. The 13th bit of this word is actually the same bit as @B_HDX1020.12.
1320 +body["XXXXXXX"] = "XXXXXXXXXXX"
1476 1476  
1477 -**2.**The address of the bit address @B_HDX has a decimal point, while the word address is an integer.
1322 +local bodyJson = json.encode(body)
1478 1478  
1479 -(((
1480 -== **8.1 Data storage area(HDW/HDX)** ==
1481 -)))
1324 +local header = {}
1482 1482  
1483 -The system storage area (HDW) of the V-BOX is used to store temporary data:
1326 +header["content-type"] = "application/json"
1484 1484  
1485 -~1. Access by word, the number range is: "@W_HDW0"-"@W_HDW299999".
1328 +local result_table, code, headers, status = https.request(url,
1486 1486  
1487 -2. Access in bit mode, the number range is: "@B_HDX0.0"-"@B_HDX299999.15".
1330 +bodyJson)
1488 1488  
1489 -(((
1490 -== **8.2 Special data area (HSW/HSX)** ==
1491 -)))
1332 +if code == 200 then
1492 1492  
1493 -**✎Note: **
1334 +print("https suc")
1494 1494  
1495 -//HSW// is a system special register, so please refer to the system special register table during use. Do not use addresses that are not mentioned in the table, and use the addresses stated in the table with caution (example: restart ("@W_HSW0") Writing a value of 1 will cause V-BOX to restart).
1336 +return true
1496 1496  
1497 -//Without any conditions. Direct use ("@W_HSW0") will cause the V-BOX to restart continuously.// When using ("@W_HSW0") address, please add judgment conditions, such as: connection to MQTT fails, there is no network, the value of a PLC address meets the condition or counts to a certain value.
1338 +else
1498 1498  
1499 -1.The system data area (HSW) of the box is used for system special registers (system reserved). Use //addr_getword// to obtain the following register information:
1340 +print("https fail")
1500 1500  
1501 -(% class="table-bordered" %)
1502 -|address|function|Read and write status: read only, write only, read and write
1503 -|@W_HSW0|restart|read and write
1504 -|@W_HSW1|Box time: year|read and write
1505 -|@W_HSW2|Box time: month|read and write
1506 -|@W_HSW3|Box time: day|read and write
1507 -|@W_HSW4|Box time: hour|read and write
1508 -|@W_HSW5|Box time: minute|read and write
1509 -|@W_HSW6|Box time: second|read and write
1510 -|@W_HSW7|Box time: week|read and write
1511 -|@W_HSW8|Ethernet IP1|read only
1512 -|@W_HSW9|Ethernet IP2|read only
1513 -|@W_HSW10|Ethernet IP3|read only
1514 -|@W_HSW11|Ethernet IP4|read only
1515 -|@W_HSW12|Ethernet Mask 1|read only
1516 -|@W_HSW13|Ethernet Mask 2|read only
1517 -|@W_HSW14|Ethernet Mask 3|read only
1518 -|@W_HSW15|Ethernet Mask 4|read only
1519 -|@W_HSW16|Ethernet Gateway 1|read only
1520 -|@W_HSW17|Ethernet Gateway 2|read only
1521 -|@W_HSW18|Ethernet Gateway 3|read only
1522 -|@W_HSW19|Ethernet Gateway 4|read only
1523 -|@W_HSW21|Ethernet MAC1|read only
1524 -|@W_HSW22|Ethernet MAC2|read only
1525 -|@W_HSW23|Ethernet MAC3|read only
1526 -|@W_HSW24|Ethernet MAC4|read only
1527 -|@W_HSW25|Ethernet MAC3|read only
1528 -|@W_HSW26|Ethernet MAC4|read only
1529 -|@W_HSW128|WIFI IP1|read only
1530 -|@W_HSW129|WIFI IP2|read only
1531 -|@W_HSW130|WIFI IP3|read only
1532 -|@W_HSW131|WIFI IP4|read only
1533 -|@W_HSW132|WIFI Mask 1|read only
1534 -|@W_HSW133|WIFI Mask 2|read only
1535 -|@W_HSW134|WIFI Mask 3|read only
1536 -|@W_HSW135|WIFI Mask 4|read only
1537 -|@W_HSW136|WIFI Gateway 1|read only
1538 -|@W_HSW137|WIFI Gateway 2|read only
1539 -|@W_HSW138|WIFI Gateway 3|read only
1540 -|@W_HSW139|WIFI Gateway 4|read only
1541 -|@W_HSW140|WIFI MAC1|read only
1542 -|@W_HSW141|WIFI MAC2|read only
1543 -|@W_HSW142|WIFI MAC3|read only
1544 -|@W_HSW143|WIFI MAC4|read only
1545 -|@W_HSW144|WIFI MAC5|read only
1546 -|@W_HSW145|WIFI MAC6|read only
1547 -|@W_HSW146|WIFI Signal value|read only
1548 -|@W_HSW148|4G IP1|read only
1549 -|@W_HSW149|4G IP2|read only
1550 -|@W_HSW150|4G IP3|read only
1551 -|@W_HSW151|4G IP4|read only
1552 -|@W_HSW152|4G Mask 1|read only
1553 -|@W_HSW153|4G Mask 2|read only
1554 -|@W_HSW154|4G Mask 3|read only
1555 -|@W_HSW155|4G Mask 4|read only
1556 -|@W_HSW156|4G Gateway 1|read only
1557 -|@W_HSW157|4G Gateway 2|read only
1558 -|@W_HSW158|4G Gateway 3|read only
1559 -|@W_HSW159|4G Gateway 4|read only
1560 -|@W_HSW160|4G MAC1|read only
1561 -|@W_HSW161|4G MAC2|read only
1562 -|@W_HSW162|4G MAC3|read only
1563 -|@W_HSW163|4G MAC4|read only
1564 -|@W_HSW164|4G MAC5|read only
1565 -|@W_HSW165|4G MAC6|read only
1566 -|@W_HSW166|4G Signal value|read only
1342 +return nil
1567 1567  
1568 -2. Other
1344 +end
1569 1569  
1570 -2.1 Access password: addr_getstring("@W_HSW27", 16)
1346 +end
1347 +{{/code}}
1571 1571  
1572 -2.2 Machine code: addr_getstring("@W_HSW60", 64)
1349 +(((
1350 += **8 Internal register** =
1351 +)))
1573 1573  
1574 -2.3 Positioning method (@W_HSW167): (read only)
1353 +The internal registers of the box are divided into bit addresses and word addresses, which can be accessed in two ways (taking HDW as an example):
1575 1575  
1576 -~1. Latitude and longitude
1355 +**Access by word, prefix @W_HDW.**
1577 1577  
1578 -Longitude: addr_getdouble("@W_HSW168") (read only)
1357 +For example: @W_HDW0 represents the first word of the system data area, @W_HDW1 represents the second word of the system data area.
1579 1579  
1580 -Latitude: addr_getdouble("@W_HSW172") (read only)
1359 +**Access in bit mode, the prefix is @B_HDX, the number in front of "." indicates the number of the word, and the number behind is the bit number of the word.**
1581 1581  
1582 -2. Base station positioning
1361 +For example: @B_HDX1020.12, its meaning is to access the system data area in bit mode, the specific location is the 13th bit of the 1020th word.
1583 1583  
1584 -LAC: addr_getdword("@W_HSW168") (read only)
1363 +(% class="box infomessage" %)
1364 +(((
1365 +**✎Note: **
1585 1585  
1586 -CI: addr_getdword("@W_HSW172") (read only)
1367 +* The address in @B_HDX is taken from the word in @W_HDW, so pay special attention when using the address.
1368 +** For example, @B_HDX1020.12 is to access the 13th bit of the 1020th word. The value of this bit is the same as the word obtained by @W_HDW001020. The 13th bit of this word is actually the same bit as @B_HDX1020.12.
1369 +* The address of the bit address @B_HDX has a decimal point, while the word address is an integer.
1370 +)))
1587 1587  
1588 -2.4 Convert base station to latitude and longitude via API
1589 1589  
1590 -Longitude: addr_getdouble("@W_HSW187") (read only)
1373 +(((
1374 +== **Data storage area(HDW/HDX)** ==
1375 +)))
1591 1591  
1592 -Latitude: addr_getdouble("@W_HSW183") (read only)
1377 +The system storage area (HDW) of the V-BOX is used to store temporary data:
1593 1593  
1594 -2.5 Operator information: addr_getdword("@W_HSW181") (read only)
1379 +1. Access by word, the number range is: "@W_HDW0"-"@W_HDW299999".
1380 +1. Access in bit mode, the number range is: "@B_HDX0.0"-"@B_HDX299999.15".
1595 1595  
1596 -2.6 Networking mode: addr_getword("@W_HSW177") (read only)
1382 +(((
1383 +== **8.2 Special data area (HSW/HSX)** ==
1597 1597  
1598 -0: Ethernet, 1: WIFI, 2: 4G, 3: 2G
1385 +(% class="box infomessage" %)
1386 +(((
1387 +**✎Note: **
1599 1599  
1600 -2.7 Map fence flag: addr_getword("@W_HSW178") (read only)
1389 +* //HSW// is a system special register, so please refer to the system special register table during use. Do not use addresses that are not mentioned in the table, and use the addresses stated in the table with caution (example: restart ("@W_HSW0") Writing a value of 1 will cause V-BOX to restart).
1390 +* //Without any conditions. Direct use ("@W_HSW0") will cause the V-BOX to restart continuously.// When using ("@W_HSW0") address, please add judgment conditions, such as: connection to MQTT fails, there is no network, the value of a PLC address meets the condition or counts to a certain value.
1391 +)))
1392 +)))
1601 1601  
1602 -0: No map fence is drawn
1394 +The system data area (HSW) of the box is used for system special registers (system reserved). Use //addr_getword// to obtain the following register information:
1603 1603  
1604 -1: Draw a map fence and the box is in the fence
1396 +(% class="table-bordered" %)
1397 +|=(% style="width: 151px;" %)address|=(% style="width: 169px;" %)function|=(% style="width: 456px;" %)Read and write status: read only, write only, read and write
1398 +|(% style="width:151px" %)@W_HSW0|(% style="width:169px" %)restart|(% style="width:456px" %)read and write
1399 +|(% style="width:151px" %)@W_HSW1|(% style="width:169px" %)Box time: year|(% style="width:456px" %)read and write
1400 +|(% style="width:151px" %)@W_HSW2|(% style="width:169px" %)Box time: month|(% style="width:456px" %)read and write
1401 +|(% style="width:151px" %)@W_HSW3|(% style="width:169px" %)Box time: day|(% style="width:456px" %)read and write
1402 +|(% style="width:151px" %)@W_HSW4|(% style="width:169px" %)Box time: hour|(% style="width:456px" %)read and write
1403 +|(% style="width:151px" %)@W_HSW5|(% style="width:169px" %)Box time: minute|(% style="width:456px" %)read and write
1404 +|(% style="width:151px" %)@W_HSW6|(% style="width:169px" %)Box time: second|(% style="width:456px" %)read and write
1405 +|(% style="width:151px" %)@W_HSW7|(% style="width:169px" %)Box time: week|(% style="width:456px" %)read and write
1406 +|(% style="width:151px" %)@W_HSW8|(% style="width:169px" %)Ethernet IP1|(% style="width:456px" %)read only
1407 +|(% style="width:151px" %)@W_HSW9|(% style="width:169px" %)Ethernet IP2|(% style="width:456px" %)read only
1408 +|(% style="width:151px" %)@W_HSW10|(% style="width:169px" %)Ethernet IP3|(% style="width:456px" %)read only
1409 +|(% style="width:151px" %)@W_HSW11|(% style="width:169px" %)Ethernet IP4|(% style="width:456px" %)read only
1410 +|(% style="width:151px" %)@W_HSW12|(% style="width:169px" %)Ethernet Mask 1|(% style="width:456px" %)read only
1411 +|(% style="width:151px" %)@W_HSW13|(% style="width:169px" %)Ethernet Mask 2|(% style="width:456px" %)read only
1412 +|(% style="width:151px" %)@W_HSW14|(% style="width:169px" %)Ethernet Mask 3|(% style="width:456px" %)read only
1413 +|(% style="width:151px" %)@W_HSW15|(% style="width:169px" %)Ethernet Mask 4|(% style="width:456px" %)read only
1414 +|(% style="width:151px" %)@W_HSW16|(% style="width:169px" %)Ethernet Gateway 1|(% style="width:456px" %)read only
1415 +|(% style="width:151px" %)@W_HSW17|(% style="width:169px" %)Ethernet Gateway 2|(% style="width:456px" %)read only
1416 +|(% style="width:151px" %)@W_HSW18|(% style="width:169px" %)Ethernet Gateway 3|(% style="width:456px" %)read only
1417 +|(% style="width:151px" %)@W_HSW19|(% style="width:169px" %)Ethernet Gateway 4|(% style="width:456px" %)read only
1418 +|(% style="width:151px" %)@W_HSW21|(% style="width:169px" %)Ethernet MAC1|(% style="width:456px" %)read only
1419 +|(% style="width:151px" %)@W_HSW22|(% style="width:169px" %)Ethernet MAC2|(% style="width:456px" %)read only
1420 +|(% style="width:151px" %)@W_HSW23|(% style="width:169px" %)Ethernet MAC3|(% style="width:456px" %)read only
1421 +|(% style="width:151px" %)@W_HSW24|(% style="width:169px" %)Ethernet MAC4|(% style="width:456px" %)read only
1422 +|(% style="width:151px" %)@W_HSW25|(% style="width:169px" %)Ethernet MAC3|(% style="width:456px" %)read only
1423 +|(% style="width:151px" %)@W_HSW26|(% style="width:169px" %)Ethernet MAC4|(% style="width:456px" %)read only
1424 +|(% style="width:151px" %)@W_HSW128|(% style="width:169px" %)WIFI IP1|(% style="width:456px" %)read only
1425 +|(% style="width:151px" %)@W_HSW129|(% style="width:169px" %)WIFI IP2|(% style="width:456px" %)read only
1426 +|(% style="width:151px" %)@W_HSW130|(% style="width:169px" %)WIFI IP3|(% style="width:456px" %)read only
1427 +|(% style="width:151px" %)@W_HSW131|(% style="width:169px" %)WIFI IP4|(% style="width:456px" %)read only
1428 +|(% style="width:151px" %)@W_HSW132|(% style="width:169px" %)WIFI Mask 1|(% style="width:456px" %)read only
1429 +|(% style="width:151px" %)@W_HSW133|(% style="width:169px" %)WIFI Mask 2|(% style="width:456px" %)read only
1430 +|(% style="width:151px" %)@W_HSW134|(% style="width:169px" %)WIFI Mask 3|(% style="width:456px" %)read only
1431 +|(% style="width:151px" %)@W_HSW135|(% style="width:169px" %)WIFI Mask 4|(% style="width:456px" %)read only
1432 +|(% style="width:151px" %)@W_HSW136|(% style="width:169px" %)WIFI Gateway 1|(% style="width:456px" %)read only
1433 +|(% style="width:151px" %)@W_HSW137|(% style="width:169px" %)WIFI Gateway 2|(% style="width:456px" %)read only
1434 +|(% style="width:151px" %)@W_HSW138|(% style="width:169px" %)WIFI Gateway 3|(% style="width:456px" %)read only
1435 +|(% style="width:151px" %)@W_HSW139|(% style="width:169px" %)WIFI Gateway 4|(% style="width:456px" %)read only
1436 +|(% style="width:151px" %)@W_HSW140|(% style="width:169px" %)WIFI MAC1|(% style="width:456px" %)read only
1437 +|(% style="width:151px" %)@W_HSW141|(% style="width:169px" %)WIFI MAC2|(% style="width:456px" %)read only
1438 +|(% style="width:151px" %)@W_HSW142|(% style="width:169px" %)WIFI MAC3|(% style="width:456px" %)read only
1439 +|(% style="width:151px" %)@W_HSW143|(% style="width:169px" %)WIFI MAC4|(% style="width:456px" %)read only
1440 +|(% style="width:151px" %)@W_HSW144|(% style="width:169px" %)WIFI MAC5|(% style="width:456px" %)read only
1441 +|(% style="width:151px" %)@W_HSW145|(% style="width:169px" %)WIFI MAC6|(% style="width:456px" %)read only
1442 +|(% style="width:151px" %)@W_HSW146|(% style="width:169px" %)WIFI Signal value|(% style="width:456px" %)read only
1443 +|(% style="width:151px" %)@W_HSW148|(% style="width:169px" %)4G IP1|(% style="width:456px" %)read only
1444 +|(% style="width:151px" %)@W_HSW149|(% style="width:169px" %)4G IP2|(% style="width:456px" %)read only
1445 +|(% style="width:151px" %)@W_HSW150|(% style="width:169px" %)4G IP3|(% style="width:456px" %)read only
1446 +|(% style="width:151px" %)@W_HSW151|(% style="width:169px" %)4G IP4|(% style="width:456px" %)read only
1447 +|(% style="width:151px" %)@W_HSW152|(% style="width:169px" %)4G Mask 1|(% style="width:456px" %)read only
1448 +|(% style="width:151px" %)@W_HSW153|(% style="width:169px" %)4G Mask 2|(% style="width:456px" %)read only
1449 +|(% style="width:151px" %)@W_HSW154|(% style="width:169px" %)4G Mask 3|(% style="width:456px" %)read only
1450 +|(% style="width:151px" %)@W_HSW155|(% style="width:169px" %)4G Mask 4|(% style="width:456px" %)read only
1451 +|(% style="width:151px" %)@W_HSW156|(% style="width:169px" %)4G Gateway 1|(% style="width:456px" %)read only
1452 +|(% style="width:151px" %)@W_HSW157|(% style="width:169px" %)4G Gateway 2|(% style="width:456px" %)read only
1453 +|(% style="width:151px" %)@W_HSW158|(% style="width:169px" %)4G Gateway 3|(% style="width:456px" %)read only
1454 +|(% style="width:151px" %)@W_HSW159|(% style="width:169px" %)4G Gateway 4|(% style="width:456px" %)read only
1455 +|(% style="width:151px" %)@W_HSW160|(% style="width:169px" %)4G MAC1|(% style="width:456px" %)read only
1456 +|(% style="width:151px" %)@W_HSW161|(% style="width:169px" %)4G MAC2|(% style="width:456px" %)read only
1457 +|(% style="width:151px" %)@W_HSW162|(% style="width:169px" %)4G MAC3|(% style="width:456px" %)read only
1458 +|(% style="width:151px" %)@W_HSW163|(% style="width:169px" %)4G MAC4|(% style="width:456px" %)read only
1459 +|(% style="width:151px" %)@W_HSW164|(% style="width:169px" %)4G MAC5|(% style="width:456px" %)read only
1460 +|(% style="width:151px" %)@W_HSW165|(% style="width:169px" %)4G MAC6|(% style="width:456px" %)read only
1461 +|(% style="width:151px" %)@W_HSW166|(% style="width:169px" %)4G Signal value|(% style="width:456px" %)read only
1605 1605  
1606 -2: Draw a map fence and the box is not in the fence
1463 +**Others**
1607 1607  
1608 -2.8 SIM card status addr_getword("@W_HSW179") (read only)
1465 +* Access password: addr_getstring("@W_HSW27", 16)
1466 +* Machine code: addr_getstring("@W_HSW60", 64)
1467 +* Positioning method (@W_HSW167): (read only)
1468 +** Latitude and longitude
1469 +*** Longitude: addr_getdouble("@W_HSW168") (read only)
1470 +*** Latitude: addr_getdouble("@W_HSW172") (read only)
1471 +** Base station positioning
1472 +*** LAC: addr_getdword("@W_HSW168") (read only)
1473 +*** CI: addr_getdword("@W_HSW172") (read only)
1474 +* Convert base station to latitude and longitude via API
1475 +** Longitude: addr_getdouble("@W_HSW187") (read only)
1476 +** Latitude: addr_getdouble("@W_HSW183") (read only)
1477 +* Operator information: addr_getdword("@W_HSW181") (read only)
1478 +* Networking mode: addr_getword("@W_HSW177") (read only)
1479 +** 0: Ethernet
1480 +** 1: WIFI
1481 +** 2: 4G
1482 +** 3: 2G
1483 +* Map fence flag: addr_getword("@W_HSW178") (read only)
1484 +** 0: No map fence is drawn
1485 +** 1: Draw a map fence and the box is in the fence
1486 +** 2: Draw a map fence and the box is not in the fence
1487 +* SIM card status addr_getword("@W_HSW179") (read only)
1488 +** 1: No card detected
1489 +** 2: Card insertion detected
1490 +** 3: The card status is abnormal
1491 +* MQTT status addr_getword("@W_HSW180") (read only)
1492 +** 1: online, 2: offline
1493 +* IO interface, X is read only, Y is read and write (H series)
1494 +** addr_getbit(addr1), addr_setbit(addr2)
1495 +** addr1:"@B_Y0" "@B_Y1" "@B_X0" "@B_X1"
1496 +** addr2:"@B_Y0" "@B_Y1"
1497 +* Obtaining IMEI (read only)
1498 +** addr_getstring("@W_HSW191",17)
1499 +* Obtaining ICCID (read only)
1500 +** addr_getstring("@W_HSW225",15)
1609 1609  
1610 -1: No card detected
1502 +(((
1503 +== **Power-down storage area (HAW/HAX)** ==
1611 1611  
1612 -2: Card insertion detected
1505 +The system storage area (HAW) is used for the system power-down hold registers:
1613 1613  
1614 -3: The card status is abnormal
1507 +1. Accessed as a word, numbered in the range: "@W_HAW0"-"@W_HAW199999".
1508 +1. Accessed by bit, the numbering range is: "@B_HAX0.0"-"@B_HAX199999.15".
1615 1615  
1616 -2.9 MQTT status addr_getword("@W_HSW180") (read only)
1617 -
1618 -1: online, 2: offline
1619 -
1620 -2.10 IO interface, X is read only, Y is read and write (H series)
1621 -
1622 -addr_getbit(addr1), addr_setbit(addr2)
1623 -
1624 -addr1:"@B_Y0" "@B_Y1" "@B_X0" "@B_X1"
1625 -
1626 -addr2:"@B_Y0" "@B_Y1"
1627 -
1510 +(% class="box infomessage" %)
1628 1628  (((
1512 +**✎Note:** HAW/HAX is a power-down hold, that is, the registers of this type can retain the data before power-down in case of power-down.
1513 +)))
1514 +
1629 1629  = **9 General Functions** =
1630 1630  )))
1631 1631  
1632 1632  (((
1633 -== **9.1 send_sms_ira(string number, string message)** ==
1519 +== **send_sms_ira(string number, string message)** ==
1634 1634  )))
1635 1635  
1636 -**Function:**
1522 +**Function:** Use IRA character set to send English text messages
1637 1637  
1638 -Use IRA character set to send English text messages
1639 -
1640 1640  **Parameters:**
1641 1641  
1642 1642  //number: //number (up to 32 characters, the excess will be discarded)
... ... @@ -1670,13 +1670,11 @@
1670 1670  Failed: multi
1671 1671  
1672 1672  (((
1673 -== **9.3 sms_get_state(number id)** ==
1557 +== **sms_get_state(number id)** ==
1674 1674  )))
1675 1675  
1676 -**Function:**
1560 +**Function:** Get the status of the SMS
1677 1677  
1678 -Get the status of the SMS
1679 -
1680 1680  **parameter:**
1681 1681  
1682 1682  //id~:// SMS corresponding id
... ... @@ -1688,13 +1688,11 @@
1688 1688  Failed: multi
1689 1689  
1690 1690  (((
1691 -== **9.4 jwt_encode(table head, table payload, string aud, number iat, number exp, string key, int jwttype)** ==
1573 +== **jwt_encode(table head, table payload, string aud, number iat, number exp, string key, int jwttype)** ==
1692 1692  )))
1693 1693  
1694 -**Function:**
1576 +**Function:** Convert data to JWT format
1695 1695  
1696 -Convert data to JWT format
1697 -
1698 1698  **parameter:**
1699 1699  
1700 1700  //aud: //project name
... ... @@ -1739,19 +1739,20 @@
1739 1739  
1740 1740  //key~:// the private key required for encryption
1741 1741  
1742 -For example:
1622 +**For example:**
1743 1743  
1624 +{{code language="LUA"}}
1744 1744  function jwt.main()
1745 1745  
1746 -local PRIVATE_KEY = ~[~[~-~- Please enter the secret key~-~-]]
1627 +local PRIVATE_KEY = [[-- Please enter the secret key--]]
1747 1747  
1748 1748  local JWTType=0
1749 1749  
1750 -local payload = ~{~{key="test1",value="test1",type="0"},
1631 +local payload = {{key="test1",value="test1",type="0"},
1751 1751  
1752 1752  {key="test",value="123122131",type="1"}}
1753 1753  
1754 -local head = ~{~{ key="name",value="data",type="0"},
1635 +local head = {{ key="name",value="data",type="0"},
1755 1755  
1756 1756  {key="test2",value="test2",type="0"}}
1757 1757  
... ... @@ -1766,15 +1766,14 @@
1766 1766  print(en)
1767 1767  
1768 1768  End
1650 +{{/code}}
1769 1769  
1770 1770  (((
1771 -== **9.5 convertohex(number type, number value)** ==
1653 +== **convertohex(number type, number value)** ==
1772 1772  )))
1773 1773  
1774 -**Function:**
1656 +**Function:** Convert data into hexadecimal data
1775 1775  
1776 -Convert data into hexadecimal data
1777 -
1778 1778  **parameter:**
1779 1779  
1780 1780  //type~:// incoming data type 0:word 1:dword 2:float
... ... @@ -1787,14 +1787,27 @@
1787 1787  
1788 1788  Failed: multi
1789 1789  
1670 +== **crc.init(table prarm)** ==
1671 +
1672 +**Function:** Initialize the CRC
1673 +
1674 +**Parameters:**
1675 +
1676 +prarm is a Lua table and needs to contain the following fields.
1677 +
1678 +* string prarm name, see table 9-1 for details of the parameter model name When this parameter is passed in, the default table parameters are used and the poly,init,xorout,refin,and refout passed in are invalid.
1679 +* number prarm.width: the width, i.e. the number of CRC bits.
1680 +* number [prarm.poly]: short for the generated item, in hexadecimal notation. For example, CRC-32 is 0x04C11DB7, ignoring the highest bit "1", i.e., the complete generation item is 0x104C11DB7.
1681 +* number [prarm.init], the initialization preset value of the register (crc) at the beginning of the algorithm.
1682 +
1683 +Fuzhou Fuchang V-Control Electronic Technology Co., Ltd. Page 32 / Total 39 Software III Hexadecimal representation. number [prarm.xorout], the final CRC value obtained after heterodyning the calculation result with this parameter. number [prarm.refin], whether each byte of the data to be measured is inverted by bit, true or false. number [prarm.refout], after the calculation and before the heterodyning output, whether the whole data is inverted by bit, true or false. Return: success: crc object Failure: multi, error code
1684 +
1790 1790  (((
1791 -== **9.6 set_network(table config)** ==
1686 +== **set_network(table config)** ==
1792 1792  )))
1793 1793  
1794 -**Function:**
1689 +**Function:** Set V-BOX network, take effect after restart
1795 1795  
1796 -Set V-BOX network, take effect after restart
1797 -
1798 1798  **parameter:**
1799 1799  
1800 1800  //config~:// incoming network configuration table