Prepare example app Connect+FW Update

Fork of example-ODINW2-mbed-Cloud-connect by u-blox

Files at this revision

API Documentation at this revision

Comitter:
MarceloSalazar
Date:
Sun Oct 14 19:41:29 2018 +0100
Parent:
6:4fea66d52b5d
Commit message:
Add support for Connect+Update

Changed in this revision

bootloader/mbed-bootloader-ODIN-EVK.bin Show annotated file Show diff for this revision Revisions of this file
bootloader/mbed_app.json Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed_app.json Show annotated file Show diff for this revision Revisions of this file
mbed_cloud_dev_credentials.c Show annotated file Show diff for this revision Revisions of this file
simple-mbed-cloud-client.lib Show annotated file Show diff for this revision Revisions of this file
Binary file bootloader/mbed-bootloader-ODIN-EVK.bin has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bootloader/mbed_app.json	Sun Oct 14 19:41:29 2018 +0100
@@ -0,0 +1,62 @@
+{
+    "macros": [
+        "MBEDTLS_USER_CONFIG_FILE=\"bootloader_mbedtls_user_config.h\"",
+        "MAX_COPY_RETRIES=1",
+        "SHOW_PROGRESS_BAR=1",
+        "MAX_BOOT_RETRIES=3",
+        "ARM_UC_USE_PAL_CRYPTO=0",
+        "ARM_BOOTLOADER_USE_NVSTORE_ROT=1",
+        "ARM_UC_USE_PAL_BLOCKDEVICE=1",
+        "ARM_UC_PAAL_TRACE_ENABLE=0",
+        "MBED_CLOUD_CLIENT_UPDATE_STORAGE=ARM_UCP_FLASHIAP_BLOCKDEVICE",
+        "DEFAULT_MAX_APPLICATION_SIZE=(MBED_CONF_APP_FLASH_START_ADDRESS + MBED_CONF_APP_FLASH_SIZE - MBED_CONF_APP_APPLICATION_START_ADDRESS)",
+        "DISABLE_ERROR_DESCRIPTION=1",
+        "Mutex=PlatformMutex"
+    ],
+    "config": {
+        "application-start-address": {
+            "help": "Address to the beginning of the active application firmware in flash",
+            "value": null
+        },
+        "application-jump-address": {
+            "help": "Jump address for running the active application firmware",
+            "value": null
+        },
+        "max-application-size": {
+            "help": "Maximum size of the active application",
+            "value": null
+        },
+        "flash-start-address": {
+            "help": "Start address of internal flash. Only used in this config to help the definition of other macros.",
+            "value": null
+        },
+        "flash-size": {
+            "help": "Total size of internal flash. Only used in this config to help the definition of other macros.",
+            "value": null
+        }
+    },
+    "target_overrides": {
+        "*": {
+            "target.features_remove": ["LWIP"],
+            "target.features_add"   : ["COMMON_PAL"],
+            "platform.stdio-baud-rate"    : 115200,
+            "platform.stdio-flush-at-exit": false,
+            "update-client.storage-address"  : "(1024*1024*64)",
+            "update-client.storage-size"     : "(1024*1024*2)",
+            "update-client.storage-locations": 1,
+            "update-client.firmware-header-version": "2"
+        },
+        "UBLOX_EVK_ODIN_W2": {
+            "target.device_has_remove"         : ["EMAC"],
+            "flash-start-address"              : "0x08000000",
+            "flash-size"                       : "(2048*1024)",
+            "nvstore.area_1_address"           : "(MBED_CONF_APP_FLASH_START_ADDRESS+32*1024)",
+            "nvstore.area_1_size"              : "(16*1024)",
+            "nvstore.area_2_address"           : "(MBED_CONF_APP_FLASH_START_ADDRESS+48*1024)",
+            "nvstore.area_2_size"              : "(16*1024)",
+            "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"
+        }
+    }
+}
--- a/main.cpp	Sun Oct 14 18:08:15 2018 +0000
+++ b/main.cpp	Sun Oct 14 19:41:29 2018 +0100
@@ -15,20 +15,21 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 // ----------------------------------------------------------------------------
-
+#ifndef MBED_TEST_MODE
 #include "mbed.h"
 #include "simple-mbed-cloud-client.h"
-#include "SDBlockDevice.h"
 #include "FATFileSystem.h"
-#include "OdinWiFiInterface.h"
 
 // An event queue is a very useful structure to debounce information between contexts (e.g. ISR and normal threads)
 // This is great because things such as network operations are illegal in ISR, so updating a resource in a button's fall() function is not allowed
 EventQueue eventQueue;
 
-// Storage implementation definition, currently using SDBlockDevice (SPI flash, DataFlash, and internal flash are also available)
-SDBlockDevice sd(D11, D12, D13, D9);
-FATFileSystem fs("sd", &sd);
+// Default block device
+BlockDevice* bd = BlockDevice::get_default_instance();
+FATFileSystem fs("sd", bd);
+
+// Default network interface object
+NetworkInterface *net;
 
 // Declaring pointers for access to Mbed Cloud Client resources outside of main()
 MbedCloudClientResource *button_res;
