gpt4 book ai didi

javascript - AppMessage 总是失败并显示 APP_MSG_SEND_TIMEOUT

转载 作者:行者123 更新时间:2023-11-30 15:35:19 25 4
gpt4 key购买 nike

我尝试从 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

我可能错过了一些简单的东西,但我一生都无法弄清楚。

最佳答案

我猜您自己已经找到了答案,但省略了将其发布在这里。

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

如果您在应用程序中将发送延迟到稍后,一旦所有内容都加载并“安定下来”,它就会按照书中的方式工作。

请参阅我在 pebble SDK 上的帖子论坛

关于javascript - AppMessage 总是失败并显示 APP_MSG_SEND_TIMEOUT,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22975216/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com