Pelion example for WIZnet IoT Shield with BG96 Cat.M1, K6xF board (SK telecom network in Korea)

Dependencies:   FXAS21002 FXOS8700Q

Overview

This document is based on https://os.mbed.com/teams/NXP/code/pelion-example-frdm/ and the code forked Daniel_Lee's BG96_K6xF_pelion-example-frdm repository and added some features. Need a WIZnet IoT Shield BG96 board and development board.

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

/media/uploads/hkjung/wiznetiotshield_bg96_frdm-k64f_separate.png /media/uploads/hkjung/wiznetiotshield_bg96_frdm-k64f_stacking.png

  • FRDM-K64F - onboard Ethernet and onboard SD card holder.
  • FRDM-K66F - onboard Ethernet and onboard SD card holder.

Requirement

  1. FRDM-K64F or FRDM-K66F
  2. WIZnet IoT Shield BG96 board
  3. USIM card

Example functionality

This example showcases the following device functionality:

Read onboard FXOS8700Q accelerometer and magnetometer, and report the values as Pelion LWM2M resources (see image below). (FRDM-K66F only) Read onboard FXAS21002 gyroscope and report the values as Pelion LWM2M resources. 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.

1. Import the application into your desktop:

mbed import https://os.mbed.com/users/hkjung/code/BG96_K6xF_pelion-example-frdm/
 
cd BG96_K6xF_pelion-example-frdm

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 the above command does not work for your Mbed CLI, please consider upgrading Mbed CLI to version 1.9.x or above.

4. Compile and program:

mbed compile -t <toolchain> -m <TARGET_BOARD>

(supported toolchains : GCC_ARM / ARM / IAR)

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

mbed sterm -b 115200

6. If successfully connect to cellular networks(SK Telecom) then you can get below message