@@ -96,29 +97,30 @@
  * @param endpoint Information about the registered endpoint such as the name (so you can find it back in portal)
  */
 void registered(const ConnectorClientEndpointInfo *endpoint) {
-    printf("Connected to Mbed Cloud. Endpoint Name: %s\n", endpoint->internal_endpoint_name.c_str());
+    printf("Connected to Pelion Device Management. Endpoint Name: %s\n", endpoint->internal_endpoint_name.c_str());
 }
 
 int main(void) {
-    printf("Starting Simple Mbed Cloud Client example\n");
-    printf("Connecting to the network using Odin WiFi...\n");
+    printf("Starting Simple Pelion Device Management Client example\n");
+    printf("Connecting to the network...\n");
 
     // Connect to the internet (DHCP is expected to be on)
-    OdinWiFiInterface net;
-    nsapi_error_t status = net.connect(MBED_CONF_APP_WIFI_SSID, MBED_CONF_APP_WIFI_PASSWORD, NSAPI_SECURITY_WPA_WPA2);
+    net = NetworkInterface::get_default_instance();
 
-    if (status != 0) {
+    nsapi_error_t status = net->connect();
+
+    if (status != NSAPI_ERROR_OK) {
         printf("Connecting to the network failed %d!\n", status);
         return -1;
     }
 
-    printf("Connected to the network successfully. IP address: %s\n", net.get_ip_address());
+    printf("Connected to the network successfully. IP address: %s\n", net->get_ip_address());
 
     // SimpleMbedCloudClient handles registering over LwM2M to Mbed Cloud
-    SimpleMbedCloudClient client(&net, &sd, &fs);
+    SimpleMbedCloudClient client(net, bd, &fs);
     int client_status = client.init();
     if (client_status != 0) {
-        printf("Initializing Mbed Cloud Client failed (%d)\n", client_status);
+        printf("Pelion Client initialization failed (%d)\n", client_status);
         return -1;
     }
 
@@ -138,7 +140,7 @@
     blink_res->methods(M2MMethod::POST);
     blink_res->attach_post_callback(blink_callback);
 
-    printf("Initialized Mbed Cloud Client. Registering...\n");
+    printf("Initialized Pelion Client. Registering...\n");
 
     // Callback that fires when registering is complete
     client.on_registered(&registered);
@@ -154,5 +156,4 @@
     // You can easily run the eventQueue in a separate thread if required
     eventQueue.dispatch_forever();
 }
-
-
+#endif
--- a/mbed_app.json	Sun Oct 14 18:08:15 2018 +0000
+++ b/mbed_app.json	Sun Oct 14 19:41:29 2018 +0100
@@ -5,9 +5,8 @@
         "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=6608",
+        "MBED_CONF_APP_MAIN_STACK_SIZE=7000",
         "ARM_UC_USE_PAL_BLOCKDEVICE=1",
-        "PAL_INT_FLASH_NUM_SECTIONS=2" ,
         "MBED_CLOUD_CLIENT_UPDATE_STORAGE=ARM_UCP_FLASHIAP_BLOCKDEVICE"
     ],
     "target_overrides": {
@@ -45,14 +44,6 @@
             "help": "Enable Developer mode to skip Factory enrollment",
             "value": 1
         },
-        "wifi-ssid": {
-            "help": "WiFi SSID",
-            "value": "\"SSID\""
-        },
-        "wifi-password": {
-            "help": "WiFi Password",
-            "value": "\"Password\""
-        },
         "sotp-section-1-address": {
             "help": "Flash sector address for SOTP sector 1",
             "macro_name": "PAL_INTERNAL_FLASH_SECTION_1_ADDRESS",
@@ -72,6 +63,11 @@
             "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
         }
     }
