This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Is it safe to call sl_Stop after a unsuccessful call to sl_Start?



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!

  • No - A successful 'sl_Start' is required before any calls to Simplelink APIs.

    -/Praneet
  • Hello Praneet, thank you for your answer.

    Our question evolved a little bit since I posted the first one.

    Our system is multithread, so we found out that calling sl_Stop before Utils_TriggerHibCycle could be dangerous, as app_utils_hibernate_cycle could be preempted by some task that uses the slimplelink API. If this preemption occurs right after sl_Stop and before Utils_TriggerHibCycle this could trigger an error.

    So we've come up with the solution below trusting that when we call sl_Stop(0) (passing a timeout of 0) we do not need to have the scheduler running, so we refactored app_utils_hibernate_cycle to the implementation bellow:

    void app_utils_hibernate_cycle (bool slstop)
    {
    	vTaskSuspendAll();
    
    	if (slstop)
    	{
    		sl_Stop(0); // Stop network processing
    	}
    
    	Utils_TriggerHibCycle(); // REBOOT !
    }

    Is this correct or we're missing something?

    In any case, should I issue a system reboot without calling sl_Stop after a failed call to sl_Start?

    Thank you very much!

  • Well.! The interface w/ NWP will be closed when 'sl_Stop' is called, and a preempting task calling host-driver APIs will still cause problem.

    -/Praneet
  • Hi, Please let me know if you have any additional queries on this topic.

    -/Praneet
  • Hi, I'm closing this thread - For any additional queries, request you to start a new thread w/ references to the current one for us to track it better.

    -/Praneet