Example #1
0
static void select_click_handler(ClickRecognizerRef recognizer, void *context) {
	int raceRoundInt = atoi(raceRoundChar);
//	APP_LOG(APP_LOG_LEVEL_DEBUG, "raceRoundChar = %s",  raceRoundChar); 
//	APP_LOG(APP_LOG_LEVEL_DEBUG, "currently round %d", raceRoundInt); 
//	APP_LOG(APP_LOG_LEVEL_DEBUG, "creating new round %d = current round+1", raceRoundInt + 1); 
	text_layer_set_text(round_layer, "getting race");
//	raceRoundInt = raceRoundInt + 1; 
		
	//int i;
	char roundRequestChar[] = "next";
	char seasonRequestChar[] = "current"; 
	//snprintf(roundRequestChar, sizeof(roundRequestChar), "%d", raceRoundInt);
//	APP_LOG(APP_LOG_LEVEL_DEBUG, "race round string = %%s %s", roundRequestChar);   
//	APP_LOG(APP_LOG_LEVEL_DEBUG, "race season string = %%s %s", seasonRequestChar);   
	//text_layer_set_text(&countLayer, buf);
	
	//Tuplet request_tuple = TupletCString(REQUEST_KEY, roundRequestChar);
//	Tuplet request_tuple; 
	DictionaryIterator *iter;
	app_message_outbox_begin(&iter);
	
	if (iter == NULL) {
		return; 
	}
	dict_write_cstring(iter, REQUEST_KEY, roundRequestChar);
	dict_write_cstring(iter, SEASON_REQUEST_KEY, seasonRequestChar); 
//	dict_write_tuplet(iter, &request_tuple); 
	dict_write_end(iter); 
	
	app_message_outbox_send(); 
	//send_message(); 
  	//fetch_msg();
}
Example #2
0
void request_weather(WeatherData *weather_data)
{
  APP_LOG(APP_LOG_LEVEL_DEBUG, "Request weather, retry: %i", retry_count);

  if (retry_count > MAX_RETRY) {
    APP_LOG(APP_LOG_LEVEL_DEBUG, "Too many retries");
    retry_count = 0;
    return;
  }

  if (!bluetooth_connection_service_peek()) {
    weather_data->error = WEATHER_E_DISCONNECTED;
    return;
  }

  DictionaryIterator *iter;
  app_message_outbox_begin(&iter);
  
  if (iter == NULL) {
    APP_LOG(APP_LOG_LEVEL_DEBUG, "Null iter");
    return;
  }

  dict_write_cstring(iter, KEY_SERVICE, weather_data->service);
  dict_write_cstring(iter, KEY_SCALE, weather_data->scale);
  dict_write_uint8(iter, KEY_DEBUG, (uint8_t)weather_data->debug);
  dict_write_uint8(iter, KEY_BATTERY, (uint8_t)weather_data->battery);

  dict_write_end(iter);

  app_message_outbox_send();
}
Example #3
0
static void app_focus_handler(bool in_focus)
{
    // Send App Message Out
    
    DictionaryIterator *iterator;
    
    if (app_message_outbox_begin(&iterator) != APP_MSG_OK)
    {
        return;
    }
    
    if (in_focus)
    {
        if (dict_write_cstring(iterator, MESSAGE_KEY, "IN FOCUS") != DICT_OK)
        {
            return;
        }
    }
    else
    {
        if (dict_write_cstring(iterator, MESSAGE_KEY, "NOT IN FOCUS") != DICT_OK)
        {
            return;
        }
    }
    
    app_message_outbox_send();
}
Example #4
0
static void send_message() {   
  APP_LOG(APP_LOG_LEVEL_DEBUG, "Got to sending message.");
  if (hint_layer) {
    text_layer_destroy(hint_layer);
    hint_layer = NULL;
  } else {
    DictionaryIterator *iter;
    app_message_outbox_begin(&iter);
    if (iter == NULL) {
      vibes_short_pulse();
      APP_LOG(APP_LOG_LEVEL_WARNING, "Can not send request to phone!");
      return;
    }
    dict_write_uint8(iter, MSG_KEY, message);
    dict_write_cstring(iter, TEXT1_KEY, s_last_text[0]);
    dict_write_cstring(iter, TEXT2_KEY, s_last_text[1]);
    dict_write_cstring(iter, TEXT3_KEY, s_last_text[2]);
    const uint32_t final_size = dict_write_end(iter);
    app_message_outbox_send();
    APP_LOG(APP_LOG_LEVEL_DEBUG, "Sent message '%d' to phone! (%d bytes)", message, (int) final_size);
    if (!hint_layer) {
      Layer *window_layer = window_get_root_layer(window);
      hint_layer = text_layer_create(hint_layer_size);
      text_layer_set_font(hint_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD));
      text_layer_set_text_alignment(hint_layer, GTextAlignmentCenter);
      layer_add_child(window_layer, text_layer_get_layer(hint_layer));
    }
    snprintf(hint_text, sizeof(hint_text), "Sent\nmessage\n'%s'",label[message-1]);
    text_layer_set_text(hint_layer, hint_text);   
  }
}
Example #5
0
static void tick_handler(struct tm *tick_time, TimeUnits units_changed) {
  static char s_uptime_buffer[32];
  vibes_short_pulse();
  alert_time--;
  if(alert_time <= 0 ){
    //TODO: write notification code
    tick_timer_service_unsubscribe();
    vibes_cancel();
    text_layer_set_text(s_alert_text_layer, "Timout Reached\n:(");
    
    // Prepare dictionary
    DictionaryIterator *iterator;
    app_message_outbox_begin(&iterator);
    
    // Write data
    char buff[100];
    if(persist_exists(PERSIST_KEY_PHONE_NUMBER)){
      persist_read_string(PERSIST_KEY_PHONE_NUMBER, buff, 100);
      dict_write_cstring(iterator, PERSIST_KEY_PHONE_NUMBER, buff);
    }
    if(persist_exists(PERSIST_KEY_NAME)){
      persist_read_string(PERSIST_KEY_NAME, buff, 100);
      dict_write_cstring(iterator, PERSIST_KEY_NAME, buff);
    }
    // Send the data!
    app_message_outbox_send();
    
  } else {
    snprintf(s_uptime_buffer, sizeof(s_uptime_buffer), BANNER_TEXT "\n" CLOCK_FORMAT_STRING, 
             alert_time/60, alert_time%60);
    text_layer_set_text(s_alert_text_layer, s_uptime_buffer);
  }
}
Example #6
0
void
write_proj_change_info (void) 
{
    status_t stat;
    int i;
    uint32_t h, m;
    char string[10];

    DictionaryIterator *iterator;

    app_message_outbox_begin(&iterator);

    for (i = 0 ; i < NUM_PROJECTS ; i++) {
	stat = persist_write_int(proj_time_val[i], (uint32_t)proj_time[i]);
	stat = persist_write_int(proj_run_val[i], (uint32_t)proj_running[i]);
	stat = persist_write_int(proj_start_val[i], (uint32_t)proj_start[i]);
	if (proj_name[i] && *proj_name[i]) {
	    stat = persist_write_string(proj_name_val[i], proj_name[i]);
	    dict_write_cstring(iterator, proj_name_val[i], proj_name[i]);
	} else {
	    stat = persist_write_string(proj_name_val[i], "");
	    dict_write_cstring(iterator, proj_name_val[i], proj_name[i]);
	}
	app_log(APP_LOG_LEVEL_WARNING,
		__FILE__,
		__LINE__,
		"Proj %d time info written as %d:%d", i, hours(proj_time[i]), minutes(proj_time[i]));
	h = (uint32_t)hours(proj_time[i]);
	stat = persist_write_int(proj_hour_val[i], h);
	m = (uint32_t)minutes(proj_time[i]);
	stat = persist_write_int(proj_min_val[i], m);

	snprintf(string, sizeof(string), "%u", (uint)h);
	dict_write_cstring(iterator, proj_hour_val[i], string);

	snprintf(string, sizeof(string), "%u", (uint)m);
	dict_write_cstring(iterator, proj_min_val[i], string);
    }

    app_log(APP_LOG_LEVEL_WARNING,
            __FILE__,
            __LINE__,
            "Writing autostop as %d", (int)autostop);
    stat = persist_write_int(AUTOSTOP, (uint32_t)autostop);
    snprintf(string, sizeof(string), "%u", (uint)autostop);
    dict_write_cstring(iterator, AUTOSTOP, string);

    app_message_outbox_send();

    if (bluetooth_connected == true && stat == 4) {
	proj_change_written = true;
    } else {
	app_log(APP_LOG_LEVEL_WARNING,
		__FILE__,
		__LINE__,
		"Proj time info written");
	proj_change_written = false;
    }
}
Example #7
0
void send_int(char* key, char* cmd)
{
  DictionaryIterator* dictionaryIterator = NULL;
  app_message_outbox_begin (&dictionaryIterator);
  dict_write_cstring (dictionaryIterator, STATUS_KEY, key);
  dict_write_cstring (dictionaryIterator, MESSAGE_KEY, cmd);
  dict_write_end (dictionaryIterator);
  app_message_outbox_send();
}
Example #8
0
// Here we capture when a user selects a menu item
void menu_select_callback(MenuLayer *menu_layer, MenuIndex *cell_index, void *data) {
	
	// Use the row to specify which item will receive the select action
	ControlButton* pushedButton = &menuSets[cell_index->section].menu[cell_index->row];
	
	if (pushedButton->action == REMOTE_ACTION)
	{
		DictionaryIterator *iter;
		if (app_message_outbox_begin(&iter) != APP_MSG_OK) {
			//return;
		}
		
		if (!didSendAddress)
		{
			if (dict_write_cstring(iter, DICT_ADDRESS, address) != DICT_OK) {
			//return;
			}
			
			if (dict_write_cstring(iter, DICT_PAIR_CODE, pairCode) != DICT_OK) {
				//return;
			}
			
			didSendAddress = true;
		}
		
		if (dict_write_cstring(iter, COMMAND, pushedButton->action) != DICT_OK) {
			//return;
		}
		
		if (dict_write_cstring(iter, DATA, pushedButton->data) != DICT_OK) {
			//return;
		}
		
		dict_write_end(iter);
		app_message_outbox_send();
	}

	if (pushedButton->action == DISPLAY_IP)
	{
		// Update subtitle to show IP
		pushedButton->subtitle = address;
		menu_layer_reload_data(menu_layer);
	}
	
	if (pushedButton->action == DISPLAY_PAIR_CODE)
	{
		// Update subtitle to show Pair code
		pushedButton->subtitle = pairCode;
		menu_layer_reload_data(menu_layer);
	}
	
	if (pushedButton->action == SYNC_ACTION)
	{
		didSendAddress = false;
	}
}
Example #9
0
static void get_weather() {
    DictionaryIterator *iter;
    app_message_outbox_begin(&iter);
    dict_write_uint8(iter, JS_KEY_IS_MINUTELY, settings.is_minutely);
    dict_write_cstring(iter, JS_KEY_API_KEY, settings.api_key);
    app_message_outbox_send();
}
Example #10
0
static int request_next_habit(struct NetworkState *state)
{
    int rval = 0;
    abort_if(!state, "state is null");

    if(state->habit_current >= state->habit_count)
        goto CLEANUP;

    DictionaryIterator *dict;
    rval = app_message_outbox_begin(&dict);
    abort_if(rval, "app_message_outbox_begin failed");

    rval = dict_write_cstring(dict, 0, "FETCH");
    abort_if(rval, "dict_write_cstring failed");

    rval = dict_write_int32(dict, 1, state->habit_current);
    abort_if(rval, "dict_write_cstring failed");

    rval = app_message_outbox_send();
    abort_if(rval, "app_message_outbox_send failed");

    state->habit_current++;

CLEANUP:
    return rval;
}
Example #11
0
// Data Request
// Params- char*:request (location/update/lastStopRequest)
static void requestData(char *request) {
    time(&lastUpdate);
    DictionaryIterator *iter;
    app_message_outbox_begin(&iter);
    dict_write_cstring(iter, 45, request);
    app_message_outbox_send();
}
static void select_click_callback(MenuLayer *menu_layer, MenuIndex *cell_index, void *callback_context) {
  APP_LOG(APP_LOG_LEVEL_DEBUG, "Got a click for row %d", cell_index->row);
  if (hint_layer) {
    text_layer_destroy(hint_layer);
    hint_layer = NULL;
  }
  if (cell_index->row > 0) {
    app_timer_reschedule(locationtimer, 1000 * (nextcall + 10));
    if (cell_index->row == 1) {
      strcpy(command, "set");
    text_layer_set_text(distance_layer, "0");
    } else
      snprintf(command, sizeof(command), "set%d", (cell_index->row)-2);
    DictionaryIterator *iter;
    app_message_outbox_begin(&iter);
    if (iter == NULL) {
      vibes_short_pulse();
      APP_LOG(APP_LOG_LEVEL_WARNING, "Can not send command %s to phone!", command);
      return;
    }
    dict_write_cstring(iter, CMD_KEY, command);
    const uint32_t final_size = dict_write_end(iter);
    app_message_outbox_send();
    APP_LOG(APP_LOG_LEVEL_DEBUG, "Sent command '%s' to phone! (%d bytes)", command, (int) final_size);
  }
  window_stack_pop(animated);
}
static void pin_set_handler(ClickRecognizerRef recognizer, void *context) {
  APP_LOG(APP_LOG_LEVEL_DEBUG, "Pin set");
  if (hint_layer) {
    text_layer_destroy(hint_layer);
    hint_layer = NULL;
  } 
  else {
    app_timer_reschedule(locationtimer, 1000 * (nextcall + 10));
    strcpy(command, "pin");
    DictionaryIterator *iter;
    app_message_outbox_begin(&iter);
    if (iter == NULL) {
      vibes_short_pulse();
      APP_LOG(APP_LOG_LEVEL_WARNING, "Can not send command %s to phone!", command);
      return;
    }
    dict_write_cstring(iter, CMD_KEY, command);
    const uint32_t final_size = dict_write_end(iter);
    app_message_outbox_send();
    APP_LOG(APP_LOG_LEVEL_DEBUG, "Sent command '%s' to phone! (%d bytes)", command, (int) final_size);
    if (!hint_layer) {
      Layer *window_layer = window_get_root_layer(window);
      hint_layer = text_layer_create(hint_layer_size);
      text_layer_set_font(hint_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD));
      text_layer_set_text_alignment(hint_layer, GTextAlignmentCenter);
      layer_add_child(window_layer, text_layer_get_layer(hint_layer));
    }
    text_layer_set_text(hint_layer, "\nSetting\ntimeline\npin...");
  }
}
Example #14
0
void messsages_open_send() {
  // first register callbacks
  app_message_register_inbox_received(messages_inbox_received);
  app_message_register_inbox_dropped(messages_inbox_dropped);
  app_message_register_outbox_sent(messages_outbox_sent);
  app_message_register_outbox_failed(messages_outbox_failed);
  
  if (app_message_open(APP_MESSAGE_INBOX_SIZE_MINIMUM, APP_MESSAGE_OUTBOX_SIZE_MINIMUM) != APP_MSG_OK) {
    APP_LOG(APP_LOG_LEVEL_ERROR, "Open Message Failed");
    return;
  }
  DictionaryIterator* dic_iterator;
  if (app_message_outbox_begin(&dic_iterator) != APP_MSG_OK) {
    APP_LOG(APP_LOG_LEVEL_ERROR, "Begin Message Outbox Failed");
    return;
  }
  char buffer[50];
  time_t now;
  time(&now);
  strftime(buffer, sizeof(buffer),"P: %H:%M %S", localtime(&now));
  // write some data
  dict_write_cstring(dic_iterator, 1, buffer);
  dict_write_end(dic_iterator);
  // send
  app_message_outbox_send();
  APP_LOG(APP_LOG_LEVEL_INFO,"Message %s sent",buffer);
}
Example #15
0
HTTPResult http_out_get(const char* url, bool use_post, int32_t cookie, DictionaryIterator **iter_out) {
	AppMessageResult app_result = app_message_out_get(iter_out);
	if(app_result != APP_MSG_OK) {
		return app_result;
	}
	DictionaryResult dict_result = dict_write_cstring(*iter_out, HTTP_URL_KEY, url);
	if(dict_result != DICT_OK) {
		return dict_result << 12;
	}
	dict_result = dict_write_int32(*iter_out, HTTP_COOKIE_KEY, cookie);
	if(dict_result != DICT_OK) {
		return dict_result << 12;
	}
	dict_result = dict_write_int32(*iter_out, HTTP_APP_ID_KEY, our_app_id);
	if(dict_result != DICT_OK) {
		return dict_result << 12;
	}
	if(!use_post) {
		dict_result = dict_write_int8(*iter_out, HTTP_USE_GET_KEY, 1);
		if(dict_result != DICT_OK) {
			return dict_result << 12;
		}
	}
	return HTTP_OK;
}
Example #16
0
static void send_settings_to_phone() {
  if (!JS_ready) return;
  DictionaryIterator *iter;
  app_message_outbox_begin(&iter);
  int dummy_int;
  
  dict_write_cstring(iter, KEY_APP_VERSION, app_version);
  dummy_int=CURRENT_STORAGE_VERSION; dict_write_int(iter, KEY_VERSION, &dummy_int, sizeof(int), true);
  dummy_int=data_timestamp;          dict_write_int(iter, KEY_TIMESTAMP, &dummy_int, sizeof(int), true);
  dummy_int=settings.Show_clock;     dict_write_int(iter, KEY_SHOW_CLOCK, &dummy_int, sizeof(int), true);
  dummy_int=settings.Auto_sort;      dict_write_int(iter, KEY_AUTO_SORT, &dummy_int, sizeof(int), true);
  dummy_int=settings.Hrs_day_x10;    dict_write_int(iter, KEY_HRS_PER_DAY, &dummy_int, sizeof(int), true);
  dummy_int=settings.Last_reset;     dict_write_int(iter, KEY_LAST_RESET, &dummy_int, sizeof(int), true);
  
  if (timer.Active) dict_write_data(iter, KEY_TIMER, (void*) &timer, sizeof(timer));
  jobs_list_write_dict(iter, KEY_JOBS);

  if (export_after_save) {
    dummy_int=true;
    dict_write_int(iter, KEY_EXPORT, &dummy_int, sizeof(int), true);
    export_after_save=false;
  }
  
  dict_write_end(iter);
  LOG("sending outbox...");
  app_message_outbox_send();
}
Example #17
0
static void sendString(int key, const char *value) {
  DictionaryIterator *iter;
  app_message_outbox_begin(&iter);

  dict_write_cstring(iter, key, value);

  app_message_outbox_send();
}
Example #18
0
static void sendMessage(char *last_text){
  DictionaryIterator* dictionaryIterator = NULL;
  app_message_outbox_begin(&dictionaryIterator);
  dict_write_cstring(dictionaryIterator,0,last_text);
  dict_write_end(dictionaryIterator);
  AppMessageResult result = app_message_outbox_send();
  APP_LOG(APP_LOG_LEVEL_INFO, "Send resut: %d", (int)result);
}
static void select_single_click_handler(ClickRecognizerRef recognizer, void *window) {
	// App Messages can be sent while using Pebble Autoconfig
	DictionaryIterator *iter;
	app_message_outbox_begin(&iter);
	dict_write_cstring(iter, PING_KEY, "Knock, knock!");
	dict_write_end(iter);
  	app_message_outbox_send();
}
Example #20
0
static void get_contact() {
  DictionaryIterator *iter;
  app_message_outbox_begin(&iter);
  dict_write_cstring(iter, DICTATED_NAME_KEY, dictated_name);
  dict_write_int(iter, STATE_KEY, &s_state, 1, 0);
  dict_write_int(iter, ATTEMPT_NUMBER_KEY, &contact_try, 1, 0);
  app_message_outbox_send();
}
Example #21
0
static void up_click_handler(ClickRecognizerRef recognizer, void *context) {
	int raceRoundInt = atoi(raceRoundChar);
	int seasonInt = atoi(seasonChar); 
//	APP_LOG(APP_LOG_LEVEL_DEBUG, "raceRoundChar = %s",  raceRoundChar); 
//	APP_LOG(APP_LOG_LEVEL_DEBUG, "seasonChar = %s",  seasonChar); 
//	APP_LOG(APP_LOG_LEVEL_DEBUG, "currently round %d", raceRoundInt); 
//	APP_LOG(APP_LOG_LEVEL_DEBUG, "creating new round %d = current round - 1", raceRoundInt - 1); 
//	APP_LOG(APP_LOG_LEVEL_DEBUG, "season is %s, sending to URL, check URL receipt", seasonChar); 
	text_layer_set_text(round_layer, "getting race");
	raceRoundInt = raceRoundInt - 1; 
	
	if (raceRoundInt == 0) {
//	APP_LOG(APP_LOG_LEVEL_DEBUG, "raceRoundInt = %d", raceRoundInt); 
//	seasonInt = seasonInt - 1; 
	raceRoundInt = 10;
	seasonInt = seasonInt - 1; 
	APP_LOG(APP_LOG_LEVEL_DEBUG, "round = %d", raceRoundInt); 		
	APP_LOG(APP_LOG_LEVEL_DEBUG, "season = %d", seasonInt); 		
	}
		
	//int i;
	char roundRequestChar[] = "123456";
	char seasonRequestChar[] = "123456"; 
	snprintf(roundRequestChar, sizeof(roundRequestChar), "%d", raceRoundInt);
	snprintf(seasonRequestChar, sizeof(seasonRequestChar), "%d", seasonInt);
	APP_LOG(APP_LOG_LEVEL_DEBUG, "race request string = %%s %s", roundRequestChar);   
	APP_LOG(APP_LOG_LEVEL_DEBUG, "season request string = %%s %s", seasonRequestChar);   
	//text_layer_set_text(&countLayer, buf);
	
	//Tuplet request_tuple = TupletCString(REQUEST_KEY, roundRequestChar);
//	Tuplet request_tuple; 
	DictionaryIterator *iter;
	app_message_outbox_begin(&iter);
	
	if (iter == NULL) {
		return; 
	}
	dict_write_cstring(iter, REQUEST_KEY, roundRequestChar);
	dict_write_cstring(iter, SEASON_REQUEST_KEY, seasonRequestChar); 
//	dict_write_tuplet(iter, &request_tuple); 
	dict_write_end(iter); 
	
	app_message_outbox_send(); 
	//send_message(); 
  	//fetch_msg();
}
Example #22
0
// Write message to buffer & send
void send_message(const char *letter){
	DictionaryIterator *iter;
	
	app_message_outbox_begin(&iter);
	dict_write_cstring(iter, 0, letter);
	
	dict_write_end(iter);
  	app_message_outbox_send();
}
Example #23
0
void whatsapp_send_message(conversation_t *conv, const char *message)
{
	DictionaryIterator *iter;
	app_message_outbox_begin(&iter);
	if (iter == NULL)
		return;
	
	dict_write_uint8(iter, KEY_ACTION, (uint8_t) ACTION_WHATSAPP_SEND_MESSAGE);
	dict_write_cstring(iter, KEY_NUMBER, conv->number);
	dict_write_cstring(iter, KEY_MESSAGE, message);
	dict_write_end(iter);
	
	// HACK
	//app_comm_set_sniff_interval(SNIFF_INTERVAL_REDUCED);
	//app_comm_set_sniff_interval(SNIFF_INTERVAL_NORMAL);
	
	app_message_outbox_send();
}
Example #24
0
static void handle_message(char *ifttt_message) {
  DictionaryIterator *iter;
  app_message_outbox_begin(&iter);

  dict_write_cstring(iter, 0, ifttt_message);

  APP_LOG(APP_LOG_LEVEL_INFO, "got message");
  app_message_outbox_send();  
}
Example #25
0
void connection_send_result(bool wasRight) {
    AppMessageResult result;
    DictionaryIterator *iter;
    result = app_message_outbox_begin(&iter);
    if (result != APP_MSG_OK) {
        APP_LOG(APP_LOG_LEVEL_ERROR, "app_message_outbox_begin returned %s", translate_error(result)); 
        return;
    }
    
    dict_write_cstring(iter, FLASH_KEY_FRONT, cards[0].front);
    dict_write_cstring(iter, FLASH_KEY_BACK, cards[0].back);
    dict_write_uint8(iter, FLASH_KEY_RESULT, (uint8_t) wasRight);
    
    result = app_message_outbox_send();
    if (result != APP_MSG_OK) {
        APP_LOG(APP_LOG_LEVEL_ERROR, "app_message_outbox_send returned %s", translate_error(result));
    }
}
Example #26
0
void validate_ip() {
    snprintf(ip_as_text, sizeof(ip_as_text), "%d.%d.%d.%d", speaker_ip[0],speaker_ip[1],speaker_ip[2],speaker_ip[3]);
    DictionaryIterator *iter;
    app_message_outbox_begin(&iter);
    dict_write_cstring(iter, KEY_IP_ADDRESS, ip_as_text);
    dict_write_uint8(iter, KEY_CMD_EXECUTED, CMD_VALIDATE_IP);
    dict_write_end(iter);
    app_message_outbox_send();
}
Example #27
0
static void inbox_received_callback(DictionaryIterator *iterator, void *context) {
  dict_write_begin(&items_iter, items_buffer, ITEMS_BUFFER_SIZE);
  Tuple *t = dict_read_first(iterator);
  while(t != NULL) {
    dict_write_cstring(&items_iter, (int) t->key, (char*) t->value->cstring);
    t = dict_read_next(iterator);
  }
  int items_size = dict_write_end(&items_iter);
  load_menu();
}
Example #28
0
// Write message to buffer & send
void send_message(void){
	DictionaryIterator *iter;

	app_message_outbox_begin(&iter);
	dict_write_uint8(iter, STATUS_KEY, 0x1);
	dict_write_cstring(iter, MESSAGE_KEY, "Hi Phone, I'm a Pebble!");
    
	dict_write_end(iter);
  	app_message_outbox_send();
}
Example #29
0
void http_get(char *url) {
    if (current_url) free(current_url);
    current_url = malloc(strlen(url) + 1);
    strcpy(current_url, url);
    DictionaryIterator *dict;
    app_message_outbox_begin(&dict);
    dict_write_cstring(dict, URL_KEY, current_url);
    dict_write_end(dict);
    app_message_outbox_send();
}
Example #30
0
static void send_final_message() {
  DictionaryIterator *iter;
  app_message_outbox_begin(&iter);
  dict_write_cstring(iter, CONTACT_NAME_KEY, contact_name);
  dict_write_cstring(iter, CONTACT_NUMBER_KEY, contact_number);
  // APP_LOG(APP_LOG_LEVEL_INFO, "contact id %s", contact_id);
  dict_write_cstring(iter, CONTACT_ID_KEY, contact_id);
  DictionaryResult res = dict_write_cstring(iter, FINAL_MESSAGE_KEY, dictated_message);
  if (res == DICT_OK) {
    // APP_LOG(APP_LOG_LEVEL_INFO, "added");
  }
  if (res == DICT_NOT_ENOUGH_STORAGE) {
    APP_LOG(APP_LOG_LEVEL_INFO, "not enough storage");
  }
  if (res == DICT_INVALID_ARGS) {
    APP_LOG(APP_LOG_LEVEL_INFO, "invalid args");
  }
  dict_write_int(iter, STATE_KEY, &s_state, 1, 0);
  app_message_outbox_send();
}