Skip to content

Commit 53a0385

Browse files
joakimtoecvinayak
authored andcommitted
applications: asset_tracker: Reboot if GPS is active.
Add reboot in the error handler if GPS is active to avoid error state caused by calling proper shutdown. Signed-off-by: Joakim Andre Tønnesen <[email protected]>
1 parent 6f93858 commit 53a0385

File tree

1 file changed

+12
-11
lines changed
  • applications/asset_tracker/src

1 file changed

+12
-11
lines changed

applications/asset_tracker/src/main.c

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -174,21 +174,27 @@ static void device_status_send(struct k_work *work);
174174
void error_handler(enum error_type err_type, int err_code)
175175
{
176176
if (err_type == ERROR_CLOUD) {
177+
if (gps_control_is_enabled()) {
178+
printk("Reboot\n");
179+
sys_reboot(0);
180+
}
177181
#if defined(CONFIG_LTE_LINK_CONTROL)
178182
/* Turn off and shutdown modem */
183+
printk("LTE link disconnect\n");
179184
int err = lte_lc_power_off();
180185
if (err) {
181186
printk("lte_lc_power_off failed: %d\n", err);
182187
}
183188
#endif /* CONFIG_LTE_LINK_CONTROL */
184189
#if defined(CONFIG_BSD_LIBRARY)
190+
printk("Shutdown modem\n");
185191
bsdlib_shutdown();
186192
#endif
187193
}
188194

189195
#if !defined(CONFIG_DEBUG) && defined(CONFIG_REBOOT)
190196
LOG_PANIC();
191-
sys_reboot(SYS_REBOOT_COLD);
197+
sys_reboot(0);
192198
#else
193199
switch (err_type) {
194200
case ERROR_CLOUD:
@@ -820,6 +826,11 @@ static void pairing_button_register(struct ui_evt *evt)
820826

821827
static void long_press_handler(struct k_work *work)
822828
{
829+
if (!atomic_get(&send_data_enable)) {
830+
printk("Link not ready, long press disregarded\n");
831+
return;
832+
}
833+
823834
if (gps_control_is_enabled()) {
824835
printk("Stopping GPS\n");
825836
gps_control_disable();
@@ -1126,16 +1137,6 @@ void main(void)
11261137

11271138
if ((fds[0].revents & POLLNVAL) == POLLNVAL) {
11281139
printk("Socket error: POLLNVAL\n");
1129-
1130-
/* If the device is recently associated, the cloud
1131-
* will usually terminate the connection, and we'll
1132-
* have to reconnect. Often we'll also have to reboot,
1133-
* but attempt once to reconnect first.
1134-
*/
1135-
if (recently_associated) {
1136-
recently_associated = false;
1137-
goto connect;
1138-
}
11391140
error_handler(ERROR_CLOUD, -EIO);
11401141
return;
11411142
}

0 commit comments

Comments
 (0)