Lab 8-WiFi Lab
Lab 8-WiFi Lab
Lab 8-WiFi Lab
LAB 8
WiFi Lab
Issue 1.0
Copyright © 2023 Arm Limited (or its affiliates). All rights reserved.
Contents
1 Introduction ............................................................................................ 1
1.1 Lab overview .......................................................................................................................... 1
2 Arm Pelion Device Management ............................................................. 1
2.1 Connecting devices................................................................................................................. 1
2.2 Managing devices ................................................................................................................... 2
2.3 Updating device firmware ...................................................................................................... 3
3 Implementation ...................................................................................... 4
3.1 Setting up the Arm Pelion Platform ....................................................................................... 4
3.2 Setting up board ..................................................................................................................... 4
3.2.1 Setting up WiFi ............................................................................................................... 4
3.2.2 Creating M2M resources ................................................................................................ 5
3.2.3 Adding API key and connect certificate .......................................................................... 5
4 Application Code ..................................................................................... 5
4.1 Program structure .................................................................................................................. 5
Copyright © 2023 Arm Limited (or its affiliates). All rights reserved.
1 Introduction
1.1 Lab overview
In this lab we will learn how to program the DISCO-L475VG-IOT01A board that has an on-board WiFi
module to send and receive sensor data from the Arm Pelion platform. This lab consists of two parts;
the first part includes setting up the board to send sensor values using WiFi and the second part
includes setting up the Arm Pelion platform to view the sensor values from our board.
• A secure connection, over which we can interact and manage our IoT devices.
• A dashboard that gives summary of our account like devices’ status and usage.
• Access Management for creating API keys to grant access to the device management portal.
• An end-to-end remote firmware update solution, including support for delta updates
suitable for low-bandwidth and mesh-based networks.
• A flexible provisioning mechanism that can work with any factory setup to give our device all
the information it needs to connect to Device Management.
• Device ID: It is a unique ID generated by Device Management when the device connects for
the first time. APIs can use this ID to refer to the device.
Copyright © 2023 Arm Limited (or its affiliates). All rights reserved.
Page 1
• Endpoint name: The name that is given to our device in the factory. This usually is the same
as the device ID
• Bootstrapping: The device first connects to the bootstrap service, which provides
the LwM2M server account credentials for registration.
• Registration: In this process the device directly connects to the LwM2M server using the
credentials received during bootstrapping.
• Resources
Resources are sensors and actuators in a device. Device Resource management means, for
example, reading a temperature value or controlling a device-activated door lock. You can
use the Device Management services to manage device resources and execute actions on
the devices. Resource management is based on read, write, create, and execute operations.
All communication to the device is asynchronous and the result of an operation is delivered
as an event through the event notification channel. To ensure the delivery, Device
Management queues the operations and provides protocol agnostic retry logic.
Resource model has a hierarchical data structure representing the device information
using Objects and Resources.
The device application creates and owns the resource structure:
• Object: An Object is a collection of Resources in the device. It is an “interface” to a
temperature sensor, for example.
Copyright © 2023 Arm Limited (or its affiliates). All rights reserved.
Page 2
Figure 1: Sample Data Structure
Copyright © 2023 Arm Limited (or its affiliates). All rights reserved.
Page 3
• A number, called the public key, which corresponds to the secret.
To sign a document, the holder of the private key first computes a hash of the manifest using
SHA256 and then transforms that hash using the private key. This new number, called
the signature, is appended to the document. Later, anyone with the public key can verify that
the signature matches the document by:
• Computing a hash of the document using SHA256.
• Transforming the signature back into a hash using the public key.
3 Implementation
3.1 Setting up the Arm Pelion Platform
To use the Arm Pelion Device Management services we just need to sign up using our existing Mbed
account at https://portal.mbedcloud.com/
Once the account is set-up, we can create API keys under Access Management. API keys allow
applications (mobile, web, and so on) to access the Device Management service APIs for a specific
team and its devices. To create a new API key:
1. Click New API key in Access Management > API keys,
Copyright © 2023 Arm Limited (or its affiliates). All rights reserved.
Page 4
We initially set the default network instance,
NetworkInterface::get_default_instance();
This code snippet binds a resource (any value) with a web path /3000/0/5701. The path can be
specified randomly. Any update of the resource can be pushed to the Pelion platform through M2M
protocols, by calling the function set_value(), and you can view the updates simultaneously on the
portal.
4 Application Code
In this lab exercise we will write a program that reads the temperature and humidity values from the
sensors on-board every 5 seconds. We will then send these values to the Arm Pelion device
management platform.
o Initialize variables.
Copyright © 2023 Arm Limited (or its affiliates). All rights reserved.
Page 5
• Handlers
o Update sensor readings.
o Raise a flag that indicates that the measurements need to be read and displayed again.
• Main function
o Initialize sensors.
o Initialize WiFi.
o Create resources and send values.
Copyright © 2023 Arm Limited (or its affiliates). All rights reserved.
Page 6