Skip to content

Commit cdb3f1a

Browse files
author
Wayne Ren
authored
Merge pull request #28 from BabaYB/secureshield_aws_app
add a new aws iot application using secureshield
2 parents 797d98c + 221e390 commit cdb3f1a

27 files changed

+4922
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Copyright (c) 2019, Synopsys, Inc. All rights reserved.
2+
3+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
4+
5+
1) Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
6+
7+
2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8+
9+
3) Neither the name of the Synopsys, Inc., nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
10+
11+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
# AWS IoT Smarthome Secureshield Application
2+
This application is designed to show how to connect only 1 EMSK and [AWS IoT Cloud](https://aws.amazon.com/iot/?nc1=h_ls) using embARC. The connection between EMSK and AWS IoT Cloud is secured by TLS. The program is secured by secureshield.
3+
4+
## Hardware and Software Setup
5+
### Required Hardware
6+
- [DesignWare ARC EM Starter Kit(EMSK)](https://www.synopsys.com/dw/ipdir.php?ds=arc_em_starter_kit)
7+
- [Digilent PMOD WiFi(MRF24WG0MA)](http://store.digilentinc.com/pmodwifi-wifi-interface-802-11g/)
8+
- [Digilent PMOD TMP2](http://store.digilentinc.com/pmod-tmp2-temperature-sensor/)
9+
- SD Card
10+
- WiFi Hotspot(SSID:**embARC**, Password:**qazwsxedc**, WPA/WPA2 encypted)
11+
12+
### Required Software
13+
- Metaware or ARC GNU Toolset
14+
- Serial port terminal, such as putty, tera-term or minicom
15+
16+
### Hardware Connection
17+
1. Connect PMOD WiFi to J5, connect PMOD TMP2 to J2.
18+
![EMSK Connections](doc/screenshots/emsk_connections.jpg)
19+
20+
2. Configure your hardware with proper core configuration.
21+
22+
## User Manual
23+
### Before running this application
24+
Prepare you own AWS IoT account, and create required thing.
25+
Before compiling this example, you need to change macro **AWS_IOT_MQTT_HOST** in `src/aws_iot_config.h` to your own aws iot cloud mqtt host, and create an aws iot thing named **SmartHome**, you can refer to [Gettting Started with AWS IoT](https://docs.aws.amazon.com/iot/latest/developerguide/iot-gs.html) for details, and generate certificates and download them and rename them to the ones under `src/cert/smarthome/`.
26+
27+
We also provided an application note about [Using a Smart Home Iot Application with EMSK](https://www.embarc.org/pdf/embARC_appnote_how_to_use_smart_home_iot.pdf).
28+
29+
Copy `src/cert/` folder to root folder of the EMSK SD card, in SD card, the cert folder should be `cert/`.
30+
31+
The hardware resources are allocated as following table.
32+
33+
| Hardware Resource | Represent |
34+
| ------------------- | ------------------------------------------------------------- |
35+
| BUTTON R | Livingroom Lights Control |
36+
| LED 0-1 | Livingroom Lights Status(On or Off) |
37+
| BUTTON L | Kitchen Lights Control |
38+
| LED 2-3 | Kitchen Lights Status(On or Off) |
39+
| BUTTON X | Front Door Lock Control |
40+
| LED 4-5 | Front Door Lock Status(On or Off) |
41+
| LED 7 | WiFi connection status(On for connected, Off for not) |
42+
| LED X | Node working status(toggling in 2s period if working well) |
43+
| PMOD TMP2 | Temperature Sensor |
44+
| PMOD WiFi | Provide WiFi Connection |
45+
46+
EMSK can send the status of the Room Temperature, FrontDoor Lock status, LivingRoom Light status and Kitchen Light status to the AWS IoT and interact with AWS IoT Cloud with using embARC.
47+
48+
Open [dashboard website](http://foss-for-synopsys-dwc-arc-processors.github.io/freeboard/), and load `dashboard-smarthome-singlething.json` dashboard configuration file in current folder, and then you can control and monitor this single node.
49+
50+
After loading this configuration file, you also need to click at the setting icon, and then click on the aws datasource, and then change the **AWS IOT ENDPOINT**, **REGION**, **ACCESS KEY**, **SECRET KEY** to your own aws ones.
51+
![embARC AWS Smart Home Dashboard Setting - Step1](doc/screenshots/webapp_setting1.jpg)
52+
![embARC AWS Smart Home Dashboard Setting - Step2](doc/screenshots/webapp_setting2.jpg)
53+
54+
The JSON Document in the AWS IoT cloud is shown below.
55+
```json
56+
{
57+
"reported": {
58+
"temperature": 0.00,
59+
"DoorLocked": false,
60+
"KitchenLights": false,
61+
"LivingRoomLights": false
62+
},
63+
"desired": {
64+
"DoorLocked": false,
65+
"KitchenLights": false,
66+
"LivingRoomLights": false
67+
}
68+
}
69+
```
70+
71+
### Run this application
72+
Here take **EMSK2.3 - ARC EM7D** with Metaware Toolset for example to show how to run this application.
73+
74+
1. Open Windows or Linux terminal, and cd to `src` folder.
75+
76+
2. To build this applicaiton, select the proper board version, core configuration and build with selected toolchain using this command `gmake BD_VER=23 CUR_CORE=arcem7d TOOLCHAIN=mw` :
77+
```
78+
<app folder>\src>gmake BD_VER=23 CUR_CORE=arcem7d TOOLCHAIN=mw
79+
"Creating Directory : " obj_emsk_23/mw_arcem7d/application/.
80+
"Creating Directory : " obj_emsk_23/mw_arcem7d/arc
81+
... ...
82+
"Assembling : " ../../../../arc/startup/arc_startup.s
83+
"Compiling : " ../../../../arc/startup/arc_cxx_support.c
84+
"Generating Linkfile : " obj_emsk_23/mw_arcem7d/linker_mw.ldf
85+
"Compiling : " main.c
86+
"Compiling : " ../../../../device/designware/spi/dw_spi.c
87+
"Compiling : " ../../../../device/designware/iic/dw_iic.c
88+
"Compiling : " ../../../../device/designware/uart/dw_uart.c
89+
"Compiling : " ../../../../device/microchip/mrf24g/mrf24g_adapter.c
90+
... ...
91+
"Archiving : " obj_emsk_23/mw_arcem7d/libmidcommon.a
92+
"Archiving : " obj_emsk_23/mw_arcem7d/libmidaws.a
93+
"Archiving : " obj_emsk_23/mw_arcem7d/libmidlwip.a
94+
"Archiving : " obj_emsk_23/mw_arcem7d/libmidfatfs.a
95+
"Archiving : " obj_emsk_23/mw_arcem7d/libembarc.a
96+
"Linking : " obj_emsk_23/mw_arcem7d/freertos_iot_aws_smarthomedemo_mw_arcem7d.elf
97+
```
98+
All object files are generated under the `obj_emsk_23/mw_arcem7d` folder according to your choice.
99+
The application elf file is also generated in that folder.
100+
101+
3. Connect PMOD WiFi to J5, PMOD TMP2 to J2.
102+
103+
4. Plug the USB cable into the J7 port(JTAG and USB-UART) on EMSK, power on the board, and setup your WiFi hotspot.
104+
105+
5. Configure the EMSK 2.3 to ARC EM7D core by setting the dip switch bit 1-2 all to OFF, then reload the core configuration by press the button above **C** character on board.
106+
107+
6. Open your serial terminal such as Tera-Term on PC, and configure it to right COM port and *115200bps*.
108+
109+
7. Run this application using this command `gmake BD_VER=23 CUR_CORE=arcem7d TOOLCHAIN=mw run` :
110+
![Run the AWS IoT Smarthome Application in command line](doc/screenshots/run_cmd.jpg)
111+
112+
8. Interact using EMSK and Dashboard.
113+
- You can press the **button L/R/X** to see the led changes on board and also on dashboard web app.
114+
- You can also click the lights of **DESIRED STATUS** pane on the dashboard app, and see the led changes on board and dashboard web app.
115+
![AWS IoT Smarthome Single Node Web App](doc/screenshots/webapp.jpg)
Lines changed: 237 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,237 @@
1+
{
2+
"version": 1,
3+
"allow_edit": true,
4+
"plugins": [],
5+
"panes": [
6+
{
7+
"width": 1,
8+
"row": {
9+
"3": 1
10+
},
11+
"col": {
12+
"3": 1
13+
},
14+
"col_width": "3",
15+
"widgets": [
16+
{
17+
"type": "picture",
18+
"settings": {
19+
"src": "https://embarc.org/images/embarc_logo-bright.png",
20+
"refresh": 18000
21+
}
22+
}
23+
]
24+
},
25+
{
26+
"title": "SmartHome Dashboard for AWS IoT Cloud",
27+
"width": 1,
28+
"row": {
29+
"3": 11,
30+
"5": 11
31+
},
32+
"col": {
33+
"3": 1,
34+
"5": 1
35+
},
36+
"col_width": "3",
37+
"widgets": [
38+
{
39+
"type": "text_widget",
40+
"settings": {
41+
"size": "regular",
42+
"value": "SmartHome Dashboard: ARC EMSK and AWS IoT Cloud Solution",
43+
"animate": true
44+
}
45+
}
46+
]
47+
},
48+
{
49+
"title": "Reported Status",
50+
"width": 1,
51+
"row": {
52+
"3": 15,
53+
"4": 1,
54+
"5": 1,
55+
"7": 1
56+
},
57+
"col": {
58+
"3": 3,
59+
"4": 2,
60+
"5": 2,
61+
"7": 2
62+
},
63+
"col_width": "1",
64+
"widgets": [
65+
{
66+
"type": "gauge",
67+
"settings": {
68+
"title": "Home Temperature",
69+
"value": "datasources[\"aws\"][\"SmartHome\"][\"reported\"][\"temperature\"].toFixed(2)",
70+
"units": "C",
71+
"min_value": "-20",
72+
"max_value": "60"
73+
}
74+
},
75+
{
76+
"type": "indicator",
77+
"settings": {
78+
"title": "Home Door Lock",
79+
"value": "datasources[\"aws\"][\"SmartHome\"][\"reported\"][\"DoorLocked\"]",
80+
"on_text": "LOCKED",
81+
"off_text": "UNLOCKED"
82+
}
83+
},
84+
{
85+
"type": "indicator",
86+
"settings": {
87+
"title": "Living Room Lights",
88+
"value": "datasources[\"aws\"][\"SmartHome\"][\"reported\"][\"LivingRoomLights\"]",
89+
"on_text": "ON",
90+
"off_text": "OFF"
91+
}
92+
},
93+
{
94+
"type": "indicator",
95+
"settings": {
96+
"title": "Kitchen Lights",
97+
"value": "datasources[\"aws\"][\"SmartHome\"][\"reported\"][\"KitchenLights\"]",
98+
"on_text": "ON",
99+
"off_text": "OFF"
100+
}
101+
}
102+
]
103+
},
104+
{
105+
"title": "CONNECTION STATUS",
106+
"width": 1,
107+
"row": {
108+
"3": 15,
109+
"5": 7,
110+
"7": 7
111+
},
112+
"col": {
113+
"3": 1,
114+
"5": 1,
115+
"7": 1
116+
},
117+
"col_width": 1,
118+
"widgets": [
119+
{
120+
"type": "interactive_indicator",
121+
"settings": {
122+
"title": "AWS IOT CONNECTION STATUS",
123+
"value": "datasources[\"aws\"][\"connected\"]",
124+
"callback": "datasources[\"aws\"][\"connected\"]",
125+
"on_text": "CONNECTED",
126+
"off_text": "DISCONNECTED"
127+
}
128+
},
129+
{
130+
"type": "interactive_indicator",
131+
"settings": {
132+
"title": "DEVICE DATA READY STATUS",
133+
"value": "datasources[\"aws\"][\"SmartHome\"][\"ready\"]",
134+
"callback": "datasources[\"aws\"][\"SmartHome\"][\"ready\"]",
135+
"on_text": "READY",
136+
"off_text": "NOT READY"
137+
}
138+
}
139+
]
140+
},
141+
{
142+
"title": "HOME TEMPERATURE",
143+
"width": 1,
144+
"row": {
145+
"3": 15,
146+
"5": 7,
147+
"7": 7
148+
},
149+
"col": {
150+
"3": 2,
151+
"5": 2,
152+
"7": 2
153+
},
154+
"col_width": 1,
155+
"widgets": [
156+
{
157+
"type": "sparkline",
158+
"settings": {
159+
"title": "Temperature History",
160+
"value": [
161+
"datasources[\"aws\"][\"SmartHome\"][\"reported\"][\"temperature\"]"
162+
],
163+
"include_legend": true,
164+
"legend": "C"
165+
}
166+
}
167+
]
168+
},
169+
{
170+
"title": "Desired Status",
171+
"width": 1,
172+
"row": {
173+
"3": 21,
174+
"5": 13,
175+
"7": 13
176+
},
177+
"col": {
178+
"3": 1,
179+
"5": 1,
180+
"7": 1
181+
},
182+
"col_width": 1,
183+
"widgets": [
184+
{
185+
"type": "interactive_indicator",
186+
"settings": {
187+
"title": "Home Door Lock ",
188+
"value": "datasources[\"aws\"][\"SmartHome\"][\"desired\"][\"DoorLocked\"]",
189+
"callback": "datasources[\"aws\"][\"SmartHome\"][\"desired\"][\"DoorLocked\"]",
190+
"on_text": "LOCKED",
191+
"off_text": "UNLOCKED"
192+
}
193+
},
194+
{
195+
"type": "interactive_indicator",
196+
"settings": {
197+
"title": "Living Room Lights",
198+
"value": "datasources[\"aws\"][\"SmartHome\"][\"desired\"][\"LivingRoomLights\"]",
199+
"callback": "datasources[\"aws\"][\"SmartHome\"][\"desired\"][\"LivingRoomLights\"]",
200+
"on_text": "ON",
201+
"off_text": "OFF"
202+
}
203+
},
204+
{
205+
"type": "interactive_indicator",
206+
"settings": {
207+
"title": "Kitchen Lights",
208+
"value": "datasources[\"aws\"][\"SmartHome\"][\"desired\"][\"KitchenLights\"]",
209+
"callback": "datasources[\"aws\"][\"SmartHome\"][\"desired\"][\"KitchenLights\"]",
210+
"on_text": "ON",
211+
"off_text": "OFF"
212+
}
213+
}
214+
]
215+
}
216+
],
217+
"datasources": [
218+
{
219+
"name": "aws",
220+
"type": "aws_iot",
221+
"settings": {
222+
"endpoint": "input_your_own_endpoint",
223+
"region": "input_your_own_region",
224+
"clientId": "",
225+
"accessKey": "input_your_own_accesskey",
226+
"secretKey": "input_your_own_secretKey",
227+
"things": [
228+
{
229+
"thing": "SmartHome"
230+
}
231+
],
232+
"name": "aws"
233+
}
234+
}
235+
],
236+
"columns": 3
237+
}
106 KB
Loading
165 KB
Loading
66.3 KB
Loading
38.3 KB
Loading
103 KB
Loading

0 commit comments

Comments
 (0)