[BOOT] Mbed Bootloader
[BOOT] ARM: 00000000000000000000
[BOOT] OEM: 00000000000000000000
[BOOT] Layout: 0 83A8
[BOOT] Active firmware integrity check:
[BOOT] SHA256: 76F082FDFF2C0E6C64A76DCF8957773A14B4146629424A0C7F71858788F24521
[BOOT] Version: 1556777151
[BOOT] Slot 0 is empty
[BOOT] Active firmware up-to-date
[BOOT] Application's start address: 0x10400
[BOOT] Application's jump address: 0x10B11
[BOOT] Application's stack address: 0x20030000
[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.

Sensors configuration:
FXOS8700Q accelerometer = 0xC7
FXOS8700Q magnetometer  = 0xC7

Connecting to the network using the default network interface...
Connected to the network successfully. IP address: 000:000:000:000
Initializing Pelion Device Management Client...
Initialized Pelion Device Management Client. Registering...
Press the user button to increment the LwM2M resource value...
Registered to Pelion Device Management. Endpoint Name: xx Your Endpoint Name xx

FXOS8700Q mag:    0.903 x,  -0.073 y,   0.477 z [gauss]
FXOS8700Q acc:   -1.143 x,  -2.459 y,   3.316 z [g]
Committer:
hkjung
Date:
Thu May 02 06:12:45 2019 +0000
Revision:
8:28b898a501b4
Parent:
0:a9d53048f0b6
Added hardware reset function for WIZnet IoT Shield BG96

Who changed what in which revision?

UserRevisionLine numberNew contents of line
hkjung 8:28b898a501b4 1
screamer 0:a9d53048f0b6 2 #ifdef MBED_CLOUD_CLIENT_USER_CONFIG_FILE
screamer 0:a9d53048f0b6 3 #include MBED_CLOUD_CLIENT_USER_CONFIG_FILE
screamer 0:a9d53048f0b6 4 #endif
hkjung 8:28b898a501b4 5
screamer 0:a9d53048f0b6 6 #include <stdint.h>
hkjung 8:28b898a501b4 7
screamer 0:a9d53048f0b6 8 #ifdef MBED_CLOUD_DEV_UPDATE_ID
hkjung 8:28b898a501b4 9 const uint8_t arm_uc_vendor_id[] = {
hkjung 8:28b898a501b4 10 0x8b, 0x9c, 0x29, 0x91, 0xfc, 0xf8, 0x55, 0x8a, 0xa5, 0x30, 0x1d, 0xd4, 0x05, 0xb4, 0x83, 0xb9
hkjung 8:28b898a501b4 11 };
screamer 0:a9d53048f0b6 12 const uint16_t arm_uc_vendor_id_size = sizeof(arm_uc_vendor_id);
hkjung 8:28b898a501b4 13
hkjung 8:28b898a501b4 14 const uint8_t arm_uc_class_id[] = {
hkjung 8:28b898a501b4 15 0x95, 0x9e, 0xdf, 0x33, 0xe0, 0x68, 0x55, 0xc2, 0x80, 0x7f, 0xb1, 0x6b, 0xa9, 0x8d, 0x29, 0x6a
hkjung 8:28b898a501b4 16 };
screamer 0:a9d53048f0b6 17 const uint16_t arm_uc_class_id_size = sizeof(arm_uc_class_id);
screamer 0:a9d53048f0b6 18 #endif
hkjung 8:28b898a501b4 19
screamer 0:a9d53048f0b6 20 #ifdef MBED_CLOUD_DEV_UPDATE_CERT
hkjung 8:28b898a501b4 21 const uint8_t arm_uc_default_fingerprint[] = {
hkjung 8:28b898a501b4 22 0x9f, 0xf5, 0xa6, 0x54, 0x58, 0xda, 0x45, 0xac, 0x53, 0x30, 0x85, 0xe7, 0xcc, 0x03, 0x75, 0xb2,
hkjung 8:28b898a501b4 23 0x23, 0xea, 0xc2, 0x6c, 0x5f, 0xd2, 0x2d, 0x0b, 0xa6, 0xfe, 0xbc, 0xdd, 0xe3, 0x65, 0x49, 0x9c
hkjung 8:28b898a501b4 24 };
screamer 0:a9d53048f0b6 25 const uint16_t arm_uc_default_fingerprint_size =
screamer 0:a9d53048f0b6 26 sizeof(arm_uc_default_fingerprint);
hkjung 8:28b898a501b4 27
hkjung 8:28b898a501b4 28 const uint8_t arm_uc_default_subject_key_identifier[] = {
hkjung 8:28b898a501b4 29 };
hkjung 8:28b898a501b4 30 const uint16_t arm_uc_default_subject_key_identifier_size =
hkjung 8:28b898a501b4 31 sizeof(arm_uc_default_subject_key_identifier);
hkjung 8:28b898a501b4 32
hkjung 8:28b898a501b4 33 const uint8_t arm_uc_default_certificate[] = {
hkjung 8:28b898a501b4 34 0x30, 0x82, 0x01, 0x4c, 0x30, 0x81, 0xf4, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x14, 0x9d, 0x07,
hkjung 8:28b898a501b4 35 0x98, 0x1f, 0x53, 0x86, 0x4b, 0x62, 0x94, 0x8a, 0x88, 0xa5, 0x2a, 0x07, 0xea, 0x4d, 0x64, 0x0c,
hkjung 8:28b898a501b4 36 0xc2, 0xe9, 0x30, 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x02, 0x30, 0x14,
hkjung 8:28b898a501b4 37 0x31, 0x12, 0x30, 0x10, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x09, 0x6c, 0x6f, 0x63, 0x61, 0x6c,
hkjung 8:28b898a501b4 38 0x68, 0x6f, 0x73, 0x74, 0x30, 0x1e, 0x17, 0x0d, 0x31, 0x39, 0x30, 0x35, 0x30, 0x32, 0x30, 0x34,
hkjung 8:28b898a501b4 39 0x35, 0x32, 0x34, 0x34, 0x5a, 0x17, 0x0d, 0x32, 0x30, 0x30, 0x35, 0x30, 0x31, 0x31, 0x35, 0x30,
hkjung 8:28b898a501b4 40 0x30, 0x30, 0x30, 0x5a, 0x30, 0x14, 0x31, 0x12, 0x30, 0x10, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c,
hkjung 8:28b898a501b4 41 0x09, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x68, 0x6f, 0x73, 0x74, 0x30, 0x59, 0x30, 0x13, 0x06, 0x07,
hkjung 8:28b898a501b4 42 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, 0x01, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x03, 0x01,
hkjung 8:28b898a501b4 43 0x07, 0x03, 0x42, 0x00, 0x04, 0x21, 0x7c, 0xa1, 0x11, 0x55, 0xbf, 0xcb, 0xf5, 0x18, 0x97, 0x40,
hkjung 8:28b898a501b4 44 0xae, 0xa2, 0x43, 0xce, 0xa2, 0x66, 0x41, 0x13, 0xf3, 0x2f, 0x92, 0x2e, 0xc4, 0xf1, 0x42, 0x52,
hkjung 8:28b898a501b4 45 0x60, 0x10, 0x08, 0xc5, 0x26, 0x61, 0x76, 0xa2, 0xcc, 0xfd, 0x99, 0x88, 0x7e, 0xc5, 0x9d, 0x6c,
hkjung 8:28b898a501b4 46 0xe0, 0x4f, 0x45, 0xae, 0x10, 0x1e, 0x9c, 0x87, 0x50, 0x86, 0x17, 0x7b, 0x41, 0x2c, 0x4c, 0x8e,
hkjung 8:28b898a501b4 47 0x33, 0xdb, 0x08, 0x40, 0x36, 0xa3, 0x24, 0x30, 0x22, 0x30, 0x0b, 0x06, 0x03, 0x55, 0x1d, 0x0f,
hkjung 8:28b898a501b4 48 0x04, 0x04, 0x03, 0x02, 0x07, 0x80, 0x30, 0x13, 0x06, 0x03, 0x55, 0x1d, 0x25, 0x04, 0x0c, 0x30,
hkjung 8:28b898a501b4 49 0x0a, 0x06, 0x08, 0x2b, 0x06, 0x01, 0x05, 0x05, 0x07, 0x03, 0x03, 0x30, 0x0a, 0x06, 0x08, 0x2a,
hkjung 8:28b898a501b4 50 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x02, 0x03, 0x47, 0x00, 0x30, 0x44, 0x02, 0x20, 0xc8, 0x0a,
hkjung 8:28b898a501b4 51 0x4d, 0x8e, 0xae, 0xee, 0xb6, 0xa6, 0x7c, 0x2a, 0x87, 0x4b, 0x24, 0xd1, 0xb8, 0x14, 0x0d, 0xf3,
hkjung 8:28b898a501b4 52 0x92, 0x2b, 0x6c, 0xc0, 0x6e, 0x1a, 0x29, 0x5f, 0x8d, 0xf3, 0xc4, 0x0f, 0x65, 0x40, 0x02, 0x20,
hkjung 8:28b898a501b4 53 0xe4, 0xd4, 0xbb, 0x40, 0xe3, 0x7a, 0x4b, 0xd1, 0x51, 0x96, 0x23, 0x4b, 0x24, 0x75, 0xf3, 0x8f,
hkjung 8:28b898a501b4 54 0x34, 0x91, 0x3a, 0xe7, 0x13, 0xae, 0x9d, 0x1d, 0xc1, 0x95, 0x71, 0x6e, 0x5f, 0xcd, 0x04, 0xc1
hkjung 8:28b898a501b4 55 };
hkjung 8:28b898a501b4 56 const uint16_t arm_uc_default_certificate_size = sizeof(arm_uc_default_certificate);
hkjung 8:28b898a501b4 57 #endif
hkjung 8:28b898a501b4 58
hkjung 8:28b898a501b4 59
hkjung 8:28b898a501b4 60 #ifdef MBED_CLOUD_DEV_UPDATE_PSK
hkjung 8:28b898a501b4 61 const uint8_t arm_uc_default_psk[] = {
hkjung 8:28b898a501b4 62
hkjung 8:28b898a501b4 63 };
hkjung 8:28b898a501b4 64 const uint8_t arm_uc_default_psk_size = sizeof(arm_uc_default_psk);
hkjung 8:28b898a501b4 65 const uint16_t arm_uc_default_psk_bits = sizeof(arm_uc_default_psk)*8;
hkjung 8:28b898a501b4 66
hkjung 8:28b898a501b4 67 const uint8_t arm_uc_default_psk_id[] = {
hkjung 8:28b898a501b4 68
hkjung 8:28b898a501b4 69 };
hkjung 8:28b898a501b4 70 const uint8_t arm_uc_default_psk_id_size = sizeof(arm_uc_default_psk_id);
hkjung 8:28b898a501b4 71 #endif