Mbed OS and Pelion Device Management example over WIFI for RHOMBIO_L476DMW1K IoT kit

DEPRECATED

This example application is not maintained and not recommended. It uses an old version of Mbed OS, Pelion DM, and Arm toolchain. It doesn't work with Mbed Studio.

Please use: https://os.mbed.com/teams/mbed-os-examples/code/mbed-os-example-pelion/

This example is known to work great on the following platforms:

RHOMBIO_L476DMW1K over WiFI and using onboard QSPI flash.

/media/uploads/galonso/rhombio_l476dmw1k_kit_assembled.png

Follow the Quick-Start instructions: https://cloud.mbed.com/quick-start

Example functionality

This example showcases the following device functionality:

  • Read onboard MCU ADC temperature and MCU ADC voltage reference, and report them as Pelion LWM2M resources (see image below).
  • On user button click, increment Pelion LWM2M button resource.
  • Allow the user to change the state of the board LED from Pelion LWM2M led_state resource and PUT request.
  • External sensors can be easily added to the kit and then sensor readings reported as Pelion LWM2M resources.

/media/uploads/galonso/temperature_-_sensor_value_-_pelion_device_management_portal.png

Use this example with Mbed CLI

1. Import the application into your desktop:

mbed import https://os.mbed.com/teams/Rhombio/code/pelion-example-rhombio-l476dmw1k

cd pelion-example-rhombio-l476dmw1k

2. Install the CLOUD_SDK_API_KEY

mbed config -G CLOUD_SDK_API_KEY <PELION_DM_API_KEY>

For instructions on how to generate your API key, please see the documentation.

3. Initialize firmware credentials (done once per repository). You can use the following command:

mbed dm init -d "<your company name in Pelion DM>" --model-name "<product model identifier>" -q --force

If above command do not work for your Mbed CLI, please consider upgrading Mbed CLI to version 1.8.x or above.

4. Compile and program:

mbed compile -t <toolchain> -m RHOMBIO_L476DMW1K -f

(supported toolchains : GCC_ARM / ARM / IAR)

5. You can connect on a virtual terminal/COM port to the platform using:

mbed sterm -b 115200

This should give you an output similar to:

[BOOT] Mbed Bootloader
[BOOT] ARM: 0000000000000000000000000000000000000000
[BOOT] OEM: 0000000000000000000000000000000000000000
[BOOT] Layout: 0 800D24C
[BOOT] Active firmware integrity check:
[BOOT] SHA256: 9036E19F1414720659B2C2FAC8855F621AF533BA211D930119720E7A2BD60BF2
[BOOT] Version: 1558516039
[BOOT] Slot 0 is empty
[BOOT] Active firmware up-to-date
[BOOT] Application's start address: 0x8010400
[BOOT] Application's jump address: 0x8010889
[BOOT] Application's stack address: 0x20018000
[BOOT] Forwarding to application...

Starting Simple Pelion Device Management Client example
You can hold the user button during boot to format the storage and change the device identity.

Connecting to the network using Wifi...
Connected to the network successfully. IP address: 192.168.1.201
Initializing Pelion Device Management Client...
Initialized Pelion Client. Registering...
Registered to Pelion Device Management. Endpoint Name: 016a***********************10006d
                                                             
ADC temp: 23.1746 C,  vref: 0.3665 V         
                                                             
ADC temp: 23.2234 C,  vref: 0.3663 V      
Committer:
galonso@rhomb.io
Date:
Wed May 22 11:17:54 2019 +0200
Revision:
4:2aee28e71add
Parent:
0:9ff56a0e4c0d
new bootloader added

Who changed what in which revision?

