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.

FS api calls fail when initiated from within the HTTP callback function

Other Parts Discussed in Thread: CC3100, CC3200

I have come across an issue that causes failure when attempting a fs api call that was initiated from within the
sl_HttpServerCallback (SimpleLinkHttpServerCallback) function.

I have come across this issue in the following environments: CC3200, CC3100/Tiva C, TI-RTOS and NO-OS....so basically under all varieties.

TI-RTOS provides some additional debug information, that makes it look like there may be a deadlock occurring. Though I tried to get around this by initiating the call on another thread by trying to use a Clock, Swi or Task. I even tried initiating a Swi with a Clock (to ensure the fs process occurred once the http callback had completed). These methods created a crash.

This issue effectively means you cannot use this method with the internal HTTP Server to POST and then save device configuration data onto the serial flash, Which will be a common requirement for many devices.

I am providing this post, so I can show how to workaround this problem, please see response below.

Glenn.

  • I have discovered a workaround thanks to the camera_application example in he SDK.

    You create a global variable that triggers the initiation of a function call from within the main program loop.

    int configTrigger = 0; // Global variable
    
    void saveConfig()
    {
        // Perform FS API calls
    }
    
    void sl_HttpServerCallback(SlHttpServerEvent_t *pEvent, SlHttpServerResponse_t *pResponse)
    {
        switch (pEvent->Event)
        {
            case SL_NETAPP_HTTPGETTOKENVALUE:  // HTTP GET recieved
            {
    	     // GET request code here
            }
            break;
    
            case SL_NETAPP_HTTPPOSTTOKENVALUE:  // HTTP POST received
            {
    	    //saveConfig(); <-- This will cause the problem
    	    
                configTrigger = 1; // This triggers the call from with the main program loop
            }
            break;
    
            default:
            break;
        }
    }
    
    void main()
    {
        // application connectivity code here
    
        // Main program loop
        while(1)
        {
            // Saves config data when requested from a HTTP POST from within the HTTP Callback
            if (configTrigger)
            {
            	saveConfig();
            	configTrigger = 0;
            }
        }
    }
    

    Hopefully this should save you some time in developing code.

    Glenn.

  • Hi Glenn,

    Event handlers including the HTTP callback cannot activate another SimpleLink API from their context.

    You are correct and indeed in these kind of calls a dead lock might occur.

    We will try to emphasize this point better in next releases.

    Barak

  • Hi Barak,

    Understood....and thanks for the explanation.

    Glenn.