Git Product home page Git Product logo

simple-mbed-cloud-client's Introduction

Note

This library has been deprecated and is no longer maintained.

Please migrate your example application to mbed-os-example-pelion

Device Management for Mbed OS

(This was previously called Simple Mbed Cloud Client.)

This provides a way to add device management capabilities to Mbed OS devices using the Arm Pelion Device Management IoT platform.

It:

  • Enables applications to connect and perform firmware updates in a few lines of code.
  • Runs separately from your main application; it does not take over your main loop.
  • Provides LWM2M resources, variables that sync automatically through Pelion Device Management.
  • Helps users avoid doing blocking network operations in interrupt contexts, by automatically defering actions to a separate thread.
  • Provides end-to-end Greentea tests for Pelion Device Management.

This library makes it trivial to expose sensors, actuators and other variables to a cloud service. For a complete Pelion Device Management Client API, please see our documentation.

Device management for your Mbed OS application

Not every device (microcontroller, module or board) is capable of running device management features. Although you can add or extend some hardware capabilities, such as connectivity, storage and TRNG, others are impossible or inconvenient to extend (for example, RAM or flash).

The minimum requirements to add device management feature to your application are:

  • RAM: 128K or more.
  • Flash: 512K or more.
  • Real Time Clock (RTC).
  • (Optional but recommended) True Random Number Generator (TRNG).
  • A storage device: SD card, SPI flash, QSPI flash or data flash.
  • IP connectivity: Ethernet, Wi-Fi, cellular, 6LoWPAN or Thread.

Additionally, we recommend the latest version of Mbed OS support the device and any additional complementary hardware components, or that they have support for the APIs provided in the latest releases of Mbed OS.

Useful references:

Adding a device management feature to your application

  1. Add this library to your Mbed OS project:

    $ mbed add https://github.com/ARMmbed/simple-mbed-cloud-client
    

    If you do not have an Mbed OS project to add, you can create one with mbed new <your_application_name> and then the mbed add step above.

  2. Reference the library from the main.cpp file, and add network and storage drivers. Finally, initialize the SimpleMbedCloudClient library. This is the architecture of a device management application with Mbed OS:

    #include "simple-mbed-cloud-client.h"
    #include <Block device>
    #include <Filesystem>
    #include <Network>
    
    int main() {
    
        /* Initialize connectivity */
        NetworkInterface *net = NetworkInterface::get_default_instance();
        net->connect();
    
        /* Initialize storage */
        BlockDevice *bd = BlockDevice::get_default_instance();
        <Filesystem> fs("fs", &bd);
    
        /* Initialize SimpleMbedCloudClient */
        SimpleMbedCloudClient client(net, &bd, &fs);
        client.init();
    
        /* Create resource */
        MbedCloudClientResource *variable;
        variable = client.create_resource("3201/0/5853", "variable");
        variable->set_value("assign new value");
        variable->methods(M2MMethod::GET | M2MMethod::PUT);
    
    }
  3. Configure the API key for your Pelion Portal account.

    If you don't have an API key available, then log in to the Pelion IoT Platform portal, navigate to Access Management and API keys, and create a new one. Then specify the API key as the global mbed configuration:

    $ mbed config -G CLOUD_SDK_API_KEY <your-api-key>
    
  4. Install the device management certificate:

    $ mbed dm init -d "<your company name.com>" --model-name "<product model identifier>"
    

This creates your private and public key pair and also initialize various .c files with these credentials, so you can use Connect and (firmware) Update device management features.

Example applications

To help you start quickly, please refer to the following application example. It demonstrates how to connect to the Pelion IoT Platform service, register resources and get ready to receive a firmware update.

Also, there are a number of board-specific applications that focus on providing more elaborate hardware features with Mbed OS and the Pelion IoT Platform. These are available in the Pelion quick start. Please see the reference table below, organized by vendor name, for details:

