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.
Hi,
I read the tutorial for Http_client demo. This is the first time i work with cloud so there is many things confuse me.
1/ I don't know where to add the code snippet in the instruction and where to place/call HTTPCli_connect function in file main.c.
I think TI should give more details for a newbie like me.
2/ Fortunately, i find this post and downloaded secure_http_client_demo.7z. Then i added file main.c into http_client demo project.
I don't know how to use this file "howmyssl.der.cer " so i do nothing with it.
I build the project and flash file. bin into CC3200.
When I run code on the board I am getting following error:
Connection to server failed. error(-102)
Error [-2011] at line [1237] in function [ConnectToHTTPServer]
Regards,
Khoa
Tuan Khoa Nguyen said:I don't know where to add the code snippet in the instruction and where to place/call HTTPCli_connect function in file main.c.
I think TI should give more details for a newbie like me.
1. For non-secure http connection you need to modify value of HOST_NAME, HOST_PORT, SSID_NAME, SEC_TYPE and PASSKEY macros as mentioned on tutorial.
2. In case of secure http connection in existing http client example you need to add code snippet before the HTTPCli_connect() and change
"HTTPCli_connect(&cli, (struct sockaddr *)&addr, 0, NULL);" to "HTTPCli_connect(&cli, (struct sockaddr *)&addr, HTTPCli_TYPE_TLS, NULL);"
Tuan Khoa Nguyen said:Fortunately, i find this post and downloaded secure_http_client_demo.7z. Then i added file main.c into http_client demo project.
I don't know how to use this file "howmyssl.der.cer " so i do nothing with it.
You need to flash certificate "howmyssl.der.cer" at /cert/1.crt using uniflash.
Regards,
Aashish
Hi,
Thank you for your replying
I follow this tutorial in section 8 to add the certificate. I change "howmyssl.der.cer" to "1.cer" and config like the attachment picture
But when I run code on the board I still getting following error
Hi,
I run in debug mode and jump into HTTPCli_connect() like you said.
and I don't see any error in ccs debug
and i'm still confuse about the Http_client_demo example.
+ I don't know how to get the certification of the website ( ex: google speech api , Wit.ai )
+ if i don't have the certificate, what should i do with this line strncpy(sparams.cafile, SL_SSL_CA_CERT, sizeof(SL_SSL_CA_CERT));
regards,
Khoa
Hi
Tuan Khoa Nguyen said:and I don't see any error in ccs debug
Jump in to HTTPCli_Connect() and share return value (ret) of connect(skt, sa, slen); API
Tuan Khoa Nguyen said:+ I don't know how to get the certification of the website ( ex: google speech api , Wit.ai )
Contact your server support team(ex: google speech api , Wit.ai) to get more information about how to get certificates for secure connecion to their server
Tuan Khoa Nguyen said:+ if i don't have the certificate, what should i do with this line strncpy(sparams.cafile, SL_SSL_CA_CERT, sizeof(SL_SSL_CA_CERT));
If your server support non-secure connection then try to run http client example in non-secure mode (undefine SECURE macro in your example code)
Regards,
Aashish
Hi
Does the current time is important ?
SlDateTime_t dt; /* Set current Date to validate certificate */ dt.sl_tm_day = 20; dt.sl_tm_mon = 3; dt.sl_tm_year = 2016; dt.sl_tm_hour = 15; dt.sl_tm_min = 57; dt.sl_tm_sec = 00;
I cannot set the time correctly when i flash the code.
And how to add a certificate in project CCS and uniflasf correcly
regards,
Khoa
Hi Khoa,
Tuan Khoa Nguyen said:I cannot set the time correctly when i flash the code.
No need of set exact time. Approx time is ok. If you still want to use exact time than get current time using Network time protocol at set it.
Tuan Khoa Nguyen said:And how to add a certificate in project CCS and uniflasf correcly
In uniflash click on button "Add File" and rename it to the name that you are going to use in code for example "/cert/testcacert.der"
Regards,
Aashish
Hi,
I debuged and jumped into HTTPCli_connect
I still using the code secure above
Best regards,
Khoa
Hi Aashish,
The value is -102.
If i want to use HTTPS POST to https://www.howsmyssl.com or https://www.google.com/speech-api/v2/recognize
Does the example HTTP_Client demo is enought or i have to combine more examples ( like SSL_demo) ?
Best regards,
Khoa
Hi Khoa,
Step into HTTPCli_Connect() API and share return value (ret) of connect(skt, sa, slen); API
Regards,
Aashish
Hi,
I'm very sorry.
I fixed the problem.
The reason is that the certificate which is contained in file zip was out of date.
Just export the new top level certificate in https://www.howsmyssl.com and no error was found
Thank you for your help.
Regards,
Khoa
Hi Aashish,
I have another problem.
Now the error is "Error [-2012] at line [1192] in function [ConnectToHTTPServer] "
I found the answer in this link but i didn't know how to change the code.
Would you mind helping me.
Regards,
Khoa
Hi Aashish,
#define HOST_NAME "https://www.google.com" #define HOST_PORT 443 #define POST_REQUEST_URI "/speech-api/v2/recognize" #define POST_DATA EncodedBase64_data HTTPCli_Field fields[4] = { {"Content-Type","audio/l16; rate=16000;"}, {"output","\"json\", \"lang\": \"vi-VN\", \"key\": \"My_key\""}, {NULL, NULL} };
I have used temboo to connect with google api and it works but it took 1 minute to receive the return value.
So i think cc3200 connect directly to google api will work faster and i am not used to using energia.
regards,
Khoa
Hi Aashish,
I am using SDK1.1.0(host driver 1.0.0.10).
If i reset cc3200, that line doesn't appear again but google api still not received anything .
When i use energia to send temboo the same data, it works properly .
Should i split a data into smaller then sent HTTPCli_sendField and HTTPCli_sendRequestBody respectively, right ?
Update: Even i sent the small data (12kB) . Google api still not received anything
Regards,
Khoa