I am trying to run the pebble-faces example project from here (it downloads an image from URL and sends it to the watch face). I tried running the project on CloudPebble and the local C SDK emulator. I get the same result. I believe there is something wrong with sending the app message to the javascript. Here is the log from 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
I tried doing more debugging. Here is the function that is having problems:
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.");
}
Note: I added the APP_LOG for debugging, and app_message_open (documentation says to do this for best practice). The app_message_open had no effect and the problem still persists.
Is this problem occurring because I am using emulators? I haven't changed anything else in this projects code..
Your problem is that the JS is taking longer than the app to start. The message is sent to the JS simulator before it's ready to receive it. If you "shake" the watch (send a tap event), it will try again to transfer an image.
(Source)