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.

CC3100BOOST: CC3100Booster Pack + MSP430F5529LP: Trouble with long RESTful API command strings? (GET Method)

Part Number: CC3100BOOST
Other Parts Discussed in Thread: CC3100, CC3100SDK

I have been working on experimenting using MSP430F5529LP and CC3100Boost wifi Boosterpack to develop a Low Power IOT device. The experiment platform connects to a server and successfully exchanges data. I am using restful API for communication/data exchange as well as TLS for security. I am also using Texas Instruments simplelink software platform for development. I am using GET Method to communicate with the server. Where I am stuck is when I executed the following command with a string length of more than 111 characters. (Note: Code snippet is modification for Http_Client example). str is string variable with the restful command.

    strcat(str,str2);
    /* Set request header fields to be send for HTTP request. */
    HTTPCli_setRequestFields(httpClient, fields);
    /* Send GET method request. */
    /* Here we are setting moreFlags = 0 as there are no more header fields 
   need to send
   at later stage. Please refer HTTP Library API documentaion @ 
   HTTPCli_sendRequest for more information.
   */
   moreFlags = 0;
   retVal = HTTPCli_sendRequest(httpClient, HTTPCli_METHOD_GET, (const char *) str, moreFlags);
   if(retVal < 0)
   {
       CLI_Write(" Failed to send HTTP GET request.\n\r");
       return retVal;
   }


   sprintf((char *)tmpBuf, "%d", (sizeof(str)-1));

   /*
    Here we are setting lastFlag = 1 as it is last header field. Please refer 
    HTTP Library API documentaion @ref HTTPCli_sendField for more information.
   */

   lastFlag = 1;
   retVal = HTTPCli_sendField(httpClient, HTTPCli_FIELD_NAME_CONTENT_LENGTH, (char *)tmpBuf, lastFlag);
   if(retVal < 0)
   {
       CLI_Write(" Failed to send HTTP GET request header.\n\r");
       return retVal;
   }

   retVal = readResponse(httpClient);
   // Send GET data/body
   retVal = HTTPCli_sendRequestBody(httpClient, (const char *) str, (sizeof(str)-1));
   if(retVal < 0)
   {
       CLI_Write(" Failed to send HTTP GET request body.\n\r");
       return retVal;
   }
 
    retVal = readResponse(httpClient); 

    return retVal;

As state aboue if str string length is more than 111 characters, upon execution of “HTTPCli_sendRequest” the function returns and error code of HTTPCli_ESENDBUFSMALL (-107). Following are additional details for the error from HTTPCli_ESENDBUFSMALL.


/#define HTTPCli_ESENDBUFSMALL (-107)
Internal send buffer is not big enough.
Modify the SEND_BUFLEN macro in the httpcli.c and rebuild the library if needed.

Following a code snippet from httpcli.c

/* Configurable lengths */
#define CONTENT_BUFLEN 128
#define URI_BUFLEN 128
#define SEND_BUFLEN 128
#define MAX_FIELD_NAME_LEN 24

I tried to change SEND_BUFLEN to 256, but I still encountered errors. So I am thinking there might be one of two possible paths moving forward

  1. Update the buffer lengths as appropriate
  2. Break the date packets into to many 128 byte groups.

Appreciate if someone could share thoughts on how to move forward.

  • Hi Mahendra,

    When you updated httpcli.c did you rebuild the webclient library and make sure the rebuilt version of the library is properly linked to the http_client example? By default it should link to a pre-built version of the library so the change may not have taken effect in the application.

    Best Regards,
    Ben M
  • Hello Ben,

    Thank you very much for your response. Can your please enlightenment me on rebuilding the web-client library? Below is a snap shot of the CCS http_client project folder.

  • Hi Mahendra,

    It looks like you merged the library and the application into one project. They are separated in the SDK by default. Also, apologies for the confusion in naming. In the CC3100 SDK the library is http_lib.

    When you merged the two, did you remove the following directory path from the project Properties -> Build -> MSP430 Linker -> File Search Path?
    "${CC3100_SDK_ROOT}/platform/msp430f5529lp/library_project_ccs/http_lib/Debug"

    Thanks,
    Ben M
  • Hello Ben,

    Thank you for the response. Yes I believe I don't have any references to http_lib under the  Properties -> Build -> MSP430 Linker -> File Search Path

    Attach below are snap shot to the file paths

    Regards

    Mahendra

  • Hi Mahendra,

    It is odd that you added "C:\ti\CC3100SDK_1.2.0\cc3100-sdk\netapps\http\client" to the library search path. It will be hard to figure out how your http client library is building with all the changes that you have made.

    Can you try using a stock version of the example from the SDK and making the modification to the SEND_BUFLEN to see if that allows it to work? Could you also check by stepping through your application to make sure the error is being generated from the point that the code compares the length of the HTTP request to the defined SEND_BUFLEN?

    Thanks,
    Ben M
  • Hello Ben,

    I am wondering if the issue on Unable to retrieve message body for a GET method on MSP430F5529LP/CC3100 (Http_Client example). Because Transfer-Encoding: chunked and CONTENT_LENGTH is not defined. Therefore the following code in the readresponse function is not getting executed.

    case 0: /* HTTPCli_FIELD_NAME_CONTENT_LENGTH */
    {
    	len = strtoul((char *)g_buff, NULL, 0);
    }

    Anyhow I changed SEND_BUFLEN to 256 and step through the code. The change is getting compiled and is reflected on sendbuf  character string. Below are some snap shot confirming the change.

    Note: I found that SEND_BUFLEN is used in following function in httpcli.c file.

    /*
     *  ======== sprsend ========
     *  Constructs a HTTP Request line to send
     */
    static int sprsend(HTTPCli_Handle cli, const char * fmt, ...)



    Also can you please shed some light on the following line of code in sprsend() function



    /*
    len = xvsnprintf(sendbuf, sendbuflen, fmt, ap);