Changes for page 2 Script

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

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