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.

HTTP Client POST Base64 Encoded data

Other Parts Discussed in Thread: CC3200, CC3200SDK, UNIFLASH

Hi

I am using the CC3200 Audio BoosterPack for streaming audio.

I want to stream the data from the MIC ( by means of HTTP Posts) to Google. 

The Microphone will recognize the voice, which is encoded in Base64. CC3200 will later send HTTP Post that contains Base64-encoded data to Google 

So i have some questions.

1/ I can encode base64 from base64.c in CC3200SDK (C:\ti\CC3200SDK_1.1.0\cc3200-sdk\netapps\http\server\base64.c) right ?

2/  In the HTTP client demo example. I can't connect with https . This is my post 

3/  I have tested with python so i have to send 

+ RequestHeaders("{\"Content-Type\": \"audio/l16; rate=16000;\"}")

+RequestParameters("{\"output\": \"json\", \"lang\": \"vi-VN\", \"key\": \"My_token\"}")

+ EncodedData : Base64 encoded data

But in the HTTP client demo example, in HTTPPostMethod.  i can't find the way to send RequestHeadersRequestParameters , Type for posting binary data.( base64 encoded data).

4/ When google return the value (Ex:  Vietnamese command voice line ) . How to code in CCS if it's not english

Example : If ( return_data == "Mở đèn đỏ")  

                       Turn_on_red_led();

Thank you

Regards,

Khoa

  • Tuan Khoa Nguyen said:
    1/ I can encode base64 from base64.c in CC3200SDK (C:\ti\CC3200SDK_1.1.0\cc3200-sdk\netapps\http\server\base64.c) right ?

    Yes, there should not be any issue.

    Tuan Khoa Nguyen said:
    2/  In the HTTP client demo example. I can't connect with https . This is my post 

    As we requested in last post jump in to HTTPCli_Connect() and share return value (ret) of connect(skt, sa, slen); API

    Tuan Khoa Nguyen said:

    3/  I have tested with python so i have to send 

    + RequestHeaders("{\"Content-Type\": \"audio/l16; rate=16000;\"}")

    +RequestParameters("{\"output\": \"json\", \"lang\": \"vi-VN\", \"key\": \"My_token\"}")

    + EncodedData : Base64 encoded data

    But in the HTTP client demo example, in HTTPPostMethod.  i can't find the way to send RequestHeadersRequestParameters , Type for posting binary data.( base64 encoded data).

    const HTTPCli_Field fields[4] = {

    {"Content-Type, "audio/16; rate=1600},
    {"output", "{\"output\": \"json\", \"lang\": \"vi-VN\", \"key\": \"My_token\"}"},
    {HTTPStd_FIELD_NAME_ACCEPT, "*/*"}, //If applicable, else remove it 
    {HTTPStd_FIELD_NAME_CONTENT_TYPE, "application/json"}, //If applicable, else remove it 
    {NULL, NULL}
    };

    To send any HTTP header use HTTPCli_Field structure and HTTPCli_sendField() API as mentioned above. To send data (base 64 encoded data) use HTTPCli_sendRequestBody() API

    Tuan Khoa Nguyen said:
    4/ When google return the value (Ex:  Vietnamese command voice line ) . How to code in CCS if it's not english

    Use memcmp to compare the value

    Regards,

    Aashish

  • Hi,

    Thank you for your help.

    I want to ask how to get a certificate from a website https

    I want to get the general root CA for connecting to Google through HTTPS which is the GeoTrust Global CA.

    I found this tutorial. Does it's right ?   If it is which format i should choose for CC3200 using.

    Best regards,

    Khoa

  • Hi Khoa,


    Yes above steps are right and you need to select der encoded binary format.


    Regards,
    Aashish
  • Hi Aashish,

    If there are two certificates in the web

    I just run this code below twice right ? run the top level certificate ( GeoTrust Global CA)  first then run the next level certificate  (Google Internet Authority G2) ? 

    or just run one certificate ?

    #define SL_SSL_CA_CERT	"/cert/1.crt"
    	struct HTTPCli_SecureParams sparams;
    	/* Set secure TLS connection  */
    	/* Security parameters */
    	sparams.method.secureMethod = SL_SO_SEC_METHOD_TLSV1_2;
    	sparams.mask.secureMask = SL_SEC_MASK_TLS_RSA_WITH_AES_256_CBC_SHA; //SL_SEC_MASK_TLS_RSA_WITH_AES_256_CBC_SHA;
    	strncpy(sparams.cafile, SL_SSL_CA_CERT, sizeof(SL_SSL_CA_CERT));
    	sparams.privkey[0] = 0;
    	sparams.cert[0] = 0;
    	sparams.dhkey[0] = 0;
    	HTTPCli_setSecureParams(&sparams);

    Best regards,

    Khoa

  • Hi Khoa,


    Use root CA certificate.


    Regards,
    Aashish
  • Hi Aashish,

    You mean the top level certificate ( GeoTrust Global CA) ?

    regards,
    Khoa
  • Hi Khoa,


    Yes. Top level certificate.


    Regards,
    Aashish
  • Hi Aashish,

    Would you mind if i ask you some question

    1/ when the request POST send successfully and Google is 100% confident in it's translation,

    It will return the following object:

    {
      "result":[
        {
          "alternative":[
            {
              "transcript":"this is a test",
              "confidence":0.97321892
            },
            {
              "transcript":"this is a test for"
            }
          ],
          "final":true
        }
      ],
      "result_index":0
    }

    So I have to use lRetVal = readResponse(httpClient); (at the end of function HTTPPostMethod)  to receive the return data

    if i use readResponse, the header will be 

    	const char *ids[5] = {
    			HTTPCli_FIELD_NAME_CONTENT_LENGTH,
    			HTTPCli_FIELD_NAME_CONNECTION,
    			HTTPCli_FIELD_NAME_CONTENT_TYPE,
    			"result",
    			NULL
    	};

    with "result " in ids[5], cc3200 can receive the result from google, right ?

    Would you mind helping me

    2/ if the certificate is Google 2.cer, in UniFlash i have to name the file to /cert/1.cer 

    But in the SSL_demo wiki, in section Usage. It said i have to name the file to /cert/129.der or  /cert/129.crt

     

    Are there any difference ?

    3 Do you have any solutions to send http post more than 16kb

    Best regards,

    Khoa

  • Tuan, were you able to send to GeoTrust Global CA? If so what were your securemethod, and securemask settings? I am unable to connect to my server. Still getting -102