Tool/software: TI-RTOS
Hi,
I am using ccs v6.2 with tm41294xl I want to create "http post" task as like http get, can I get any links or solutions in TI-RTOS.
Regards,
Raghu DS
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.
Tool/software: TI-RTOS
Hi,
I am using ccs v6.2 with tm41294xl I want to create "http post" task as like http get, can I get any links or solutions in TI-RTOS.
Regards,
Raghu DS
Hi Steven,
Thanks for the reply, I had include path to my compiler as shown in my image
Am I added to correct place, and I am using tirtos V 2_16_00_08. But till getting same error- #1965 cannot open source file "ti/net/http/sswolfssl.h". Can you please help me to solve my problem.
Regards,
Raghu DS
Hi Steven,
I think what I did on above may be wrong, as you suggest my project already includes the path "C:\ti\tirtos_tivac_2_16_00_08\products\ns_1_11_00_10\packages"
but I searched in directory also the http folder not contain any of files like "sswolfssl.h" and "sssl.h" . The below is my directory image
So, Am I need to update anything, as told any problem with tirtos version.
Thanks,
Regards
Raghu DS
Raghu,
Yes, you actually were very close but that was the wrong place to add the compiler path. It should be added under the "Include Options" subsection of the compiler settings. See screen shot.
Note that if you based your app on the httpget example, the paths should already be set up properly for you. But if you need to add it, it should be done like the screen shot shows.
I searched in directory also the http folder not contain any of files like "sswolfssl.h" and "sssl.h"
Ok this is the issue - the documentation is out of date. The files “sssl.h” and “sswolfssl.h” morphed into “ti/net/tls.h” in TIRTOS 2.16. So, you should just need to include "ti/net/tls.h"
Steve
Hi Raghu,
Ok, I see the problem. It turns out that the example shown in that documentation was not updated for changes to the TLS set up code.
You should be able to do the following:
1. Copy the TLS set up code from the secure HTTP GET example (httpsget for TivaC)
2. Then use the HTTP code from the example in the documentation for POST
It should look something like this (note I did not compile this, I just did the work of combining the code of steps 1. and 2. for you):
Void httpsTask(UArg arg0, UArg arg1)
{
bool moreFlag = false;
char data[64];
int ret;
int len;
struct sockaddr_in addr;
TLS_Params tlsParams;
TLS_Handle tls;
HTTPCli_Struct cli;
// Request fields
HTTPCli_Field fields[2] = {
{ HTTPStd_FIELD_NAME_HOST, "www.example.com" },
{ NULL, NULL }
};
// Response field filters
char respFields[2] = {
HTTPStd_FIELD_NAME_CONTENT_LENGTH,
NULL
};
startNTP();
TLS_Params_init(&tlsParams);
tlsParams.ca = ca;
tlsParams.calen = calen;
tls = TLS_create(TLS_METHOD_CLIENT_TLSV1_2, &tlsParams, NULL);
if (!tls) {
printError("httpsTask: TLS create failed", -1);
}
// Construct a static HTTP client instance
HTTPCli_construct(&cli);
HTTPCli_setRequestFields(&cli, fields);
HTTPCli_setResponseFields(&cli, respFields);
// Connect securely to the HTTPS Server
HTTPCli_connect(&cli, &addr, HTTPCli_TYPE_TLS, NULL);
// 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, len, true);
// Send request body
//
// <data>
HTTPCli_sendRequestBody(&cli, data, strlen(data));
// Get the processed response status
//
// HTTP/1.1 200 OK
status = HTTPCli_getResponseStatus(&cli);
// Check the HTTP return status and process remaining response
if (status == HTTPStd_OK) {
do {
// Filter the response headers and get the set response field
//
//...
// Content-type: text/xml; charset=utf-8\r\n
// Content-length: 34
// ...
ret = HTTPCli_getResponseField(&cli, buf, sizeof(buf), &moreFlag);
// Process data in buf if field is content length
// Zero is the index of Content length in respFields array
if (ret == 0) {
len = (int)strtoul(buf, NULL, 0);
}
} while (ret != HTTPCli_FIELD_ID_END);
while (len > 0) {
len -= HTTPCli_readRawResponseBody(&cli, buf, sizeof(buf));
// ... process buf data and save ...
}
}
HTTPCli_disconnect(&cli);
HTTPCli_destruct(&cli);
Steve