我正在尝试从这里运行鹅卵石脸示例项目(它从URL下载一个图像并将其发送到监视面板)。我尝试在CloudPebble和本地C模拟器上运行这个项目。我也得到了同样的结果。我认为向javascript发送应用程序消息是有问题的。这是云鹅卵石的原木:
[DEBUG] netdownload.c:23: NetDownloadContext = 0x20020d68
[DEBUG] netdownload.c:30: Max buffer sizes are 2026 / 654
[DEBUG] pebble-faces.c:127: Done initializing, pushed window: 0x20020d7c
[DEBUG] netdownload.c:48: App message outbox sending..
[DEBUG] netdownload.c:51: App message outbox sent.
[PHONE] pebble-app.js:?: NetDownload JS Ready
[DEBUG] netdownload.c:151: Failed to send message. Reason = APP_MSG_SEND_TIMEOUT我试着做更多的调试。下面是有问题的函数:
void netdownload_request(char *url) {
DictionaryIterator *outbox;
app_message_outbox_begin(&outbox);
// Tell the javascript how big we want each chunk of data: max possible size - dictionary overhead with one Tuple in it.
uint32_t chunk_size = app_message_inbox_size_maximum() - dict_calc_buffer_size(1);
dict_write_int(outbox, NETDL_CHUNK_SIZE, &chunk_size, sizeof(uint32_t), false);
// Send the URL
dict_write_cstring(outbox, NETDL_URL, url);
APP_LOG(APP_LOG_LEVEL_DEBUG, "App message outbox sending..");
app_message_open(app_message_inbox_size_maximum(), app_message_outbox_size_maximum());
app_message_outbox_send();
APP_LOG(APP_LOG_LEVEL_DEBUG, "App message outbox sent.");
}注意:我添加了用于调试的APP_LOG和app_message_open (文档中说这样做是为了实现最佳实践)。app_message_open没有效果,问题仍然存在。
这个问题是因为我使用仿真器而发生的吗?在这个项目代码中,我没有改变任何其他的东西。
发布于 2015-06-05 05:43:06
你的问题是,JS的启动时间比应用程序要长。在JS模拟器准备好接收消息之前,消息会被发送到JS模拟器。如果你“摇动”手表(发送一个点击事件),它将再次尝试传输一个图像。
若要与模拟器交互,请单击两侧的按钮,或在屏幕上单击,然后使用按钮的箭头键。在键盘模式下,也可以按X、Y或Z表示正方向的抽头,或按shift-X、shift-Y或shift-Z表示负向的抽头。
(来源)
https://stackoverflow.com/questions/30658934
复制相似问题