Specific Pelion ready example using features of Seeed Wio boards including cellular and SD Card
Dependencies: WS2812 PixelArray
Fork of simple-mbed-cloud-example-wio_3g by
This example is known to work great on the following platforms:
Seeed Wio 3G and Seeed Wio LTE-M1/NB1(BG96) over cellular and using SD card.
Follow the Quick-Start instructions: https://cloud.mbed.com/quick-start
Example functionality
This example showcases the following device functionality:
- Allow the user to change the state of the board LED from Pelion LWM2M led_state resource and PUT request.
Instructions to use this program with mbed CLI
1. Import the application into your desktop:
mbed import https://os.mbed.com/teams/Seeed/code/pelion-example-common/ cd pelion-example-common
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.9.x or above.
- Set APN name, username and password in the mbed_app.json.
"nsapi.default-cellular-plmn" : "\"00000\"", "nsapi.default-cellular-sim-pin" : "\"0000\"", "nsapi.default-cellular-apn" : "\"apn\"", "nsapi.default-cellular-username" : "\"username\"", "nsapi.default-cellular-password" : "\"password\""
Information
For the Wio LTE-M1/NB1(BG96) target, PLMN (Public land mobile network) should be specified to get quick connection to the network. This is usually found first 5 digit from your SIM card IMSI (International Mobile Subscriber Identity) number. e.g. 44052
4. Compile and program:
mbed compile -t <toolchain> -m WIO_3G
(supported toolchains : GCC_ARM / ARM / IAR)
Troubleshooting
- Make sure the fields
nsapi.default-cellular-sim-pin
,nsapi.default-cellular-apn
,nsapi.default-cellular-username
andnsapi.default-cellular-password
from the mbed_app.json file are filled in correctly. The correct values should appear in the user manual in the details of the SIM card. - Enable trace flag to have access to debug information
"mbed-trace.enable": true
. - Try both TCP and UDP socket types.
- Try both
"lwip.ppp-enabled": true
and"lwip.ppp-enabled": false
. - The modem and network may only support IPv6 in which case
"lwip.ipv6-enabled": true
shall be defined. - The SIM and modem must have compatible cellular technology (3G, 4G, NB-IoT, ...) supported and cellular network available.
Diff: mbed_app.json
- Revision:
- 0:91c16b1711c2
- Child:
- 2:aadfd874279d
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed_app.json Sat Nov 10 20:27:36 2018 +0900 @@ -0,0 +1,112 @@ +{ + "macros": [ + "MBEDTLS_USER_CONFIG_FILE=\"mbedTLSConfig_mbedOS.h\"", + "PAL_USER_DEFINED_CONFIGURATION=\"sotp_fs_config_MbedOS.h\"", + "MBED_CLIENT_USER_CONFIG_FILE=\"mbed_cloud_client_user_config.h\"", + "MBED_CLOUD_CLIENT_USER_CONFIG_FILE=\"mbed_cloud_client_user_config.h\"", + "PAL_DTLS_PEER_MIN_TIMEOUT=5000", + "MBED_CONF_APP_MAIN_STACK_SIZE=7000", + "ARM_UC_USE_PAL_BLOCKDEVICE=1", + "MBED_CLOUD_CLIENT_UPDATE_STORAGE=ARM_UCP_FLASHIAP_BLOCKDEVICE" + ], + "target_overrides": { + "*": { + "platform.stdio-baud-rate": 115200, + "platform.stdio-convert-newlines": true, + "update-client.storage-address" : "(1024*1024*64)", + "update-client.storage-size" : "(1024*1024*2)", + "update-client.storage-locations": "1", + "mbed-trace.enable": null, + "nsapi.default-wifi-security" : "WPA_WPA2", + "nsapi.default-wifi-ssid" : "\"SSID\"", + "nsapi.default-wifi-password" : "\"Password\"" + }, + "K64F": { + "target.features_add" : ["BOOTLOADER"], + "sotp-section-1-address" : "(32*1024)", + "sotp-section-1-size" : "(4*1024)", + "sotp-section-2-address" : "(36*1024)", + "sotp-section-2-size" : "(4*1024)", + "sotp-num-sections" : 2, + "update-client.application-details": "(40*1024)" + }, + "WIO_3G": { + "target.features_add" : ["STORAGE", "BOOTLOADER", "LWIP"], + "target.network-default-interface-type" : "CELLULAR", + "target.components_add" : ["SD"], + "target.app_offset" : "0x10400", + "target.header_offset" : "0x10000", + "target.bootloader_img" : "bootloader/mbed-bootloader-WIO_3G.bin", + "sd.SPI_MOSI" : "PC_12", + "sd.SPI_MISO" : "PC_11", + "sd.SPI_CLK" : "PC_10", + "sd.SPI_CS" : "PD_0", + "update-client.application-details" : "(0x08000000+64*1024)", + "sotp-section-1-address" : "(0x08008000)", + "sotp-section-1-size" : "(16*1024)", + "sotp-section-2-address" : "(0x0800C000)", + "sotp-section-2-size" : "(16*1024)", + "sotp-num-sections" : 2, + "lwip.ipv4-enabled" : true, + "lwip.ethernet-enabled" : false, + "lwip.ppp-enabled" : true, + "lwip.tcp-enabled" : true, + "cellular.use-apn-lookup" : false, + "apn" : "\"apn\"", + "username" : "\"username\"", + "password" : "\"password\"" + } + }, + "config": { + "format-storage-layer-on-error": { + "help": "Whether to format the storage layer when it cannot be read - always disable for production devices!", + "value": 1 + }, + "developer-mode": { + "help": "Enable Developer mode to skip Factory enrollment", + "value": 1 + }, + "sotp-section-1-address": { + "help": "Flash sector address for SOTP sector 1", + "macro_name": "PAL_INTERNAL_FLASH_SECTION_1_ADDRESS", + "value": null + }, + "sotp-section-1-size": { + "help": "Flash sector size for SOTP sector 1", + "macro_name": "PAL_INTERNAL_FLASH_SECTION_1_SIZE", + "value": null + }, + "sotp-section-2-address": { + "help": "Flash sector address for SOTP sector 2", + "macro_name": "PAL_INTERNAL_FLASH_SECTION_2_ADDRESS", + "value": null + }, + "sotp-section-2-size": { + "help": "Flash sector size for SOTP sector 2", + "macro_name": "PAL_INTERNAL_FLASH_SECTION_2_SIZE", + "value": null + }, + "sotp-num-sections": { + "help": "Number of SOTP sections", + "macro_name": "PAL_INT_FLASH_NUM_SECTIONS", + "value": null + }, + "sock-type": "TCP", + "sim-pin-code": { + "help": "SIM PIN code", + "value": "\"0000\"" + }, + "apn": { + "help": "The APN string to use for this SIM/network, set to 0 if none", + "value": "\"internet\"" + }, + "username": { + "help": "The user name string to use for this APN, set to zero if none", + "value": 0 + }, + "password": { + "help": "The password string to use for this APN, set to 0 if none", + "value": 0 + } + } +}