Debug tool request

Posts: 14
Joined: Wed Dec 03, 2014 10:29 pm

Debug tool request

Postby ScottR » Mon Mar 02, 2015 12:47 pm

Forgive me if this question is a basic one, but can you please suggest how to get more information displayed in the UART messages about the POST and GET requests?

The IoT_Demo code currently prints "We have a POST request.", or "We have a GET request". It would be very useful for debugging if it would also print the parsed JSON data to help make sure the JSON commands in the POST / GET are being received and interpreted properly.


Posts: 8
Joined: Fri Feb 20, 2015 6:25 am

Re: Debug tool request

Postby Thorvald » Mon Mar 02, 2015 4:43 pm

hi Scott

I ran into the same problem, but solved it by adding some printstatement, where the JSON is parsed

Like in this statement

LOCAL struct jsontree_callback status_callback = JSONTREE_CALLBACK(status_get, status_set);

Where the first parameter is used when GETting your values and setting it into the JSON-variable, and the second is SETting your variables from values in the JSON-variable.

ANd then in the status-set function adding

* FunctionName : status_set
* Description : parse the device status parmer as a JSON format
* Parameters : js_ctx -- A pointer to a JSON set up
* parser -- A pointer to a JSON parser state
* Returns : result
status_set(struct jsontree_context *js_ctx, struct jsonparse_state *parser)
int type;

while ((type = jsonparse_next(parser)) != 0) {
if (type == JSON_TYPE_PAIR_NAME) {
if (jsonparse_strcmp_value(parser, "status") == 0) {
uint8 status;
status = jsonparse_get_value_as_int(parser);
os_printf("status: %d\n", status);

return 0;

Best regards

Who is online

Users browsing this forum: Bing [Bot] and 15 guests