![](/media/cache/group/toshiba_logo-square.jpg.50x50_q85.jpg)
Mbed OS example of Pelion device management client
This example is known to work great on the following platforms:
- AdBun-M46B over Wi-Fi.
To use this example, connect ESP8266 Wi-Fi module (Grove UART WiFi) to the AdBun-M46B board as below:
ESP8266 Wi-Fi | AdBun-M46B |
---|---|
TX | PL1 (CN4-22) |
RX | PL2 (CN4-24) |
VIN | VCC3.3 (CN11-5) |
GND | GND (CN11-6) |
Example functionality
- Initialize, connect and register to Pelion DM
- Interact with the user through the serial port (115200 bauds)
- Press enter through putty/minicom to simulate button
- Press i to print endpoint name
- Press Ctrl-C to to unregister
- Press r to reset storage and reboot (warning: it generates a new device ID!)
Instructions to use this program with Mbed CLI
1. Import the application into your desktop:
mbed import https://os.mbed.com/teams/Toshiba/code/mbed-os-example-pelion/ cd mbed-os-example-pelion
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. Connect Pins used with Wifi shield (ESP8266) and SD card shield:
5. Edit mbed_app.json to specify Wi-Fi access point information
"nsapi.default-wifi-ssid" : "\"SSID\"", "nsapi.default-wifi-password" : "\"PASSWORD\""
6. Compile and program:
mbed compile -t <toolchain> -m TMPM46B
(supported toolchains : GCC_ARM / ARM / IAR)
TESTS/README.md@0:9f917a7bf2da, 2019-12-12 (annotated)
- Committer:
- MACRUM
- Date:
- Thu Dec 12 10:26:06 2019 +0900
- Revision:
- 0:9f917a7bf2da
Initial commit.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
MACRUM | 0:9f917a7bf2da | 1 | # Device Management E2E testing |
MACRUM | 0:9f917a7bf2da | 2 | |
MACRUM | 0:9f917a7bf2da | 3 | Device Management E2E tests are platform agnostic. They verify that a target platform can reliably perform basic critical operations. |
MACRUM | 0:9f917a7bf2da | 4 | There are two different test sets: |
MACRUM | 0:9f917a7bf2da | 5 | |
MACRUM | 0:9f917a7bf2da | 6 | - Tests for verifying the basic functionality of a target platform. |
MACRUM | 0:9f917a7bf2da | 7 | - Advanced tests for more complex use cases (for example `device_update` test case). |
MACRUM | 0:9f917a7bf2da | 8 | |
MACRUM | 0:9f917a7bf2da | 9 | ## Requirements |
MACRUM | 0:9f917a7bf2da | 10 | |
MACRUM | 0:9f917a7bf2da | 11 | 1. [IceTea](https://github.com/ARMmbed/icetea) v1.2.1 or later. |
MACRUM | 0:9f917a7bf2da | 12 | 1. [Mbed Cloud SDK for Python](https://cloud.mbed.com/docs/current/mbed-cloud-sdk-python/index.html) v2.0.5 or later. |
MACRUM | 0:9f917a7bf2da | 13 | |
MACRUM | 0:9f917a7bf2da | 14 | ## Installation |
MACRUM | 0:9f917a7bf2da | 15 | |
MACRUM | 0:9f917a7bf2da | 16 | ``` |
MACRUM | 0:9f917a7bf2da | 17 | pip install icetea mbed-cloud-sdk |
MACRUM | 0:9f917a7bf2da | 18 | ``` |
MACRUM | 0:9f917a7bf2da | 19 | |
MACRUM | 0:9f917a7bf2da | 20 | ## Basic usage for Mbed OS (serial dependency) |
MACRUM | 0:9f917a7bf2da | 21 | |
MACRUM | 0:9f917a7bf2da | 22 | These Mbed OS specific tests use the serial console to read the `device_id` automatically from console output. |
MACRUM | 0:9f917a7bf2da | 23 | |
MACRUM | 0:9f917a7bf2da | 24 | 1. Define environmental variable `MBED_CLOUD_SDK_API_KEY` with your [API key](https://cloud.mbed.com/docs/current/integrate-web-app/api-keys.html) as the value. Alternatively add your API key to `TESTS/pelion.tc_cfg`. |
MACRUM | 0:9f917a7bf2da | 25 | 1. Verify with `mbed ls` that the device is connected via serial and mounted. |
MACRUM | 0:9f917a7bf2da | 26 | |
MACRUM | 0:9f917a7bf2da | 27 | ### Running the test suite |
MACRUM | 0:9f917a7bf2da | 28 | |
MACRUM | 0:9f917a7bf2da | 29 | To run the test suite, use the following command: |
MACRUM | 0:9f917a7bf2da | 30 | |
MACRUM | 0:9f917a7bf2da | 31 | ``` |
MACRUM | 0:9f917a7bf2da | 32 | icetea --suite basic_os_tests.json --suitedir TESTS/ --tcdir ./TESTS/ --tc_cfg TESTS/pelion.tc_cfg --reset |
MACRUM | 0:9f917a7bf2da | 33 | ``` |
MACRUM | 0:9f917a7bf2da | 34 | |
MACRUM | 0:9f917a7bf2da | 35 | If you have prepared a manifest (see below the instructions for `device_update` testcase), you can run the full suite with: |
MACRUM | 0:9f917a7bf2da | 36 | |
MACRUM | 0:9f917a7bf2da | 37 | ``` |
MACRUM | 0:9f917a7bf2da | 38 | icetea --suite full_os_tests.json --suitedir TESTS/ --tcdir ./TESTS/ --tc_cfg TESTS/pelion.tc_cfg --reset |
MACRUM | 0:9f917a7bf2da | 39 | ``` |
MACRUM | 0:9f917a7bf2da | 40 | |
MACRUM | 0:9f917a7bf2da | 41 | ## Basic usage |
MACRUM | 0:9f917a7bf2da | 42 | |
MACRUM | 0:9f917a7bf2da | 43 | These generic tests do not depend on console. |
MACRUM | 0:9f917a7bf2da | 44 | |
MACRUM | 0:9f917a7bf2da | 45 | 1. Register your device to Device Management. For examples, see the [tutorials](https://cloud.mbed.com/docs/current/connecting/device-management-client-tutorials.html). |
MACRUM | 0:9f917a7bf2da | 46 | 1. Enter your [device_id](https://cloud.mbed.com/docs/current/connecting/device-identity.html) to `TESTS/pelion.tc_cfg`. |
MACRUM | 0:9f917a7bf2da | 47 | 1. Enter your [API key](https://cloud.mbed.com/docs/current/integrate-web-app/api-keys.html) to `TESTS/pelion.tc_cfg`. |
MACRUM | 0:9f917a7bf2da | 48 | |
MACRUM | 0:9f917a7bf2da | 49 | ### Running the test suite |
MACRUM | 0:9f917a7bf2da | 50 | |
MACRUM | 0:9f917a7bf2da | 51 | To run the test suite, use the following command: |
MACRUM | 0:9f917a7bf2da | 52 | |
MACRUM | 0:9f917a7bf2da | 53 | ``` |
MACRUM | 0:9f917a7bf2da | 54 | icetea --suite basic_tests.json --suitedir TESTS/ --tcdir ./TESTS/ --tc_cfg TESTS/pelion.tc_cfg |
MACRUM | 0:9f917a7bf2da | 55 | ``` |
MACRUM | 0:9f917a7bf2da | 56 | |
MACRUM | 0:9f917a7bf2da | 57 | If you have prepared a manifest (see below the instructions for `device_update` testcase), you can run the full suite with: |
MACRUM | 0:9f917a7bf2da | 58 | |
MACRUM | 0:9f917a7bf2da | 59 | ``` |
MACRUM | 0:9f917a7bf2da | 60 | icetea --suite full_tests.json --suitedir TESTS/ --tcdir ./TESTS/ --tc_cfg TESTS/pelion.tc_cfg |
MACRUM | 0:9f917a7bf2da | 61 | ``` |
MACRUM | 0:9f917a7bf2da | 62 | |
MACRUM | 0:9f917a7bf2da | 63 | ### Running a single test |
MACRUM | 0:9f917a7bf2da | 64 | |
MACRUM | 0:9f917a7bf2da | 65 | To run a single test, use the following command: |
MACRUM | 0:9f917a7bf2da | 66 | |
MACRUM | 0:9f917a7bf2da | 67 | ``` |
MACRUM | 0:9f917a7bf2da | 68 | icetea --tc basic_get --tcdir ./TESTS/ --tc_cfg TESTS/pelion.tc_cfg |
MACRUM | 0:9f917a7bf2da | 69 | ``` |
MACRUM | 0:9f917a7bf2da | 70 | |
MACRUM | 0:9f917a7bf2da | 71 | ## Current tests |
MACRUM | 0:9f917a7bf2da | 72 | |
MACRUM | 0:9f917a7bf2da | 73 | | Test name | Main functions | Notes | |
MACRUM | 0:9f917a7bf2da | 74 | | ---------------- | ------------------------------------------ | --------------------------------------| |
MACRUM | 0:9f917a7bf2da | 75 | | `register` | Verify that the device is registered. | | |
MACRUM | 0:9f917a7bf2da | 76 | | `register_and_read_id` | Verify that the device is registered. | Uses serial to read the `device_id`. Mbed OS only. | |
MACRUM | 0:9f917a7bf2da | 77 | | `get` | Verify that the device responds to GET. | Uses OMA resource `/3/0/0` | |
MACRUM | 0:9f917a7bf2da | 78 | | `put` | Verify that the device responds to PUT. | Uses custom resource `/3201/0/5853` | |
MACRUM | 0:9f917a7bf2da | 79 | | `post` | Verify that the device responds to POST. | Uses custom resource `/3201/0/5850` | |
MACRUM | 0:9f917a7bf2da | 80 | | `observation` | Verify that the device can send notifications. | Uses custom resource `/3201/0/5853` | |
MACRUM | 0:9f917a7bf2da | 81 | | `deregister` | Verify that the device can deregister. | Uses custom resource `/5000/0/1` | |
MACRUM | 0:9f917a7bf2da | 82 | | `device_update` | Performs the firmware update. | This testcase verifies that the device can perform a firmware update. For this testcase, you need to manually generate an update image and a manifest. | |
MACRUM | 0:9f917a7bf2da | 83 | |
MACRUM | 0:9f917a7bf2da | 84 | ### Executing `device_update` test case |
MACRUM | 0:9f917a7bf2da | 85 | |
MACRUM | 0:9f917a7bf2da | 86 | The test case does not automatically generate an update image or generate a manifest. Read [Update documentation](https://cloud.mbed.com/docs/current/updating-firmware/index.html) for more information. |
MACRUM | 0:9f917a7bf2da | 87 | |
MACRUM | 0:9f917a7bf2da | 88 | To run the test case: |
MACRUM | 0:9f917a7bf2da | 89 | |
MACRUM | 0:9f917a7bf2da | 90 | 1. Compile a new update image. |
MACRUM | 0:9f917a7bf2da | 91 | 1. Upload the image to Device Management. |
MACRUM | 0:9f917a7bf2da | 92 | 1. Generate a manifest for the update image. |
MACRUM | 0:9f917a7bf2da | 93 | 1. Upload the manifest to Device Management. |
MACRUM | 0:9f917a7bf2da | 94 | 1. Add the `<manifest-id>` to `TESTS/pelion.tc_cfg`. |
MACRUM | 0:9f917a7bf2da | 95 | |
MACRUM | 0:9f917a7bf2da | 96 | #### Example for executing the `device_update` test case on Mbed OS platform |
MACRUM | 0:9f917a7bf2da | 97 | |
MACRUM | 0:9f917a7bf2da | 98 | To prepare the latest Device Management Client example on Mbed OS for testing, run the following commands: |
MACRUM | 0:9f917a7bf2da | 99 | |
MACRUM | 0:9f917a7bf2da | 100 | 1. `mbed dm init -d arm.com --model-name example-app --force -q` |
MACRUM | 0:9f917a7bf2da | 101 | 1. `mbed compile -t <toolchain> -m <MCU>` |
MACRUM | 0:9f917a7bf2da | 102 | 1. `mbed dm update prepare` |
MACRUM | 0:9f917a7bf2da | 103 | |
MACRUM | 0:9f917a7bf2da | 104 | The last command uploads the `mbed-cloud-client-example_update.bin`, generates a new manifest and uploads the manifest to Device Management. Record the resulting Manifest ID and add it to `TESTS/pelion.tc_cfg`. |
MACRUM | 0:9f917a7bf2da | 105 | |
MACRUM | 0:9f917a7bf2da | 106 | ``` |
MACRUM | 0:9f917a7bf2da | 107 | [INFO] 2018-12-12 15:06:42 - manifesttool.prepare - Manifest ID: <manifest-id> |
MACRUM | 0:9f917a7bf2da | 108 | ``` |
MACRUM | 0:9f917a7bf2da | 109 | |
MACRUM | 0:9f917a7bf2da | 110 | To execute the test, use the following command: |
MACRUM | 0:9f917a7bf2da | 111 | |
MACRUM | 0:9f917a7bf2da | 112 | ``` |
MACRUM | 0:9f917a7bf2da | 113 | icetea --tc device_update --tcdir ./TESTS/ --tc_cfg TESTS/pelion.tc_cfg |
MACRUM | 0:9f917a7bf2da | 114 | ``` |
MACRUM | 0:9f917a7bf2da | 115 | |
MACRUM | 0:9f917a7bf2da | 116 | <span class="notes">**Note:** After each successful update, you need to generate a new manifest for a new firmware update test. Otherwise, the test will pass without actually performing any device side updates. The update campaign ends automatically because the manifest has already been applied to the device.</span> |