Пример #1
0
 // Menu callback
 void select_menu_callback(int index, void *context) {
	app_message_outbox_begin(&iter);
	static char* select_action;
	if  (strcmp(menu_action, "c") == 0) {
		select_action = "selClient";
	} else if(strcmp(menu_action, "t") == 0) {
		select_action = "selTask";
		snprintf(task_title, 40, "Task:\n%s", list_menu_items[index].title);
		text_layer_set_text(task_layer, task_title);
	} else if (strcmp(menu_action, "p") == 0) {
		select_action = "selProj";
		snprintf(project_title, 40, "Project:\n%s", list_menu_items[index].title);
		text_layer_set_text(task_layer, project_title);
	} else {
		// strcmp failed to find a match
		APP_LOG(APP_LOG_LEVEL_DEBUG, "No match on strcmp, value of menu_action follows");
		APP_LOG(APP_LOG_LEVEL_DEBUG, menu_action);
	}
	Tuplet action_type = TupletCString(0, select_action);
	dict_write_tuplet(iter, &action_type);
	Tuplet selected = TupletInteger(1, index);
	dict_write_tuplet(iter, &selected);
	app_message_outbox_send(); // this send is causing crash :S

	//pop the menu off
	window_stack_pop(true);
 }
Пример #2
0
// Next or previous
void go_next_or_prev(uint8_t key, uint8_t cmd){
  if (current == -1 || max == -1){
    //Not all data has been received, unable to determine if you can go next/prev
    return;
  }
  if (current == 1 && cmd == BUTTON_PREVIOUS){
    //First already, cannot prev, exit
    return;
  }
  if (current == max && cmd == BUTTON_NEXT){
    //Last in list, exit
    return;
  }
  resetData();
  if (debugMode)
    APP_LOG(APP_LOG_LEVEL_INFO, "Sending data to phone");
  DictionaryIterator *iter;
  app_message_outbox_begin(&iter);
      
  Tuplet value = TupletInteger(key, cmd);
  dict_write_tuplet(iter, &value);
  
  if (current != -1){
    Tuplet page = TupletInteger(MESSAGE_CURRENT_FAV, current);
    dict_write_tuplet(iter, &page);
  }
  
  app_message_outbox_send();
}
Пример #3
0
/*
 * Tick-Handler - executes once every second using watch's internal clock.
 * Switched every other second between getting most recent temp (if desired) and checking for tripped alarm.
 */
