Changes for page 01 Lua Functions
Last modified by Theodore Xu on 2023/10/26 10:51
Summary
-
Page properties (1 modified, 0 added, 0 removed)
Details
- Page properties
-
- Content
-
... ... @@ -627,13 +627,11 @@ 627 627 1. When the data bit is 8, the maximum value of data transmission is 255 (0xFF), which supports the transmission of any character. 628 628 629 629 ((( 630 -== ** 3.1serial.open(table setup)** ==630 +== **serial.open(table setup)** == 631 631 ))) 632 632 633 -**Function:** 633 +**Function:** Enable one serial port 634 634 635 -Enable one serial port 636 - 637 637 **Parameters:** 638 638 639 639 //Setup// is a Lua table; it needs to contain the following fields ... ... @@ -667,17 +667,13 @@ 667 667 Failed: multi 668 668 669 669 ((( 670 -== ** 3.2serial.close(serial obj)** ==668 +== **serial.close(serial obj)** == 671 671 ))) 672 672 673 -**Function:** 671 +**Function:** Disable the serial port 674 674 675 - Disable the serialport673 +**Parameters: **//Obj //is the object returned by serial.open 676 676 677 -**Parameters:** 678 - 679 -//Obj //is the object returned by serial.open 680 - 681 681 **Return:** 682 682 683 683 Succeed: true ... ... @@ -685,13 +685,11 @@ 685 685 Failed: multi 686 686 687 687 ((( 688 -== ** 3.3serial:read(number bytes[, number timeout])** ==682 +== **serial:read(number bytes[, number timeout])** == 689 689 ))) 690 690 691 -**Function:** 685 +**Function:** Read the specified byte length serial port data 692 692 693 -Read the specified byte length serial port data 694 - 695 695 **Parameters:** 696 696 697 697 //bytes//: number of bytes ... ... @@ -705,15 +705,13 @@ 705 705 Failed: multi 706 706 707 707 ((( 708 -== ** 3.4serial:write(string data)** ==700 +== **serial:write(string data)** == 709 709 ))) 710 710 711 -**Function:** 703 +**Function:** Write the specified byte length to serial port data 712 712 713 - Writehepecifiedbyte length to serial port data705 +**Parameters: ** 714 714 715 -**Parameters:** 716 - 717 717 //data//: serial port data 718 718 719 719 **Return:** ... ... @@ -723,13 +723,11 @@ 723 723 Failed: multi 724 724 725 725 ((( 726 -== ** 3.5serial:flush([number flag])** ==716 +== **serial:flush([number flag])** == 727 727 ))) 728 728 729 -**Function:** 719 +**Function:** Clear the serial port buffer 730 730 731 -Clear the serial port buffer 732 - 733 733 **Parameters:** 734 734 735 735 //[flag=2]// clear option: 0: read, 1: write, 2: read-write ... ... @@ -741,17 +741,13 @@ 741 741 Failed: multi 742 742 743 743 ((( 744 -== ** 3.6serial:close()** ==732 +== **serial:close()** == 745 745 ))) 746 746 747 -**Function:** 735 +**Function:** Close the serial port object 748 748 749 - Closeheserial port object737 +**Parameters:** None 750 750 751 -**Parameters:** 752 - 753 -None 754 - 755 755 **Return:** 756 756 757 757 Succeed: true ... ... @@ -768,12 +768,10 @@ 768 768 769 769 **QoS value:** 770 770 771 -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. 772 772 773 -1: The message is delivered at least once, but the message may be delivered repeatedly. 774 - 775 -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. 776 - 777 777 **Retain flag:** 778 778 779 779 0: not reserved; ... ... @@ -781,13 +781,11 @@ 781 781 1: reserved 782 782 783 783 ((( 784 -== ** 4.1mqtt.create(string serverurl, string clientid)** ==766 +== **mqtt.create(string serverurl, string clientid)** == 785 785 ))) 786 786 787 -**Function:** 769 +**Function:** Create an MQTT object 788 788 789 -Create an MQTT object 790 - 791 791 **Parameters:** 792 792 793 793 //serverurl //Server url ... ... @@ -809,17 +809,13 @@ 809 809 Failed: multi 810 810 811 811 ((( 812 -== ** 4.2mqtt.close(mqtt obj)** ==792 +== **mqtt.close(mqtt obj)** == 813 813 ))) 814 814 815 -**Function:** 795 +**Function:** Close the specified MQTT object (if the connected server will be disconnected automatically) 816 816 817 - ClosehepecifiedMQTT object(iftheconnectedserverwill be disconnectedautomatically)797 +**Parameters: **//Obj //is the objeced returned by mqtt.create 818 818 819 -**Parameters:** 820 - 821 -//Obj //is the objeced returned by mqtt.create 822 - 823 823 **Return:** 824 824 825 825 Succeed: true ... ... @@ -827,32 +827,25 @@ 827 827 Failed: multi 828 828 829 829 ((( 830 -== ** 4.3mqtt:connect(table conn[, table lwt, table cart])** ==806 +== **mqtt:connect(table conn[, table lwt, table cart])** == 831 831 ))) 832 832 833 -**Function:** 809 +**Function:**Establish a connection to the server 834 834 835 -Establish a connection to the server 836 - 837 837 **Parameters:** 838 838 839 839 //conn //is a Lua table and needs to contain the following fields 840 840 841 -//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: 842 842 843 -//string conn.password//, password 844 - 845 -//number [conn.netway=0]//, networking method, if set error number will use Ethernet method 846 - 847 -* 0: Ethernet 848 -* 1: WIFI 849 -* 2: 4G 850 -* 3: 2G 851 - 852 -//number [conn.keepalive=60]//, keep connected heartbeat interval, in seconds 853 - 854 -//number [conn.cleansession=1]//, empty the session as described below: 855 - 856 856 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: 857 857 858 858 * 1 (Empty): If a session exists and is 1, the previous session messages on the client and server are emptied. ... ... @@ -860,14 +860,11 @@ 860 860 861 861 //lwt// (Last Will and Testament) is a Lua table and needs to contain the following fields 862 862 863 -//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 864 864 865 -//string lwt.message//, message 866 - 867 -//number [lwt.qos=0]//, qos value 868 - 869 -//number [lwt.retain=0]//, retain flag 870 - 871 871 **Return:** 872 872 873 873 Succeed: true ... ... @@ -875,17 +875,13 @@ 875 875 Failed: multi 876 876 877 877 ((( 878 -== ** 4.4mqtt:disconnect([number timeout])** ==844 +== **mqtt:disconnect([number timeout])** == 879 879 ))) 880 880 881 -**Function:** 847 +**Function:** Disconnect from the MQTT server 882 882 883 -Disconnect fromtheMQTTserver849 +**Parameters: **//[timeout=10000] //Disconnect waiting timeout, in milliseconds 884 884 885 -**Parameters:** 886 - 887 -//[timeout=10000] //Disconnect waiting timeout, in milliseconds 888 - 889 889 **Return:** 890 890 891 891 Succeed: true ... ... @@ -893,17 +893,13 @@ 893 893 Failed: multi 894 894 895 895 ((( 896 -== ** 4.5mqtt:isconnected()** ==858 +== **mqtt:isconnected()** == 897 897 ))) 898 898 899 -**Function:** 861 +**Function:** Test whether or not a client is currently connected to the MQTT server 900 900 901 - Test whetheror notaclientis currently connectedto the MQTT server863 +**Parameters:** None 902 902 903 -**Parameters:** 904 - 905 -None 906 - 907 907 **Return:** 908 908 909 909 Succeed: true ~-~-Connected ... ... @@ -911,13 +911,11 @@ 911 911 Failed: false ~-~- Unconnected and other unknowns 912 912 913 913 ((( 914 -== ** 4.6mqtt:subscribe(string topic, number qos)** ==872 +== **mqtt:subscribe(string topic, number qos)** == 915 915 ))) 916 916 917 -**Function:** 875 +**Function: **Subscribe to the topic (before the subscription, the user must first call the connect method to connect to the server) 918 918 919 -Subscribe to the topic (before the subscription, the user must first call the connect method to connect to the server) 920 - 921 921 **Parameters:** 922 922 923 923 //topic//, topic name ... ... @@ -931,13 +931,11 @@ 931 931 Failed: multi 932 932 933 933 ((( 934 -== ** 4.7mqtt:unsubscribe(string topic)** ==890 +== **mqtt:unsubscribe(string topic)** == 935 935 ))) 936 936 937 -**Function:** 893 +**Function:** Unsubscribe topic 938 938 939 -Unsubscribe topic 940 - 941 941 **Parameters:** 942 942 943 943 //topic//, topic name ... ... @@ -949,13 +949,11 @@ 949 949 Failed: multi 950 950 951 951 ((( 952 -== ** 4.8mqtt:publish(string topic, string message, number qos, number retain[, number timeout])** ==906 +== **mqtt:publish(string topic, string message, number qos, number retain[, number timeout])** == 953 953 ))) 954 954 955 -**Function:** 909 +**Function:** Publish message 956 956 957 -Publish message 958 - 959 959 **Parameters:** 960 960 961 961 //topic//, topic name ... ... @@ -975,17 +975,13 @@ 975 975 Failed: multi 976 976 977 977 ((( 978 -== ** 4.9mqtt:close()** ==930 +== **mqtt:close()** == 979 979 ))) 980 980 981 -**Function:** 933 +**Function:** Close the mqtt object (the connection to the server will be automatically disconnected) 982 982 983 - Close themqtt object(theconnection to the server will be automatically disconnected)935 +**Parameters:** None 984 984 985 -**Parameters:** 986 - 987 -None 988 - 989 989 **Return:** 990 990 991 991 Succeed: true ... ... @@ -993,13 +993,11 @@ 993 993 Failed: multi 994 994 995 995 ((( 996 -== ** 4.10mqtt:on(string method, function callback)** ==944 +== **mqtt:on(string method, function callback)** == 997 997 ))) 998 998 999 -**Function:** 947 +**Function:** Register event callback function 1000 1000 1001 -Register event callback function 1002 - 1003 1003 **Parameters:** 1004 1004 1005 1005 //method//, It can be message/arrived/offline, these 3 types of events