Question

I have the following code that I send messages to my pebble watchapp, from the js in the phone. this is with sdk2.

Pebble.sendAppMessage({note_id:json[count].note_id,
title:json[count].title,
text:json[count].text,
total_count: count
});

I can console.log() the total_count property in the JS when I run the app, and it rightly gets the count , like 2.

Yet, in my pebble app, when I try to extract it in the in_received_handler function, the APP LOG in the code below prints out 536999434.

Tuple *total_count_tuple = dict_find(iter, TOTAL_COUNT_KEY);

if (total_count_tuple) {
    current_count = (int)total_count_tuple->value->cstring;
    APP_LOG(APP_LOG_LEVEL_DEBUG, "In in_received_handler, total count     %u",current_count);

}

It is getting a count, so I know the dictionary is being filled out and sent over to the watch, but I can't figure out how to get the value that I store in the js to be the same on the pebble side.

Any experienced pebble programmers have a thought?

Was it helpful?

Solution

You are sending an integer so to read it you need to use:

current_count = total_count_tuple->value->int32;

instead of:

current_count = (int)total_count_tuple->value->cstring;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top