Other Parts Discussed in Thread: CC3200
Tool/software: Code Composer Studio
Hello,
I am using cc3200 sdk 1.3.0 and ccs v7 with cc3200launchXL for prototyping. The example works out of the box, but now I am trying to create dynamic json data with the help of this library. I have unit tested json strings generated from this library and also did http post using curl and it works fine. The problem is when I use strings generated from its api (which are json validated), the http post does not work and on the terminal I see only HTTP Post begin and HTTP Post end. on the Http server no data is received, and I get absolutely no error logs on the terminal. Its making debugging the issue difficult. If anyone already knows the code flow, any pointers to the bug would be appreciated. Here is the code I use:
int main(){
...
size_t buff_size = build_packet((float) i);
lRetVal = HTTPPostMethod(&httpClient, g_cpOutputBuffer, buff_size);
...
}
static size_t build_packet(float value)
{
JSON_Value *root_value = json_value_init_object();
JSON_Object *root_object = json_value_get_object(root_value);
size_t bytes;
char *serialized_string = NULL;
json_object_set_string(root_object, "name", "abc");
json_object_set_number(root_object, "voltage", value);
bytes = json_serialization_size_pretty(root_value);
g_cpOutputBuffer = (char*) malloc(bytes); //g_cpOutputBuffer is a global static char pointer
serialized_string = json_serialize_to_string_pretty(root_value);
strcpy(g_cpOutputBuffer, serialized_string);
json_free_serialized_string(serialized_string);
json_value_free(root_value);
return bytes;
}
static int HTTPPostMethod(HTTPCli_Handle httpClient, char *data, size_t length){
...
sprintf((char *) tmpBuf, "%d", length);
... //rest of the code has no modifications
lRetVal = HTTPCli_sendRequestBody(httpClient, data, length);
...
}
Here are the logs I get:
************************************************* CC3200 HTTP Client Application ************************************************* Host Driver Version: 1.0.1.11 Build Version 2.9.0.0.31.1.4.0.1.1.0.3.37 Device is configured in default state Device started as STATION [WLAN EVENT] STA Connected to the AP: ------- , BSSID: --:--:--:--:--:-- [NETAPP EVENT] IP Acquired: IP=------, Gateway=-------- Connected to the AP: --------- Connection to server created successfully HTTP Post Begin: HTTP Post End: HTTP Get Begin: HTTP Status 200 Content-Type : application/json Successfully parsed 7 JSON tokens HTTP Get End: