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.

CC3220SF-LAUNCHXL: How to handle SL_SOCKET_TX_FAILED_EVENT?

Part Number: CC3220SF-LAUNCHXL

When I receive the SL_SOCKET_TX_FAILED_EVENT, what's the right way to handle it?

I.e. retry to send data, close socket and reopen, restart SimpleLink, reboot MCU, etc...

  • Hi,

    I believe the way to handle this is very dependent on the use case and the cause of the failed TX.

    Regards,
    Charles
  • Hi! The point is how to know what is the cause of the failed TX. As far as I understand that error is emitted when a sk_Send() fails, according to the header:

    In case of transmission failure an async event SL_SOCKET_TX_FAILED_EVENT is going to be received.

    but there are no information about the possible causes.
    Anyway my use case is the following:

    1. every X minutes the MCU wakes up
    2. acquires data from sensors
    3. send them using a GET HTTP request
    4. hibernates for other X minutes

    The GET HTTP request is done manually in this way:

    // Retrieve ip from host name
    sl_NetAppDnsGetHostByName()
    
    // Open socket
    sl_SetSockOpt()
    sl_Connect()
    
    // Send formatted GET request
    sl_Send()
    
    // Receive answer
    sl_Recv()
    
    // Close socket
    sl_Close()
    

    Furthermore, I'm asserting the ret code of sl_Send() but it doesn't return a negative value on failure. Then when I receive the async event I really don't know what specific sl_Send() command has failed:

    _i16 HTTPClient_GET(char *service, char *header, char *data)
    {
        _i16 ret;
    
        char requestheader[256];
        sprintf(requestheader, " %s\r\nUser-Agent: %s\r\nHost: %d.%d.%d.%d\r\n\r\n", HTTP_VERSION, HTTP_USERAGENT,
                (_u8)SL_IPV4_BYTE(HTTPClient.ipV4Addr.sin_addr.s_addr, 0),\
                (_u8)SL_IPV4_BYTE(HTTPClient.ipV4Addr.sin_addr.s_addr, 1),\
                (_u8)SL_IPV4_BYTE(HTTPClient.ipV4Addr.sin_addr.s_addr, 2),\
                (_u8)SL_IPV4_BYTE(HTTPClient.ipV4Addr.sin_addr.s_addr, 3));
    
        strcpy(HTTPClient.response.content, "");
        HTTPClient.response.contentLen = 0;
        HTTPClient.response.status = 0;
    
        _Write("GET ");
        _Write(service);
        _Write("?");
        _Write(header);
        _Write("&");
        _Write(data);
        ret = _Write(requestheader);
    
        UART_PRINT("[HTTP] HTTP GET Request sent\r\n");
        UART_PRINT("GET %s?%s&%s%s", service, header, data, requestheader);
    
        return ret;
    }
    
    _i16 _Write(char *data)
    {
        _i16 ret;
    
        ret = sl_Send(HTTPClient.sockId, data, strlen(data), 0);
        ASSERT_ON_ERROR(ret);
    
        return ret;
    }

    For this reason I don't understand if I need to just retry sending data (i.e. ALL data was't transmitted) or I need to close and reopen the socket, and so on...