Difference between revisions of "EdgeSense"

From ESS-WIKI
Jump to: navigation, search
 
(37 intermediate revisions by 5 users not shown)
Line 59: Line 59:
 
# Follow the readme to install your converter protocol</pre>
 
# Follow the readme to install your converter protocol</pre>
  
=== How to modify&nbsp;EnSaaS&nbsp;ID/Password and resart ===
+
=== How To modify&nbsp;EnSaaS&nbsp;ID/Password and resart ===
 
<pre># To fill your "IoTKey" then save and exit  
 
<pre># To fill your "IoTKey" then save and exit  
 
  <IoTKey>304a99b5b452444c749a83bbb9e35dpow</IoTKey>
 
  <IoTKey>304a99b5b452444c749a83bbb9e35dpow</IoTKey>
Line 65: Line 65:
 
$sudo vim agent_config.xml
 
$sudo vim agent_config.xml
 
$sudo docker restart ensaas-ei-agent</pre>
 
$sudo docker restart ensaas-ei-agent</pre>
 +
 +
=== How To config Modbus and resart service ===
 +
<pre>$cd {Installed path}/Installer/packages/Plugins/docker-edgesense-image-x86/EdgeSense/EService-Modbus/config/
 +
$sudo vim Modbus_Handler.ini
 +
$sudo docker restart service-modbus</pre>
 +
 +
=== How To Restart Service ===
 +
<pre>// MQTT-BUS
 +
$sudo docker restart advigw-mqtt-bus
 +
 +
// Node-RED
 +
$sudo docker restart advigw-node-red
 +
 +
// Modbus_Handler Service
 +
$sudo docker restart service-modbus
 +
 +
// HDD PMQ
 +
$sudo docker restart service-hddpmq
 +
 +
// SUSIControl
 +
$sudo docker restart service-susi</pre>
 +
 +
=== How To Uninstall Edgent Sense Docker&nbsp;Image ===
 +
<pre>$cd {Installed path}/Installer/packages/Plugins/docker-edgesense-image-x86/
 +
$sudo ./deploy.sh rmi</pre>
  
 
= Cloud =
 
= Cloud =
Line 108: Line 133:
 
[[File:Create hub 1.png|center|750px|create-hub.png]]
 
[[File:Create hub 1.png|center|750px|create-hub.png]]
  
*Input IoT hub name: '''protocol-conn-hub''' (for example)
+
*Select Resource group created at step 2: click “'''Use existing'''” and select “'''protocol-conn-rg'''”
 +
 
 +
*Select Region: '''East Asia'''
 +
 
 +
*Input IoT hub name: '''protocol-con-hub''' (for example)
  
*Select pricing and scale tier: here we chose “'''S1 - Standard'''
+
*Click on '''Review+Create'''
  
*Select Resource group created at step 2: click “'''Use existing'''” and select “'''protocol-conn-rg'''
+
[[File:Iot hub.png|center|800px|iot_hub.png]]
 +
 
 +
*Click on '''Create'''
  
[[File:Create-hub-detail.png|center|300px|create-hub-detail.png]]
+
[[File:Iot hub2.png|center|800px|iot_hub2.png]]
  
 
=== Connect device and data to Azure for Windows device – Protocol Converter Using Node-RED ===
 
=== Connect device and data to Azure for Windows device – Protocol Converter Using Node-RED ===
Line 122: Line 153:
 
