6.2.5.1 Building and Running the Azure Cloud Demo Application
Building the Application
To build this application, open the project file
(apps/azure_demo/azure_demo_sam_e54_xpro_rnwf02.X/
) in MPLAB X
IDE. For more details on opening the project file in MPLAB X IDE, refer to the Opening, Building and Programming the Existing Application . The following
table provides details on the project file.
Project Name | Description |
---|---|
azure_demo_sam_e54_xpro_rnwf02.X |
|
Running the Application
- Create a Root of Trust Chain
for RNWF Devices:The demo application includes a set of tools in
../apps/azure_cloud/tools
folder. It enables easy creation of certificate infrastructure and individual device certificates with very minimal user inputs.Note:- On Windows Operating Systems, make sure the GitBash is installed to run these tools.
- These scripts are based on the Azure’s Create and Upload Certificates for Testing tutorial.
- Right click and open the Git Bash in the tools folder
- Run the create_initial_setup.sh as illustrated in the following figure. It will request the user to provide the domain suffix and common name for Root CA.
- Up on successful execution of above command, following three new folders will be created
- Device Certificate
- Run the
create_device_certificate.sh
to create individual device certificate. It requests the user to provide Subordinate/Intermediate CA folder name and a unique device id (Common Name).Note:- Note down the information of device ID or common name for later use in Azure configuration.
- In order
to modify the default subject identifier information,
open the
create_device_certificate.sh
and update the following macros.
- On successful
execution of device certificate, a new folder is created inside the
../tools/devcerts
folder as illustrated in following figure.Note: Note down the information of certificate and key file names (by default device ID or common name) for use later in the Azure TLS configuration. - Use the PC companion mode of the setup and program the .pem and * .key* files (highlighted/marked below) using file_upload tools.
- Run the
-
To establish a connection with a Azure IoT Hub without using Azure DPS or configuring Azure IoT Central service, follow Appendix A.1.
Note:- This is applicable to
only
v2.0.0
and above Azure Cloud Demo. - In 32-bit Azure Cloud demo application the authentication type is X.509 Self-Signed.
- This is applicable to
only
- Connect the debugger USB port on the SAM E54 Xplained Pro evaluation kit to computer using a micro USB cable.
- Open the project and launch MCC with Harmony3.
- Change the configuration. There
are two options to change the configuration:
- Option 1: Change the
configuration manually in the code.
- Open the code in
MPLAB IDE v6.00 or higher and add Home AP and device information
in the application code.
- In
configuration.h
, add Wi-Fi configurations inSYS_RNWF_WIFI_STA_SSID
,SYS_RNWF_WIFI_STA_PWD
,SYS_RNWF_STA_SECURITY
. - In
configuration.h
, add Serial Number (Common Name) in the macroSYS_RNWF_MQTT_CLIENT_ID
. For example, in a certificate, this value is the same assn012362DA8ABEC97F01
. For more details, see Figure 6-97. The device ID will be listed as shown in the following figure. - In
configuration.h
, add IoT hub’s URL in the macroSYS_RNWF_MQTT_CLOUD_URL
(see the following figure). - In
configuration.h
, add username in formatiothub broker url}/{registration_id}/?api-version=2021-04-12
to macroSYS_RNWF_MQTT_CLOUD_USER_NAME
. Replace{iothub broker url}
with URL of your IOT hub and{registration_id}
with Serial Number (Common Name). - Similarly, in configuration.h,
SYS_RNWF_MQTT_TOPIC_NAME
is in formatdevices/{registration_id}/messages/events/
. Replace{registration_id}
with Serial number (Common Name).
- In
- Open the code in
MPLAB IDE v6.00 or higher and add Home AP and device information
in the application code.
- Option 2: Change the
configuration via MCC.
- For more details
about Wi-Fi configurations, refer Figure 3-69.
- The
following fields can be configured via MCC Wi-Fi
settings:
- SSID
- Security Type
- Passphrase
- The
following fields can be configured via MCC Wi-Fi
settings:
- Refer Figure 3-75 to understand how to make Cloud
Configuration changes
- The
following fields can be configured via MCC settings.
- Cloud URL
- Replace with IOT hub’s URL.
This value is displayed on the Overview tab of the IoT Hub webpage (see Figure 6-96).
- Replace with IOT hub’s URL.
- Client ID
- Add Serial Number (Common Name). Note: Go to “Devices” in the IoT Hub. The user can find the Serial Number in the device list (see Figure 6-95).
- Add Serial Number (Common Name).
- Username
- The format of username field is
{iothub broker url}/{registration_id}/?api-version=2021-04-12
. Replace{iothub broker url}
with IoT hub’s URL and{registration_id}
with Serial Number (Common Name).
- The format of username field is
- Publish Topic Name
- The format of publish topic name is
devices/{registration_id}/messages/event
. Replace{registration_id}
with the user’s Client ID.
- The format of publish topic name is
- Cloud URL
- The
following fields can be configured via MCC settings.
- For more details
about Wi-Fi configurations, refer Figure 3-69.
- Option 1: Change the
configuration manually in the code.
- Generate the code as illustrated below.
- Build and program the code to the hardware using MPLABX IDE.
- Open the Terminal application
(for example, Tera Term or PuTTY) on the PC.
- Connect to the EDBG Virtual COM Port and configure the serial settings
as follows:
- Baud: 115200
- Data: 8 Bits
- Parity: None
- Stop: 1 Bit
- Flow Control: None
- Connect to the EDBG Virtual COM Port and configure the serial settings
as follows:
- Press the Reset button on the host board, see Figure 6-58.
- As the board boots up, application will list available certificates and keys on RNWF02 board. The board will connect to Home-AP configured. After this, the demo will attempt to connect to Azure IoT Hub (using link configured it sends telemetry data for button press events and its count to the cloud). To verify the device-to-cloud and cloud-to-device telemetry, go to Install and use Azure IoT explorer.