I'm trying to send a simple message from my Pebble to a JS app, but it always fails with the error code APP_MSG_SEND_TIMEOUT. Sending a message from JS to the device, however, works like a charm. Here's my code:
app_message_register_inbox_received(in_received_handler);
app_message_register_inbox_dropped(in_dropped_handler);
app_message_register_outbox_sent(out_sent_handler);
app_message_register_outbox_failed(out_failed_handler);
const uint32_t inbound_size = 512;
const uint32_t outbound_size = 512;
app_message_open(inbound_size, outbound_size);
// some UI things...
DictionaryIterator *iter;
app_message_outbox_begin(&iter);
if(iter == NULL)
APP_LOG(APP_LOG_LEVEL_DEBUG, "null iter");
Tuplet value = TupletInteger(0, 42);
dict_write_tuplet(iter, &value);
dict_write_end(iter);
app_message_outbox_send();
All of my handlers contain only a few lines of logging code. My JS is:
Pebble.addEventListener("ready",
function(e) {
console.log("JavaScript app ready and running!");
Pebble.sendAppMessage({"0": 42, "1": "hello"}, function(e) {
console.log("success");
}, function(e) {
console.log("fail");
});
}
);
Pebble.addEventListener("appmessage", function(e) {
console.log("received message: " + e.payload);
});
Finally, my log output is this:
[PHONE] pebble-app.js:?: {'runhost client uuid' = 00000000-0000-0000-0000-000000000000}:{'webapp uuid' = 00e9f277-489d-4c97-87ba-22659062bf12}: ++_JS_LIFECYCLE_++:LAUNCHING
[PHONE] pebble-app.js:?: {'runhost client uuid' = 00000000-0000-0000-0000-000000000000}:{'webapp uuid' = 00e9f277-489d-4c97-87ba-22659062bf12}: ++_JS_LIFECYCLE_++:LAUNCHING
[PHONE] pebble-app.js:?: CTwitch__1/pebble-js-app.js:3 JavaScript app ready and running!
[PHONE] pebble-app.js:?: {'runhost client uuid' = 833ceb3c-9bf6-40e5-a14d-48c401515ca2}:{'webapp uuid' = 00e9f277-489d-4c97-87ba-22659062bf12}: ++_JS_LIFECYCLE_++:READY-RUNNING
[DEBUG] hello_world.c:15: Got message!
[PHONE] pebble-app.js:?: CTwitch__1/pebble-js-app.js:5 success
[ERROR] hello_world.c:71: Outbox failed!
[ERROR] hello_world.c:72: APP_MSG_SEND_TIMEOUT
I'm probably missing something simple, but I can't figure it out for the life of me.