Other Parts Discussed in Thread: CC3100, EK-TM4C1294XL
Hi All,
I am using ti rtos and httpcli library with tm4c129encpdt using Ethernet.
I am trying to connect to mqtt server (AWS IoT) using httpcli library over port no 8883
My raw code is -
typedef struct TLSDataParams {
HTTPCli_Struct aws_cli;
HTTPCli_Params aws_params;
HTTPCli_Field aws_fields;
struct sockaddr_in aws_addr;
TLS_Params aws_tlsPar;
TLS_Handle aws_tls;
} TLSDataParams; //////// tls parameters at one place
////////////// creating and connecting to server
tlsDataParams->aws_fields.name = HTTPStd_FIELD_NAME_HOST;
tlsDataParams->aws_fields.value ="xxxxxxxxxxxxxxx";
HTTPCli_construct(&tlsDataParams->aws_cli);
HTTPCli_setRequestFields(&tlsDataParams->aws_cli, (const HTTPCli_Field *)&tlsDataParams->aws_fields);
TLS_Params_init(&tlsDataParams->aws_tlsPar);
tlsDataParams->aws_tlsPar.ca = pRootCALocation ; // certs to be done later akhilesh
tlsDataParams->aws_tlsPar.calen = root_ca_pem_len;//sizeof(tlsParams->pRootCALocation );
tlsDataParams->aws_tlsPar.cert = tpDeviceCertLocation;
tlsDataParams->aws_tlsPar.certlen = client_cert_pem_len;//sizeof(tlsParams->pDeviceCertLocation);
tlsDataParams->aws_tlsPar.key = pDevicePrivateKeyLocation;
tlsDataParams->aws_tlsPar.keylen = client_private_key_pem_len;//sizeof(tlsParams->pDevicePrivateKeyLocation);
tlsDataParams->aws_tls = TLS_create(TLS_METHOD_CLIENT_TLSV1_2, &tlsDataParams->aws_tlsPar, NULL);
if(!tlsDataParams->aws_tls){
ret = FAILURE;
goto QUIT;
}
strcat(pDestinationURL, ":"); strcat(tlsParams->pDestinationURL, portStr);
status = HTTPCli_initSockAddr((struct sockaddr *)&tlsDataParams->aws_addr, pDestinationURL, 0);
if(status < 0)
{
int error = HTTPCli_getSocketError(&tlsDataParams->aws_cli);
ret = error;
goto QUIT;
}
HTTPCli_Params_init(&tlsDataParams->aws_params);
tlsDataParams->aws_params.tls = tlsDataParams->aws_tls;
// logStr(" url is %s", __FUNCTION__,tlsParams->pDestinationURL);
status = HTTPCli_connect(&tlsDataParams->aws_cli, (struct sockaddr *)&tlsDataParams->aws_addr, 0, &tlsDataParams->aws_params);
if(status < 0)
{
int error = HTTPCli_getSocketError(&tlsDataParams->aws_cli);
ret = error;
goto QUIT;
} /////////////// till here. I am getting status = 0;
///////sedning data to server
bytes = HTTPCli_sendRequestBody(&tlsDataParams.aws_cli, ( char *)pMsg, len); // pmsg and len are valid fields
/// here I am getting the value of bytes = -188
if (bytes < 0 ) {
error = HTTPCli_getSocketError(&pNetwork->tlsDataParams.aws_cli);
/// the value of error is 0 despite getting bytes = -188
IOT_ERROR("send failed (error = %d)\n", error);
}
My main concern is here at while sending. I hope the connection is successful as I am not getting any error and return value is 0.
bytes = HTTPCli_sendRequestBody(&tlsDataParams.aws_cli, ( char *)pMsg, len); // pmsg and len are valid fields
/// here I am getting the value of bytes = -188
if (bytes < 0 ) {
error = HTTPCli_getSocketError(&pNetwork->tlsDataParams.aws_cli);
/// the value of error is 0 despite getting bytes = -188
IOT_ERROR("send failed (error = %d)\n", error);
}
While sending, bytes = -188 and error = 0.
Why is it so? Can anyone help me in this?
Thanks
Akhi