Platform Connectivity Storage Example URL
Nuvoton NUMAKER-IOT-M487 Wi-Fi SD Card https://os.mbed.com/teams/Nuvoton/code/pelion-example-common
Nuvoton NUMAKER-PFM-M487 Ethernet SD Card https://os.mbed.com/teams/Nuvoton/code/pelion-example-common
Nuvoton NUMAKER-PFM-NUC472 Ethernet SD Card https://os.mbed.com/teams/Nuvoton/code/pelion-example-common
NXP FRDM-K64F Ethernet SD Card https://os.mbed.com/teams/NXP/code/pelion-example-frdm
NXP FRDM-K66F Ethernet SD Card https://os.mbed.com/teams/NXP/code/pelion-example-frdm
Renesas GR-PEACH Ethernet SD Card https://os.mbed.com/teams/Renesas/code/pelion-example-common
Renesas GR-LYCHEE Wi-Fi SD Card https://os.mbed.com/teams/Renesas/code/pelion-example-common
Sigma Delta Technologies SDT64B Ethernet SD Card https://os.mbed.com/teams/Sigma-Delta-Technologies/code/pelion-example-common
Silicon Labs Giant Gecko 11 Ethernet QSPI https://os.mbed.com/teams/SiliconLabs/code/pelion-example-common
Silicon Labs Thunderboard Sense 2 15.4 Thread SPI Flash https://os.mbed.com/teams/SiliconLabs/code/pelion-example-tbsense2
ST DISCO_L475E_IOT01A Wi-Fi QSPI https://os.mbed.com/teams/ST/code/pelion-example-disco-iot01
ST DISCO_F413H Wi-Fi QSPI https://os.mbed.com/teams/ST/code/pelion-example-common
ST DISCO_F469NI Wi-Fi Shield QSPI https://os.mbed.com/teams/ST/code/pelion-example-common
ST DISCO_F746NG Ethernet QSPI https://os.mbed.com/teams/ST/code/pelion-example-common
ST DISCO_F769NI Ethernet QSPI https://os.mbed.com/teams/ST/code/pelion-example-common
ST DISCO_L496AG Wi-Fi Shield QSPI https://os.mbed.com/teams/ST/code/pelion-example-common
ST NUCLEO_F207ZG Ethernet SD Card https://os.mbed.com/teams/ST/code/pelion-example-common
ST NUCLEO_F412ZG Wi-Fi Shield SD Card https://os.mbed.com/teams/ST/code/pelion-example-common
ST NUCLEO_F429ZI Ethernet SD Card https://os.mbed.com/teams/ST/code/pelion-example-common
ST NUCLEO_F767ZI Ethernet SD Card https://os.mbed.com/teams/ST/code/pelion-example-common
ST NUCLEO_F746ZG Ethernet SD Card https://os.mbed.com/teams/ST/code/pelion-example-common
ST NUCLEO_L476RG Wi-Fi Shield SD Card https://os.mbed.com/teams/ST/code/pelion-example-common
ST NUCLEO_L496ZG Wi-Fi Shield SD Card https://os.mbed.com/teams/ST/code/pelion-example-common
ST NUCLEO_L4R5ZI Wi-Fi Shield SD Card https://os.mbed.com/teams/ST/code/pelion-example-common
UBlox C030 U201 Cellular SD Card https://os.mbed.com/teams/ublox/code/pelion-example-common
UBlox EVK ODIN W2 Wi-Fi SD Card https://os.mbed.com/teams/ublox/code/pelion-example-common

Device management configuration

The device management configuration has five distinct areas:

  • Connectivity - the transport type for the device to connect to the device management service.
  • Storage - the storage type and writing used for both the credentials and the firmware storage.
  • Flash geometry - the device flash "sandbox" for bootloader, application header, application image and two SOTP regions.
  • SOTP - the address and size of the SOTP regions in flash used to store the device special key that decrypts the credentials storage.
  • Bootloader - the bootloader image, application and header offset.

Except for connectivity, the majority of the configuration is shared between the application and bootloader, which ensures the bootloader can correctly find, verify, authorize and apply an update to the device application.

For full documentation about bootloaders and firmware update, please read the following documents:

To hasten this process, you can copy the configuration from the application example as the basis for your application configuration.

1. Application configuration