static void tick_handler(struct tm *tick_time, TimeUnits units_changed) {
  if (tickTimerMod % 2 == 0){
      if (wantAverage && !standbyEngaged && !tripped){
        DictionaryIterator *iter;
        app_message_outbox_begin(&iter);
        int key = 0;
        // send the message "b" to the phone, using key #0
        Tuplet value = TupletCString(key, "b");
        dict_write_tuplet(iter, &value);
        app_message_outbox_send();
      }
  }
  else{
      //checks if alarm has been tripped, checks to see every 10 seconds if not
      if (tripped){
          text_layer_set_text(hello_layer, "INTRUDER ALERT!!!");
          vibes_double_pulse();
      }
      else { 
          DictionaryIterator *iter;
          app_message_outbox_begin(&iter);
          int key = 0;
          // send the message "t" to the phone, using key #0
          Tuplet value = TupletCString(key, "t");
          dict_write_tuplet(iter, &value);
          app_message_outbox_send();
      }
  }
  tickTimerMod += 1;
}
Пример #4
0
static void http_capture_send_buffer() {
	int len = 64;
	if (http_capture_sentLen+len > 18*168)
		len = 18*168 - http_capture_sentLen;
	if (len <= 0)
		return;
		
	Tuplet start = TupletInteger(0xFFF9, http_capture_sentLen);
	Tuplet buf = TupletBytes(1000, &http_capture_frameBuffer[http_capture_sentLen], len);

	DictionaryIterator *iter;
	app_message_out_get(&iter);

	if (iter == NULL)
		return;

	dict_write_tuplet(iter, &start);
	dict_write_tuplet(iter, &buf);
	dict_write_end(iter);

	http_capture_sentLen += len;

	app_message_out_send();
	app_message_out_release();	
}
Пример #5
0
static void fetch_data(void) {

  Tuplet style_tuple = TupletInteger(STYLE_KEY, 0);
  Tuplet bluetoothvibe_tuple = TupletInteger(BLUETOOTHVIBE_KEY, 0);
  Tuplet hourlyvibe_tuple = TupletInteger(HOURLYVIBE_KEY, 0);
  Tuplet blink_tuple = TupletInteger(BLINK_KEY, 0);
  Tuplet dateformat_tuple = TupletInteger(DATEFORMAT_KEY, 0);
  Tuplet units_tuple = TupletInteger(WEATHER_UNITS, 0);
  Tuplet weather_temperature_tuple = TupletInteger(WEATHER_TEMPERATURE_KEY, 0);
  Tuplet weather_icon_tuple = TupletInteger(WEATHER_ICON_KEY, 0);
  Tuplet weather_high_tuple = TupletInteger(WEATHER_TEMPERATUREHIGH_KEY, 0);
  Tuplet weather_low_tuple = TupletInteger(WEATHER_TEMPERATURELOW_KEY, 0);

  DictionaryIterator *iter;
  app_message_outbox_begin(&iter);

  if (iter == NULL) {
    return;
  }

  dict_write_tuplet(iter, &style_tuple);
  dict_write_tuplet(iter, &bluetoothvibe_tuple);
  dict_write_tuplet(iter, &hourlyvibe_tuple);
  dict_write_tuplet(iter, &units_tuple);
  dict_write_tuplet(iter, &weather_temperature_tuple);
  dict_write_tuplet(iter, &weather_icon_tuple);
  dict_write_tuplet(iter, &weather_high_tuple);
  dict_write_tuplet(iter, &weather_low_tuple);
  dict_write_tuplet(iter, &blink_tuple);
  dict_write_tuplet(iter, &dateformat_tuple);
  dict_write_end(iter);

  app_message_outbox_send();
}
Пример #6
0
/* 
 * Responds to double up button clicks. When !tripped, asks the server to put the Arduino in
 * or out of standby mode and records it. When tripped, resets the alarm on the server and Arduino.
 */
void up_double_click_handler(ClickRecognizerRef recognizer, void *context) {
  if (!tripped){
      standbyEngaged = !standbyEngaged;
      wantAverage = 0;
      //text_layer_set_text(hello_layer, "UP!");
      DictionaryIterator *iter;
      app_message_outbox_begin(&iter);
      int key = 0;
      // send the message "hello?" to the phone, using key #0
      Tuplet value = TupletCString(key, "s");
      dict_write_tuplet(iter, &value);
      app_message_outbox_send();
  }
  else {
      tripped = 0;
      //text_layer_set_text(hello_layer, "UP!");
      DictionaryIterator *iter;
      app_message_outbox_begin(&iter);
      int key = 0;
      // send the message "hello?" to the phone, using key #0
      Tuplet value = TupletCString(key, "r");
      dict_write_tuplet(iter, &value);
      app_message_outbox_send();
  }
}
Пример #7
0
static void send_cmd(void) {

	DictionaryIterator *iter;
	app_message_outbox_begin(&iter);

	if (iter == NULL) {
		return;
	}
	static char *bgptr = last_bg;
		static char *bgptr2 = last_bg_2;
	static char *timeptr = new_time;
		static char *timeptr_2 = new_time_2;

	Tuplet alertval = TupletInteger(3, 0);
	Tuplet bgVal = TupletCString(1, bgptr);
	Tuplet bgVal2 = TupletCString(4, bgptr2);
	Tuplet lastTimeVal = TupletCString(2, timeptr);
	Tuplet lastTimeVal2 = TupletCString(6, timeptr_2);


	dict_write_tuplet(iter, &alertval);
	dict_write_tuplet(iter, &bgVal);
	dict_write_tuplet(iter, &bgVal2);
	dict_write_tuplet(iter, &lastTimeVal);
	dict_write_tuplet(iter, &lastTimeVal2);

	dict_write_end(iter);

	app_message_outbox_send();

}
Пример #8
0
// Change to another client
void change_client_click(ClickRecognizerRef recognizer, Window *window) {
	app_message_outbox_begin(&iter);
	Tuplet value = TupletCString(0, "getClients");
	dict_write_tuplet(iter, &value);
	Tuplet pager = TupletInteger(1, page);
	dict_write_tuplet(iter, &pager);
	app_message_outbox_send();
}
Пример #9
0
void submit_time_to_task(ClickRecognizerRef recognizer, Window *window) {
	app_message_outbox_begin(&iter);
	Tuplet value = TupletCString(0, "postTask");
	dict_write_tuplet(iter, &value);
	Tuplet start = TupletInteger(1, start_time);
	dict_write_tuplet(iter, &start);
	Tuplet duration = TupletInteger(1, elapsed_time);
	dict_write_tuplet(iter, &duration);
	app_message_outbox_send();
}
Пример #10
0
/* Sends a request to change the units between celsius and fahrenheit */
void send_change_units_message() {
  DictionaryIterator *iter;
  app_message_outbox_begin(&iter);
  if (celsius) {
    Tuplet value = TupletCString(4, "Use celsius");
    dict_write_tuplet(iter, &value);
  } else {
    Tuplet value = TupletCString(5, "Use Fahrenheit");
    dict_write_tuplet(iter, &value);
  }
  app_message_outbox_send();
}
Пример #11
0
/*!
 @brief メッセージ送信処理。
 */
