Hello,
On my application I want to issue a system reboot after a failed sl_Start call. For this I am using Utils_TriggerHibCyclefunction. It is noted in the documentation that "This routine should only be exercised after all the network processing has been stopped. To stop network processing use sl_stop API"
My question is, after a failed sl_Start call, is it safe to call sl_Stop? I did realize that calling sl_Stop before any call to sl_Start causes a hard fault...
Bellow is an example of such a situation when I want to reboot the system after a failed call to sl_Start. Please note that app_utils_hibernate_cycle may or may not call sl_Stop according to the first parameter.
g_main_device_mode = sl_Start(NULL, NULL, NULL);
// Check for sl_Start errors
if ((g_main_device_mode == ROLE_STA_ERR) ||
(g_main_device_mode == ROLE_AP_ERR) ||
(g_main_device_mode == ROLE_P2P_ERR) ||
(g_main_device_mode == SL_POOL_IS_EMPTY) ||
(g_main_device_mode == ROLE_UNKNOWN_ERR) ||
(g_main_device_mode == SL_BAD_INTERFACE))
{
app_utils_uart_print("[MAIN] Failed to start Simplelink !!!\r\n");
app_utils_hibernate_cycle(true, true);
}
And bellow is the implementation of app_utils_hibernate_cycle
void app_utils_hibernate_cycle (bool slstop, bool signal_fatal_error)
{
if (signal_fatal_error)
{
// Signal fatal error
LED_set_sys_flag(LED_sys_flags_fatal_error, true);
vTaskDelay(2000 * portTICK_PERIOD_MS);
LED_set_sys_flag(LED_sys_flags_off, true);
}
if (slstop)
{
// Stop network processing
sl_Stop(SL_STOP_TIMEOUT);
}
// Wait
MAP_UtilsDelay ( 1000 * UTILS_DELAY_TIMEBASE );
app_utils_uart_print("REBOOTING !!!\r\n");
// REBOOT !
Utils_TriggerHibCycle();
}
Thank you!