Edit the mbed_app.json file, and create a new entry under target_overrides with the target name for your device:

  • Connectivity - Specify the default connectivity type for your target. It's essential with targets that lack default connectivity set in targets.json or for targets that support multiple connectivity options. For example:

             "target.network-default-interface-type" : "ETHERNET",
    

    The possible options are ETHERNET, WIFI and CELLULAR.

    Depending on connectivity type, you might have to specify more config options. For an example, please see the defined CELLULAR targets in mbed_app.json.

  • Storage - Specify the storage block device type, which dynamically adds the block device driver you specified at compile time. For example:

             "target.components_add" : ["SD"],
    

    Valid options are SD, SPIF, QSPIF and FLASHIAP (not recommended). For more available options, please see the block device components.

    You also have to specify block device pin configuration, which may vary from one block device type to another. Here's an example for SD:

             "sd.SPI_MOSI"                      : "PE_6",
             "sd.SPI_MISO"                      : "PE_5",
             "sd.SPI_CLK"                       : "PE_2",
             "sd.SPI_CS"                        : "PE_4",
    

    If you are using SPI/QSPI flash, please make sure you have specified the correct SPI frequency by configuring spif-driver.SPI_FREQ. If it is not configured, 40Mhz will be applied by default.

  • Flash - Define the basics for the microcontroller flash. For example:

             "device-management.flash-start-address"              : "0x08000000",
             "device-management.flash-size"                       : "(2048*1024)",
    
  • SOTP - Define two SOTP or NVStore regions that Mbed OS Device Management will use to store its special keys, which encrypt the data stored. Use the last two Flash sectors (if possible) to ensure that they don't get overwritten when new firmware is applied. For example:

             "device-management.sotp-section-1-address"            : "(MBED_CONF_APP_FLASH_START_ADDRESS + MBED_CONF_APP_FLASH_SIZE - 2*(128*1024))",
             "device-management.sotp-section-1-size"               : "(128*1024)",
             "device-management.sotp-section-2-address"            : "(MBED_CONF_APP_FLASH_START_ADDRESS + MBED_CONF_APP_FLASH_SIZE - 1*(128*1024))",
             "device-management.sotp-section-2-size"               : "(128*1024)",
             "device-management.sotp-num-sections" : 2
    

*-address defines the start of the Flash sector, and *-size defines the actual sector size. sotp-num-sections should always be set to 2.

At this point, we recommend you run the "connect" test suite, which verifies that the device can successfully bootstrap, register and send and receive data from Pelion Device Management service with the provided configuration.

If you already configured your Pelion API key and initialized your credentials as described in the previous section, you can compile the "Connect" tests using:

$ mbed test -t <TOOLCHAIN> -m <BOARD> -n simple-mbed-cloud-client-tests* -DMBED_TEST_MODE --compile

To run the tests:

$ mbed test -t <TOOLCHAIN> -m <BOARD> -n simple-mbed-cloud-client-tests* --run -v

2. Bootloader configuration

After you've successfully passed the "Connect" tests as described above, you can enable firmware update feature by adding a bootloader to your application.

  1. Import as a new application the official mbed-bootloader repository or the mbed-bootloader-extended repository that builds on top of mbed-bootloader and extends the support for file systems and storage drivers. You can do this with mbed import mbed-bootloader-extended.

  2. Inside the imported bootloader application, and edit the application configuration, for example mbed-bootloader-extended/mbed_app.json. Add a new target entry similar to the step above, and specify:

    • Flash - Define the basics for the microcontroller flash (the same as in mbed_app.json). For example:

            "flash-start-address"              : "0x08000000",
            "flash-size"                       : "(2048*1024)",
      
    • SOTP - Similar to the SOTP step above, specify the location of the SOTP key storage. In the bootloader, the variables are named differently. Try to use the last two Flash sectors (if possible) to ensure that they don't get overwritten when new firmware is applied. For example:

            "nvstore.area_1_address"           : "(MBED_CONF_APP_FLASH_START_ADDRESS + MBED_CONF_APP_FLASH_SIZE - 2*(128*1024))",
            "nvstore.area_1_size"              : "(128*1024)",
            "nvstore.area_2_address"           : "(MBED_CONF_APP_FLASH_START_ADDRESS + MBED_CONF_APP_FLASH_SIZE - 1*(128*1024))", "nvstore.area_2_size" : "(128*1024)",
    
    • Application offset - Specify start address for the application, and also the update-client meta information. As these are automatically calculated, you can copy the ones below:
            "update-client.application-details": "(MBED_CONF_APP_FLASH_START_ADDRESS + 64*1024)",
            "application-start-address"        : "(MBED_CONF_APP_FLASH_START_ADDRESS + 65*1024)",
            "max-application-size"             : "DEFAULT_MAX_APPLICATION_SIZE",
    
    • Storage - Specify the block device pin configuration, exactly as you defined it in the mbed_app.json file. For example:
            "target.components_add"            : ["SD"],
            "sd.SPI_MOSI"                      : "PE_6",
            "sd.SPI_MISO"                      : "PE_5",
            "sd.SPI_CLK"                       : "PE_2",
            "sd.SPI_CS"                        : "PE_4"
    

    If you are using SPI/QSPI flash, please make sure you have specified the correct SPI frequency by configuring spif-driver.SPI_FREQ. If it is not configured, 40Mhz will be applied by default.

  3. Compile the bootloader using the bootloader_app.json configuration you just edited:

    $ mbed compile -t <TOOLCHAIN> -m <TARGET> --profile=tiny.json --app-config=<path to pelion-enablement/bootloader/bootloader_app.json>
    

