Changes for page 2 Script

Last modified by Devin Chen on 2025/06/06 14:03

From version 11.1
edited by Jim(Forgotten)
on 2022/07/09 17:01
Change comment: There is no comment for this version
To version 5.1
edited by Hunter
on 2022/07/08 14:11
Change comment: There is no comment for this version

Summary

Details

Page properties
Author
... ... @@ -1,1 +1,1 @@
1 -XWiki.Jim
1 +XWiki.Hunter
Content
... ... @@ -256,7 +256,7 @@
256 256   sv=addr_getshort("@SV Silicone")/10,
257 257   pv=addr_getshort("@PV Silicone")/10,
258 258   product1=addr_getshort("@Product 1")/10,
259 -
259 +
260 260   product2=addr_getshort("@Product 2")/10,
261 261   product3=addr_getshort("@Product 3")/10,
262 262   product4=addr_getshort("@Product 4")/10,
... ... @@ -263,7 +263,7 @@
263 263   ice1=addr_getshort("@Ice condenser 1")/10,
264 264   ice2=addr_getshort("@Ice condenser 2")/10,
265 265   vacuum=addr_getfloat("@Vacuum")
266 -
266 +
267 267   }
268 268   local jsAlarm = { HPC = addr_getbit("@B_25395#W0.00"),
269 269   ODPC = addr_getbit("@B_25395#W0.01"),
... ... @@ -279,7 +279,7 @@
279 279   FSE=addr_getbit("@B_25395#W2.04"),
280 280   AVVSVV=addr_getbit("@B_25395#W1.12"),
281 281   ICHT=addr_getbit("@B_25395#W3.06")
282 -
282 +
283 283   }
284 284  \\ ~-~- ("@B_25395#CIO1.02")
285 285   mq.m:publish("mqtt-v-box-epsilon-fd300", json.encode(js) , 0, 0)
... ... @@ -702,363 +702,4 @@
702 702  
703 703  == **2.5 V-Box connect with AWS platform** ==
704 704  
705 -=== **Log in AWS** ===
706 -
707 -Login aws account and click“Connect an IoT device”
708 -
709 -[[image:image-20220709165402-1.png]]
710 -
711 -[[image:image-20220709165402-2.png]]
712 -
713 -
714 -=== **Create policy** ===
715 -
716 -Click “Secure”~-~-->“Policies”~-~-->“Create policy”~-~-->Click “Create”
717 -
718 -[[image:image-20220709165402-3.png]]
719 -
720 -Name the policy~-~-->Click “JSON”~-~-->Copy the following content~-~-->Click “Create”
721 -
722 -[[image:image-20220709165402-5.png]]
723 -
724 -[[image:image-20220709165402-4.png]]
725 -
726 -{{code language="LUA"}}
727 -{
728 -
729 -  "Version": "2012-10-17",
730 -
731 -  "Statement": [
732 -
733 -    {
734 -
735 -      "Effect": "Allow",
736 -
737 -      "Action": [
738 -
739 -        "iot:Connect",
740 -
741 -        "iot:Publish",
742 -
743 -        "iot:Subscribe",
744 -
745 -        "iot:Receive",
746 -
747 -        "greengrass:Discover"
748 -
749 -      ],
750 -
751 -      "Resource": "*"
752 -
753 -    }
754 -
755 -  ]
756 -
757 -}
758 -{{/code}}
759 -
760 -1. **Create things**
761 -
762 -Click “Manage”~-~-->“Things”~-~-->“Create things”~-~-->“Create single thing”
763 -
764 -
765 -|
766 -| |[[image:image-20220709165402-6.png]]
767 -
768 -
769 -|
770 -| |[[image:image-20220709165402-7.png]]
771 -
772 -|
773 -| |[[image:image-20220709165402-8.png]]
774 -
775 -Name the thing~-~-->Click “Next”
776 -
777 -
778 -Select the way to create certificate
779 -
780 -
781 -|
782 -| |[[image:image-20220709165402-9.png]]
783 -
784 -Select policy
785 -
786 -
787 -|
788 -| |[[image:image-20220709165402-10.png]]
789 -
790 -
791 -
792 -
793 -
794 -
795 -
796 -
797 -
798 -
799 -|
800 -| |[[image:image-20220709165402-11.png]]
801 -
802 -
803 -
804 -
805 -
806 -
807 -
808 -1. **Test with MQTT.fx tool**
809 -
810 -Click “View Setting” to get the “Broker Adress”
811 -
812 -
813 -|
814 -| |[[image:image-20220709165402-12.png]]
815 -
816 -|
817 -| |[[image:image-20220709165402-13.png]]
818 -
819 -
820 -
821 -
822 -
823 -
824 -
825 -
826 -
827 -|
828 -| |[[image:image-20220709165402-14.png]]
829 -
830 -Create one connection in MQTT.fx tool, set broker port as 8883.
831 -
832 -Upload the CA File, Client Certificate File, Client Key File
833 -
834 -
835 -|
836 -| |[[image:image-20220709165402-15.png]]
837 -
838 -
839 -
840 -Publish message to topic “TEST”
841 -
842 -
843 -|
844 -| |[[image:image-20220709165402-16.png]]
845 -
846 -|
847 -| |[[image:image-20220709165402-17.png]]
848 -
849 -Click”Test”~-~-->”MQTT test client”~-~-->”Subscrible to a topic”, to get message publish from MQTT.fx tool.
850 -
851 -And we can also send message form AWS platform to MQTT.fx tool.
852 -
853 -
854 -|
855 -| |[[image:image-20220709165402-18.png]]
856 -
857 -
858 -
859 -1. **Configurate in CloudTool**
860 -
861 -Copy the same setting in MQTT.fx to MQTT configuration
862 -
863 -
864 -|
865 -| |[[image:image-20220709165402-19.png]]
866 -
867 - Add a lua script and copy the lua demo into it.
868 -
869 -
870 -|
871 -| |[[image:image-20220709165402-20.png]]
872 -
873 -
874 -
875 -
876 -sprint = print
877 -
878 -~-~-Cloud mode interface to obtain the MQTT information configured by the cloud platform: (5 returns, namely the server address, client ID, connection table, last word table, certificate table)
879 -
880 -local MQTT_URL, MQTT_CLIENTID, MQTT_CFG, MQTT_LWT, MQTT_CART = mqtt.setup_cfg()
881 -
882 -~-~-publish to topics
883 -
884 -local pub_RE_TOPIC = string.format('TEST')
885 -
886 -~-~-Subscribe topics
887 -
888 -local Subscribe_RE_TOPIC1 = string.format('TEST')
889 -
890 -~-~-variable
891 -
892 -local last_time = 0
893 -
894 -~-~-Timing main function
895 -
896 -function aws.main()
897 -
898 - sprint(os.date("%Y-%m-%d %H:%M %S", os.time()) .. " aws.main start")
899 -
900 - if g_mq then
901 -
902 - if g_mq:isconnected() then
903 -
904 - send_Data()
905 -
906 - else
907 -
908 - if os.time() - last_time > 5 then
909 -
910 - last_time = os.time()
911 -
912 - mymqtt_connect()
913 -
914 - end
915 -
916 - end
917 -
918 - else
919 -
920 - mymqtt_init()
921 -
922 - end
923 -
924 - sprint(os.date("%Y-%m-%d %H:%M %S", os.time()) .. " aws.main end")
925 -
926 -end
927 -
928 -
929 -~-~- Initialize MQTT
930 -
931 -function mymqtt_init()
932 -
933 - sprint(string.format("mqtt init mqtt_url:%s mqtt_clientid:%s", MQTT_URL, MQTT_CLIENTID))
934 -
935 - g_mq, err = mqtt.create(MQTT_URL, MQTT_CLIENTID) ~-~- Create the object and declare it as a global variable
936 -
937 - if g_mq then
938 -
939 - g_mq:on("message", mymqtt_msg_callback) ~-~- Register to receive message callbacks
940 -
941 - sprint("mqtt init success")
942 -
943 - else
944 -
945 - sprint("mqtt init failed:", err)
946 -
947 - end
948 -
949 -end
950 -
951 -~-~- Connect to MQTT server
952 -
953 -function mymqtt_connect()
954 -
955 - sprint("mqtt connecting...")
956 -
957 - local stat, err = g_mq:connect(MQTT_CFG,MQTT_LWT, MQTT_CART)
958 -
959 - if stat == nil then
960 -
961 - sprint("mqtt connect failed:", err)
962 -
963 - return
964 -
965 - else
966 -
967 - sprint("mqtt connected")
968 -
969 - end
970 -
971 - g_mq:subscribe(TEST, 0)
972 -
973 -end
974 -
975 -~-~- Receive MQTT message callback function
976 -
977 -function mymqtt_msg_callback(topic, msg)
978 -
979 - print("topic:",topic)
980 -
981 - print("revdata:",msg)
982 -
983 - local revData = json.decode(msg)
984 -
985 - print (revData)
986 -
987 - if topic == Subscribe_RE_TOPIC1 then ~-~-Process topic information subscribed from the cloud
988 -
989 -if string.match(topic,Subscribe_RE_TOPIC1) then
990 -
991 - ~-~-if revData ~~= nil then
992 -
993 - for k,v in pairs (revData) do
994 -
995 - print("printing revdata after kv here")
996 -
997 - print (k,v)
998 -
999 - end
1000 -
1001 - print ("current state is",fanstate)
1002 -
1003 - ~-~-end
1004 -
1005 -end
1006 -
1007 -end
1008 -
1009 -end
1010 -
1011 -
1012 -~-~-Get real-time data
1013 -
1014 -function getData()
1015 -
1016 - local jdata = {}
1017 -
1018 - local addr = bns_get_alldata()
1019 -
1020 - print(json.encode(addr))
1021 -
1022 - for i,v in pairs(addr) do
1023 -
1024 - if v[2] == 1 then
1025 -
1026 - jdata[v[3]] = v[4]
1027 -
1028 - end
1029 -
1030 - end
1031 -
1032 - return jdata
1033 -
1034 -end
1035 -
1036 -~-~-send data
1037 -
1038 -function send_Data()
1039 -
1040 - local pub_data =
1041 -
1042 - {
1043 -
1044 -123
1045 -
1046 -}
1047 -
1048 -sprint(json.encode(pub_data))
1049 -
1050 -print("..........",pub_RE_TOPIC)
1051 -
1052 - return g_mq:publish(pub_RE_TOPIC, json.encode(pub_data), 0, 0)
1053 -
1054 -end
1055 -
1056 -
1057 -
1058 -Get message in AWS
1059 -
1060 -
1061 -|
1062 -| |[[image:image-20220709165402-21.png]]
1063 -
1064 -
705 +[[https:~~/~~/ftp.we-con.com.cn/Download/WIKI/V-BOX/Demo/AWS/AWS.zip>>https://ftp.we-con.com.cn/Download/WIKI/V-BOX/Demo/AWS/AWS.zip]]
image-20220709165226-1.png
Author
... ... @@ -1,1 +1,0 @@
1 -XWiki.Jim
Size
... ... @@ -1,1 +1,0 @@
1 -1.2 MB
Content
image-20220709165402-1.png
Author
... ... @@ -1,1 +1,0 @@
1 -XWiki.Jim
Size
... ... @@ -1,1 +1,0 @@
1 -200.2 KB
Content
image-20220709165402-10.png
Author
... ... @@ -1,1 +1,0 @@
1 -XWiki.Jim
Size
... ... @@ -1,1 +1,0 @@
1 -19.0 KB
Content
image-20220709165402-11.png
Author
... ... @@ -1,1 +1,0 @@
1 -XWiki.Jim
Size
... ... @@ -1,1 +1,0 @@
1 -105.9 KB
Content
image-20220709165402-12.png
Author
... ... @@ -1,1 +1,0 @@
1 -XWiki.Jim
Size
... ... @@ -1,1 +1,0 @@
1 -29.0 KB
Content
image-20220709165402-13.png
Author
... ... @@ -1,1 +1,0 @@
1 -XWiki.Jim
Size
... ... @@ -1,1 +1,0 @@
1 -158.8 KB
Content
image-20220709165402-14.png
Author
... ... @@ -1,1 +1,0 @@
1 -XWiki.Jim
Size
... ... @@ -1,1 +1,0 @@
1 -48.1 KB
Content
image-20220709165402-15.png
Author
... ... @@ -1,1 +1,0 @@
1 -XWiki.Jim
Size
... ... @@ -1,1 +1,0 @@
1 -46.9 KB
Content
image-20220709165402-16.png
Author
... ... @@ -1,1 +1,0 @@
1 -XWiki.Jim
Size
... ... @@ -1,1 +1,0 @@
1 -140.7 KB
Content
image-20220709165402-17.png
Author
... ... @@ -1,1 +1,0 @@
1 -XWiki.Jim
Size
... ... @@ -1,1 +1,0 @@
1 -12.5 KB
Content
image-20220709165402-18.png
Author
... ... @@ -1,1 +1,0 @@
1 -XWiki.Jim
Size
... ... @@ -1,1 +1,0 @@
1 -32.2 KB
Content
image-20220709165402-19.png
Author
... ... @@ -1,1 +1,0 @@
1 -XWiki.Jim
Size
... ... @@ -1,1 +1,0 @@
1 -66.6 KB
Content
image-20220709165402-2.png
Author
... ... @@ -1,1 +1,0 @@
1 -XWiki.Jim
Size
... ... @@ -1,1 +1,0 @@
1 -188.5 KB
Content
image-20220709165402-20.png
Author
... ... @@ -1,1 +1,0 @@
1 -XWiki.Jim
Size
... ... @@ -1,1 +1,0 @@
1 -33.3 KB
Content
image-20220709165402-21.png
Author
... ... @@ -1,1 +1,0 @@
1 -XWiki.Jim
Size
... ... @@ -1,1 +1,0 @@
1 -124.8 KB
Content
image-20220709165402-3.png
Author
... ... @@ -1,1 +1,0 @@
1 -XWiki.Jim
Size
... ... @@ -1,1 +1,0 @@
1 -103.9 KB
Content
image-20220709165402-4.png
Author
... ... @@ -1,1 +1,0 @@
1 -XWiki.Jim
Size
... ... @@ -1,1 +1,0 @@
1 -4.0 KB
Content
image-20220709165402-5.png
Author
... ... @@ -1,1 +1,0 @@
1 -XWiki.Jim
Size
... ... @@ -1,1 +1,0 @@
1 -66.5 KB
Content
image-20220709165402-6.png
Author
... ... @@ -1,1 +1,0 @@
1 -XWiki.Jim
Size
... ... @@ -1,1 +1,0 @@
1 -110.0 KB
Content
image-20220709165402-7.png
Author
... ... @@ -1,1 +1,0 @@
1 -XWiki.Jim
Size
... ... @@ -1,1 +1,0 @@
1 -25.4 KB
Content
image-20220709165402-8.png
Author
... ... @@ -1,1 +1,0 @@
1 -XWiki.Jim
Size
... ... @@ -1,1 +1,0 @@
1 -64.2 KB
Content
image-20220709165402-9.png
Author
... ... @@ -1,1 +1,0 @@
1 -XWiki.Jim
Size
... ... @@ -1,1 +1,0 @@
1 -37.5 KB
Content