-}
\ No newline at end of file
+}
--- a/mbed_cloud_dev_credentials.c	Sun Oct 14 18:08:15 2018 +0000
+++ b/mbed_cloud_dev_credentials.c	Sun Oct 14 19:41:29 2018 +0100
@@ -1,53 +1,53 @@
-/*
- * Copyright (c) 2017 ARM Limited. All rights reserved.
- * SPDX-License-Identifier: Apache-2.0
- * Licensed under the Apache License, Version 2.0 (the License); you may
- * not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#ifndef __MBED_CLOUD_DEV_CREDENTIALS_H__
-#define __MBED_CLOUD_DEV_CREDENTIALS_H__
-
-#if MBED_CONF_APP_DEVELOPER_MODE == 1
-#error "Replace mbed_cloud_dev_credentials.c with your own developer cert."
-#endif
-
-#include <inttypes.h>
-
-const char MBED_CLOUD_DEV_BOOTSTRAP_ENDPOINT_NAME[] = "";
-const char MBED_CLOUD_DEV_ACCOUNT_ID[] = "";
-const char MBED_CLOUD_DEV_BOOTSTRAP_SERVER_URI[] = "";
-
-const uint8_t MBED_CLOUD_DEV_BOOTSTRAP_DEVICE_CERTIFICATE[] =
-{ 0x0 };
-
-const uint8_t MBED_CLOUD_DEV_BOOTSTRAP_SERVER_ROOT_CA_CERTIFICATE[] =
-{ 0x0 };
-
-const uint8_t MBED_CLOUD_DEV_BOOTSTRAP_DEVICE_PRIVATE_KEY[] =
-{ 0x0 };
-
-const char MBED_CLOUD_DEV_MANUFACTURER[] = "dev_manufacturer";
-
-const char MBED_CLOUD_DEV_MODEL_NUMBER[] = "dev_model_num";
-
-const char MBED_CLOUD_DEV_SERIAL_NUMBER[] = "0";
-
-const char MBED_CLOUD_DEV_DEVICE_TYPE[] = "dev_device_type";
-
-const char MBED_CLOUD_DEV_HARDWARE_VERSION[] = "dev_hardware_version";
-
-const uint32_t MBED_CLOUD_DEV_MEMORY_TOTAL_KB = 0;
-const uint32_t MBED_CLOUD_DEV_BOOTSTRAP_DEVICE_CERTIFICATE_SIZE = sizeof(MBED_CLOUD_DEV_BOOTSTRAP_DEVICE_CERTIFICATE);
-const uint32_t MBED_CLOUD_DEV_BOOTSTRAP_SERVER_ROOT_CA_CERTIFICATE_SIZE = sizeof(MBED_CLOUD_DEV_BOOTSTRAP_SERVER_ROOT_CA_CERTIFICATE);
-const uint32_t MBED_CLOUD_DEV_BOOTSTRAP_DEVICE_PRIVATE_KEY_SIZE = sizeof(MBED_CLOUD_DEV_BOOTSTRAP_DEVICE_PRIVATE_KEY);
-
-#endif //__MBED_CLOUD_DEV_CREDENTIALS_H__
+/*
+ * Copyright (c) 2017 ARM Limited. All rights reserved.
+ * SPDX-License-Identifier: Apache-2.0
+ * Licensed under the Apache License, Version 2.0 (the License); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef __MBED_CLOUD_DEV_CREDENTIALS_H__
+#define __MBED_CLOUD_DEV_CREDENTIALS_H__
+
+#if MBED_CONF_APP_DEVELOPER_MODE == 1
+#error "Replace mbed_cloud_dev_credentials.c with your own developer cert."
+#endif
+
+#include <inttypes.h>
+
+const char MBED_CLOUD_DEV_BOOTSTRAP_ENDPOINT_NAME[] = "";
+const char MBED_CLOUD_DEV_ACCOUNT_ID[] = "";
+const char MBED_CLOUD_DEV_BOOTSTRAP_SERVER_URI[] = "";
+
+const uint8_t MBED_CLOUD_DEV_BOOTSTRAP_DEVICE_CERTIFICATE[] =
+{ 0x0 };
+
+const uint8_t MBED_CLOUD_DEV_BOOTSTRAP_SERVER_ROOT_CA_CERTIFICATE[] =
+{ 0x0 };
+
+const uint8_t MBED_CLOUD_DEV_BOOTSTRAP_DEVICE_PRIVATE_KEY[] =
+{ 0x0 };
+
+const char MBED_CLOUD_DEV_MANUFACTURER[] = "dev_manufacturer";
+
+const char MBED_CLOUD_DEV_MODEL_NUMBER[] = "dev_model_num";
+
+const char MBED_CLOUD_DEV_SERIAL_NUMBER[] = "0";
+
+const char MBED_CLOUD_DEV_DEVICE_TYPE[] = "dev_device_type";
+
+const char MBED_CLOUD_DEV_HARDWARE_VERSION[] = "dev_hardware_version";
+
+const uint32_t MBED_CLOUD_DEV_MEMORY_TOTAL_KB = 0;
+const uint32_t MBED_CLOUD_DEV_BOOTSTRAP_DEVICE_CERTIFICATE_SIZE = sizeof(MBED_CLOUD_DEV_BOOTSTRAP_DEVICE_CERTIFICATE);
+const uint32_t MBED_CLOUD_DEV_BOOTSTRAP_SERVER_ROOT_CA_CERTIFICATE_SIZE = sizeof(MBED_CLOUD_DEV_BOOTSTRAP_SERVER_ROOT_CA_CERTIFICATE);
+const uint32_t MBED_CLOUD_DEV_BOOTSTRAP_DEVICE_PRIVATE_KEY_SIZE = sizeof(MBED_CLOUD_DEV_BOOTSTRAP_DEVICE_PRIVATE_KEY);
+
+#endif //__MBED_CLOUD_DEV_CREDENTIALS_H__
--- a/simple-mbed-cloud-client.lib	Sun Oct 14 18:08:15 2018 +0000
+++ b/simple-mbed-cloud-client.lib	Sun Oct 14 19:41:29 2018 +0100
@@ -1,1 +1,1 @@
-https://github.com/armmbed/simple-mbed-cloud-client/#9f05156e8386f7ef27a0194d12546b8397c0c564
+https://github.com/armmbed/simple-mbed-cloud-client/#8b023aa9e04bcd15ac01726c6f5b58b9422fafad