Note: mbed-bootloader is primarily optimized for GCC_ARM, so you may want to compile it with that toolchain. Before jumping to the next step, you should compile and flash the bootloader and then connect over the virtual comport to ensure the bootloader is running correctly. You can ignore errors related to checksum verification or falure to jump to application - these are expected at this stage.

3. Add the bootloader to your application

  1. Copy the compiled bootloader from mbed-bootloader-extended/BUILDS/<TARGET>/<TOOLCHAIN>-TINY/mbed-bootloader.bin to <your_application_name>/bootloader/mbed-bootloader-<TARGET>.bin.

  2. Edit <your_application_name>/mbed_app.json, and modify the target entry to include:

             "target.features_add"              : ["BOOTLOADER"],
             "target.bootloader_img"            : "bootloader/mbed-bootloader-<TARGET>.bin",
             "target.app_offset"                : "0x10400",
             "target.header_offset"             : "0x10000",
             "update-client.application-details": "(MBED_CONF_APP_FLASH_START_ADDRESS + 64*1024)",
    

    Note:

    • update-client.application-details should be identical in both bootloader_app.json and mbed_app.json.
    • target.app_offset is relative offset to flash-start-address you specified in mbed_app.json and bootloader_app.json, and is the hex value of the offset specified by application-start-address in bootloader_app.json. For example, (MBED_CONF_APP_FLASH_START_ADDRESS+65*1024) dec equals 0x10400 hex.
    • target.header_offset is also relative offset to the flash-start-address you specified in the bootloader_app.json, and is the hex value of the offset specified by update-client.application-details. For example, (MBED_CONF_APP_FLASH_START_ADDRESS+64*1024) dec equals 0x10000 hex.
  3. Finally, compile and rerun all tests, including the firmware update ones with:

    $ mbed test -t <TOOLCHAIN> -m <BOARD> -n simple-mbed-cloud-client-tests-* -DMBED_TEST_MODE --compile
    
    $ mbed test -t <TOOLCHAIN> -m <BOARD> -n simple-mbed-cloud-client-tests-* --run -v
    

Refer to the next section about what tests are being executed.

Validation and testing

Mbed Device Management provides built-in tests to help you when define your device management configuration. Before running these tests, we recommend you refer to the testing setup section below.

Test suites

Test suite Description
fs-single File system single-threaded tests with write buffer sizes - 1 byte, 4b, 16b, 64b, 256b, 1kb, 4kb, 16kb, 64kb.
fs-multi File system multithreaded test with write buffer sizes - 1 byte, 4b, 16b, 64b, 256b, 1kb, 4kb, 16kb, 64kb.
net-single Network single-threaded test with receive buffer sizes - 128 bytes, 256b, 1kb, 2kb, 4kb.
net-multi Network multithreaded test for 1, 2 and 3 download threads with 1kb receive buffer size.
stress-net-fs Network and file system single and multithreaded tests:
  • memory allocation - 10k, 20k, 40k, 60k
  • 1 thread (sequential) - 1 download (1kb buffer), 1 file thread (1kb buffer)
  • 2 parallel threads - 1 download, 1 file thread (1kb buffer)
  • 3 parallel threads - 1 download, 2 file (256 bytes, 1 kb buffer)
  • 4 parallel threads - 1 download, 3 file (1 byte, 256 bytes, 1kb buffer)

Test cases - connect

Test case Description
Connect to <Network type> Tests the connection to the network through the network interface.
Initialize <Blockdevice>+<Filesystem> Initializes the block device driver and file system on top. Usually, the test will be stuck at this point if there's a problem with the storage device.
Format <Filesystem> Tests that you can successfully format the block device for the file system type.
Initialize Simple PDMC Verifies you can initialize Pelion Device Management with the given network, storage and file system configuration. This is where the FCU and KCM configuration is written to storage and the Root of Trust is written to SOTP.
Pelion DM Bootstrap & Register Bootstraps the device and registers it for first time with Pelion Device Management.
Pelion DM Directory Verifies that a registered device appears in the Device Directory in Pelion Device Management.
Pelion DM Re-register Resets the device and reregisters with Pelion Device Management with previously bootstrapped credentials.
Post-reset Identity Verifies that the device identity is preserved over device reset, confirming that Root of Trust is stored in SOTP correctly.
ResourceLwM2M GET Verifies that the device can perform a GET request on an LwM2M resource.
ResourceLwM2M SET Test Sets or changes value from the device and verifies the Pelion Device Management API client can observe the value changing.
ResourceLwM2M PUT Test Verifies the device can perform a PUT request on an LwM2M resource by setting a new value.
Resource LwM2M POST Test Verifies the device can execute a POST on an LwM2M resource and the callback function on the device is called.

