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_message_outbox_send(); }
void imagedownload_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 zero-byte Tuple in it (since rest of tuple is our data). uint32_t chunk_size = app_message_inbox_size_maximum() - dict_calc_buffer_size(1, 0); dict_write_int(outbox, MYQR_CHUNK_SIZE, &chunk_size, sizeof(uint32_t), false); // Send the URL dict_write_cstring(outbox, MYQR_REQUEST_CODE, url); app_message_outbox_send(); }
void send_byte_array(){ static const uint8_t data[] = {0}; const uint32_t size = dict_calc_buffer_size(1, sizeof(data)+1); // Stack-allocated buffer in which to create the Dictionary: uint8_t buffer[size]; DictionaryIterator *iter; app_message_outbox_begin(&iter); // Begin: dict_write_begin(iter, buffer, sizeof(buffer)); // Write the Data: dict_write_data(iter, XVALUE_KEY, data, sizeof(data)); const uint32_t final_size = dict_write_end(iter); app_message_outbox_send(); APP_LOG(APP_LOG_LEVEL_DEBUG, "**WATCH**: A message has been sent from pebble to the phone"); }
void connection_create() { AppMessageResult result; // make the buffer big enough to hold 2 cards (front/back) plus a result int buffer_size = dict_calc_buffer_size(5, MAX_TEXT, MAX_TEXT, MAX_TEXT, MAX_TEXT, 1); APP_LOG(APP_LOG_LEVEL_DEBUG, "buffer size=%d", buffer_size); // open the AppMessage library result = app_message_open(buffer_size, buffer_size); if (result != APP_MSG_OK) { APP_LOG(APP_LOG_LEVEL_DEBUG, "app_message_open returned %s", translate_error(result)); } // register callbacks app_message_register_inbox_received(connection_received); app_message_register_outbox_sent(connection_sent); app_message_register_outbox_failed(connection_send_failed); }
void message_init() { uint32_t size = dict_calc_buffer_size(4,sizeof(Light),sizeof(uint16_t),sizeof(Light *),sizeof(GetLightCallback)); app_message_register_inbox_received(_message_callback); app_message_open(size,size); }