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: CC3220 HTTP Client missing - is it for real?

Part Number: CC3220SF-LAUNCHXL
Other Parts Discussed in Thread: CC3200

Hi TI!

Using the CC3220 as my application processor, I need to have access to external Web services, and for this, I need to have

HTTP/S client.

I couldn't find any reference to such library. I saw previous response, that it is not yet included in the SDK, and that there are plans to 
add it. any update on this subject?

I must admit that HTTP client is one of the very basic functionalities an IoT processor should have!

Please advice,
Thanks!
Mickey

  • Hi Mickey,

    We are planning to add a HTTP client library, but it is not currently available. The functionality is all application-based, so in the meantime you can implement your own or migrate the old library from the CC3200 (the Gen 1 to Gen 2 Migration Guide is available in the docs folder of the SDK).

    Best regards,

    Sarah

  • Hi Sarah,

    I can't find it on the docs folder of the CC3200 SDK (v1.3.0). What is the name of that migration guide ?
    Thanks.

    Best regards,

    Tom
  • Hi Tom,

    You can find the HTTP Client example and library in the CC3200 SDK in folders cc3200-sdk/example/http_client_demo and cc3200-sdk/netapps/http/client. You can find the Gen 1 to Gen 2 Migration Guide in the CC3220 SDK in the docs folder through the Documentation Overview. You can also find it at docs/simplelink_mcu_sdk/SimpleLink_Gen1_to_Gen2_SDK_Migration_Guide.html

    Best regards,
    Sarah

  • Sarah,

    When do you plan on having an HTTP Client library available? 

     

    I've been struggling to migrate the old CC3200 library over.. it has been a nightmare.

     

    Steve

     

  • Hi Steve,

    This library is planned for the Q4 release (at end of 4th quarter).

    Best regards,
    Sarah

  • Hi Mickey and Steve,

    The HTTP library for the CC3220 is actually already available and included in several plugins that use HTTP. We anticipate integrating the HTTP library into the Q4 release of the SDK, but in the meantime you can download one of the plugins and use the included HTTP library.

    One plugin with the new CC3220 HTTP client library is the CC3220 AWS IoT plugin. You can download it following the instructions on the AWS IoT wiki page.

    Once you have downloaded and unzipped the package, the new CC3220-compatible HTTP library is located at source\ti\net\http. The HTTP library is built on top of the new Network Services library, so you'll need to link to \source\ti\lib\network_sl.aem4 in addition to source\ti\net\http\lib\http_sl.aem4

    Make sure you define the symbol "ti_net_http_HTTPCli__deprecated" in your compile options so that you can use the CC3200-style API calls.

    Regards,

    Michael

  • Thanks for your help....

  • When I add in the HTTP library and build my project, I get an error of undefined symbol xdc_runtime_System_vsnprintf__E first referenced in C:/ti/aws_cc3220_1_10_00_07/source/ti/net/http/lib/http_sl.aem4<httpcli.oem4>
  • Here is a function I wrote (based off the TI example in the header file) to post "certhash" to a requestb.in.  If I uncomment any of the 3 HTTPCli_send lines, it throws that error.  Hopefully that helps.

    int32_t network_task_http_post (void) {
        int32_t error = NETWORK_TASK_ERROR_SUCCESS;
        TLS_Handle tls;
        HTTPCli_Struct cli;
        HTTPCli_Params params;
        int status = 0;
        char* p_data = "certhash";
        char* p_length = "8";
        char buffer[100] = {};
        int32_t length = 0;
        bool moreFlag = 0;
        const char* hostname = "https://requestb.in/ssfheyss";
        _u32 ip_address = 0;
        struct sockaddr_in address;
    
        tls = TLS_create(TLS_METHOD_CLIENT_TLSV1_1);
        TLS_setCertFile(tls, TLS_CERT_TYPE_CA, TLS_CERT_FORMAT_DER, "./requestbin-ca.crt");
    
        // Request fields
        HTTPCli_Field fields[2] = {
           { HTTPStd_FIELD_NAME_HOST,  "https://requestb.in/ssfheyss" },
           { NULL, NULL }
        };
    
        // Response field filters
        const char* respFields[2] = {
           HTTPStd_FIELD_NAME_CONTENT_LENGTH,
           NULL
        };
    
        address.sin_family = AF_INET;
        sl_NetAppDnsGetHostByName((signed char*)hostname, strlen(hostname), &ip_address, address.sin_family);
        address.sin_port = htons(80);
        address.sin_addr.s_addr = htonl(ip_address);
        // Construct a static HTTP client instance
        HTTPCli_construct(&cli);
    
        HTTPCli_setRequestFields(&cli, fields);
    
        HTTPCli_setResponseFields(&cli, respFields);
    
        //Set the TLS context
        HTTPCli_Params_init(&params);
        params.tls = tls;
    
        // Connect securely to the HTTPS Server
        HTTPCli_connect(&cli, (struct sockaddr*)&address, 0, &params);
    
        // Make HTTP 1.1 POST request
        //
        // Send request to the server:
        //
        // POST /index.html HTTP/1.1
        // Host: www.example.com
    //    HTTPCli_sendRequest(&cli, HTTPStd_POST, "/index.html", true);
    
        // Send additional fields
        //
        // Content-Length: <length>
        // <blank line>
    //    HTTPCli_sendField(&cli, HTTPStd_FIELD_NAME_CONTENT_LENGTH, p_length, true);
    
        // Send request body
        //
        // <data>
    //    HTTPCli_sendRequestBody(&cli, p_data, strlen(data));
    
        // Get the processed response status
        //
        // HTTP/1.1 200 OK
        status = HTTPCli_getResponseStatus(&cli);
    
        NETWORK_TASK_PRINTF("Response: %d\n\r", status);
        // Check the HTTP return status and process remaining response
        if (status == HTTPStd_OK) {
            gb_is_profile_confirmation_pending = 0;
           do {
               // Filter the response headers and get the set response field
               //
               //...
               // Content-type: text/xml; charset=utf-8\r\n
               // Content-length: 34
               //  ...
               error = HTTPCli_getResponseField(&cli, buffer, sizeof(buffer), &moreFlag);
    
               //  Process data in buffer if field is content length
               //  Zero is the index of Content length in respFields array
               if (error == 0) {
                   length = (int)strtoul(buffer, NULL, 0);
               }
    
           } while (error != HTTPCli_FIELD_ID_END);
    
           while (length > 0) {
               length -= HTTPCli_readRawResponseBody(&cli, buffer, sizeof(buffer));
               // ... process buf data and save ...
           }
        } else {
            error = NETWORK_TASK_ERROR_EXTERNAL_CONFIRMATION;
        }
    
        HTTPCli_disconnect(&cli);
    
        HTTPCli_destruct(&cli);
    
        return error;
    }

  • Hi Matt,

    Are you using TIRTOS? You need to have TIRTOS setup properly otherwise you'll run into errors with missing runtime libraries.

    Try out the steps in this forum post and see if that helps:

    e2e.ti.com/.../325006

    If that doesn't work, you could also import one of the AWS examples which will have everything setup properly, and then strip out all of the example-specific code and replace it with your own program.

    Regards,
    Michael
  • My project uses FreeRTOS. Am I not able to use that with the AWS http library? I actually started my project with the FreeRTOS subscribe and publish example from the AWS plugin. All of that functionality seems to be working fine.
  • Michael,

    Thank you for the pointer, but... there are lots of questions to answer before I can get the HTTP Client demo working. Which of the Ssock.h versions should I be using there isn't one in the AWS plugin. will the one in the TI RTOS  directory work or should I use the one in the CC3200 SDK? 

    There seems to be a mountain of dependencies

    It would be great if you would port the HTTP Client to the latest libs/inculdes demo so I can copy the include and Lib paths as well as predefined symbols. 

    The porting documentation is pretty minimal and not too much help

  • Hi Matt,

    It could be that the http_sl binaries were built with TIRTOS components. In that case, you might need to build from the HTTP library source files instead of just linking to the http_sl binary.

    What I did to get the subscribe_publish_sample freertos example compiling with the HTTPcli_sendRequest() call was the following:

    1. I included ti/net/common.h in addition to ti/net/http/httpcli.h in the source file making the HTTPCli_sendRequest() call.

    2. I edited ti/net/common.h to remove the xdc runtime references. Specifically, I had to change the include statements at the top to the following:

    #include <assert.h>
    #include <stdarg.h>
    #include <stdlib.h>
    
    #ifdef __linux__
    #include <stdio.h>
    #else
    #ifdef freertos
    #include <stdio.h>
    #else
    #include <xdc/runtime/System.h>
    #endif
    #endif

    Then I changed the xsnprintf function to the following:

    static inline int xvsnprintf(char *s, size_t n, const char *fmt, va_list arg)
    {
    #ifdef __linux__
        return (vsnprintf(s, n, fmt, arg));
    #else
    #ifdef freertos
        return (vsnprintf(s, n, fmt, arg));
    #else
        return (System_vsnprintf(s, n, fmt, arg));
    #endif
    #endif
    }

    and then I added "freertos" as a predefined symbol in my compiler options.

    3. Finally, I copied httpcli.c from the source\ti\net\http\ directory of the AWS plugin into my workspace, so that the linker would link to HTTPcli_ functions that do not use xdc libs. In this copy of httpcli.c, I also fixed the include path to httpcli.h.

    That should hopefully fix your issue and allow you to use the updated HTTP library wiith FreeRTOS.


    Regards,

    Michael

  • Please note, the FreeRTOS support in NS will be available in the Q4'ish time-frame. FreeRTOS is fine with most of NS, but as Michael noted, the HTTPClie portion has not been ported to work with FreeRTOS.
  • Hi Steve,

    As Sarah mentioned, we plan on having full documentation and support for the HTTP library ready by the Q4 SDK release. In the meantime however, the HTTP library distributed with the plugins can be used, it's just that we do not have complete support for it yet. The HTTP Client functionality should be demonstrated with an SDK example in Q4, but if you want to start porting over the CC3200 example, here is some general advice on how you would go about doing this.

    When porting from CC3200 to CC3220, I would recommend that you start by taking an existing CC3220 project that has the components you need, remove all of the application-specific source files, and then integrate your existing CC3200 code into this project.

    In this case, you could import one of the examples provided as part of the AWS plugin and then remove all of the AWS-specific code. That would leave you with a project with an RTOS linked correctly, correct include paths, etc.

    Once you have moved over the CC3200 HTTP client demo code into that project, you'll need to add source\ti\net\http\lib\http_sl.aem4 to your linker's file search path, and then include ti/net/http/httpcli.h and ti/net/common.h in your ported source files. If you use an example project from the AWS plugin and add the appropriate includes mentioned above, the mountain of dependencies should resolve itself.

    For example, the ssock.h would be pulled from source\ti\net, as httpcli.h refers to it. This ssock.h will refer to source\ti\net\socket.h, which will pull in the needed SimpleLink WiFi drivers.

    Hopefully, that will make your porting effort much easier.

    Regards,
    Michael

     

  • Michael,

    Thanks that worked well and I am able to use the HTTP Library with FreeRTOS.  However, AWS API Gateway requires Domain Name Verification.  While this is supported by the CC3220 and it has a code snippet in the documentation, I'm not sure exactly where to put it so that it gets compiled into my project.  I've tried to just insert it into the HTTPCli_connect function in the httpccli.c I copied into my project, but that doesn't seem to do anything.  I tried to track down the function calls and it looks like maybe another socket is created or something with different options that is part of a library?  Below is the piece of code I need to use (google is just an example), but I'm not really sure where I need to put it and what I need to build so that it is actually getting called.

    ret = sl_SetSockOpt(SockID, SL_SOL_SOCKET,_SO_SECURE_DOMAIN_NAME_VERIFICATION, "www.google.com",strlen("www.google.com"));

  • Hi Matt,

    Try putting the sl_SetSockOpt() call enabling Domain Name Verification right after the Ssock_startTLS() call in HTTPCli_connect.

    Regards,
    Michael
  • Michael,

    I tried that and it's still not sending the domain name, which is causing the handshake to fail and return error -340.  In order to verify what is being sent, we enabled some logging features on a test server that shows the server name is not provided

    AH02645: Server name not provided via TLS extension (using default/first virtual host)

    #ifdef NET_SL
                /* In SL, the secure params have to be set before connect */
                if (cli->tls) {
                    ret = Ssock_startTLS(&(cli->ssock), cli->tls);
                    if (ret < 0) {
                        cli->sockerr = getErrno(ret);
                        HTTPCli_disconnect(cli);
    
                        return (HTTPCli_ETLSFAIL);
                    }
                    ret = sl_SetSockOpt(skt, SL_SOL_SOCKET, SL_SO_SECURE_DOMAIN_NAME_VERIFICATION, "johnveldboom.com", strlen("johnveldboom.com"));
                    if(ret < 0) {
                        cli->sockerr = getErrno(ret);
                        HTTPCli_disconnect(cli);
                        return (HTTPCli_ETLSFAIL);
                    }
                }
    #endif

  • Still having this issue, any other suggestions?
  • Hi Matt,

    You should set the Domain Verification option before starting the TLS.

    Br,

    Kobi 

  • Sarah Pelosi said:

    Hi Steve,

    This library is planned for the Q4 release (at end of 4th quarter).

    Best regards,
    Sarah

    Hi Sarah,

    a new revision of the SDK was released a few days ago, and apparently HTTP library was not included in this review.

    That's right?

    Is there any hope that it will be released later this year?

    Thanks!
    Rafael

  • Hi Rafael,

    The HTTP Client library is still planned for the end of 4th quarter, so by the end of this year.

    Thanks,

    Sarah

  • Hi Sarah,

    thanks for feedback.

    Taking advantage of the occasion, is there any provision for adding the client websocket library as well?

    Thanks,
    Rafael
  • Hi Rafael,

    Not yet. We do not currently have a date for a websocket client library. It would be possible to implement as application code though.

    Best regards,
    Sarah