Test cases - update

Test case Description
Connect to <Network type> Tests the connection to the network using the network interface.
Initialize <Blockdevice>+<Filesystem> Initializes block device driver and file system on top. Usually the test will be stuck at this point if there's problem with the storage device.
Format <Filesystem> Tests that you can successfully format the block device for the file system type.
Initialize Simple PDMC Verifies you can initialize Pelion Device Management with the given network, storage and file system configuration. This is where the FCU and KCM configuration is written to storage and the Root of Trust is written to SOTP.
Pelion DM Bootstrap & Register Bootstraps the device and registers it for first time with Pelion Device Management.
Pelion DM Directory Verifies a registered device appears in the Device Directory in Pelion Device Management.
Firmware Prepare Prepares the firmware on the host side and calls mbed dm to initiate the Pelion Device Management update campaign.
Firmware Download Downloads the firmware onto the device.
Firmware Update Resets the device, verifies that the firmware has correct checksum, applies it and reverifies the applied firmware checksum.
Pelion DM Re-register Reregisters the device with Pelion Device Management using the new firmware and previously bootstrapped credentials.
Post-update Identity Verifies that the device identity is preserved over firmware update and device reset, confirming that Root of Trust is stored in SOTP correctly.

Requirements

Mbed Device Management tests rely on the Python SDK to test the end-to-end solution. To install the Python SDK:

 $ pip install mbed-cloud-sdk>=2.0.6

Note: The Python SDK requires Python 2.7.10+ or Python 3.4.3+, built with SSL support.

Testing setup

  1. Import an example application for Pelion Device Management that contains the corresponding configuration for your target.

    Please refer to the following application example. It demonstrates how to connect to the Pelion IoT Platform service, register resources and get ready to receive a firmware update.

    Also, there are board-specific applications that focus on providing more elaborate hardware features with Mbed OS and the Pelion IoT Platform. These are available in the Pelion quick start.

  2. Set a global mbed config variable CLOUD_SDK_API_KEY on the host machine valid for the account your device will connect to. For example:

    $ mbed config -G CLOUD_SDK_API_KEY <API_KEY>
    

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

  3. Initialize your Pelion DM credentials (once per project):

    $ mbed dm init -d "<your company name.com>" --model-name "<product model identifier>"
    

    This creates your private and public key pair and also initializes various .c files with these credentials, so you can use Connect and (firmware) Update device management features.

  4. Remove the main.cpp application from the project, or ensure the content of the file is wrapped with #ifndef MBED_TEST_MODE.

  5. Compile the tests with the MBED_TEST_MODE compilation flag.

    $ mbed test -t <toolchain> -m <platform> -n simple-mbed-cloud-client-tests-* -DMBED_TEST_MODE --compile
    
  6. Run the tests from the application directory:

    $ mbed test -t <toolchain> -m <platform> -n simple-mbed-cloud-client-tests-* --run -v
    

Troubleshooting

Below are common issues and fixes.

Autoformatting failed with error -5005

This is due to an issue with the storage block device. If using an SD card, ensure that the SD card is seated properly.

Storage initialization failed with error -4002

This is observed when the device is using legacy serial flash which does not support SFDP, or the SPI frequency is not configured properly.

SYNC_FAILED during testing

Occasionally, if the test failed during a previous attempt, the SMCC Greentea tests fail to sync. If this is the case, please replug your device to the host PC. Additionally, you may need to update your DAPLink or ST-Link interface firmware.

If the test fails with SYNC_FAILED all the time, please check if the UART flow control pins (UART_CTS, UART_RTS) are properly defined. If your device supports flow control over UART, fill them with the corresponding pins; if not, please specify NC.

Device identity is inconsistent

If your device ID in Pelion Device Management is inconsistent over a device reset, it could be because it is failing to open the credentials on the storage held in the Enhanced Secure File System. Typically, this is because the device cannot access the Root of Trust stored in SOTP.

One way to verify this is to see if the storage is reformatted after a device reset when format-storage-layer-on-error is set to 1 in mbed_app.json. It would appear on the serial terminal output from the device as:

[SMCC] Initializing storage.
[SMCC] Autoformatting the storage.
[SMCC] Reset storage to an empty state.
[SMCC] Starting developer flow

