0
我试图从我的Pebble发送一个简单的消息到一个JS应用程序,但它总是失败,错误代码为APP_MSG_SEND_TIMEOUT。然而,从JS向设备发送消息就像一个魅力。这里是我的代码:AppMessage总是失败,APP_MSG_SEND_TIMEOUT
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();
我所有的处理程序只包含几行日志代码。我的JS是:
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);
});
最后,我的日志输出是这样的:
[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
我可能失去了一些东西简单,但我无法弄清楚了我的生活。
后,你可以发布在GitHub上的代码和共享,所以我们可以尝试?你在做什么看起来不错。 – sarfata
刚发布,它在这里:https://github.com/shawnwalton/twitch –