6.5.2 Running the Application

  1. 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:
    1. Right click and open the Git Bash in the tools folder
      Figure 6-38. Git Bash
    2. 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.
      Figure 6-39. Running create_initial_setup.sh
    3. Up on successful execution of above command, following three new folders will be created
      Figure 6-40. Setup Folders
  2. Device Certificate
    1. 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).
      Figure 6-41. Unique Device ID
      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.
      Figure 6-42. create_device_certificate.sh
    2. 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
    3. Use the PC companion mode of the setup and program the .pem and * .key* files (highlighted/marked below) using file_upload tools. For more details on file_upload tools, refer to the 7.1 Certificate and Key Utility
      Figure 6-43. Certificate and Key File
  3. Creating a Microsoft Azure Account and Azure IoT Central Application
    1. For new users, create a new Azure Account
    2. Log into the Azure Portal using the new/existing account
    3. Create an IoT Central application by clicking on Create a resource>Internet of Things>IoT Central application
      Figure 6-44. Create A Resource
      Figure 6-45. IOT Central Application
    4. Under Subscription create a new group (say RNWF) to manage it's resources and cost
    5. Provide the resource name and Application URL to view/manage the IoT Central devices
      Figure 6-46. IOT Central Application
    6. Open the Azure Central Applicaiton and build a new App
      Figure 6-47. Building IOT Application
      Figure 6-48. New Application Details
    7. Select the application and navigate to Permision>Device connection groups
      Figure 6-49. Application Portal Enrollment
    8. Note down the information of ID scope and click + New as illustrated above to create an enrollment group
    9. Provide a name for the enrollment group and select Attestation Type as Certificates (X.509)
      Figure 6-50. Creating New Enrollment Group
    10. Save the enrollment group and click on Primary>Manage primary to manage the Primary certificate and select the subordinate CA certificate generated in the Step 1 (Create a Root of Trust Chain for RNWF Devices) subca.crt certificate inside the subca folder.
    11. Mount the AVR128DB48 Curiosity Nano host board and the RNWF02 Add On Board on Curiosity Nano base board at respective headers. For more details about the boards placement in the Curiosity Nano base, see Figure 6-1.
    12. Connect the debugger USB port on the AVR128DB48 Curiosity Nano board to computer using a micro USB cable
    13. Open the project and launch MCC with Melody Content Manager Tool
    14. Configure Home-AP credentials for STA mode, using the Wi-Fi settings configuration. For more details about the Wi-Fi settings configuration, See Figure 3-14.
    15. Update the Azure Cloud configuration with following details. For more details about the Azure Cloud configuration, See Figure 3-21
      1. ID Scope noted in Step 3.g (Creating a Microsoft Azure Account and Azure IoT Central Application, see Figure 6-49), update this scope ID in Azure Cloud configuration as illustrated below
        Figure 6-51. Scope ID
      2. Unique Device ID (Common Name) noted in Step 2.a (Device Certificate, see Figure 6-41), update this Unique Device ID in Azure Cloud configuration as illustrated below
        Figure 6-52. User Name
        Figure 6-53. Publish Topic Name
      3. Device Certificate and Key file names noted in Step 2.c (Device Certificate, see Figure 6-43), update this in Azure Cloud configuration as illustrated below
        Figure 6-54. Device Certificate and Key
    16. Generate the code as illustrated below
      Figure 6-55. Generating the Code
    17. Build and program the code to the hardware using MPLAB X IDE
      Figure 6-56. Programming the Board
    18. Open the Terminal application (for example: Tera Term or PuTTY) on the PC
    19. Connect to the host board COM port and configure the serial settings as follows:
      1. Baud: 115200
      2. Data: 8 Bits
      3. Parity: None
      4. Stop: 1 Bit
      5. Flow Control: None
    20. Press the SW0 (Soft Reset) button on the host board, see Figure 6-1.
    21. 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) and starts sending the telemetry
      Figure 6-57. Device Echo Message Log
    22. After the successful connection to Azure IoT Central, the device gets listed in the Azure Central Applicaiton> Devices view.
      Figure 6-58. Device Connection to Azure IoT Central
    23. Click on the device name to view the device About, Overview, Commands, Raw data tabs as follows
      Figure 6-59. Device Details
    24. The Overview tab shows the default Telemetry graph, the Overview can be modified by adding other parameters through the Device Templates>(Model)>Views>Overview
    25. New views can be added through the Device Templates>(Model)>Views
      Figure 6-60. New Views
    26. Example add a Properties View tab and all the properties, now through the Properties view one can change the LED status on the board and Telemetry Reporting Rate. Make sure to Save the new values.
      Figure 6-61. Device Properties
    27. The Commands view can be used to trigger a device Reset at a given time in the ISO format (Example PT5S for 5 seconds) or to send messages (echoed from device) to the device.
      Figure 6-62. Device Commands
      Figure 6-63. Device Reset
      Figure 6-64. Device Reboot Log
    28. The SW0 press from the device will be notified to the Azure Cloud in the Raw data view
      Figure 6-65. Raw Data View