When this occurs, look at the SOTP sectors defined in mbed_app.json:

"sotp-section-1-address"           : "0xFE000",
"sotp-section-1-size"              : "0x1000",
"sotp-section-2-address"           : "0xFF000",
"sotp-section-2-size"              : "0x1000",

Ensure that the sectors are correct according to the flash layout of your device, and they are not being overwritten during the programming of the device. ST-Link devices overwrite these sectors when you use drag-and-drop of .bin files. Thus, moving the SOTP sectors to the end sectors of flash ensures they are not overwritten.

Stack overflow

If you receive a stack overflow error, increase the Mbed OS main stack size to at least 6000. You can do this by modifying the following parameter in mbed_app.json:

 "MBED_CONF_APP_MAIN_STACK_SIZE=6000",

Device failed to register

Check the device allocation on your Pelion account to see if you are allowed additional devices to connect. You can delete development devices. After being deleted, they will not count toward your allocation.

In network test cases, tests over larger buffers passed, but tests over small buffers keeps failing

This could be observed with cellular modems driven by AT commands. Suggestions:

  1. Connect the modem to an serial interface which supports hardware flow control, and define MDMRTS and MDMCTS correspondingly.
  2. Use the highest possible baud-rate of your modem, e.g. 115200bps
  3. For the UART connected to your host PC, choose one which supports hardware flow control
  4. Set the STDIO UART baud-rate to 230400bps by configuring platform.stdio-baud-rate.

With SPI/QSPI Flash, LittleFS got corrupted after firmware update test

If you observe logs such as mbed assertation failed: block < lfs->cfg->block_count or invalid superblock, etc., please check if partition mode is set to 0:

"device-management.partition_mode"         : 0

Notification channel failures during LwM2M Resource test cases

This could be observed if a previously registered long-poll or webhook notification channel with the same API key existed. You may either use another API key, or delete the notification channel with curl command:

to delete Long Poll:

curl -H "Authorization: Bearer ${API_KEY}" -X DELETE ${API_URL}/v2/notification/pull

to delete WebHook:

curl -H "Authorization: Bearer ${API_KEY}" -X DELETE ${API_URL}/v2/notification/callback

Please note that long-polling is now deprecated and will be likely be replace in the future. Use callback notification channel (WebHook) instead.

I had built the test suites but somehow I got my Python environment messed up; can I run the test binaries without GreenTea?

The test binaries are built under:

  <repo folder>/BUILD/tests/<Target Name>/<Toolchain>/simple-mbed-cloud-client/TESTS/<Test Suites>/<test case>/<test case name>.hex. 

You may copy the binary you want to manually test and flash it to the device, then when the device boots, paste the following line to the serial console to trigger the test:

 {{__sync;1}}

Known issues

Check open issues on GitHub.

simple-mbed-cloud-client's People

Contributors

andrewc-arm avatar bridadan avatar cyliangtw avatar dhwalters423 avatar ithinuel avatar janjongboom avatar screamerbg avatar soleilplanet avatar stevew817 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

simple-mbed-cloud-client's Issues

Convergence with mbed-cloud-client-example...

Now that the Mbed OS 5.10.0 release is coming soon, it brings with it all the default interfaces for block devices and network interfaces. This simplifies quite a bit of the complexity that was originally present in the apis/examples.

What are your thoughts on trying to move the lessons learned with this API back into the mainline mbed-cloud-client library and example? It would certainly help remove some of the engineering load and time spent porting this library for each release.

Short term fix for Windows Path length limit

There are known issues due to the Windows path limit.
Even installing the app in the root directory (c:) causes problems when running the tests.
Is unclear when exactly this will be fixed.

In the meantime, we need a short-term fix. I can think of a few options (could be combined)

  1. Rename to "simple-mbed-cloud-client" to "spdmc"
  2. Move MCC library out and put it at same level as the SMCC library.
    The application would integrate the two libs. People could potentially upgrade MCC themselves.
  3. Other? Unknown

@janjongboom @bridadan @screamerbg

Please share your thoughts asap.

simple mbed client was disconnecting, if resource payload size greater than 512 bytes

Hi Team,

We are working on DISCO-L475VG-IOT01A board with WiFi module Inventek ISM43362-M3G-L44 (802.11 b/g/n compliant) for ARM mbed pelion cloud.

issue : simple mbed client was disconnecting, if resource payload size greater than 512 bytes

[SMCC] Error occurred : MbedCloudClient::ConnectSecureConnectionFailed
[SMCC] Error code : 11
[SMCC] Error details : Client in reconnection mode SecureConnectionFailed

