AppMessage始终因APP_MSG_SEND_TIMEOUT而失败

时间:2014-04-09 22:32:33

标签: javascript c pebble-watch pebble-sdk

我试图从我的Pebble向JS应用程序发送一条简单的消息,但总是失败,错误代码为APP_MSG_SEND_TIMEOUT。然而,从JS向设备发送消息就像一个魅力。这是我的代码:

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

我可能错过了一些简单的事情,但我无法理解我的生活。

1 个答案:

答案 0 :(得分:1)

我猜你自己解决了问题,但在此处省略了。

这是手表和手机之间的计时问题。

如果你延迟发送到应用程序的后期,一旦所有内容都已加载并且#34;已经安定下来",它将按照本书的规定运行。

pebble SDK论坛

上查看我的帖子