|
|
Line 1: |
Line 1: |
− | = IoT Data Ingestion = | + | = = |
− | | |
− | Prerequisites:
| |
− | | |
− | *AWS account
| |
− | *this example use service which is region in US East (N. Virginia).
| |
− | | |
− | ==== Cloud Environment Setups ====
| |
− | | |
− | Step 1.Return the AWS console and go to IAM menu.
| |
− | | |
− | [[File:IAM1.png|center|1000px|IAM1.png]]
| |
− | | |
− | Step 2.Click “user” menu
| |
− | | |
− | [[File:IAM2.png|center|1000px|IAM2.png]]
| |
− | | |
− | | |
− | | |
− |
| |
− | | |
− | Step 3.Click “Add user” button
| |
− | | |
− | [[File:IAM3.png|center|1000px|IAM3.png]]
| |
− | | |
− | Step 4.Enter your user name. In this example user name is “Adv_test”.→ chose Programmatic access → Click “Next Permissions” button.
| |
− | | |
− | [[File:IAM4.png|center|1000px|IAM4png]]
| |
− | | |
− | Step 5.Click [[File:IAM GP.png|IAM_GP.png]]
| |
− | | |
− | [[File:IAM5.png|center|1000px|IAM.png]]
| |
− | | |
− | Step 6.Choose AdministratorAccess → Click “Next: Review” button
| |
− | | |
− | [[File:IAM6.png|center|1000px|IAM6.png]]
| |
− | | |
− | Step 7.Click “Create user”
| |
− | | |
− | [[File:IAM7.png|center|1000px|IAM7.png]]
| |
− | | |
− | Step 8.Download the credentials. This is the last time these credentials will be available to download.
| |
− | | |
− | Step 9.Click “Download .csv” button
| |
− | | |
− | [[File:IAM8.png|center|1000px|IAM8.png]]
| |
− | | |
− | ==== Device Environment Setups ====
| |
− | | |
− | In this section, you will install Advantech Node-Red tool for and Configurate the setting to connect AWS IoT
| |
− | | |
− | | |
− | | |
− | * click on desktop to open NodeRED in web browser
| |
− | | |
− | [[File:8.png|center|1000px|8.png]]
| |
− | | |
− | Set up edge device environment
| |
− | | |
− | *Copy following NodeRED flow and import it into NodeRED:
| |
− | <pre>
| |
− | [{"id":"d652f017.65e74","type":"tab","label":"Protocol Connector ","disabled":false,"info":""},
| |
− | {"id":"bec4e2f6.b7b83","type":"mqtt in","z":"d652f017.65e74","name":"Data Recieved","topic":"/cagent/admin/+/deviceinfo","qos":"2","broker":"22aa981b.46a50c","x":150,"y":132,"wires":[["5651a33f.5722bc","cd4723c3.e1624"]]},{"id":"cd4723c3.e1624","type":"debug","z":"d652f017.65e74","name":"","active":true,"console":"false","complete":"payload","x":340,"y":112,"wires":[]},
| |
− | {"id":"f7640bf7.c78ab8","type":"comment","z":"d652f017.65e74","name":"Send Protocol Connector Sensor Data to AWS IoT","info":"","x":260,"y":69.36331176757812,"wires":[]},
| |
− | {"id":"f6c0c463.1d1928","type":"comment","z":"d652f017.65e74","name":"Send Auto-Report Request to Internal MQTT","info":"","x":220,"y":296,"wires":[]},
| |
− | {"id":"5651a33f.5722bc","type":"function","z":"d652f017.65e74","name":"messgae topic","func":"var device_id = 'DK10';\nvar plugin_id = msg.topic.replace(/^\\/cagent\\/admin\\/|\\/deviceinfo$/g, \"\");\nmsg.topic = 'protocol-conn/' + device_id + '/' + plugin_id;\nreturn msg;","outputs":1,"noerr":0,"x":350,"y":157.10000610351562,"wires":[["bb0580c5.75a24"]]},{"id":"b74f9d97.3e912","type":"mqtt out","z":"d652f017.65e74","name":"Auto-Report Request","topic":"","qos":"0","retain":"false","broker":"22aa981b.46a50c","x":692.0001220703125,"y":401,"wires":[]},
| |
− | {"id":"828deeb3.bd324","type":"mqtt in","z":"d652f017.65e74","name":"Handler Registered","topic":"/cagent/admin/+/agentinfoack","qos":"2","broker":"22aa981b.46a50c","x":160,"y":364.8398742675781,"wires":[["8e87ec7b.6487b"]]},
| |
− | {"id":"8e87ec7b.6487b","type":"function","z":"d652f017.65e74","name":"pakcage auto report command","func":"var auto_rpt_msg = function(device) {\n return {\n topic: \"/cagent/admin/\" + device + \"/agentcallbackreq\",\n payload: {\n \"susiCommData\": {\n \"commCmd\": 2053,\n \"requestItems\": {\"All\":{}},\n \"autoUploadIntervalSec\": 10,\n \"handlerName\": \"general\"\n }\n }\n };\n};\n\nvar registered = context.get(\"registered\") || [];\nvar dev_id = msg.topic.replace(/^\\/cagent\\/admin\\/|\\/agentinfoack$|\\/notify$/g, \"\");\nvar is_reg_msg = (\n msg.topic.endsWith(\"agentinfoack\") && JSON.parse(msg.payload).susiCommData.status\n);\nvar msg_out = (is_reg_msg || (!~registered.indexOf(dev_id)))? auto_rpt_msg(dev_id) : null;\n\nif(!~registered.indexOf(dev_id)) {\n registered.push(dev_id);\n}\n\ncontext.set(\"registered\", registered);\nreturn msg_out;\n","outputs":1,"noerr":0,"x":418.0195617675781,"y":401.00390625,"wires":[["b74f9d97.3e912"]]},{"id":"b06132d0.4baf6","type":"mqtt in","z":"d652f017.65e74","name":"Handler Heartbeat","topic":"/cagent/admin/+/notify","qos":"2","broker":"22aa981b.46a50c","x":157,"y":438,"wires":[["8e87ec7b.6487b"]]},
| |
− | {"id":"bb0580c5.75a24","type":"AWS IotData","z":"d652f017.65e74","aws":"20e9a430.34135","operation":"Publish","thingName":"","topic":"","payload":"","endPoint":"","name":"","x":535,"y":156.75,"wires":[[]]},{"id":"22aa981b.46a50c","type":"mqtt-broker","z":"","broker":"127.0.0.1","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"willTopic":"","willQos":"0","willPayload":"","birthTopic":"","birthQos":"0","birthPayload":""},
| |
− | {"id":"20e9a430.34135","type":"amazon config","z":"","name":"AWS","region":"us-east-1"}]
| |
− | </pre>
| |
− | | |
− | *Switch to Protocol Connector tab and double click “IotData Publish” node to set device configuration.
| |
− | | |
− | *Click [[File:Button NR.png|button_NR.png]] button[[File:2018-02-13 145112.png|center|2018-02-13_145112.png]]
| |
− | | |
− | | |
− | | |
− |
| |
− | | |
− | *Enter the Access Id and Secret Key which is on credentials .csv file.
| |
− | | |
− | [[File:11.png|center|11.png]]
| |
− | | |
− | *Enter the Name “IoT Pubilsh” and Endpoint
| |
− | | |
− | [[File:2018-02-13 144939.png|center|2018-02-13_144939.png]]
| |
− | | |
− | | |
− | | |
− |
| |
− | | |
− |
| |
− | | |
− | *You can find endpoint in AWS IoT console.
| |
− | | |
− | [[File:13.png|center|1000px|13.png]]
| |
− | | |
− | *Check your message topic on the "message topic' function node[[File:15-2.png|center|1000px|15-2.png]]
| |
− | | |
− | *Enter {your devie id} in device_id, you can choose {your device id} which you want.
| |
− | <pre>[[File:2018-02-13 152702.png|center|2018-02-13_152702.png]]
| |
− | </pre>
| |
− | | |
− | *Click [[File:Deploy.png|deploy.png]] to finish edge device environment setups.
| |
− | | |
− | [[File:17-2.png|center|1000px|17-2.png]]
| |
− | | |
− | *Click NodeRED “Debug” tab, the sent messages will be displayed.
| |
− | | |
− | [[File:18-2.png|center|1000px|18-2.png]]
| |
− | | |
− | *Go back to AWS IoT menu
| |
− | *click “Test” and enter Subscription topic click [[File:Subscription.png|Subscription.png]]
| |
− | *For more information, see <references /><references /><references />[https://docs.aws.amazon.com/iot/latest/developerguide/topics.html https://docs.aws.amazon.com/iot/latest/developerguide/topics.html]
| |
− | | |
− | [[File:2018-02-13 152730.png|center|1000px|2018-02-13_152730.png]]
| |
− | | |
− | | |
− | | |
− | *if your settings is correct, then you can see the message in this area.
| |
− | | |
− | [[File:2018-02-13 152741.png|center|1000px|2018-02-13_152741.png]]
| |
| | | |
| | | |
| | | |
| | | |