[SMCC] Error occurred : MbedCloudClient::ConnectSecureConnectionFailed
[SMCC] Error code : 11
[SMCC] Error details : Client in reconnection mode SecureConnectionFailed

could you please let me know what may be issue and is there any mbed paramter need to change?.

Thanks &Regards
Praveen.Thota

Archived

๐ŸŽ‰๐ŸŽ‰๐ŸŽ‰๐ŸŽ‰

Can it be archived too for good measure?

Format not working on QSPI devices

Problem

When using devices with QSPI instead of an SD Card (like the ST Disco IOT01A board) the format function does not work. Not sure why.

A work around I found is to add the following code to the top of main()

    printf("Checking SDCard is Formatted\r\n");
    int err = fs.mount(&sd);
    printf("%s\n", (err ? "Fail :(" : "OK"));
    if (err) {
        // Reformat if we can't mount the filesystem
        // this should only happen on the first boot
        printf("No filesystem found, formatting... ");
        fflush(stdout);
        err = fs.reformat(&sd);
        printf("%s\n", (err ? "Fail :(" : "OK"));
        if (err) {
            error("error: %s (%d)\n", strerror(-err), err);
        }
    }
    // err = fs.unmount();
    // printf("%s\n", (err < 0 ? "Fail :(" : "OK"));
    // if (err < 0) {
    //     error("error: %s (%d)\n", strerror(-err), err);
    // }

Example code can be found here: https://github.com/BlackstoneEngineering/mbed-cloud-workshop-connect/#310576453999a900ba059feb3b7c8385aa269956

Solution

Unsure. Dont have time to debug this right now.

##Tag
@MarceloSalazar

Support for delayed post response

Simple Mbed Cloud Client would benefit from support for delayed POST responses, supporting this API from Client: https://cloud.mbed.com/docs/current/mbed-client/class_m2_m_resource.html#a4c53a06afc748c66f7b8baa7501b21de

Use case is to support sending success responses for operations in a callback function that require sequencing.

Example:

POST some data to the device
device writes that data to block device storage
send_delayed_post_response()
server POSTs additional data to device
...

Sometimes tests never finish

This issue happens sometimes, which makes me think there is a timing/race condition involved.

While running SMCC tests on ST Disco L475 and K64F on Windows and OSX, this message keeps showing up and the tests never finish.

[1539114564.55][mbed_cloud._backends.mds.rest]response body:

@dhwalters423

Concerns with filesystem/block device in the same SD card

I am evaluating mbed cloud client 1.3.3 on NUMAKER_PFM_NUC472/NUMAKER_PFM_M487 and send the same issue as PelionIoT/mbed-cloud-client-example#10. In this case, my SD card is not partitioned (no MBR) but it is used for both FAT file system (to save KCM data) and block device (to save F/W update candidates). My concerns are:

  1. There's potential risk that FAT file system and block device would overlap. Do you have plan to fix it?
  2. FAT file system and block device both would call the underlying block device init/deinit? How do you coordinate them? Because deinit called by one end will make the other end to fail to work with the underlying block device.

How to connect to Leshan server

Normally we use SMCC to connect to Pelion Device Management however i would like to know if it is possible to use SMCC to connect to Eclipse Leshan server? What changes are required and where?

Should have typed resources

Right now everything is a string, so you're constantly casting values. This is very error-prone, plus removes all benefits from a statically typed language. MbedCloudClientResource should have type information, either through generics MbedCloudClientResource<int> or by specifying particular types like MbedCloudClientResourceInt.

I think we could start with just string, int and float and perhaps change at a later point.

How to enable simple client traces ?

Hello,
I don't see the effect in the hyperterminal while writing
"mbed-trace.enable": true in mbed_app.json
I don't see the difference between trace = 0 and trace = true

I would like to be able to read the traces for this files, for instance https://github.com/ARMmbed/mbed-cloud-client/blob/9b0bc6a2f3f1f5dbb5be1827db83004d531b99c9/source/MbedCloudClient.cpp#L92

I am writing the following in mbed_app.json for the example cloud client
(based on https://github.com/ARMmbed/simple-mbed-cloud-client-template-restricted )
"target_overrides": {
"": {
"platform.stdio-baud-rate": 115200,
"platform.stdio-convert-newlines": true,
"update-client.storage-address" : "(1024
102464)",
"update-client.storage-size" : "(1024
1024*2)",
"update-client.storage-locations": "1",
"mbed-trace.enable": true
},

Platform: DISCO_F413ZH
toolchain GCC_ARM
gcc version 6 2017-q2-update