UserRevisionLine numberNew contents of line
galonso@rhomb.io 0:9ff56a0e4c0d 1 {
galonso@rhomb.io 0:9ff56a0e4c0d 2 "target_overrides": {
galonso@rhomb.io 0:9ff56a0e4c0d 3 "*": {
galonso@rhomb.io 0:9ff56a0e4c0d 4 "target.components_remove" : ["FLASHIAP"],
galonso@rhomb.io 0:9ff56a0e4c0d 5 "target.extra_labels_remove" : ["PSA"],
galonso@rhomb.io 0:9ff56a0e4c0d 6 "platform.stdio-baud-rate" : 115200,
galonso@rhomb.io 0:9ff56a0e4c0d 7 "platform.stdio-convert-newlines" : true,
galonso@rhomb.io 0:9ff56a0e4c0d 8 "mbed-trace.enable" : null,
galonso@rhomb.io 0:9ff56a0e4c0d 9 "mbed-cloud-client.external-sst-support" : null,
galonso@rhomb.io 0:9ff56a0e4c0d 10 "nsapi.default-wifi-security" : "WPA_WPA2",
galonso@rhomb.io 0:9ff56a0e4c0d 11 "nsapi.default-wifi-ssid" : "\"SSID\"",
galonso@rhomb.io 0:9ff56a0e4c0d 12 "nsapi.default-wifi-password" : "\"Password\""
galonso@rhomb.io 0:9ff56a0e4c0d 13 },
galonso@rhomb.io 0:9ff56a0e4c0d 14 "RHOMBIO_L476DMW1K": {
galonso@rhomb.io 0:9ff56a0e4c0d 15 "target.macros_remove" : ["MBED_TICKLESS"],
galonso@rhomb.io 0:9ff56a0e4c0d 16 "target.components_add" : ["QSPIF"],
galonso@rhomb.io 0:9ff56a0e4c0d 17 "target.network-default-interface-type" : "WIFI",
galonso@rhomb.io 0:9ff56a0e4c0d 18 "esp8266.provide-default" : true,
galonso@rhomb.io 0:9ff56a0e4c0d 19 "esp8266.tx" : "PA_2",
galonso@rhomb.io 0:9ff56a0e4c0d 20 "esp8266.rx" : "PA_3",
galonso@rhomb.io 0:9ff56a0e4c0d 21 "device-management.flash-start-address" : "0x08000000",
galonso@rhomb.io 0:9ff56a0e4c0d 22 "device-management.flash-size" : "(1024*1024)",
galonso@rhomb.io 0:9ff56a0e4c0d 23 "device-management.sotp-section-1-address" : "(MBED_CONF_APP_FLASH_START_ADDRESS + MBED_CONF_APP_FLASH_SIZE - 2*(2*1024))",
galonso@rhomb.io 0:9ff56a0e4c0d 24 "device-management.sotp-section-1-size" : "(2*1024)",
galonso@rhomb.io 0:9ff56a0e4c0d 25 "device-management.sotp-section-2-address" : "(MBED_CONF_APP_FLASH_START_ADDRESS + MBED_CONF_APP_FLASH_SIZE - 1*(2*1024))",
galonso@rhomb.io 0:9ff56a0e4c0d 26 "device-management.sotp-section-2-size" : "(2*1024)",
galonso@rhomb.io 0:9ff56a0e4c0d 27 "update-client.application-details" : "(MBED_CONF_APP_FLASH_START_ADDRESS + 64*1024)",
galonso@rhomb.io 0:9ff56a0e4c0d 28 "update-client.storage-address" : "(2*1024*1024)",
galonso@rhomb.io 0:9ff56a0e4c0d 29 "update-client.storage-size" : "(2*1024*1024)",
galonso@rhomb.io 0:9ff56a0e4c0d 30 "update-client.storage-locations" : "1",
galonso@rhomb.io 0:9ff56a0e4c0d 31 "target.features_add" : ["BOOTLOADER"],
galonso@rhomb.io 0:9ff56a0e4c0d 32 "target.bootloader_img" : "bootloader/mbed-bootloader-RHOMBIO_L476DMW1K.bin",
galonso@rhomb.io 0:9ff56a0e4c0d 33 "target.header_offset" : "0x10000",
galonso@rhomb.io 0:9ff56a0e4c0d 34 "target.app_offset" : "0x10400",
galonso@rhomb.io 0:9ff56a0e4c0d 35 "button-pressed-state" : 0
galonso@rhomb.io 0:9ff56a0e4c0d 36 }
galonso@rhomb.io 0:9ff56a0e4c0d 37 },
galonso@rhomb.io 0:9ff56a0e4c0d 38 "config": {
galonso@rhomb.io 0:9ff56a0e4c0d 39 "format-storage-layer-on-error": {
galonso@rhomb.io 0:9ff56a0e4c0d 40 "help": "Whether to format the storage layer when it cannot be read - always disable for production devices!",
galonso@rhomb.io 0:9ff56a0e4c0d 41 "value": 1
galonso@rhomb.io 0:9ff56a0e4c0d 42 },
galonso@rhomb.io 0:9ff56a0e4c0d 43 "main-stack-size": {
galonso@rhomb.io 0:9ff56a0e4c0d 44 "value": 6000
galonso@rhomb.io 0:9ff56a0e4c0d 45 },
galonso@rhomb.io 0:9ff56a0e4c0d 46 "use-button": {
galonso@rhomb.io 0:9ff56a0e4c0d 47 "help": "Whether the target has a button",
galonso@rhomb.io 0:9ff56a0e4c0d 48 "macro_name": "USE_BUTTON",
galonso@rhomb.io 0:9ff56a0e4c0d 49 "value": true
galonso@rhomb.io 0:9ff56a0e4c0d 50 },
galonso@rhomb.io 0:9ff56a0e4c0d 51 "button-pressed-state": {
galonso@rhomb.io 0:9ff56a0e4c0d 52 "help": "Value of the button when pressed",
galonso@rhomb.io 0:9ff56a0e4c0d 53 "value": 1
galonso@rhomb.io 0:9ff56a0e4c0d 54 },
galonso@rhomb.io 0:9ff56a0e4c0d 55 "no_led": {
galonso@rhomb.io 0:9ff56a0e4c0d 56 "help": "This flag disables the heartbeat thread in tests. This is useful for platforms that don't have an LED or the LED is used for other functionality like LED on the SPI clockline etc",
galonso@rhomb.io 0:9ff56a0e4c0d 57 "value": null
galonso@rhomb.io 0:9ff56a0e4c0d 58 },
galonso@rhomb.io 0:9ff56a0e4c0d 59 "tests-fs-size": {
galonso@rhomb.io 0:9ff56a0e4c0d 60 "help": "Maximum size of the file system used for tests",
galonso@rhomb.io 0:9ff56a0e4c0d 61 "value": null
galonso@rhomb.io 0:9ff56a0e4c0d 62 }
galonso@rhomb.io 0:9ff56a0e4c0d 63 }
galonso@rhomb.io 0:9ff56a0e4c0d 64 }