void send_message()
{
    DBG_LOG(APP_LOG_LEVEL_DEBUG, "send_message");

    DictionaryIterator *iter = NULL;
    app_message_outbox_begin(&iter);
    if (iter == NULL) {
        // 送信用イテレータの作成に失敗
        //entry_log( "error", "outbox_begin" ) ;
        DBG_LOG(APP_LOG_LEVEL_DEBUG, "send_message_error: outbox_begin");

        return;
    }

    int k = 0, v = 0;
    bool more = mq_kv_get_first(&k, &v);

    while (more) {
        if (k == KEY_PARAM_SETTING_DATE) {
            time_t timer = time(NULL);
            struct tm *local = localtime(&timer);
            char str[64];
            // ポインタにしないとTupletCStringがエラーを出す
            char *p = str;
            int year = local->tm_year + 1900;
            int month = local->tm_mon + 1;
            int day = local->tm_mday;
            int hour = local->tm_hour;
            int min = local->tm_min;
            int sec = local->tm_sec;
            // RFC 3339に合わせて変換を行う
            snprintf(str, sizeof(str), "%4d-%02d-%02dT%02d:%02d:%02d", year, month, day, hour, min, sec);
            entry_log("get setting/date", str);
            Tuplet dateTuple = TupletCString(KEY_PARAM_SETTING_DATE, p);
            dict_write_tuplet(iter, &dateTuple);
        } else {
            Tuplet tuple = TupletInteger(k, v);
            dict_write_tuplet(iter, &tuple);
        }

        more = mq_kv_get_next(&k, &v);
    }

    // データ終了
    dict_write_end(iter);
    // データ送信
    AppMessageResult res = app_message_outbox_send();
    DBG_LOG(APP_LOG_LEVEL_DEBUG, "res:%d", res);
}
Пример #12
0
static void send_cmd(void) {
	DictionaryIterator *iter;
	app_message_outbox_begin(&iter);
	
	if (iter == NULL) {
		return;
	}
	Tuplet direction = TupletCString(0, index);	
	dict_write_tuplet(iter, &direction);
	Tuplet load = TupletCString(2, "Loading...");
	dict_write_tuplet(iter, &load);
	dict_write_end(iter);
	
	app_message_outbox_send();
}
Пример #13
0
void getDetails(char *monitorId) {
	APP_LOG(APP_LOG_LEVEL_DEBUG, "Getting info for %s", monitorId);
	Tuplet get_details_tuple = TupletInteger(MONITOR_GET_DETAILS, 1);
	Tuplet monitor_id_tuple = TupletCString(MONITOR_ID, monitorId);
	DictionaryIterator *iter;
	app_message_outbox_begin(&iter);

	if (iter == NULL) {
		return;
	}

	dict_write_tuplet(iter, &get_details_tuple);
	dict_write_tuplet(iter, &monitor_id_tuple);
	dict_write_end(iter);
	app_message_outbox_send();
}
Пример #14
0
static void select_click_callback(MenuLayer *menu_layer, MenuIndex *cell_index, void *callback_context)
{
  switch(cell_index->row){
    case 0:
      finish_init();
      
      DictionaryIterator *iter;
      app_message_outbox_begin(&iter);
      char * phone_num = (char*)malloc(11 * sizeof(char));
      phone_num[0] = cont_num[0];
      phone_num[1] = cont_num[1];
      phone_num[2] = cont_num[2];
      phone_num[3] = cont_num[4];
      phone_num[4] = cont_num[5];
      phone_num[5] = cont_num[6];
      phone_num[6] = cont_num[8];
      phone_num[7] = cont_num[9];
      phone_num[8] = cont_num[10];
      phone_num[9] = cont_num[11];
      phone_num[10] = '\0';
      Tuplet value = TupletCString(1, phone_num);
      dict_write_tuplet(iter, &value);
      int number = (int)(amount * 10);
      dict_write_int(iter, 2, &number, sizeof(int), 0);
      app_message_outbox_send();
      
      break;
    case 1:
      amount = 0;
      was_back = 1;
      show_home();
      break;
  }
}
Пример #15
0
static bool  app_msg_RequestLatLong_internal(void)
{

   bool fMyRet = true;

#if TESTING_DISABLE_LOCATION_REQUEST
   return true;
#endif

   Tuplet fetch_tuple = TupletInteger(MSG_KEY_GET_LAT_LONG, 1); 

   DictionaryIterator *iter;
   AppMessageResult amRet;

   amRet = app_message_outbox_begin(&iter);

   if (amRet != APP_MSG_OK)
   {
      APP_LOG(APP_LOG_LEVEL_DEBUG, "app_message_outbox_begin failed, ret = %04X", amRet);
      return false; 
   }

   if (iter == NULL)
   {
      APP_LOG(APP_LOG_LEVEL_DEBUG, "app_message_outbox_begin returned null iter");
      return false;
   }

   DictionaryResult dRet;

   dRet = dict_write_tuplet(iter, &fetch_tuple);
   if (dRet != DICT_OK)
   {
      APP_LOG(APP_LOG_LEVEL_DEBUG, "dict_write_tuplet failed, ret = %04X", dRet);
      fMyRet = false;
      //  fall through to call end anyway
   }

   unsigned uRet;

   uRet = dict_write_end(iter);
   if (uRet == 0)
   {
      fMyRet = false;
   }

   if (fMyRet)
   {
      amRet = app_message_outbox_send();
      if (amRet != APP_MSG_OK)
      {
         APP_LOG(APP_LOG_LEVEL_DEBUG, "app_message_outbox_send failed, ret = %04X", amRet);
         fMyRet = false;
      }
   }

   return fMyRet;

}  /* end of app_msg_RequestLatLong_internal(void) */
Пример #16
0
/* This is called when the down button is clicked */
void select_click_down_handler(ClickRecognizerRef recognizer, void *context) {
  DictionaryIterator *iter;
  app_message_outbox_begin(&iter);
  int key = 0;
  Tuplet value = TupletCString(key, "tmrw");
  dict_write_tuplet(iter, &value);
  app_message_outbox_send();
}
Пример #17
0
static void notifySpark(int sparkkey) {
  Tuplet value = TupletInteger(KEY_NOTIFY,sparkkey);
  DictionaryIterator *iter;
  app_message_outbox_begin(&iter);

  dict_write_tuplet(iter,&value);
  app_message_outbox_send();
}
Пример #18
0
static void setLED(int newLEDState) {
  Tuplet value = TupletInteger(KEY_LED,newLEDState);
  DictionaryIterator *iter;
  app_message_outbox_begin(&iter);

  dict_write_tuplet(iter,&value);
  app_message_outbox_send();
}
Пример #19
0
void getListOfRoutes(char stopid[512], char stopname[512]) {
	strncpy(currentstopid, stopid, sizeof(currentstopid));
	strncpy(currentstopname, stopname, sizeof(currentstopname));
	Tuplet get_routes_tuple = TupletInteger(DOUBLEMAP_GET_ROUTES, 1);
	Tuplet stop_id_tuple = TupletCString(DOUBLEMAP_STOP_ID, stopid);
	DictionaryIterator *iter;
	app_message_outbox_begin(&iter);
	
	if (iter == NULL) {
		return;
	}
	
	dict_write_tuplet(iter, &get_routes_tuple);
	dict_write_tuplet(iter, &stop_id_tuple);
	dict_write_end(iter);
	app_message_outbox_send();
}
Пример #20
0
static void send_appmessage(char* message) {
  APP_LOG(APP_LOG_LEVEL_DEBUG, "Fetching stop time");
  DictionaryIterator *iter;
  app_message_outbox_begin(&iter);
  Tuplet value = TupletCString(ACTION, message);
  dict_write_tuplet(iter, &value);
  app_message_outbox_send();
}
Пример #21
0
void getEtas(char stopid[512], char routeid[512]) {
	Tuplet get_eta_tuple = TupletInteger(DOUBLEMAP_GET_ETA, 1);
	Tuplet stop_id_tuple = TupletCString(DOUBLEMAP_STOP_ID, stopid);
	Tuplet route_id_tuple = TupletCString(DOUBLEMAP_ROUTE_ID, routeid);
	DictionaryIterator *iter;
	app_message_outbox_begin(&iter);
	
	if (iter == NULL) {
		return;
	}
	
	dict_write_tuplet(iter, &get_eta_tuple);
	dict_write_tuplet(iter, &stop_id_tuple);
	dict_write_tuplet(iter, &route_id_tuple);
	dict_write_end(iter);
	app_message_outbox_send();
}
Пример #22
0
void select_click_handler(ClickRecognizerRef recognizer, void *context) {
   text_layer_set_text(s_time_layer, "Retrieve");
  DictionaryIterator *iter;
 app_message_outbox_begin(&iter);
Tuplet value = TupletInteger(1, 42);
 dict_write_tuplet(iter, &value);
app_message_outbox_send();
}
Пример #23
0
void send_request(char *request){
  Tuplet request_tuple = TupletCString(DATA, request);
  DictionaryIterator *iter;
  app_message_outbox_begin(&iter);
  dict_write_tuplet(iter, &request_tuple);
  dict_write_end(iter);
  app_message_outbox_send();
}
Пример #24
0
/*
 * send out msg to cell phone.
 * Param:
 * @param: msg to send out.
 */