Could you advise me or fix that, please ?

[TEST] get_mac_address() hangs by cellular connectivity

simple-mbed-cloud-client-tests-basic-net-single, net-threaded and stress-net-fs test always failed (timeout) by IAR compiler.
This is occurred by calling get_mac_address() which no implementation in Cellular class.

https://github.com/ARMmbed/simple-mbed-cloud-client/blob/0beabc34b95ee9c52e6494a25da24df7a8a288ab/TESTS/basic/net-single/main.cpp#L70

Reproduced test code

#include "mbed.h"
#include "CellularContext.h"
#include "CellularDevice.h"

NetworkInterface *iface;

int main() {
    printf("Cellular test start.\n\n");
    iface = CellularContext::get_default_instance();
    MBED_ASSERT(iface);
    iface->set_default_parameters();
    if (iface->connect() == NSAPI_ERROR_OK) {
        printf("IP address: %s\n", iface->get_ip_address());
        printf("MAC address: %s\n", iface->get_mac_address());
    }
    printf("\nCellular test finish.\n");
    return 0;
}

Test result by Wio LTE-M1/NB1(BG96) and Wio 3G target

[ARM]

Cellular test start.

IP address: 10.216.97.66
MAC address:

Cellular test finish.

[GCC_ARM]

Cellular test start.

IP address: 10.216.97.66
MAC address: (null)

Cellular test finish.

[IAR]

Cellular test start.

IP

Should be possible to override platform configuration

In this 'simple-mbed-cloud-client' library, there are a few files that are imported by everyone that wants to use the library, regardless on their platform. These define platform configuration.

  • pal_plat_rot_insecure.cpp --> implementation of the RoT for the platform. By default is fake RoT.

  • sotp_fs_config_MbedOS.h --> definition of what SOTP / RoT is being used.

  • mbed_cloud_client_user_config_template.h --> Possible application configuration (TCP, UDP, lifetimes, payload, etc). By default everything is commented out.

It's ok to define a default implementation or behavior. However, it should be possible to override these functions in the application. One solution is to define those functions as weak or use #ifndef.

Additionally, these configurations should be documented in the markdown to make application developers aware of this.

FYI @janjongboom

Compile failure on sn_nsdl.c

Hi,

I am using the fresh 'mbed new' test space with simple-mbed-cloud-client v2.0.1.
This is the result of my 'mbed ls'.

mbed@mbedVB:~/code/SPDMC_test$ mbed ls
SPDMC_test ( revision in the current branch)
|- mbed-os (#bf6f2c3c6434, tags: latest, mbed-os-5.10.3)
`- simple-mbed-cloud-client (#907d5098a148, tag: v2.0.1)
   `- mbed-cloud-client (#62de4b89d235, tag: 2.0.1.1)

I am having this compile failure.

Compile [ 87.3%]: sn_nsdl.c
[Error] sn_nsdl.c@1962,91: 'struct coap_s' has no member named 'linked_list_blockwise_received_payloads'
[Error] sn_nsdl.c@1962,91: 'struct coap_s' has no member named 'linked_list_blockwise_received_payloads'
[Error] sn_nsdl.c@1962,91: 'struct coap_s' has no member named 'linked_list_blockwise_received_payloads'
[Error] sn_nsdl.c@1962,91: 'struct coap_s' has no member named 'linked_list_blockwise_received_payloads'
[Error] sn_nsdl.c@1962,91: 'struct coap_s' has no member named 'linked_list_blockwise_received_payloads'
[Warning] ns_list.h@204,75: left-hand operand of comma expression has no effect [-Wunused-value]
[Warning] ns_list.h@504,51: left-hand operand of comma expression has no effect [-Wunused-value]
[Error] sn_nsdl.c@1963,42: 'struct coap_s' has no member named 'linked_list_blockwise_received_payloads'
[Error] sn_nsdl.c@1963,42: 'struct coap_s' has no member named 'linked_list_blockwise_received_payloads'
[Error] sn_nsdl.c@1963,42: 'struct coap_s' has no member named 'linked_list_blockwise_received_payloads'
[Warning] ns_list.h@204,75: left-hand operand of comma expression has no effect [-Wunused-value]
Failed to build library

Am I missing something? I am going to dig down on why we are having this compile error, but I would really appreciate if I get some hints on how to avoid this.

Thanks,

Test not working with Mbed CLI 1.8.3

Mbed CLI 1.8.3 introduces an enhancement to detect the current path.
This creates different output for 'mbed config', and therefore not able to grab the CLOUD API KEY

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.