Following steps will create an azure iot device to connect to iot hub created at [[#Create_Azure_IoT_Hub|previous section]].
 
Following steps will create an azure iot device to connect to iot hub created at [[#Create_Azure_IoT_Hub|previous section]].
  
Step 1. Go to iot hub created at previous section: Resource groups → protocol-conn-rg → protocol-conn-hub
+
Step 1. Go to iot hub created at previous section: Resource groups → protocol-conn-rg → Overview → protocol-con-rg (for example)
  
[[File:Select-conn-hub.png|center|750px|select conn hub]]
+
[[File:Iot device0.png|center|750px|iot_device0]]
  
 
Step 2. IoT Devices → Add
 
Step 2. IoT Devices → Add
Line 137: Line 168:
  
 
*Connect device to IoT Hub: select “Enable”
 
*Connect device to IoT Hub: select “Enable”
 +
*Save the configurations
  
[[File:Create-conn-iot-device-details.png|center|300px|iot device details]]
+
[[File:Add device.png|center|300px|add_device]]
  
 
*Select the created iot device to get device connection string
 
*Select the created iot device to get device connection string
  
[[File:Select-iot-device.png|center|700px|select iot device]]
+
[[File:Iot device.png|center|700px|iot_device]]
  
 
*Click [[File:Save icon.png|20px|save-icon.png]] to copy “Connection string-primary key” and make sure the "Connect device to IoT Hub" is "'''Enable'''"
 
*Click [[File:Save icon.png|20px|save-icon.png]] to copy “Connection string-primary key” and make sure the "Connect device to IoT Hub" is "'''Enable'''"
Line 148: Line 180:
 
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span style="color:#FFA07A;">"Connection string-primary key" will be used later in Node-Red "Connection String" field.</span>
 
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span style="color:#FFA07A;">"Connection string-primary key" will be used later in Node-Red "Connection String" field.</span>
  
[[File:Select-iot-device-conn-str.png|center|700px|copy device conn string.png]]
+
[[File:Iot device2.png|center|700px|iot_device2]]
  
 
*Save the connection string in a text file for later use
 
*Save the connection string in a text file for later use
Line 158: Line 190:
 
Following steps will configure device Node-RED nodes to enable communications between Advantech protocol converter modules and azure iot hub.
 
Following steps will configure device Node-RED nodes to enable communications between Advantech protocol converter modules and azure iot hub.
  
Step 1. Open Node-RED page in the web browser (default URI is [http://127.0.0.1:1880 http://127.0.0.1:1880])
+
Step 1. Open Node-RED page in the web browser (default URI is '''[http://127.0.0.1:1880 http://127.0.0.1:1880]''')
  
 
[[File:Nr-main.png|center|750px|nr main]]
 
[[File:Nr-main.png|center|750px|nr main]]
Line 192: Line 224:
 
Step 5. Click [[File:Deploy-icon.png|100px|deploy icon]] to complete edge device environment setups and make sure the states of MQTT nodes are "connected"[[File:Deploy-nr-protocol2.png|center|750px|nr deployed]]
 
Step 5. Click [[File:Deploy-icon.png|100px|deploy icon]] to complete edge device environment setups and make sure the states of MQTT nodes are "connected"[[File:Deploy-nr-protocol2.png|center|750px|nr deployed]]
  
Next, jump to [[#Monitor Messages]] for further steps.
+
Step 6. Jump to&nbsp;'''[[#Monitor_Messages|Monitor Messages]]''' for further steps.
  
 
=== Connect device and data to Azure for Linux Ubuntu device – Protocol Converter Using IoT Edge ===
 
=== Connect device and data to Azure for Linux Ubuntu device – Protocol Converter Using IoT Edge ===
Line 238: Line 270:
  
 
1. Install IoT Edge control script (may need to run as root)
 
1. Install IoT Edge control script (may need to run as root)
<pre>        pip install -U azure-iot-edge-runtime-ctl</pre>
+
<pre>        pip install -U azure-iot-edge-runtime-ctl==1.0.0rc17</pre>
  
 
2. Make sure the “iotedgectl” command is available. (the version number may be different)
 
2. Make sure the “iotedgectl” command is available. (the version number may be different)
Line 287: Line 319:
  
 
*Open a command prompt and type following command. Replace "{your iot edge device connection string}" with the saved device connection string
 
*Open a command prompt and type following command. Replace "{your iot edge device connection string}" with the saved device connection string
<pre>        iotedgectl setup --connection-string "{your iot edge device connection string}" --auto-cert-gen-force-no-passwords</pre>
+
<pre>        sudo iotedgectl setup --connection-string "{your iot edge device connection string}" --auto-cert-gen-force-no-passwords</pre>
<!--
+
 
[[File:Edge-ctl-setup-win.png|center|750px|iotedge-setup-win]]<br/>
 
-->
 
 
[[File:Edge-ctl-setup-linux.png|center|750px|iotedge-setup-linux]]
 
[[File:Edge-ctl-setup-linux.png|center|750px|iotedge-setup-linux]]
  
 
*Start the IoT Edge runtime
 
*Start the IoT Edge runtime
<pre>        iotedgectl start</pre>
+
<pre>        sudo iotedgectl start</pre>
<!--
+
 
[[File:Edge-ctl-start-win.png|center|750px|iotedge-start-win]]<br/>
 
-->
 
 
[[File:Edge-ctl-start-linux.png|center|750px|iotedge-start-linux]]
 
[[File:Edge-ctl-start-linux.png|center|750px|iotedge-start-linux]]
  
 
*Check Docker to see that the IoT Edge agent is running as a module
 
*Check Docker to see that the IoT Edge agent is running as a module
<pre>        docker ps</pre>
+
<pre>        sudo docker ps</pre>
<!--
 
[[File:Iotedge-docker-ps-win.png|center|750px|docker-ps-win]]<br/>
 
-->
 
[[File:Docker ps linux.png|center|750px|docker-ps-linux]]
 
  
 
=== Deploy an IoT edge device module to edge device ===
 
=== Deploy an IoT edge device module to edge device ===
Line 363: Line 387:
 
=== Monitor Messages ===
 
=== Monitor Messages ===
  
==== Device to Cloud (D2C) ====
+
==== .Device to Cloud (D2C) ====
  
 
*Get IoT Hub Connection String from below steps.
 
*Get IoT Hub Connection String from below steps.
Step 1. Go to iot hub created at "[[#Create_Azure_IoT_Hub|Create Azure IoT Hub]]" section: Resource groups → protocol-conn-rg → protocol-conn-hub
 
[[File:Select-conn-hub.png|center|750px|select conn hub]]
 
  
Step 2. Click [[File:Save icon.png|20px|save-icon.png]] to copy iot hub connection string: Shared access policies → iothubowner → Primary key
+
Step 1. Go to iot hub created at "[[#Create_Azure_IoT_Hub|Create Azure IoT Hub]]" section: Resource groups → protocol-conn-rg → protocol-conn-hub [[File:Select-conn-hub.png|center|750px|select conn hub]]
[[File:Hub-conn-str.png|center|750px|copy hub conn string]]
+
 
 +
Step 2. Click [[File:Save icon.png|20px|save-icon.png]] to copy iot hub connection string: Resource groups → Shared access policies → iothubowner →&nbsp;Connection String​[[File:Share access policy.png|center|750px|Share_access_policy]]
  
*use [https://github.com/azure/iothub-explorer iothub-explorer] tool (require nodejs and npm) to monitor D2C messages.
+
*Use [https://github.com/azure/iothub-explorer iothub-explorer] tool (require nodejs and npm) to monitor D2C messages.
 
<pre>        npm install -g iothub-explorer
 
<pre>        npm install -g iothub-explorer
  
         iothub-explorer monitor-events iotedge-protocol-connector --login "{your iot hub connection string}"
+
         iothub-explorer monitor-events {Your IoT Device id} --login "{your iot hub connection string}"
 
</pre>
 
</pre>
  
Line 381: Line 404:
  
 
[[File:Iothub-explorer-linux.png|center|700px|iothub-explorer-linux]]
 
[[File:Iothub-explorer-linux.png|center|700px|iothub-explorer-linux]]
 +
 +
'''When Installing'''&nbsp;'''iothub-explorer on Windows system, please use administrator role to execute&nbsp;cmd. Otherwise,&nbsp;the environment variable cannot be correctly written to the system. You can add the&nbsp;environment variable&nbsp;manually.&nbsp;''' [[File:Iothub-explorer-win 1.png|center|700px|iothub-explorer-win_1]] [[File:Iothub-explorer-win 2.png|center|700px|iothub-explorer-win_2]]
  
 
==== Cloud to Device (C2D) ====
 
==== Cloud to Device (C2D) ====
Line 406: Line 431:
 
== AWS ==
 
== AWS ==
  
<h3> Connect device and data to AWS for Windows device – Protocol Converter using Node-Red </h3>
+
=== Connect device and data to AWS for Windows device – Protocol Converter using Node-Red ===
<p>Prerequisites:
+
 
</p>
+
Prerequisites:
<ul><li>AWS account
+
 
</li>
+
*AWS account
<li>this example use service which is region in US East (N. Virginia).
+
 
</li></ul><h4> Cloud Environment Setup </h4>
+
*this example use service which is region in US East (N. Virginia).
<p>Step 1.Return the AWS console and go to IAM menu.
+
 
</p><p><img src="/wiki/images/1/18/IAM1.png" _fck_mw_filename="IAM1.png" _fck_mw_location="center" width="1000" _fck_mw_origimgwidth="1280" _fck_mw_origimgheight="984" alt="IAM1.png" title="IAM1.png" class="fck_mw_center" style="vertical-align:middle;" />
+
==== Cloud Environment Setup ====
</p><p>Step 2.Click “user” menu
+
 
</p><p><img src="/wiki/images/2/2f/IAM2.png" _fck_mw_filename="IAM2.png" _fck_mw_location="center" width="1000" _fck_mw_origimgwidth="1280" _fck_mw_origimgheight="984" alt="IAM2.png" title="IAM2.png" class="fck_mw_center" style="vertical-align:middle;" />
+
Step 1.Return the AWS console and go to IAM menu. [[File:IAM1.png|center|1000px|IAM1.png]]
</p><p>
+
 
</p><p>&#160;
+
Step 2.Click “user” menu [[File:IAM2.png|center|1000px|IAM2.png]]
</p><p>Step 3.Click “Add user” button
+
 
</p><p><img src="/wiki/images/e/ee/IAM3.png" _fck_mw_filename="IAM3.png" _fck_mw_location="center" width="1000" _fck_mw_origimgwidth="1280" _fck_mw_origimgheight="984" alt="IAM3.png" title="IAM3.png" class="fck_mw_center" style="vertical-align:middle;" />
+
Step 3.Click “Add user” button [[File:IAM3.png|center|1000px|IAM3.png]]
</p><p>Step 4.Enter your user name. In this example user name is “Adv_test”.→ chose Programmatic access → Click “Next Permissions” button.
+
 
</p><p><img src="/wiki/images/4/46/IAM4.png" _fck_mw_filename="IAM4.png" _fck_mw_location="center" width="1000" _fck_mw_origimgwidth="1280" _fck_mw_origimgheight="984" alt="IAM4png" title="IAM4png" class="fck_mw_center" style="vertical-align:middle;" />
+
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]]
</p><p>Step 5.Click <img src="/wiki/images/8/80/IAM_GP.png" _fck_mw_filename="IAM GP.png" _fck_mw_origimgwidth="133" _fck_mw_origimgheight="149" alt="IAM_GP.png" title="IAM_GP.png" style="vertical-align:middle;" />
+
 
</p><p><img src="/wiki/images/2/24/IAM5.png" _fck_mw_filename="IAM5.png" _fck_mw_location="center" width="1000" _fck_mw_origimgwidth="1280" _fck_mw_origimgheight="984" alt="IAM.png" title="IAM.png" class="fck_mw_center" style="vertical-align:middle;" />
+
Step 5.Click [[File:IAM GP.png|IAM_GP.png]]
</p><p>Step 6.Choose AdministratorAccess → Click “Next: Review” button
+
 
</p><p><img src="/wiki/images/2/2a/IAM6.png" _fck_mw_filename="IAM6.png" _fck_mw_location="center" width="1000" _fck_mw_origimgwidth="1280" _fck_mw_origimgheight="984" alt="IAM6.png" title="IAM6.png" class="fck_mw_center" style="vertical-align:middle;" />
+
Step 6.Choose AdministratorAccess → Click “Next: Review” button [[File:IAM6.png|center|1000px|IAM6.png]]
</p><p>Step 7.Click “Create user”
+
 
</p><p><img src="/wiki/images/1/10/IAM7.png" _fck_mw_filename="IAM7.png" _fck_mw_location="center" width="1000" _fck_mw_origimgwidth="1280" _fck_mw_origimgheight="984" alt="IAM7.png" title="IAM7.png" class="fck_mw_center" style="vertical-align:middle;" />
+
Step 7.Click “Create user” [[File:IAM7.png|center|1000px|IAM7.png]]
</p><p>Step 8.Download the credentials. This is the last time these credentials will be available to download.
+
 
</p><p>Step 9.Click “Download .csv” button
+
Step 8.Download the credentials. This is the last time these credentials will be available to download.
</p><p><img src="/wiki/images/f/f0/IAM8.png" _fck_mw_filename="IAM8.png" _fck_mw_location="center" width="1000" _fck_mw_origimgwidth="1280" _fck_mw_origimgheight="984" alt="IAM8.png" title="IAM8.png" class="fck_mw_center" style="vertical-align:middle;" />
+
 
</p><p>Step 10. Go to AWS IoT Core.
+
Step 9.Click “Download .csv” button [[File:IAM8.png|center|1000px|IAM8.png]]
</p><p><img src="/wiki/images/f/f7/AWS_iot_core.png" _fck_mw_filename="AWS iot core.png" _fck_mw_location="center" width="1000" _fck_mw_origimgwidth="1294" _fck_mw_origimgheight="490" alt="AWS iot core.png" title="AWS iot core.png" class="fck_mw_center" style="vertical-align:middle;" />
+
 
</p><p>Step 11. Copy the endpoint from "Setting". <span style="color:#FF8C00;">The endpoint will be used in Node-Red setting later.</span>
+
Step 10. Go to AWS IoT Core. [[File:AWS iot core.png|center|1000px|AWS iot core.png]]
</p><p>Check if the region is N. Virginia before copying the endpint.
+
 
</p><p><img src="/wiki/images/4/4b/13_2.png" _fck_mw_filename="13 2.png" _fck_mw_location="center" width="1000" _fck_mw_origimgwidth="1280" _fck_mw_origimgheight="918" alt="13 2.png" title="13 2.png" class="fck_mw_center" style="vertical-align:middle;" />
+
Step 11. Copy the endpoint from "Setting". <span style="color:#FF8C00;">The endpoint will be used in Node-Red setting later.</span> Check if the region is N. Virginia before copying the endpint. [[File:13 2.png|center|1000px|13 2.png]]
</p>
+
 
<h4> Device Environment Setup </h4>
+
==== Device Environment Setup ====
<p>In this section, you will install Advantech Node-Red tool for and Configurate the setting to connect AWS IoT
+
 
</p><p>
+
In this section, you will install Advantech Node-Red tool for and Configurate the setting to connect AWS IoT
</p>
+
 
<ul><li>&#160;click on desktop to open NodeRED in web browser
+
*&nbsp;click on desktop to open NodeRED in web browser
</li></ul><p><img src="/wiki/images/6/60/8.png" _fck_mw_filename="8.png" _fck_mw_location="center" width="1000" _fck_mw_origimgwidth="1450" _fck_mw_origimgheight="832" alt="8.png" title="8.png" class="fck_mw_center" style="vertical-align:middle;" />
+
 
</p><p>Set up edge device environment
+
[[File:8.png|center|1000px|8.png]]
</p>
+
 
<ul><li>Copy following NodeRED flow and import it into NodeRED:
+
Set up edge device environment
</li></ul><pre> 
+
 
[{&quot;id&quot;:&quot;d652f017.65e74&quot;,&quot;type&quot;:&quot;tab&quot;,&quot;label&quot;:&quot;Protocol Connector &quot;,&quot;disabled&quot;:false,&quot;info&quot;:&quot;&quot;},
+
*Copy following NodeRED flow and import it into NodeRED:
{&quot;id&quot;:&quot;bec4e2f6.b7b83&quot;,&quot;type&quot;:&quot;mqtt in&quot;,&quot;z&quot;:&quot;d652f017.65e74&quot;,&quot;name&quot;:&quot;Data Recieved&quot;,&quot;topic&quot;:&quot;/cagent/admin/+/deviceinfo&quot;,&quot;qos&quot;:&quot;2&quot;,&quot;broker&quot;:&quot;22aa981b.46a50c&quot;,&quot;x&quot;:150,&quot;y&quot;:132,&quot;wires&quot;:[[&quot;5651a33f.5722bc&quot;,&quot;cd4723c3.e1624&quot;]]},{&quot;id&quot;:&quot;cd4723c3.e1624&quot;,&quot;type&quot;:&quot;debug&quot;,&quot;z&quot;:&quot;d652f017.65e74&quot;,&quot;name&quot;:&quot;&quot;,&quot;active&quot;:true,&quot;console&quot;:&quot;false&quot;,&quot;complete&quot;:&quot;payload&quot;,&quot;x&quot;:340,&quot;y&quot;:112,&quot;wires&quot;:[]},
+
<pre>[
{&quot;id&quot;:&quot;f7640bf7.c78ab8&quot;,&quot;type&quot;:&quot;comment&quot;,&quot;z&quot;:&quot;d652f017.65e74&quot;,&quot;name&quot;:&quot;Send Protocol Connector  Sensor Data to AWS IoT&quot;,&quot;info&quot;:&quot;&quot;,&quot;x&quot;:260,&quot;y&quot;:69.36331176757812,&quot;wires&quot;:[]},
+
{"id":"79179714.505328","type":"tab","label":"Protocol Connector ","disabled":false,"info":""},{"id":"d79da03e.4ac02","type":"mqtt in","z":"79179714.505328","name":"Data Recieved","topic":"/cagent/admin/+/deviceinfo","qos":"2","broker":"7c9c4d87.a21bd4","x":150,"y":132,"wires":[["f9b3112b.9e99a","d48faaf7.aded28"]]},
{&quot;id&quot;:&quot;f6c0c463.1d1928&quot;,&quot;type&quot;:&quot;comment&quot;,&quot;z&quot;:&quot;d652f017.65e74&quot;,&quot;name&quot;:&quot;Send Auto-Report Request to Internal MQTT&quot;,&quot;info&quot;:&quot;&quot;,&quot;x&quot;:220,&quot;y&quot;:296,&quot;wires&quot;:[]},
+
{"id":"d48faaf7.aded28","type":"debug","z":"79179714.505328","name":"","active":true,"console":"false","complete":"payload","x":340,"y":112,"wires":[]},{"id":"27eaa5d8.f85fea","type":"comment","z":"79179714.505328","name":"Send Protocol Connector &nbsp;Sensor Data to AWS IoT","info":"","x":260,"y":69.36331176757812,"wires":[]},{"id":"3dc94fa0.0fb2d","type":"comment","z":"79179714.505328","name":"Send Auto-Report Request to Internal MQTT","info":"","x":220,"y":296,"wires":[]},{"id":"f9b3112b.9e99a","type":"function","z":"79179714.505328","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":[["21def20a.3d43ae"]]},{"id":"a99e0e2f.e33a3","type":"mqtt out","z":"79179714.505328","name":"Auto-Report Request","topic":"","qos":"0","retain":"false","broker":"7c9c4d87.a21bd4","x":692.0001220703125,"y":401,"wires":[]},{"id":"d10bad11.60342","type":"mqtt in","z":"79179714.505328","name":"Handler Registered","topic":"/cagent/admin/+/agentinfoack","qos":"2","broker":"7c9c4d87.a21bd4","x":160,"y":364.8398742675781,"wires":[["e0848357.efe7a"]]},{"id":"e0848357.efe7a","type":"function","z":"79179714.505328","name":"pakcage auto report command","func":"var auto_rpt_msg = function(device) {\n &nbsp; &nbsp;return {\n &nbsp; &nbsp; &nbsp; &nbsp;topic: \"/cagent/admin/\" + device + \"/agentcallbackreq\",\n &nbsp; &nbsp; &nbsp; &nbsp;payload: {\n &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\"susiCommData\": {\n &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\"commCmd\": 2053,\n &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\"requestItems\": {\"All\":{}},\n &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\"autoUploadIntervalSec\": 10,\n &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\"handlerName\": \"general\"\n &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}\n &nbsp; &nbsp; &nbsp; &nbsp;}\n &nbsp; &nbsp;};\n};\n\nvar registered = context.get(\"registered\") || [];\nvar dev_id = msg.topic.replace(/^\\/cagent\\/admin\\/|\\/agentinfoack$|\\/notify$/g, \"\");\nvar is_reg_msg = (\n &nbsp; &nbsp;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 &nbsp; &nbsp;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":[["a99e0e2f.e33a3"]]},
{&quot;id&quot;:&quot;5651a33f.5722bc&quot;,&quot;type&quot;:&quot;function&quot;,&quot;z&quot;:&quot;d652f017.65e74&quot;,&quot;name&quot;:&quot;messgae topic&quot;,&quot;func&quot;:&quot;var device_id = 'DK10';\nvar plugin_id = msg.topic.replace(/^\\/cagent\\/admin\\/|\\/deviceinfo$/g, \&quot;\&quot;);\nmsg.topic = 'protocol-conn/' + device_id + '/' + plugin_id;\nreturn msg;&quot;,&quot;outputs&quot;:1,&quot;noerr&quot;:0,&quot;x&quot;:350,&quot;y&quot;:157.10000610351562,&quot;wires&quot;:[[&quot;bb0580c5.75a24&quot;]]},{&quot;id&quot;:&quot;b74f9d97.3e912&quot;,&quot;type&quot;:&quot;mqtt out&quot;,&quot;z&quot;:&quot;d652f017.65e74&quot;,&quot;name&quot;:&quot;Auto-Report Request&quot;,&quot;topic&quot;:&quot;&quot;,&quot;qos&quot;:&quot;0&quot;,&quot;retain&quot;:&quot;false&quot;,&quot;broker&quot;:&quot;22aa981b.46a50c&quot;,&quot;x&quot;:692.0001220703125,&quot;y&quot;:401,&quot;wires&quot;:[]},
+
{"id":"5b81aa8.282ba54","type":"mqtt in","z":"79179714.505328","name":"Handler Heartbeat","topic":"/cagent/admin/+/notify","qos":"2","broker":"7c9c4d87.a21bd4","x":157,"y":438,"wires":[["e0848357.efe7a"]]},
{&quot;id&quot;:&quot;828deeb3.bd324&quot;,&quot;type&quot;:&quot;mqtt in&quot;,&quot;z&quot;:&quot;d652f017.65e74&quot;,&quot;name&quot;:&quot;Handler Registered&quot;,&quot;topic&quot;:&quot;/cagent/admin/+/agentinfoack&quot;,&quot;qos&quot;:&quot;2&quot;,&quot;broker&quot;:&quot;22aa981b.46a50c&quot;,&quot;x&quot;:160,&quot;y&quot;:364.8398742675781,&quot;wires&quot;:[[&quot;8e87ec7b.6487b&quot;]]},
+
{"id":"21def20a.3d43ae","type":"AWS IotData","z":"79179714.505328","aws":"b610e400.9f9db8","operation":"Publish","thingName":"","topic":"","payload":"","endPoint":"","name":"","x":535,"y":156.75,"wires":[[]]},
{&quot;id&quot;:&quot;8e87ec7b.6487b&quot;,&quot;type&quot;:&quot;function&quot;,&quot;z&quot;:&quot;d652f017.65e74&quot;,&quot;name&quot;:&quot;pakcage auto report command&quot;,&quot;func&quot;:&quot;var auto_rpt_msg = function(device) {\n    return {\n        topic: \&quot;/cagent/admin/\&quot; + device + \&quot;/agentcallbackreq\&quot;,\n        payload: {\n            \&quot;susiCommData\&quot;: {\n                \&quot;commCmd\&quot;: 2053,\n                \&quot;requestItems\&quot;: {\&quot;All\&quot;:{}},\n                \&quot;autoUploadIntervalSec\&quot;: 10,\n                \&quot;handlerName\&quot;: \&quot;general\&quot;\n            }\n        }\n    };\n};\n\nvar registered = context.get(\&quot;registered\&quot;) || [];\nvar dev_id = msg.topic.replace(/^\\/cagent\\/admin\\/|\\/agentinfoack$|\\/notify$/g, \&quot;\&quot;);\nvar is_reg_msg = (\n    msg.topic.endsWith(\&quot;agentinfoack\&quot;) &amp;&amp; JSON.parse(msg.payload).susiCommData.status\n);\nvar msg_out = (is_reg_msg || (!~registered.indexOf(dev_id)))? auto_rpt_msg(dev_id)&amp;nbsp;: null;\n\nif(!~registered.indexOf(dev_id)) {\n    registered.push(dev_id);\n}\n\ncontext.set(\&quot;registered\&quot;, registered);\nreturn msg_out;\n&quot;,&quot;outputs&quot;:1,&quot;noerr&quot;:0,&quot;x&quot;:418.0195617675781,&quot;y&quot;:401.00390625,&quot;wires&quot;:[[&quot;b74f9d97.3e912&quot;]]},{&quot;id&quot;:&quot;b06132d0.4baf6&quot;,&quot;type&quot;:&quot;mqtt in&quot;,&quot;z&quot;:&quot;d652f017.65e74&quot;,&quot;name&quot;:&quot;Handler Heartbeat&quot;,&quot;topic&quot;:&quot;/cagent/admin/+/notify&quot;,&quot;qos&quot;:&quot;2&quot;,&quot;broker&quot;:&quot;22aa981b.46a50c&quot;,&quot;x&quot;:157,&quot;y&quot;:438,&quot;wires&quot;:[[&quot;8e87ec7b.6487b&quot;]]},
+
{"id":"7c9c4d87.a21bd4","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":""},
{&quot;id&quot;:&quot;bb0580c5.75a24&quot;,&quot;type&quot;:&quot;AWS IotData&quot;,&quot;z&quot;:&quot;d652f017.65e74&quot;,&quot;aws&quot;:&quot;20e9a430.34135&quot;,&quot;operation&quot;:&quot;Publish&quot;,&quot;thingName&quot;:&quot;&quot;,&quot;topic&quot;:&quot;&quot;,&quot;payload&quot;:&quot;&quot;,&quot;endPoint&quot;:&quot;&quot;,&quot;name&quot;:&quot;&quot;,&quot;x&quot;:535,&quot;y&quot;:156.75,&quot;wires&quot;:[[]]},{&quot;id&quot;:&quot;22aa981b.46a50c&quot;,&quot;type&quot;:&quot;mqtt-broker&quot;,&quot;z&quot;:&quot;&quot;,&quot;broker&quot;:&quot;127.0.0.1&quot;,&quot;port&quot;:&quot;1883&quot;,&quot;clientid&quot;:&quot;&quot;,&quot;usetls&quot;:false,&quot;compatmode&quot;:true,&quot;keepalive&quot;:&quot;60&quot;,&quot;cleansession&quot;:true,&quot;willTopic&quot;:&quot;&quot;,&quot;willQos&quot;:&quot;0&quot;,&quot;willPayload&quot;:&quot;&quot;,&quot;birthTopic&quot;:&quot;&quot;,&quot;birthQos&quot;:&quot;0&quot;,&quot;birthPayload&quot;:&quot;&quot;},
+
{"id":"b610e400.9f9db8","type":"amazon config","z":"","name":"AWS","region":"us-east-1"}
{&quot;id&quot;:&quot;20e9a430.34135&quot;,&quot;type&quot;:&quot;amazon config&quot;,&quot;z&quot;:&quot;&quot;,&quot;name&quot;:&quot;AWS&quot;,&quot;region&quot;:&quot;us-east-1&quot;}]
+
]
 
</pre>
 
</pre>
<ul><li>Switch to Protocol Converter tab and double click “IotData Publish” node to set device configuration.
 
</li></ul><ul><li>Click <img src="/wiki/images/8/8d/Button_NR.png" _fck_mw_filename="Button NR.png" _fck_mw_origimgwidth="38" _fck_mw_origimgheight="41" alt="button_NR.png" title="button_NR.png" style="vertical-align:middle;" />&#160;button<img src="/wiki/images/d/d9/2018-02-13_145112.png" _fck_mw_filename="2018-02-13 145112.png" _fck_mw_location="center" _fck_mw_origimgwidth="514" _fck_mw_origimgheight="402" alt="2018-02-13_145112.png" title="2018-02-13_145112.png" class="fck_mw_center" style="vertical-align:middle;" />
 
</li></ul><p>
 
</p><p>&#160;
 
</p>
 
<ul><li>Enter the Access Id and Secret Key which is on credentials .csv file.
 
</li></ul><p><img src="/wiki/images/5/59/11.png" _fck_mw_filename="11.png" _fck_mw_location="center" _fck_mw_origimgwidth="512" _fck_mw_origimgheight="301" alt="11.png" title="11.png" class="fck_mw_center" style="vertical-align:middle;" />
 
</p>
 
<ul><li>Enter the Name “IoT Pubilsh” and Endpoint, <span style="color:#FF8C00;">Endpoint is copied in AWS IoT Core.</span>
 
</li></ul><p><img src="/wiki/images/5/5f/2018-02-13_144939.png" _fck_mw_filename="2018-02-13 144939.png" _fck_mw_location="center" _fck_mw_origimgwidth="509" _fck_mw_origimgheight="409" alt="2018-02-13_144939.png" title="2018-02-13_144939.png" class="fck_mw_center" style="vertical-align:middle;" />
 
</p><p>
 
</p><p>
 
</p>
 
<ul><li>Check your message topic&#160;on the "message&#160;topic' function node<img src="/wiki/images/c/cf/15-2.png" _fck_mw_filename="15-2.png" _fck_mw_location="center" width="1000" _fck_mw_origimgwidth="1280" _fck_mw_origimgheight="918" alt="15-2.png" title="15-2.png" class="fck_mw_center" style="vertical-align:middle;" />
 
</li>
 
<li>Enter {your device id} in device_id, you can choose {your device id} which you want.
 
</li></ul><p><img src="/wiki/images/0/01/16-2.PNG" _fck_mw_filename="16-2.PNG" _fck_mw_location="center" width="800" _fck_mw_origimgwidth="555" _fck_mw_origimgheight="372" alt="16-2.PNG" title="16-2.PNG" class="fck_mw_center" style="vertical-align:middle;" />
 
</p>
 
<ul><li>Click <img src="/wiki/images/8/8e/Deploy.png" _fck_mw_filename="Deploy.png" _fck_mw_origimgwidth="122" _fck_mw_origimgheight="31" alt="deploy.png" title="deploy.png" style="vertical-align:middle;" />&#160;to finish edge device environment setups.
 
</li></ul><p><img src="/wiki/images/b/b9/17-2.png" _fck_mw_filename="17-2.png" _fck_mw_location="center" width="1000" _fck_mw_origimgwidth="1280" _fck_mw_origimgheight="918" alt="17-2.png" title="17-2.png" class="fck_mw_center" style="vertical-align:middle;" />
 
</p>
 
<ul><li>Click NodeRED “Debug” tab, the sent messages will be displayed.&#160;
 
</li></ul><p><img src="/wiki/images/9/99/18-2.png" _fck_mw_filename="18-2.png" _fck_mw_location="center" width="1000" _fck_mw_origimgwidth="1280" _fck_mw_origimgheight="918" alt="18-2.png" title="18-2.png" class="fck_mw_center" style="vertical-align:middle;" />
 
</p>
 
<ul><li>Go back to AWS IoT menu
 
</li>
 
<li>click “Test” and enter Subscription&#160;topic click <img src="/wiki/images/0/0f/Subscription.png" _fck_mw_filename="Subscription.png" _fck_mw_origimgwidth="141" _fck_mw_origimgheight="38" alt="Subscription.png" title="Subscription.png" style="vertical-align:middle;" />
 
</li>
 
<li>For more information, see&#160; <span _fck_mw_customtag="true" _fck_mw_tagname="references" _fck_mw_tagtype="t" class="fck_mw_references">_</span><span _fck_mw_customtag="true" _fck_mw_tagname="references" _fck_mw_tagtype="t" class="fck_mw_references">_</span><span _fck_mw_customtag="true" _fck_mw_tagname="references" _fck_mw_tagtype="t" class="fck_mw_references">_</span><a href="https://docs.aws.amazon.com/iot/latest/developerguide/topics.html" alt="https://docs.aws.amazon.com/iot/latest/developerguide/topics.html" title="https://docs.aws.amazon.com/iot/latest/developerguide/topics.html">https://docs.aws.amazon.com/iot/latest/developerguide/topics.html</a>
 
</li></ul><p><img src="/wiki/images/d/d9/2018-02-13_152730.png" _fck_mw_filename="2018-02-13 152730.png" _fck_mw_location="center" width="1000" _fck_mw_origimgwidth="1280" _fck_mw_origimgheight="918" alt="2018-02-13_152730.png" title="2018-02-13_152730.png" class="fck_mw_center" style="vertical-align:middle;" />
 
</p><p>
 
</p>
 
<ul><li>if your settings is correct, then you can see the message in this area.
 
</li></ul><p><img src="/wiki/images/9/93/2018-02-13_152741.png" _fck_mw_filename="2018-02-13 152741.png" _fck_mw_location="center" width="1000" _fck_mw_origimgwidth="1280" _fck_mw_origimgheight="918" alt="2018-02-13_152741.png" title="2018-02-13_152741.png" class="fck_mw_center" style="vertical-align:middle;" />
 
</p><p>
 
</p><p>&#160;
 
</p><p>&#160;
 
</p>
 
  
<h3> Connect device and data to AWS for Linux Ubuntu device – Protocol Converter using Greengrass </h3>
+
*Switch to Protocol Converter tab and double click “IotData Publish” node to set device configuration.
<h4> Prerequisites </h4>
+
*Click [[File:Button NR.png|button_NR.png]]&nbsp;button[[File:2018-02-13 145112.png|center|2018-02-13_145112.png]]
<p>AWS Account
+
 
</p><p>Linux Host
+
&nbsp;
</p><p>OS version&#160;: Ubuntu 16.04 x64
+
 
</p><p><a href="#Basic_Requirment:">Protocol Converter installation steps</a>
+
*Enter the Access Id and Secret Key which is on credentials .csv file.
</p>
+
 
<h4> Create Greengrass Group </h4>
+
[[File:11.png|center|11.png]]
<p>Using the AWS IoT console, create an AWS IoT thing, certificate, and policy for your AWS Greengrass core device:
+
 
</p><p>&#160;
+
*Enter the Name “IoT Pubilsh” and Endpoint, <span style="color:#FF8C00;">Endpoint is copied in AWS IoT Core.</span>
</p><p>Step 1. Go to the AWS IoT console and click Greengrass.
+
 
</p><p><img src="/wiki/images/4/4e/2018-02-07_105949.png" _fck_mw_filename="2018-02-07 105949.png" _fck_mw_location="center" width="1000" _fck_mw_origimgwidth="1280" _fck_mw_origimgheight="918" alt="2018-02-07_105948.png" title="2018-02-07_105948.png" class="fck_mw_center" style="vertical-align:middle;" /> <img src="/wiki/images/0/0c/2018-02-07_110140.png" _fck_mw_filename="2018-02-07 110140.png" _fck_mw_location="center" width="1000" _fck_mw_origimgwidth="1280" _fck_mw_origimgheight="918" alt="2018-02-07_110140.png" title="2018-02-07_110140.png" class="fck_mw_center" style="vertical-align:middle;" />
+
[[File:2018-02-13 144939.png|center|2018-02-13_144939.png]]
</p><p>Step 2. Create an AWS Greengrass group and name it GGC <img src="/wiki/images/e/e3/2018-02-07_110247.PNG" _fck_mw_filename="2018-02-07 110247.PNG" _fck_mw_location="center" width="1000" _fck_mw_origimgwidth="1280" _fck_mw_origimgheight="918" alt="2018-02-07_110247.png" title="2018-02-07_110247.png" class="fck_mw_center" style="vertical-align:middle;" />Step 3. Create an AWS IoT for Greengrass core <img src="/wiki/images/4/4f/2018-02-07_110257.png" _fck_mw_filename="2018-02-07 110257.png" _fck_mw_location="center" width="1000" _fck_mw_origimgwidth="1280" _fck_mw_origimgheight="918" alt="2018-02-07_110247.png" title="2018-02-07_110247.png" class="fck_mw_center" style="vertical-align:middle;" /> Step 4. One-click to create Greengrass certificate and attach policy. <img src="/wiki/images/1/1e/2018-02-07_110405.png" _fck_mw_filename="2018-02-07 110405.png" _fck_mw_location="center" width="1000" _fck_mw_origimgwidth="1280" _fck_mw_origimgheight="918" alt="2018-02-07_110405.png" title="2018-02-07_110405.png" class="fck_mw_center" style="vertical-align:middle;" /> Step 5. Download Certificate and Greengrass config. <span style="color:#FF8C00;">This Certificate will be used later for&#160;setup AWS IoT device.</span><img src="/wiki/images/e/ec/2018-02-07_110435.png" _fck_mw_filename="2018-02-07 110435.png" _fck_mw_location="center" width="1000" _fck_mw_origimgwidth="1280" _fck_mw_origimgheight="918" alt="2018-02-07_110435.png" title="2018-02-07_110435.png" class="fck_mw_center" style="vertical-align:middle;" />
+
 
</p>
+
*Check your message topic&nbsp;on the "message&nbsp;topic' function node[[File:15-2.png|center|1000px|15-2.png]]
<h4> Setup Greengrass Group </h4>
+
 
<p>To define your Greengrass group, follow these steps:
+
*Enter {your device id} in device_id, you can choose {your device id} which you want.
</p>
+
 
<ol><li>Add devices to your group
+
[[File:16-2.PNG|center|800px|16-2.PNG]]
</li>
+
 
<li>Add Lambda functions to your group
+
*Click [[File:Deploy.png|deploy.png]]&nbsp;to finish edge device environment setups.
</li>
+
 
<li>Add subscriptions to your group
+
[[File:17-2.png|center|1000px|17-2.png]]
</li></ol><h5> Add Device to Your Group </h5>
+
 
<p>Step 1.Go to the AWS IoT console.
+
*Click NodeRED “Debug” tab, the sent messages will be displayed.&nbsp;
</p><p>Step 2.In the navigation pane, select Greengrass and then Groups.
+
 
</p><p>Step 3.Click on your group, <i>GGC</i>
+
[[File:18-2.png|center|1000px|18-2.png]]
</p><p>Step 4.In the navigation pane, click <b>Devices </b>and then <b>Add Device</b>. <img src="/wiki/images/5/5a/2018-02-07_114426.png" _fck_mw_filename="2018-02-07 114426.png" _fck_mw_location="center" width="1000" _fck_mw_origimgwidth="1280" _fck_mw_origimgheight="869" alt="2018-02-07_114426.png" title="2018-02-07_114426.png" class="fck_mw_center" style="vertical-align:middle;" />
+
 
</p><p>Step 5. Enter AWS IoT Name Device and click Next <img src="/wiki/images/b/bc/2018-02-07_114443.png" _fck_mw_filename="2018-02-07 114443.png" _fck_mw_location="center" width="1000" _fck_mw_origimgwidth="1280" _fck_mw_origimgheight="869" alt="2018-02-07_114443.png" title="2018-02-07_114443.png" class="fck_mw_center" style="vertical-align:middle;" />
+
*>Go back to AWS IoT menu
</p><p>Step 6. Using default setting to quick create access permissions and certificate. <img src="/wiki/images/b/b0/2018-02-07_114456.png" _fck_mw_filename="2018-02-07 114456.png" _fck_mw_location="center" width="1000" _fck_mw_origimgwidth="1280" _fck_mw_origimgheight="869" alt="2018-02-07_114456.png" title="2018-02-07_114456.png" class="fck_mw_center" style="vertical-align:middle;" />
+
*click “Test” and enter Subscription&nbsp;topic click [[File:Subscription.png|Subscription.png]]
</p><p>Step 7. Download certificate and finish this process.<span style="color:#FF8C00;">&#160;This Certificate will be used for running GreenGrass Core.</span><img src="/wiki/images/8/8b/2018-02-07_114508.png" _fck_mw_filename="2018-02-07 114508.png" _fck_mw_location="center" width="1000" _fck_mw_origimgwidth="1280" _fck_mw_origimgheight="869" alt="2018-02-07_114508.png" title="2018-02-07_114508.png" class="fck_mw_center" style="vertical-align:middle;" />
+
 
</p><p>
+
*For more information, see&nbsp; <references /><references /><references />[https://docs.aws.amazon.com/iot/latest/developerguide/topics.html https://docs.aws.amazon.com/iot/latest/developerguide/topics.html]
</p>
+
 
<h5> Add Subscriptions to Your Group </h5>
+
[[File:2018-02-13 152730.png|center|1000px|2018-02-13_152730.png]]
<p>Step 1.In the navigation pane, click Subscriptions and then Add Subscription.
+
 
</p><p><img src="/wiki/images/8/8c/SubscriptionAdd.png" _fck_mw_filename="SubscriptionAdd.png" _fck_mw_location="center" width="700" _fck_mw_origimgwidth="1280" _fck_mw_origimgheight="869" alt="SubscriptionAdd.png" title="SubscriptionAdd.png" class="fck_mw_center" style="vertical-align:middle;" />
+
*if your settings is correct, then you can see the message in this area.
</p><p>Step 2.Under Select a source, select the source of the subscription and click on Next.
+
 
</p><p><img src="/wiki/images/2/29/Subscription1.png" _fck_mw_filename="Subscription1.png" _fck_mw_location="center" width="700" _fck_mw_origimgwidth="1278" _fck_mw_origimgheight="917" alt="Subscription1.png" title="Subscription1.png" class="fck_mw_center" style="vertical-align:middle;" />
+
[[File:2018-02-13 152741.png|center|1000px|2018-02-13_152741.png]] &nbsp; &nbsp;
</p><p>Step 3.Under Select a target, select the target of the subscription and click on Next.
+
 
</p><p><img src="/wiki/images/e/e6/Subscription2.png" _fck_mw_filename="Subscription2.png" _fck_mw_location="center" width="700" _fck_mw_origimgwidth="1262" _fck_mw_origimgheight="956" alt="Subscription2.png" title="Subscription2.png" class="fck_mw_center" style="vertical-align:middle;" />
+
=== Connect device and data to AWS for Linux Ubuntu device – Protocol Converter using Greengrass ===
</p><p>Step 4.In the Optional topic filter, type the topic of the subscription <span style="color:#FF8C00;">" topic/MQTT "</span>.
+
 
</p><p><img src="/wiki/images/d/d1/Subscription3.png" _fck_mw_filename="Subscription3.png" _fck_mw_location="center" width="700" _fck_mw_origimgwidth="1278" _fck_mw_origimgheight="917" alt="Subscription3.png" title="Subscription3.png" class="fck_mw_center" style="vertical-align:middle;" />
+
==== Prerequisites ====
</p><p>Step 5.Click on finish to confirm and save subscription.
+
 
</p><p><img src="/wiki/images/2/20/Subscription4.png" _fck_mw_filename="Subscription4.png" _fck_mw_location="center" width="700" _fck_mw_origimgwidth="1278" _fck_mw_origimgheight="917" alt="Subscription4.png" title="Subscription4.png" class="fck_mw_center" style="vertical-align:middle;" />
+
AWS Account Linux Host OS version&nbsp;: Ubuntu 16.04 x64 [[#Basic_Requirment:|Protocol Converter installation steps]]
</p><p>Step 6.Review the subscription information.
+
 
</p><p><img src="/wiki/images/a/a7/Subscription_done.png" _fck_mw_filename="Subscription done.png" _fck_mw_location="center" width="700" _fck_mw_origimgwidth="1278" _fck_mw_origimgheight="917" alt="Subscription done.png" title="Subscription done.png" class="fck_mw_center" style="vertical-align:middle;" />
+
==== Create Greengrass Group ====
</p>
+
 
<h4> Run Greengrass Core in Your Device </h4>
+
Using the AWS IoT console, create an AWS IoT thing, certificate, and policy for your AWS Greengrass core device: &nbsp; Step 1. Go to the AWS IoT console and click Greengrass. [[File:2018-02-07 105949.png|center|1000px|2018-02-07_105948.png]] [[File:2018-02-07 110140.png|center|1000px|2018-02-07_110140.png]]
<p>/greengrass&#160;is located under Installer folder, e.g. {$Unzip Path} is ~/Desktop/Installer/packages/AWS/EISXGCC&#160;
+
 
</p><p>To configure your core to recognize the AWS IoT thing, update the /greengrass/config/config.json file. and /greengrass/certs.
+
Step 2. Create an AWS Greengrass group and name it GGC [[File:2018-02-07 110247.PNG|center|1000px|2018-02-07_110247.png]]Step 3. Create an AWS IoT for Greengrass core [[File:2018-02-07 110257.png|center|1000px|2018-02-07_110247.png]] Step 4. One-click to create Greengrass certificate and attach policy. [[File:2018-02-07 110405.png|center|1000px|2018-02-07_110405.png]] Step 5. Download Certificate and Greengrass config. <span style="color:#FF8C00;">This Certificate will be used later for&nbsp;setup AWS IoT device.</span>[[File:2018-02-07 110435.png|center|1000px|2018-02-07_110435.png]]
</p><p>Copy certs and config with root permission, <span style="color:#FF8C00;">use the certificate for GreenGrass Core</span>.
+
 
</p><p>Step 1.sudo cp -R certs/ {$Unzip Path}/greengrass/
+
 
</p><p>Step 2.sudo cp -R conf/ {$Unzip Path}/greengrass/
+
 
</p><p>Step 3.sudo cp root.ca.pem {$Unzip Path}/greengrass/certs/
+
==== Setup Greengrass Group ====
</p><p><span style="color:#888888;">root.ca.pem is just located under&#160;{$Unzip Path}. If the original file under&#160;{$Unzip Path} is root-ca.pem, just rename it to root.ca.pem after copying to&#160;{$Unzip Path}/greengrass/certs/</span>
+
 
</p><p><span style="color:#888888;"># mv root-ca.pem root.ca.pem</span>
+
To define your Greengrass group, follow these steps:
</p><p>
+
 
</p><p>&#160;The Greengrass core software is installed inside the /<b>greengrass</b> directory of your device.
+
#Add devices to your group
</p><p>Step 1.Make sure your device is connected to the Internet.
+
#Add Lambda functions to your group
</p><p>Step 2.sudo {$Unzip Path}/greengrass/ggc/core/greengrassd start
+
#Add subscriptions to your group
</p><p><img src="/wiki/images/3/38/Greengrassrun.png" _fck_mw_filename="Greengrassrun.png" _fck_mw_location="center" width="1000" _fck_mw_origimgwidth="732" _fck_mw_origimgheight="438" alt="greengrassrun.png" title="greengrassrun.png" class="fck_mw_center" style="vertical-align:middle;" />
+
 
</p>
+
===== Add Device to Your Group =====
<h4> Deploy Your Greengrass Group </h4>
+
 
<p>After running Greengrass core, you can deploy your Greengrass group to your device.
+
Step 1.Go to the AWS IoT console. Step 2.In the navigation pane, select Greengrass and then Groups. Step 3.Click on your group, "GGC" Step 4.In the navigation pane, click '''Devices '''and then '''Add Device'''. [[File:2018-02-07 114426.png|center|1000px|2018-02-07_114426.png]]
</p><p>Step 1.Go to the AWS IoT console.
+
 
</p><p>Step 2.In the navigation pane, select Greengrass and then Groups.
+
Step 5. Enter AWS IoT Name Device and click Next [[File:2018-02-07 114443.png|center|1000px|2018-02-07_114443.png]]
</p><p>Step 3.Click on your group, GGC.
+
 
</p><p>Step 4.In the navigation pane, click Deployments.
+
Step 6. Using default setting to quick create access permissions and certificate. [[File:2018-02-07 114456.png|center|1000px|2018-02-07_114456.png]]
</p><p>Step 5.Click Actions &gt; Deploy.
+
 
</p><p>&#160;
+
Step 7. Download certificate and finish this process.<span style="color:#FF8C00;">&nbsp;This Certificate will be used for running GreenGrass Core.</span>[[File:2018-02-07 114508.png|center|1000px|2018-02-07_114508.png]]
</p><p><img src="/wiki/images/f/fa/2018-02-01_135700.png" _fck_mw_filename="2018-02-01 135700.png" _fck_mw_location="center" width="1000" _fck_mw_origimgwidth="1280" _fck_mw_origimgheight="907" alt="2018-02-01_135700.png" title="2018-02-01_135700.png" class="fck_mw_center" style="vertical-align:middle;" />
+
 
</p><p>Step 6.In the Configure how Devices discover your Core select Automatic detection. <img src="/wiki/images/b/bc/2018-02-01_135720.png" _fck_mw_filename="2018-02-01 135720.png" _fck_mw_location="center" width="1000" _fck_mw_origimgwidth="1280" _fck_mw_origimgheight="906" alt="2018-02-01_135720.png" title="2018-02-01_135720.png" class="fck_mw_center" style="vertical-align:middle;" />
+
===== Add Subscriptions to Your Group =====
</p><p>Step 7.In the Grant permissions to access other services, click Grant permission. <img src="/wiki/images/c/c3/2018-02-01_135731.png" _fck_mw_filename="2018-02-01 135731.png" _fck_mw_location="center" width="1000" _fck_mw_origimgwidth="1280" _fck_mw_origimgheight="907" alt="2018-02-01_135731.png" title="2018-02-01_135731.png" class="fck_mw_center" style="vertical-align:middle;" />
+
 
</p><p>When the operation is complete, the Deployment successfully completed is displayed at the top of the page. <img src="/wiki/images/e/ee/2018-02-08_151442.png" _fck_mw_filename="2018-02-08 151442.png" _fck_mw_location="center" width="1000" _fck_mw_origimgwidth="1280" _fck_mw_origimgheight="918" alt="2018-02-08_151442.png" title="2018-02-08_151442.png" class="fck_mw_center" style="vertical-align:middle;" />
+
Step 1.In the navigation pane, click Subscriptions and then Add Subscription. [[File:SubscriptionAdd.png|center|700px|SubscriptionAdd.png]]
</p>
+
 
<h4> Set Up Your AWS IoT Things </h4>
+
Step 2.Under Select a source, select the source of the subscription and click on Next. [[File:Subscription1.png|center|700px|Subscription1.png]]
<p>When Greengrass group is deployed successful. You can setup AWS IoT <b>Device </b>which is defined in Greengrass group with Protocol Converter.
+
 
</p><p>&#160;
+
Step 3.Under Select a target, select the target of the subscription and click on Next.  
</p><p>AWS IoT devices need certificates to authenticate with AWS IoT and retrieve the connectivity information of your Greengrass core. You downloaded these certificates in <b>Add devices to your group</b> Create device things.
+
[[File:Subscription2.png|center|700px|Subscription2.png]]
</p>
+
 
<h4> Install Your IoT Thing Certificate </h4>
+
Step 4.In the Optional topic filter, type the topic of the subscription <span style="color:#FF8C00;">" topic/MQTT "</span>. [[File:Subscription3.png|center|700px|Subscription3.png]]
<p><span style="color:#FF8C00;">Use Certificate for setup AWS IoT device.</span>
+
 
</p><p>cp root-ca.pem {$Unzip Path}/ProtocolConnectorSample/certs
+
Step 5.Click on finish to confirm and save subscription. [[File:Subscription4.png|center|700px|Subscription4.png]]
</p><p>cp &lt;id&gt;.cert.pem&#160;{$Unzip Path}/ProtocolConnectorSample/certs
+
 
</p><p>cp &lt;id&gt;-private.key {$Unzip Path}/ProtocolConnectorSample/certs
+
Step 6.Review the subscription information. [[File:Subscription done.png|center|700px|Subscription done.png]]
</p>
+
 
<h4> Configure The Samples </h4>
+
==== Run Greengrass Core in Your Device ====
<p>Inside the ProtocolConnectorSample/config/ directory you can find the configuration files&#160;<span style="color:#FF8C00;">SampleConfig.json</span>&#160;for your things:
+
 
</p><p>1. Please find your endpoint in Settings page in AWS IoT Console.
+
/greengrass&nbsp;is located under Installer folder, e.g. {$Unzip Path} is ~/Desktop/Installer/packages/AWS/EISXGCC&nbsp; <br />
</p><p>2. Fill in relative path of root-ca.pem.
+
 
</p><p>3. Fill in relative path of &lt;id&gt;.cert.pem.
+
To configure your core to recognize the AWS IoT thing, update the /greengrass/config/config.json file. and /greengrass/certs.<br />
</p><p>4. Fill in relatvie path of &lt;id&gt;.private.key
+
 
</p><p>5. Fill in your device name that you added for GreenGrass group&#160;in the following three fields.
+
Copy certs and config with root permission, <span style="color:#FF8C00;">use the certificate for GreenGrass Core</span>.<br />
</p><p><img src="/wiki/images/0/0e/Screenshot_from_2018-02-09_16-17-16.png" _fck_mw_filename="Screenshot from 2018-02-09 16-17-16.png" _fck_mw_location="center" _fck_mw_origimgwidth="900" _fck_mw_origimgheight="728" alt="2018-02-09 16-17-16.png" title="2018-02-09 16-17-16.png" class="fck_mw_center" style="vertical-align:middle;" />
+
 
</p>
+
Step 1.sudo cp -R certs/ {$Unzip Path}/greengrass/ <br />
<h4> Run the Protocol Converter Sample </h4>
+
Step 2.sudo cp -R config/ {$Unzip Path}/greengrass/ <br />
<p>After setting AWS IoT you can execute protocol converter sample,
+
Step 3.sudo cp root.ca.pem {$Unzip Path}/greengrass/certs/ <br />
</p><p>In the ProtocolConnectorSample folder
+
<span style="color:#888888;">root.ca.pem is just located under&nbsp;{$Unzip Path}.<br />  
</p><p>./MQTTAgent-sample
+
If the original file under&nbsp;{$Unzip Path} is root-ca.pem, just rename it to root.ca.pem after copying to&nbsp;{$Unzip Path}/greengrass/certs/</span>
</p><p><img src="/wiki/images/a/a2/Screenshot_from_2018-02-09_16-18-09.png" _fck_mw_filename="Screenshot from 2018-02-09 16-18-09.png" _fck_mw_location="center" _fck_mw_origimgwidth="732" _fck_mw_origimgheight="438" alt="2018-02-09 16-18-09.png" title="2018-02-09 16-18-09.png" class="fck_mw_center" style="vertical-align:middle;" />
+
<br />
</p>
+
<span style="color:#888888;"># mv root-ca.pem root.ca.pem</span>
 +
 
 +
The Greengrass core software is installed inside the /'''greengrass''' directory of your device.
 +
 
 +
Step 1.Make sure your device is connected to the Internet. <br />
 +
Step 2.sudo {$Unzip Path}/greengrass/ggc/core/greengrassd start [[File:Greengrassrun.png|center|1000px|greengrassrun.png]]
 +
 
 +
==== Deploy Your Greengrass Group ====
 +
 
 +
After running Greengrass core, you can deploy your Greengrass group to your device. <br />
 +
Step 1.Go to the AWS IoT console. <br />
 +
Step 2.In the navigation pane, select Greengrass and then Groups. <br />
 +
Step 3.Click on your group, GGC. <br />
 +
Step 4.In the navigation pane, click Deployments. <br />
 +
Step 5.Click Actions > Deploy. &nbsp; [[File:2018-02-01 135700.png|center|1000px|2018-02-01_135700.png]]
 +
 
 +
Step 6.In the Configure how Devices discover your Core select Automatic detection. [[File:2018-02-01 135720.png|center|1000px|2018-02-01_135720.png]]
 +
 
 +
Step 7.In the Grant permissions to access other services, click Grant permission. [[File:2018-02-01 135731.png|center|1000px|2018-02-01_135731.png]]
 +
 
 +
When the operation is complete, the Deployment successfully completed is displayed at the top of the page. [[File:2018-02-08 151442.png|center|1000px|2018-02-08_151442.png]]
 +
 
 +
==== Set Up Your AWS IoT Things ====
 +
 
 +
When Greengrass group is deployed successful. You can setup AWS IoT '''Device '''which is defined in Greengrass group with Protocol Converter. &nbsp;
 +
 
 +
AWS IoT devices need certificates to authenticate with AWS IoT and retrieve the connectivity information of your Greengrass core. You downloaded these certificates in '''Add devices to your group''' Create device things.
 +
 
 +
==== Install Your IoT Thing Certificate ====
 +
 
 +
<span style="color:#FF8C00;">Use Certificate for setup AWS IoT device.</span><br/>cp root-ca.pem {$Unzip Path}/ProtocolConnectorSample/certs<br/>cp &lt;id&gt;.cert.pem&nbsp;{$Unzip Path}/ProtocolConnectorSample/certs<br/>cp &lt;id&gt;.private.key {$Unzip Path}/ProtocolConnectorSample/certs
 +
 
 +
==== Configure The Samples ====
 +
 
 +
Inside the ProtocolConnectorSample/config/ directory you can find the configuration files&nbsp;<span style="color:#FF8C00;">SampleConfig.json</span>&nbsp;for your things: <br />
 +
1. Please find your endpoint in Settings page in AWS IoT Console. <br />
 +
2. Fill in relative path of root-ca.pem. <br />
 +
3. Fill in relative path of &lt;id&gt;.cert.pem. <br />
 +
4. Fill in relatvie path of &lt;id&gt;.private.key <br />
 +
5. Fill in your device name that you added for GreenGrass group&nbsp;in the following three fields. [[File:Screenshot from 2018-02-09 16-17-16.png|center|2018-02-09 16-17-16.png]]
 +
 
 +
==== Run the Protocol Converter Sample ====
 +
 
 +
After setting AWS IoT you can execute protocol converter sample, In the ProtocolConnectorSample folder <br />
 +
./MQTTAgent-sample [[File:Screenshot from 2018-02-09 16-18-09.png|center|2018-02-09 16-18-09.png]]
  
 
= IoT connectivity =
 
= IoT connectivity =
 +
 
== How to use SUSI (Advantech HW information) plugin ==
 
== How to use SUSI (Advantech HW information) plugin ==
  

Latest revision as of 11:36, 12 September 2018

Contents

Introduction

    WISE-PaaS/EdgeSense is an edge intelligence and sensing integration software solution that incorporates sensor data aggregation, cloud applications, edge analytics, and secure end-to-end data protection for fast and easy device-to-cloud operation. “Protocol Converter” is one of the major part of EdgeSense, it is an all-in-one message broker service which collects sensor data via various industrial protocols and then upload to cloud.

Installation Guide

For Windows Device

How To Install

  • Step 1. Execute EdgeSense installer, click "Next >".

RTENOTITLE

  • Step 2. Select "I accept the ..." then click "Next >".

RTENOTITLE

  • Step 3. Select any cloud you would like to connect then click "Next >". (here we take WISE-PaaS/EnSaaS and RMM as example for below steps)

RTENOTITLE

  • Step 4. Click "Next >".

RTENOTITLE

  • Step 5. Click "Install".

RTENOTITLE

  • Step 6. Wait for installation finished.

RTENOTITLE

  • Step 7. Select "I agree to the ..." then click "Install".

RTENOTITLE

  • Step 8. Select "I agree to the ..." then click "Install".

RTENOTITLE

  • Step 9. Click "Finish". Now you have necessary component and agent installed in your device.

RTENOTITLE

For Linux Ubuntu ( Docker version )

Basic Requirment:

  • Host OS must be Linux Distribution (we developed and tested our software offering with Ubuntu 16.04 environment so below content is referring to this specific Linux distribution.)
  • Docker Engine - Installation Guide ( Ubuntu )
  • Docker compose - Installation Guid
  • Hardward: Advantech x86_64 Platforms ( e.g. ARK-2121L...)

How To Install and Run - Protocol Converter Docker Container Services

# unzip installation package
tar zxvf EdgeSense_1.0.2.tar.gz
# Follow the readme to install your converter protocol

How To modify EnSaaS ID/Password and resart

# To fill your "IoTKey" then save and exit 
 <IoTKey>304a99b5b452444c749a83bbb9e35dpow</IoTKey>
$cd {Installed path}/Installer/packages/Plugins/docker-edgesense-image-x86/EdgeSense/AgentService/config/
$sudo vim agent_config.xml
$sudo docker restart ensaas-ei-agent

How To config Modbus and resart service

$cd {Installed path}/Installer/packages/Plugins/docker-edgesense-image-x86/EdgeSense/EService-Modbus/config/
$sudo vim Modbus_Handler.ini
$sudo docker restart service-modbus

How To Restart Service

// MQTT-BUS
$sudo docker restart advigw-mqtt-bus

// Node-RED
$sudo docker restart advigw-node-red

// Modbus_Handler Service
$sudo docker restart service-modbus

// HDD PMQ
$sudo docker restart service-hddpmq

// SUSIControl
$sudo docker restart service-susi

How To Uninstall Edgent Sense Docker Image

$cd {Installed path}/Installer/packages/Plugins/docker-edgesense-image-x86/
$sudo ./deploy.sh rmi

Cloud

WISE-PaaS/EnSaaS

WISE-PaaS/EnSaaS is an open and standardized industrial IoT platform provided by Advantech Corp., and EdgeSense leverages cloud services on top of it to offer device management and visualization service.

You will be re-directed to WISE-PaaS online documentation site via below links.

Register account on EdgesSense Portal

Please visit this page for step by step instruction.

How to Connect Edge Devices to RMM Cloud

Please visit this page for step by step instruction.

Azure

Create Azure IoT Hub

To utilize Azure services, we need a Microsoft account to log in to azure portal. Following steps will create an azure iot hub to communicate with Advantech protocol converter modules.

Step 1. Log in to Microsoft Azure Portal

Step 2. Create a resource group

  • Search “resource group” and create new one
create-rg.png
  • Input resource group name: protocol-conn-rg (for example)
  • Select a location (service region): East Asia (for example)
create-rg-detail.png

Step 3. Create an azure iot hub

  • Search “iot hub” and create new one
create-hub.png
  • Select Resource group created at step 2: click “Use existing” and select “protocol-conn-rg
  • Select Region: East Asia
  • Input IoT hub name: protocol-con-hub (for example)
  • Click on Review+Create
iot_hub.png
  • Click on Create
iot_hub2.png

Connect device and data to Azure for Windows device – Protocol Converter Using Node-RED

Cloud Environment Setup

Following steps will create an azure iot device to connect to iot hub created at previous section.

Step 1. Go to iot hub created at previous section: Resource groups → protocol-conn-rg → Overview → protocol-con-rg (for example)

iot_device0

Step 2. IoT Devices → Add

select conn hub
  • Device ID: protocol-conn-device (for example)
  • Authentication Type: select “Symmetric Key” for this tutorial
  • Check “Auto Generate Keys”
  • Connect device to IoT Hub: select “Enable”
  • Save the configurations
add_device
  • Select the created iot device to get device connection string
iot_device
  • Click save-icon.png to copy “Connection string-primary key” and make sure the "Connect device to IoT Hub" is "Enable"

          "Connection string-primary key" will be used later in Node-Red "Connection String" field.

iot_device2
  • Save the connection string in a text file for later use
save-conn-string

Device Environment Setup

Following steps will configure device Node-RED nodes to enable communications between Advantech protocol converter modules and azure iot hub.

Step 1. Open Node-RED page in the web browser (default URI is http://127.0.0.1:1880)

nr main

Step 2. Copy following content and import it into Node-RED

        [
            {"id": "ce169f53.786dd" , "type": "tab", "label": "Protocol Connector ", "disabled": false, "info": ""},
            {"id": "104120.85f37ee" , "type": "mqtt in", "z": "ce169f53.786dd", "name": "Data Recieved", "topic": "/cagent/admin/+/deviceinfo", "qos": "2", "broker": "23acb8c5.a15ad8", "x": 150, "y": 132, "wires": [["12642914.e549c7", "95d1843d.e8a5c8"]]},
            {"id": "97d0f87d.614ea8", "type": "mqtt out", "z": "ce169f53.786dd", "name": "Auto-Report Request", "topic": "", "qos": "0", "retain": "false", "broker": "23acb8c5.a15ad8", "x": 692.0001220703125, "y": 401, "wires": []},
            {"id": "12642914.e549c7", "type": "debug", "z": "ce169f53.786dd", "name": "", "active": true, "console": "false", "complete": "payload", "x": 340, "y": 112, "wires": []},
            {"id": "6bacc623.4bc318", "type": "comment", "z": "ce169f53.786dd", "name": "Send Protocol Connector  Sensor Data to Azure IoT Hub", "info": "", "x": 270, "y": 69.36331176757812, "wires": []},
            {"id": "4a9698eb.3deed8", "type": "comment", "z": "ce169f53.786dd", "name": "Send Auto-Report Request to Internal MQTT", "info": "", "x": 240, "y": 296, "wires": []},
            {"id": "3a7f0c9.34066f4", "type": "mqtt in", "z": "ce169f53.786dd", "name": "Handler Registered", "topic": "/cagent/admin/+/agentinfoack", "qos": "2", "broker": "23acb8c5.a15ad8", "x": 160, "y": 364.8398742675781, "wires": [["3cd5a503.a6b2ca"]]},
            {"id": "3cd5a503.a6b2ca", "type": "function", "z": "ce169f53.786dd", "name": "pack 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": [["97d0f87d.614ea8"]]},
            {"id": "95d1843d.e8a5c8", "type": "azureiothub", "z": "ce169f53.786dd", "name": "Send to Azure IoT Hub", "protocol": "http", "x": 370, "y": 152, "wires": [["ecc11415.86a138"]]},
            {"id": "ecc11415.86a138", "type": "debug", "z": "ce169f53.786dd", "name": "", "active": true, "console": "false", "complete": "payload", "x": 601.5, "y": 151.29998779296875, "wires": []},
            {"id": "bf50c923.03a288", "type": "comment", "z": "ce169f53.786dd", "name": "Display Cloud to Device Messages", "info": "", "x": 671, "y": 192, "wires": []},
            {"id": "71829e36.9c78c" , "type": "mqtt in", "z": "ce169f53.786dd", "name": "Handler Heartbeat", "topic": "/cagent/admin/+/notify", "qos": "2", "broker": "23acb8c5.a15ad8", "x": 157, "y": 438, "wires": [["3cd5a503.a6b2ca"]]},
            {"id": "23acb8c5.a15ad8", "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": ""}
        ]
import nr flow

Step 3. Select "Protocol Converter" tab and double click "Send to Azure IoT Hub" node to configure node settings.

select nr node

Step 4. Copy the saved device "Connection String" and paste to "Connection String" field

select nr conn string
Step 5. Click deploy icon to complete edge device environment setups and make sure the states of MQTT nodes are "connected"
nr deployed

Step 6. Jump to Monitor Messages for further steps.

Connect device and data to Azure for Linux Ubuntu device – Protocol Converter Using IoT Edge

Prerequisites

Before to perform Azure IoT Edge environment setup steps, please make sure all following packages and tools are available and are correctly setup.

Linux Host

  • Docker:

1. Install Docker and check "docker" command is available. (the version number may be different).

prerequisites-docker-linux.png

Protocol Converter will install Python and IoT Edge Runtime Control Tool automatically, user could check the version to see if it's well installed. 

  • Python pip:

1. Install Python pip command.

        sudo apt-get install python-pip

2. Make sure the “pip” command is available.

prerequisites-win-python.png
  • IoT Edge Runtime Control Tool:

1. Install IoT Edge control script (may need to run as root)

        pip install -U azure-iot-edge-runtime-ctl==1.0.0rc17

2. Make sure the “iotedgectl” command is available. (the version number may be different)

prerequisites-win-iotedgectl.png

Cloud Environment Setup

Following steps will create an azure iot edge device at previously created iot hub.

Step 1. Create an iot edge device

  • Go to iot hub created at previous section: Resource groups → protocol-conn-rg → protocol-conn-hub
select conn hub
  • IoT Edge → Add IoT Edge Device
create-iotedge-device.png
  • Device ID: protocol-conn-device (for example)
  • Authentication Type: select “Symmetric Key” for this tutorial
  • Check “Auto Generate Keys
  • Connect device to IoT Hub: select “Enable
create-iotedge-device-details
  • Select the created iot edge device to get device connection string
select-iotedge-device
  • Click save-icon.png to copy “Connection string-primary key” and make sure the "Connect device to IoT Hub" is "Enable"
select-edge-device-conn-string
  • Save the connection string in a text file for later use
conn-string.png

Device Environment Setup

Following steps will configure edge device to bind to azure iot edge device previously created.

Step 1. Configure the iot edge runtime (need administrator privileges on windows 10 host or root privileges on linux host)

  • Open a command prompt and type following command. Replace "{your iot edge device connection string}" with the saved device connection string
        sudo iotedgectl setup --connection-string "{your iot edge device connection string}" --auto-cert-gen-force-no-passwords
iotedge-setup-linux
  • Start the IoT Edge runtime
        sudo iotedgectl start
iotedge-start-linux
  • Check Docker to see that the IoT Edge agent is running as a module
        sudo docker ps

Deploy an IoT edge device module to edge device

Step 1. Select iot edge device created at previous section

select-iotedge-device

Step 2. Set Modules → Add IoT Edge Module

add-iotedge-device-module.png
  • Name: protocol-connector-module
  • Image URI: advigw4x86/protocol-connector-azure-iot-edge:latest
  • Container Create Options:
  • In Windows host, paste following content
        {
            "Env": ["MQTT_HOST=10.0.75.1", "MQTT_PORT=1883"]
        }
  • In Linux host, paste following content
        {
            "Env": ["MQTT_HOST=172.17.0.1", "MQTT_PORT=1883"]
        }
  • Restart Policy: select “always
  • Desired Status: select “running
add-device-module-detail.png
  • Click “Next” to specify routes step
add-device-module-cont.png
  • Paste following content to specify route and click “Next” to review template
        {
            "routes": {
                "moduleToIoTHub": "FROM /messages/modules/protocol-connector-module/outputs/output1 INTO $upstream"
            }
        }
add-device-module-route.png
  • In the Review Template step, click “Submit”
add-device-module-template.png
  • Return to the IoT Edge device details page and click Refresh. The "protocol-connector-module" should be running along with the IoT Edge runtime
add-device-module-done.png

Monitor Messages

.Device to Cloud (D2C)

  • Get IoT Hub Connection String from below steps.
Step 1. Go to iot hub created at "Create Azure IoT Hub" section: Resource groups → protocol-conn-rg → protocol-conn-hub
select conn hub
Step 2. Click save-icon.png to copy iot hub connection string: Resource groups → Shared access policies → iothubowner → Connection String​
Share_access_policy
        npm install -g iothub-explorer

        iothub-explorer monitor-events {Your IoT Device id} --login "{your iot hub connection string}"
iothub-explorer-win
iothub-explorer-linux
When Installing iothub-explorer on Windows system, please use administrator role to execute cmd. Otherwise, the environment variable cannot be correctly written to the system. You can add the environment variable manually. 
iothub-explorer-win_1
iothub-explorer-win_2

Cloud to Device (C2D)

  • C2D message is not yet ready on IoT Edge public preview.
  • For Node-RED protocol converter modules, we can take following steps to send C2D messages.

Step 1. Open Node-RED in web browser, select Protocol Converter and click the debug tab

select c2d message

Step 2. Go to iot device created at previous section: Resource groups → protocol-conn-rg → protocol-conn-hub → protocol-conn-device, then select "Message To Device"

select c2d message

Step 3. Type our cloud to device messages in "Message Body" field then click "Send Message".

send select c2d message

Step 4. Back to Node-RED page, we can see the received message

receive c2d message

AWS

Connect device and data to AWS for Windows device – Protocol Converter using Node-Red

Prerequisites:

  • AWS account
  • this example use service which is region in US East (N. Virginia).

Cloud Environment Setup

Step 1.Return the AWS console and go to IAM menu.
IAM1.png
Step 2.Click “user” menu
IAM2.png
Step 3.Click “Add user” button
IAM3.png
Step 4.Enter your user name. In this example user name is “Adv_test”.→ chose Programmatic access → Click “Next Permissions” button.
IAM4png

Step 5.Click IAM_GP.png

Step 6.Choose AdministratorAccess → Click “Next: Review” button
IAM6.png
Step 7.Click “Create user”
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
IAM8.png
Step 10. Go to AWS IoT Core.
AWS iot core.png
Step 11. Copy the endpoint from "Setting". The endpoint will be used in Node-Red setting later. Check if the region is N. Virginia before copying the endpint.
13 2.png

Device Environment Setup

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
8.png

Set up edge device environment

  • Copy following NodeRED flow and import it into NodeRED:
[
{"id":"79179714.505328","type":"tab","label":"Protocol Connector ","disabled":false,"info":""},{"id":"d79da03e.4ac02","type":"mqtt in","z":"79179714.505328","name":"Data Recieved","topic":"/cagent/admin/+/deviceinfo","qos":"2","broker":"7c9c4d87.a21bd4","x":150,"y":132,"wires":[["f9b3112b.9e99a","d48faaf7.aded28"]]},
{"id":"d48faaf7.aded28","type":"debug","z":"79179714.505328","name":"","active":true,"console":"false","complete":"payload","x":340,"y":112,"wires":[]},{"id":"27eaa5d8.f85fea","type":"comment","z":"79179714.505328","name":"Send Protocol Connector  Sensor Data to AWS IoT","info":"","x":260,"y":69.36331176757812,"wires":[]},{"id":"3dc94fa0.0fb2d","type":"comment","z":"79179714.505328","name":"Send Auto-Report Request to Internal MQTT","info":"","x":220,"y":296,"wires":[]},{"id":"f9b3112b.9e99a","type":"function","z":"79179714.505328","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":[["21def20a.3d43ae"]]},{"id":"a99e0e2f.e33a3","type":"mqtt out","z":"79179714.505328","name":"Auto-Report Request","topic":"","qos":"0","retain":"false","broker":"7c9c4d87.a21bd4","x":692.0001220703125,"y":401,"wires":[]},{"id":"d10bad11.60342","type":"mqtt in","z":"79179714.505328","name":"Handler Registered","topic":"/cagent/admin/+/agentinfoack","qos":"2","broker":"7c9c4d87.a21bd4","x":160,"y":364.8398742675781,"wires":[["e0848357.efe7a"]]},{"id":"e0848357.efe7a","type":"function","z":"79179714.505328","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":[["a99e0e2f.e33a3"]]},
{"id":"5b81aa8.282ba54","type":"mqtt in","z":"79179714.505328","name":"Handler Heartbeat","topic":"/cagent/admin/+/notify","qos":"2","broker":"7c9c4d87.a21bd4","x":157,"y":438,"wires":[["e0848357.efe7a"]]},
{"id":"21def20a.3d43ae","type":"AWS IotData","z":"79179714.505328","aws":"b610e400.9f9db8","operation":"Publish","thingName":"","topic":"","payload":"","endPoint":"","name":"","x":535,"y":156.75,"wires":[[]]},
{"id":"7c9c4d87.a21bd4","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":"b610e400.9f9db8","type":"amazon config","z":"","name":"AWS","region":"us-east-1"}
]
  • Switch to Protocol Converter tab and double click “IotData Publish” node to set device configuration.
  • Click button_NR.png button
    2018-02-13_145112.png

 

  • Enter the Access Id and Secret Key which is on credentials .csv file.
11.png
  • Enter the Name “IoT Pubilsh” and Endpoint, Endpoint is copied in AWS IoT Core.
2018-02-13_144939.png
  • Check your message topic on the "message topic' function node
    15-2.png
  • Enter {your device id} in device_id, you can choose {your device id} which you want.
16-2.PNG
  • Click deploy.png to finish edge device environment setups.
17-2.png
  • Click NodeRED “Debug” tab, the sent messages will be displayed. 
18-2.png
  • >Go back to AWS IoT menu
  • click “Test” and enter Subscription topic click Subscription.png
2018-02-13_152730.png
  • if your settings is correct, then you can see the message in this area.
2018-02-13_152741.png
   

Connect device and data to AWS for Linux Ubuntu device – Protocol Converter using Greengrass

Prerequisites

AWS Account Linux Host OS version : Ubuntu 16.04 x64 Protocol Converter installation steps

Create Greengrass Group

Using the AWS IoT console, create an AWS IoT thing, certificate, and policy for your AWS Greengrass core device:   Step 1. Go to the AWS IoT console and click Greengrass.
2018-02-07_105948.png
2018-02-07_110140.png
Step 2. Create an AWS Greengrass group and name it GGC
2018-02-07_110247.png
Step 3. Create an AWS IoT for Greengrass core
2018-02-07_110247.png
Step 4. One-click to create Greengrass certificate and attach policy.
2018-02-07_110405.png
Step 5. Download Certificate and Greengrass config. This Certificate will be used later for setup AWS IoT device.
2018-02-07_110435.png


Setup Greengrass Group

To define your Greengrass group, follow these steps:

  1. Add devices to your group
  2. Add Lambda functions to your group
  3. Add subscriptions to your group
Add Device to Your Group
Step 1.Go to the AWS IoT console. Step 2.In the navigation pane, select Greengrass and then Groups. Step 3.Click on your group, "GGC" Step 4.In the navigation pane, click Devices and then Add Device.
2018-02-07_114426.png
Step 5. Enter AWS IoT Name Device and click Next
2018-02-07_114443.png
Step 6. Using default setting to quick create access permissions and certificate.
2018-02-07_114456.png
Step 7. Download certificate and finish this process. This Certificate will be used for running GreenGrass Core.
2018-02-07_114508.png
Add Subscriptions to Your Group
Step 1.In the navigation pane, click Subscriptions and then Add Subscription.
SubscriptionAdd.png
Step 2.Under Select a source, select the source of the subscription and click on Next.
Subscription1.png

Step 3.Under Select a target, select the target of the subscription and click on Next.

Subscription2.png
Step 4.In the Optional topic filter, type the topic of the subscription " topic/MQTT ".
Subscription3.png
Step 5.Click on finish to confirm and save subscription.
Subscription4.png
Step 6.Review the subscription information.
Subscription done.png

Run Greengrass Core in Your Device

/greengrass is located under Installer folder, e.g. {$Unzip Path} is ~/Desktop/Installer/packages/AWS/EISXGCC 

To configure your core to recognize the AWS IoT thing, update the /greengrass/config/config.json file. and /greengrass/certs.

Copy certs and config with root permission, use the certificate for GreenGrass Core.

Step 1.sudo cp -R certs/ {$Unzip Path}/greengrass/
Step 2.sudo cp -R config/ {$Unzip Path}/greengrass/
Step 3.sudo cp root.ca.pem {$Unzip Path}/greengrass/certs/
root.ca.pem is just located under {$Unzip Path}.
If the original file under {$Unzip Path} is root-ca.pem, just rename it to root.ca.pem after copying to {$Unzip Path}/greengrass/certs/

# mv root-ca.pem root.ca.pem

The Greengrass core software is installed inside the /greengrass directory of your device.

Step 1.Make sure your device is connected to the Internet.

Step 2.sudo {$Unzip Path}/greengrass/ggc/core/greengrassd start
greengrassrun.png

Deploy Your Greengrass Group

After running Greengrass core, you can deploy your Greengrass group to your device.
Step 1.Go to the AWS IoT console.
Step 2.In the navigation pane, select Greengrass and then Groups.
Step 3.Click on your group, GGC.
Step 4.In the navigation pane, click Deployments.

Step 5.Click Actions > Deploy.  
2018-02-01_135700.png
Step 6.In the Configure how Devices discover your Core select Automatic detection.
2018-02-01_135720.png
Step 7.In the Grant permissions to access other services, click Grant permission.
2018-02-01_135731.png
When the operation is complete, the Deployment successfully completed is displayed at the top of the page.
2018-02-08_151442.png

Set Up Your AWS IoT Things

When Greengrass group is deployed successful. You can setup AWS IoT Device which is defined in Greengrass group with Protocol Converter.  

AWS IoT devices need certificates to authenticate with AWS IoT and retrieve the connectivity information of your Greengrass core. You downloaded these certificates in Add devices to your group Create device things.

Install Your IoT Thing Certificate

Use Certificate for setup AWS IoT device.
cp root-ca.pem {$Unzip Path}/ProtocolConnectorSample/certs
cp <id>.cert.pem {$Unzip Path}/ProtocolConnectorSample/certs
cp <id>.private.key {$Unzip Path}/ProtocolConnectorSample/certs

Configure The Samples

Inside the ProtocolConnectorSample/config/ directory you can find the configuration files SampleConfig.json for your things:
1. Please find your endpoint in Settings page in AWS IoT Console.
2. Fill in relative path of root-ca.pem.
3. Fill in relative path of <id>.cert.pem.
4. Fill in relatvie path of <id>.private.key

5. Fill in your device name that you added for GreenGrass group in the following three fields.
2018-02-09 16-17-16.png

Run the Protocol Converter Sample

After setting AWS IoT you can execute protocol converter sample, In the ProtocolConnectorSample folder

./MQTTAgent-sample
2018-02-09 16-18-09.png

IoT connectivity

How to use SUSI (Advantech HW information) plugin

Page under construction...

How to use Modbus plugin

Please visit this page for more details and plugin configuration.

How to use OPC-UA plugin

Currently our OPC-UA plugin is only available on Windows platform. Please visit this page for more details and plugin configuration.

How to use PMQ plugin

Advantech storage PMQ solution includes the deployment of the trained model to make predictions and visualization UI, and recommendations for corresponding strategies. Except storage PMQ service for Advantech hardware, the objective is to provide software developers basic concepts and better understating of PMQ deployment and to be more effective to bring your predictive model to production with Advantech PMQ architecture.

Visit this page for more details.

Release

Pages under construction...