我正在尝试从此处运行 pebble-faces 示例项目(它从 URL 下载图像并将其发送到表盘)。我尝试在 CloudPebble 和本地 C SDK 模拟器上运行该项目。我得到相同的结果。我认为将应用程序消息发送到 javascript 有问题。这是来自 cloudpebble 的日志:
[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 没有效果,问题仍然存在。
出现这个问题是因为我使用的是模拟器吗?我没有更改此项目代码中的任何其他内容..