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.

Compiler/CC3220SF-LAUNCHXL: Issue with HTTP Get after trasfering Code to Latest SDK

Part Number: CC3220SF-LAUNCHXL


Tool/software: TI C/C++ Compiler

Hi,

WE have successfully developed our application with HTTP GET and POST using SDK 2_30_00_05  and then we transferred our app to new sdk  3_30_01_02 and done all include and build  successfully. After build while debug we are getting HTTP Get error 2006, we already check our Host name, API etc. still this code is working with older sdk 2_30.

Please Help

  • Hi,

    Which command exactly returns the -2006 (SL_RET_CODE_INVALID_INPUT) value?

    Please go step by step in the code (or use prints to debug this) to find the exact point of failure.

    Br,

    Kobi

  • Hi,

    We are getting error from HTTP Connect Function, Also we tried HTTP GET example from sdk (Host name and api was changed according to our app), still we got same issue. We tried to debug and found error from library(No changes made by us ) function GETHOSTBYNAME returns this error.

  • Please check the parameters for the GETHOSTBYNAME and compare them to waht you pass in the working SDK.

    Br,

    Kobi

  • Hi,

    We already checked the parameters, we are passing same parameters as it is in working sdk. We observed that library files having functions are different/ modified in new sdk and seems different. Also we have tried new sdk HTTP get example and it gives same error. 

  • Hi

    I am sharing my code in attachment, in older sdk it works, and in New it not, This example file is from new SDK.

    /*
     * Copyright (c) 2015-2017, Texas Instruments Incorporated
     * All rights reserved.
     *
     * Redistribution and use in source and binary forms, with or without
     * modification, are permitted provided that the following conditions
     * are met:
     *
     * *  Redistributions of source code must retain the above copyright
     *    notice, this list of conditions and the following disclaimer.
     *
     * *  Redistributions in binary form must reproduce the above copyright
     *    notice, this list of conditions and the following disclaimer in the
     *    documentation and/or other materials provided with the distribution.
     *
     * *  Neither the name of Texas Instruments Incorporated nor the names of
     *    its contributors may be used to endorse or promote products derived
     *    from this software without specific prior written permission.
     *
     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
     * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
     * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     */
    
    /*
     *  ======== httpget.c ========
     *  HTTP Client GET example application
     */
    
    /* BSD support */
    #include "string.h"
    #include <ti/display/Display.h>
    #include <ti/net/http/httpclient.h>
    #include "semaphore.h"
    
    #define HOSTNAME              "http://www.alteemiot.com"
    #define REQUEST_URI           "/" //"/Api/config_new/50f14ad65fbc"
    #define USER_AGENT            "Content-Type:application/json"
    #define HTTP_MIN_RECV         (256)
    
    extern Display_Handle display;
    extern sem_t ipEventSyncObj;
    extern void printError(char *errString,
                           int code);
    
    /*
     *  ======== httpTask ========
     *  Makes a HTTP GET request
     */
    void* httpTask(void* pvParameters)
    {
        bool moreDataFlag = false;
        char data[HTTP_MIN_RECV];
        int16_t ret = 0;
        int16_t len = 0;
    
        Display_printf(display, 0, 0, "Sending a HTTP GET request to '%s'\n",
                       HOSTNAME);
    
    
    
    
        HTTPClient_Handle httpClientHandle;
        int16_t statusCode;
        httpClientHandle = HTTPClient_create(&statusCode,0);
        if(statusCode < 0)
        {
            printError("httpTask: creation of http client handle failed",
                       statusCode);
        }
    
    
        ret = HTTPClient_setHeader(httpClientHandle,
                                   HTTPClient_HFIELD_REQ_CONTENT_TYPE,
                                    USER_AGENT,sizeof(USER_AGENT),
                                    HTTPClient_HFIELD_NOT_PERSISTENT);
        if(ret < 0)
        {
           printError("httpTask: setting request header failed", ret);
        }
    
    
        ret = HTTPClient_connect(httpClientHandle,HOSTNAME,0,0);
        if(ret < 0)
        {
            printError("httpTask: connect failed", ret);
        }
    
        /*
        const char header[] = "Basic dZdDpXGVz0N0\r\nContent-Type: application/json";
                      ret = HTTPClient_setHeader(httpClientHandle,
                      HTTPClient_HFIELD_REQ_AUTHORIZATION,
                      header,sizeof(header),
                      HTTPClient_HFIELD_PERSISTENT);
    
    */
        ret =
            HTTPClient_sendRequest(httpClientHandle,HTTP_METHOD_GET,REQUEST_URI,
                                   NULL,0,
                                   0);
        if(ret < 0)
        {
            printError("httpTask: send failed", ret);
        }
    
        if(ret != HTTP_SC_OK)
        {
            printError("httpTask: cannot get status", ret);
        }
    
        Display_printf(display, 0, 0, "HTTP Response Status Code: %d\n", ret);
    
        len = 0;
        do
        {
            ret = HTTPClient_readResponseBody(httpClientHandle, data, sizeof(data),
                                              &moreDataFlag);
            if(ret < 0)
            {
                printError("httpTask: response body processing failed", ret);
            }
            Display_printf(display, 0, 0, "%.*s \r\n",ret,data);
            len += ret;
        }
        while(moreDataFlag);
    
        Display_printf(display, 0, 0, "Received %d bytes of payload\n", len);
    
        ret = HTTPClient_disconnect(httpClientHandle);
        if(ret < 0)
        {
            printError("httpTask: disconnect failed", ret);
        }
    
        HTTPClient_destroy(httpClientHandle);
        return(0);
    }
    

  • The -2006 is generated by the host you can trace the exact point of failure.

    It is probably related to an interface that was not enabled.

    You should have the following code (or similar) in your app init:

    /* The network stack is ready. Initialize the socket layer */
    status = SlNetSock_init(0);
    if (status != 0) {
    /* SlNetSock_init failed */
    while (1);
    }

    status = SlNetIf_init(0);
    if (status != 0) {
    /* SlNetIf_init failed */
    while (1);
    }

    status = SlNetUtil_init(0);
    if (status != 0) {
    /* SlNetUtil_init failed */
    while (1);
    }

    /* Register the WiFi interface with the socket layer */
    status = SlNetIf_add(SLNETIF_ID_1, SLNET_IF_WIFI_NAME,
    (const SlNetIf_Config_t *)&SlNetIfConfigWifi, SLNET_IF_WIFI_PRIO);
    if (status != 0) {
    /* SlNetIf_add failed */
    while (1);
    }

    The latest SDK releases works over an abstraction layer called slNetScok that enables easy replacement of interfaces (between WIFI and ETHERNET for example) rather than through direct call to the WIFI sl_.... API.

    You will need to enable the slNetSock and slNetIf to enable the HTTP.

    Br,

    Kobi  

  • HI

    WE checked whatever you suggested and is already done our Example. You may also create HTTP GET example and take paramteres from shared files and try to do so.

    /*
     * Copyright (c) 2015-2017, Texas Instruments Incorporated
     * All rights reserved.
     *
     * Redistribution and use in source and binary forms, with or without
     * modification, are permitted provided that the following conditions
     * are met:
     *
     * *  Redistributions of source code must retain the above copyright
     *    notice, this list of conditions and the following disclaimer.
     *
     * *  Redistributions in binary form must reproduce the above copyright
     *    notice, this list of conditions and the following disclaimer in the
     *    documentation and/or other materials provided with the distribution.
     *
     * *  Neither the name of Texas Instruments Incorporated nor the names of
     *    its contributors may be used to endorse or promote products derived
     *    from this software without specific prior written permission.
     *
     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
     * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
     * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     */
    
    /*
     *  ======== httpget.c ========
     *  HTTP Client GET example application
     */
    
    /* BSD support */
    #include "string.h"
    #include <ti/display/Display.h>
    #include <ti/net/http/httpclient.h>
    #include "semaphore.h"
    
    //#define HOSTNAME              "http://www.example.com"
    #define HOSTNAME              "http://www.alteemiot.com"
    #define REQUEST_URI           "/"
    //#define REQUEST_URI            "/Api/config_new/50f14ad65fbc"
    //#define USER_AGENT            "HTTPClient (ARM; TI-RTOS)"
    #define USER_AGENT            "Content-Type:application/json"
    #define HTTP_MIN_RECV         (256)
    
    extern Display_Handle display;
    extern sem_t ipEventSyncObj;
    extern void printError(char *errString,
                           int code);
    
    /*
     *  ======== httpTask ========
     *  Makes a HTTP GET request
     */
    void* httpTask(void* pvParameters)
    {
        bool moreDataFlag = false;
        char data[HTTP_MIN_RECV];
        int16_t ret = 0;
        int16_t len = 0;
    
        Display_printf(display, 0, 0, "Sending a HTTP GET request to '%s'\n",
                       HOSTNAME);
    
        HTTPClient_Handle httpClientHandle;
        int16_t statusCode;
        httpClientHandle = HTTPClient_create(&statusCode,0);
        if(statusCode < 0)
        {
            printError("httpTask: creation of http client handle failed",
                       statusCode);
        }
    
        ret =
            HTTPClient_setHeader(httpClientHandle,
                                 HTTPClient_HFIELD_REQ_USER_AGENT,
                                 USER_AGENT,strlen(USER_AGENT)+1,
                                 HTTPClient_HFIELD_PERSISTENT);
        if(ret < 0)
        {
            printError("httpTask: setting request header failed", ret);
        }
    
        ret = HTTPClient_connect(httpClientHandle,HOSTNAME,0,0);
        if(ret < 0)
        {
            printError("httpTask: connect failed", ret);
        }
        ret =
            HTTPClient_sendRequest(httpClientHandle,HTTP_METHOD_GET,REQUEST_URI,
                                   NULL,0,
                                   0);
        if(ret < 0)
        {
            printError("httpTask: send failed", ret);
        }
    
        if(ret != HTTP_SC_OK)
        {
            printError("httpTask: cannot get status", ret);
        }
    
        Display_printf(display, 0, 0, "HTTP Response Status Code: %d\n", ret);
    
        len = 0;
        do
        {
            ret = HTTPClient_readResponseBody(httpClientHandle, data, sizeof(data),
                                              &moreDataFlag);
            if(ret < 0)
            {
                printError("httpTask: response body processing failed", ret);
            }
            Display_printf(display, 0, 0, "%.*s \r\n",ret,data);
            len += ret;
        }
        while(moreDataFlag);
    
        Display_printf(display, 0, 0, "Received %d bytes of payload\n", len);
    
        ret = HTTPClient_disconnect(httpClientHandle);
        if(ret < 0)
        {
            printError("httpTask: disconnect failed", ret);
        }
    
        HTTPClient_destroy(httpClientHandle);
        return(0);
    }
    
    /*
     * Copyright (c) 2015-2017, Texas Instruments Incorporated
     * All rights reserved.
     *
     * Redistribution and use in source and binary forms, with or without
     * modification, are permitted provided that the following conditions
     * are met:
     *
     * *  Redistributions of source code must retain the above copyright
     *    notice, this list of conditions and the following disclaimer.
     *
     * *  Redistributions in binary form must reproduce the above copyright
     *    notice, this list of conditions and the following disclaimer in the
     *    documentation and/or other materials provided with the distribution.
     *
     * *  Neither the name of Texas Instruments Incorporated nor the names of
     *    its contributors may be used to endorse or promote products derived
     *    from this software without specific prior written permission.
     *
     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
     * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
     * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     */
    
    #include <ti/drivers/net/wifi/simplelink.h>
    #include <ti/drivers/net/wifi/slnetifwifi.h>
    #include <ti/display/Display.h>
    #include <ti/drivers/SPI.h>
    
    #include "ti_drivers_config.h"
    #include "pthread.h"
    #include "semaphore.h"
    
    #define APPLICATION_NAME                      "HTTP GET"
    #define DEVICE_ERROR                          ("Device error, please refer \"DEVICE ERRORS CODES\" section in errors.h")
    #define WLAN_ERROR                            ("WLAN error, please refer \"WLAN ERRORS CODES\" section in errors.h")
    #define SL_STOP_TIMEOUT                       (200)
    #define SPAWN_TASK_PRIORITY                   (9)
    #define SPAWN_STACK_SIZE                      (4096)
    #define TASK_STACK_SIZE                       (2048)
    #define SLNET_IF_WIFI_PRIO                    (5)
    #define SLNET_IF_WIFI_NAME                    "CC32xx"
    /* AP SSID */
    #define SSID_NAME                             "ASUS"
    
    /* Security type could be SL_WLAN_SEC_TYPE_WPA_WPA2 */      
    #define SECURITY_TYPE                         SL_WLAN_SEC_TYPE_WPA_WPA2
    
    /* Password of the secured AP */
    #define SECURITY_KEY                          "12345678"
    
    pthread_t httpThread = (pthread_t)NULL;
    pthread_t spawn_thread = (pthread_t)NULL;
    
    int32_t mode;
    Display_Handle display;
    
    extern void* httpTask(void* pvParameters);
    
    /*
     *  ======== printError ========
     */
    void printError(char *errString,
                    int code)
    {
        Display_printf(display, 0, 0, "Error! code = %d, Description = %s\n", code,
                       errString);
        while(1)
        {
            ;
        }
    }
    
    /*!
        \brief          SimpleLinkNetAppEventHandler
    
        This handler gets called whenever a Netapp event is reported
        by the host driver / NWP. Here user can implement he's own logic
        for any of these events. This handler is used by 'network_terminal'
        application to show case the following scenarios:
    
        1. Handling IPv4 / IPv6 IP address acquisition.
        2. Handling IPv4 / IPv6 IP address Dropping.
    
        \param          pNetAppEvent     -   pointer to Netapp event data.
    
        \return         void
    
        \note           For more information, please refer to: user.h in the porting
                        folder of the host driver and the  CC31xx/CC32xx
                        NWP programmer's
                        guide (SWRU455) section 5.7
    
     */
    void SimpleLinkNetAppEventHandler(SlNetAppEvent_t *pNetAppEvent)
    {
        int32_t             status = 0;
        pthread_attr_t      pAttrs;
        struct sched_param  priParam;
    
        if(pNetAppEvent == NULL)
        {
            return;
        }
    
        switch(pNetAppEvent->Id)
        {
        case SL_NETAPP_EVENT_IPV4_ACQUIRED:
        case SL_NETAPP_EVENT_IPV6_ACQUIRED:
            /* Initialize SlNetSock layer with CC3x20 interface                   */
            SlNetIf_init(0);
            SlNetIf_add(SLNETIF_ID_1, SLNET_IF_WIFI_NAME, 
                       (const SlNetIf_Config_t *)&SlNetIfConfigWifi,
                        SLNET_IF_WIFI_PRIO);
    
            SlNetSock_init(0);
            SlNetUtil_init(0);
            if(mode != ROLE_AP)
            {
                Display_printf(display, 0, 0,"[NETAPP EVENT] IP Acquired: IP=%d.%d.%d.%d , "
                            "Gateway=%d.%d.%d.%d\n\r",
                            SL_IPV4_BYTE(pNetAppEvent->Data.IpAcquiredV4.Ip,3),
                            SL_IPV4_BYTE(pNetAppEvent->Data.IpAcquiredV4.Ip,2),
                            SL_IPV4_BYTE(pNetAppEvent->Data.IpAcquiredV4.Ip,1),
                            SL_IPV4_BYTE(pNetAppEvent->Data.IpAcquiredV4.Ip,0),
                            SL_IPV4_BYTE(pNetAppEvent->Data.IpAcquiredV4.Gateway,3),
                            SL_IPV4_BYTE(pNetAppEvent->Data.IpAcquiredV4.Gateway,2),
                            SL_IPV4_BYTE(pNetAppEvent->Data.IpAcquiredV4.Gateway,1),
                            SL_IPV4_BYTE(pNetAppEvent->Data.IpAcquiredV4.Gateway,0));
    
                pthread_attr_init(&pAttrs);
                priParam.sched_priority = 1;
                status = pthread_attr_setschedparam(&pAttrs, &priParam);
                status |= pthread_attr_setstacksize(&pAttrs, TASK_STACK_SIZE);
    
                status = pthread_create(&httpThread, &pAttrs, httpTask, NULL);
                if(status)
                {
                    printError("Task create failed", status);
                }
            }
            break;
        default:
            break;
        }
    }
    
    /*!
        \brief          SimpleLinkFatalErrorEventHandler
    
        This handler gets called whenever a socket event is reported
        by the NWP / Host driver. After this routine is called, the user's
        application must restart the device in order to recover.
    
        \param          slFatalErrorEvent    -   pointer to fatal error event.
    
        \return         void
    
        \note           For more information, please refer to: user.h in the porting
                        folder of the host driver and the  CC31xx/CC32xx NWP
                        programmer's
                        guide (SWRU455) section 17.9.
    
     */
    void SimpleLinkFatalErrorEventHandler(SlDeviceFatal_t *slFatalErrorEvent)
    {
        /* Unused in this application */
    }
    
    /*!
        \brief          SimpleLinkNetAppRequestMemFreeEventHandler
    
        This handler gets called whenever the NWP is done handling with
        the buffer used in a NetApp request. This allows the use of
        dynamic memory with these requests.
    
        \param         pNetAppRequest     -   Pointer to NetApp request structure.
    
        \param         pNetAppResponse    -   Pointer to NetApp request Response.
    
        \note          For more information, please refer to: user.h in the porting
                       folder of the host driver and the  CC31xx/CC32xx NWP
                       programmer's
                       guide (SWRU455) section 17.9.
    
        \return        void
    
     */
    void SimpleLinkNetAppRequestMemFreeEventHandler(uint8_t *buffer)
    {
        /* Unused in this application */
    }
    
    /*!
        \brief         SimpleLinkNetAppRequestEventHandler
    
        This handler gets called whenever a NetApp event is reported
        by the NWP / Host driver. User can write he's logic to handle
        the event here.
    
        \param         pNetAppRequest     -   Pointer to NetApp request structure.
    
        \param         pNetAppResponse    -   Pointer to NetApp request Response.
    
        \note          For more information, please refer to: user.h in the porting
                       folder of the host driver and the  CC31xx/CC32xx NWP
                       programmer's
                       guide (SWRU455) section 17.9.
    
        \return         void
    
     */
    void SimpleLinkNetAppRequestEventHandler(SlNetAppRequest_t *pNetAppRequest,
                                             SlNetAppResponse_t *pNetAppResponse)
    {
        /* Unused in this application */
    }
    
    /*!
        \brief          SimpleLinkHttpServerEventHandler
    
        This handler gets called whenever a HTTP event is reported
        by the NWP internal HTTP server.
    
        \param          pHttpEvent       -   pointer to http event data.
    
        \param          pHttpEvent       -   pointer to http response.
    
        \return         void
    
        \note          For more information, please refer to: user.h in the porting
                       folder of the host driver and the  CC31xx/CC32xx NWP
                       programmer's
                       guide (SWRU455) chapter 9.
    
     */
    void SimpleLinkHttpServerEventHandler(
        SlNetAppHttpServerEvent_t *pHttpEvent,
        SlNetAppHttpServerResponse_t *
        pHttpResponse)
    {
        /* Unused in this application */
    }
    
    /*!
        \brief          SimpleLinkWlanEventHandler
    
        This handler gets called whenever a WLAN event is reported
        by the host driver / NWP. Here user can implement he's own logic
        for any of these events. This handler is used by 'network_terminal'
        application to show case the following scenarios:
    
        1. Handling connection / Disconnection.
        2. Handling Addition of station / removal.
        3. RX filter match handler.
        4. P2P connection establishment.
    
        \param          pWlanEvent       -   pointer to Wlan event data.
    
        \return         void
    
        \note          For more information, please refer to: user.h in the porting
                       folder of the host driver and the  CC31xx/CC32xx
                       NWP programmer's
                       guide (SWRU455) sections 4.3.4, 4.4.5 and 4.5.5.
    
        \sa             cmdWlanConnectCallback, cmdEnableFilterCallback, 
        cmdWlanDisconnectCallback,
                        cmdP2PModecallback.
    
     */
    void SimpleLinkWlanEventHandler(SlWlanEvent_t *pWlanEvent)
    {
        /* Unused in this application */
    }
    
    /*!
        \brief          SimpleLinkGeneralEventHandler
    
        This handler gets called whenever a general error is reported
        by the NWP / Host driver. Since these errors are not fatal,
        application can handle them.
    
        \param          pDevEvent    -   pointer to device error event.
    
        \return         void
    
        \note          For more information, please refer to: user.h in the porting
                       folder of the host driver and the  CC31xx/CC32xx NWP
                       programmer's
                       guide (SWRU455) section 17.9.
    
     */
    void SimpleLinkGeneralEventHandler(SlDeviceEvent_t *pDevEvent)
    {
        /* Unused in this application */
    }
    
    /*!
        \brief          SimpleLinkSockEventHandler
    
        This handler gets called whenever a socket event is reported
        by the NWP / Host driver.
    
        \param          SlSockEvent_t    -   pointer to socket event data.
    
        \return         void
    
        \note          For more information, please refer to: user.h in the porting
                       folder of the host driver and the  CC31xx/CC32xx NWP
                       programmer's
                       guide (SWRU455) section 7.6.
                       
    
     */
    void SimpleLinkSockEventHandler(SlSockEvent_t *pSock)
    {
        /* Unused in this application */
    }
    
    void Connect(void)
    {
        SlWlanSecParams_t secParams = {0};
        int16_t ret = 0;
        secParams.Key = (signed char*)SECURITY_KEY;
        secParams.KeyLen = strlen(SECURITY_KEY);
        secParams.Type = SECURITY_TYPE;
        Display_printf(display, 0, 0, "Connecting to : %s.\r\n",SSID_NAME);
        ret = sl_WlanConnect((signed char*)SSID_NAME, strlen(
                                 SSID_NAME), 0, &secParams, 0);
        if(ret)
        {
            printError("Connection failed", ret);
        }
    }
    
    /*!
        \brief          Display application banner
    
        This routine shows application startup display on UART.
    
        \param          appName    -   points to a string representing application name.
    
    
    */
    static void DisplayBanner(char * AppName)
    {
        Display_printf(display, 0, 0, "\n\n\n\r");
        Display_printf(display, 0, 0,
                       "\t\t *************************"
                       "************************\n\r");
        Display_printf(display, 0, 0, "\t\t            %s Application       \n\r",
                       AppName);
        Display_printf(display, 0, 0,
                       "\t\t **************************"
                       "***********************\n\r");
        Display_printf(display, 0, 0, "\n\n\n\r");
    }
    
    
    void mainThread(void *pvParameters)
    {
        int32_t status = 0;
        pthread_attr_t pAttrs_spawn;
        struct sched_param priParam;
    	
        SPI_init();
        Display_init();
        display = Display_open(Display_Type_UART, NULL);
        if(display == NULL)
        {
            /* Failed to open display driver */
            while(1)
            {
                ;
            }
        }
    
        /* Print Application name */
        DisplayBanner(APPLICATION_NAME);
    
        /* Start the SimpleLink Host */
        pthread_attr_init(&pAttrs_spawn);
        priParam.sched_priority = SPAWN_TASK_PRIORITY;
        status = pthread_attr_setschedparam(&pAttrs_spawn, &priParam);
        status |= pthread_attr_setstacksize(&pAttrs_spawn, SPAWN_STACK_SIZE);
    
        status = pthread_create(&spawn_thread, &pAttrs_spawn, sl_Task, NULL);
        if(status)
        {
            printError("Task create failed", status);
        }
    
        /* Turn NWP on - initialize the device*/
        mode = sl_Start(0, 0, 0);
        if (mode < 0)
        {
            Display_printf(display, 0, 0,"\n\r[line:%d, error code:%d] %s\n\r", __LINE__, mode, DEVICE_ERROR);
        }
    
        if(mode != ROLE_STA)
        {
            /* Set NWP role as STA */
            mode = sl_WlanSetMode(ROLE_STA);
            if (mode < 0)
            {
                Display_printf(display, 0, 0,"\n\r[line:%d, error code:%d] %s\n\r", __LINE__, mode, WLAN_ERROR);
            }
    
            /* For changes to take affect, we restart the NWP */
            status = sl_Stop(SL_STOP_TIMEOUT);
            if (status < 0)
            {
                Display_printf(display, 0, 0,"\n\r[line:%d, error code:%d] %s\n\r", __LINE__, status, DEVICE_ERROR);
            }
    
            mode = sl_Start(0, 0, 0);
            if (mode < 0)
            {
                Display_printf(display, 0, 0,"\n\r[line:%d, error code:%d] %s\n\r", __LINE__, mode, DEVICE_ERROR);
            }
        }
    
        if(mode != ROLE_STA)
        {
            printError("Failed to configure device to it's default state", mode);
        }
        Connect();
    }
    

  • The -2006 is returned when the socket used is closed. Are you sure about the socket status?

    Are you able to work with the reference "httpget" example in the new sdk?

    Please provide a FW log (https://processors.wiki.ti.com/index.php/CC3120_&_CC3220_Capture_NWP_Logs)?

    br,

    Kobi

  • Hi

    I have already tried "HTTPGET" example of new sdk and isue is same. Also previously  shared code file are from that only. you can see log file also in attachment.

    Terminal log file
    Date: 23-12-2019 - 10:56:49
    -----------------------------------------------
    
    
    		 *************************************************
    
    		            HTTP GET Application       
    
    		 *************************************************
    
    
    
    Connecting to : ASUS.
    
    [NETAPP EVENT] IP Acquired: IP=192.168.5.165 , Gateway=192.168.5.1
    
    Sending a HTTP GET request to 'http://www.alteemiot.com'
    Error! code = -2006, Description = httpTask: connect failed
    
    -----------------------------------------------
    Date: 23-12-2019 - 10:57:11
    End log file
    

  • Hi,

    Please try to debug the SlNetUtil_getHostByName (either by stepping inside with the debugger, or by adding the source/ti/net/slnetutils.c to your project and adding debug messages within the function).

    There are couple of points of failure, but i can't tell which one is relevant here. I need more inputs to understand your problem.

    Br,

    Kobi

  • Hi,

    we will try to debug inside  SlNetUtil_getHostByName function. 

  • Ok. 

    Please let us know if you find anything.

    Br,

    Kobi

  • Hi,

    presently we are focusing on our main app development, as well as parallely looking for solution for such issues. as anything will solved surely we post on this forum.

    Thank you