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.

CC3220S-LAUNCHXL: Creating HTTP client in init() and sendRequest in send()

Part Number: CC3220S-LAUNCHXL

Hi,

I am trying to create/connect httpClientHandle by doing the below in the init() of my code

                    Display_printf(display, 0, 0, "httpTask: CREATING HTTP");
                    // HTTP Construct
                    int16_t ret = 0;
                    int16_t statusCode;
                    httpClientHandle = HTTPClient_create(&statusCode,0);
                    if (statusCode < 0)
                    {
                        Display_printf(display, 0, 0, "httpTask: creation of http client handle failed", statusCode);
                    }
                    ret = HTTPClient_connect(httpClientHandle,HOST_NAME,0,0);
                    if (ret < 0) {
                        Display_printf(display, 0, 0, "httpTask: connect failed", ret);
                    }

I also have a function called httpTask() which references to the above httpClientHandle by doing

extern HTTPClient_Handle httpClientHandle;

However, when I try to do a Send request inside of httpTask(), I get an error. On the other hand, when I create/connect httpClientHandle inside of httpTask() instead of init() and then do a Send request, I don't have a problem. Why is this so?

extern HTTPClient_Handle httpClientHandle;

  • Hi Jack,

    When you run your program with the debugger and halt at your Send, what do you see in the httpClient struct? Is there any substantial difference between calling the create() and connect() in init() as opposed to in httpTask()? Is the httpClientHandle initialized correctly? Is it deallocated or otherwise corrupted by the time you get to httpTask()?

    I would take a close look at what you're doing different in init() compared to the having the equivalent create() and connect() calls in httpTask.

    Regards,
    Michael
  • Hi Jack,

    I assume that you have resolved your issue since I haven't heard back from you. If not, please feel free to post here on this thread or open a new one regarding the issue.

    Regards,
    Michael