BG96_K6xF_pelion-example-frdm_Temp

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(https://os.mbed.com/users/Daniel_Lee/code/BG96_K6xF_pelion-example-frdm/)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/stkim92/pel01.png

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, magnetometer and temperature(on shield). 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 into Compiler

/media/uploads/stkim92/pel1.png

2. Apply Update Certificate

/media/uploads/stkim92/pel03.png

3. Compile and Program

/media/uploads/stkim92/pel04.png

4. If successfully connect to cellular networks(SKTelecom) then you can get below message

Device's Result

include the mbed library with this snippet

You can hold the user button during boot to format the storage and change the device identity.

M2Mnet(BG96) Power ON



Sensors configuration:

FXOS8700Q accelerometer = 0xC7

FXOS8700Q magnetometer  = 0xC7



Connecting to the network using the default network interface...

Connected to the network successfully. IP address: 2001:2D8:65

Initializing Pelion Device Management Client...

Initialized Pelion Device Management Client. Registering...

Press the user button to increment the LwM2M resource value...

Celsius temp : 26.10 C                                                             

FXOS8700Q mag:    0.217 x,   0.420 y,   0.288 z [gauss]     

Pelion Cloud Result (1)

/media/uploads/stkim92/pel4.png

Pelion Cloud Result (2)

/media/uploads/stkim92/pel5.png

Committer:
Daniel_Lee
Date:
Wed Jul 24 16:03:48 2019 +0000
Revision:
11:34e86cb4dd2f
Parent:
0:a9d53048f0b6
Added BG96 power on sequence

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Daniel_Lee 11:34e86cb4dd2f 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
Daniel_Lee 11:34e86cb4dd2f 5
screamer 0:a9d53048f0b6 6 #include <stdint.h>
Daniel_Lee 11:34e86cb4dd2f 7
screamer 0:a9d53048f0b6 8 #ifdef MBED_CLOUD_DEV_UPDATE_ID
Daniel_Lee 11:34e86cb4dd2f 9 const uint8_t arm_uc_vendor_id[] = {
Daniel_Lee 11:34e86cb4dd2f 10 0x8b, 0x9c, 0x29, 0x91, 0xfc, 0xf8, 0x55, 0x8a, 0xa5, 0x30, 0x1d, 0xd4, 0x05, 0xb4, 0x83, 0xb9
Daniel_Lee 11:34e86cb4dd2f 11 };
screamer 0:a9d53048f0b6 12 const uint16_t arm_uc_vendor_id_size = sizeof(arm_uc_vendor_id);
Daniel_Lee 11:34e86cb4dd2f 13
Daniel_Lee 11:34e86cb4dd2f 14 const uint8_t arm_uc_class_id[] = {
Daniel_Lee 11:34e86cb4dd2f 15 0x95, 0x9e, 0xdf, 0x33, 0xe0, 0x68, 0x55, 0xc2, 0x80, 0x7f, 0xb1, 0x6b, 0xa9, 0x8d, 0x29, 0x6a
Daniel_Lee 11:34e86cb4dd2f 16 };
screamer 0:a9d53048f0b6 17 const uint16_t arm_uc_class_id_size = sizeof(arm_uc_class_id);
screamer 0:a9d53048f0b6 18 #endif
Daniel_Lee 11:34e86cb4dd2f 19
screamer 0:a9d53048f0b6 20 #ifdef MBED_CLOUD_DEV_UPDATE_CERT
Daniel_Lee 11:34e86cb4dd2f 21 const uint8_t arm_uc_default_fingerprint[] = {
Daniel_Lee 11:34e86cb4dd2f 22 0xf2, 0x35, 0x6b, 0x7b, 0x7b, 0xf8, 0x67, 0xf5, 0xe9, 0x64, 0xbc, 0x74, 0x46, 0xc2, 0xcb, 0x03,
Daniel_Lee 11:34e86cb4dd2f 23 0x7b, 0xcf, 0x97, 0x95, 0xb4, 0x1b, 0x0b, 0x0f, 0x34, 0x31, 0xf0, 0xc8, 0xf0, 0x52, 0x34, 0x52
Daniel_Lee 11:34e86cb4dd2f 24 };
screamer 0:a9d53048f0b6 25 const uint16_t arm_uc_default_fingerprint_size =
screamer 0:a9d53048f0b6 26 sizeof(arm_uc_default_fingerprint);
Daniel_Lee 11:34e86cb4dd2f 27
Daniel_Lee 11:34e86cb4dd2f 28 const uint8_t arm_uc_default_subject_key_identifier[] = {
Daniel_Lee 11:34e86cb4dd2f 29 };
Daniel_Lee 11:34e86cb4dd2f 30 const uint16_t arm_uc_default_subject_key_identifier_size =
Daniel_Lee 11:34e86cb4dd2f 31 sizeof(arm_uc_default_subject_key_identifier);
Daniel_Lee 11:34e86cb4dd2f 32
Daniel_Lee 11:34e86cb4dd2f 33 const uint8_t arm_uc_default_certificate[] = {
Daniel_Lee 11:34e86cb4dd2f 34 0x30, 0x82, 0x01, 0x4c, 0x30, 0x81, 0xf4, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x14, 0xea, 0xae,
Daniel_Lee 11:34e86cb4dd2f 35 0x79, 0x9d, 0x16, 0xd6, 0x27, 0x94, 0x76, 0x5a, 0x9b, 0x77, 0x7e, 0x6b, 0xfb, 0xd1, 0x39, 0x01,
Daniel_Lee 11:34e86cb4dd2f 36 0x24, 0x17, 0x30, 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x02, 0x30, 0x14,
Daniel_Lee 11:34e86cb4dd2f 37 0x31, 0x12, 0x30, 0x10, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x09, 0x6c, 0x6f, 0x63, 0x61, 0x6c,
Daniel_Lee 11:34e86cb4dd2f 38 0x68, 0x6f, 0x73, 0x74, 0x30, 0x1e, 0x17, 0x0d, 0x31, 0x39, 0x30, 0x37, 0x32, 0x34, 0x31, 0x35,
Daniel_Lee 11:34e86cb4dd2f 39 0x35, 0x32, 0x30, 0x39, 0x5a, 0x17, 0x0d, 0x32, 0x30, 0x30, 0x37, 0x32, 0x34, 0x31, 0x35, 0x30,
Daniel_Lee 11:34e86cb4dd2f 40 0x30, 0x30, 0x30, 0x5a, 0x30, 0x14, 0x31, 0x12, 0x30, 0x10, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c,
Daniel_Lee 11:34e86cb4dd2f 41 0x09, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x68, 0x6f, 0x73, 0x74, 0x30, 0x59, 0x30, 0x13, 0x06, 0x07,
Daniel_Lee 11:34e86cb4dd2f 42 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, 0x01, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x03, 0x01,
Daniel_Lee 11:34e86cb4dd2f 43 0x07, 0x03, 0x42, 0x00, 0x04, 0x6e, 0xbb, 0x70, 0x11, 0xea, 0x3e, 0x1c, 0x7f, 0x2c, 0x4e, 0x12,
Daniel_Lee 11:34e86cb4dd2f 44 0x07, 0x40, 0x43, 0x7f, 0xd4, 0x5e, 0x72, 0x67, 0xf7, 0xa5, 0xf5, 0xf4, 0xdc, 0x0a, 0xff, 0x1f,
Daniel_Lee 11:34e86cb4dd2f 45 0x7b, 0xd7, 0x41, 0x61, 0x47, 0x89, 0xe0, 0x38, 0x7d, 0xcf, 0xcb, 0x12, 0xc6, 0x82, 0xb6, 0x57,
Daniel_Lee 11:34e86cb4dd2f 46 0xcc, 0x81, 0x67, 0x58, 0x0d, 0x5a, 0x37, 0xb3, 0xe6, 0x82, 0xe3, 0xc5, 0x64, 0x64, 0xee, 0xa8,
Daniel_Lee 11:34e86cb4dd2f 47 0x05, 0x62, 0xfb, 0x56, 0x02, 0xa3, 0x24, 0x30, 0x22, 0x30, 0x0b, 0x06, 0x03, 0x55, 0x1d, 0x0f,
Daniel_Lee 11:34e86cb4dd2f 48 0x04, 0x04, 0x03, 0x02, 0x07, 0x80, 0x30, 0x13, 0x06, 0x03, 0x55, 0x1d, 0x25, 0x04, 0x0c, 0x30,
Daniel_Lee 11:34e86cb4dd2f 49 0x0a, 0x06, 0x08, 0x2b, 0x06, 0x01, 0x05, 0x05, 0x07, 0x03, 0x03, 0x30, 0x0a, 0x06, 0x08, 0x2a,
Daniel_Lee 11:34e86cb4dd2f 50 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x02, 0x03, 0x47, 0x00, 0x30, 0x44, 0x02, 0x20, 0xc3, 0xf9,
Daniel_Lee 11:34e86cb4dd2f 51 0xaa, 0x5f, 0x49, 0xa6, 0x25, 0x8d, 0x88, 0x1b, 0xea, 0xc0, 0x53, 0xd5, 0x57, 0xc5, 0x2a, 0x61,
Daniel_Lee 11:34e86cb4dd2f 52 0xfd, 0xe2, 0x0d, 0xc4, 0x38, 0x22, 0xcf, 0x96, 0xfe, 0xd5, 0xbf, 0xcc, 0x46, 0x9a, 0x02, 0x20,
Daniel_Lee 11:34e86cb4dd2f 53 0x42, 0x4e, 0x38, 0xca, 0xf4, 0xb4, 0x30, 0x61, 0xaa, 0xbd, 0x54, 0xfe, 0xf6, 0x3d, 0xb2, 0x64,
Daniel_Lee 11:34e86cb4dd2f 54 0x12, 0xc0, 0xa7, 0x2e, 0xca, 0x88, 0xdd, 0x58, 0xaf, 0xcd, 0xf3, 0x26, 0xdb, 0xa7, 0x0d, 0x9d
Daniel_Lee 11:34e86cb4dd2f 55 };
Daniel_Lee 11:34e86cb4dd2f 56 const uint16_t arm_uc_default_certificate_size = sizeof(arm_uc_default_certificate);
Daniel_Lee 11:34e86cb4dd2f 57 #endif
Daniel_Lee 11:34e86cb4dd2f 58
Daniel_Lee 11:34e86cb4dd2f 59
Daniel_Lee 11:34e86cb4dd2f 60 #ifdef MBED_CLOUD_DEV_UPDATE_PSK
Daniel_Lee 11:34e86cb4dd2f 61 const uint8_t arm_uc_default_psk[] = {
Daniel_Lee 11:34e86cb4dd2f 62
Daniel_Lee 11:34e86cb4dd2f 63 };
Daniel_Lee 11:34e86cb4dd2f 64 const uint8_t arm_uc_default_psk_size = sizeof(arm_uc_default_psk);
Daniel_Lee 11:34e86cb4dd2f 65 const uint16_t arm_uc_default_psk_bits = sizeof(arm_uc_default_psk)*8;
Daniel_Lee 11:34e86cb4dd2f 66
Daniel_Lee 11:34e86cb4dd2f 67 const uint8_t arm_uc_default_psk_id[] = {
Daniel_Lee 11:34e86cb4dd2f 68
Daniel_Lee 11:34e86cb4dd2f 69 };
Daniel_Lee 11:34e86cb4dd2f 70 const uint8_t arm_uc_default_psk_id_size = sizeof(arm_uc_default_psk_id);
Daniel_Lee 11:34e86cb4dd2f 71 #endif