void send_outbox(char *param) {
    DictionaryIterator *iter;
    app_message_outbox_begin(&iter);
    int key = 0;
    Tuplet value = TupletCString(key, param);
    dict_write_tuplet(iter, &value);
    app_message_outbox_send();
}
Пример #25
0
static void select_click_handler(ClickRecognizerRef recognizer, void *context) {
    DictionaryIterator *iter2;
    app_message_outbox_begin(&iter2);
    BatteryChargeState cs = battery_state_service_peek();
    Tuplet value = TupletInteger(3, cs.charge_percent);
    dict_write_tuplet(iter2, &value);
    app_message_outbox_send();
}
Пример #26
0
static void select_click_handler(ClickRecognizerRef recognizer, void *context) {
  DictionaryIterator *iter;
  app_message_outbox_begin(&iter);
  Tuplet value = TupletInteger(1, 42);
  dict_write_tuplet(iter, &value);
  app_message_outbox_send();
  text_layer_set_text(text_layer, "Select button tapped.");
}
Пример #27
0
/* 
 * Call on the phone to ring
 */
static void ring() {
  //Ring the phone
  DictionaryIterator *iter;
  app_message_outbox_begin(&iter);
  Tuplet ringTuplet = TupletInteger(RING, 2550);
  dict_write_tuplet(iter, &ringTuplet);
  app_message_outbox_send();
}
Пример #28
0
static void down_click_handler(ClickRecognizerRef recognizer, void *context) {
    DictionaryIterator *iter;
    app_message_outbox_begin(&iter);
    
    Tuplet value = TupletInteger(SELECT, STR_CHANGE_DOWN);
    dict_write_tuplet(iter, &value);
    
    app_message_outbox_send();
}
Пример #29
0
void getTL(){

    DictionaryIterator *it;
    app_message_outbox_begin(&it);
    Tuplet tuplet = TupletInteger(KEY_RESOURCE, r);
    dict_write_tuplet(it, &tuplet);
    dict_write_end(it);
    app_message_outbox_send();
}
Пример #30
0
void send_int(uint8_t key, uint8_t cmd) {
	DictionaryIterator *iter;
 	app_message_outbox_begin(&iter);

 	Tuplet value = TupletInteger(key, cmd);
 	dict_write_tuplet(iter, &value);

 	app_message_outbox_send();
}