static MMI_PROTOCOL_FZD_RECEIVE_SPACE_STRUCT s_receive_space_struct = {0};
-static bool mmi_protocol_fzd_request_without_data(MMI_PROTOCOL_FZD_ACTION_ENUM action);
-static bool mmi_protocol_fzd_respond_without_data(MMI_PROTOCOL_FZD_ACTION_ENUM action);
+static bool mmi_protocol_fzd_send_without_data(MMI_PROTOCOL_FZD_ACTION_ENUM action);
+static bool mmi_protocol_fzd_send_with_data(MMI_PROTOCOL_FZD_ACTION_ENUM action, unsigned char * content_buff, int content_lenth);
static unsigned char * mmi_protocol_fzd_action_string_get(MMI_PROTOCOL_FZD_ACTION_ENUM action);
static bool mmi_protocol_fzd_content_parse(unsigned char * content_ptr, unsigned int content_length);
}
// [MD5_DATADEVICE_NAME*DEVICE_ID*CONTENT_LEN*ACTION_STRING,ACTION_CONTENT]
-bool mmi_protocol_fzd_send_content_construct(MMI_PROTOCOL_FZD_ACTION_ENUM action, unsigned char * content_ptr, int content_len)
+static bool mmi_protocol_fzd_send_content_construct(MMI_PROTOCOL_FZD_ACTION_ENUM action, unsigned char * content_ptr, int content_len)
{
unsigned char * send_space_ptr = NULL;
int send_space_size = 0, curr_offset = 0;
}
}
-static bool mmi_protocol_fzd_request_without_data(MMI_PROTOCOL_FZD_ACTION_ENUM action)
+static bool mmi_protocol_fzd_send_without_data(MMI_PROTOCOL_FZD_ACTION_ENUM action)
{
bool result = false;
unsigned char content_buff = NULL;
return result;
}
-static bool mmi_protocol_fzd_respond_without_data(MMI_PROTOCOL_FZD_ACTION_ENUM action)
+static bool mmi_protocol_fzd_send_with_data(MMI_PROTOCOL_FZD_ACTION_ENUM action, unsigned char * content_buff, int content_lenth)
{
bool result = false;
- unsigned char * content_buff = NULL;
- unsigned int content_lenth = 0;
result = mmi_protocol_fzd_send_content_construct(action, content_buff, content_lenth);
{MMI_FZD_ACTION_GET_WEATHER, "WT"}, //
{MMI_FZD_SERVER_SET_SOS_NUMBER, "SOS"}, //
{MMI_FZD_SERVER_SET_CENTER_NUMBER, "CENTER"}, //
-
+ {MMI_FZD_ACTION_UNBIND, "DLT"},
/*******add before this line*******/
mmi_protocol_fzd_parse_SERVER_SET_CENTER_NUMBER(next_buff, next_buff_len);
break;
+ case MMI_FZD_ACTION_UNBIND:
+ break;
default:
unsigned char * content_buff = NULL;
unsigned int content_lenth = 0;
hal_rtc_t cur_time = {0};
- int step_num = 0;
+ int step_num = asl_pedometer_steps_get();
int roll_num = 0;
int battery_percent = Hal_Battery_Get_Status();
sprintf(content_buff, ",%02d%02d%02d,%u,%u,%u", cur_time.tm_year%2000, cur_time.tm_mon, cur_time.tm_mday, step_num, roll_num, battery_percent);
content_lenth = strlen(content_buff);
- result = mmi_protocol_fzd_send_content_construct(action, content_buff, content_lenth);
+ result = mmi_protocol_fzd_send_with_data(action, content_buff, content_lenth);
lv_mem_free(content_buff);
return result;
bool mmi_protocol_fzd_action_bind(void)
{
- return mmi_protocol_fzd_request_without_data(MMI_FZD_ACTION_BIND);
+ return mmi_protocol_fzd_send_without_data(MMI_FZD_ACTION_BIND);
}
bool mmi_protocol_fzd_parse_ACTION_BIND(unsigned char * next_buff, unsigned int next_buff_len)
bool mmi_protocol_fzd_action_get_time(void)
{
- return mmi_protocol_fzd_request_without_data(MMI_FZD_ACTION_GET_TIME);
+ return mmi_protocol_fzd_send_without_data(MMI_FZD_ACTION_GET_TIME);
}
//[XX*YYYY*001D*LGZONE,+8,08:00:00,2016-01-12]
MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_SERVER_GET_CUR_LOCATION;
result = true;
- mmi_protocol_fzd_respond_without_data(action);
+ mmi_protocol_fzd_send_without_data(action);
mmi_watch_location_mission_current_location_action();
}
result = true;
- mmi_protocol_fzd_respond_without_data(action);
+ mmi_protocol_fzd_send_without_data(action);
uint32_t value = atoi(next_buff);
MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_SERVER_SET_FACTORY;
result = true;
- mmi_protocol_fzd_respond_without_data(action);
- uos_sleep(10);
+ mmi_protocol_fzd_send_without_data(action);
+ //uos_sleep(10);
mmi_watch_reset(NULL);
return result;
MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_SERVER_SET_POWEROFF;
result = true;
- mmi_protocol_fzd_respond_without_data(action);
+ mmi_protocol_fzd_send_without_data(action);
uos_sleep(10);
mmi_watch_power_off();
MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_SERVER_FIND_WATCH;
result = true;
- mmi_protocol_fzd_respond_without_data(action);
+ mmi_protocol_fzd_send_without_data(action);
mmi_watch_server_search_screen_create(NULL);
//sprintf(content_buff, ",%s", temp_value);
content_lenth = strlen(content_buff);
- result = mmi_protocol_fzd_send_content_construct(action, content_buff, content_lenth);
+ result = mmi_protocol_fzd_send_with_data(action, content_buff, content_lenth);
return result;
}
}
result = true;
- mmi_protocol_fzd_respond_without_data(action);
+ mmi_protocol_fzd_send_without_data(action);
app_adaptor_contact_t server_set_contact[NV_WATCH_MAX_CONTACT_NUM] = {0};
char * temp_ptr = NULL;
}
result = true;
- mmi_protocol_fzd_respond_without_data(action);
+ mmi_protocol_fzd_send_without_data(action);
uos_sleep(10);
char * number = (char *)lv_mem_alloc(next_buff_len + 1);
}
result = true;
- mmi_protocol_fzd_respond_without_data(action);
+ mmi_protocol_fzd_send_without_data(action);
app_adaptor_alarm_t server_set_alarm[NV_ALARM_MAX_ALARM_NUM] = {0};
char * group_str = NULL;
sprintf(content_buff, ",%s", data_str);
content_lenth = strlen(content_buff);
- result = mmi_protocol_fzd_send_content_construct(action, content_buff, content_lenth);
+ result = mmi_protocol_fzd_send_with_data(action, content_buff, content_lenth);
return result;
}
sprintf(content_buff, ",%d", heart_value);
content_lenth = strlen(content_buff);
- result = mmi_protocol_fzd_send_content_construct(action, content_buff, content_lenth);
+ result = mmi_protocol_fzd_send_with_data(action, content_buff, content_lenth);
return result;
}
sprintf(content_buff, ",%d,%d", blood_high_value, blood_low_value);
content_lenth = strlen(content_buff);
- result = mmi_protocol_fzd_send_content_construct(action, content_buff, content_lenth);
+ result = mmi_protocol_fzd_send_with_data(action, content_buff, content_lenth);
return result;
}
sprintf(content_buff, ",%d", spo2_value);
content_lenth = strlen(content_buff);
- result = mmi_protocol_fzd_send_content_construct(action, content_buff, content_lenth);
+ result = mmi_protocol_fzd_send_with_data(action, content_buff, content_lenth);
return result;
}
}
result = true;
- mmi_protocol_fzd_respond_without_data(action);
+ mmi_protocol_fzd_send_without_data(action);
int value_interval = atoi(next_buff);
}
result = true;
- mmi_protocol_fzd_respond_without_data(action);
+ mmi_protocol_fzd_send_without_data(action);
int value_interval = atoi(next_buff);
}
result = true;
- mmi_protocol_fzd_respond_without_data(action);
+ mmi_protocol_fzd_send_without_data(action);
int value_interval = atoi(next_buff);
}
result = true;
- mmi_protocol_fzd_respond_without_data(action);
+ mmi_protocol_fzd_send_without_data(action);
int value_interval = atoi(next_buff);
PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: content_lenth=%d\n", __FUNCTION__, __LINE__, content_lenth);
- result = mmi_protocol_fzd_send_content_construct(action, content_buff, content_lenth);
+ result = mmi_protocol_fzd_send_with_data(action, content_buff, content_lenth);
lv_mem_free(content_buff);
return result;
sprintf(content_buff, ",1");
content_lenth = strlen(content_buff);
- result = mmi_protocol_fzd_send_content_construct(action, content_buff, content_lenth);
+ result = mmi_protocol_fzd_send_with_data(action, content_buff, content_lenth);
next_buff_len_new = mmi_protocol_fzd_voice_data_decrypt(next_buff, next_buff_len);
result = wechat_msg_receive_from_server(next_buff, next_buff_len_new, WECHAT_MSG_TYPE_VOICE);
return false;
}
- result = mmi_protocol_fzd_respond_without_data(action);
+ result = mmi_protocol_fzd_send_without_data(action);
unsigned char t_buff[WECHAT_MSG_TEXT_LEN_MAX + 1] = {0};
uint8_t t_len = 0;
hal_rtc_t cur_time = {0};
unsigned int battery_value = Hal_Battery_Get_Status();
unsigned int sleep_roll_value = 0;
- unsigned int step_value = 0;
+ unsigned int step_value = asl_pedometer_steps_get();
uint8_t i = 0;
char data_str[128] = {0};
content_lenth = mmi_protocol_fzd_action_send_content_fill_location_data(content_buff, content_lenth, location_data, action, NULL);
- result = mmi_protocol_fzd_send_content_construct(action, content_buff, content_lenth);
+ result = mmi_protocol_fzd_send_with_data(action, content_buff, content_lenth);
lv_mem_free(content_buff);
return result;
content_lenth = mmi_protocol_fzd_action_send_content_fill_location_data(content_buff, content_lenth, location_data, action, NULL);
- result = mmi_protocol_fzd_send_content_construct(action, content_buff, content_lenth);
+ result = mmi_protocol_fzd_send_with_data(action, content_buff, content_lenth);
lv_mem_free(content_buff);
return result;
content_lenth = mmi_protocol_fzd_action_send_content_fill_location_data(content_buff, content_lenth, location_data, action, NULL);
- result = mmi_protocol_fzd_send_content_construct(action, content_buff, content_lenth);
+ result = mmi_protocol_fzd_send_with_data(action, content_buff, content_lenth);
lv_mem_free(content_buff);
return result;
}
result = true;
- mmi_protocol_fzd_respond_without_data(action);
+ mmi_protocol_fzd_send_without_data(action);
uint8_t i = 0;
unsigned char * temp_ptr = NULL;
}
result = true;
- mmi_protocol_fzd_respond_without_data(action);
+ mmi_protocol_fzd_send_without_data(action);
//////////
//////////
}
+static MMI_PROTOCOL_FZD_WARNING_INFO_STRUCT s_fzd_warning_info = {0};
+
+void mmi_protocol_fzd_set_warning_info(MMI_PROTOCOL_FZD_WARNING_TYPE_ENUM warning_type, bool value)
+{
+ PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: type=%d,value=%d\n", __FUNCTION__, __LINE__, warning_type, value);
+
+ if(MMI_FZD_WARNING_TYPE_NONE >= warning_type || MMI_FZD_WARNING_TYPE_MAX <= warning_type)
+ {
+ PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+ return;
+ }
+
+ switch(warning_type)
+ {
+ case MMI_FZD_WARNING_TYPE_SOS:
+ s_fzd_warning_info.sos = value;
+ break;
+
+ case MMI_FZD_WARNING_TYPE_LOW_BATTERY:
+ s_fzd_warning_info.low_battery = value;
+ break;
+
+ case MMI_FZD_WARNING_TYPE_TAKE_OFF:
+ s_fzd_warning_info.take_off = value;
+ break;
+
+ case MMI_FZD_WARNING_TYPE_TAKE_ON:
+ s_fzd_warning_info.take_on = value;
+ break;
+
+ case MMI_FZD_WARNING_TYPE_FALL_DOWN:
+ s_fzd_warning_info.fall_down = value;
+ break;
+
+ default:
+ break;
+ }
+
+ if(true == value)
+ {
+ mmi_watch_location_mission_warning_action();
+ }
+}
+
+bool mmi_protocol_fzd_action_send_warning_info(MMI_WATCH_LOCATION_DATA_T * location_data)
+{
+ bool result = false;
+ MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_ACTION_ALERT;
+ unsigned char * content_buff = NULL;
+ unsigned int content_lenth = 0;
+
+ while(1)
+ {
+ unsigned int warning_value = 0;
+ unsigned char warning_buff[16] = {0};
+ if(true == s_fzd_warning_info.sos)
+ {
+ warning_value |= (1 << 16);
+ s_fzd_warning_info.sos = false;
+ }
+ else if(true == s_fzd_warning_info.low_battery)
+ {
+ warning_value |= 1;
+ warning_value |= (1 << 17);
+ s_fzd_warning_info.low_battery = false;
+ }
+ else if(true == s_fzd_warning_info.take_off)
+ {
+ warning_value |= (1 << 3);
+ warning_value |= (1 << 20);
+ s_fzd_warning_info.take_off = false;
+ }
+ else if(true == s_fzd_warning_info.take_on)
+ {
+ warning_value |= (1 << 20);
+ s_fzd_warning_info.take_on = false;
+ }
+ else if(true == s_fzd_warning_info.fall_down)
+ {
+ warning_value |= (1 << 4);
+ warning_value |= (1 << 21);
+ s_fzd_warning_info.fall_down = false;
+ }
+ else
+ {
+ break;
+ }
+
+ sprintf(warning_buff, "%02x%02x%02x%02x",
+ (unsigned char)(warning_value >> 24), (unsigned char)(warning_value >> 16),
+ (unsigned char)(warning_value >> 8), (unsigned char)warning_value);
+
+ PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: value=%d,buff=%s\n", __FUNCTION__, __LINE__, warning_value, warning_buff);
+
+ content_lenth = MMI_PROTOCOL_FZD_FILL_LOCATION_DATA_BUFF_LEN;
+ content_buff = (unsigned char *)lv_mem_alloc(content_lenth);
+ if(NULL == content_buff)
+ {
+ PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+ return false;
+ }
+ _lv_memset_00(content_buff, content_lenth);
+
+ content_lenth = mmi_protocol_fzd_action_send_content_fill_location_data(content_buff, content_lenth, location_data, action, warning_buff);
+
+ result = mmi_protocol_fzd_send_with_data(action, content_buff, content_lenth);
+ lv_mem_free(content_buff);
+ }
+
+ return result;
+}
+
+bool mmi_protocol_fzd_action_unbind(void)
+{
+ return mmi_protocol_fzd_send_without_data(MMI_FZD_ACTION_UNBIND);
+}
{"SETFACTORY", 10, mmi_protocol_sms_parse_set_factory},
{"SETREBOOT", 9, mmi_protocol_sms_parse_set_reboot},
{"GETIMEI", 7, mmi_protocol_sms_parse_get_imei},
+ {"UNBIND", 6, mmi_protocol_sms_parse_unbind},
/*******add before this line*******/
{"", 0, NULL}
};
+bool mmi_protocol_sms_content_parse(char * sms_content, char * sms_send_number)
+{
+ bool result = false;
+
+ SMS_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: num=%s\n", __FUNCTION__, __LINE__, sms_send_number);
+ SMS_DEBUG_PRINTF("[@CHENG_DEBUG][%d]: %s\n", __LINE__, sms_content);
+
+ if(NULL != sms_content)
+ {
+ int content_len = 0, num_len = 0;
+ char data[NV_SMS_MAX_DATA_LEN] = {0};
+ char number[NV_CONTACTS_MAX_NUMBER_LEN] = {0};
+ uint8_t i = 0;
+
+ content_len = strlen(sms_content);
+ if(NV_SMS_MAX_DATA_LEN <= content_len)
+ content_len = NV_SMS_MAX_DATA_LEN - 1;
+ _lv_memcpy(data, sms_content, content_len);
+
+ num_len = strlen(sms_send_number);
+ if(NV_CONTACTS_MAX_NUMBER_LEN <= num_len)
+ num_len = NV_CONTACTS_MAX_NUMBER_LEN - 1;
+ _lv_memcpy(number, sms_send_number, num_len);
+
+ i = 0;
+ while(0 != s_sms_parse_info[i].fixed_str_len)
+ {
+ if(content_len < s_sms_parse_info[i].fixed_str_len)
+ {
+ SMS_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+ }
+ else if(0 == strncmp(s_sms_parse_info[i].fixed_str, data, s_sms_parse_info[i].fixed_str_len))
+ {
+ SMS_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+
+ if(NULL != s_sms_parse_info[i].parse_cb)
+ {
+ result = s_sms_parse_info[i].parse_cb(s_sms_parse_info[i].fixed_str, data + s_sms_parse_info[i].fixed_str_len, number);
+ SMS_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: result=%d\n", __FUNCTION__, __LINE__, result);
+ break;
+ }
+ }
+ i++;
+ }
+ }
+
+ return result;
+}
static void mmi_protocol_sms_parse_sms_reply(char * content_str, char * fixed_str, char * number, app_adaptor_sms_send_result_ind cb)
{
return true;
}
-
-
-bool mmi_protocol_sms_content_parse(char * sms_content, char * sms_send_number)
+//
+static void mmi_protocol_sms_unbind_cb(watch_app_adp_sms_send_result_type_t result)
{
- bool result = false;
-
- SMS_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: num=%s\n", __FUNCTION__, __LINE__, sms_send_number);
- SMS_DEBUG_PRINTF("[@CHENG_DEBUG][%d]: %s\n", __LINE__, sms_content);
+ SMS_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: %d\n", __FUNCTION__, __LINE__, result);
- if(NULL != sms_content)
+ if(APP_SMS_SEND_SUCCESS == result)
{
- int content_len = 0, num_len = 0;
- char data[NV_SMS_MAX_DATA_LEN] = {0};
- char number[NV_CONTACTS_MAX_NUMBER_LEN] = {0};
- uint8_t i = 0;
-
- content_len = strlen(sms_content);
- if(NV_SMS_MAX_DATA_LEN <= content_len)
- content_len = NV_SMS_MAX_DATA_LEN - 1;
- _lv_memcpy(data, sms_content, content_len);
+ mmi_protocol_action_unbind();
+ }
+ else if(APP_SMS_SEND_FAIL == result)
+ {
+ //
+ }
+}
- num_len = strlen(sms_send_number);
- if(NV_CONTACTS_MAX_NUMBER_LEN <= num_len)
- num_len = NV_CONTACTS_MAX_NUMBER_LEN - 1;
- _lv_memcpy(number, sms_send_number, num_len);
-
- i = 0;
- while(0 != s_sms_parse_info[i].fixed_str_len)
- {
- if(content_len < s_sms_parse_info[i].fixed_str_len)
- {
- SMS_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
- }
- else if(0 == strncmp(s_sms_parse_info[i].fixed_str, data, s_sms_parse_info[i].fixed_str_len))
- {
- SMS_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
-
- if(NULL != s_sms_parse_info[i].parse_cb)
- {
- result = s_sms_parse_info[i].parse_cb(s_sms_parse_info[i].fixed_str, data + s_sms_parse_info[i].fixed_str_len, number);
- SMS_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: result=%d\n", __FUNCTION__, __LINE__, result);
- break;
- }
- }
- i++;
- }
+bool mmi_protocol_sms_parse_unbind(char * fixed_str, char * data, char * number)
+{
+ SMS_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: num=%s\n", __FUNCTION__, __LINE__, number);
+ SMS_DEBUG_PRINTF("[@CHENG_DEBUG][%d]: %s\n", __LINE__, data);
+
+ if(0 != strlen(data))
+ {
+ SMS_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+ return false;
}
+
+ mmi_protocol_sms_parse_sms_reply(NULL, fixed_str, number, mmi_protocol_sms_unbind_cb);
- return result;
+ return true;
}
+
+
+
#endif