Changes for page 2 Script

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

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

Summary

Details

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