Skip to content

Commit c4ebabb

Browse files
authored
Merge branch 'master' into dev_wio_3g
2 parents 8489cda + 1f1d102 commit c4ebabb

File tree

2 files changed

+26
-5
lines changed

2 files changed

+26
-5
lines changed

drivers/COMPONENT_WIFI_ISM43362.lib

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
https://github.com/ARMmbed/wifi-ism43362/#1c040113be0fe2a14c4b6107e1db3ec24e8b20b6
1+
https://github.com/ARMmbed/wifi-ism43362/#1978369b2310ea3955715b67869b717fd224a74c

main.cpp

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// ----------------------------------------------------------------------------
2-
// Copyright 2016-2019 ARM Ltd.
2+
// Copyright 2016-2020 ARM Ltd.
33
//
44
// SPDX-License-Identifier: Apache-2.0
55
//
@@ -21,6 +21,7 @@
2121
#include "mbed-cloud-client/MbedCloudClient.h" // Required for new MbedCloudClient()
2222
#include "factory_configurator_client.h" // Required for fcc_* functions and FCC_* defines
2323
#include "m2mresource.h" // Required for M2MResource
24+
#include "key_config_manager.h" // Required for kcm_factory_reset
2425

2526
#include "mbed-trace/mbed_trace.h" // Required for mbed_trace_*
2627

@@ -36,6 +37,8 @@ static M2MResource* m2m_get_res;
3637
static M2MResource* m2m_put_res;
3738
static M2MResource* m2m_post_res;
3839
static M2MResource* m2m_deregister_res;
40+
static M2MResource* m2m_factory_reset_res;
41+
static SocketAddress sa;
3942

4043
EventQueue queue(32 * EVENTS_EVENT_SIZE);
4144
Thread t;
@@ -98,6 +101,14 @@ void client_unregistered(void)
98101
cloud_client_running = false;
99102
}
100103

104+
void factory_reset(void*)
105+
{
106+
printf("POST factory reset executed\n");
107+
m2m_factory_reset_res->send_delayed_post_response();
108+
109+
kcm_factory_reset();
110+
}
111+
101112
void client_error(int err)
102113
{
103114
printf("client_error(%d) -> %s\n", err, cloud_client->error_description());
@@ -139,8 +150,12 @@ int main(void)
139150
printf("NetworkInterface failed to connect with %d\n", status);
140151
return -1;
141152
}
142-
143-
printf("Network initialized, connected with IP %s\n\n", network->get_ip_address());
153+
status = network->get_ip_address(&sa);
154+
if (status!=0) {
155+
printf("get_ip_address failed with %d\n", status);
156+
return -2;
157+
}
158+
printf("Network initialized, connected with IP %s\n\n", sa.get_ip_address());
144159

145160
// Run developer flow
146161
printf("Start developer flow\n");
@@ -202,6 +217,12 @@ int main(void)
202217
return -1;
203218
}
204219

220+
// optional Device resource for running factory reset for the device. Path of this resource will be: 3/0/6.
221+
m2m_factory_reset_res = M2MInterfaceFactory::create_device()->create_resource(M2MDevice::FactoryReset);
222+
if (m2m_factory_reset_res) {
223+
m2m_factory_reset_res->set_execute_function(factory_reset);
224+
}
225+
205226
printf("Register Pelion Device Management Client\n\n");
206227

207228
#ifdef MBED_CLOUD_CLIENT_SUPPORT_UPDATE
@@ -224,7 +245,7 @@ int main(void)
224245
} else if (in_char == 'r') {
225246
(void) fcc_storage_delete(); // When 'r' is pressed, erase storage and reboot the board.
226247
printf("Storage erased, rebooting the device.\n\n");
227-
wait(1);
248+
ThisThread::sleep_for(1*1000);
228249
NVIC_SystemReset();
229250
} else if (in_char > 0 && in_char != 0x03) { // Ctrl+C is 0x03 in Mbed OS and Linux returns negative number
230251
value_increment(); // Simulate button press

0 commit comments

Comments
 (0)