Changes for page 01 Lua Functions

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

From version 5.9
edited by Stone Wu
on 2022/07/12 09:26
Change comment: There is no comment for this version
To version 5.10
edited by Stone Wu
on 2022/07/12 09:30
Change comment: (Autosaved)

Summary

Details

Page properties
Content
... ... @@ -752,12 +752,10 @@
752 752  
753 753  **QoS value:**
754 754  
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.
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.
756 756  
757 -1: The message is delivered at least once, but the message may be delivered repeatedly.
758 -
759 -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.
760 -
761 761  **Retain flag:**
762 762  
763 763  0: not reserved;
... ... @@ -765,13 +765,11 @@
765 765  1: reserved
766 766  
767 767  (((
768 -== **4.1 mqtt.create(string serverurl, string clientid)** ==
766 +== **mqtt.create(string serverurl, string clientid)** ==
769 769  )))
770 770  
771 -**Function:**
769 +**Function:** Create an MQTT object
772 772  
773 -Create an MQTT object
774 -
775 775  **Parameters:**
776 776  
777 777  //serverurl //Server url
... ... @@ -793,17 +793,13 @@
793 793  Failed: multi
794 794  
795 795  (((
796 -== **4.2 mqtt.close(mqtt obj)** ==
792 +== **mqtt.close(mqtt obj)** ==
797 797  )))
798 798  
799 -**Function:**
795 +**Function:** Close the specified MQTT object (if the connected server will be disconnected automatically)
800 800  
801 -Close the specified MQTT object (if the connected server will be disconnected automatically)
797 +**Parameters: **//Obj //ithe objeced returned by mqtt.create
802 802  
803 -**Parameters:**
804 -
805 -//Obj //is the objeced returned by mqtt.create
806 -
807 807  **Return:**
808 808  
809 809  Succeed: true
... ... @@ -811,32 +811,25 @@
811 811  Failed: multi
812 812  
813 813  (((
814 -== **4.3 mqtt:connect(table conn[, table lwt, table cart])** ==
806 +== **mqtt:connect(table conn[, table lwt, table cart])** ==
815 815  )))
816 816  
817 -**Function:**
809 +**Function:**Establish a connection to the server
818 818  
819 -Establish a connection to the server
820 -
821 821  **Parameters:**
822 822  
823 823  //conn //is a Lua table and needs to contain the following fields
824 824  
825 -//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:
826 826  
827 -//string conn.password//, password
828 -
829 -//number [conn.netway=0]//, networking method, if set error number will use Ethernet method
830 -
831 -* 0: Ethernet
832 -* 1: WIFI
833 -* 2: 4G
834 -* 3: 2G
835 -
836 -//number [conn.keepalive=60]//, keep connected heartbeat interval, in seconds
837 -
838 -//number [conn.cleansession=1]//, empty the session as described below:
839 -
840 840  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:
841 841  
842 842  * 1 (Empty): If a session exists and is 1, the previous session messages on the client and server are emptied.
... ... @@ -844,14 +844,11 @@
844 844  
845 845  //lwt// (Last Will and Testament) is a Lua table and needs to contain the following fields
846 846  
847 -//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
848 848  
849 -//string lwt.message//, message
850 -
851 -//number [lwt.qos=0]//, qos value
852 -
853 -//number [lwt.retain=0]//, retain flag
854 -
855 855  **Return:**
856 856  
857 857  Succeed: true
... ... @@ -859,17 +859,13 @@
859 859  Failed: multi
860 860  
861 861  (((
862 -== **4.4 mqtt:disconnect([number timeout])** ==
844 +== **mqtt:disconnect([number timeout])** ==
863 863  )))
864 864  
865 -**Function:**
847 +**Function:** Disconnect from the MQTT server
866 866  
867 -Disconnect from the MQTT server
849 +**Parameters: **//[timeout=10000] //Disconnect waiting timeout, in milliseconds
868 868  
869 -**Parameters:**
870 -
871 -//[timeout=10000] //Disconnect waiting timeout, in milliseconds
872 -
873 873  **Return:**
874 874  
875 875  Succeed: true
... ... @@ -877,17 +877,13 @@
877 877  Failed: multi
878 878  
879 879  (((
880 -== **4.5 mqtt:isconnected()** ==
858 +== **mqtt:isconnected()** ==
881 881  )))
882 882  
883 -**Function:**
861 +**Function:** Test whether or not a client is currently connected to the MQTT server
884 884  
885 -Test whether or not a client is currently connected to the MQTT server
863 +**Parameters:** None
886 886  
887 -**Parameters:**
888 -
889 -None
890 -
891 891  **Return:**
892 892  
893 893  Succeed: true ~-~-Connected
... ... @@ -895,13 +895,11 @@
895 895  Failed: false ~-~- Unconnected and other unknowns
896 896  
897 897  (((
898 -== **4.6 mqtt:subscribe(string topic, number qos)** ==
872 +== **mqtt:subscribe(string topic, number qos)** ==
899 899  )))
900 900  
901 -**Function:**
875 +**Function: **Subscribe to the topic (before the subscription, the user must first call the connect method to connect to the server)
902 902  
903 -Subscribe to the topic (before the subscription, the user must first call the connect method to connect to the server)
904 -
905 905  **Parameters:**
906 906  
907 907  //topic//, topic name
... ... @@ -915,13 +915,11 @@
915 915  Failed: multi
916 916  
917 917  (((
918 -== **4.7 mqtt:unsubscribe(string topic)** ==
890 +== **mqtt:unsubscribe(string topic)** ==
919 919  )))
920 920  
921 -**Function:**
893 +**Function:** Unsubscribe topic
922 922  
923 -Unsubscribe topic
924 -
925 925  **Parameters:**
926 926  
927 927  //topic//, topic name
... ... @@ -933,13 +933,11 @@
933 933  Failed: multi
934 934  
935 935  (((
936 -== **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])** ==
937 937  )))
938 938  
939 -**Function:**
909 +**Function:** Publish message
940 940  
941 -Publish message
942 -
943 943  **Parameters:**
944 944  
945 945  //topic//, topic name
... ... @@ -959,17 +959,13 @@
959 959  Failed: multi
960 960  
961 961  (((
962 -== **4.9 mqtt:close()** ==
930 +== **mqtt:close()** ==
963 963  )))
964 964  
965 -**Function:**
933 +**Function:** Close the mqtt object (the connection to the server will be automatically disconnected)
966 966  
967 -Close the mqtt object (the connection to the server will be automatically disconnected)
935 +**Parameters:** None
968 968  
969 -**Parameters:**
970 -
971 -None
972 -
973 973  **Return:**
974 974  
975 975  Succeed: true
... ... @@ -977,13 +977,11 @@
977 977  Failed: multi
978 978  
979 979  (((
980 -== **4.10 mqtt:on(string method, function callback)** ==
944 +== **mqtt:on(string method, function callback)** ==
981 981  )))
982 982  
983 -**Function:**
947 +**Function:** Register event callback function
984 984  
985 -Register event callback function
986 -
987 987  **Parameters:**
988 988  
989 989  //method//, It can be message/arrived/offline, these 3 types of events