NuMaker Pelion Device Management example

Fork of mbed-os-example-pelion by cc li

Committer:
ccli8
Date:
Thu Aug 05 15:06:55 2021 +0800
Revision:
18:029355615cc7
Parent:
16:75a4830fc40a
Update to mbed-os 5.15.7, mcc 4.10.0, and NUSD

1. Update to mbed-os 5.15.7
2. Update ot mbed-cloud-client 4.10.0
3. Update NUSD

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ccli8 0:f78ec4a22e67 1 // ----------------------------------------------------------------------------
ccli8 11:d147172e94b5 2 // Copyright 2016-2020 ARM Ltd.
ccli8 0:f78ec4a22e67 3 //
ccli8 0:f78ec4a22e67 4 // SPDX-License-Identifier: Apache-2.0
ccli8 0:f78ec4a22e67 5 //
ccli8 0:f78ec4a22e67 6 // Licensed under the Apache License, Version 2.0 (the "License");
ccli8 0:f78ec4a22e67 7 // you may not use this file except in compliance with the License.
ccli8 0:f78ec4a22e67 8 // You may obtain a copy of the License at
ccli8 0:f78ec4a22e67 9 //
ccli8 0:f78ec4a22e67 10 // http://www.apache.org/licenses/LICENSE-2.0
ccli8 0:f78ec4a22e67 11 //
ccli8 0:f78ec4a22e67 12 // Unless required by applicable law or agreed to in writing, software
ccli8 0:f78ec4a22e67 13 // distributed under the License is distributed on an "AS IS" BASIS,
ccli8 0:f78ec4a22e67 14 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
ccli8 0:f78ec4a22e67 15 // See the License for the specific language governing permissions and
ccli8 0:f78ec4a22e67 16 // limitations under the License.
ccli8 0:f78ec4a22e67 17 // ----------------------------------------------------------------------------
ccli8 0:f78ec4a22e67 18 #ifndef MBED_TEST_MODE
ccli8 0:f78ec4a22e67 19 #include "mbed.h"
ccli8 0:f78ec4a22e67 20 #include "kv_config.h"
ccli8 0:f78ec4a22e67 21 #include "mbed-cloud-client/MbedCloudClient.h" // Required for new MbedCloudClient()
ccli8 0:f78ec4a22e67 22 #include "factory_configurator_client.h" // Required for fcc_* functions and FCC_* defines
ccli8 0:f78ec4a22e67 23 #include "m2mresource.h" // Required for M2MResource
ccli8 11:d147172e94b5 24 #include "key_config_manager.h" // Required for kcm_factory_reset
ccli8 0:f78ec4a22e67 25
ccli8 0:f78ec4a22e67 26 #include "mbed-trace/mbed_trace.h" // Required for mbed_trace_*
ccli8 0:f78ec4a22e67 27
ccli8 0:f78ec4a22e67 28 // Pointers to the resources that will be created in main_application().
ccli8 0:f78ec4a22e67 29 static MbedCloudClient *cloud_client;
ccli8 0:f78ec4a22e67 30 static bool cloud_client_running = true;
ccli8 0:f78ec4a22e67 31 static NetworkInterface *network = NULL;
ccli8 11:d147172e94b5 32 static int error_count = 0;
ccli8 0:f78ec4a22e67 33
ccli8 0:f78ec4a22e67 34 // Fake entropy needed for non-TRNG boards. Suitable only for demo devices.
ccli8 0:f78ec4a22e67 35 const uint8_t MBED_CLOUD_DEV_ENTROPY[] = { 0xf6, 0xd6, 0xc0, 0x09, 0x9e, 0x6e, 0xf2, 0x37, 0xdc, 0x29, 0x88, 0xf1, 0x57, 0x32, 0x7d, 0xde, 0xac, 0xb3, 0x99, 0x8c, 0xb9, 0x11, 0x35, 0x18, 0xeb, 0x48, 0x29, 0x03, 0x6a, 0x94, 0x6d, 0xe8, 0x40, 0xc0, 0x28, 0xcc, 0xe4, 0x04, 0xc3, 0x1f, 0x4b, 0xc2, 0xe0, 0x68, 0xa0, 0x93, 0xe6, 0x3a };
ccli8 11:d147172e94b5 36 const int MAX_ERROR_COUNT = 5;
ccli8 0:f78ec4a22e67 37
ccli8 0:f78ec4a22e67 38 static M2MResource* m2m_get_res;
ccli8 0:f78ec4a22e67 39 static M2MResource* m2m_put_res;
ccli8 0:f78ec4a22e67 40 static M2MResource* m2m_post_res;
ccli8 0:f78ec4a22e67 41 static M2MResource* m2m_deregister_res;
ccli8 11:d147172e94b5 42 static M2MResource* m2m_factory_reset_res;
ccli8 11:d147172e94b5 43 static SocketAddress sa;
ccli8 11:d147172e94b5 44
ccli8 11:d147172e94b5 45 EventQueue queue(32 * EVENTS_EVENT_SIZE);
ccli8 11:d147172e94b5 46 Thread t;
ccli8 11:d147172e94b5 47 Mutex value_increment_mutex;
ccli8 0:f78ec4a22e67 48
ccli8 0:f78ec4a22e67 49 void print_client_ids(void)
ccli8 0:f78ec4a22e67 50 {
ccli8 0:f78ec4a22e67 51 printf("Account ID: %s\n", cloud_client->endpoint_info()->account_id.c_str());
ccli8 0:f78ec4a22e67 52 printf("Endpoint name: %s\n", cloud_client->endpoint_info()->internal_endpoint_name.c_str());
ccli8 11:d147172e94b5 53 printf("Device ID: %s\n\n", cloud_client->endpoint_info()->endpoint_name.c_str());
ccli8 0:f78ec4a22e67 54 }
ccli8 0:f78ec4a22e67 55
ccli8 11:d147172e94b5 56 void value_increment(void)
ccli8 0:f78ec4a22e67 57 {
ccli8 11:d147172e94b5 58 value_increment_mutex.lock();
ccli8 0:f78ec4a22e67 59 m2m_get_res->set_value(m2m_get_res->get_value_int() + 1);
ccli8 0:f78ec4a22e67 60 printf("Counter %" PRIu64 "\n", m2m_get_res->get_value_int());
ccli8 11:d147172e94b5 61 value_increment_mutex.unlock();
ccli8 0:f78ec4a22e67 62 }
ccli8 0:f78ec4a22e67 63
ccli8 11:d147172e94b5 64 void get_res_update(const char* /*object_name*/)
ccli8 11:d147172e94b5 65 {
ccli8 11:d147172e94b5 66 printf("Counter resource set to %d\n", (int)m2m_get_res->get_value_int());
ccli8 11:d147172e94b5 67 }
ccli8 11:d147172e94b5 68
ccli8 11:d147172e94b5 69 void put_res_update(const char* /*object_name*/)
ccli8 0:f78ec4a22e67 70 {
ccli8 0:f78ec4a22e67 71 printf("PUT update %d\n", (int)m2m_put_res->get_value_int());
ccli8 0:f78ec4a22e67 72 }
ccli8 0:f78ec4a22e67 73
ccli8 0:f78ec4a22e67 74 void execute_post(void* /*arguments*/)
ccli8 0:f78ec4a22e67 75 {
ccli8 0:f78ec4a22e67 76 printf("POST executed\n");
ccli8 0:f78ec4a22e67 77 }
ccli8 0:f78ec4a22e67 78
ccli8 0:f78ec4a22e67 79 void deregister_client(void)
ccli8 0:f78ec4a22e67 80 {
ccli8 0:f78ec4a22e67 81 printf("Unregistering and disconnecting from the network.\n");
ccli8 0:f78ec4a22e67 82 cloud_client->close();
ccli8 0:f78ec4a22e67 83 }
ccli8 0:f78ec4a22e67 84
ccli8 0:f78ec4a22e67 85 void deregister(void* /*arguments*/)
ccli8 0:f78ec4a22e67 86 {
ccli8 0:f78ec4a22e67 87 printf("POST deregister executed\n");
ccli8 0:f78ec4a22e67 88 m2m_deregister_res->send_delayed_post_response();
ccli8 0:f78ec4a22e67 89
ccli8 0:f78ec4a22e67 90 deregister_client();
ccli8 0:f78ec4a22e67 91 }
ccli8 0:f78ec4a22e67 92
ccli8 0:f78ec4a22e67 93 void client_registered(void)
ccli8 0:f78ec4a22e67 94 {
ccli8 0:f78ec4a22e67 95 printf("Client registered.\n");
ccli8 0:f78ec4a22e67 96 print_client_ids();
ccli8 11:d147172e94b5 97 error_count = 0;
ccli8 11:d147172e94b5 98 }
ccli8 11:d147172e94b5 99
ccli8 11:d147172e94b5 100 void client_registration_updated(void)
ccli8 11:d147172e94b5 101 {
ccli8 11:d147172e94b5 102 printf("Client registration updated.\n");
ccli8 11:d147172e94b5 103 error_count = 0;
ccli8 0:f78ec4a22e67 104 }
ccli8 0:f78ec4a22e67 105
ccli8 0:f78ec4a22e67 106 void client_unregistered(void)
ccli8 0:f78ec4a22e67 107 {
ccli8 0:f78ec4a22e67 108 printf("Client unregistered.\n");
ccli8 0:f78ec4a22e67 109 (void) network->disconnect();
ccli8 0:f78ec4a22e67 110 cloud_client_running = false;
ccli8 0:f78ec4a22e67 111 }
ccli8 0:f78ec4a22e67 112
ccli8 11:d147172e94b5 113 void factory_reset(void*)
ccli8 11:d147172e94b5 114 {
ccli8 11:d147172e94b5 115 printf("POST factory reset executed\n");
ccli8 11:d147172e94b5 116 m2m_factory_reset_res->send_delayed_post_response();
ccli8 11:d147172e94b5 117
ccli8 11:d147172e94b5 118 kcm_factory_reset();
ccli8 11:d147172e94b5 119 }
ccli8 11:d147172e94b5 120
ccli8 0:f78ec4a22e67 121 void client_error(int err)
ccli8 0:f78ec4a22e67 122 {
ccli8 0:f78ec4a22e67 123 printf("client_error(%d) -> %s\n", err, cloud_client->error_description());
ccli8 11:d147172e94b5 124 if (err == MbedCloudClient::ConnectNetworkError ||
ccli8 11:d147172e94b5 125 err == MbedCloudClient::ConnectDnsResolvingFailed ||
ccli8 11:d147172e94b5 126 err == MbedCloudClient::ConnectSecureConnectionFailed) {
ccli8 11:d147172e94b5 127 if(++error_count == MAX_ERROR_COUNT) {
ccli8 11:d147172e94b5 128 printf("Max error count %d reached, rebooting.\n\n", MAX_ERROR_COUNT);
ccli8 11:d147172e94b5 129 ThisThread::sleep_for(1*1000);
ccli8 11:d147172e94b5 130 NVIC_SystemReset();
ccli8 11:d147172e94b5 131 }
ccli8 11:d147172e94b5 132 }
ccli8 0:f78ec4a22e67 133 }
ccli8 0:f78ec4a22e67 134
ccli8 0:f78ec4a22e67 135 void update_progress(uint32_t progress, uint32_t total)
ccli8 0:f78ec4a22e67 136 {
ccli8 0:f78ec4a22e67 137 uint8_t percent = (uint8_t)((uint64_t)progress * 100 / total);
ccli8 0:f78ec4a22e67 138 printf("Update progress = %" PRIu8 "%%\n", percent);
ccli8 0:f78ec4a22e67 139 }
ccli8 0:f78ec4a22e67 140
ccli8 11:d147172e94b5 141 void flush_stdin_buffer(void)
ccli8 11:d147172e94b5 142 {
ccli8 11:d147172e94b5 143 FileHandle *debug_console = mbed::mbed_file_handle(STDIN_FILENO);
ccli8 11:d147172e94b5 144 while(debug_console->readable()) {
ccli8 11:d147172e94b5 145 char buffer[1];
ccli8 11:d147172e94b5 146 debug_console->read(buffer, 1);
ccli8 11:d147172e94b5 147 }
ccli8 11:d147172e94b5 148 }
ccli8 11:d147172e94b5 149
ccli8 5:ae686808e015 150 extern "C" MBED_WEAK void dispatch_host_command(int);
ccli8 5:ae686808e015 151
ccli8 0:f78ec4a22e67 152 int main(void)
ccli8 0:f78ec4a22e67 153 {
ccli8 0:f78ec4a22e67 154 int status;
SHLIU1@OANBE02333.nuvoton.com 16:75a4830fc40a 155 #ifdef MBED_MAJOR_VERSION
SHLIU1@OANBE02333.nuvoton.com 16:75a4830fc40a 156 printf("Mbed OS version %d.%d.%d\r\n\n", MBED_MAJOR_VERSION, MBED_MINOR_VERSION, MBED_PATCH_VERSION);
SHLIU1@OANBE02333.nuvoton.com 16:75a4830fc40a 157 #endif
ccli8 0:f78ec4a22e67 158 status = mbed_trace_init();
ccli8 0:f78ec4a22e67 159 if (status != 0) {
ccli8 0:f78ec4a22e67 160 printf("mbed_trace_init() failed with %d\n", status);
ccli8 0:f78ec4a22e67 161 return -1;
ccli8 0:f78ec4a22e67 162 }
ccli8 0:f78ec4a22e67 163
ccli8 0:f78ec4a22e67 164 // Mount default kvstore
ccli8 0:f78ec4a22e67 165 printf("Application ready\n");
ccli8 0:f78ec4a22e67 166 status = kv_init_storage_config();
ccli8 0:f78ec4a22e67 167 if (status != MBED_SUCCESS) {
ccli8 0:f78ec4a22e67 168 printf("kv_init_storage_config() - failed, status %d\n", status);
ccli8 0:f78ec4a22e67 169 return -1;
ccli8 0:f78ec4a22e67 170 }
ccli8 0:f78ec4a22e67 171
ccli8 0:f78ec4a22e67 172 // Connect with NetworkInterface
ccli8 0:f78ec4a22e67 173 printf("Connect to network\n");
ccli8 0:f78ec4a22e67 174 network = NetworkInterface::get_default_instance();
ccli8 0:f78ec4a22e67 175 if (network == NULL) {
ccli8 0:f78ec4a22e67 176 printf("Failed to get default NetworkInterface\n");
ccli8 0:f78ec4a22e67 177 return -1;
ccli8 0:f78ec4a22e67 178 }
ccli8 0:f78ec4a22e67 179 status = network->connect();
ccli8 0:f78ec4a22e67 180 if (status != NSAPI_ERROR_OK) {
ccli8 0:f78ec4a22e67 181 printf("NetworkInterface failed to connect with %d\n", status);
ccli8 0:f78ec4a22e67 182 return -1;
ccli8 0:f78ec4a22e67 183 }
ccli8 11:d147172e94b5 184 status = network->get_ip_address(&sa);
ccli8 11:d147172e94b5 185 if (status!=0) {
ccli8 11:d147172e94b5 186 printf("get_ip_address failed with %d\n", status);
ccli8 11:d147172e94b5 187 return -2;
ccli8 11:d147172e94b5 188 }
ccli8 11:d147172e94b5 189 printf("Network initialized, connected with IP %s\n\n", sa.get_ip_address());
ccli8 0:f78ec4a22e67 190
ccli8 0:f78ec4a22e67 191 // Run developer flow
ccli8 0:f78ec4a22e67 192 printf("Start developer flow\n");
ccli8 0:f78ec4a22e67 193 status = fcc_init();
ccli8 0:f78ec4a22e67 194 if (status != FCC_STATUS_SUCCESS) {
ccli8 0:f78ec4a22e67 195 printf("fcc_init() failed with %d\n", status);
ccli8 0:f78ec4a22e67 196 return -1;
ccli8 0:f78ec4a22e67 197 }
ccli8 0:f78ec4a22e67 198
ccli8 0:f78ec4a22e67 199 // Inject hardcoded entropy for the device. Suitable only for demo devices.
ccli8 0:f78ec4a22e67 200 (void) fcc_entropy_set(MBED_CLOUD_DEV_ENTROPY, sizeof(MBED_CLOUD_DEV_ENTROPY));
ccli8 0:f78ec4a22e67 201 status = fcc_developer_flow();
ccli8 0:f78ec4a22e67 202 if (status != FCC_STATUS_SUCCESS && status != FCC_STATUS_KCM_FILE_EXIST_ERROR && status != FCC_STATUS_CA_ERROR) {
ccli8 0:f78ec4a22e67 203 printf("fcc_developer_flow() failed with %d\n", status);
ccli8 0:f78ec4a22e67 204 return -1;
ccli8 0:f78ec4a22e67 205 }
ccli8 0:f78ec4a22e67 206
ccli8 11:d147172e94b5 207 #ifdef MBED_CLOUD_CLIENT_SUPPORT_UPDATE
ccli8 11:d147172e94b5 208 cloud_client = new MbedCloudClient(client_registered, client_unregistered, client_error, NULL, update_progress);
ccli8 11:d147172e94b5 209 #else
ccli8 11:d147172e94b5 210 cloud_client = new MbedCloudClient(client_registered, client_unregistered, client_error);
ccli8 11:d147172e94b5 211 #endif // MBED_CLOUD_CLIENT_SUPPORT_UPDATE
ccli8 11:d147172e94b5 212
ccli8 11:d147172e94b5 213 // Initialize client
ccli8 11:d147172e94b5 214 cloud_client->init();
ccli8 11:d147172e94b5 215
ccli8 0:f78ec4a22e67 216 printf("Create resources\n");
ccli8 0:f78ec4a22e67 217 M2MObjectList m2m_obj_list;
ccli8 0:f78ec4a22e67 218
ccli8 0:f78ec4a22e67 219 // GET resource 3200/0/5501
ccli8 11:d147172e94b5 220 // PUT also allowed for resetting the resource
ccli8 11:d147172e94b5 221 m2m_get_res = M2MInterfaceFactory::create_resource(m2m_obj_list, 3200, 0, 5501, M2MResourceInstance::INTEGER, M2MBase::GET_PUT_ALLOWED);
ccli8 0:f78ec4a22e67 222 if (m2m_get_res->set_value(0) != true) {
ccli8 0:f78ec4a22e67 223 printf("m2m_get_res->set_value() failed\n");
ccli8 0:f78ec4a22e67 224 return -1;
ccli8 0:f78ec4a22e67 225 }
ccli8 11:d147172e94b5 226 if (m2m_get_res->set_value_updated_function(get_res_update) != true) {
ccli8 11:d147172e94b5 227 printf("m2m_get_res->set_value_updated_function() failed\n");
ccli8 11:d147172e94b5 228 return -1;
ccli8 11:d147172e94b5 229 }
ccli8 0:f78ec4a22e67 230
ccli8 0:f78ec4a22e67 231 // PUT resource 3201/0/5853
ccli8 0:f78ec4a22e67 232 m2m_put_res = M2MInterfaceFactory::create_resource(m2m_obj_list, 3201, 0, 5853, M2MResourceInstance::INTEGER, M2MBase::GET_PUT_ALLOWED);
ccli8 0:f78ec4a22e67 233 if (m2m_put_res->set_value(0) != true) {
ccli8 11:d147172e94b5 234 printf("m2m_put_res->set_value() failed\n");
ccli8 0:f78ec4a22e67 235 return -1;
ccli8 0:f78ec4a22e67 236 }
ccli8 11:d147172e94b5 237 if (m2m_put_res->set_value_updated_function(put_res_update) != true) {
ccli8 0:f78ec4a22e67 238 printf("m2m_put_res->set_value_updated_function() failed\n");
ccli8 0:f78ec4a22e67 239 return -1;
ccli8 0:f78ec4a22e67 240 }
ccli8 0:f78ec4a22e67 241
ccli8 0:f78ec4a22e67 242 // POST resource 3201/0/5850
ccli8 0:f78ec4a22e67 243 m2m_post_res = M2MInterfaceFactory::create_resource(m2m_obj_list, 3201, 0, 5850, M2MResourceInstance::INTEGER, M2MBase::POST_ALLOWED);
ccli8 0:f78ec4a22e67 244 if (m2m_post_res->set_execute_function(execute_post) != true) {
ccli8 0:f78ec4a22e67 245 printf("m2m_post_res->set_execute_function() failed\n");
ccli8 0:f78ec4a22e67 246 return -1;
ccli8 0:f78ec4a22e67 247 }
ccli8 0:f78ec4a22e67 248
ccli8 0:f78ec4a22e67 249 // POST resource 5000/0/1 to trigger deregister.
ccli8 0:f78ec4a22e67 250 m2m_deregister_res = M2MInterfaceFactory::create_resource(m2m_obj_list, 5000, 0, 1, M2MResourceInstance::INTEGER, M2MBase::POST_ALLOWED);
ccli8 0:f78ec4a22e67 251
ccli8 0:f78ec4a22e67 252 // Use delayed response
ccli8 0:f78ec4a22e67 253 m2m_deregister_res->set_delayed_response(true);
ccli8 0:f78ec4a22e67 254
ccli8 0:f78ec4a22e67 255 if (m2m_deregister_res->set_execute_function(deregister) != true) {
ccli8 0:f78ec4a22e67 256 printf("m2m_post_res->set_execute_function() failed\n");
ccli8 0:f78ec4a22e67 257 return -1;
ccli8 0:f78ec4a22e67 258 }
ccli8 0:f78ec4a22e67 259
ccli8 11:d147172e94b5 260 // optional Device resource for running factory reset for the device. Path of this resource will be: 3/0/5.
ccli8 11:d147172e94b5 261 m2m_factory_reset_res = M2MInterfaceFactory::create_device()->create_resource(M2MDevice::FactoryReset);
ccli8 11:d147172e94b5 262 if (m2m_factory_reset_res) {
ccli8 11:d147172e94b5 263 m2m_factory_reset_res->set_execute_function(factory_reset);
ccli8 11:d147172e94b5 264 }
ccli8 11:d147172e94b5 265
ccli8 0:f78ec4a22e67 266 printf("Register Pelion Device Management Client\n\n");
ccli8 11:d147172e94b5 267
ccli8 11:d147172e94b5 268 cloud_client->on_registration_updated(client_registration_updated);
ccli8 11:d147172e94b5 269
ccli8 0:f78ec4a22e67 270 cloud_client->add_objects(m2m_obj_list);
ccli8 11:d147172e94b5 271 cloud_client->setup(network);
ccli8 11:d147172e94b5 272
ccli8 11:d147172e94b5 273 t.start(callback(&queue, &EventQueue::dispatch_forever));
ccli8 11:d147172e94b5 274 queue.call_every(5000, value_increment);
ccli8 11:d147172e94b5 275
ccli8 11:d147172e94b5 276 // Flush the stdin buffer before reading from it
ccli8 11:d147172e94b5 277 flush_stdin_buffer();
ccli8 0:f78ec4a22e67 278
ccli8 0:f78ec4a22e67 279 while(cloud_client_running) {
ccli8 0:f78ec4a22e67 280 int in_char = getchar();
ccli8 0:f78ec4a22e67 281 if (in_char == 'i') {
ccli8 0:f78ec4a22e67 282 print_client_ids(); // When 'i' is pressed, print endpoint info
ccli8 0:f78ec4a22e67 283 continue;
ccli8 0:f78ec4a22e67 284 } else if (in_char == 'r') {
ccli8 0:f78ec4a22e67 285 (void) fcc_storage_delete(); // When 'r' is pressed, erase storage and reboot the board.
ccli8 0:f78ec4a22e67 286 printf("Storage erased, rebooting the device.\n\n");
ccli8 11:d147172e94b5 287 ThisThread::sleep_for(1*1000);
ccli8 0:f78ec4a22e67 288 NVIC_SystemReset();
ccli8 5:ae686808e015 289 } else if (dispatch_host_command && in_char != 0x03) {
ccli8 5:ae686808e015 290 /* Intercept other host commands */
ccli8 5:ae686808e015 291 dispatch_host_command(in_char);
ccli8 5:ae686808e015 292 continue;
ccli8 0:f78ec4a22e67 293 } else if (in_char > 0 && in_char != 0x03) { // Ctrl+C is 0x03 in Mbed OS and Linux returns negative number
ccli8 11:d147172e94b5 294 value_increment(); // Simulate button press
ccli8 0:f78ec4a22e67 295 continue;
ccli8 0:f78ec4a22e67 296 }
ccli8 0:f78ec4a22e67 297 deregister_client();
ccli8 0:f78ec4a22e67 298 break;
ccli8 0:f78ec4a22e67 299 }
ccli8 0:f78ec4a22e67 300 return 0;
ccli8 0:f78ec4a22e67 301 }
ccli8 0:f78ec4a22e67 302
ccli8 0:f78ec4a22e67 303 #endif /* MBED_TEST_MODE */