gengxin
author@CHENG <2393524978@qq.com>
Fri, 24 May 2024 07:58:40 +0000 (15:58 +0800)
committer@CHENG <2393524978@qq.com>
Fri, 24 May 2024 07:58:40 +0000 (15:58 +0800)
13 files changed:
2.sdk/sdk/gui/lv_watch/mmi_location/mmi_location.c [new file with mode: 0644]
2.sdk/sdk/gui/lv_watch/mmi_location/mmi_location.h [new file with mode: 0644]
2.sdk/sdk/gui/lv_watch/mmi_protocol/mmi_protocol_api.c [new file with mode: 0644]
2.sdk/sdk/gui/lv_watch/mmi_protocol/mmi_protocol_api.h [new file with mode: 0644]
2.sdk/sdk/gui/lv_watch/mmi_protocol/mmi_protocol_fzd.c [new file with mode: 0644]
2.sdk/sdk/gui/lv_watch/mmi_protocol/mmi_protocol_fzd.h [new file with mode: 0644]
2.sdk/sdk/gui/lv_watch/mmi_protocol/mmi_protocol_fzd_content.c [new file with mode: 0644]
2.sdk/sdk/gui/lv_watch/mmi_protocol/mmi_protocol_sms.c [new file with mode: 0644]
2.sdk/sdk/gui/lv_watch/mmi_protocol/mmi_protocol_sms.h [new file with mode: 0644]
2.sdk/sdk/gui/lv_watch/mmi_sundry/mmi_common.c [new file with mode: 0644]
2.sdk/sdk/gui/lv_watch/mmi_sundry/mmi_common.h [new file with mode: 0644]
2.sdk/sdk/gui/lv_watch/mmi_sundry/mmi_sundry.c [new file with mode: 0644]
2.sdk/sdk/gui/lv_watch/mmi_sundry/mmi_sundry.h [new file with mode: 0644]

diff --git a/2.sdk/sdk/gui/lv_watch/mmi_location/mmi_location.c b/2.sdk/sdk/gui/lv_watch/mmi_location/mmi_location.c
new file mode 100644 (file)
index 0000000..cdd6225
--- /dev/null
@@ -0,0 +1,523 @@
+
+
+
+#include "lv_watch.h"
+
+#ifdef __MMI_ZHSX_SUPPORT__
+
+#if USE_GPS
+#include "../../../product/craneg_modem/hal/gps_device/inc/gpsnmeaapi.h"
+#endif
+#include "../modem/mmi_modem_tcp/wifi_scan_task.h"
+
+
+static uint8_t s_watch_location_state = 0; // 0-default; 1-locating
+static MMI_WATCH_LOCATION_STATE_E s_watch_location_gps_state = 0, s_watch_location_cell_state = 0, s_watch_location_wifi_state = 0;
+static MMI_WATCH_LOCATION_DATA_T s_watch_location_data = {0};
+static lv_ll_t s_watch_location_mission_ll = {0};
+static uint8_t s_watch_location_mission_ll_locked = 0;
+static void * s_watch_location_timer_id = NULL;
+static uint8_t s_watch_location_times_check_count = 0;
+
+static void mmi_watch_location_mission_timer_cb(uint32_t para);
+
+
+void mmi_watch_location_mission_list_init(void)
+{
+       s_watch_location_mission_ll_locked = 0;
+       _lv_ll_clear(&s_watch_location_mission_ll);
+       _lv_ll_init(&s_watch_location_mission_ll, sizeof(MMI_WATCH_LOCATION_TYPE_E));
+}
+
+void mmi_watch_location_mission_list_clear(void)
+{
+       _lv_ll_clear(&s_watch_location_mission_ll);
+}
+
+/*
+void mmi_watch_location_mission_list_node_remove(MMI_WATCH_LOCATION_TYPE_E location_type)
+{
+       if(true == _lv_ll_is_empty(&s_watch_location_mission_ll))
+               return;
+       
+    MMI_WATCH_LOCATION_TYPE_E * node = _lv_ll_get_tail(&s_watch_location_mission_ll);
+       
+    while(NULL != node)
+       {
+               if(location_type == * node)
+               {
+                       _lv_ll_remove(&s_watch_location_mission_ll, node);
+                       lv_mem_free(node);
+                       node = NULL;
+                       return ; // delete
+               }
+        node = _lv_ll_get_prev(&s_watch_location_mission_ll, node);
+    }
+}
+*/
+
+bool mmi_watch_location_mission_list_node_add(MMI_WATCH_LOCATION_TYPE_E location_type)
+{
+       if(1 == s_watch_location_mission_ll_locked)
+       {
+               LOCATION_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: location ll locked\n", __FUNCTION__, __LINE__);
+               return false;
+       }
+       
+    MMI_WATCH_LOCATION_TYPE_E * node = _lv_ll_get_head(&s_watch_location_mission_ll);
+       
+       LOCATION_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: location ll head=0x%x\n", __FUNCTION__, __LINE__, (NULL != node) ? node : 0);
+       
+    while(NULL != node)
+       {
+               if(location_type == * node)
+               {
+                       LOCATION_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: location type exist\n", __FUNCTION__, __LINE__);
+                       return false;
+               }
+        node = _lv_ll_get_next(&s_watch_location_mission_ll, node);
+    }
+       
+       LOCATION_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: location type add\n", __FUNCTION__, __LINE__);
+       
+       MMI_WATCH_LOCATION_TYPE_E * new_node = _lv_ll_ins_head(&s_watch_location_mission_ll);
+       * new_node = location_type;
+
+       return true;
+}
+
+void mmi_watch_location_mission_list_data_send(void)
+{
+       LOCATION_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+       
+       if(true == _lv_ll_is_empty(&s_watch_location_mission_ll))
+               return;
+               
+       LOCATION_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+    LOCATION_DEBUG_PRINTF("[@CHENG_DEBUG][%d]: %d,%d,%d,%d,%d,%d,%d,%d,%u\n", __LINE__,
+                                       s_watch_location_data.gps_data.state,
+                                       s_watch_location_data.gps_data.latitude * 1000000,
+                                       s_watch_location_data.gps_data.ns,
+                                       s_watch_location_data.gps_data.longitude * 1000000,
+                                       s_watch_location_data.gps_data.ew,
+                                       s_watch_location_data.gps_data.speed * 100,
+                                       s_watch_location_data.gps_data.degree * 10,
+                                       s_watch_location_data.gps_data.altitude * 10,
+                                       s_watch_location_data.gps_data.satellite_num);
+
+#if 1
+
+       uint8_t t_total = _lv_ll_get_len(&s_watch_location_mission_ll);
+       uint8_t t_counter = 0;
+       
+       s_watch_location_mission_ll_locked = 1;
+       MMI_WATCH_LOCATION_TYPE_E * node = _lv_ll_get_head(&s_watch_location_mission_ll);
+       
+       while((NULL != node) && (t_counter != t_total))
+       {
+               switch(* node)
+               {
+                       case MMI_WATCH_LOCATION_UD:
+                               LOCATION_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+                               mmi_protocol_action_send_location(&s_watch_location_data);
+                               break;
+                               
+                       case MMI_WATCH_LOCATION_CRUD:
+                               LOCATION_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+                               mmi_protocol_action_send_cur_location(&s_watch_location_data);
+                               break;
+                               
+                       case MMI_WATCH_LOCATION_WT:
+                               LOCATION_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+                               mmi_protocol_action_send_get_weather(&s_watch_location_data);
+                               break;
+                               
+                       case MMI_WATCH_LOCATION_WARNING:
+                               LOCATION_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+                               mmi_protocol_action_send_warning_info(&s_watch_location_data);
+                               break;
+                               
+                       default:
+                               break;
+               }
+
+               node = _lv_ll_get_next(&s_watch_location_mission_ll, node);
+               t_counter++;
+       }
+
+       LOCATION_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: total=%d,counter=%d\n", __FUNCTION__, __LINE__, t_total, t_counter);
+       _lv_ll_clear(&s_watch_location_mission_ll);
+
+#else
+
+       // for debug
+       uint8_t t_total = _lv_ll_get_len(&s_watch_location_mission_ll);
+       uint8_t t_counter = 0;
+       
+       s_watch_location_mission_ll_locked = 1;
+       MMI_WATCH_LOCATION_TYPE_E * node = _lv_ll_get_tail(&s_watch_location_mission_ll);
+       
+       while(NULL != node)
+       {
+               switch(* node)
+               {
+                       case MMI_WATCH_LOCATION_UD:
+                               LOCATION_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+                               mmi_protocol_action_send_location(&s_watch_location_data);
+                               break;
+                               
+                       case MMI_WATCH_LOCATION_CRUD:
+                               LOCATION_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+                               mmi_protocol_action_send_cur_location(&s_watch_location_data);
+                               break;
+                               
+                       case MMI_WATCH_LOCATION_WT:
+                               LOCATION_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+                               mmi_protocol_action_send_get_weather(&s_watch_location_data);
+                               break;
+                               
+                       case MMI_WATCH_LOCATION_WARNING:
+                               LOCATION_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+                               mmi_protocol_action_send_warning_info(&s_watch_location_data);
+                               break;
+                               
+                       default:
+                               break;
+               }
+
+               MMI_WATCH_LOCATION_TYPE_E * pre_node = _lv_ll_get_prev(&s_watch_location_mission_ll, node);
+               _lv_ll_remove(&s_watch_location_mission_ll, node);
+               lv_mem_free(node);
+               node = pre_node;
+
+               // for debug
+               t_counter++;
+       }
+       LOCATION_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: total=%d,counter=%d\n", __FUNCTION__, __LINE__, t_total, t_counter);
+#endif
+}
+
+void mmi_watch_location_gps_data_get(void)
+{
+#if USE_GPS
+       double gpsLon = 0, gpsLat = 0;
+       gpsNmeaDataT gpsNmeaData = {0};
+
+       LOCATION_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+
+    ReadNmeaData(&gpsNmeaData);
+       if('A' == gpsNmeaData.NmeaRmcData.Status) 
+       {
+               LOCATION_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               
+        hal_gps_aidpos_save(gpsNmeaData.NmeaRmcData.Latitude, gpsNmeaData.NmeaRmcData.NSIndicator,
+                            gpsNmeaData.NmeaRmcData.Longitude, gpsNmeaData.NmeaRmcData.WEIndicator,
+                            gpsNmeaData.NmeaGgaData.Altitude);
+
+               gps2wgs84(gpsNmeaData.NmeaRmcData.Latitude, gpsNmeaData.NmeaRmcData.Longitude, &gpsLat, &gpsLon);
+
+               s_watch_location_data.gps_data.state = 'A';
+               s_watch_location_data.gps_data.latitude = gpsLat;
+               s_watch_location_data.gps_data.ns = gpsNmeaData.NmeaRmcData.NSIndicator;
+               s_watch_location_data.gps_data.longitude = gpsLon;
+               s_watch_location_data.gps_data.ew = gpsNmeaData.NmeaRmcData.WEIndicator;
+               s_watch_location_data.gps_data.speed = gpsNmeaData.NmeaRmcData.SpeedOverGround;
+               s_watch_location_data.gps_data.degree = gpsNmeaData.NmeaRmcData.CourseOverGround;
+               s_watch_location_data.gps_data.altitude = gpsNmeaData.NmeaGgaData.Altitude;
+               s_watch_location_data.gps_data.satellite_num = gpsNmeaData.NmeaGgaData.SatellitesUsed;
+
+               s_watch_location_gps_state = MMI_WATCH_LOCATION_STATE_SUCCESS;
+       }
+       /*
+       else if(pBuf.NmeaGgaData.status == 1) 
+       {
+        hal_gps_aidpos_save(pBuf.NmeaGgaData.latitude, pBuf.NmeaGgaData.NSIndicator,
+                            pBuf.NmeaGgaData.longitude, pBuf.NmeaGgaData.WEIndicator,
+                            pBuf.NmeaGgaData.Altitude);
+        gps2wgs84(pBuf.NmeaGgaData.latitude, pBuf.NmeaGgaData.longitude, &gpsLat, &gpsLon);
+    }
+       */
+#endif
+}
+
+void mmi_watch_location_gps_finsh_cb(void *param)
+{
+#if USE_GPS
+       LOCATION_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+       
+       if(NULL != param)
+       {
+               LOCATION_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               
+               double gpsLon = 0, gpsLat = 0;
+               gpsNmeaDataT * gpsNmeaData = (gpsNmeaDataT * )param;
+               
+               if('A' == gpsNmeaData->NmeaRmcData.Status) 
+               {
+                       LOCATION_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+                       
+                       gps2wgs84(gpsNmeaData->NmeaRmcData.Latitude, gpsNmeaData->NmeaRmcData.Longitude, &gpsLat, &gpsLon);
+
+                       s_watch_location_data.gps_data.state = 'A';
+                       s_watch_location_data.gps_data.latitude = gpsLat;
+                       s_watch_location_data.gps_data.ns = gpsNmeaData->NmeaRmcData.NSIndicator;
+                       s_watch_location_data.gps_data.longitude = gpsLon;
+                       s_watch_location_data.gps_data.ew = gpsNmeaData->NmeaRmcData.WEIndicator;
+                       s_watch_location_data.gps_data.speed = gpsNmeaData->NmeaRmcData.SpeedOverGround;
+                       s_watch_location_data.gps_data.degree = gpsNmeaData->NmeaRmcData.CourseOverGround;
+                       s_watch_location_data.gps_data.altitude = gpsNmeaData->NmeaGgaData.Altitude;
+                       s_watch_location_data.gps_data.satellite_num = gpsNmeaData->NmeaGgaData.SatellitesUsed;
+
+                       s_watch_location_gps_state = MMI_WATCH_LOCATION_STATE_SUCCESS;
+               }
+       }
+#endif
+}
+
+void mmi_watch_location_gps_stop(void)
+{
+#if USE_GPS
+       LOCATION_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+       
+       gps_request_locate_stop();
+#endif
+}
+
+void mmi_watch_location_gps_start(void)
+{
+#if USE_GPS
+       LOCATION_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+       
+       s_watch_location_gps_state = MMI_WATCH_LOCATION_STATE_PROCESS;
+       
+       gps_request_locate_start(mmi_watch_location_gps_finsh_cb);
+#endif
+}
+
+void mmi_watch_location_cell_stop(void)
+{
+       LOCATION_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+}
+
+void mmi_watch_location_lte_cell_info_ind(app_adp_lte_cells_t *cell_list)
+{
+       uint8_t i = 0;
+
+       s_watch_location_data.cell_data.mcc = cell_list->scell.mcc;
+       s_watch_location_data.cell_data.mnc = cell_list->scell.mnc;
+       s_watch_location_data.cell_data.link_cell_id = cell_list->scell.cellid;
+       s_watch_location_data.cell_data.link_lac = cell_list->scell.tac;
+       s_watch_location_data.cell_data.link_rxlev = cell_list->scell.rsrp;
+       s_watch_location_data.cell_data.cell_num = cell_list->encell_num;
+       for(i = 0; i < s_watch_location_data.cell_data.cell_num; i++)
+       {
+               s_watch_location_data.cell_data.lac[i] = cell_list->encell[i].tac;
+               s_watch_location_data.cell_data.cell_id[i] = cell_list->encell[i].cellid;
+               s_watch_location_data.cell_data.rxlev[i] = cell_list->encell[i].rsrp;
+       }
+
+       s_watch_location_cell_state = MMI_WATCH_LOCATION_STATE_SUCCESS;
+}
+
+void mmi_watch_location_gsm_cell_info_ind(app_adp_gsm_cells_t *cell_list)
+{
+       uint8_t i = 0;
+
+       s_watch_location_data.cell_data.mcc = cell_list->scell.mcc;
+       s_watch_location_data.cell_data.mnc = cell_list->scell.mnc;
+       s_watch_location_data.cell_data.link_cell_id = cell_list->scell.cell_id;
+       s_watch_location_data.cell_data.link_lac = cell_list->scell.lac;
+       s_watch_location_data.cell_data.link_rxlev = cell_list->scell.rxlev;
+       s_watch_location_data.cell_data.cell_num = cell_list->gncell_num;
+       for(i = 0; i < s_watch_location_data.cell_data.cell_num; i++)
+       {
+               s_watch_location_data.cell_data.lac[i] = cell_list->gncell[i].lac;
+               s_watch_location_data.cell_data.cell_id[i] = cell_list->gncell[i].cell_id;
+               s_watch_location_data.cell_data.rxlev[i] = cell_list->gncell[i].rxlev;
+       }
+
+       s_watch_location_cell_state = MMI_WATCH_LOCATION_STATE_SUCCESS;
+}
+
+void mmi_watch_location_cell_start(void)
+{
+       LOCATION_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+       
+       s_watch_location_cell_state = MMI_WATCH_LOCATION_STATE_PROCESS;
+
+       app_adaptor_lte_cell_info_ind_bind(mmi_watch_location_lte_cell_info_ind);
+       app_adaptor_gsm_cell_info_ind_bind(mmi_watch_location_gsm_cell_info_ind);
+       app_adaptor_get_cell_info_req(GET_CELL_INFO_ONCE_MODE);
+}
+
+void mmi_watch_location_wifi_stop(void)
+{
+       LOCATION_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+       
+       wifi_scan_destroy();
+}
+
+void mmi_watch_location_wifi_scan_cb(WIFI_SCAN_ID_DEF msgid, WifiInfoT *wifi_info)
+{
+       //if(WIFI_SCAN_MSG_COMPLETE == msgid)
+       if(0 != wifi_info->HotspotNum)
+       {
+               LOCATION_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               
+               s_watch_location_wifi_state = MMI_WATCH_LOCATION_STATE_SUCCESS;
+
+               s_watch_location_data.wifi_data.count = wifi_info->HotspotNum;
+
+               uint8_t i = 0;
+               for(i = 0; i < s_watch_location_data.wifi_data.count; i++)
+               {
+                       s_watch_location_data.wifi_data.item[i].rssi = wifi_info->WifiHotspot[i].Rssi;
+
+                       uint8_t j = 0;
+                       for(j = 0; j < APP_ADP_WIFI_MAC_LEN; j++)
+                       {
+                               s_watch_location_data.wifi_data.item[i].mac[j] = mmi_hex_string_to_number(wifi_info->WifiHotspot[i].MacAddr + (j * 2), 2);
+                               //LOCATION_DEBUG_PRINTF("[@CHENG_DEBUG][%d]: %d-%s\n", __LINE__,
+                               //                                              s_watch_location_data.wifi_data.item[i].mac[j],
+                               //                                              wifi_info->WifiHotspot[i].MacAddr + (j * 2));
+                       }
+                       LOCATION_DEBUG_PRINTF("[@CHENG_DEBUG][%d]: %d-%s\n", __LINE__, 
+                                                                       wifi_info->WifiHotspot[i].Rssi, 
+                                                                       wifi_info->WifiHotspot[i].MacAddr);
+               }
+       }
+       else
+       {
+               wifi_scan_start();
+       }
+}
+
+void mmi_watch_location_wifi_start(void)
+{
+       LOCATION_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+       
+       s_watch_location_wifi_state = MMI_WATCH_LOCATION_STATE_PROCESS;
+
+       wifi_scan_init();
+       wifi_scan_set_result_callback(mmi_watch_location_wifi_scan_cb);
+       wifi_scan_start();
+}
+
+void mmi_watch_location_mission_stop(void)
+{
+       LOCATION_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+       
+       s_watch_location_mission_ll_locked = 0;
+       s_watch_location_state = 0;
+       if(NULL != s_watch_location_timer_id)
+       {
+               uos_timer_stop(s_watch_location_timer_id);
+               uos_timer_delete(s_watch_location_timer_id);
+               s_watch_location_timer_id = NULL;
+       }
+
+       mmi_watch_location_gps_stop();
+       mmi_watch_location_cell_stop();
+       mmi_watch_location_wifi_stop();
+}
+
+static void mmi_watch_location_mission_timer_cb(uint32_t para)
+{
+       LOCATION_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: total=%d,count=%d\n", __FUNCTION__, __LINE__, MMI_WATCH_LOCATION_CHECK_TIMES_COUNT_MAX, s_watch_location_times_check_count);
+
+       //mmi_watch_location_gps_data_get();
+       
+       s_watch_location_times_check_count++;
+       if(MMI_WATCH_LOCATION_CHECK_TIMES_COUNT_MAX <= s_watch_location_times_check_count)
+       {
+               LOCATION_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               
+               mmi_watch_location_mission_list_data_send();
+               mmi_watch_location_mission_stop();
+       }
+       else
+       {
+               if(MMI_WATCH_LOCATION_STATE_SUCCESS == s_watch_location_cell_state
+                       #if USE_GPS
+                       && MMI_WATCH_LOCATION_STATE_SUCCESS == s_watch_location_gps_state
+                       #else
+                       && MMI_WATCH_LOCATION_STATE_SUCCESS == s_watch_location_wifi_state
+                       #endif
+                       )
+               {
+                       LOCATION_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+                       
+                       mmi_watch_location_mission_list_data_send();
+                       mmi_watch_location_mission_stop();
+               }
+               else
+               {
+                       LOCATION_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+                       
+                       uos_timer_stop(s_watch_location_timer_id);
+                       uos_timer_start(s_watch_location_timer_id, MS_TO_TICKS(MMI_WATCH_LOCATION_PROCESS_DURATION), 0, mmi_watch_location_mission_timer_cb, NULL);
+               }
+       }
+}
+
+void mmi_watch_location_mission_start(void)
+{
+       LOCATION_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+       
+       if(0 == s_watch_location_state)
+       {
+               LOCATION_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               
+               s_watch_location_state = 1;
+               _lv_memset_00(&s_watch_location_data, sizeof(MMI_WATCH_LOCATION_DATA_T));
+               s_watch_location_times_check_count = 0;
+
+               uos_timer_create(&s_watch_location_timer_id);
+               uos_timer_start(s_watch_location_timer_id, MS_TO_TICKS(MMI_WATCH_LOCATION_PROCESS_DURATION), 0, mmi_watch_location_mission_timer_cb, NULL);
+               
+               mmi_watch_location_gps_start();
+               mmi_watch_location_cell_start();
+               mmi_watch_location_wifi_start();
+       }
+}
+
+static void mmi_watch_location_mission_action(MMI_WATCH_LOCATION_TYPE_E location_type)
+{
+       LOCATION_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: type=%d\n", __FUNCTION__, __LINE__, location_type);
+
+       if(MMI_WATCH_LOCATION_NONE >= location_type || MMI_WATCH_LOCATION_MAX <= location_type)
+       {
+               LOCATION_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               return;
+       }
+
+       if(true == mmi_watch_location_mission_list_node_add(location_type))
+       {
+               LOCATION_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               mmi_watch_location_mission_start();
+       }
+}
+
+void mmi_watch_location_mission_timed_location_action(void)
+{
+       mmi_watch_location_mission_action(MMI_WATCH_LOCATION_UD);
+}
+
+void mmi_watch_location_mission_current_location_action(void)
+{
+       mmi_watch_location_mission_action(MMI_WATCH_LOCATION_CRUD);
+}
+
+void mmi_watch_location_mission_get_weather_action(void)
+{
+       mmi_watch_location_mission_action(MMI_WATCH_LOCATION_WT);
+}
+
+void mmi_watch_location_mission_warning_action(void)
+{
+       mmi_watch_location_mission_action(MMI_WATCH_LOCATION_WARNING);
+}
+
+#endif
+
+
diff --git a/2.sdk/sdk/gui/lv_watch/mmi_location/mmi_location.h b/2.sdk/sdk/gui/lv_watch/mmi_location/mmi_location.h
new file mode 100644 (file)
index 0000000..4a9e526
--- /dev/null
@@ -0,0 +1,131 @@
+
+
+
+#ifndef __MMI_LOCATION_H__
+#define __MMI_LOCATION_H__
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif //__cplusplus
+
+#ifdef LV_CONF_INCLUDE_SIMPLE
+#include "lvgl.h"
+#include "lv_watch_conf.h"
+#else
+#include "../../../lvgl/lvgl.h"
+#include "../../../lv_watch_conf.h"
+#endif
+
+#ifdef __MMI_ZHSX_SUPPORT__
+
+typedef void (*FUNC_CB)(int);
+
+
+#define __MMI_LOCATION_DEBUG__
+#ifdef __MMI_LOCATION_DEBUG__
+#define LOCATION_DEBUG_PRINTF(fmt, ...)        printf("[LOCATION]"fmt, ##__VA_ARGS__)
+#else
+#define LOCATION_DEBUG_PRINTF(fmt, ...)
+#endif
+
+
+#define LOCATION_MAX(a, b)     (((a) > (b)) ? (a) : (b))
+#define LOCATION_MIN(a, b)     (((a) > (b)) ? (b) : (a))
+
+#define MMI_WATCH_LOCATION_PROCESS_DURATION            (1000 * 10) // ms
+#define MMI_WATCH_LOCATION_CHECK_TIMES_COUNT_MAX               (4) // 40000 ms
+
+#define MMI_WATCH_LOCATION_UPLOAD_INTERVAL_MIN         (2 * 60) // s
+
+
+typedef enum
+{
+       MMI_WATCH_LOCATION_STATE_NONE,
+       MMI_WATCH_LOCATION_STATE_PROCESS,
+       MMI_WATCH_LOCATION_STATE_SUCCESS,
+       MMI_WATCH_LOCATION_STATE_TIMEOUT,
+       MMI_WATCH_LOCATION_STATE_FAIL,
+       MMI_WATCH_LOCATION_STATE_MAX,
+}MMI_WATCH_LOCATION_STATE_E;
+
+typedef struct
+{
+    //Êý¾ÝÊÇ·ñÓÐЧ£¬'A'ÓÐЧ£¬'V'ÎÞЧ
+    uint8_t state;
+       
+       //γ¶È£¬¾ø¶ÔÖµ
+    double latitude;
+    // Äϱ±Î³
+    uint8_t ns;
+
+    //¾­¶È£¬¾ø¶ÔÖµ
+    double longitude;
+    //¶«Î÷¾­
+    uint8_t ew;
+
+    //ËÙÂÊ
+    float speed;
+
+    //½Ç¶È
+    float degree;
+       
+       //º£°Î¸ß¶È
+       double altitude;
+       
+    //¶¨Î»µÄÎÀÐÇÊýÁ¿
+       uint8_t satellite_num;
+}MMI_WATCH_GPS_DATA_T;
+
+typedef struct
+{
+    uint16_t mcc;
+    uint16_t mnc;
+    uint16_t link_lac;
+    uint32_t link_cell_id;
+    int16_t link_rxlev;
+       uint8_t cell_num;
+    uint16_t lac[APP_ADP_MAX_GSM_NCELL_NUM];
+    uint32_t cell_id[APP_ADP_MAX_GSM_NCELL_NUM];
+    int16_t rxlev[APP_ADP_MAX_GSM_NCELL_NUM];
+} MMI_WATCH_CELL_DATA_T;
+
+typedef struct
+{
+       MMI_WATCH_GPS_DATA_T gps_data;
+       MMI_WATCH_CELL_DATA_T cell_data;
+       app_adp_wifi_ap_list wifi_data;
+} MMI_WATCH_LOCATION_DATA_T;
+
+
+typedef enum
+{
+       MMI_WATCH_LOCATION_NONE,
+       MMI_WATCH_LOCATION_UD, // ud
+       MMI_WATCH_LOCATION_CRUD, // crud
+       MMI_WATCH_LOCATION_WT, //weather
+       MMI_WATCH_LOCATION_WARNING, // warning
+
+       MMI_WATCH_LOCATION_MAX,
+}MMI_WATCH_LOCATION_TYPE_E;
+
+
+void mmi_watch_location_mission_list_init(void);
+void mmi_watch_location_mission_list_clear(void);
+
+void mmi_watch_location_mission_timed_location_action(void);
+void mmi_watch_location_mission_current_location_action(void);
+void mmi_watch_location_mission_get_weather_action(void);
+void mmi_watch_location_mission_warning_action(void);
+
+
+
+#endif
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif //__cplusplus
+
+#endif
+
+
diff --git a/2.sdk/sdk/gui/lv_watch/mmi_protocol/mmi_protocol_api.c b/2.sdk/sdk/gui/lv_watch/mmi_protocol/mmi_protocol_api.c
new file mode 100644 (file)
index 0000000..b9c4b93
--- /dev/null
@@ -0,0 +1,966 @@
+
+
+
+#include "lv_watch.h"
+
+#ifdef __MMI_ZHSX_SUPPORT__
+
+
+static nv_watch_protocol_data_t s_watch_protocol_data = {0};
+static bool s_watch_bind_state = false;
+
+bool mmi_protocol_action_location(void);
+
+
+bool mmi_watch_tcp_connect_state_get(void)
+{
+       return (bool)get_mmi_modem_tcp_connect_state();
+}
+
+bool mmi_protocol_watch_bind_state_get(void)
+{
+       return s_watch_bind_state;
+}
+
+void mmi_protocol_watch_bind_state_set(bool state)
+{
+       s_watch_bind_state = state;
+}
+
+void mmi_protocol_receive_data_process(char * recv_str, int recv_len)
+{
+       mmi_protocol_fzd_receive_data_process(recv_str, recv_len);
+}
+
+void * mmi_protocol_send_space_ptr_get(int cmd)
+{
+       mmi_protocol_fzd_send_space_ptr_get(cmd);
+}
+
+int mmi_protocol_send_space_size_get(int cmd)
+{
+       return mmi_protocol_fzd_send_space_size_get(cmd);
+}
+
+void mmi_protocol_send_space_free(int cmd)
+{
+       mmi_protocol_fzd_send_space_deinit(cmd);
+}
+
+bool mmi_protocol_send_cmd_check(int cmd)
+{
+       return mmi_protocol_fzd_send_cmd_check(cmd);
+}
+
+void mmi_watch_protocol_data_nv_write(void)
+{
+       uint32_t nv_data_length = sizeof(nv_watch_protocol_data_t);
+       
+       if(nv_data_length != UI_NV_Write_Req(NV_SECTION_UI_PROTOCOL_DATA, 0, nv_data_length, (uint8_t *)&s_watch_protocol_data))
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: nv write fail\n", __FUNCTION__, __LINE__);
+       }
+}
+
+void mmi_watch_protocol_data_nv_read(void)
+{
+       uint32_t nv_data_length = sizeof(nv_watch_protocol_data_t);
+       
+       if(nv_data_length != UI_NV_Read_Req(NV_SECTION_UI_PROTOCOL_DATA, 0, nv_data_length, (uint8_t *)&s_watch_protocol_data))
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: nv read fail\n", __FUNCTION__, __LINE__);
+       }
+}
+
+void mmi_watch_protocol_data_nv_default(nv_watch_protocol_data_t * data)
+{
+       PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: nv default\n", __FUNCTION__, __LINE__);
+       
+#ifdef __MMI_ZHSX_SUPPORT_AUTHENTICATE__
+       data->authenticate_flag = 0;
+#endif
+       strncpy(data->watch_host_name, MMI_PROTOCOL_IP_ADDRESS_DEFAULT, NV_WATCH_HOST_NAME_LEN_MAX - 1);
+       data->watch_host_port = MMI_PROTOCOL_IP_PORT_DEFAULT;
+       strncpy(data->protocol_md5_key, MMI_PROTOCOL_MD5_KEY_DEFAULT, NV_PROTOCOL_MD5_KEY_LEN_MAX - 1);
+       strncpy(data->protocol_device_name, MMI_PROTOCOL_DEVICE_NAME_DEFAULT, NV_PROTOCOL_DEVICE_NAME_LEN_MAX - 1);
+       data->heartbeat_action_interval = MMI_PROTOCOL_HEARTBEAT_ACTION_INTERVAL;
+       data->location_upload_interval = MMI_PROTOCOL_LOCATION_UPLOAD_INTERVAL;
+       data->weather_update_interval = MMI_PROTOCOL_WEATHER_UPDATE_INTERVAL;
+}
+
+#ifdef __MMI_ZHSX_SUPPORT_AUTHENTICATE__
+#include "hal/dm/cJSON.h"
+#include "hal/dm/libhttpclient.h"
+
+//#define MMI_AUTHENTICATE_URL "http://app.api.thisiot.com/dev/device/check"
+#define MMI_AUTHENTICATE_URL "http://iot.api.thisiot.com/dev/device/check"
+
+static struct http_client * s_authenticate_http_client = NULL;
+static struct http_client_list * s_authenticate_http_client_list_header = NULL;
+static uint8_t s_authenticate_http_try_count = 0;
+static char * s_authenticate_http_revceive_buf = NULL;
+
+static char * response_data = NULL;
+static int response_len = 0;
+
+/*
+data: the data is received http context data
+len: the length of http context data 
+num: the http response header "Content-Length" value
+cbdata: user private data
+*/
+static void response_cb(char * data, int len, int num, void *cbdata)
+{
+       char * temp;
+
+       PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: data_len=%d\n", __FUNCTION__, __LINE__, len);
+
+       temp = (void*)malloc(response_len + len);
+       if (NULL == temp)
+       {
+        PROTOCOL_DEBUG_PRINTF("malloc failed\n");
+               return;
+       }
+       memset(temp, 0, response_len + len);
+       if (response_data) {
+               memcpy(temp, response_data, response_len);
+               free(response_data);
+       }
+       memcpy(&temp[response_len], data, len);
+       response_data = temp;
+       response_len += len;
+
+       PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: response_len=%d\n", __FUNCTION__, __LINE__, response_len);
+}
+
+void mmi_authenticate_http_resource_free(void)
+{
+    if(NULL != s_authenticate_http_client_list_header)
+       {
+        http_client_list_destroy(s_authenticate_http_client_list_header);
+        s_authenticate_http_client_list_header = NULL;
+       }
+       
+    if(NULL != s_authenticate_http_client)
+    {
+        http_client_shutdown(s_authenticate_http_client);
+        s_authenticate_http_client = NULL;
+    }
+       
+    if (response_data) 
+        free(response_data);
+       
+       response_data = NULL;
+       response_len = 0;
+}
+
+int mmi_authenticate_http_data(char * url)
+{
+    int response_code= 0;
+    int ret = 0;
+
+       if (NULL != s_authenticate_http_client)
+       {
+               PROTOCOL_DEBUG_PRINTF("client not null\n");
+               ret = -2;
+               goto EXIT;
+       }
+    
+    s_authenticate_http_client = http_client_init();
+    http_client_setopt(s_authenticate_http_client, HTTPCLIENT_OPT_URL, url);    /*set URL:support http/https and ip4/ip6*/
+       http_client_setopt(s_authenticate_http_client, HTTPCLIENT_OPT_HTTP1_0, 0);              /*"0" is HTTP 1.1, "1" is HTTP 1.0*/
+    http_client_setopt(s_authenticate_http_client, HTTPCLIENT_OPT_RESPONSECB, response_cb);     /*response callback*/
+    //http_client_setopt(s_authenticate_http_client, HTTPCLIENT_OPT_RESPONSECB_DATA, private_data);           /*set user private data,*/
+    http_client_setopt(s_authenticate_http_client, HTTPCLIENT_OPT_METHOD, HTTPCLIENT_REQUEST_GET);  /*set method,support GET/POST/PUT*/
+    //http_client_setopt(s_authenticate_http_client, HTTPCLIENT_OPT_POSTDATA, post_data);          /*post data is http context*/
+    //http_client_setopt(s_authenticate_http_client, HTTPCLIENT_OPT_POSTLENGTH, strlen(post_data));           /*http context length*/
+
+       s_authenticate_http_client_list_header = http_client_list_append(s_authenticate_http_client_list_header, "Content-Type: application/json\r\n");
+    s_authenticate_http_client_list_header = http_client_list_append(s_authenticate_http_client_list_header, "Accept: */*\r\n");
+    http_client_setopt(s_authenticate_http_client, HTTPCLIENT_OPT_HTTPHEADER, s_authenticate_http_client_list_header);
+       
+    http_client_getinfo(s_authenticate_http_client, HTTPCLIENT_GETINFO_TCP_STATE, &response_code);
+    if(response_code != HTTP_TCP_ESTABLISHED)
+       {
+        PROTOCOL_DEBUG_PRINTF("http tcp not connecting\n");
+        ret = -1;
+        goto EXIT;
+    }
+       
+    response_code = http_client_perform(s_authenticate_http_client);    /*execute http send and recv*/
+    if(response_code != HTTP_CLIENT_OK)
+       {
+        PROTOCOL_DEBUG_PRINTF("http perform have some wrong=%d\n", response_code);
+        ret = -3;
+        goto EXIT;
+       }
+       
+    http_client_getinfo(s_authenticate_http_client, HTTPCLIENT_GETINFO_RESPONSE_CODE, &response_code);
+    if (response_code != 200 && response_code != 204)
+       {
+        PROTOCOL_DEBUG_PRINTF("response is not 'HTTP OK'=%d\n", response_code);
+    }
+       
+       if(NULL != s_authenticate_http_revceive_buf)
+       {
+               lv_mem_free(s_authenticate_http_revceive_buf);
+               s_authenticate_http_revceive_buf = NULL;
+       }
+       s_authenticate_http_revceive_buf = lv_mem_alloc(response_len + 1);
+    if(NULL == s_authenticate_http_revceive_buf)
+       {
+        PROTOCOL_DEBUG_PRINTF("malloc failed\n");
+        ret = -4;
+        goto EXIT;
+       }
+       _lv_memset_00(s_authenticate_http_revceive_buf, response_len + 1);
+       _lv_memcpy(s_authenticate_http_revceive_buf, response_data, response_len);
+       PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: data_len=%d\n", __FUNCTION__, __LINE__, response_len);
+
+EXIT:
+       mmi_authenticate_http_resource_free();
+       
+    return ret;
+}
+
+void mmi_watch_authenticate_action(void)
+{
+       PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+       
+       int ret_value = 0;
+       char url[256] = {0};
+       char * bid = mmi_protocol_device_name_get();
+       char * key = mmi_protocol_md5_key_str_get();
+       char rand_str[32 + 1] = {0};
+       char md5_input[256] = {0};
+       unsigned char output[16] = {0};
+       char md5_output[32 + 1] = {0};
+
+       char imei[16 + 1] = {0};
+       app_adp_get_imei_req(imei);
+
+       srand(Hal_Timer_Get_Counter());
+       sprintf(rand_str, "%032d", rand());
+
+       sprintf(md5_input, "%s*%s*%s*%s", imei, bid, rand_str, key); // imei*bid*sonce*key
+       mbedtls_md5_ret(md5_input, strlen(md5_input), output);
+       for(int i = 0; i < 16; i++)
+       {
+               sprintf(&md5_output[i*2], "%02x", output[i]);
+       }
+
+       // url
+       sprintf(url, "%s?imei=%s&bid=%s&sonce=%s&sign=%s", MMI_AUTHENTICATE_URL, imei, bid, rand_str, md5_output);
+       
+       s_authenticate_http_try_count = 0;
+       while(1)
+       {
+               s_authenticate_http_try_count++;
+
+               int ret = mmi_authenticate_http_data(url);
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: ret=%d\n", __FUNCTION__, __LINE__, ret);
+               //cplog_printf("[@CHENG_DEBUG][%s][%d]: ret=%d\n", __FUNCTION__, __LINE__, ret);
+               if(0 == ret)
+               {
+                       PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+                       ret_value = 0;
+                       break;
+               }
+               else
+               {
+                       if(3 <= s_authenticate_http_try_count)
+                       {
+                               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+                               mmi_authenticate_http_resource_free();
+                               ret_value = -1;
+                               break;
+                       }
+                       
+                       uos_sleep(10);
+               }
+       }
+
+       if(0 == ret_value)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: %d\n", __FUNCTION__, __LINE__, strlen(s_authenticate_http_revceive_buf));
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG]: %s\n", s_authenticate_http_revceive_buf);
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG]: %s\n", s_authenticate_http_revceive_buf + 100);
+               //cplog_printf("[@CHENG_DEBUG][%d]: %s\n", __LINE__, s_authenticate_http_revceive_buf);
+               //cplog_printf("[@CHENG_DEBUG]: %s\n", s_authenticate_http_revceive_buf + 100);
+               
+               cJSON * json_recv = cJSON_Parse(s_authenticate_http_revceive_buf);
+               if(NULL != json_recv)
+               {
+                       if(cJSON_IsTrue(cJSON_GetObjectItem(json_recv, "success"))) // "isSuccess"
+                       {
+                               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: true\n", __FUNCTION__, __LINE__);
+                               //cplog_printf("[@CHENG_DEBUG][%s][%d]: true\n", __FUNCTION__, __LINE__);
+                               
+                               cJSON * json_data = cJSON_GetObjectItem(json_recv, "data");
+                               if(NULL != json_data)
+                               {
+                                       char * bid = cJSON_GetStringValue(cJSON_GetObjectItem(json_data, "bid"));
+                                       //PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: bid=%s\n", __FUNCTION__, __LINE__, bid);
+                                       if(NULL != bid && 0 != strlen(bid))
+                                               mmi_protocol_device_name_set(bid);
+
+                                       char * key = cJSON_GetStringValue(cJSON_GetObjectItem(json_data, "secretKey"));
+                                       //PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: key=%s\n", __FUNCTION__, __LINE__, key);
+                                       if(NULL != key && 0 != strlen(key))
+                                               mmi_protocol_md5_key_str_set(key);
+                                       
+                                       char * host = cJSON_GetStringValue(cJSON_GetObjectItem(json_data, "host"));
+                                       //PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: host=%s\n", __FUNCTION__, __LINE__, host);
+                                       if(NULL != host && 0 != strlen(host))
+                                               mmi_watch_host_name_set(host);
+                                       
+                                       int port = cJSON_GetIntValue(cJSON_GetObjectItem(json_data, "port"));
+                                       //PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: port=%d\n", __FUNCTION__, __LINE__, port);
+                                       if(0 < port)
+                                               mmi_watch_host_port_set(port);
+                               }
+
+                               mmi_watch_authenticate_flag_set(1);
+                               mmi_launcher_tcp_first_connect(0);
+                       }
+                       else
+                       {
+                               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: false\n", __FUNCTION__, __LINE__);
+                               //cplog_printf("[@CHENG_DEBUG][%s][%d]: false\n", __FUNCTION__, __LINE__);
+                       }
+               }
+               else
+               {
+                       PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: not json file\n", __FUNCTION__, __LINE__);
+               }
+               
+               if(NULL != json_recv)
+               {
+                       PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: free json root\n", __FUNCTION__, __LINE__);
+                       cJSON_Delete(json_recv);
+                       json_recv = NULL;
+               }
+       }
+       
+       if(NULL != s_authenticate_http_revceive_buf)
+       {
+               lv_mem_free(s_authenticate_http_revceive_buf);
+               s_authenticate_http_revceive_buf = NULL;
+       }
+}
+
+uint8_t mmi_watch_authenticate_flag_get(void)
+{
+       return (s_watch_protocol_data.authenticate_flag);
+}
+
+void mmi_watch_authenticate_flag_set(uint8_t flag)
+{
+       s_watch_protocol_data.authenticate_flag = flag;
+       mmi_watch_protocol_data_nv_write();
+}
+#endif
+
+char * mmi_watch_host_name_get(void)
+{
+       return (s_watch_protocol_data.watch_host_name);
+}
+
+void mmi_watch_host_name_set(char * ip_address)
+{
+       if(NULL == ip_address || 0 == strlen(ip_address))
+               return;
+       if(NV_WATCH_HOST_NAME_LEN_MAX <= strlen(ip_address))
+               return;
+       
+       _lv_memset_00(s_watch_protocol_data.watch_host_name, NV_WATCH_HOST_NAME_LEN_MAX);
+       strcpy(s_watch_protocol_data.watch_host_name, ip_address);
+       mmi_watch_protocol_data_nv_write();
+}
+
+int mmi_watch_host_port_get(void)
+{
+       return (s_watch_protocol_data.watch_host_port);
+}
+
+void mmi_watch_host_port_set(int ip_port)
+{
+       if(0 >= ip_port)
+               return;
+       
+       s_watch_protocol_data.watch_host_port = ip_port;
+       mmi_watch_protocol_data_nv_write();
+}
+
+uint8_t mmi_protocol_md5_key_str_len_get(void)
+{
+       return (strlen(s_watch_protocol_data.protocol_md5_key));
+}
+
+char * mmi_protocol_md5_key_str_get(void)
+{
+       return (s_watch_protocol_data.protocol_md5_key);
+}
+
+void mmi_protocol_md5_key_str_set(char * md5_key)
+{
+       if(NULL == md5_key || 0 == strlen(md5_key))
+               return;
+       if(NV_PROTOCOL_MD5_KEY_LEN_MAX <= strlen(md5_key))
+               return;
+       
+       _lv_memset_00(s_watch_protocol_data.protocol_md5_key, NV_PROTOCOL_MD5_KEY_LEN_MAX);
+       strcpy(s_watch_protocol_data.protocol_md5_key, md5_key);
+       mmi_watch_protocol_data_nv_write();
+}
+
+uint8_t mmi_protocol_device_name_len_get(void)
+{
+       return (strlen(s_watch_protocol_data.protocol_device_name));
+}
+
+char * mmi_protocol_device_name_get(void)
+{
+       return (s_watch_protocol_data.protocol_device_name);
+}
+
+void mmi_protocol_device_name_set(char * device_name)
+{
+       if(NULL == device_name || 0 == strlen(device_name))
+               return;
+       if(NV_PROTOCOL_DEVICE_NAME_LEN_MAX <= strlen(device_name))
+               return;
+       
+       _lv_memset_00(s_watch_protocol_data.protocol_device_name, NV_PROTOCOL_DEVICE_NAME_LEN_MAX);
+       strcpy(s_watch_protocol_data.protocol_device_name, device_name);
+       mmi_watch_protocol_data_nv_write();
+}
+
+uint32_t mmi_protocol_watch_heartbeat_action_interval_get(void)
+{
+       return (s_watch_protocol_data.heartbeat_action_interval);
+}
+
+void mmi_protocol_watch_heartbeat_action_interval_set(uint32_t value)
+{
+       s_watch_protocol_data.heartbeat_action_interval = value;
+       mmi_watch_protocol_data_nv_write();
+}
+
+uint32_t mmi_protocol_watch_location_upload_interval_get(void)
+{
+       return (s_watch_protocol_data.location_upload_interval);
+}
+
+void mmi_protocol_watch_location_upload_interval_set(uint32_t value)
+{
+       s_watch_protocol_data.location_upload_interval = ((MMI_WATCH_LOCATION_UPLOAD_INTERVAL_MIN > value) ? MMI_WATCH_LOCATION_UPLOAD_INTERVAL_MIN : value); // value;
+       mmi_watch_protocol_data_nv_write();
+}
+
+uint32_t mmi_protocol_watch_weather_update_interval_get(void)
+{
+       return (s_watch_protocol_data.weather_update_interval);
+}
+
+void mmi_protocol_watch_weather_update_interval_set(uint32_t value)
+{
+       s_watch_protocol_data.weather_update_interval = value;
+       mmi_watch_protocol_data_nv_write();
+}
+
+
+
+static void * s_protocol_timing_timer = NULL;
+TASK_HANDLE * s_protocol_timing_task_id = NULL;
+static uint32_t s_protocol_heartbeat_time_stamp = 0, s_protocol_timed_location_time_stamp = 0, s_protocol_timed_weather_time_stamp = 0;
+static void * s_protocol_location_move_check_timer = NULL;
+static uint8_t s_protocol_location_move_flag = 0;
+static int16_t s_gsensor_chip_x = 0, s_gsensor_chip_y = 0, s_gsensor_chip_z = 0;
+
+#define PROTOCOL_LOCATION_MOVE_CHECK_TIMER_INTERVAL    (2 * 1000) // ms
+
+static void mmi_protocol_timing_timer_callback(uint32_t param);
+static uint8_t mmi_protocol_location_move_state_get(void);
+static void mmi_protocol_location_move_state_set(uint8_t flag);
+static void mmi_protocol_location_move_state_check_cb(uint32_t param);
+
+static void mmi_protocol_timing_task_msg_send(MMI_PROTOCOL_TIMING_MSG_ID_E msg_id, void * msg_param)
+{
+       if(NULL == s_protocol_timing_task_id)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: task not exist\n",__FUNCTION__,__LINE__);
+               if(NULL != msg_param)
+                       Hal_Mem_Free(msg_param);
+               
+               return;
+       }
+       
+       if((PROTOCOL_TIMING_MSG_QUEUE_SIZE - 1) < Hal_Get_Message_Count(s_protocol_timing_task_id))
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: msg queue full\n",__FUNCTION__,__LINE__);
+               if(NULL != msg_param)
+                       Hal_Mem_Free(msg_param);
+               
+               return;
+       }
+
+       PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: msg_id=%d\n",__FUNCTION__,__LINE__, msg_id);
+    mmi_protocol_timing_task_msg_t * msg = Hal_Mem_Alloc(sizeof(mmi_protocol_timing_task_msg_t));
+       if(NULL == msg)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: memory alloc fail\n",__FUNCTION__,__LINE__);
+               if(NULL != msg_param)
+                       Hal_Mem_Free(msg_param);
+               
+               return;
+       }
+       msg->msg_id = msg_id;
+       msg->msg_param = msg_param;
+
+    Hal_Send_Message((TASK_ID)s_protocol_timing_task_id, (void *)msg);
+}
+
+static void mmi_protocol_timing_task_handle(void * param)
+{
+       mmi_protocol_timing_task_msg_t * msg = (mmi_protocol_timing_task_msg_t *)param;
+       MMI_PROTOCOL_TIMING_MSG_ID_E msg_id = msg->msg_id;
+       void * msg_param = msg->msg_param;
+
+       PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: msg_id=%d\n",__FUNCTION__,__LINE__, msg_id);
+    switch(msg_id)
+       {
+               case MMI_PROTOCOL_TIMING_MSG_HEARTBEAT:
+                       mmi_protocol_fzd_action_HEARTBEAT();
+                       break;
+                       
+               case MMI_PROTOCOL_TIMING_MSG_LOCATION_UPDATE:
+                       mmi_protocol_action_location();
+            break;
+                       
+               case MMI_PROTOCOL_TIMING_MSG_WEATHER_UPDATE:
+                       mmi_protocol_action_get_weather();
+            break;
+                       
+               case MMI_PROTOCOL_TIMING_MSG_HEALTH_MEASURE:
+                       #ifdef __MMI_ZHSX_SUPPORT_HEALTH_SENSOR__
+                       uint32_t cur_time_stamp = *((uint32_t *) msg_param);
+                       PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: cur_stamp=%d\n", __FUNCTION__, __LINE__, cur_time_stamp);
+                       mmi_health_measure_timed_mission_action(cur_time_stamp);
+                       #endif
+            break;
+
+               default:
+                       break;
+    }
+}
+
+static void mmi_protocol_timing_task_entry(void * para)
+{
+    while(NULL == s_protocol_timing_task_id)
+       {
+        uos_sleep(10);
+    }
+
+    while(1)
+       {
+        mmi_protocol_timing_task_msg_t * msg = (mmi_protocol_timing_task_msg_t *)Hal_Receive_Message((TASK_ID)s_protocol_timing_task_id, TRUE);
+
+               mmi_protocol_timing_task_handle(msg);
+
+        Hal_Mem_Free(msg->msg_param);
+        Hal_Mem_Free(msg);
+    }
+}
+
+static void mmi_protocol_timing_task_create(void)
+{
+       if(NULL != s_protocol_timing_task_id)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: task_id=0x%x\n",__FUNCTION__,__LINE__, s_protocol_timing_task_id);
+               return;
+       }
+       
+       s_protocol_timing_task_id = uos_create_task(mmi_protocol_timing_task_entry,
+                                                                                       NULL,
+                                                                                       PROTOCOL_TIMING_MSG_QUEUE_SIZE,
+                                                                                       PROTOCOL_TIMING_TASK_STACK_SIZE,
+                                                                                       PROTOCOL_TIMING_TASK_PRIORITY,
+                                                                                       "mmi_protocol_timing_task");
+
+       PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: task_id=0x%x\n",__FUNCTION__,__LINE__, s_protocol_timing_task_id);
+}
+
+static void mmi_protocol_timing_timer_callback(uint32_t param)
+{
+       uint32_t cur_time_stamp = 0;
+
+       Hal_Rtc_Gettime_Count_Utc(&cur_time_stamp);
+       PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: cur_time_stamp=%d\n", __FUNCTION__, __LINE__, cur_time_stamp);
+
+       uos_timer_stop(s_protocol_timing_timer);
+    uos_timer_start(s_protocol_timing_timer, MS_TO_TICKS(PROTOCOL_TIMING_TIMER_INTERVAL), 0, mmi_protocol_timing_timer_callback, NULL);
+
+       // heartbeat
+       if(mmi_protocol_watch_heartbeat_action_interval_get() <= (cur_time_stamp - s_protocol_heartbeat_time_stamp))
+       {
+               mmi_protocol_timing_task_msg_send(MMI_PROTOCOL_TIMING_MSG_HEARTBEAT, NULL);
+               s_protocol_heartbeat_time_stamp = cur_time_stamp;
+       }
+
+       //location
+       if(mmi_protocol_watch_location_upload_interval_get() <= (cur_time_stamp - s_protocol_timed_location_time_stamp))
+       {
+               if(0 != mmi_protocol_location_move_state_get())
+               {
+                       mmi_protocol_timing_task_msg_send(MMI_PROTOCOL_TIMING_MSG_LOCATION_UPDATE, NULL);
+               }
+               s_protocol_timed_location_time_stamp = cur_time_stamp;
+               mmi_protocol_location_move_state_set(0);
+       }
+
+       //weather
+       if(mmi_protocol_watch_weather_update_interval_get() <= (cur_time_stamp - s_protocol_timed_weather_time_stamp))
+       {
+               mmi_protocol_timing_task_msg_send(MMI_PROTOCOL_TIMING_MSG_WEATHER_UPDATE, NULL);
+               s_protocol_timed_weather_time_stamp = cur_time_stamp;
+       }
+
+       //health measure
+#ifdef __MMI_ZHSX_SUPPORT_HEALTH_SENSOR__
+       uint32_t * time_stamp_p = Hal_Mem_Alloc(sizeof(uint32_t));
+       //Hal_Mem_Copy(time_stamp_p, &cur_time_stamp, sizeof(uint32_t));
+       * time_stamp_p = cur_time_stamp;
+       mmi_protocol_timing_task_msg_send(MMI_PROTOCOL_TIMING_MSG_HEALTH_MEASURE, time_stamp_p);
+#endif
+
+}
+
+static uint8_t mmi_protocol_location_move_state_get(void)
+{
+       return s_protocol_location_move_flag;
+}
+
+static void mmi_protocol_location_move_state_set(uint8_t flag)
+{
+       s_protocol_location_move_flag = flag;
+}
+
+static void mmi_protocol_location_move_state_check_cb(uint32_t param)
+{
+       PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+
+       uos_timer_stop(s_protocol_location_move_check_timer);
+    uos_timer_start(s_protocol_location_move_check_timer, MS_TO_TICKS(PROTOCOL_LOCATION_MOVE_CHECK_TIMER_INTERVAL), 0, mmi_protocol_location_move_state_check_cb, NULL);
+
+       if(0 == mmi_protocol_location_move_state_get())
+       {
+               int16_t chip_x = 0, chip_y = 0, chip_z = 0;
+               
+               xMotion_Chip_Read_XYZ(&chip_x, &chip_y, &chip_z);
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: %d,%d,%d/%d,%d,%d\n", __FUNCTION__, __LINE__,
+                                                               chip_x, chip_y, chip_z, s_gsensor_chip_x, s_gsensor_chip_y, s_gsensor_chip_z);
+               if((100 < abs(s_gsensor_chip_x - chip_x)) || (100 < abs(s_gsensor_chip_y - chip_y)) || (100 < abs(s_gsensor_chip_z - chip_z)))
+               {
+                       PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+                       mmi_protocol_location_move_state_set(1);
+               }
+               s_gsensor_chip_x = chip_x;
+               s_gsensor_chip_y = chip_y;
+               s_gsensor_chip_z = chip_z;
+       }
+}
+
+void mmi_protocol_location_move_state_check(void)
+{
+       if(NULL == s_protocol_location_move_check_timer)
+           uos_timer_create(&s_protocol_location_move_check_timer);
+       else
+               uos_timer_stop(s_protocol_location_move_check_timer);
+
+       mmi_protocol_location_move_state_set(0);
+       xMotion_Chip_Read_XYZ(&s_gsensor_chip_x, &s_gsensor_chip_y, &s_gsensor_chip_z);
+    uos_timer_start(s_protocol_location_move_check_timer, MS_TO_TICKS(PROTOCOL_LOCATION_MOVE_CHECK_TIMER_INTERVAL), 0, mmi_protocol_location_move_state_check_cb, NULL);
+}
+
+void mmi_protocol_timing_mission_action(void)
+{
+       mmi_protocol_timing_mission_stop();
+       
+       mmi_protocol_timing_task_create();
+
+       uint32_t cur_time_stamp = 0;
+       
+       Hal_Rtc_Gettime_Count_Utc(&cur_time_stamp);
+       PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: cur_time_stamp=%d\n", __FUNCTION__, __LINE__, cur_time_stamp);
+       
+       mmi_protocol_fzd_action_HEARTBEAT();
+       s_protocol_heartbeat_time_stamp = cur_time_stamp;
+
+       mmi_watch_location_mission_list_init();
+       mmi_protocol_action_location();
+       s_protocol_timed_location_time_stamp = cur_time_stamp;
+       mmi_protocol_location_move_state_check();
+
+       mmi_protocol_action_get_weather();
+       s_protocol_timed_weather_time_stamp = cur_time_stamp;
+
+#ifdef __MMI_ZHSX_SUPPORT_HEALTH_SENSOR__
+       mmi_health_measure_task_init();
+       mmi_health_measure_timed_info_nv_read();
+       mmi_health_measure_first_mission_action(cur_time_stamp);
+#endif
+
+       if(NULL == s_protocol_timing_timer)
+           uos_timer_create(&s_protocol_timing_timer);
+       else
+               uos_timer_stop(s_protocol_timing_timer);
+
+    uos_timer_start(s_protocol_timing_timer, MS_TO_TICKS(PROTOCOL_TIMING_TIMER_INTERVAL), 0, mmi_protocol_timing_timer_callback, NULL);
+}
+
+void mmi_protocol_timing_mission_stop(void)
+{
+       //char info_buf[64] = {0};
+       //sprintf(info_buf, "mmi_protocol_timing_mission_stop");
+       //mmi_debug_info_write_to_file(info_buf);
+       
+       if(NULL != s_protocol_timing_timer)
+       {
+               uos_timer_stop(s_protocol_timing_timer);
+               uos_timer_delete(s_protocol_timing_timer);
+               s_protocol_timing_timer = NULL;
+       }
+
+       if(NULL != s_protocol_location_move_check_timer)
+       {
+               uos_timer_stop(s_protocol_location_move_check_timer);
+               uos_timer_delete(s_protocol_location_move_check_timer);
+               s_protocol_location_move_check_timer = NULL;
+       }
+
+       mmi_watch_location_mission_list_clear();
+       
+#ifdef __MMI_ZHSX_SUPPORT_HEALTH_SENSOR__
+       mmi_health_measure_timed_list_clear();
+#endif
+}
+
+
+
+extern void dm_send_msg_active(void);
+bool mmi_protocol_watch_link_action(void)
+{
+#ifdef __MMI_CUSTOM_HENGAI_HEALTH__
+#ifdef __MMI_CUSTOM_HENGAI_HEALTH_UPLOAD_USE_TCP__
+       mmi_hengai_tcp_algorithm_interface_login_action();
+#else
+       mmi_hengai_algorithm_interface_login_action();
+       mmi_hengai_health_lib_activation_check_action();
+#endif
+#endif
+#if USE_DS_DM
+       dm_send_msg_active();
+#endif
+       return mmi_protocol_fzd_action_LINK();
+}
+
+bool mmi_protocol_check_state_before_send_action(void)
+{
+       if(false == watch_modem_sim_present_check_req()) 
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: no sim\n", __FUNCTION__, __LINE__);
+               return false;
+       }
+    if(MMI_MODEM_SIGNAL_BAR_0 == watch_modem_get_signal_bar_req())
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: no signal\n", __FUNCTION__, __LINE__);
+               return false;
+       }
+       if(false == mmi_watch_tcp_connect_state_get())
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: tcp not connect\n", __FUNCTION__, __LINE__);
+               return false;
+       }
+       if(false == mmi_protocol_watch_bind_state_get())
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: watch not bind\n", __FUNCTION__, __LINE__);
+               return false;
+       }
+
+       return true;
+}
+
+bool mmi_protocol_action_send_temperature(float temp_value)
+{
+       if(false == mmi_protocol_check_state_before_send_action())
+               return false;
+       
+#ifdef __MMI_ZHSX_SUPPORT_HEALTH_SENSOR__
+       return mmi_protocol_fzd_action_send_temperature(temp_value);
+#else
+       return false;
+#endif
+}
+
+bool mmi_protocol_action_send_heart(uint16_t heart_value)
+{
+       if(false == mmi_protocol_check_state_before_send_action())
+               return false;
+       
+#ifdef __MMI_ZHSX_SUPPORT_HEALTH_SENSOR__
+       return mmi_protocol_fzd_action_send_heart(heart_value);
+#else
+       return false;
+#endif
+}
+
+bool mmi_protocol_action_send_blood(uint16_t blood_high_value, uint16_t blood_low_value)
+{
+       if(false == mmi_protocol_check_state_before_send_action())
+               return false;
+       
+#ifdef __MMI_ZHSX_SUPPORT_HEALTH_SENSOR__
+       return mmi_protocol_fzd_action_send_blood(blood_high_value, blood_low_value);
+#else
+       return false;
+#endif
+}
+
+bool mmi_protocol_action_send_spo2(uint16_t spo2_value)
+{
+       if(false == mmi_protocol_check_state_before_send_action())
+               return false;
+       
+#ifdef __MMI_ZHSX_SUPPORT_HEALTH_SENSOR__
+       return mmi_protocol_fzd_action_send_spo2(spo2_value);
+#else
+       return false;
+#endif
+}
+
+bool mmi_protocol_action_send_talk(char * data_buff, int data_buff_len)
+{
+       if(false == mmi_protocol_check_state_before_send_action())
+               return false;
+       
+#ifdef __MMI_WECHAT_SUPPORT__
+       return mmi_protocol_fzd_ACTION_TALK(data_buff, data_buff_len);
+#else
+       return false;
+#endif
+}
+
+bool mmi_protocol_action_send_photo(uint8_t type, char * time_str, char * data_buff, int data_buff_len)
+{
+#if USE_LV_WATCH_CAMERA
+       if(false == mmi_protocol_check_state_before_send_action())
+               return false;
+       
+       return mmi_protocol_fzd_action_send_photo(type, time_str, data_buff, data_buff_len);
+#endif
+}
+
+bool mmi_protocol_action_send_location(MMI_WATCH_LOCATION_DATA_T * location_data)
+{
+       if(false == mmi_protocol_check_state_before_send_action())
+               return false;
+       
+       return mmi_protocol_fzd_action_send_location(location_data);
+}
+
+bool mmi_protocol_action_location(void)
+{
+       if(0 == mmi_timing_location_switch_get())
+               return false;
+       
+    mmi_watch_location_mission_timed_location_action();
+       return true;
+}
+
+bool mmi_protocol_action_send_cur_location(MMI_WATCH_LOCATION_DATA_T * location_data)
+{
+       if(false == mmi_protocol_check_state_before_send_action())
+               return false;
+       
+       return mmi_protocol_fzd_action_send_cur_location(location_data);
+}
+
+bool mmi_protocol_action_send_get_weather(MMI_WATCH_LOCATION_DATA_T * location_data)
+{
+       if(false == mmi_protocol_check_state_before_send_action())
+               return false;
+       
+       return mmi_protocol_fzd_action_send_get_weather(location_data);
+}
+
+bool mmi_protocol_action_get_weather(void)
+{
+    mmi_watch_location_mission_get_weather_action();
+       return true;
+}
+
+bool mmi_protocol_action_send_warning_info(MMI_WATCH_LOCATION_DATA_T * location_data)
+{
+       if(false == mmi_protocol_check_state_before_send_action())
+               return false;
+       
+       return mmi_protocol_fzd_action_send_warning_info(location_data);
+}
+
+bool mmi_protocol_action_sos(void)
+{
+       mmi_protocol_fzd_set_warning_info(MMI_FZD_WARNING_TYPE_SOS, true);
+       return true;
+}
+
+bool mmi_protocol_action_low_battery(void)
+{
+       if(0 == mmi_low_battery_switch_get())
+               return false;
+       
+       mmi_protocol_fzd_set_warning_info(MMI_FZD_WARNING_TYPE_LOW_BATTERY, true);
+       return true;
+}
+
+bool mmi_protocol_action_take_off(void)
+{
+       if(0 == mmi_take_off_switch_get())
+               return false;
+       
+       mmi_protocol_fzd_set_warning_info(MMI_FZD_WARNING_TYPE_TAKE_OFF, true);
+       return true;
+}
+
+bool mmi_protocol_action_take_on(void)
+{
+       if(0 == mmi_take_off_switch_get())
+               return false;
+       
+       mmi_protocol_fzd_set_warning_info(MMI_FZD_WARNING_TYPE_TAKE_ON, true);
+       return true;
+}
+
+bool mmi_protocol_action_fall_down(void)
+{
+       if(0 == mmi_fall_down_switch_get())
+               return false;
+       
+       mmi_protocol_fzd_set_warning_info(MMI_FZD_WARNING_TYPE_FALL_DOWN, true);
+       return true;
+}
+
+bool mmi_protocol_action_unbind(void)
+{
+       mmi_protocol_fzd_action_unbind();
+       return true;
+}
+
+
+
+
+
+
+#endif
+
+
diff --git a/2.sdk/sdk/gui/lv_watch/mmi_protocol/mmi_protocol_api.h b/2.sdk/sdk/gui/lv_watch/mmi_protocol/mmi_protocol_api.h
new file mode 100644 (file)
index 0000000..4fb5276
--- /dev/null
@@ -0,0 +1,129 @@
+
+
+
+#ifndef __MMI_PROTOCOL_API_H__
+#define __MMI_PROTOCOL_API_H__
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif //__cplusplus
+
+#ifdef LV_CONF_INCLUDE_SIMPLE
+#include "lvgl.h"
+#include "lv_watch_conf.h"
+#else
+#include "../../../lvgl/lvgl.h"
+#include "../../../lv_watch_conf.h"
+#endif
+
+#ifdef __MMI_ZHSX_SUPPORT__
+
+
+#define __MMI_PROTOCOL_DEBUG__
+#ifdef __MMI_PROTOCOL_DEBUG__
+#define PROTOCOL_DEBUG_PRINTF(fmt, ...)        printf("[PROTOCOL]"fmt, ##__VA_ARGS__)
+#else
+#define PROTOCOL_DEBUG_PRINTF(fmt, ...)
+#endif
+
+
+#define PROTOCOL_TIMING_TIMER_INTERVAL (20 * 1000) // ms
+
+#define PROTOCOL_TIMING_TASK_PRIORITY 220
+#define PROTOCOL_TIMING_TASK_STACK_SIZE (10 * 1024)
+#define PROTOCOL_TIMING_MSG_QUEUE_SIZE (64)
+
+
+typedef enum
+{
+       MMI_PROTOCOL_TIMING_MSG_ID_START,
+
+    MMI_PROTOCOL_TIMING_MSG_HEARTBEAT,
+       MMI_PROTOCOL_TIMING_MSG_LOCATION_UPDATE,
+    MMI_PROTOCOL_TIMING_MSG_WEATHER_UPDATE,
+       MMI_PROTOCOL_TIMING_MSG_HEALTH_MEASURE,
+
+    MMI_PROTOCOL_TIMING_MSG_ID_END
+}MMI_PROTOCOL_TIMING_MSG_ID_E;
+
+
+typedef struct
+{
+       uint16_t msg_id;
+       void * msg_param;
+}mmi_protocol_timing_task_msg_t;
+
+
+
+
+bool mmi_watch_tcp_connect_state_get(void);
+
+bool mmi_protocol_watch_bind_state_get(void);
+void mmi_protocol_watch_bind_state_set(bool state);
+
+void mmi_protocol_receive_data_process(char * recv_str, int recv_len);
+void * mmi_protocol_send_space_ptr_get(int cmd);
+int mmi_protocol_send_space_size_get(int cmd);
+void mmi_protocol_send_space_free(int cmd);
+bool mmi_protocol_send_cmd_check(int cmd);
+
+void mmi_watch_protocol_data_nv_read(void);
+void mmi_watch_protocol_data_nv_default(nv_watch_protocol_data_t * data);
+
+#ifdef __MMI_ZHSX_SUPPORT_AUTHENTICATE__
+uint8_t mmi_watch_authenticate_flag_get(void);
+void mmi_watch_authenticate_flag_set(uint8_t flag);
+void mmi_watch_authenticate_action(void);
+#endif
+char * mmi_watch_host_name_get(void);
+void mmi_watch_host_name_set(char * ip_address);
+int mmi_watch_host_port_get(void);
+void mmi_watch_host_port_set(int ip_port);
+uint8_t mmi_protocol_md5_key_str_len_get(void);
+char * mmi_protocol_md5_key_str_get(void);
+void mmi_protocol_md5_key_str_set(char * md5_str);
+uint8_t mmi_protocol_device_name_len_get(void);
+char * mmi_protocol_device_name_get(void);
+void mmi_protocol_device_name_set(char * device_name);
+
+void mmi_protocol_timing_mission_action(void);
+void mmi_protocol_timing_mission_stop(void);
+
+bool mmi_protocol_watch_link_action(void);
+
+bool mmi_protocol_action_send_temperature(float temp_value);
+bool mmi_protocol_action_send_heart(uint16_t heart_value);
+bool mmi_protocol_action_send_blood(uint16_t blood_high_value, uint16_t blood_low_value);
+bool mmi_protocol_action_send_spo2(uint16_t spo2_value);
+
+bool mmi_protocol_action_send_talk(char * data_buff, int data_buff_len);
+
+bool mmi_protocol_action_send_location(MMI_WATCH_LOCATION_DATA_T * location_data);
+
+bool mmi_protocol_action_send_cur_location(MMI_WATCH_LOCATION_DATA_T * location_data);
+
+bool mmi_protocol_action_send_get_weather(MMI_WATCH_LOCATION_DATA_T * location_data);
+
+bool mmi_protocol_action_get_weather(void);
+
+bool mmi_protocol_action_send_warning_info(MMI_WATCH_LOCATION_DATA_T * location_data);
+
+bool mmi_protocol_action_sos(void);
+bool mmi_protocol_action_low_battery(void);
+bool mmi_protocol_action_take_off(void);
+bool mmi_protocol_action_take_on(void);
+bool mmi_protocol_action_fall_down(void);
+
+bool mmi_protocol_action_unbind(void);
+
+
+#endif
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif //__cplusplus
+
+#endif
+
+
diff --git a/2.sdk/sdk/gui/lv_watch/mmi_protocol/mmi_protocol_fzd.c b/2.sdk/sdk/gui/lv_watch/mmi_protocol/mmi_protocol_fzd.c
new file mode 100644 (file)
index 0000000..9da41cd
--- /dev/null
@@ -0,0 +1,3929 @@
+
+
+
+#include "lv_watch.h"
+
+#ifdef __MMI_ZHSX_SUPPORT_FZD__
+
+#if defined(MBEDTLS_MD5_C)
+//#include "mbedtls/md5.h"
+#include "../../../../product/craneg_modem/pcac/mbedtls/include/mbedtls/md5.h"
+#endif
+
+// action key string & action case parse
+#include "mmi_protocol_fzd_content.c"
+
+
+static uint8_t s_fzd_time_data_flag = 0;
+static MMI_PROTOCOL_FZD_SEND_SPACE_STRUCT s_send_space_struct[MMI_FZD_ACTION_MAX] = {0};
+static MMI_PROTOCOL_FZD_RECEIVE_SPACE_STRUCT s_receive_space_struct = {0};
+
+
+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);
+
+
+void mmi_protocol_fzd_action_UP_REMIND(app_adaptor_alarm_t *alarm,uint_8 count)
+{
+       
+       MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_SEND_UP_REMIND;
+       char  content_buff[128]={0};
+       unsigned int content_lenth = 0;
+    //app_adaptor_alarm_t *alarm = alarm_get_alarm();
+       int send_t[3]={0};
+    char send_buf[3][8]={{0},{0},{0}};
+       int flag_1=1;
+       int flag_2=1;
+    for(uint8_t i = 0; i < count; i++) {
+               flag_1=1;
+               flag_2=1;
+       for(int j=0;j<7;j++)
+       {
+            if(((alarm[i].repeat_bitmap >> j) & 0x01))
+            {
+                send_buf[i][j]='1';
+                               flag_1=0;
+            }
+            else
+            {
+                send_buf[i][j]='0';
+                               flag_2=0;
+            }
+       }
+               if(flag_1==0 && flag_1==0)
+               {
+                       send_t[i]=3;
+               }
+               else if(flag_1==1)
+               {
+                       send_t[i]=1;
+               }
+               else if(flag_2==1)
+               {
+                       send_t[i]=2;
+               }
+       send_buf[i][7]='\0';
+       
+    }
+    /*??:[XT*334588000000156*0018*UP_REMIND,] "08:10-1-1,08:10-1-2,08:10-1-3-0111110"*/
+       char buf[128]={0};
+       sprintf(buf,"%02d:%02d-%d-%d-%s",alarm[0].hour,alarm[0].min,alarm[0].valid,alarm[0].on_off,send_buf[0]);
+       printf("%d\n",strlen(buf));
+       sprintf(content_buff,
+    ",%02d:%02d-%d-%d-%s,%02d:%02d-%d-%d-%s,%02d:%02d-%d-%d-%s",
+    alarm[0].hour,alarm[0].min,alarm[0].on_off,send_t[0],send_buf[0],
+    alarm[1].hour,alarm[1].min,alarm[1].on_off,send_t[1],send_buf[1],
+    alarm[2].hour,alarm[2].min,alarm[2].on_off,send_t[2],send_buf[2]     
+    );
+       content_lenth =strlen(content_buff);
+
+       printf("up_data:%d,%s\n",content_lenth,content_buff);  
+       mmi_protocol_fzd_send_with_data(action, content_buff,content_lenth);
+       //lv_mem_free(content_buff);
+
+
+}
+
+
+//
+// XX*IMEI*LEN*ACTION
+//
+int mmi_protocol_fzd_convert_md5_data_get(MMI_PROTOCOL_FZD_ACTION_ENUM action, int content_len, unsigned char * convert_md5_str)
+{
+       int out_len = 0;
+       
+       if(NULL == convert_md5_str)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               
+               return out_len;         
+       }
+
+       unsigned char action_str[MMI_PROTOCOL_FZD_ACTION_STR_LEN_MAX + 1] = {0};
+       int action_str_len = 0;
+       strncpy(action_str, mmi_protocol_fzd_action_string_get(action), MMI_PROTOCOL_FZD_ACTION_STR_LEN_MAX);
+       action_str_len = strlen(action_str);
+
+       //device name
+       sprintf(convert_md5_str, "%s", mmi_protocol_device_name_get());
+
+       //separator
+       strncat(convert_md5_str, MMI_PROTOCOL_FZD_SEPARATOR, MMI_PROTOCOL_FZD_SEPARATOR_LEN);
+       
+       //deviece id
+    char imei[16] = {0};
+       app_adp_get_imei_req(imei);
+       strncat(convert_md5_str, imei, strlen(imei));
+       
+       //separator
+       strncat(convert_md5_str, MMI_PROTOCOL_FZD_SEPARATOR, MMI_PROTOCOL_FZD_SEPARATOR_LEN);
+
+       //content len
+       char full_content_len_str[8] = {0};
+       int full_content_len = action_str_len + content_len;
+       sprintf(full_content_len_str, "%04X", full_content_len);
+       strncat(convert_md5_str, full_content_len_str, strlen(full_content_len_str));
+
+       //separator
+       strncat(convert_md5_str, MMI_PROTOCOL_FZD_SEPARATOR, MMI_PROTOCOL_FZD_SEPARATOR_LEN);
+       
+       //action key
+       strncat(convert_md5_str, action_str, action_str_len);
+       
+       //total len
+       out_len = strlen(convert_md5_str);
+
+       PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: out_len=%d\n", __FUNCTION__, __LINE__, out_len);
+       
+       return out_len;
+}
+
+//
+// [XX*IMEI*LEN*ACTION,CONTENT] + MD5_KEY
+// XX*IMEI*LEN*ACTIONMD5_KEY -> md5_data
+//
+bool mmi_protocol_fzd_send_content_md5_data_get(unsigned char * input_buff, int input_len, unsigned char * output_md5_buff)
+{
+       bool result = false;
+       unsigned char output[16] = {0};
+       int temp_len = mmi_protocol_md5_key_str_len_get() + input_len + 1;
+       unsigned char * temp_buff = lv_mem_alloc(temp_len);
+
+       if(NULL == temp_buff)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: memory alloc fail\n", __FUNCTION__, __LINE__);
+               
+               result = false;         
+       }
+       else
+       {
+               _lv_memset_00(temp_buff, temp_len);
+               _lv_memcpy(temp_buff, input_buff, input_len);
+               _lv_memcpy(temp_buff + input_len, mmi_protocol_md5_key_str_get(), mmi_protocol_md5_key_str_len_get());
+               mbedtls_md5_ret(temp_buff, temp_len - 1, output);
+               for(int i = 0; i < 16; i++)
+               {
+                       sprintf(&output_md5_buff[i*2], "%02x", output[i]);
+               }
+               lv_mem_free(temp_buff);
+               result = true;  
+       }
+
+       return result;
+}
+
+void * mmi_protocol_fzd_send_space_ptr_get(MMI_PROTOCOL_FZD_ACTION_ENUM action)
+{
+       return (s_send_space_struct[action].ptr);
+}
+
+int mmi_protocol_fzd_send_space_size_get(MMI_PROTOCOL_FZD_ACTION_ENUM action)
+{
+       return (s_send_space_struct[action].size);
+}
+
+void * mmi_protocol_fzd_send_space_init(MMI_PROTOCOL_FZD_ACTION_ENUM action, int size)
+{
+    if (NULL != s_send_space_struct[action].ptr)
+    {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: action=%d is busy\n", __FUNCTION__, __LINE__, action);
+        return NULL;
+    }
+
+       s_send_space_struct[action].ptr = (void *)lv_mem_alloc(size);
+       if(NULL == s_send_space_struct[action].ptr)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__, action);
+               
+               s_send_space_struct[action].size = 0;
+               return NULL;
+       }
+       s_send_space_struct[action].size = size;
+
+       PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: ptr=0x%x\n", __FUNCTION__, __LINE__, s_send_space_struct[action].ptr);
+
+       return (s_send_space_struct[action].ptr);
+}
+
+void mmi_protocol_fzd_send_space_deinit(MMI_PROTOCOL_FZD_ACTION_ENUM action)
+{
+    if (NULL != s_send_space_struct[action].ptr)
+    {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: action=%d,ptr=0x%x\n", __FUNCTION__, __LINE__, action, s_send_space_struct[action].ptr);
+       lv_mem_free(s_send_space_struct[action].ptr);
+               s_send_space_struct[action].ptr = NULL;
+               s_send_space_struct[action].size = 0;
+    }
+}
+
+bool mmi_protocol_fzd_send_cmd_check(MMI_PROTOCOL_FZD_ACTION_ENUM action)
+{
+       if(MMI_FZD_ACTION_NONE >= action || MMI_FZD_ACTION_MAX <= action)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: action=%d\n", __FUNCTION__, __LINE__, action);
+               return false;
+       }
+       
+       return true;
+}
+
+void mmi_protocol_fzd_send_action_do(MMI_PROTOCOL_FZD_ACTION_ENUM action)
+{
+       PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: action=%d\n", __FUNCTION__, __LINE__, action);
+       
+       send_tcp_cmdmsg(action, NULL);
+
+       //mmi_modem_tcp_send(send_space_ptr, send_space_size);
+       //mmi_protocol_fzd_send_space_deinit(action);
+}
+
+// [MD5_DATADEVICE_NAME*DEVICE_ID*CONTENT_LEN*ACTION_STRING,ACTION_CONTENT]
+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;
+       unsigned char convert_md5_str[96] = {0}; // XX*IMEI*LEN*ACTION
+       int convert_md5_str_len = 0;
+       unsigned char md5_data_str[MMI_PROTOCOL_FZD_MD5_DATA_LEN + 1] = {0};
+
+       if((false == watch_modem_sim_present_check_req())
+               || (MMI_MODEM_SIGNAL_BAR_0 == watch_modem_get_signal_bar_req())
+               || (false == mmi_watch_tcp_connect_state_get())
+               )
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               return false;
+       }
+    
+    if(NULL == content_ptr)
+    {
+        content_len = 0;
+    }
+
+       //convert md5 data
+       convert_md5_str_len = mmi_protocol_fzd_convert_md5_data_get(action, content_len, convert_md5_str);
+
+       //md5 data
+       if(false == mmi_protocol_fzd_send_content_md5_data_get(convert_md5_str, convert_md5_str_len, md5_data_str))
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               
+               return false;
+       }
+
+       //init send space
+       send_space_size = MMI_PROTOCOL_FZD_BRACKET_LEN * 2 + MMI_PROTOCOL_FZD_MD5_DATA_LEN + convert_md5_str_len + content_len;
+       send_space_ptr = (unsigned char *)mmi_protocol_fzd_send_space_init(action, send_space_size);
+       if(NULL == send_space_ptr)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               
+               mmi_protocol_fzd_send_space_deinit(action);
+               return false;
+       }
+
+       //fill full send content
+       _lv_memcpy(send_space_ptr, MMI_PROTOCOL_FZD_HEAD_BRACKET, MMI_PROTOCOL_FZD_BRACKET_LEN);
+       curr_offset += MMI_PROTOCOL_FZD_BRACKET_LEN;
+
+       _lv_memcpy(send_space_ptr + curr_offset, md5_data_str, MMI_PROTOCOL_FZD_MD5_DATA_LEN);
+       curr_offset += MMI_PROTOCOL_FZD_MD5_DATA_LEN;
+
+       _lv_memcpy(send_space_ptr + curr_offset, convert_md5_str, convert_md5_str_len);
+       curr_offset += convert_md5_str_len;
+
+       if(0 != content_len)
+       {
+               _lv_memcpy(send_space_ptr + curr_offset, content_ptr, content_len);
+               curr_offset += content_len;
+       }
+
+       _lv_memcpy(send_space_ptr + curr_offset, MMI_PROTOCOL_FZD_TAIL_BRACKET, MMI_PROTOCOL_FZD_BRACKET_LEN);
+       curr_offset += MMI_PROTOCOL_FZD_BRACKET_LEN;
+
+       mmi_protocol_fzd_send_action_do(action);
+
+       return true;
+}
+
+static uint32_t mmi_protocol_fzd_receive_data_fixed_len_get(void)
+{
+       uint32_t t_len = 0;
+       
+       // receive fixed:[DEVICE_NAME*DEVICE_ID*CONTENT_LENGTH*]
+       t_len = (MMI_PROTOCOL_FZD_BRACKET_LEN * 2 + mmi_protocol_device_name_len_get()
+                               + MMI_PROTOCOL_FZD_SEPARATOR_LEN * 3 + MMI_PROTOCOL_FZD_DEVICE_ID_LEN
+                               + MMI_PROTOCOL_FZD_CONTENT_LEN_LEN);
+
+       PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: %d\n", __FUNCTION__, __LINE__, t_len);
+
+       return t_len;
+}
+
+void mmi_protocol_fzd_receive_buff_free(void)
+{
+       s_receive_space_struct.receive_len = 0;
+       if(NULL != s_receive_space_struct.receive_ptr)
+       {
+               lv_mem_free(s_receive_space_struct.receive_ptr);
+               s_receive_space_struct.receive_ptr = NULL;
+       }
+}
+
+void mmi_protocol_fzd_incomplete_buff_free(void)
+{
+       s_receive_space_struct.incomplete_len = 0;
+       if(NULL != s_receive_space_struct.incomplete_ptr)
+       {
+               lv_mem_free(s_receive_space_struct.incomplete_ptr);
+               s_receive_space_struct.incomplete_ptr = NULL;
+       }
+}
+
+void mmi_protocol_fzd_incomplete_buff_store(unsigned char * recv_buffer, int recv_len)
+{
+       if(NULL == recv_buffer || 0 == recv_len)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               return;
+       }
+       
+       s_receive_space_struct.incomplete_ptr = lv_mem_alloc(recv_len);
+       if(NULL != s_receive_space_struct.incomplete_ptr)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: incomplete_ptr=0x%x\n", __FUNCTION__, __LINE__, s_receive_space_struct.incomplete_ptr);
+               _lv_memcpy(s_receive_space_struct.incomplete_ptr, recv_buffer, recv_len);
+               s_receive_space_struct.incomplete_len = recv_len;
+       }
+}
+
+bool mmi_protocol_fzd_receive_buff_store(unsigned char * recv_buffer, int recv_len)
+{
+       bool result = false;
+       unsigned char * temp_ptr = NULL;
+       
+       //PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: receive_ptr=0x%x\n", __FUNCTION__, __LINE__, s_receive_space_struct.receive_ptr);
+       
+       if(NULL == recv_buffer || 0 == recv_len)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: receive data is null\n", __FUNCTION__, __LINE__);
+               mmi_protocol_fzd_receive_buff_free();
+       }
+       else if(NULL != s_receive_space_struct.incomplete_ptr && 0 != s_receive_space_struct.incomplete_len)
+       {
+               temp_ptr = lv_mem_alloc(recv_len + s_receive_space_struct.incomplete_len);
+               if (NULL != temp_ptr)
+               {
+                       PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: temp_ptr=0x%x\n", __FUNCTION__, __LINE__, temp_ptr);
+                       _lv_memset_00(temp_ptr, (recv_len + s_receive_space_struct.incomplete_len));
+                       _lv_memcpy(temp_ptr, s_receive_space_struct.incomplete_ptr, s_receive_space_struct.incomplete_len);
+                       _lv_memcpy(temp_ptr + s_receive_space_struct.incomplete_len, recv_buffer, recv_len);
+
+                       mmi_protocol_fzd_receive_buff_free();
+                       s_receive_space_struct.receive_ptr = temp_ptr;
+                       s_receive_space_struct.receive_len = (recv_len + s_receive_space_struct.incomplete_len);
+                       mmi_protocol_fzd_incomplete_buff_free();
+                       result = true;
+               }
+               else
+               {
+                       PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+                       mmi_protocol_fzd_incomplete_buff_free();
+                       mmi_protocol_fzd_receive_buff_free();
+               }
+       }
+       else
+       {
+               temp_ptr = lv_mem_alloc(recv_len);
+               if (NULL != temp_ptr)
+               {
+                       PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: temp_ptr=0x%x\n", __FUNCTION__, __LINE__, temp_ptr);
+                       _lv_memset_00(temp_ptr, recv_len);
+                       _lv_memcpy(temp_ptr, recv_buffer, recv_len);
+                       mmi_protocol_fzd_receive_buff_free();
+                       s_receive_space_struct.receive_ptr = temp_ptr;
+                       s_receive_space_struct.receive_len = recv_len;
+                       result = true;
+               }
+               else
+               {
+                       PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+                       mmi_protocol_fzd_receive_buff_free();
+               }
+       }
+       
+       return result;
+}
+
+bool mmi_protocol_fzd_receive_data_parse(void)
+{
+       bool result = false;
+       unsigned char* recv_buffer = s_receive_space_struct.receive_ptr;
+       int recv_len = s_receive_space_struct.receive_len;
+       uint32_t recv_fixed_len = mmi_protocol_fzd_receive_data_fixed_len_get();
+    char imei[16] = {0};
+       uint8_t i = 0;
+       unsigned char * content_ptr = NULL;
+       unsigned char * content_len_ptr = NULL;
+       int content_len = 0;
+       int offset_head_bracket = 0, offset_device_name = 0, offset_first_sep = 0, offset_device_id = 0, 
+                       offset_second_sep = 0, offset_content_len = 0, offset_third_sep = 0, offset_tail_bracket = 0;
+       
+       PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+       PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%d]: len=%d, buff=%s\n", __LINE__, recv_len, recv_buffer);
+       
+       //check
+       if(NULL == recv_buffer || 0 == recv_len)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: buffer receive error\n", __FUNCTION__, __LINE__);
+               mmi_protocol_fzd_receive_buff_free();
+               return false;
+       }
+
+       //length
+       if(recv_fixed_len > recv_len)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: data length error\n", __FUNCTION__, __LINE__);
+               mmi_protocol_fzd_incomplete_buff_store(recv_buffer, recv_len);
+               mmi_protocol_fzd_receive_buff_free();
+               return false;
+       }
+
+       // [DEVICE_NAME*DEVICE_ID*CONTENT_LEN*ACTION_STRING,ACTION_CONTENT]
+       offset_head_bracket = 0;
+       offset_device_name = offset_head_bracket + MMI_PROTOCOL_FZD_BRACKET_LEN;
+       offset_first_sep = offset_device_name + mmi_protocol_device_name_len_get();
+       offset_device_id = offset_first_sep + MMI_PROTOCOL_FZD_SEPARATOR_LEN;
+       offset_second_sep = offset_device_id + MMI_PROTOCOL_FZD_DEVICE_ID_LEN;
+       offset_content_len = offset_second_sep + MMI_PROTOCOL_FZD_SEPARATOR_LEN;
+       offset_third_sep = offset_content_len + MMI_PROTOCOL_FZD_CONTENT_LEN_LEN;
+       
+       app_adp_get_imei_req(imei);
+
+       //head
+       for(i = 0; (NULL != (recv_buffer + i)) && (i < recv_len - recv_fixed_len); i++)
+       {
+               if(0 == strncmp(recv_buffer + i + offset_head_bracket, MMI_PROTOCOL_FZD_HEAD_BRACKET, MMI_PROTOCOL_FZD_BRACKET_LEN) // [
+                       && (0 == strncmp(recv_buffer + i + offset_device_name, mmi_protocol_device_name_get(), mmi_protocol_device_name_len_get())) // NAME
+                       && (0 == strncmp(recv_buffer + i + offset_first_sep, MMI_PROTOCOL_FZD_SEPARATOR, MMI_PROTOCOL_FZD_SEPARATOR_LEN)) // *
+                       && (0 == strncmp(recv_buffer + i + offset_device_id, imei, MMI_PROTOCOL_FZD_DEVICE_ID_LEN)) // ID
+                       && (0 == strncmp(recv_buffer + i + offset_second_sep, MMI_PROTOCOL_FZD_SEPARATOR, MMI_PROTOCOL_FZD_SEPARATOR_LEN)) // *
+                       && (0 == strncmp(recv_buffer + i + offset_third_sep, MMI_PROTOCOL_FZD_SEPARATOR, MMI_PROTOCOL_FZD_SEPARATOR_LEN)) // *
+                       )
+               {
+                       content_len_ptr = recv_buffer + i + offset_content_len;
+                       content_ptr = recv_buffer + i + offset_third_sep + MMI_PROTOCOL_FZD_SEPARATOR_LEN;
+                       break;
+               }
+       }
+
+       //content
+       if(NULL == content_ptr || NULL == content_len_ptr)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: data content error\n", __FUNCTION__, __LINE__);
+               mmi_protocol_fzd_receive_buff_free();
+               return false;
+       }
+
+       //length
+       content_len = mmi_hex_string_to_number(content_len_ptr, MMI_PROTOCOL_FZD_CONTENT_LEN_LEN);
+       PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: content_len=%d, recv_len=%d\n", __FUNCTION__, __LINE__, content_len, recv_len);
+       if(recv_fixed_len + content_len > recv_len)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: data length error\n", __FUNCTION__, __LINE__);
+               mmi_protocol_fzd_incomplete_buff_store(recv_buffer, recv_len);
+               mmi_protocol_fzd_receive_buff_free();
+               return false;
+       }
+
+       //tail
+       offset_tail_bracket = offset_third_sep + MMI_PROTOCOL_FZD_SEPARATOR_LEN + content_len;
+       //PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: offset_tail_bracket=%d\n", __FUNCTION__, __LINE__, offset_tail_bracket);
+       if(0 != strncmp(recv_buffer + i + offset_tail_bracket, MMI_PROTOCOL_FZD_TAIL_BRACKET, MMI_PROTOCOL_FZD_BRACKET_LEN)) // ]
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: tail check error\n", __FUNCTION__, __LINE__);
+               mmi_protocol_fzd_receive_buff_free();
+               return false;
+       }
+
+       //parse
+       _lv_memset_00(content_ptr + content_len, MMI_PROTOCOL_FZD_BRACKET_LEN);
+       mmi_protocol_fzd_content_parse(content_ptr, content_len);
+
+       //store
+       result = mmi_protocol_fzd_receive_buff_store(content_ptr + content_len + MMI_PROTOCOL_FZD_BRACKET_LEN, recv_len - offset_tail_bracket - MMI_PROTOCOL_FZD_BRACKET_LEN);
+
+       return result;
+}
+
+void mmi_protocol_fzd_receive_data_process(char * recv_str, int recv_len)
+{
+       PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+       PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%d]: len=%d,str=%s", __LINE__, recv_len, recv_str);
+       
+       mmi_protocol_fzd_receive_buff_store(recv_str, recv_len);
+       while(1)
+       {
+               if(false == mmi_protocol_fzd_receive_data_parse())
+               {
+                       PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+                       break;
+               }
+       }
+}
+
+static bool mmi_protocol_fzd_send_without_data(MMI_PROTOCOL_FZD_ACTION_ENUM action)
+{
+       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);
+
+       return result;
+}
+
+static bool mmi_protocol_fzd_send_with_data(MMI_PROTOCOL_FZD_ACTION_ENUM action, unsigned char * content_buff, int content_lenth)
+{
+       bool result = false;
+
+       result = mmi_protocol_fzd_send_content_construct(action, content_buff, content_lenth);
+
+       return result;
+}
+
+/////////////////////////
+
+bool mmi_protocol_fzd_action_LINK(void)
+{
+       return mmi_protocol_fzd_send_without_data(MMI_FZD_ACTION_LINK);
+}
+
+bool mmi_protocol_fzd_parse_LINK(unsigned char * next_buff, unsigned int next_buff_len)
+{
+       if(true != mmi_protocol_watch_bind_state_get())
+       {
+               mmi_protocol_fzd_action_bind();
+       }
+
+       mmi_protocol_fzd_action_get_app_qrcode();
+
+       return true;
+}
+
+bool mmi_protocol_fzd_action_HEARTBEAT(void)
+{
+       bool result = false;
+       MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_ACTION_HEARTBEAT;
+       unsigned char * content_buff = NULL;
+       unsigned int content_lenth = 0;
+    hal_rtc_t cur_time = {0};
+       int step_num = asl_pedometer_steps_get();
+       int roll_num = mmi_sleep_roll_number_get();
+       int battery_percent = Hal_Battery_Get_Status();
+
+       content_buff = (unsigned char *)lv_mem_alloc(128);
+       if(NULL == content_buff)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               return false;
+       }
+       _lv_memset_00(content_buff, 128);
+
+    Hal_Rtc_Gettime(&cur_time);
+       
+       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_with_data(action, content_buff, content_lenth);
+       lv_mem_free(content_buff);
+
+       // tcms 
+#ifdef __MMI_CUSTOM_HENGAI_TCMS__
+       mmi_hengai_tcms_data_send();
+#endif
+
+       return result;
+}
+
+bool mmi_protocol_fzd_parse_HEARTBEAT(unsigned char * next_buff, unsigned int next_buff_len)
+{
+       if(0 == s_fzd_time_data_flag)
+       {
+               mmi_protocol_fzd_action_get_time();
+       }
+
+       return true;
+}
+
+bool mmi_protocol_fzd_action_bind(void)
+{
+       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 result = false;
+       uint8_t value = 0;
+
+       if(1 != next_buff_len)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               return false;
+       }
+
+       value = atoi(next_buff);
+       if(true == mmi_protocol_watch_bind_state_get())
+       {
+               if(0 == value)
+               {
+                       mmi_protocol_watch_bind_state_set(false);
+                       //uos_sleep(10);
+                       mmi_watch_factory_aciton();                     
+               }
+       }
+       else
+       {
+               if(1 == value)
+               {
+                       mmi_protocol_watch_bind_state_set(true);
+
+                       // sim unbind check
+               #ifdef __MMI_ZHSX_SUPPORT_CHECK_SIM_UNBIND__
+                       mmi_watch_sim_unbind_check();
+               #endif
+
+                       // timing mission
+                       mmi_protocol_timing_mission_action();
+
+                       //video call
+               #ifdef __MMI_ZHSX_SUPPORT_VIDEO_CALL__
+                       mmi_protocol_fzd_action_get_vc_config();
+               #endif
+
+                       // hengai sleep
+               #ifdef __MMI_CUSTOM_HENGAI_SLEEP__
+                       mmi_hengai_sleep_activation_check_action();
+               #endif
+
+                       // hengai tcms  
+               #ifdef __MMI_CUSTOM_HENGAI_TCMS__
+                       mmi_hengai_tcms_action();
+               #endif
+               
+
+               }
+       }
+
+       return true;
+}
+
+bool mmi_protocol_fzd_action_get_time(void)
+{
+       return mmi_protocol_fzd_send_without_data(MMI_FZD_ACTION_GET_TIME);
+}
+
+//[XX*YYYY*001D*LGZONE,+8,08:00:00,2016-01-12]
+bool mmi_protocol_fzd_parse_ACTION_GET_TIME(unsigned char * next_buff, unsigned int next_buff_len)
+{
+       bool result = false;
+       unsigned char * temp_ptr = NULL;
+       float time_zone = 0.0;
+    hal_rtc_t set_time = {0};
+
+       if(NULL == next_buff || 0 == next_buff_len)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               return false;
+       }
+       
+       s_fzd_time_data_flag = 1;
+       temp_ptr = km_strtok_r(NULL, ",", &next_buff);
+       if(NULL != temp_ptr)
+               time_zone = atof(temp_ptr);
+
+       temp_ptr = km_strtok_r(NULL, ":", &next_buff);
+       if(NULL != temp_ptr)
+               set_time.tm_hour = atoi(temp_ptr);
+       temp_ptr = km_strtok_r(NULL, ":", &next_buff);
+       if(NULL != temp_ptr)
+               set_time.tm_min = atoi(temp_ptr);
+       temp_ptr = km_strtok_r(NULL, ",", &next_buff);
+       if(NULL != temp_ptr)
+               set_time.tm_sec = atoi(temp_ptr);
+
+       temp_ptr = km_strtok_r(NULL, "-", &next_buff);
+       if(NULL != temp_ptr)
+               set_time.tm_year = atoi(temp_ptr);
+       temp_ptr = km_strtok_r(NULL, "-", &next_buff);
+       if(NULL != temp_ptr)
+               set_time.tm_mon = atoi(temp_ptr);
+       if(NULL != next_buff)
+               set_time.tm_mday = atoi(next_buff);
+
+       Hal_Rtc_Settime(&set_time);
+       alarm_set_rtc_alarm();
+       result = true;
+
+       return result;
+}
+
+bool mmi_protocol_fzd_parse_SERVER_GET_CUR_LOCATION(unsigned char * next_buff, unsigned int next_buff_len)
+{
+       bool result = false;
+       MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_SERVER_GET_CUR_LOCATION;
+       
+       result = true;
+       mmi_protocol_fzd_send_without_data(action);
+
+       mmi_watch_location_mission_current_location_action();
+       
+       return result;
+}
+
+bool mmi_protocol_fzd_parse_SERVER_SET_UD_INTERVAL(unsigned char * next_buff, unsigned int next_buff_len)
+{
+       bool result = false;
+       MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_SERVER_SET_UD_INTERVAL;
+       
+       if(NULL == next_buff || 0 == next_buff_len)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               return false;
+       }
+       
+       result = true;
+       mmi_protocol_fzd_send_without_data(action);
+
+       uint32_t value = atoi(next_buff);
+
+       mmi_protocol_watch_location_upload_interval_set(value);
+       
+       return result;
+}
+
+bool mmi_protocol_fzd_parse_SERVER_SET_FACTORY(unsigned char * next_buff, unsigned int next_buff_len)
+{
+       bool result = false;
+       MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_SERVER_SET_FACTORY;
+       
+       result = true;
+       mmi_protocol_fzd_send_without_data(action);
+
+       //uos_sleep(10);
+       mmi_watch_factory_aciton();
+
+       return result;
+}
+
+bool mmi_protocol_fzd_parse_SERVER_SET_POWEROFF(unsigned char * next_buff, unsigned int next_buff_len)
+{
+       bool result = false;
+       MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_SERVER_SET_POWEROFF;
+       
+       result = true;
+       mmi_protocol_fzd_send_without_data(action);
+
+       mmi_watch_power_off_aciton();
+
+       return result;
+}
+
+bool mmi_protocol_fzd_parse_SERVER_SET_REBOOT(unsigned char * next_buff, unsigned int next_buff_len)
+{
+       bool result = false;
+       MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_SERVER_SET_REBOOT;
+       
+       result = true;
+       mmi_protocol_fzd_send_without_data(action);
+
+       mmi_watch_reboot_aciton();
+
+       return result;
+}
+
+bool mmi_protocol_fzd_parse_SERVER_FIND_WATCH(unsigned char * next_buff, unsigned int next_buff_len)
+{
+       bool result = false;
+       MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_SERVER_FIND_WATCH;
+       
+       result = true;
+       mmi_protocol_fzd_send_without_data(action);
+
+       //mmi_watch_server_search_screen_create(NULL);  
+       mmi_watch_searching_aciton();
+
+       return result;
+}
+
+bool mmi_protocol_fzd_parse_SERVER_GET_VERSION(unsigned char * next_buff, unsigned int next_buff_len)
+{
+       bool result = false;
+       MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_SERVER_GET_VERSION;
+       unsigned char content_buff[8] = {0};
+       unsigned int content_lenth = 0;
+
+    //////////
+    //////////
+    //////////
+    //function
+    //////////
+    //////////
+    //////////
+
+       //sprintf(content_buff, ",%s", temp_value);
+       content_lenth = strlen(content_buff);
+
+       result = mmi_protocol_fzd_send_with_data(action, content_buff, content_lenth);
+
+       return result;
+}
+
+bool mmi_protocol_fzd_parse_SERVER_SET_PHONEBOOK(unsigned char * next_buff, unsigned int next_buff_len)
+{
+       bool result = false;
+       MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_SERVER_SET_PHONEBOOK;
+
+       if(NULL == next_buff || 0 == next_buff_len)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               return false;
+       }
+       
+       result = true;
+       mmi_protocol_fzd_send_without_data(action);
+
+       app_adaptor_contact_t server_set_contact[NV_WATCH_MAX_CONTACT_NUM] = {0};
+       char * temp_ptr = NULL;
+       uint8_t i = 0;
+
+       while (NULL != next_buff)
+       {
+               server_set_contact[i].contact_type = 0;
+               server_set_contact[i].portrait_id = WATCH_PORTRAIT_ID_FATHER;
+               
+               temp_ptr = km_strtok_r(NULL, ",", &next_buff);
+               if (NULL != temp_ptr)
+               {
+                       strncpy(server_set_contact[i].contact_number, temp_ptr, FZD_MIN(strlen(temp_ptr), (WATCH_CONTACTS_MAX_NUMBER_LEN - 1)));
+               }
+               else
+               {
+                       break;
+               }
+               
+               temp_ptr = km_strtok_r(NULL, ",", &next_buff);
+               if (NULL != temp_ptr)
+               {
+                       uint8_t t_len = 0;
+
+                       mmi_unicode_hex_str_to_utf8_str(temp_ptr, strlen(temp_ptr), server_set_contact[i].contact_name, &t_len);
+               }
+               else
+               {
+                       break;
+               }
+
+               i++;
+               if(NV_WATCH_MAX_CONTACT_NUM <= i)
+               {
+                       break;
+               }
+       }
+
+       mmi_phonebook_contact_list_set(&server_set_contact, i);
+
+       return result;
+}
+
+bool mmi_protocol_fzd_parse_SERVER_SET_CALL(unsigned char * next_buff, unsigned int next_buff_len)
+{
+       bool result = false;
+       MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_SERVER_SET_CALL;
+
+       if(NULL == next_buff || 0 == next_buff_len)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               return false;
+       }
+       
+       result = true;
+       mmi_protocol_fzd_send_without_data(action);
+       uos_sleep(10);
+
+    char * number = (char *)lv_mem_alloc(NV_CONTACTS_MAX_NUMBER_LEN);
+       if(NULL == number)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               return false;
+       }
+       _lv_memset_00(number, NV_CONTACTS_MAX_NUMBER_LEN);
+       _lv_memcpy(number, next_buff, ((NV_CONTACTS_MAX_NUMBER_LEN > next_buff_len) ? next_buff_len : NV_CONTACTS_MAX_NUMBER_LEN - 1));
+    phone_voice_call_req(number);
+
+       return result;
+}
+
+//[XX*YYYY*0018*REMIND,08:10-1-1,08:10-1-2, 08:10-1-3-0111110]
+//[SZKW*860132060004801*0034*REMIND,10:00-1-1,10:02-1-3-0111000,10:03-1-3-0111111]
+bool mmi_protocol_fzd_parse_SERVER_SET_REMIND(unsigned char * next_buff, unsigned int next_buff_len)
+{
+       bool result = false;
+       MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_SERVER_SET_REMIND;
+
+       if(NULL == next_buff || 0 == next_buff_len)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               return false;
+       }
+       
+       result = true;
+       mmi_protocol_fzd_send_without_data(action);
+
+       app_adaptor_alarm_t server_set_alarm[NV_ALARM_MAX_ALARM_NUM] = {0};
+       char * group_str = NULL;
+       char * group_last = NULL;
+       char * temp_ptr = NULL;
+       char * last = NULL;
+       uint8_t i = 0;
+
+       //PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: next_buff=%s\n", __FUNCTION__, __LINE__, next_buff);
+       group_str = km_strtok_r(next_buff, ",", &group_last);
+       //PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: temp_ptr1=%s,next_buff=%s\n", __FUNCTION__, __LINE__, group_str, next_buff);
+       while(NULL != group_str)
+       {
+               server_set_alarm[i].valid = 1;
+               
+               temp_ptr = km_strtok_r(group_str, ":", &last);
+               server_set_alarm[i].hour = atoi(temp_ptr);
+               
+               temp_ptr = km_strtok_r(NULL, "-", &last);
+               server_set_alarm[i].min = atoi(temp_ptr);
+
+               temp_ptr = km_strtok_r(NULL, "-", &last);
+               server_set_alarm[i].on_off = atoi(temp_ptr);
+               
+               temp_ptr = km_strtok_r(NULL, "-", &last);
+               //PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: temp_ptr=%s,last=%s\n", __FUNCTION__, __LINE__, temp_ptr, last);
+               if(1 == atoi(temp_ptr))
+               {
+                       server_set_alarm[i].repeat_bitmap = 0;
+               }
+               else if(2 == atoi(temp_ptr))
+               {
+                       server_set_alarm[i].repeat_bitmap = 0xff;
+               }
+               else
+               {
+                       //server_set_alarm[i].repeat_bitmap = 0xff;
+                       server_set_alarm[i].repeat_bitmap = 0x80;
+                       if(NULL != last)
+                       {
+                               uint8_t j = 0;
+                               for(j = 0; j < 7; j++)
+                               {
+                                       //server_set_alarm[i].repeat_bitmap &= ((('0' == *(last + j)) ? 0 : 1) << j);
+                                       server_set_alarm[i].repeat_bitmap |= ((('0' == *(last + j)) ? 0 : 1) << j);
+                               }
+                       }
+               }
+
+               i++;
+               if(NV_ALARM_MAX_ALARM_NUM <= i)
+               {
+                       break;
+               }
+               
+               group_str = km_strtok_r(NULL, ",", &group_last);
+       }
+
+       alarm_set_alarm_by_ui(&server_set_alarm, i);
+
+       //uint8_t x = 0;
+       //for(x = 0; x < i; x++)
+       //{
+       //      PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%d]: %d,%d\n", __LINE__, server_set_alarm[x].on_off, server_set_alarm[x].repeat_bitmap);
+       //}
+
+       return result;
+}
+
+/*
+????:[XT*YYYYYYYYYYYYYYY*LEN*BOOTOFFQ]
+??: [XT*334588000000156*0008*BOOTOFFQ] 
+????:??app??????
+????:[XT*YYYYYYYYYYYYYYY*LEN*BOOTOFF,??(0?,1?),????,????]
+?:[XT*334588000000156*LEN*BOOTOFF,         1,07:10,21:00        ]
+*/
+bool mmi_protocol_fzd_parse_SERVER_SET_BOOTOFF(unsigned char * next_buff, unsigned int next_buff_len)
+{
+
+       bool result = false;
+       MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_SERVER_SET_BOOTOFF;
+
+       if(NULL == next_buff || 0 == next_buff_len)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               return false;
+       }
+       
+       result = true;
+       mmi_protocol_fzd_send_without_data(action);
+
+       app_adaptor_alarm_t server_set_alarm[2] = {0};
+
+       char * temp_ptr = NULL;
+       char * last = NULL;
+
+       temp_ptr = km_strtok_r(next_buff, ",", &last);
+
+       server_set_alarm[0].valid = 1;
+       server_set_alarm[1].valid = 1;
+
+       server_set_alarm[0].on_off = atoi(temp_ptr);
+       server_set_alarm[1].on_off = atoi(temp_ptr);
+
+       server_set_alarm[0].repeat_bitmap = 0x03ff;
+       server_set_alarm[1].repeat_bitmap = 0x01ff;
+       
+       
+       temp_ptr = km_strtok_r(NULL, ":", &last);
+       server_set_alarm[0].hour = atoi(temp_ptr);
+
+       
+       temp_ptr = km_strtok_r(NULL, ",", &last);
+       server_set_alarm[0].min = atoi(temp_ptr);
+       
+
+
+       temp_ptr = km_strtok_r(NULL, ":", &last);
+       server_set_alarm[1].hour = atoi(temp_ptr);
+
+       
+       temp_ptr = last;
+       server_set_alarm[1].min = atoi(temp_ptr);
+
+
+       alarm_set_alarm_by_ui_shutdwon(&server_set_alarm, 2);
+
+       //uint8_t x = 0;
+       //for(x = 0; x < i; x++)
+       //{
+       //      PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%d]: %d,%d\n", __LINE__, server_set_alarm[x].on_off, server_set_alarm[x].repeat_bitmap);
+       //}
+
+       return result;
+}
+
+
+
+#ifdef __MMI_ZHSX_SUPPORT_HEALTH_SENSOR__
+bool mmi_protocol_fzd_action_send_temperature(float temp_value)
+{
+       bool result = false;
+       MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_ACTION_SEND_TEMPERATURE;
+       unsigned char content_buff[8] = {0};
+       unsigned int content_lenth = 0;
+       char data_str[8] = {0};
+
+       mmi_float_to_str(temp_value, 1, data_str);
+       sprintf(content_buff, ",%s", data_str);
+       content_lenth = strlen(content_buff);
+
+       result = mmi_protocol_fzd_send_with_data(action, content_buff, content_lenth);
+
+       return result;
+}
+
+bool mmi_protocol_fzd_action_send_heart(uint16_t heart_value)
+{
+       bool result = false;
+       MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_ACTION_SEND_HEART;
+       unsigned char content_buff[8] = {0};
+       unsigned int content_lenth = 0;
+
+       sprintf(content_buff, ",%d", heart_value);
+       content_lenth = strlen(content_buff);
+       
+       result = mmi_protocol_fzd_send_with_data(action, content_buff, content_lenth);
+
+       return result;
+}
+
+bool mmi_protocol_fzd_action_send_blood(uint16_t blood_high_value, uint16_t blood_low_value)
+{
+       bool result = false;
+       MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_ACTION_SEND_BLOOD;
+       unsigned char content_buff[16] = {0};
+       unsigned int content_lenth = 0;
+
+       sprintf(content_buff, ",%d,%d", blood_high_value, blood_low_value);
+       content_lenth = strlen(content_buff);
+       
+       result = mmi_protocol_fzd_send_with_data(action, content_buff, content_lenth);
+
+       return result;
+}
+
+bool mmi_protocol_fzd_action_send_spo2(uint16_t spo2_value)
+{
+       bool result = false;
+       MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_ACTION_SEND_SPO2;
+       unsigned char content_buff[8] = {0};
+       unsigned int content_lenth = 0;
+
+       sprintf(content_buff, ",%d", spo2_value);
+       content_lenth = strlen(content_buff);
+       
+       result = mmi_protocol_fzd_send_with_data(action, content_buff, content_lenth);
+
+       return result;
+}
+
+bool mmi_protocol_fzd_parse_SERVER_SET_HEART_INTERVAL(unsigned char * next_buff, unsigned int next_buff_len)
+{
+       bool result = false;
+       MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_SERVER_SET_HEART_INTERVAL;
+
+       if(NULL == next_buff || 0 == next_buff_len)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               return false;
+       }
+
+       result = true;
+       mmi_protocol_fzd_send_without_data(action);
+
+       int value_interval = atoi(next_buff);
+       
+       if((0 == value_interval) // close timed measure
+               || (1 == value_interval) // measure once
+               || (300 <= value_interval) // immediate timed measure
+               )
+       {
+               mmi_health_measure_server_set_action(MMI_HEALTH_MEASURE_HEART, value_interval);
+       }
+       else // the interval value error
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               result = false;
+       }
+
+       return result;
+}
+
+bool mmi_protocol_fzd_parse_SERVER_SET_TEMPERATURE_INTERVAL(unsigned char * next_buff, unsigned int next_buff_len)
+{
+       bool result = false;
+       MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_SERVER_SET_TEMPERATURE_INTERVAL;
+
+       if(NULL == next_buff || 0 == next_buff_len)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               return false;
+       }
+
+       result = true;
+       mmi_protocol_fzd_send_without_data(action);
+
+       int value_interval = atoi(next_buff);
+       
+       if((0 == value_interval) // close timed measure
+               || (1 == value_interval) // measure once
+               || (300 <= value_interval) // immediate timed measure
+               )
+       {
+               mmi_health_measure_server_set_action(MMI_HEALTH_MEASURE_TEMPERATURE, value_interval);
+       }
+       else // the interval value error
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               result = false;
+       }
+
+       return result;
+}
+
+bool mmi_protocol_fzd_parse_SERVER_SET_BLOOD_INTERVAL(unsigned char * next_buff, unsigned int next_buff_len)
+{
+       bool result = false;
+       MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_SERVER_SET_BLOOD_INTERVAL;
+
+       if(NULL == next_buff || 0 == next_buff_len)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               return false;
+       }
+
+       result = true;
+       mmi_protocol_fzd_send_without_data(action);
+
+       int value_interval = atoi(next_buff);
+       
+       if((0 == value_interval) // close timed measure
+               || (1 == value_interval) // measure once
+               || (300 <= value_interval) // immediate timed measure
+               )
+       {
+               mmi_health_measure_server_set_action(MMI_HEALTH_MEASURE_BLOOD, value_interval);
+       }
+       else // the interval value error
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               result = false;
+       }
+
+       return result;
+}
+
+
+bool mmi_protocol_fzd_parse_SERVER_SET_SPO2_INTERVAL(unsigned char * next_buff, unsigned int next_buff_len)
+{
+       bool result = false;
+       MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_SERVER_SET_SPO2_INTERVAL;
+
+       if(NULL == next_buff || 0 == next_buff_len)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               return false;
+       }
+
+       result = true;
+       mmi_protocol_fzd_send_without_data(action);
+
+       int value_interval = atoi(next_buff);
+       
+       if((0 == value_interval) // close timed measure
+               || (1 == value_interval) // measure once
+               || (300 <= value_interval) // immediate timed measure
+               )
+       {
+               mmi_health_measure_server_set_action(MMI_HEALTH_MEASURE_SPO2, value_interval);
+       }
+       else // the interval value error
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               result = false;
+       }
+
+       return result;
+}
+#endif
+
+
+#define ENCRYPT_EXT_MIN  100
+#define ENCRYPT_EXT_COEF  10
+
+static int mmi_protocol_fzd_voice_data_encrypt(char * data_buff, int data_buff_len, char * encrypt_data)
+{
+       uint32_t curr_p = 0, i = 0;
+
+       //convert data_buff to send_buff.
+       //0x7D -> 0x7D 0x01 
+       //0x5D -> 0x7D 0x03
+       encrypt_data[0] = ',';
+       curr_p++;
+       
+       for(i = 0; i < data_buff_len; i++)
+       {
+               if(data_buff[i] == 0x7D)
+               {
+                       encrypt_data[curr_p++] = 0x7D;
+                       encrypt_data[curr_p++] = 0x01;
+               }
+               else if(data_buff[i] == 0x5B)
+               {
+                       encrypt_data[curr_p++] = 0x7D;
+                       encrypt_data[curr_p++] = 0x02;
+               }
+               else if(data_buff[i] == 0x5D)
+               {
+                       encrypt_data[curr_p++] = 0x7D;
+                       encrypt_data[curr_p++] = 0x03;
+               }
+               else if(data_buff[i] == 0x2C)
+               {
+                       encrypt_data[curr_p++] = 0x7D;
+                       encrypt_data[curr_p++] = 0x04;
+               }
+               else if(data_buff[i] == 0x2A)
+               {
+                       encrypt_data[curr_p++] = 0x7D;
+                       encrypt_data[curr_p++] = 0x05;
+               }
+               else
+               {
+                       encrypt_data[curr_p++] = data_buff[i];
+               }
+       }
+
+       return curr_p;
+}
+
+static int mmi_protocol_fzd_voice_data_decrypt(char * data_buff, int data_buff_len)
+{
+    int offset = 0;
+       
+    if (NULL != data_buff) 
+       {
+        int pos = 0;
+               
+        for ( ; pos < data_buff_len; pos++, offset++) 
+               {
+            char ch = data_buff[pos];
+                       
+            if ( 0x7D == ch ) 
+                       {
+                switch ( data_buff[pos + 1] ) 
+                               {
+                    case 0x05:
+                        ch = 0x2A;
+                        pos ++;
+                        break;                    
+
+                    case 0x04:
+                        ch = 0x2C;
+                        pos ++;
+                        break;                    
+
+                    case 0x03:
+                        ch = 0x5D;
+                        pos ++;
+                        break;                    
+
+                    case 0x02: 
+                        ch = 0x5B;
+                        pos ++;
+                        break;
+
+                    case 0x01:
+                        pos ++;
+                        break;                    
+
+                    default:
+                        break;
+                }
+            }
+
+            if ( pos != offset ) 
+                       {
+                data_buff[offset] = ch;
+            }
+        }
+    }
+
+    return offset;
+}
+
+#ifdef __MMI_WECHAT_SUPPORT__
+bool mmi_protocol_fzd_ACTION_TALK(char * data_buff, int data_buff_len)
+{
+       bool result = false;
+       MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_ACTION_TALK;
+       unsigned char * content_buff = NULL;
+       unsigned int content_lenth = 0;
+       unsigned int memory_size = 0;
+
+       if(NULL == data_buff || 0 == data_buff_len)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               return false;
+       }
+
+       memory_size = data_buff_len;
+       memory_size += LV_MATH_MAX((data_buff_len * ENCRYPT_EXT_COEF/100), LV_MATH_MIN(ENCRYPT_EXT_MIN, data_buff_len));
+       content_buff = (unsigned char *)lv_mem_alloc(memory_size);
+       if(NULL == content_buff)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               return false;
+       }
+       _lv_memset_00(content_buff, memory_size);
+       
+       PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: memory_size=%d\n", __FUNCTION__, __LINE__, memory_size);
+       
+       content_lenth = mmi_protocol_fzd_voice_data_encrypt(data_buff, data_buff_len, content_buff);
+
+       PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: content_lenth=%d\n", __FUNCTION__, __LINE__, 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_parse_ACTION_TALK(unsigned char * next_buff, unsigned int next_buff_len)
+{
+       bool result = false;
+       MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_ACTION_TALK;
+
+       if(NULL == next_buff || 0 == next_buff_len)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               return false;
+       }
+
+       if(1 == next_buff_len)
+       {
+               // the server return result value
+               result = true;
+       }
+       else
+       {
+               unsigned char content_buff[8] = {0};
+               unsigned int content_lenth = 0;
+               unsigned int next_buff_len_new = 0;
+               
+               sprintf(content_buff, ",1");
+               content_lenth = strlen(content_buff);
+               
+               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 result;
+}
+
+bool mmi_protocol_fzd_parse_ACTION_TALK_MESSAGE(unsigned char * next_buff, unsigned int next_buff_len)
+{
+       bool result = false;
+       MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_ACTION_TALK_MESSAGE;
+
+       if(NULL == next_buff || 0 == next_buff_len)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               return false;
+       }
+
+       result = mmi_protocol_fzd_send_without_data(action);
+
+       unsigned char t_buff[WECHAT_MSG_TEXT_LEN_MAX * 4 + 1] = {0};
+       uint8_t t_len_1 = 0, t_len_2 = 0;
+       
+       t_len_1 = (WECHAT_MSG_TEXT_LEN_MAX * 4 < next_buff_len) ? (WECHAT_MSG_TEXT_LEN_MAX * 4) : next_buff_len;
+       mmi_unicode_hex_str_to_utf8_str(next_buff, next_buff_len, t_buff, &t_len_2);
+       PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: %d,%d,%d\n", __FUNCTION__, __LINE__, next_buff_len, t_len_1, t_len_2);
+       result = wechat_msg_receive_from_server(t_buff, t_len_2, WECHAT_MSG_TYPE_TEXT); 
+       
+       return result;
+}
+#endif
+
+#if USE_LV_WATCH_CAMERA != 0
+bool mmi_protocol_fzd_action_send_photo(uint8_t type, char * time_str, char * data_buff, int data_buff_len)
+{
+       bool result = false;
+       MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_ACTION_SEND_PHOTO;
+       unsigned char * content_buff = NULL;
+       unsigned int content_lenth = 0;
+       unsigned char * t_content_buff = NULL;
+       unsigned int t_content_lenth = 0;
+       unsigned int memory_size = 0;
+
+       if(NULL == data_buff || 0 == data_buff_len)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               return false;
+       }
+
+       memory_size = data_buff_len;
+       memory_size += LV_MATH_MAX((data_buff_len * ENCRYPT_EXT_COEF/100), LV_MATH_MIN(ENCRYPT_EXT_MIN, data_buff_len));
+       PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: memory_size=%d\n", __FUNCTION__, __LINE__, memory_size);
+
+       // image data
+       t_content_buff = (unsigned char *)lv_mem_alloc(memory_size);
+       if(NULL == t_content_buff)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               return false;
+       }
+       _lv_memset_00(t_content_buff, memory_size);
+       t_content_lenth = mmi_protocol_fzd_voice_data_encrypt(data_buff, data_buff_len, t_content_buff);
+
+       // all data
+       content_buff = (unsigned char *)lv_mem_alloc(memory_size + 24);
+       if(NULL == content_buff)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+
+               lv_mem_free(t_content_buff);
+               return false;
+       }
+       _lv_memset_00(content_buff, (memory_size + 24));
+
+       sprintf(content_buff, ",0,0");
+       content_lenth = strlen(content_buff);
+       
+       _lv_memcpy(content_buff + content_lenth, t_content_buff, t_content_lenth);
+       content_lenth += t_content_lenth;
+       lv_mem_free(t_content_buff);
+
+       PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: content_lenth=%d\n", __FUNCTION__, __LINE__, content_lenth);
+       
+       result = mmi_protocol_fzd_send_with_data(action, content_buff, content_lenth);
+       lv_mem_free(content_buff);
+       
+       return result;
+}
+#endif
+
+static void mmi_location_gps_data_process(MMI_WATCH_GPS_DATA_T * gps_data, char * data_str)
+{
+       char state_str[2] = {0};
+       char latitude_str[16] = {0}, longitude_str[16] = {0};
+       char ns_str[2] = {0}, ew_str[2] = {0};
+       char speed_str[8] = {0}, degree_str[8] = {0}, altitude_str[8] = {0};
+
+       if('A' == gps_data->state)
+               state_str[0] = 'A';
+       else
+               state_str[0] = 'V';
+
+       mmi_float_to_str(gps_data->latitude, 6, latitude_str);
+
+       if('S' == gps_data->ns || 's' == gps_data->ns)
+               ns_str[0] = 'S';
+       else
+               ns_str[0] = 'N';
+
+       mmi_float_to_str(gps_data->longitude, 6, longitude_str);
+
+       if('W' == gps_data->ew || 'w' == gps_data->ew)
+               ew_str[0] = 'W';
+       else
+               ew_str[0] = 'E';
+
+       mmi_float_to_str(gps_data->speed, 2, speed_str);
+
+       mmi_float_to_str(gps_data->degree, 1, degree_str);
+
+       mmi_float_to_str(gps_data->altitude, 1, altitude_str);
+
+    sprintf(data_str, "%s,%s,%s,%s,%s,%s,%s,%s,%u",
+                               state_str, 
+                               latitude_str, ns_str, longitude_str, ew_str, 
+                               speed_str, degree_str, altitude_str, 
+                               gps_data->satellite_num);
+}
+
+static unsigned int mmi_protocol_fzd_action_send_content_fill_location_data(unsigned char * content_buff,
+                                                                                                                       unsigned int content_lenth,
+                                                                                                                       MMI_WATCH_LOCATION_DATA_T * location_data, 
+                                                                                                                       MMI_PROTOCOL_FZD_ACTION_ENUM action, 
+                                                                                                                       unsigned char * alert_info)
+{
+       unsigned char * t_ptr = NULL;
+       unsigned int t_count = 0;
+       hal_rtc_t cur_time = {0}, cur_utc_time = {0};
+       unsigned int battery_value = Hal_Battery_Get_Status();
+       unsigned int sleep_roll_value = 0;
+       unsigned int step_value = asl_pedometer_steps_get();
+       uint8_t i = 0;
+       char data_str[128] = {0};
+
+       t_ptr = content_buff;
+
+       //seperator & time
+#if 1
+       Hal_Rtc_Gettime_Utc(&cur_utc_time);
+       sprintf(t_ptr, ",%02u%02u%02u,%02u%02u%02u", cur_utc_time.tm_year%100, cur_utc_time.tm_mon, cur_utc_time.tm_mday,
+                                                                                               cur_utc_time.tm_hour, cur_utc_time.tm_min, cur_utc_time.tm_sec);
+#else
+       Hal_Rtc_Gettime(&cur_time);
+    sprintf(t_ptr, ",%02u%02u%02u,%02u%02u%02u", cur_time.tm_year%100, cur_time.tm_mon, cur_time.tm_mday,
+                                                                                               cur_time.tm_hour, cur_time.tm_min, cur_time.tm_sec);
+#endif
+       t_count = strlen(t_ptr);
+
+    //gps
+       t_ptr += t_count;
+       mmi_location_gps_data_process(&(location_data->gps_data), data_str);
+       sprintf(t_ptr, ",%s", data_str);
+       t_count = strlen(t_ptr);
+
+       //
+       t_ptr += t_count;
+    sprintf(t_ptr, ",%d,%u,%u,%u",
+                                       location_data->cell_data.link_rxlev, // location_data->cell_data.rxlev[0],
+                                       battery_value,
+                                       step_value,
+                                       sleep_roll_value);
+       t_count = strlen(t_ptr);
+
+    //alert info
+       t_ptr += t_count;
+    if (NULL != alert_info)
+       {
+       sprintf(t_ptr, ",%s", alert_info);
+    }
+       else 
+       {
+       sprintf(t_ptr, ",%s", "00000000");
+    }
+       t_count = strlen(t_ptr);
+
+    //cell
+       t_ptr += t_count;
+    sprintf(t_ptr, ",%u,%u,%u,%u", location_data->cell_data.cell_num, 1, location_data->cell_data.mcc, location_data->cell_data.mnc);
+       t_count = strlen(t_ptr);
+       for (i = 0; i < location_data->cell_data.cell_num; i++)
+       {
+               t_ptr += t_count;
+       sprintf(t_ptr, ",%u,%u,%d", location_data->cell_data.lac[i], location_data->cell_data.cell_id[i], location_data->cell_data.rxlev[i]);
+               t_count = strlen(t_ptr);
+       }
+
+       //wifi
+       t_ptr += t_count;
+#if 1
+    sprintf(t_ptr, ",%u", location_data->wifi_data.count);
+       t_count = strlen(t_ptr);
+    for (i = 0; i < location_data->wifi_data.count; i++)
+       {
+               t_ptr += t_count;
+        sprintf(t_ptr, ",wifi%u,%02x:%02x:%02x:%02x:%02x:%02x,%d",
+                                       i,
+                                               location_data->wifi_data.item[i].mac[0],
+                                               location_data->wifi_data.item[i].mac[1],
+                                               location_data->wifi_data.item[i].mac[2],
+                                               location_data->wifi_data.item[i].mac[3],
+                                               location_data->wifi_data.item[i].mac[4],
+                                               location_data->wifi_data.item[i].mac[5],
+                                               location_data->wifi_data.item[i].rssi);
+               t_count = strlen(t_ptr);
+    }
+#else
+    sprintf(t_ptr, ",%u", 0);
+#endif
+
+       t_count = strlen(content_buff);
+       return t_count;
+}
+
+bool mmi_protocol_fzd_action_send_location(MMI_WATCH_LOCATION_DATA_T * location_data)
+{
+       bool result = false;
+       MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_ACTION_SEND_LOCATION;
+       unsigned char * content_buff = NULL;
+       unsigned int content_lenth = 0;
+
+       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, NULL);
+       
+       result = mmi_protocol_fzd_send_with_data(action, content_buff, content_lenth);
+       lv_mem_free(content_buff);
+       
+       return result;
+}
+
+bool mmi_protocol_fzd_action_send_cur_location(MMI_WATCH_LOCATION_DATA_T * location_data)
+{
+       bool result = false;
+       MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_ACTION_SEND_CUR_LOCATION;
+       unsigned char * content_buff = NULL;
+       unsigned int content_lenth = 0;
+
+       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, NULL);
+       
+       result = mmi_protocol_fzd_send_with_data(action, content_buff, content_lenth);
+       lv_mem_free(content_buff);
+       
+       return result;
+}
+
+bool mmi_protocol_fzd_action_send_get_weather(MMI_WATCH_LOCATION_DATA_T * location_data)
+{
+       bool result = false;
+       MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_ACTION_GET_WEATHER;
+       unsigned char * content_buff = NULL;
+       unsigned int content_lenth = 0;
+
+       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, NULL);
+       
+       result = mmi_protocol_fzd_send_with_data(action, content_buff, content_lenth);
+       lv_mem_free(content_buff);
+       
+       return result;
+}
+
+//[XX*YYYY*009F*WT,Äê-ÔÂ-ÈÕ,ʱ:·Ö:Ãë,ÌìÆøÃèÊö,ÌìÆø±àºÅ,µ±Ç°Î¶È,×îµÍÎÂ,×î¸ßÎÂ,³ÇÊÐÃû]
+//ÌìÆøÃèÊöÓàGB2312 ±àÂ룬³ÇÊÐÃûʹÓàUnicode ±àÂë  ÌìÆø±àºÅ£º0¡ª¡ªÇç 1¡ª¡ªÒõ 2¡ª¡ªÓê 3¡ª¡ªÑ©
+//[XX*YYYY*009F*WT,16-09-24,11:00:00,b6e0d4c6,2,-5,-12,22,316df15733]
+//[SZKW*860132060004801*0035*WT,23-10-11,16:09:11,b6e0d4c6,1,27,-1,40,6DF157335E02]
+bool mmi_protocol_fzd_parse_ACTION_GET_WEATHER(unsigned char * next_buff, unsigned int next_buff_len)
+{
+       bool result = false;
+       MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_ACTION_GET_WEATHER;
+
+       if(NULL == next_buff || 0 == next_buff_len)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               return false;
+       }
+
+       result = true;
+
+       unsigned char * temp_ptr = NULL;
+       app_adaptor_weather_t weather_info = {0};
+       uint8_t t_len = 0;
+
+       //date
+       temp_ptr = km_strtok_r(NULL, ",", &next_buff);
+       //time
+       temp_ptr = km_strtok_r(NULL, ",", &next_buff);
+       //descripe
+       temp_ptr = km_strtok_r(NULL, ",", &next_buff);
+       
+       //index
+       temp_ptr = km_strtok_r(NULL, ",", &next_buff);
+       switch(atoi(temp_ptr))
+       {
+               case 0:
+                       weather_info.weather_id = WATCH_WEATHER_ID_SUNNY;
+                       break;
+
+               case 1:
+                       weather_info.weather_id = WATCH_WEATHER_ID_OVERCAST;
+                       break;
+               case 2:
+                       weather_info.weather_id = WATCH_WEATHER_ID_HEAVY_RAIN;
+                       break;
+               case 3:
+                       weather_info.weather_id = WATCH_WEATHER_ID_HEAVY_SNOW;
+                       break;
+
+               default:
+                       weather_info.weather_id = WATCH_WEATHER_ID_SUNNY;
+                       break;
+       }
+       
+       //current temp
+       temp_ptr = km_strtok_r(NULL, ",", &next_buff);
+       weather_info.current_temperature = atoi(temp_ptr);
+       //lowest temp
+       temp_ptr = km_strtok_r(NULL, ",", &next_buff);
+       weather_info.lowest_temperature = atoi(temp_ptr);
+       //highest temp
+       temp_ptr = km_strtok_r(NULL, ",", &next_buff);
+       weather_info.highest_temperature= atoi(temp_ptr);
+
+       //city
+       mmi_unicode_hex_str_to_utf8_str(next_buff, strlen(next_buff), weather_info.city, &t_len);
+
+       mmi_weather_info_set(&weather_info);
+
+       return result;
+}
+
+#ifdef __MMI_SOS_NUMBER_NAME_SUPPORT__
+bool mmi_protocol_fzd_parse_SERVER_SET_SOS_NUMBER_NAME(unsigned char * next_buff, unsigned int next_buff_len)
+{
+       bool result = false;
+       MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_SERVER_SET_SOS_NUMBER_NAME;
+
+       if(NULL == next_buff || 0 == next_buff_len)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               return false;
+       }
+
+       result = true;
+       mmi_protocol_fzd_send_without_data(action);
+
+       uint8_t i = 0;
+       unsigned char * temp_ptr = NULL;
+       nv_watch_sos_number_t sos_number = {0};
+
+       while (NULL != next_buff)
+       {
+               temp_ptr = km_strtok_r(NULL, ",", &next_buff);
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: %s,%s\n", __FUNCTION__, __LINE__, temp_ptr, next_buff);
+               
+               if (NULL != temp_ptr)
+               {
+                       strncpy(sos_number.number[i], temp_ptr, FZD_MIN(strlen(temp_ptr), (WATCH_CONTACTS_MAX_NUMBER_LEN - 1)));
+               }
+
+               temp_ptr = km_strtok_r(NULL, ",", &next_buff);
+               if (NULL != temp_ptr)
+               {
+                       uint8_t t_len = 0;
+               
+                       mmi_unicode_hex_str_to_utf8_str(temp_ptr, strlen(temp_ptr), sos_number.name[i], &t_len);
+               }
+
+               i++;
+               if(NV_WATCH_SOS_NUMBER_MAX <= i)
+               {
+                       break;
+               }
+       }
+
+       mmi_sos_number_set(&sos_number);
+
+       return result;
+}
+#else
+bool mmi_protocol_fzd_parse_SERVER_SET_SOS_NUMBER(unsigned char * next_buff, unsigned int next_buff_len)
+{
+       bool result = false;
+       MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_SERVER_SET_SOS_NUMBER;
+
+       if(NULL == next_buff || 0 == next_buff_len)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               return false;
+       }
+
+       result = true;
+       mmi_protocol_fzd_send_without_data(action);
+
+       uint8_t i = 0;
+       unsigned char * temp_ptr = NULL;
+       nv_watch_sos_number_t sos_number = {0};
+
+       while (NULL != next_buff)
+       {
+               temp_ptr = km_strtok_r(NULL, ",", &next_buff);
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: %s,%s\n", __FUNCTION__, __LINE__, temp_ptr, next_buff);
+               
+               if (NULL != temp_ptr)
+               {
+                       strncpy(sos_number.number[i], temp_ptr, FZD_MIN(strlen(temp_ptr), (WATCH_CONTACTS_MAX_NUMBER_LEN - 1)));
+               }
+
+               i++;
+               if(NV_WATCH_SOS_NUMBER_MAX <= i)
+               {
+                       break;
+               }
+       }
+
+       mmi_sos_number_set(&sos_number);
+
+       return result;
+}
+#endif
+
+bool mmi_protocol_fzd_parse_SERVER_SET_CENTER_NUMBER(unsigned char * next_buff, unsigned int next_buff_len)
+{
+       bool result = false;
+       MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_SERVER_SET_CENTER_NUMBER;
+
+       if(NULL == next_buff || 0 == next_buff_len)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               return false;
+       }
+
+       result = true;
+       mmi_protocol_fzd_send_without_data(action);
+
+    nv_watch_center_number_t center_number = {0};
+       memcpy(center_number.number, next_buff, FZD_MIN(next_buff_len, (NV_CONTACTS_MAX_NUMBER_LEN - 1)));
+       mmi_center_number_set(&center_number);
+
+       return result;
+}
+
+bool mmi_protocol_fzd_parse_SERVER_SET_MONITOR(unsigned char * next_buff, unsigned int next_buff_len)
+{
+       bool result = false;
+       MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_SERVER_SET_MONITOR;
+
+       if(NULL != next_buff || 0 != next_buff_len)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               return false;
+       }
+
+       result = true;
+       mmi_protocol_fzd_send_without_data(action);
+
+       mmi_center_number_dialing_action();
+
+       return result;
+}
+
+
+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;
+                       if(true == value)
+                       {
+                               s_fzd_warning_info.take_on = false;
+                       }
+                       break;
+
+               case MMI_FZD_WARNING_TYPE_TAKE_ON:
+                       s_fzd_warning_info.take_on = value;
+                       if(true == value)
+                       {
+                               s_fzd_warning_info.take_off = false;
+                       }
+                       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);
+}
+
+bool mmi_protocol_fzd_action_get_app_qrcode(void)
+{
+#ifdef __MMI_APP_QRCODE_FROM_SERVER_SUPPORT__
+       if(0 == mmi_app_qrcode_get_flag_get())
+               return mmi_protocol_fzd_send_without_data(MMI_FZD_ACTION_GET_APP_QRCODE);
+       else
+               return false;
+#else
+       return false;
+#endif
+}
+
+bool mmi_protocol_fzd_parse_ACTION_GET_APP_QRCODE(unsigned char * next_buff, unsigned int next_buff_len)
+{
+       bool result = false;
+       MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_ACTION_GET_APP_QRCODE;
+
+#ifdef __MMI_APP_QRCODE_FROM_SERVER_SUPPORT__
+       if(NULL == next_buff || 0 == next_buff_len)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               return false;
+       }
+
+       result = true;
+
+       unsigned int next_buff_len_new = 0;
+       
+       next_buff_len_new = mmi_protocol_fzd_voice_data_decrypt(next_buff, next_buff_len);
+       PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: %d, %d\n", __FUNCTION__, __LINE__, next_buff_len, next_buff_len_new);
+       mmi_app_qrcode_content_buffer_set(next_buff, next_buff_len_new);
+#endif
+
+       return result;
+}
+
+
+#ifdef __MMI_ZHSX_SUPPORT_VIDEO_CALL__
+#ifdef __MMI_ZHSX_SUPPORT_VIDEO_CALL_WULIAN__
+bool mmi_protocol_fzd_action_get_vc_config(void)
+{
+       return mmi_protocol_fzd_send_without_data(MMI_FZD_WATCH_GET_VC_CONFIG);
+}
+
+bool mmi_protocol_fzd_action_get_vc_contact(void)
+{
+       return mmi_protocol_fzd_send_without_data(MMI_FZD_WATCH_GET_VC_CONTACT);
+}
+
+bool mmi_protocol_fzd_parse_WATCH_GET_VC_CONFIG(unsigned char * next_buff, unsigned int next_buff_len)
+{
+       bool result = false;
+       //MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_WATCH_GET_VC_CONFIG;
+
+       if(NULL == next_buff || 0 == next_buff_len)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               return false;
+       }
+
+       result = true;
+       //mmi_protocol_fzd_send_without_data(action);
+
+       char * t_tokens = NULL;
+       char * t_appkey = NULL;
+       char * t_key = NULL;
+
+       t_tokens = km_strtok_r(NULL, ",", &next_buff);
+       t_appkey = km_strtok_r(NULL, ",", &next_buff);
+       t_key = next_buff;
+       
+       mmi_video_call_jrtc_config_init_01(t_appkey, t_key, t_tokens);
+
+       //get contact
+       mmi_protocol_fzd_action_get_vc_contact();
+       
+       return result;
+}
+
+bool mmi_protocol_fzd_parse_WATCH_GET_VC_CONTACT(unsigned char * next_buff, unsigned int next_buff_len)
+{
+       bool result = false;
+       //MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_WATCH_GET_VC_CONTACT;
+
+       if(NULL == next_buff || 0 == next_buff_len)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               return false;
+       }
+       
+       result = true;
+       //mmi_protocol_fzd_send_without_data(action);
+
+       nv_watch_vc_contact_t t_vc_contact = {0};
+       char * temp_ptr = NULL;
+       uint8_t i = 0;
+       uint8_t t_len_1 = 0, t_len_2 = 0;
+
+       while (NULL != next_buff)
+       {
+               temp_ptr = km_strtok_r(NULL, ",", &next_buff);
+               if (NULL != temp_ptr)
+               {
+                       t_len_1 = FZD_MIN(strlen(temp_ptr), (NV_WATCH_VC_CONTACT_NUMBER_LEN - 1));
+                       strncpy(t_vc_contact.number[i], temp_ptr, t_len_1);
+               }
+               else
+               {
+                       break;
+               }
+               
+               temp_ptr = km_strtok_r(NULL, ",", &next_buff);
+               if (NULL != temp_ptr)
+               {
+                       t_len_1 = FZD_MIN(strlen(temp_ptr), ((NV_WATCH_VC_CONTACT_NAME_LEN - 1) * 4));
+                       mmi_unicode_hex_str_to_utf8_str(temp_ptr, t_len_1, t_vc_contact.name[i], &t_len_2);
+
+                       //PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: %d,%d\n", __FUNCTION__, __LINE__, t_len_1, t_len_2);
+                       //PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: %s\n", __FUNCTION__, __LINE__, temp_ptr);
+               }
+               else
+               {
+                       //PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+                       break;
+               }
+
+               i++;
+               if(NV_WATCH_VC_CONTACT_TOTAL <= i)
+               {
+                       break;
+               }
+       }
+
+       t_vc_contact.total = i;
+       mmi_vc_contact_set(&t_vc_contact);
+
+       return result;
+}
+
+bool mmi_protocol_fzd_action_VC_CALL_REQUEST(char * number, uint8_t call_type)
+{
+       bool result = false;
+       MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_WATCH_VC_CALL_REQUEST;
+       unsigned char content_buff[NV_WATCH_VC_CONTACT_NUMBER_LEN + 8] = {0};
+       unsigned int content_lenth = 0;
+
+       sprintf(content_buff, ",%s,%d", number, call_type);
+       content_lenth = strlen(content_buff);
+
+       result = mmi_protocol_fzd_send_with_data(action, content_buff, content_lenth);
+
+       return result;
+}
+       
+// 1£º¶Ô·½ÔÚÏߣ¬µÈ´ý½ÓÌý£»0£º¶Ô·½²»ÔÚÏß
+bool mmi_protocol_fzd_parse_WATCH_VC_CALL_REQUEST(unsigned char * next_buff, unsigned int next_buff_len)
+{
+       bool result = false;
+
+       if(NULL == next_buff || 0 == next_buff_len)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               return false;
+       }
+
+       result = true;
+
+       uint8_t t_value = 0;
+
+       t_value = atoi(next_buff);
+       if(0 == t_value)
+       {
+               // the other party is not online
+               mmi_vc_call_action_call_stop();
+       }
+       else
+       {
+               // wait, do nothing
+       }
+       
+       return result;
+}
+
+// state: 1-other accept; 0-other reject
+bool mmi_protocol_fzd_parse_SERVER_VC_CALL_RESPONSE(unsigned char * next_buff, unsigned int next_buff_len)
+{
+       bool result = false;
+       MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_SERVER_VC_CALL_RESPONSE;
+
+       if(NULL == next_buff || 0 == next_buff_len)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               return false;
+       }
+
+       result = true;
+       mmi_protocol_fzd_send_without_data(action);
+
+       uint8_t t_value = 0;
+
+       t_value = atoi(next_buff);
+       if(0 == t_value)
+       {
+               // the other party is reject
+               mmi_vc_call_action_call_stop();
+       }
+       else
+       {
+               // wait, do nothing
+       }
+       
+       return result;
+}
+
+bool mmi_protocol_fzd_parse_SERVER_VC_CALL_REQUEST(unsigned char * next_buff, unsigned int next_buff_len)
+{
+       bool result = false;
+       MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_SERVER_VC_CALL_REQUEST;
+
+       if(NULL == next_buff || 0 == next_buff_len)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               return false;
+       }
+
+       result = true;
+       mmi_protocol_fzd_send_without_data(action);
+
+       char * t_ptr = NULL;
+       char t_number[NV_WATCH_VC_CONTACT_NUMBER_LEN] = {0};
+       uint8_t t_calltype = 0;
+
+       t_ptr = km_strtok_r(NULL, ",", &next_buff);
+       strncpy(t_number, t_ptr, NV_WATCH_VC_CONTACT_NUMBER_LEN - 1); 
+       t_calltype = atoi(next_buff);
+
+       mmi_vc_call_action_incoming(t_number, t_calltype);
+       
+       return result;
+}
+
+// state: 1-watch accept; 0-watch reject
+bool mmi_protocol_fzd_action_VC_CALL_RESPONSE(char * number, uint8_t state)
+{
+       bool result = false;
+       MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_WATCH_VC_CALL_RESPONSE;
+       unsigned char content_buff[NV_WATCH_VC_CONTACT_NUMBER_LEN + 8] = {0};
+       unsigned int content_lenth = 0;
+
+       sprintf(content_buff, ",%s,%d", number, state);
+       content_lenth = strlen(content_buff);
+
+       result = mmi_protocol_fzd_send_with_data(action, content_buff, content_lenth);
+
+       return result;
+}
+#endif
+
+#ifdef __MMI_ZHSX_SUPPORT_VIDEO_CALL_FZD__
+bool mmi_protocol_fzd_action_get_vc_config(void)
+{
+       return mmi_protocol_fzd_send_without_data(MMI_FZD_WATCH_GET_VC_CONFIG);
+}
+
+bool mmi_protocol_fzd_action_get_vc_contact(void)
+{
+       return mmi_protocol_fzd_send_without_data(MMI_FZD_WATCH_GET_VC_CONTACT);
+}
+
+bool mmi_protocol_fzd_parse_WATCH_GET_VC_CONFIG(unsigned char * next_buff, unsigned int next_buff_len)
+{
+       bool result = false;
+#if 0
+       //MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_WATCH_GET_VC_CONFIG;
+
+       if(NULL == next_buff || 0 == next_buff_len)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               return false;
+       }
+
+       result = true;
+       //mmi_protocol_fzd_send_without_data(action);
+
+       char * t_char = NULL;
+       int32_t t_id = 0;
+
+       t_char = next_buff;
+       t_id = atoi(t_char);
+       PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: %d\n", __FUNCTION__, __LINE__, t_id);
+#endif
+
+       //get contact
+       mmi_protocol_fzd_action_get_vc_contact();
+       
+       return result;
+}
+
+bool mmi_protocol_fzd_parse_WATCH_GET_VC_CONTACT(unsigned char * next_buff, unsigned int next_buff_len)
+{
+       bool result = false;
+       //MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_WATCH_GET_VC_CONTACT;
+
+       if(NULL == next_buff || 0 == next_buff_len)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               return false;
+       }
+       
+       result = true;
+       //mmi_protocol_fzd_send_without_data(action);
+
+       // MEMBERS,0036003500300034003800320031002C0069006E00630061007200740065007300   
+       
+       PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: %d\n", __FUNCTION__, __LINE__, next_buff_len);
+       PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG]: %s\n", next_buff);
+       PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG]: %s\n", next_buff + 64);
+
+       nv_watch_vc_contact_t t_vc_contact = {0};
+       char temp_buffer[4] = {0};
+       char * temp_ptr = next_buff;
+       uint16_t i = 0;
+       uint16_t t_len = 0;
+       char t_content_buffer[NV_WATCH_VC_CONTACT_NUMBER_LEN] = {0};
+       uint16_t t_next = 0, t_current = 0;
+       uint16_t t_offset = 0;
+       
+       while((NULL != temp_ptr) && (i < next_buff_len))
+       {
+               memset(temp_buffer, 0x0, sizeof(temp_buffer));
+               mmi_unicode_hex_str_to_utf8_str(temp_ptr + t_offset, 4, temp_buffer, &t_len);
+               if(0x002C == temp_buffer[0]) // ,
+               {
+                       if(2 == t_current)
+                       {
+                               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+                               
+                               t_current = 0;
+                               t_next++;
+                               
+                               if(NV_WATCH_VC_CONTACT_TOTAL <= t_next)
+                               {
+                                       PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+                                       break;
+                               }
+                       }
+                       else if(1 == t_current) // name
+                       {
+                               //PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: %d\n", __FUNCTION__, __LINE__, t_offset);
+
+                               memset(t_content_buffer, 0x0, sizeof(t_content_buffer));
+                               mmi_unicode_hex_str_to_utf8_str(temp_ptr, t_offset, t_content_buffer, &t_len);
+                               strncpy(t_vc_contact.name[t_next], t_content_buffer, NV_WATCH_VC_CONTACT_NAME_LEN - 1);
+                               t_current++;
+                       }
+                       else // user id
+                       {
+                               //PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: %d\n", __FUNCTION__, __LINE__, t_offset);
+                               
+                               memset(t_content_buffer, 0x0, sizeof(t_content_buffer));
+                               mmi_unicode_hex_str_to_utf8_str(temp_ptr, t_offset, t_content_buffer, &t_len);
+                               strncpy(t_vc_contact.number[t_next], t_content_buffer, NV_WATCH_VC_CONTACT_NUMBER_LEN - 1);
+                               t_current++;
+                       }
+
+                       temp_ptr += t_offset + 4;
+                       t_offset = 0;
+               }
+               else
+               {
+                       t_offset += 4;
+                       //PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: %d\n", __FUNCTION__, __LINE__, t_offset);
+               }
+
+               i += 4;
+               //PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: %d\n", __FUNCTION__, __LINE__, i);
+       }
+
+       t_next++;
+
+       PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: %d\n", __FUNCTION__, __LINE__, t_next);
+       for(i = 0; i < t_next; i++)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: %s\n", __FUNCTION__, __LINE__, t_vc_contact.number[i]);
+       }
+
+       t_vc_contact.total = t_next;
+       mmi_vc_contact_set(&t_vc_contact);
+
+       return result;
+}
+
+bool mmi_protocol_fzd_action_VC_CALL_REQUEST(char * number, uint8_t call_type)
+{
+       bool result = false;
+       MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_WATCH_VC_CALL_REQUEST;
+       unsigned char content_buff[NV_WATCH_VC_CONTACT_NUMBER_LEN + 8] = {0};
+       unsigned int content_lenth = 0;
+
+       sprintf(content_buff, ",%d,%s", call_type, number);
+       content_lenth = strlen(content_buff);
+
+       result = mmi_protocol_fzd_send_with_data(action, content_buff, content_lenth);
+
+       return result;
+}
+       
+// [XT*334588000000156*0006*AGTALK,0,efef2323423423,123]
+// 0-continue; other-stop
+bool mmi_protocol_fzd_parse_WATCH_VC_CALL_REQUEST(unsigned char * next_buff, unsigned int next_buff_len)
+{
+       bool result = false;
+
+       if(NULL == next_buff || 0 == next_buff_len)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               return false;
+       }
+
+       result = true;
+
+       char * t_value = NULL;
+       char * t_tokens = NULL;
+       char * t_ticket = NULL;
+
+       t_value = km_strtok_r(NULL, ",", &next_buff);
+       t_tokens = km_strtok_r(NULL, ",", &next_buff);
+       t_ticket = next_buff;
+
+       
+       PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: t_value=%s\n", __FUNCTION__, __LINE__, t_value);
+       PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%d]: t_tokens,%d,%s\n", __LINE__, strlen(t_tokens), t_tokens+0);
+       PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%d]: %s\n", __LINE__, t_tokens+31);
+       PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%d]: %s\n", __LINE__, t_tokens+63);
+       PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%d]: %s\n", __LINE__, t_tokens+95);
+       PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%d]: t_ticket,%d,%s\n", __LINE__, strlen(t_ticket), t_ticket+0);
+       
+       
+       if(0 == atoi(t_value))
+       {
+               // go on
+               mmi_vc_call_action_dialing_ext(t_tokens, t_ticket);     
+       }
+       else
+       {
+               // stop
+               mmi_vc_call_action_call_stop();
+       }
+       
+       return result;
+}
+
+// reject
+bool mmi_protocol_fzd_parse_SERVER_VC_CALL_RESPONSE(unsigned char * next_buff, unsigned int next_buff_len)
+{
+       bool result = false;
+       MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_SERVER_VC_CALL_RESPONSE;
+
+       if(NULL == next_buff || 0 == next_buff_len)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               return false;
+       }
+
+       result = true;
+       mmi_protocol_fzd_send_without_data(action);
+
+       // the other party is reject
+       mmi_vc_call_action_call_stop();
+       
+       return result;
+}
+
+bool mmi_protocol_fzd_action_SERVER_VC_CALL_REQUEST(int8_t state)
+{
+       bool result = false;
+       MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_SERVER_VC_CALL_REQUEST;
+       unsigned char content_buff[8] = {0};
+       unsigned int content_lenth = 0;
+
+       sprintf(content_buff, ",%d", state);
+       content_lenth = strlen(content_buff);
+
+       result = mmi_protocol_fzd_send_with_data(action, content_buff, content_lenth);
+
+       return result;
+}
+
+// [XT*YYYYYYYYYYYYYYY*LEN*CALLING,ºô½ÐÕßid,»áÒéid(ûÓÐÔòÁô¿Õ£¬µ«Î»Öñ£Áô£©,ÒôƵ»¹ÊÇÊÓÆµ£¨0ΪÒôƵ£¬1ΪÊÓÆµ£©£¬ÉùÍøToken]
+bool mmi_protocol_fzd_parse_SERVER_VC_CALL_REQUEST(unsigned char * next_buff, unsigned int next_buff_len)
+{
+       bool result = false;
+       MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_SERVER_VC_CALL_REQUEST;
+
+       if(NULL == next_buff || 0 == next_buff_len)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               return false;
+       }
+
+       if(true == mmi_vc_call_action_incoming_no_permission())
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               mmi_protocol_fzd_action_SERVER_VC_CALL_REQUEST(-1);
+               return false;
+       }
+       
+       result = true;
+       mmi_protocol_fzd_action_SERVER_VC_CALL_REQUEST(0);
+
+       char * t_ptr = NULL;
+       char t_number[NV_WATCH_VC_CONTACT_NUMBER_LEN] = {0};
+       char t_ticket[64 + 1] = {0};
+       uint8_t t_calltype = 0;
+       char t_tokens[128 + 1] = {0};
+
+       t_ptr = km_strtok_r(NULL, ",", &next_buff);
+       strncpy(t_number, t_ptr, NV_WATCH_VC_CONTACT_NUMBER_LEN - 1);
+
+       t_ptr = km_strtok_r(NULL, ",", &next_buff);
+       strncpy(t_ticket, t_ptr, strlen(t_ptr));
+       
+       t_ptr = km_strtok_r(NULL, ",", &next_buff);
+       t_calltype = atoi(t_ptr);
+
+       t_ptr = km_strtok_r(NULL, ",", &next_buff);
+       strncpy(t_tokens, t_ptr, strlen(t_ptr));
+
+       mmi_vc_call_action_incoming(t_number, t_calltype, t_ticket, t_tokens);
+       
+       return result;
+}
+
+// [XT*YYYYYYYYYYYYYYY*LEN*RCALLING,ºô½ÐÕßid,»áÒéid(ûÓÐÔòÁô¿Õ£¬µ«Î»Öñ£Áô£©,ÒôƵ»¹ÊÇÊÓÆµ£¨0ΪÒôƵ£¬1ΪÊÓÆµ£©]
+bool mmi_protocol_fzd_action_VC_CALL_RESPONSE(char * number, char * ticket, MODEM_VIDEO_CALL_TYPE type)
+{
+       bool result = false;
+       MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_WATCH_VC_CALL_RESPONSE;
+
+       unsigned char content_buff[NV_WATCH_VC_CONTACT_NUMBER_LEN + 64 + 8] = {0};
+       unsigned int content_lenth = 0;
+
+       sprintf(content_buff, ",%s,%s,%d", number, ticket, type);
+       content_lenth = strlen(content_buff);
+
+       result = mmi_protocol_fzd_send_with_data(action, content_buff, content_lenth);
+
+       return result;
+}
+#endif
+
+#ifdef __MMI_ZHSX_SUPPORT_VIDEO_CALL_TONGXIN__
+bool mmi_protocol_fzd_action_get_vc_contact(void)
+{
+       return mmi_protocol_fzd_send_without_data(MMI_FZD_WATCH_GET_VC_CONTACT);
+}
+
+bool mmi_protocol_fzd_action_get_vc_config(void)
+{
+       //get contact
+       return mmi_protocol_fzd_action_get_vc_contact();
+}
+
+bool mmi_protocol_fzd_parse_WATCH_GET_VC_CONFIG(unsigned char * next_buff, unsigned int next_buff_len)
+{
+       return false;
+}
+
+bool mmi_protocol_fzd_parse_WATCH_GET_VC_CONTACT(unsigned char * next_buff, unsigned int next_buff_len)
+{
+       bool result = false;
+       //MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_WATCH_GET_VC_CONTACT;
+
+       if(NULL == next_buff || 0 == next_buff_len)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               return false;
+       }
+       
+       result = true;
+       //mmi_protocol_fzd_send_without_data(action);
+
+       nv_watch_vc_contact_t t_vc_contact = {0};
+       char * temp_ptr = NULL;
+       uint8_t i = 0;
+       uint8_t t_len_1 = 0, t_len_2 = 0;
+
+       while (NULL != next_buff)
+       {
+               temp_ptr = km_strtok_r(NULL, ",", &next_buff);
+               if (NULL != temp_ptr)
+               {
+                       t_len_1 = FZD_MIN(strlen(temp_ptr), (NV_WATCH_VC_CONTACT_NUMBER_LEN - 1));
+                       strncpy(t_vc_contact.number[i], temp_ptr, t_len_1);
+               }
+               else
+               {
+                       break;
+               }
+               
+               temp_ptr = km_strtok_r(NULL, ",", &next_buff);
+               if (NULL != temp_ptr)
+               {
+                       t_len_1 = FZD_MIN(strlen(temp_ptr), ((NV_WATCH_VC_CONTACT_NAME_LEN - 1) * 4));
+                       mmi_unicode_hex_str_to_utf8_str(temp_ptr, t_len_1, t_vc_contact.name[i], &t_len_2);
+
+                       //PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: %d,%d\n", __FUNCTION__, __LINE__, t_len_1, t_len_2);
+                       //PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: %s\n", __FUNCTION__, __LINE__, temp_ptr);
+               }
+               else
+               {
+                       //PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+                       break;
+               }
+
+               i++;
+               if(NV_WATCH_VC_CONTACT_TOTAL <= i)
+               {
+                       break;
+               }
+       }
+
+       t_vc_contact.total = i;
+       mmi_vc_contact_set(&t_vc_contact);
+
+       return result;
+}
+
+bool mmi_protocol_fzd_action_VC_CALL_REQUEST(char * number, uint8_t call_type)
+{
+       bool result = false;
+       MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_WATCH_VC_CALL_REQUEST;
+       unsigned char content_buff[NV_WATCH_VC_CONTACT_NUMBER_LEN + 8] = {0};
+       unsigned int content_lenth = 0;
+
+       sprintf(content_buff, ",%s,%d", number, call_type);
+       content_lenth = strlen(content_buff);
+
+       result = mmi_protocol_fzd_send_with_data(action, content_buff, content_lenth);
+
+       return result;
+}
+       
+// [XT*YYYYYYYYYYYYYYY*LEN*AGTALK,ÒôÊÓÆµ×´Ì¬,»áÒéid,appKey,ÃØÔ¿,token,uid]
+// ״̬ 0-continue; other-stop
+bool mmi_protocol_fzd_parse_WATCH_VC_CALL_REQUEST(unsigned char * next_buff, unsigned int next_buff_len)
+{
+       bool result = false;
+
+       if(NULL == next_buff || 0 == next_buff_len)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               return false;
+       }
+
+       result = true;
+
+       char * t_value = NULL;
+       t_value = km_strtok_r(NULL, ",", &next_buff);
+       PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: t_value=%s\n", __FUNCTION__, __LINE__, t_value);
+       
+       if(0 == atoi(t_value))
+       {
+               // go on
+               char * t_ticket = NULL;
+               char * t_appkey = NULL;
+               char * t_secret = NULL;
+               char * t_tokens = NULL;
+               char * t_uid = NULL;
+               
+               t_ticket = km_strtok_r(NULL, ",", &next_buff);
+               t_appkey = km_strtok_r(NULL, ",", &next_buff);
+               t_secret = km_strtok_r(NULL, ",", &next_buff);
+               t_tokens = km_strtok_r(NULL, ",", &next_buff);
+               t_uid = next_buff;
+
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: %d,%d,%d\n", __FUNCTION__, __LINE__, strlen(t_ticket), strlen(t_appkey), strlen(t_secret));
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: %d,%d\n", __FUNCTION__, __LINE__, strlen(t_tokens), strlen(t_uid));
+               
+               mmi_vc_call_action_dialing_ext(t_ticket, t_appkey, t_secret, t_tokens, t_uid);  
+       }
+       else
+       {
+               // stop
+               mmi_vc_call_action_call_stop();
+       }
+       
+       return result;
+}
+
+// reject
+bool mmi_protocol_fzd_parse_SERVER_VC_CALL_RESPONSE(unsigned char * next_buff, unsigned int next_buff_len)
+{
+       bool result = false;
+       MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_SERVER_VC_CALL_RESPONSE;
+
+       if(NULL == next_buff || 0 == next_buff_len)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               return false;
+       }
+
+       result = true;
+       mmi_protocol_fzd_send_without_data(action);
+
+       // the other party is reject
+       mmi_vc_call_action_call_stop();
+       
+       return result;
+}
+
+bool mmi_protocol_fzd_action_SERVER_VC_CALL_REQUEST(int8_t state)
+{
+       bool result = false;
+       MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_SERVER_VC_CALL_REQUEST;
+       unsigned char content_buff[8] = {0};
+       unsigned int content_lenth = 0;
+
+       sprintf(content_buff, ",%d", state);
+       content_lenth = strlen(content_buff);
+
+       result = mmi_protocol_fzd_send_with_data(action, content_buff, content_lenth);
+
+       return result;
+}
+
+// [XT*YYYYYYYYYYYYYYY*LEN*CALLING,ºô½ÐÕßÕ˺Å,ͨ»°ÀàÐÍ,»áÒéid,appKey,ÃØÔ¿,token,uid]
+bool mmi_protocol_fzd_parse_SERVER_VC_CALL_REQUEST(unsigned char * next_buff, unsigned int next_buff_len)
+{
+       bool result = false;
+       MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_SERVER_VC_CALL_REQUEST;
+
+       if(NULL == next_buff || 0 == next_buff_len)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               return false;
+       }
+
+       if(true == mmi_vc_call_action_incoming_no_permission())
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               mmi_protocol_fzd_action_SERVER_VC_CALL_REQUEST(-1);
+               return false;
+       }
+               
+       result = true;
+       mmi_protocol_fzd_action_SERVER_VC_CALL_REQUEST(0);
+
+       char * t_number = NULL;
+       char * t_type = NULL;
+       char * t_ticket = NULL;
+       char * t_appkey = NULL;
+       char * t_secret = NULL;
+       char * t_tokens = NULL;
+       char * t_uid = NULL;
+       uint8_t t_value = 0;
+
+       //PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: %d\n", __FUNCTION__, __LINE__, next_buff_len);
+       //PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%d]: %s\n", __LINE__, next_buff+0);
+       //PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%d]: %s\n", __LINE__, next_buff+31);
+       //PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%d]: %s\n", __LINE__, next_buff+63);
+       //PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%d]: %s\n", __LINE__, next_buff+95);
+       
+       t_number = km_strtok_r(NULL, ",", &next_buff);
+       t_type = km_strtok_r(NULL, ",", &next_buff);
+       t_ticket = km_strtok_r(NULL, ",", &next_buff);
+       t_appkey = km_strtok_r(NULL, ",", &next_buff);
+       t_secret = km_strtok_r(NULL, ",", &next_buff);
+       t_tokens = km_strtok_r(NULL, ",", &next_buff);
+       t_uid = next_buff;
+       t_value = atoi(t_type);
+
+       PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: %d,%d,%d,%d,%d\n", __FUNCTION__, __LINE__, 
+                                                       strlen(t_ticket), strlen(t_appkey), strlen(t_secret), strlen(t_tokens), strlen(t_uid));
+       
+       mmi_vc_call_action_incoming(t_number, t_value, t_ticket, t_appkey, t_secret, t_tokens, t_uid);
+       
+       return result;
+}
+
+// [XT*YYYYYYYYYYYYYYY*LEN*RCALLING,ºô½ÐÕßÕ˺Å,ͨ»°ÀàÐÍ,»áÒéid]
+bool mmi_protocol_fzd_action_VC_CALL_RESPONSE(char * number, char * ticket, MODEM_VIDEO_CALL_TYPE type)
+{
+       bool result = false;
+       MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_WATCH_VC_CALL_RESPONSE;
+
+       if(NULL == number) // hang up
+       {
+               result = mmi_protocol_fzd_send_without_data(action);
+       }
+       else // reject
+       {
+               unsigned char content_buff[NV_WATCH_VC_CONTACT_NUMBER_LEN + 64 + 8] = {0};
+               unsigned int content_lenth = 0;
+
+               sprintf(content_buff, ",%s,%d,%s", number, type, ticket);
+               content_lenth = strlen(content_buff);
+
+               result = mmi_protocol_fzd_send_with_data(action, content_buff, content_lenth);
+       }
+       return result;
+}
+#endif
+
+#endif
+
+#ifdef __MMI_ZHSX_SUPPORT_DO_NOT_DISTURB__
+// [XT*334588000000156*0038*SILENCETIME2,7:30-21:10-1-0111110,7:30-21:10-1-0111110,7:30-21:10-0-0111110]
+bool mmi_protocol_fzd_parse_SERVER_SET_NOT_DISTURB(unsigned char * next_buff, unsigned int next_buff_len)
+{
+       bool result = false;
+       MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_SERVER_SET_NOT_DISTURB;
+
+       if(NULL == next_buff || 0 == next_buff_len)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               return false;
+       }
+       
+       result = true;
+       mmi_protocol_fzd_send_without_data(action);
+
+       nv_watch_do_not_disturb_t not_disturb_data = {0};
+       char * group_str = NULL;
+       char * group_last = NULL;
+       char * temp_ptr = NULL;
+       char * last = NULL;
+       uint8_t i = 0;
+
+       //PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: next_buff=%s\n", __FUNCTION__, __LINE__, next_buff);
+       group_str = km_strtok_r(next_buff, ",", &group_last);
+       //PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: temp_ptr1=%s,next_buff=%s\n", __FUNCTION__, __LINE__, group_str, next_buff);
+       while(NULL != group_str)
+       {
+               temp_ptr = km_strtok_r(group_str, ":", &last);
+               not_disturb_data.item_info[i].begin_hour = atoi(temp_ptr);
+               
+               temp_ptr = km_strtok_r(NULL, "-", &last);
+               not_disturb_data.item_info[i].begin_min = atoi(temp_ptr);
+
+               temp_ptr = km_strtok_r(NULL, ":", &last);
+               not_disturb_data.item_info[i].end_hour = atoi(temp_ptr);
+
+               temp_ptr = km_strtok_r(NULL, "-", &last);
+               not_disturb_data.item_info[i].end_min = atoi(temp_ptr);         
+
+               temp_ptr = km_strtok_r(NULL, "-", &last);
+               not_disturb_data.item_info[i].on_off = atoi(temp_ptr);
+               
+               //not_disturb_data.item_info[i].week_bitmap = 0x80; // 0xff;
+               if(NULL != last)
+               {
+                       uint8_t j = 0;
+                       for(j = 0; j < 7; j++)
+                       {
+                               not_disturb_data.item_info[i].week_bitmap |= ((('0' == *(last + j)) ? 0 : 1) << j);
+                       }
+               }
+
+               i++;
+               if(NV_WATCH_DO_NOT_DISTURB_ITEM_MAX <= i)
+               {
+                       break;
+               }
+               
+               group_str = km_strtok_r(NULL, ",", &group_last);
+       }
+
+       mmi_watch_do_not_disturb_data_set(&not_disturb_data);
+
+       //uint8_t x = 0;
+       //for(x = 0; x < i; x++)
+       //{
+       //      PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%d]: %d,%d\n", __LINE__, server_set_alarm[x].on_off, server_set_alarm[x].repeat_bitmap);
+       //}
+
+       return result;
+}
+#endif
+
+#ifdef __MMI_SLEEP_FUNCTION_SUPPORT__
+// [*SLEEPTIME,21:30-6:10] [*SLEEPTIME,]
+bool mmi_protocol_fzd_parse_SERVER_SET_SLEEPTIME(unsigned char * next_buff, unsigned int next_buff_len)
+{
+       bool result = false;
+       MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_SERVER_SET_SLEEPTIME;
+
+       result = true;
+       mmi_protocol_fzd_send_without_data(action);
+       
+       nv_watch_sleep_time_t data = {0};
+       char * temp_ptr = NULL;
+       
+       if(NULL == next_buff || 0 == next_buff_len)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+       }
+       else
+       {
+               data.on_off = 1;
+               
+               temp_ptr = km_strtok_r(NULL, ":", &next_buff);
+               data.begin_hour = atoi(temp_ptr);
+
+               temp_ptr = km_strtok_r(NULL, "-", &next_buff);
+               data.begin_min = atoi(temp_ptr);
+
+               temp_ptr = km_strtok_r(NULL, ":", &next_buff);
+               data.end_hour = atoi(temp_ptr);
+
+               data.end_min = atoi(next_buff);
+       }
+       
+       mmi_watch_sleep_time_data_set(&data);
+
+       return result;
+}
+#endif
+
+// 0-off; 1-on
+bool mmi_protocol_fzd_parse_SERVER_SET_UD_SWITCH(unsigned char * next_buff, unsigned int next_buff_len)
+{
+       bool result = false;
+       MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_SERVER_SET_UD_SWITCH;
+
+       if(NULL == next_buff || 0 == next_buff_len)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               return false;
+       }
+       
+       result = true;
+       mmi_protocol_fzd_send_without_data(action);
+
+       uint32_t value = atoi(next_buff);
+       mmi_timing_location_switch_set(value);
+       
+       return result;
+}
+       
+bool mmi_protocol_fzd_parse_SERVER_SET_DIAL_PAD_SWITCH(unsigned char * next_buff, unsigned int next_buff_len)
+{
+       bool result = false;
+       MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_SERVER_SET_DIAL_PAD_SWITCH;
+
+       if(NULL == next_buff || 0 == next_buff_len)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               return false;
+       }
+       
+       result = true;
+       mmi_protocol_fzd_send_without_data(action);
+
+       uint32_t value = atoi(next_buff);
+       mmi_dial_pad_switch_set(value);
+       
+       return result;
+}
+
+// 0-off; 1-on; 2-auto answer
+bool mmi_protocol_fzd_parse_SERVER_SET_WHITE_LIST_SWITCH(unsigned char * next_buff, unsigned int next_buff_len)
+{
+       bool result = false;
+       MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_SERVER_SET_WHITE_LIST_SWITCH;
+
+       if(NULL == next_buff || 0 == next_buff_len)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               return false;
+       }
+       
+       result = true;
+       mmi_protocol_fzd_send_without_data(action);
+
+       uint32_t value = atoi(next_buff);
+       mmi_white_list_switch_set(value);
+       
+       return result;
+}
+
+// 0-off; 1-on
+bool mmi_protocol_fzd_parse_SERVER_SET_LOW_BATTERY_SWITCH(unsigned char * next_buff, unsigned int next_buff_len)
+{
+       bool result = false;
+       MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_SERVER_SET_LOW_BATTERY_SWITCH;
+
+       if(NULL == next_buff || 0 == next_buff_len)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               return false;
+       }
+       
+       result = true;
+       mmi_protocol_fzd_send_without_data(action);
+
+       uint32_t value = atoi(next_buff);
+       mmi_low_battery_switch_set(value);
+       
+       return result;
+}
+
+// 0-off; 1-on
+bool mmi_protocol_fzd_parse_SERVER_SET_FALL_DOWN_SWITCH(unsigned char * next_buff, unsigned int next_buff_len)
+{
+       bool result = false;
+       MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_SERVER_SET_FALL_DOWN_SWITCH;
+
+       if(NULL == next_buff || 0 == next_buff_len)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               return false;
+       }
+       
+       result = true;
+       mmi_protocol_fzd_send_without_data(action);
+
+       uint32_t value = atoi(next_buff);
+       mmi_fall_down_switch_set(value);
+       
+       return result;
+}
+
+// 0-off; 1-on
+bool mmi_protocol_fzd_parse_SERVER_SET_TAKE_OFF_SWITCH(unsigned char * next_buff, unsigned int next_buff_len)
+{
+       bool result = false;
+       MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_SERVER_SET_TAKE_OFF_SWITCH;
+
+       if(NULL == next_buff || 0 == next_buff_len)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               return false;
+       }
+       
+       result = true;
+       mmi_protocol_fzd_send_without_data(action);
+
+       uint32_t value = atoi(next_buff);
+       mmi_take_off_switch_set(value);
+       
+       return result;
+}
+
+#ifdef __MMI_REMIND_WAKE_UP_SUPPORT__
+//[XX*YYYY*0018*REMIND,08:10-1-1,08:10-1-2, 08:10-1-3-0111110]
+//[SZKW*860132060004801*0034*REMIND,10:00-1-1,10:02-1-3-0111000,10:03-1-3-0111111]
+bool mmi_protocol_fzd_parse_SERVER_SET_REMIND_WAKE_UP(unsigned char * next_buff, unsigned int next_buff_len)
+{
+       bool result = false;
+       MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_SERVER_SET_REMIND_WAKE_UP;
+
+       if(NULL == next_buff || 0 == next_buff_len)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               return false;
+       }
+       
+       result = true;
+       mmi_protocol_fzd_send_without_data(action);
+
+       nv_watch_remind_item_t t_data = {0};
+       char * group_str = NULL;
+       char * group_last = NULL;
+       char * temp_ptr = NULL;
+       char * last = NULL;
+       uint8_t i = 0;
+
+       //PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: next_buff=%s\n", __FUNCTION__, __LINE__, next_buff);
+       group_str = km_strtok_r(next_buff, ",", &group_last);
+       //PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: temp_ptr1=%s,next_buff=%s\n", __FUNCTION__, __LINE__, group_str, next_buff);
+       while(NULL != group_str)
+       {
+               temp_ptr = km_strtok_r(group_str, ":", &last);
+               t_data.remind_info[i].hour = atoi(temp_ptr);
+               
+               temp_ptr = km_strtok_r(NULL, "-", &last);
+               t_data.remind_info[i].min = atoi(temp_ptr);
+
+               temp_ptr = km_strtok_r(NULL, "-", &last);
+               t_data.remind_info[i].is_valid = atoi(temp_ptr);
+               
+               temp_ptr = km_strtok_r(NULL, "-", &last);
+               //PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: temp_ptr=%s,last=%s\n", __FUNCTION__, __LINE__, temp_ptr, last);
+               if(1 == atoi(temp_ptr))
+               {
+                       t_data.remind_info[i].repeat_bitmap = 0;
+               }
+               else if(2 == atoi(temp_ptr))
+               {
+                       t_data.remind_info[i].repeat_bitmap = 0xff;
+               }
+               else
+               {
+                       //server_set_alarm[i].repeat_bitmap = 0xff;
+                       t_data.remind_info[i].repeat_bitmap = 0x80;
+                       if(NULL != last)
+                       {
+                               uint8_t j = 0;
+                               for(j = 0; j < 7; j++)
+                               {
+                                       //server_set_alarm[i].repeat_bitmap &= ((('0' == *(last + j)) ? 0 : 1) << j);
+                                       t_data.remind_info[i].repeat_bitmap |= ((('0' == *(last + j)) ? 0 : 1) << j);
+                               }
+                       }
+               }
+
+               i++;
+               if(NV_REMIND_ITEM_MAX_NUM <= i)
+               {
+                       break;
+               }
+               
+               group_str = km_strtok_r(NULL, ",", &group_last);
+       }
+
+       mmi_remind_wake_up_data_set(&t_data);
+
+       return result;
+}
+#endif
+
+#ifdef __MMI_REMIND_SLEEP_SUPPORT__
+// [SZKW*876226002021592*001B*REMIND_CH_SLEEP,11:00-1-2,,]
+bool mmi_protocol_fzd_parse_SERVER_SET_REMIND_SLEEP(unsigned char * next_buff, unsigned int next_buff_len)
+{
+       bool result = false;
+       MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_SERVER_SET_REMIND_SLEEP;
+
+       if(NULL == next_buff || 0 == next_buff_len)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               return false;
+       }
+       
+       result = true;
+       mmi_protocol_fzd_send_without_data(action);
+
+       nv_watch_remind_item_t t_data = {0};
+       char * group_str = NULL;
+       char * group_last = NULL;
+       char * temp_ptr = NULL;
+       char * last = NULL;
+       uint8_t i = 0;
+
+       //PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: next_buff=%s\n", __FUNCTION__, __LINE__, next_buff);
+       group_str = km_strtok_r(next_buff, ",", &group_last);
+       //PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: temp_ptr1=%s,next_buff=%s\n", __FUNCTION__, __LINE__, group_str, next_buff);
+       while(NULL != group_str)
+       {
+               temp_ptr = km_strtok_r(group_str, ":", &last);
+               t_data.remind_info[i].hour = atoi(temp_ptr);
+               
+               temp_ptr = km_strtok_r(NULL, "-", &last);
+               t_data.remind_info[i].min = atoi(temp_ptr);
+
+               temp_ptr = km_strtok_r(NULL, "-", &last);
+               t_data.remind_info[i].is_valid = atoi(temp_ptr);
+               
+               temp_ptr = km_strtok_r(NULL, "-", &last);
+               //PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: temp_ptr=%s,last=%s\n", __FUNCTION__, __LINE__, temp_ptr, last);
+               if(1 == atoi(temp_ptr))
+               {
+                       t_data.remind_info[i].repeat_bitmap = 0;
+               }
+               else if(2 == atoi(temp_ptr))
+               {
+                       t_data.remind_info[i].repeat_bitmap = 0xff;
+               }
+               else
+               {
+                       //server_set_alarm[i].repeat_bitmap = 0xff;
+                       t_data.remind_info[i].repeat_bitmap = 0x80;
+                       if(NULL != last)
+                       {
+                               uint8_t j = 0;
+                               for(j = 0; j < 7; j++)
+                               {
+                                       //server_set_alarm[i].repeat_bitmap &= ((('0' == *(last + j)) ? 0 : 1) << j);
+                                       t_data.remind_info[i].repeat_bitmap |= ((('0' == *(last + j)) ? 0 : 1) << j);
+                               }
+                       }
+               }
+
+               i++;
+               if(NV_REMIND_ITEM_MAX_NUM <= i)
+               {
+                       break;
+               }
+               
+               group_str = km_strtok_r(NULL, ",", &group_last);
+       }
+
+       mmi_remind_sleep_data_set(&t_data);
+
+       return result;
+}
+#endif
+
+// [*REMIND_CH_REST,01:00-00:03,22:00-23:00]
+// [*REMIND_CH_REST,]
+#ifdef __MMI_REMIND_REST_SUPPORT__
+bool mmi_protocol_fzd_parse_SERVER_SET_REMIND_REST(unsigned char * next_buff, unsigned int next_buff_len)
+{
+       bool result = false;
+       MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_SERVER_SET_REMIND_REST;
+
+       nv_watch_remind_rest_t t_data = {0};
+       
+       if(NULL == next_buff || 0 == next_buff_len)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+       }
+       else
+       {
+               char * group_str = NULL;
+               char * group_last = NULL;
+               char * temp_ptr = NULL;
+               char * last = NULL;
+               uint8_t i = 0;
+
+               t_data.is_valid = 1;
+               
+               //PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: next_buff=%s\n", __FUNCTION__, __LINE__, next_buff);
+               group_str = km_strtok_r(next_buff, ",", &group_last);
+               //PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: temp_ptr1=%s,next_buff=%s\n", __FUNCTION__, __LINE__, group_str, next_buff);
+               while(NULL != group_str)
+               {
+                       temp_ptr = km_strtok_r(group_str, ":", &last);
+                       t_data.remind_info[i].hour_begin = atoi(temp_ptr);
+                       
+                       temp_ptr = km_strtok_r(NULL, "-", &last);
+                       t_data.remind_info[i].min_begin = atoi(temp_ptr);
+
+                       temp_ptr = km_strtok_r(NULL, ":", &last);
+                       t_data.remind_info[i].hour_end = atoi(temp_ptr);
+                       
+                       temp_ptr = km_strtok_r(NULL, "-", &last);
+                       t_data.remind_info[i].min_end = atoi(temp_ptr);
+
+                       i++;
+                       if(NV_REMIND_REST_MAX_NUM <= i)
+                       {
+                               break;
+                       }
+                       
+                       group_str = km_strtok_r(NULL, ",", &group_last);
+               }
+       }
+
+       result = true;
+       mmi_protocol_fzd_send_without_data(action);
+
+       mmi_remind_rest_data_set(&t_data);
+
+       return result;
+}
+#endif
+
+// [*REMIND_CH_HOME,01:00] [*REMIND_CH_HOME,]
+#ifdef __MMI_REMIND_HOME_SUPPORT__
+bool mmi_protocol_fzd_parse_SERVER_SET_REMIND_HOME(unsigned char * next_buff, unsigned int next_buff_len)
+{
+       bool result = false;
+       MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_SERVER_SET_REMIND_HOME;
+
+       nv_watch_remind_home_t t_data = {0};
+       
+       if(NULL == next_buff || 0 == next_buff_len)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+       }
+       else
+       {
+               char * temp_ptr = NULL;
+
+               t_data.is_valid = 1;
+               
+               temp_ptr = km_strtok_r(NULL, ":", &next_buff);
+               t_data.hour = atoi(temp_ptr);
+               
+               temp_ptr = next_buff;
+               t_data.min = atoi(temp_ptr);
+       }
+       
+       result = true;
+       mmi_protocol_fzd_send_without_data(action);
+
+       mmi_remind_home_data_set(&t_data);
+
+       return result;
+}
+#endif
+
+// [*REMIND_CH_MEDICINE,02:00,01:00,10:00]
+// [*REMIND_CH_MEDICINE,01:00,00:00]
+// [*REMIND_CH_MEDICINE,]
+#ifdef __MMI_REMIND_MEDICINE_SUPPORT__
+bool mmi_protocol_fzd_parse_SERVER_SET_REMIND_MEDICINE(unsigned char * next_buff, unsigned int next_buff_len)
+{
+       bool result = false;
+       MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_SERVER_SET_REMIND_MEDICINE;
+
+       nv_watch_remind_medicine_t t_data = {0};
+       
+       if(NULL == next_buff || 0 == next_buff_len)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+       }
+       else
+       {
+               char * group_str = NULL;
+               char * group_last = NULL;
+               char * temp_ptr = NULL;
+               char * last = NULL;
+               uint8_t i = 0;
+
+               //PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: next_buff=%s\n", __FUNCTION__, __LINE__, next_buff);
+               group_str = km_strtok_r(next_buff, ",", &group_last);
+               //PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: temp_ptr1=%s,next_buff=%s\n", __FUNCTION__, __LINE__, group_str, next_buff);
+               while(NULL != group_str)
+               {
+                       t_data.remind_info[i].is_valid = 1;
+                       
+                       temp_ptr = km_strtok_r(group_str, ":", &last);
+                       t_data.remind_info[i].hour = atoi(temp_ptr);
+                       
+                       temp_ptr = km_strtok_r(NULL, ":", &last);
+                       t_data.remind_info[i].min = atoi(temp_ptr);             
+
+                       i++;
+                       if(NV_REMIND_MEDICINE_MAX_NUM <= i)
+                       {
+                               break;
+                       }
+                       
+                       group_str = km_strtok_r(NULL, ",", &group_last);
+               }
+       }
+       
+       result = true;
+       mmi_protocol_fzd_send_without_data(action);
+
+       mmi_remind_medicine_data_set(&t_data);
+
+       return result;
+}
+#endif
+
+// [*REMIND_CH_MEDICINE2,10:00-1,14:00-0,18:00-0,1111111]
+// [*REMIND_CH_MEDICINE2,09:00-1,14:00-0,18:00-1,1111111]
+#ifdef __MMI_REMIND_CUSTOM_MEDICINE_SUPPORT__
+bool mmi_protocol_fzd_parse_SERVER_SET_REMIND_CUSTOM_MEDICINE(unsigned char * next_buff, unsigned int next_buff_len)
+{
+       bool result = false;
+       MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_SERVER_SET_REMIND_CUSTOM_MEDICINE;
+
+       if(NULL == next_buff || 0 == next_buff_len)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               return false;
+       }
+       
+       result = true;
+       mmi_protocol_fzd_send_without_data(action);
+
+       nv_watch_remind_custom_medicine_t t_data = {0};
+       char * group_str = NULL;
+       char * group_last = NULL;
+       char * temp_ptr = NULL;
+       char * last = NULL;
+       uint8_t i = 0;
+
+       //PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: next_buff=%s\n", __FUNCTION__, __LINE__, next_buff);
+       group_str = km_strtok_r(next_buff, ",", &group_last);
+       //PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: temp_ptr1=%s,next_buff=%s\n", __FUNCTION__, __LINE__, group_str, next_buff);
+       while(NULL != group_str)
+       {
+               temp_ptr = km_strtok_r(group_str, ":", &last);
+               t_data.remind_info[i].hour = atoi(temp_ptr);
+               
+               temp_ptr = km_strtok_r(NULL, "-", &last);
+               t_data.remind_info[i].min = atoi(temp_ptr);
+
+               temp_ptr = last;
+               t_data.remind_info[i].is_valid = atoi(temp_ptr);
+               
+               i++;
+               if(NV_REMIND_CUSTOM_MEDICINE_MAX_NUM <= i)
+               {
+                       break;
+               }
+               
+               group_str = km_strtok_r(NULL, ",", &group_last);
+       }
+
+       //server_set_alarm[i].repeat_bitmap = 0xff;
+       t_data.repeat_bitmap = 0x80;
+       if(NULL != group_last)
+       {
+               uint8_t j = 0;
+               for(j = 0; j < 7; j++)
+               {
+                       //server_set_alarm[i].repeat_bitmap &= ((('0' == *(last + j)) ? 0 : 1) << j);
+                       t_data.repeat_bitmap |= ((('0' == *(last + j)) ? 0 : 1) << j);
+               }
+       }
+
+       mmi_remind_custom_medicine_data_set(&t_data);
+
+       return result;
+}
+#endif
+
+// [*REMIND_CH_DRINK,4-1]
+#ifdef __MMI_REMIND_DRINK_SUPPORT__
+bool mmi_protocol_fzd_parse_SERVER_SET_REMIND_DRINK(unsigned char * next_buff, unsigned int next_buff_len)
+{
+       bool result = false;
+       MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_SERVER_SET_REMIND_DRINK;
+
+       if(NULL == next_buff || 0 == next_buff_len)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               return false;
+       }
+
+       result = true;
+       mmi_protocol_fzd_send_without_data(action);
+
+       nv_watch_remind_drink_t t_data = {0};
+       char * temp_ptr = NULL;
+
+       // compatible '-' & ','
+       if(NULL != strchr(next_buff, '-'))
+       {
+               temp_ptr = km_strtok_r(NULL, "-", &next_buff);
+       }
+       else
+       {
+               temp_ptr = km_strtok_r(NULL, ",", &next_buff);
+       }
+       t_data.hour_value = atoi(temp_ptr);
+
+       temp_ptr = next_buff;
+       t_data.is_valid = atoi(temp_ptr);
+
+       mmi_remind_drink_data_set(&t_data);
+
+       return result;
+}
+#endif
+
+
+#ifdef __MMI_CUSTOM_HENG_AI__
+bool mmi_protocol_fzd_parse_SERVER_SET_HENG_AI_WAKE_NOW(unsigned char * next_buff, unsigned int next_buff_len)
+{
+       bool result = false;
+       MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_SERVER_SET_HENG_AI_WAKE_NOW;
+       
+       result = true;
+       mmi_protocol_fzd_send_without_data(action);
+
+       mmi_heng_ai_wake_now_aciton();
+
+       return result;
+}
+               
+bool mmi_protocol_fzd_parse_SERVER_SET_HENG_AI_WAKE_RING_TYPE(unsigned char * next_buff, unsigned int next_buff_len)
+{
+       bool result = false;
+       MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_SERVER_SET_HENG_AI_WAKE_RING_TYPE;
+
+       if(NULL == next_buff || 0 == next_buff_len)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               return false;
+       }
+       
+       result = true;
+       mmi_protocol_fzd_send_without_data(action);
+
+       uint32_t value = atoi(next_buff);
+       if(0 == value || 1 == value)
+       {
+               mmi_heng_ai_wake_ring_type_set(value);
+       }
+       
+       return result;
+}
+
+bool mmi_protocol_fzd_parse_SERVER_SET_HENG_AI_WARNING(unsigned char * next_buff, unsigned int next_buff_len)
+{
+       bool result = false;
+       MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_SERVER_SET_HENG_AI_WARNING;
+
+       if(NULL == next_buff || 0 == next_buff_len)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               return false;
+       }
+       
+       result = true;
+       mmi_protocol_fzd_send_without_data(action);
+
+       char * temp_ptr = NULL;
+       uint8_t type_value = 0;
+       uint8_t state_value = 0;
+
+       temp_ptr = km_strtok_r(NULL, ",", &next_buff);
+       type_value = atoi(temp_ptr);
+
+       temp_ptr = km_strtok_r(NULL, ",", &next_buff);
+       state_value = atoi(temp_ptr);
+       
+       PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+       
+       mmi_heng_ai_warning_info_set(type_value, state_value, next_buff);
+       
+       return result;
+}
+#endif
+
+#ifdef __MMI_CUSTOM_HENGAI_SLEEP__
+// [*HENGAI_ACTIVATION, name, model, firm, sensor,fs, sinklib_version, request_code] 
+bool mmi_protocol_fzd_action_hengai_activation(char * req_code)
+{
+       bool result = false;
+       MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_ACTION_HENGAI_ACTIVATION;
+       unsigned char * content_buff = NULL;
+       unsigned int content_lenth = 256;
+
+       char * name = "Z5_HA_K7"; // É豸Ãû³Æ
+       char * model = "Z5_HA_K7"; // É豸ÐͺÅ
+       char * firm = "zh"; // É豸³§ÉÌ
+       char * sensor = "whale"; // ´«¸ÐÆ÷ÐͺÅ
+       uint16_t fs = 50; // ²ÉÑùÂÊ
+       char * sinklib_version = "v0.3.2.101122"; // Ï³Á¿â°æ±¾ºÅ
+
+       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);
+       
+       sprintf(content_buff, ",%s,%s,%s,%s,%d,%s,%s", name, model, firm, sensor, fs, sinklib_version, req_code);
+       content_lenth = strlen(content_buff);
+       
+       result = mmi_protocol_fzd_send_with_data(action, content_buff, content_lenth);
+       lv_mem_free(content_buff);
+       
+       return result;
+}
+
+bool mmi_protocol_fzd_parse_ACTION_HENGAI_ACTIVATION(unsigned char * next_buff, unsigned int next_buff_len)
+{
+       bool result = false;
+       MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_ACTION_HENGAI_ACTIVATION;
+
+       if(NULL == next_buff || 0 == next_buff_len)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               return false;
+       }
+       
+       result = true;
+       //mmi_protocol_fzd_send_without_data(action);
+
+       PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+       
+       mmi_hengai_sleep_activation_act_code_set(next_buff, next_buff_len);
+       
+       return result;
+}
+
+bool mmi_protocol_fzd_action_hengai_activation_feedback(void)
+{
+       return mmi_protocol_fzd_send_without_data(MMI_FZD_ACTION_HENGAI_ACTIVATION_FEEDBACK);
+}
+
+bool mmi_protocol_fzd_action_hengai_sleep_data(char * file_buf, uint32_t file_size)
+{
+       bool result = false;
+       MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_ACTION_HENGAI_SLEEP_DATA;
+       unsigned char * content_buff = NULL;
+       unsigned int content_lenth = 0;
+
+       content_buff = (unsigned char *)lv_mem_alloc(file_size + 2);
+       if(NULL == content_buff)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               return false;
+       }
+       _lv_memset_00(content_buff, file_size + 2);
+       sprintf(content_buff, ",");
+       _lv_memcpy(content_buff + 1, file_buf, file_size);
+       content_lenth = file_size;
+       
+       result = mmi_protocol_fzd_send_with_data(action, content_buff, content_lenth);
+       lv_mem_free(content_buff);
+       
+       return result;
+}
+
+#if 0
+bool mmi_protocol_fzd_action_hengai_gsensor_data(char * file_buf, uint32_t file_size)
+{
+       bool result = false;
+       MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_ACTION_GSENSOR_DATA_UPLOAD;
+       unsigned char * content_buff = NULL;
+       unsigned int content_lenth = 0;
+
+       content_buff = (unsigned char *)lv_mem_alloc(file_size + 2);
+       if(NULL == content_buff)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               return false;
+       }
+       _lv_memset_00(content_buff, file_size + 2);
+       sprintf(content_buff, ",");
+       _lv_memcpy(content_buff + 1, file_buf, file_size);
+       content_lenth = file_size;
+       
+       result = mmi_protocol_fzd_send_with_data(action, content_buff, content_lenth);
+       lv_mem_free(content_buff);
+       
+       return result;
+}
+
+bool mmi_protocol_fzd_parse_SERVER_SET_GSENSOR_UPLOAD_SWITCH(unsigned char * next_buff, unsigned int next_buff_len)
+{
+       bool result = false;
+       MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_SERVER_SET_GSENSOR_UPLOAD_SWITCH;
+
+       if(NULL == next_buff || 0 == next_buff_len)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               return false;
+       }
+       
+       result = true;
+       mmi_protocol_fzd_send_without_data(action);
+
+       uint8_t state_value = 0;
+       state_value = atoi(next_buff);
+       
+       PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+       
+       mmi_heng_ai_gsensor_upload_switch_set(state_value);
+       
+       return result;
+}
+
+bool mmi_protocol_fzd_parse_SERVER_SET_GSENSOR_DATA(unsigned char * next_buff, unsigned int next_buff_len)
+{
+       bool result = false;
+       MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_SERVER_SET_GSENSOR_DATA;
+
+       if(NULL == next_buff || 0 == next_buff_len)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               return false;
+       }
+       
+       result = true;
+       mmi_protocol_fzd_send_without_data(action);
+
+       
+       PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+       
+       __gsensor_data_set(next_buff, next_buff_len);
+       
+       return result;
+}
+
+
+bool mmi_protocol_fzd_action_hengai_sleep_data_test(char * file_buf, uint32_t file_size)
+{
+       bool result = false;
+       MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_ACTION_HENGAI_SLEEP_DATA_TEST;
+       unsigned char * content_buff = NULL;
+       unsigned int content_lenth = 0;
+
+       content_buff = (unsigned char *)lv_mem_alloc(file_size + 2);
+       if(NULL == content_buff)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               return false;
+       }
+       _lv_memset_00(content_buff, file_size + 2);
+       sprintf(content_buff, ",");
+       _lv_memcpy(content_buff + 1, file_buf, file_size);
+       content_lenth = file_size;
+       
+       result = mmi_protocol_fzd_send_with_data(action, content_buff, content_lenth);
+       lv_mem_free(content_buff);
+       
+       return result;
+}
+
+#endif
+
+#endif
+
+#ifdef __MMI_CUSTOM_HENGAI_TCMS__
+bool mmi_protocol_fzd_parse_SERVER_SET_HENGAI_TCMS_SWITCH(unsigned char * next_buff, unsigned int next_buff_len)
+{
+       bool result = false;
+       MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_SERVER_SET_HENGAI_TCMS_SWITCH;
+
+       if(NULL == next_buff || 0 == next_buff_len)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               return false;
+       }
+       
+       result = true;
+       mmi_protocol_fzd_send_without_data(action);
+
+       uint8_t state_value = 0;
+       state_value = atoi(next_buff);
+       
+       PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+       
+       mmi_hengai_tcms_switch_set(state_value);
+       
+       return result;
+}
+
+bool mmi_protocol_fzd_action_hengai_tcms_data(char * data_ptr, uint32_t data_len)
+{
+       bool result = false;
+       MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_ACTION_HENGAI_TCMS_DATA;
+       unsigned char * content_buff = NULL;
+       unsigned int content_lenth = 0;
+       unsigned char * temp_ptr = NULL;
+       unsigned int temp_lenth = 0;
+       uint32_t cur_time_stamp = 0;
+
+       content_lenth = data_len + 128;
+       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);
+
+       Hal_Rtc_Gettime_Count_Utc(&cur_time_stamp); // Hal_Rtc_Gettime_Count(&cur_time_stamp);
+       
+       temp_lenth = 0;
+       temp_ptr = content_buff + temp_lenth;
+       sprintf(temp_ptr, ",%d,%d,", 0, cur_time_stamp);
+
+       temp_lenth = strlen(temp_ptr);
+       temp_ptr += temp_lenth;
+
+       _lv_memcpy(temp_ptr, data_ptr, data_len - 1); // not copy the last char(',')
+
+       content_lenth = strlen(content_buff);
+       
+       PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: %d\n", __FUNCTION__, __LINE__, content_lenth);
+       PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%d]: %s\n", __LINE__, content_buff);
+       PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%d]: %s\n", __LINE__, content_buff + 90);
+       PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%d]: %s\n", __LINE__, content_buff + 180);
+       result = mmi_protocol_fzd_send_with_data(action, content_buff, content_lenth);
+
+       if(NULL != content_buff)
+       {
+               lv_mem_free(content_buff);
+               content_buff = NULL;
+       }
+       
+       return true;
+}
+#endif
+
+bool mmi_protocol_fzd_action_tcp_http(char * data_ptr, uint32_t data_len)
+{
+       bool result = false;
+       MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_ACTION_TCP_HTTP;
+       unsigned char * content_buff = NULL;
+       unsigned int content_lenth = 0;
+       unsigned char * temp_ptr = NULL;
+       unsigned int temp_lenth = 0;
+
+#if 1
+       PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: %d\n", __FUNCTION__, __LINE__, data_len);
+       PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%d]: %s\n", __LINE__, data_ptr);
+
+       result = mmi_protocol_fzd_send_with_data(action, data_ptr, data_len);
+#else
+
+       content_lenth = data_len + 8;
+       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);
+
+       temp_lenth = 0;
+       temp_ptr = content_buff + temp_lenth;
+       sprintf(temp_ptr, ",");
+
+       temp_lenth = strlen(temp_ptr);
+       temp_ptr += temp_lenth;
+       _lv_memcpy(temp_ptr, data_ptr, data_len);
+
+       content_lenth = strlen(content_buff);
+       
+       PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: %d\n", __FUNCTION__, __LINE__, content_lenth);
+       PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%d]: %s\n", __LINE__, content_buff);
+
+       result = mmi_protocol_fzd_send_with_data(action, content_buff, content_lenth);
+
+       if(NULL != content_buff)
+       {
+               lv_mem_free(content_buff);
+               content_buff = NULL;
+       }
+#endif
+       
+       return true;
+}
+
+bool mmi_protocol_fzd_parse_ACTION_TCP_HTTP(unsigned char * next_buff, unsigned int next_buff_len)
+{
+       bool result = false;
+       MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_ACTION_TCP_HTTP;
+
+       if(NULL == next_buff || 0 == next_buff_len)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               return false;
+       }
+       
+       result = true;
+       //mmi_protocol_fzd_send_without_data(action);
+
+       char * temp_ptr = NULL;
+       int state_code = 0;
+
+       temp_ptr = km_strtok_r(NULL, ",", &next_buff);
+       state_code = atoi(temp_ptr);
+       PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: %d\n", __FUNCTION__, __LINE__, state_code);
+       
+       if(5000 != state_code && 4005 != state_code)
+       {
+       #ifdef __MMI_CUSTOM_HENGAI_HEALTH_UPLOAD_USE_TCP__
+               mmi_hengai_health_data_parse(next_buff, strlen(next_buff));
+       #else
+
+       #endif
+       }
+       
+       return result;
+}
+
+
+
+#endif
+
+
diff --git a/2.sdk/sdk/gui/lv_watch/mmi_protocol/mmi_protocol_fzd.h b/2.sdk/sdk/gui/lv_watch/mmi_protocol/mmi_protocol_fzd.h
new file mode 100644 (file)
index 0000000..205da75
--- /dev/null
@@ -0,0 +1,387 @@
+
+
+
+#ifndef __MMI_PROTOCOL_FZD_H__
+#define __MMI_PROTOCOL_FZD_H__
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif //__cplusplus
+
+#ifdef LV_CONF_INCLUDE_SIMPLE
+#include "lvgl.h"
+#include "lv_watch_conf.h"
+#else
+#include "../../../lvgl/lvgl.h"
+#include "../../../lv_watch_conf.h"
+#endif
+
+#ifdef __MMI_ZHSX_SUPPORT_FZD__
+
+
+/****************************************
+
+FORMAT: [MD5_DATADEVICE_NAME*DEVICE_ID*CONTENT_LENGTH*CONTENT_KEY,CONTENT_VALUE]
+
+****************************************/
+
+//#ifdef __MMI_ZHSX_SUPPORT_WULIAN_SERVER__
+//#define MMI_PROTOCOL_FZD_MD5_KEY_STR         "3JyCjsw4ryXKzjzudayY"
+//#else
+//#define MMI_PROTOCOL_FZD_MD5_KEY_STR         "bZld0ALsZTt15tKEZhOlLPgbsO75BLTP" // "FDF9532BB5914C0F9D0999CAF99DEBB9" // "XMQcHi0lGIdru6xzW7lygBwBT8N0c09P"
+//#endif
+//#define MMI_PROTOCOL_FZD_MD5_KEY_LEN         (strlen(MMI_PROTOCOL_FZD_MD5_KEY_STR)) // (32)
+#define MMI_PROTOCOL_FZD_MD5_DATA_LEN  (32)
+
+
+#define MMI_PROTOCOL_FZD_HEAD_BRACKET          "["
+#define MMI_PROTOCOL_FZD_BRACKET_LEN           (strlen(MMI_PROTOCOL_FZD_HEAD_BRACKET))
+//#ifdef __MMI_ZHSX_SUPPORT_WULIAN_SERVER__
+//#define MMI_PROTOCOL_FZD_DEVICE_NAME         "qAELPTKmFanR4RHe"
+//#else
+//#define MMI_PROTOCOL_FZD_DEVICE_NAME         "SZKW" // "ZHSX"
+//#endif
+//#define MMI_PROTOCOL_FZD_DEVICE_NAME_LEN     (strlen(MMI_PROTOCOL_FZD_DEVICE_NAME))
+#define MMI_PROTOCOL_FZD_SEPARATOR                     "*"
+#define MMI_PROTOCOL_FZD_SEPARATOR_LEN         (strlen(MMI_PROTOCOL_FZD_SEPARATOR))
+#define MMI_PROTOCOL_FZD_TAIL_BRACKET          "]"
+#define MMI_PROTOCOL_FZD_DEVICE_ID_LEN         (15) // imei
+#define MMI_PROTOCOL_FZD_CONTENT_LEN_LEN       (4)
+
+// send fixed:[MD5_DATADEVICE_NAME*DEVICE_ID*CONTENT_LENGTH*]
+//#define MMI_PROTOCOL_FZD_SEND_FIXED_CONTENT_LEN      (MMI_PROTOCOL_FZD_BRACKET_LEN * 2 + MMI_PROTOCOL_FZD_MD5_DATA_LEN + MMI_PROTOCOL_FZD_DEVICE_NAME_LEN \
+//                                                                                             + MMI_PROTOCOL_FZD_SEPARATOR_LEN * 3 + MMI_PROTOCOL_FZD_DEVICE_ID_LEN + MMI_PROTOCOL_FZD_CONTENT_LEN_LEN)
+// receive fixed:[DEVICE_NAME*DEVICE_ID*CONTENT_LENGTH*]
+//#define MMI_PROTOCOL_FZD_RECEIVE_FIXED_CONTENT_LEN   (MMI_PROTOCOL_FZD_BRACKET_LEN * 2 + MMI_PROTOCOL_FZD_DEVICE_NAME_LEN \
+//                                                                                             + MMI_PROTOCOL_FZD_SEPARATOR_LEN * 3 + MMI_PROTOCOL_FZD_DEVICE_ID_LEN + MMI_PROTOCOL_FZD_CONTENT_LEN_LEN)
+
+
+#define MMI_PROTOCOL_FZD_ACTION_STR_LEN_MAX            (31) // "LK"
+
+
+#define FZD_MAX(a, b)  (((a) > (b)) ? (a) : (b))
+#define FZD_MIN(a, b)  (((a) > (b)) ? (b) : (a))
+
+#define SWAP_4(x)    (((x & 0x000000FF) << 24) |    \
+                     ((x & 0x0000FF00) <<  8) |     \
+                     ((x & 0x00FF0000) >>  8) |     \
+                     ((x & 0xFF000000) >> 24))
+
+#define SWAP_2(x)    (((x) & 0xFF) << 8) | ((unsigned short)(x) >> 8)
+
+#define MMI_PROTOCOL_FZD_FILL_LOCATION_DATA_BUFF_LEN           (1024 - 256)
+
+
+typedef struct
+{
+    void * ptr;
+    int size;
+} MMI_PROTOCOL_FZD_SEND_SPACE_STRUCT;
+
+typedef struct
+{
+       unsigned char * receive_ptr;
+       int receive_len;
+    unsigned char * incomplete_ptr;
+    int incomplete_len;
+} MMI_PROTOCOL_FZD_RECEIVE_SPACE_STRUCT;
+
+
+typedef enum
+{
+    MMI_FZD_ACTION_NONE,       //0 nothing
+
+       MMI_FZD_ACTION_LINK,
+       MMI_FZD_ACTION_HEARTBEAT, // tcp heartbeat
+       MMI_FZD_ACTION_BIND, // 
+       MMI_FZD_ACTION_GET_TIME,
+       MMI_FZD_ACTION_SEND_LOCATION,
+       MMI_FZD_ACTION_SEND_CUR_LOCATION, // send to server
+       MMI_FZD_SERVER_GET_CUR_LOCATION, // from server
+       MMI_FZD_SERVER_SET_UD_INTERVAL,
+       MMI_FZD_ACTION_ALERT,
+       MMI_FZD_SERVER_SET_FACTORY,
+       MMI_FZD_SERVER_SET_POWEROFF,
+       
+       MMI_FZD_SERVER_FIND_WATCH, // 11
+       MMI_FZD_SERVER_GET_VERSION,
+       MMI_FZD_SERVER_SET_PHONEBOOK,
+       MMI_FZD_SERVER_SET_CALL,
+       MMI_FZD_SERVER_SET_REMIND,
+       
+#ifdef __MMI_ZHSX_SUPPORT_HEALTH_SENSOR__
+       MMI_FZD_SERVER_SET_HEART_INTERVAL, // 16
+       MMI_FZD_ACTION_SEND_HEART,
+       MMI_FZD_SERVER_SET_TEMPERATURE_INTERVAL,
+       MMI_FZD_ACTION_SEND_TEMPERATURE,
+       MMI_FZD_SERVER_SET_BLOOD_INTERVAL,
+       MMI_FZD_ACTION_SEND_BLOOD,
+       MMI_FZD_SERVER_SET_SPO2_INTERVAL,
+       MMI_FZD_ACTION_SEND_SPO2,
+#endif
+
+#ifdef __MMI_WECHAT_SUPPORT__
+       MMI_FZD_ACTION_TALK, // wechat
+       MMI_FZD_ACTION_TALK_MESSAGE, // text message
+#endif
+#if USE_LV_WATCH_CAMERA != 0
+       MMI_FZD_ACTION_SEND_PHOTO,
+#endif
+       MMI_FZD_ACTION_GET_WEATHER,
+
+#ifdef __MMI_SOS_NUMBER_NAME_SUPPORT__
+       MMI_FZD_SERVER_SET_SOS_NUMBER_NAME,
+#else
+       MMI_FZD_SERVER_SET_SOS_NUMBER,
+#endif
+       MMI_FZD_SERVER_SET_CENTER_NUMBER,
+       MMI_FZD_SERVER_SET_MONITOR,     
+       MMI_FZD_ACTION_UNBIND,
+       MMI_FZD_SERVER_SET_REBOOT,
+       MMI_FZD_ACTION_GET_APP_QRCODE,
+
+#ifdef __MMI_ZHSX_SUPPORT_VIDEO_CALL__
+#if defined(__MMI_ZHSX_SUPPORT_VIDEO_CALL_WULIAN__) || defined(__MMI_ZHSX_SUPPORT_VIDEO_CALL_FZD__) || defined(__MMI_ZHSX_SUPPORT_VIDEO_CALL_TONGXIN__)
+       MMI_FZD_WATCH_GET_VC_CONFIG,
+       MMI_FZD_WATCH_GET_VC_CONTACT,
+       MMI_FZD_WATCH_VC_CALL_REQUEST,
+       MMI_FZD_SERVER_VC_CALL_RESPONSE,
+       MMI_FZD_SERVER_VC_CALL_REQUEST,
+       MMI_FZD_WATCH_VC_CALL_RESPONSE,
+#endif
+#endif
+
+#ifdef __MMI_ZHSX_SUPPORT_DO_NOT_DISTURB__
+       MMI_FZD_SERVER_SET_NOT_DISTURB, 
+#endif
+#ifdef __MMI_SLEEP_FUNCTION_SUPPORT__
+       MMI_FZD_SERVER_SET_SLEEPTIME,
+#endif
+       MMI_FZD_SERVER_SET_UD_SWITCH,
+       MMI_FZD_SERVER_SET_DIAL_PAD_SWITCH, 
+       MMI_FZD_SERVER_SET_WHITE_LIST_SWITCH, 
+       MMI_FZD_SERVER_SET_LOW_BATTERY_SWITCH,
+       MMI_FZD_SERVER_SET_FALL_DOWN_SWITCH,
+       MMI_FZD_SERVER_SET_TAKE_OFF_SWITCH,
+#ifdef __MMI_REMIND_WAKE_UP_SUPPORT__
+       MMI_FZD_SERVER_SET_REMIND_WAKE_UP,
+#endif
+#ifdef __MMI_REMIND_SLEEP_SUPPORT__
+       MMI_FZD_SERVER_SET_REMIND_SLEEP,
+#endif
+#ifdef __MMI_REMIND_REST_SUPPORT__
+       MMI_FZD_SERVER_SET_REMIND_REST,
+#endif
+#ifdef __MMI_REMIND_HOME_SUPPORT__
+       MMI_FZD_SERVER_SET_REMIND_HOME,
+#endif
+#ifdef __MMI_REMIND_MEDICINE_SUPPORT__
+       MMI_FZD_SERVER_SET_REMIND_MEDICINE,
+#endif
+#ifdef __MMI_REMIND_CUSTOM_MEDICINE_SUPPORT__
+       MMI_FZD_SERVER_SET_REMIND_CUSTOM_MEDICINE,
+#endif
+#ifdef __MMI_REMIND_DRINK_SUPPORT__
+       MMI_FZD_SERVER_SET_REMIND_DRINK,
+#endif
+#ifdef __MMI_CUSTOM_HENG_AI__
+       MMI_FZD_SERVER_SET_HENG_AI_WAKE_NOW,
+       MMI_FZD_SERVER_SET_HENG_AI_WAKE_RING_TYPE,
+       MMI_FZD_SERVER_SET_HENG_AI_WARNING,
+#endif
+#ifdef __MMI_CUSTOM_HENGAI_SLEEP__
+       MMI_FZD_ACTION_HENGAI_ACTIVATION,
+       MMI_FZD_ACTION_HENGAI_ACTIVATION_FEEDBACK,
+       MMI_FZD_ACTION_HENGAI_SLEEP_DATA,
+#if 0
+MMI_FZD_ACTION_GSENSOR_DATA_UPLOAD,
+MMI_FZD_SERVER_SET_GSENSOR_UPLOAD_SWITCH,
+MMI_FZD_SERVER_SET_GSENSOR_DATA,
+MMI_FZD_ACTION_HENGAI_SLEEP_DATA_TEST,
+#endif
+#endif
+#ifdef __MMI_CUSTOM_HENGAI_TCMS__
+       MMI_FZD_SERVER_SET_HENGAI_TCMS_SWITCH,
+       MMI_FZD_ACTION_HENGAI_TCMS_DATA,
+#endif
+       MMI_FZD_ACTION_TCP_HTTP,
+
+       MMI_FZD_SERVER_SET_BOOTOFF,
+       MMI_FZD_SEND_UP_REMIND,
+
+/*******add before this line*******/
+    MMI_FZD_ACTION_MAX
+} MMI_PROTOCOL_FZD_ACTION_ENUM;
+
+typedef enum
+{
+       MMI_FZD_WARNING_TYPE_NONE,
+       MMI_FZD_WARNING_TYPE_SOS,
+       MMI_FZD_WARNING_TYPE_LOW_BATTERY,
+       MMI_FZD_WARNING_TYPE_TAKE_OFF,
+       MMI_FZD_WARNING_TYPE_TAKE_ON,
+       MMI_FZD_WARNING_TYPE_FALL_DOWN,
+
+       MMI_FZD_WARNING_TYPE_MAX
+}MMI_PROTOCOL_FZD_WARNING_TYPE_ENUM;
+
+typedef struct
+{
+       bool sos;
+       bool low_battery;
+       bool take_off;
+       bool take_on;
+       bool fall_down;
+}MMI_PROTOCOL_FZD_WARNING_INFO_STRUCT;
+
+
+void mmi_protocol_fzd_receive_data_process(char * recv_str, int recv_len);
+
+void * mmi_protocol_fzd_send_space_ptr_get(MMI_PROTOCOL_FZD_ACTION_ENUM action);
+
+int mmi_protocol_fzd_send_space_size_get(MMI_PROTOCOL_FZD_ACTION_ENUM action);
+
+void mmi_protocol_fzd_send_space_deinit(MMI_PROTOCOL_FZD_ACTION_ENUM action);
+
+bool mmi_protocol_fzd_send_cmd_check(MMI_PROTOCOL_FZD_ACTION_ENUM action);
+
+bool mmi_protocol_fzd_action_LINK(void);
+bool mmi_protocol_fzd_parse_LINK(unsigned char * next_buff, unsigned int next_buff_len);
+
+bool mmi_protocol_fzd_action_HEARTBEAT(void);
+bool mmi_protocol_fzd_parse_HEARTBEAT(unsigned char * next_buff, unsigned int next_buff_len);
+
+bool mmi_protocol_fzd_action_bind(void);
+bool mmi_protocol_fzd_parse_ACTION_BIND(unsigned char * next_buff, unsigned int next_buff_len);
+
+bool mmi_protocol_fzd_action_get_time(void);
+bool mmi_protocol_fzd_parse_ACTION_GET_TIME(unsigned char * next_buff, unsigned int next_buff_len);
+
+bool mmi_protocol_fzd_parse_SERVER_GET_CUR_LOCATION(unsigned char * next_buff, unsigned int next_buff_len);
+
+bool mmi_protocol_fzd_parse_SERVER_SET_UD_INTERVAL(unsigned char * next_buff, unsigned int next_buff_len);
+
+bool mmi_protocol_fzd_parse_SERVER_SET_FACTORY(unsigned char * next_buff, unsigned int next_buff_len);
+bool mmi_protocol_fzd_parse_SERVER_SET_POWEROFF(unsigned char * next_buff, unsigned int next_buff_len);
+bool mmi_protocol_fzd_parse_SERVER_SET_REBOOT(unsigned char * next_buff, unsigned int next_buff_len);
+
+bool mmi_protocol_fzd_parse_SERVER_FIND_WATCH(unsigned char * next_buff, unsigned int next_buff_len);
+
+bool mmi_protocol_fzd_parse_SERVER_GET_VERSION(unsigned char * next_buff, unsigned int next_buff_len);
+
+bool mmi_protocol_fzd_parse_SERVER_SET_PHONEBOOK(unsigned char * next_buff, unsigned int next_buff_len);
+
+bool mmi_protocol_fzd_parse_SERVER_SET_CALL(unsigned char * next_buff, unsigned int next_buff_len);
+
+bool mmi_protocol_fzd_parse_SERVER_SET_REMIND(unsigned char * next_buff, unsigned int next_buff_len);
+
+#ifdef __MMI_ZHSX_SUPPORT_HEALTH_SENSOR__
+bool mmi_protocol_fzd_parse_SERVER_SET_HEART_INTERVAL(unsigned char * next_buff, unsigned int next_buff_len);
+bool mmi_protocol_fzd_parse_SERVER_SET_TEMPERATURE_INTERVAL(unsigned char * next_buff, unsigned int next_buff_len);
+bool mmi_protocol_fzd_parse_SERVER_SET_BLOOD_INTERVAL(unsigned char * next_buff, unsigned int next_buff_len);
+bool mmi_protocol_fzd_parse_SERVER_SET_SPO2_INTERVAL(unsigned char * next_buff, unsigned int next_buff_len);
+bool mmi_protocol_fzd_action_send_temperature(float temp_value);
+bool mmi_protocol_fzd_action_send_heart(uint16_t heart_value);
+bool mmi_protocol_fzd_action_send_blood(uint16_t blood_high_value, uint16_t blood_low_value);
+bool mmi_protocol_fzd_action_send_spo2(uint16_t spo2_value);
+#endif
+
+#ifdef __MMI_WECHAT_SUPPORT__
+bool mmi_protocol_fzd_ACTION_TALK(char * data_buff, int data_buff_len);
+bool mmi_protocol_fzd_parse_ACTION_TALK(unsigned char * next_buff, unsigned int next_buff_len);
+bool mmi_protocol_fzd_parse_ACTION_TALK_MESSAGE(unsigned char * next_buff, unsigned int next_buff_len);
+#endif
+#if USE_LV_WATCH_CAMERA != 0
+bool mmi_protocol_fzd_action_send_photo(uint8_t type, char * time_str, char * data_buff, int data_buff_len);
+#endif
+
+bool mmi_protocol_fzd_action_send_location(MMI_WATCH_LOCATION_DATA_T * location_data);
+
+bool mmi_protocol_fzd_action_send_cur_location(MMI_WATCH_LOCATION_DATA_T * location_data);
+
+bool mmi_protocol_fzd_action_send_get_weather(MMI_WATCH_LOCATION_DATA_T * location_data);
+bool mmi_protocol_fzd_parse_ACTION_GET_WEATHER(unsigned char * next_buff, unsigned int next_buff_len);
+
+#ifdef __MMI_SOS_NUMBER_NAME_SUPPORT__
+bool mmi_protocol_fzd_parse_SERVER_SET_SOS_NUMBER_NAME(unsigned char * next_buff, unsigned int next_buff_len);
+#else
+bool mmi_protocol_fzd_parse_SERVER_SET_SOS_NUMBER(unsigned char * next_buff, unsigned int next_buff_len);
+#endif
+
+bool mmi_protocol_fzd_parse_SERVER_SET_CENTER_NUMBER(unsigned char * next_buff, unsigned int next_buff_len);
+
+void mmi_protocol_fzd_set_warning_info(MMI_PROTOCOL_FZD_WARNING_TYPE_ENUM warning_type, bool value);
+bool mmi_protocol_fzd_action_send_warning_info(MMI_WATCH_LOCATION_DATA_T * location_data);
+
+bool mmi_protocol_fzd_action_unbind(void);
+
+bool mmi_protocol_fzd_action_get_app_qrcode(void);
+bool mmi_protocol_fzd_parse_ACTION_GET_APP_QRCODE(unsigned char * next_buff, unsigned int next_buff_len);
+
+#ifdef __MMI_ZHSX_SUPPORT_VIDEO_CALL__
+bool mmi_protocol_fzd_action_get_vc_config(void);
+bool mmi_protocol_fzd_action_VC_CALL_REQUEST(char * number, uint8_t call_type);
+#endif
+
+#ifdef __MMI_ZHSX_SUPPORT_DO_NOT_DISTURB__
+bool mmi_protocol_fzd_parse_SERVER_SET_NOT_DISTURB(unsigned char * next_buff, unsigned int next_buff_len);
+#endif
+bool mmi_protocol_fzd_parse_SERVER_SET_UD_SWITCH(unsigned char * next_buff, unsigned int next_buff_len);
+bool mmi_protocol_fzd_parse_SERVER_SET_DIAL_PAD_SWITCH(unsigned char * next_buff, unsigned int next_buff_len);
+bool mmi_protocol_fzd_parse_SERVER_SET_WHITE_LIST_SWITCH(unsigned char * next_buff, unsigned int next_buff_len);
+bool mmi_protocol_fzd_parse_SERVER_SET_LOW_BATTERY_SWITCH(unsigned char * next_buff, unsigned int next_buff_len);
+bool mmi_protocol_fzd_parse_SERVER_SET_FALL_DOWN_SWITCH(unsigned char * next_buff, unsigned int next_buff_len);
+bool mmi_protocol_fzd_parse_SERVER_SET_TAKE_OFF_SWITCH(unsigned char * next_buff, unsigned int next_buff_len);
+
+#ifdef __MMI_REMIND_WAKE_UP_SUPPORT__
+bool mmi_protocol_fzd_parse_SERVER_SET_REMIND_WAKE_UP(unsigned char * next_buff, unsigned int next_buff_len);
+#endif
+#ifdef __MMI_REMIND_SLEEP_SUPPORT__
+bool mmi_protocol_fzd_parse_SERVER_SET_REMIND_SLEEP(unsigned char * next_buff, unsigned int next_buff_len);
+#endif
+#ifdef __MMI_REMIND_REST_SUPPORT__
+bool mmi_protocol_fzd_parse_SERVER_SET_REMIND_REST(unsigned char * next_buff, unsigned int next_buff_len);
+#endif
+#ifdef __MMI_REMIND_HOME_SUPPORT__
+bool mmi_protocol_fzd_parse_SERVER_SET_REMIND_HOME(unsigned char * next_buff, unsigned int next_buff_len);
+#endif
+#ifdef __MMI_REMIND_MEDICINE_SUPPORT__
+bool mmi_protocol_fzd_parse_SERVER_SET_REMIND_MEDICINE(unsigned char * next_buff, unsigned int next_buff_len);
+#endif
+#ifdef __MMI_REMIND_CUSTOM_MEDICINE_SUPPORT__
+bool mmi_protocol_fzd_parse_SERVER_SET_REMIND_CUSTOM_MEDICINE(unsigned char * next_buff, unsigned int next_buff_len);
+#endif
+#ifdef __MMI_REMIND_DRINK_SUPPORT__
+bool mmi_protocol_fzd_parse_SERVER_SET_REMIND_DRINK(unsigned char * next_buff, unsigned int next_buff_len);
+#endif
+#ifdef __MMI_CUSTOM_HENG_AI__
+bool mmi_protocol_fzd_parse_SERVER_SET_HENG_AI_WAKE_NOW(unsigned char * next_buff, unsigned int next_buff_len);                
+bool mmi_protocol_fzd_parse_SERVER_SET_HENG_AI_WAKE_RING_TYPE(unsigned char * next_buff, unsigned int next_buff_len);
+bool mmi_protocol_fzd_parse_SERVER_SET_HENG_AI_WARNING(unsigned char * next_buff, unsigned int next_buff_len);
+#endif
+#ifdef __MMI_CUSTOM_HENGAI_SLEEP__
+bool mmi_protocol_fzd_action_hengai_activation(char * req_code);
+bool mmi_protocol_fzd_parse_ACTION_HENGAI_ACTIVATION(unsigned char * next_buff, unsigned int next_buff_len);
+bool mmi_protocol_fzd_action_hengai_activation_feedback(void);
+bool mmi_protocol_fzd_action_hengai_sleep_data(char * file_buf, uint32_t file_size);
+#endif
+#ifdef __MMI_CUSTOM_HENGAI_TCMS__
+bool mmi_protocol_fzd_parse_SERVER_SET_HENGAI_TCMS_SWITCH(unsigned char * next_buff, unsigned int next_buff_len);
+bool mmi_protocol_fzd_action_hengai_tcms_data(char * data_ptr, uint32_t data_len);
+#endif
+
+bool mmi_protocol_fzd_action_tcp_http(char * data_ptr, uint32_t data_len);
+bool mmi_protocol_fzd_parse_ACTION_TCP_HTTP(unsigned char * next_buff, unsigned int next_buff_len);
+
+
+
+#endif
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif //__cplusplus
+
+#endif
+
+
diff --git a/2.sdk/sdk/gui/lv_watch/mmi_protocol/mmi_protocol_fzd_content.c b/2.sdk/sdk/gui/lv_watch/mmi_protocol/mmi_protocol_fzd_content.c
new file mode 100644 (file)
index 0000000..80f3f45
--- /dev/null
@@ -0,0 +1,493 @@
+
+
+
+#include "lv_watch.h"
+
+#ifdef __MMI_ZHSX_SUPPORT_FZD__
+
+
+static unsigned char * mmi_protocol_fzd_action_string_get(MMI_PROTOCOL_FZD_ACTION_ENUM action)
+{
+       struct
+       {
+               MMI_PROTOCOL_FZD_ACTION_ENUM action;
+               unsigned char* action_string;
+       }action_struct[MMI_FZD_ACTION_MAX] =
+           {
+                       {MMI_FZD_ACTION_NONE, "NONE"},
+                       
+                       {MMI_FZD_ACTION_LINK, "LK"},
+               {MMI_FZD_ACTION_HEARTBEAT, "KA"},
+                       {MMI_FZD_ACTION_BIND, "PING"}, 
+                       {MMI_FZD_ACTION_GET_TIME, "LGZONE"},
+                       {MMI_FZD_ACTION_SEND_LOCATION, "UD"},
+                       {MMI_FZD_ACTION_SEND_CUR_LOCATION, "CRUD"},
+                       {MMI_FZD_SERVER_GET_CUR_LOCATION, "CR"},
+                       {MMI_FZD_SERVER_SET_UD_INTERVAL, "UPLOAD"},
+                       {MMI_FZD_ACTION_ALERT, "AL"},
+                       {MMI_FZD_SERVER_SET_FACTORY, "FACTORY"},
+                       {MMI_FZD_SERVER_SET_POWEROFF, "POWEROFF"},
+                       
+                       {MMI_FZD_SERVER_FIND_WATCH, "FIND"}, 
+                       {MMI_FZD_SERVER_GET_VERSION, "VERNO"},  
+               {MMI_FZD_SERVER_SET_PHONEBOOK, "PHL"},      
+                       {MMI_FZD_SERVER_SET_CALL, "CALL"},      
+                       {MMI_FZD_SERVER_SET_REMIND, "REMIND"},  
+                       
+               #ifdef __MMI_ZHSX_SUPPORT_HEALTH_SENSOR__
+               {MMI_FZD_SERVER_SET_HEART_INTERVAL, "hrtstart"},   
+                       {MMI_FZD_ACTION_SEND_HEART, "heart"},   
+                       {MMI_FZD_SERVER_SET_TEMPERATURE_INTERVAL, "wdstart"},
+                       {MMI_FZD_ACTION_SEND_TEMPERATURE, "temp"},      
+               {MMI_FZD_SERVER_SET_BLOOD_INTERVAL, "bldstart"},   
+                       {MMI_FZD_ACTION_SEND_BLOOD, "blood"},
+                       {MMI_FZD_SERVER_SET_SPO2_INTERVAL, "oxstart"},
+                       {MMI_FZD_ACTION_SEND_SPO2, "oxygen"},
+               #endif
+                       
+               #ifdef __MMI_WECHAT_SUPPORT__
+                       {MMI_FZD_ACTION_TALK, "TK"},
+                       {MMI_FZD_ACTION_TALK_MESSAGE, "MESSAGE"},
+               #endif
+               #if USE_LV_WATCH_CAMERA != 0
+                       {MMI_FZD_ACTION_SEND_PHOTO, "img"},
+               #endif
+                       {MMI_FZD_ACTION_GET_WEATHER, "WT"},     
+               #ifdef __MMI_SOS_NUMBER_NAME_SUPPORT__
+                       {MMI_FZD_SERVER_SET_SOS_NUMBER_NAME, "SOS2"}, 
+               #else
+                       {MMI_FZD_SERVER_SET_SOS_NUMBER, "SOS"}, 
+               #endif
+                       {MMI_FZD_SERVER_SET_CENTER_NUMBER, "CENTER"},
+                       {MMI_FZD_SERVER_SET_MONITOR, "MONITOR"},
+                       {MMI_FZD_ACTION_UNBIND, "DLT"},
+                       {MMI_FZD_SERVER_SET_REBOOT, "REBOOT"},
+                       {MMI_FZD_ACTION_GET_APP_QRCODE, "CID"},
+
+               #ifdef __MMI_ZHSX_SUPPORT_VIDEO_CALL__
+               #ifdef __MMI_ZHSX_SUPPORT_VIDEO_CALL_WULIAN__
+                       {MMI_FZD_WATCH_GET_VC_CONFIG, "jup_hoo_config"},
+                       {MMI_FZD_WATCH_GET_VC_CONTACT, "video_contact"},
+                       
+                       {MMI_FZD_WATCH_VC_CALL_REQUEST, "jup_hoo_call"},
+                       {MMI_FZD_SERVER_VC_CALL_RESPONSE, "jup_hoo_reply"},
+               
+                       {MMI_FZD_SERVER_VC_CALL_REQUEST, "jup_hoo_request"},
+                       {MMI_FZD_WATCH_VC_CALL_RESPONSE, "jup_hoo_response"},
+               #endif
+               #if defined(__MMI_ZHSX_SUPPORT_VIDEO_CALL_FZD__) || defined(__MMI_ZHSX_SUPPORT_VIDEO_CALL_TONGXIN__)
+                       {MMI_FZD_WATCH_GET_VC_CONFIG, "JPREG"},
+                       {MMI_FZD_WATCH_GET_VC_CONTACT, "MEMBERS"},
+                       {MMI_FZD_WATCH_VC_CALL_REQUEST, "AGTALK"},
+                       {MMI_FZD_SERVER_VC_CALL_RESPONSE, "RTALK"},
+                       {MMI_FZD_SERVER_VC_CALL_REQUEST, "CALLING"},
+                       {MMI_FZD_WATCH_VC_CALL_RESPONSE, "RCALLING"},
+               #endif
+               #endif
+               #ifdef __MMI_ZHSX_SUPPORT_DO_NOT_DISTURB__
+                       {MMI_FZD_SERVER_SET_NOT_DISTURB, "SILENCETIME2"},
+               #endif
+               #ifdef __MMI_SLEEP_FUNCTION_SUPPORT__
+                       {MMI_FZD_SERVER_SET_SLEEPTIME, "SLEEPTIME"},
+               #endif
+                       {MMI_FZD_SERVER_SET_UD_SWITCH, "LOC_SWITCH"},
+                       {MMI_FZD_SERVER_SET_DIAL_PAD_SWITCH, "KEYBRD"},
+                       {MMI_FZD_SERVER_SET_WHITE_LIST_SWITCH, "WLKEY"}, 
+                       {MMI_FZD_SERVER_SET_LOW_BATTERY_SWITCH, "LOWBAT"},
+                       {MMI_FZD_SERVER_SET_FALL_DOWN_SWITCH, "FALLDOWN"},
+                       {MMI_FZD_SERVER_SET_TAKE_OFF_SWITCH, "REMOVE"},
+               #ifdef __MMI_REMIND_WAKE_UP_SUPPORT__
+                       {MMI_FZD_SERVER_SET_REMIND_WAKE_UP, "REMIND_CH_WAKEUP"},
+               #endif
+               #ifdef __MMI_REMIND_SLEEP_SUPPORT__
+                       {MMI_FZD_SERVER_SET_REMIND_SLEEP, "REMIND_CH_SLEEP"},
+               #endif
+               #ifdef __MMI_REMIND_REST_SUPPORT__
+                       {MMI_FZD_SERVER_SET_REMIND_REST, "REMIND_CH_REST"},
+               #endif
+               #ifdef __MMI_REMIND_HOME_SUPPORT__
+                       {MMI_FZD_SERVER_SET_REMIND_HOME, "REMIND_CH_HOME"},
+               #endif
+               #ifdef __MMI_REMIND_MEDICINE_SUPPORT__
+                       {MMI_FZD_SERVER_SET_REMIND_MEDICINE, "REMIND_CH_MEDICINE"},
+               #endif
+               #ifdef __MMI_REMIND_CUSTOM_MEDICINE_SUPPORT__
+                       {MMI_FZD_SERVER_SET_REMIND_CUSTOM_MEDICINE, "REMIND_CH_MEDICINE2"},
+               #endif
+               #ifdef __MMI_REMIND_DRINK_SUPPORT__
+                       {MMI_FZD_SERVER_SET_REMIND_DRINK, "REMIND_CH_DRINK"},
+               #endif
+               #ifdef __MMI_CUSTOM_HENG_AI__
+                       {MMI_FZD_SERVER_SET_HENG_AI_WAKE_NOW, "HENG_AI_WAKE_NOW"},
+                       {MMI_FZD_SERVER_SET_HENG_AI_WAKE_RING_TYPE, "HENG_AI_WAKE_RING_TYPE"},
+                       {MMI_FZD_SERVER_SET_HENG_AI_WARNING, "HENGAI_WARNING"},
+               #endif
+               #ifdef __MMI_CUSTOM_HENGAI_SLEEP__
+                       {MMI_FZD_ACTION_HENGAI_ACTIVATION, "HENGAI_ACTIVATION"},
+                       {MMI_FZD_ACTION_HENGAI_ACTIVATION_FEEDBACK, "HENGAI_ACTIVATION_FEEDBACK"},
+                       {MMI_FZD_ACTION_HENGAI_SLEEP_DATA, "HENGAI_SLEEP_DATA"},
+
+                       #if 0
+                       {MMI_FZD_ACTION_GSENSOR_DATA_UPLOAD, "TEST_SLEEP_UPLOAD"},
+                       {MMI_FZD_SERVER_SET_GSENSOR_UPLOAD_SWITCH, "TEST_SLEEP_CONTROL"},
+                       {MMI_FZD_SERVER_SET_GSENSOR_DATA, "TEST_SLEEP_SNED"},                   
+                       {MMI_FZD_ACTION_HENGAI_SLEEP_DATA_TEST, "TEST_SLEEP_DATA"},                     
+                       #endif
+               #endif
+               #ifdef __MMI_CUSTOM_HENGAI_TCMS__
+                       {MMI_FZD_SERVER_SET_HENGAI_TCMS_SWITCH, "TRIGGER_CNDOCD"},
+                       {MMI_FZD_ACTION_HENGAI_TCMS_DATA, "CNDOCD"},                    
+               #endif
+                       {MMI_FZD_ACTION_TCP_HTTP, "TCP_HTTP"},
+                       {MMI_FZD_SERVER_SET_BOOTOFF, "BOOTOFF"},
+                       {MMI_FZD_SEND_UP_REMIND, "UP_REMIND"},
+               
+               /*******add before this line*******/
+                       {MMI_FZD_ACTION_MAX, ""}, // MMI_FZD_ACTION_MAX
+           };
+
+    return action_struct[action].action_string;
+}
+
+static bool mmi_protocol_fzd_content_parse(unsigned char * content_ptr, unsigned int content_length)
+{
+       unsigned char * next_buff = NULL;
+       unsigned int next_buff_len = 0;
+       MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_ACTION_NONE;
+       uint8_t content_action_str_len = 0;
+       
+       PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: length=%d, content=%s\n", __FUNCTION__, __LINE__, content_length, content_ptr);
+
+       km_strtok_r(content_ptr, ",", &next_buff);
+       content_action_str_len = strlen(content_ptr);
+       if(NULL == next_buff)
+               next_buff_len = 0;
+       else
+               next_buff_len = content_length - content_action_str_len - 1;
+       
+       for(action = MMI_FZD_ACTION_NONE; action < MMI_FZD_ACTION_MAX; action++)
+       {
+               unsigned char * action_string = mmi_protocol_fzd_action_string_get(action);
+               if(strlen(action_string) == content_action_str_len)
+               {
+                       if(0 == strncmp(content_ptr, action_string, content_action_str_len))
+                       {
+                               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: action_string=%s, action=%d\n", __FUNCTION__, __LINE__, action_string, action);
+                               break;
+                       }
+               }
+       }
+
+       if(MMI_FZD_ACTION_MAX == action)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               return false;
+       }
+
+       switch(action)
+       {
+               case MMI_FZD_ACTION_LINK:
+                       mmi_protocol_fzd_parse_LINK(next_buff, next_buff_len);
+                       break;
+               
+               case MMI_FZD_ACTION_HEARTBEAT:
+                       mmi_protocol_fzd_parse_HEARTBEAT(next_buff, next_buff_len);
+                       break;
+
+               case MMI_FZD_ACTION_BIND:
+                       mmi_protocol_fzd_parse_ACTION_BIND(next_buff, next_buff_len);
+                       break;
+
+               case MMI_FZD_ACTION_GET_TIME:
+                       mmi_protocol_fzd_parse_ACTION_GET_TIME(next_buff, next_buff_len);
+                       break;
+                       
+               case MMI_FZD_ACTION_SEND_LOCATION:
+                       break;
+
+               case MMI_FZD_ACTION_SEND_CUR_LOCATION:
+                       break;
+                       
+               case MMI_FZD_SERVER_GET_CUR_LOCATION:
+                       mmi_protocol_fzd_parse_SERVER_GET_CUR_LOCATION(next_buff, next_buff_len);
+                       break;
+
+               case MMI_FZD_SERVER_SET_UD_INTERVAL:
+                       mmi_protocol_fzd_parse_SERVER_SET_UD_INTERVAL(next_buff, next_buff_len);
+                       break;
+                       
+               case MMI_FZD_ACTION_ALERT:
+                       break;
+                       
+               case MMI_FZD_SERVER_SET_FACTORY:
+                       mmi_protocol_fzd_parse_SERVER_SET_FACTORY(next_buff, next_buff_len);
+                       break;
+                       
+               case MMI_FZD_SERVER_SET_POWEROFF:
+                       mmi_protocol_fzd_parse_SERVER_SET_POWEROFF(next_buff, next_buff_len);
+                       break;
+                       
+               case MMI_FZD_SERVER_FIND_WATCH:
+                       mmi_protocol_fzd_parse_SERVER_FIND_WATCH(next_buff, next_buff_len);
+                       break;
+                       
+               case MMI_FZD_SERVER_GET_VERSION:
+                       mmi_protocol_fzd_parse_SERVER_GET_VERSION(next_buff, next_buff_len);
+                       break;
+
+               case MMI_FZD_SERVER_SET_PHONEBOOK:
+                       mmi_protocol_fzd_parse_SERVER_SET_PHONEBOOK(next_buff, next_buff_len);
+                       break;
+                       
+               case MMI_FZD_SERVER_SET_CALL:
+                       mmi_protocol_fzd_parse_SERVER_SET_CALL(next_buff, next_buff_len);
+                       break;
+
+               case MMI_FZD_SERVER_SET_REMIND:
+                       mmi_protocol_fzd_parse_SERVER_SET_REMIND(next_buff, next_buff_len);
+                       break;
+                       
+       #ifdef __MMI_ZHSX_SUPPORT_HEALTH_SENSOR__
+               case MMI_FZD_SERVER_SET_HEART_INTERVAL:
+                       mmi_protocol_fzd_parse_SERVER_SET_HEART_INTERVAL(next_buff, next_buff_len);
+                       break;
+
+               case MMI_FZD_ACTION_SEND_HEART:
+                       break;
+                       
+               case MMI_FZD_SERVER_SET_TEMPERATURE_INTERVAL:
+                       mmi_protocol_fzd_parse_SERVER_SET_TEMPERATURE_INTERVAL(next_buff, next_buff_len);
+                       break;
+                       
+               case MMI_FZD_ACTION_SEND_TEMPERATURE:
+                       break;
+
+               case MMI_FZD_SERVER_SET_BLOOD_INTERVAL:
+                       mmi_protocol_fzd_parse_SERVER_SET_BLOOD_INTERVAL(next_buff, next_buff_len);
+                       break;
+                       
+               case MMI_FZD_ACTION_SEND_BLOOD:
+                       break;
+
+               case MMI_FZD_SERVER_SET_SPO2_INTERVAL:
+                       mmi_protocol_fzd_parse_SERVER_SET_SPO2_INTERVAL(next_buff, next_buff_len);
+                       break;
+                       
+               case MMI_FZD_ACTION_SEND_SPO2:
+                       break;
+       #endif
+                       
+       #ifdef __MMI_WECHAT_SUPPORT__
+               case MMI_FZD_ACTION_TALK:
+                       mmi_protocol_fzd_parse_ACTION_TALK(next_buff, next_buff_len);
+                       break;
+
+               case MMI_FZD_ACTION_TALK_MESSAGE:
+                       mmi_protocol_fzd_parse_ACTION_TALK_MESSAGE(next_buff, next_buff_len);
+                       break;
+       #endif
+
+       #if USE_LV_WATCH_CAMERA != 0
+               case MMI_FZD_ACTION_SEND_PHOTO:
+                       break;
+       #endif
+       
+               case MMI_FZD_ACTION_GET_WEATHER:
+                       mmi_protocol_fzd_parse_ACTION_GET_WEATHER(next_buff, next_buff_len);
+                       break;
+
+       #ifdef __MMI_SOS_NUMBER_NAME_SUPPORT__
+               case MMI_FZD_SERVER_SET_SOS_NUMBER_NAME:
+                       mmi_protocol_fzd_parse_SERVER_SET_SOS_NUMBER_NAME(next_buff, next_buff_len);
+                       break;
+       #else
+               case MMI_FZD_SERVER_SET_SOS_NUMBER:
+                       mmi_protocol_fzd_parse_SERVER_SET_SOS_NUMBER(next_buff, next_buff_len);
+                       break;
+       #endif
+                       
+               case MMI_FZD_SERVER_SET_CENTER_NUMBER:
+                       mmi_protocol_fzd_parse_SERVER_SET_CENTER_NUMBER(next_buff, next_buff_len);
+                       break;
+
+               case MMI_FZD_SERVER_SET_MONITOR:
+                       mmi_protocol_fzd_parse_SERVER_SET_MONITOR(next_buff, next_buff_len);
+                       break;
+
+               case MMI_FZD_ACTION_UNBIND:
+                       break;
+
+               case MMI_FZD_SERVER_SET_REBOOT:
+                       mmi_protocol_fzd_parse_SERVER_SET_REBOOT(next_buff, next_buff_len);
+                       break;
+
+               case MMI_FZD_ACTION_GET_APP_QRCODE:
+                       mmi_protocol_fzd_parse_ACTION_GET_APP_QRCODE(next_buff, next_buff_len);
+                       break;
+
+       #ifdef __MMI_ZHSX_SUPPORT_VIDEO_CALL__
+       #if defined(__MMI_ZHSX_SUPPORT_VIDEO_CALL_WULIAN__) || defined(__MMI_ZHSX_SUPPORT_VIDEO_CALL_FZD__) || defined(__MMI_ZHSX_SUPPORT_VIDEO_CALL_TONGXIN__)
+               case MMI_FZD_WATCH_GET_VC_CONFIG:
+                       mmi_protocol_fzd_parse_WATCH_GET_VC_CONFIG(next_buff, next_buff_len);
+                       break;
+                       
+               case MMI_FZD_WATCH_GET_VC_CONTACT:
+                       mmi_protocol_fzd_parse_WATCH_GET_VC_CONTACT(next_buff, next_buff_len);
+                       break;
+               
+               case MMI_FZD_WATCH_VC_CALL_REQUEST:
+                       mmi_protocol_fzd_parse_WATCH_VC_CALL_REQUEST(next_buff, next_buff_len);
+                       break;
+                       
+               case MMI_FZD_SERVER_VC_CALL_RESPONSE:
+                       mmi_protocol_fzd_parse_SERVER_VC_CALL_RESPONSE(next_buff, next_buff_len);
+                       break;
+               
+               case MMI_FZD_SERVER_VC_CALL_REQUEST:
+                       mmi_protocol_fzd_parse_SERVER_VC_CALL_REQUEST(next_buff, next_buff_len);
+                       break;
+                       
+               case MMI_FZD_WATCH_VC_CALL_RESPONSE:
+                       break;
+       #endif
+       #endif
+
+       #ifdef __MMI_ZHSX_SUPPORT_DO_NOT_DISTURB__
+               case MMI_FZD_SERVER_SET_NOT_DISTURB:
+                       mmi_protocol_fzd_parse_SERVER_SET_NOT_DISTURB(next_buff, next_buff_len);
+                       break;
+       #endif
+
+       #ifdef __MMI_SLEEP_FUNCTION_SUPPORT__
+               case MMI_FZD_SERVER_SET_SLEEPTIME:
+                       mmi_protocol_fzd_parse_SERVER_SET_SLEEPTIME(next_buff, next_buff_len);
+                       break;
+       #endif
+                       
+               case MMI_FZD_SERVER_SET_UD_SWITCH:
+                       mmi_protocol_fzd_parse_SERVER_SET_UD_SWITCH(next_buff, next_buff_len);
+                       break;
+                       
+               case MMI_FZD_SERVER_SET_DIAL_PAD_SWITCH:
+                       mmi_protocol_fzd_parse_SERVER_SET_DIAL_PAD_SWITCH(next_buff, next_buff_len);
+                       break;
+
+               case MMI_FZD_SERVER_SET_WHITE_LIST_SWITCH:
+                       mmi_protocol_fzd_parse_SERVER_SET_WHITE_LIST_SWITCH(next_buff, next_buff_len);
+                       break;
+
+               case MMI_FZD_SERVER_SET_LOW_BATTERY_SWITCH:
+                       mmi_protocol_fzd_parse_SERVER_SET_LOW_BATTERY_SWITCH(next_buff, next_buff_len);
+                       break;
+
+               case MMI_FZD_SERVER_SET_FALL_DOWN_SWITCH:
+                       mmi_protocol_fzd_parse_SERVER_SET_FALL_DOWN_SWITCH(next_buff, next_buff_len);
+                       break;
+
+               case MMI_FZD_SERVER_SET_TAKE_OFF_SWITCH:
+                       mmi_protocol_fzd_parse_SERVER_SET_TAKE_OFF_SWITCH(next_buff, next_buff_len);
+                       break;
+
+       #ifdef __MMI_REMIND_WAKE_UP_SUPPORT__
+               case MMI_FZD_SERVER_SET_REMIND_WAKE_UP:
+                       mmi_protocol_fzd_parse_SERVER_SET_REMIND_WAKE_UP(next_buff, next_buff_len);
+                       break;
+       #endif
+       #ifdef __MMI_REMIND_SLEEP_SUPPORT__
+               case MMI_FZD_SERVER_SET_REMIND_SLEEP:
+                       mmi_protocol_fzd_parse_SERVER_SET_REMIND_SLEEP(next_buff, next_buff_len);
+                       break;
+       #endif
+       #ifdef __MMI_REMIND_REST_SUPPORT__
+               case MMI_FZD_SERVER_SET_REMIND_REST:
+                       mmi_protocol_fzd_parse_SERVER_SET_REMIND_REST(next_buff, next_buff_len);
+                       break;
+       #endif
+       #ifdef __MMI_REMIND_HOME_SUPPORT__
+               case MMI_FZD_SERVER_SET_REMIND_HOME:
+                       mmi_protocol_fzd_parse_SERVER_SET_REMIND_HOME(next_buff, next_buff_len);
+                       break;
+       #endif
+       #ifdef __MMI_REMIND_MEDICINE_SUPPORT__
+               case MMI_FZD_SERVER_SET_REMIND_MEDICINE:
+                       mmi_protocol_fzd_parse_SERVER_SET_REMIND_MEDICINE(next_buff, next_buff_len);
+                       break;
+       #endif
+       #ifdef __MMI_REMIND_CUSTOM_MEDICINE_SUPPORT__
+               case MMI_FZD_SERVER_SET_REMIND_CUSTOM_MEDICINE:
+                       mmi_protocol_fzd_parse_SERVER_SET_REMIND_CUSTOM_MEDICINE(next_buff, next_buff_len);
+                       break;
+       #endif
+       #ifdef __MMI_REMIND_DRINK_SUPPORT__
+               case MMI_FZD_SERVER_SET_REMIND_DRINK:
+                       mmi_protocol_fzd_parse_SERVER_SET_REMIND_DRINK(next_buff, next_buff_len);
+                       break;
+       #endif
+
+       #ifdef __MMI_CUSTOM_HENG_AI__
+               case MMI_FZD_SERVER_SET_HENG_AI_WAKE_NOW:
+                       mmi_protocol_fzd_parse_SERVER_SET_HENG_AI_WAKE_NOW(next_buff, next_buff_len);
+                       break;
+                       
+               case MMI_FZD_SERVER_SET_HENG_AI_WAKE_RING_TYPE:
+                       mmi_protocol_fzd_parse_SERVER_SET_HENG_AI_WAKE_RING_TYPE(next_buff, next_buff_len);
+                       break;
+
+               case MMI_FZD_SERVER_SET_HENG_AI_WARNING:
+                       mmi_protocol_fzd_parse_SERVER_SET_HENG_AI_WARNING(next_buff, next_buff_len);
+                       break;
+       #endif
+
+       #ifdef __MMI_CUSTOM_HENGAI_SLEEP__
+               case MMI_FZD_ACTION_HENGAI_ACTIVATION:
+                       mmi_protocol_fzd_parse_ACTION_HENGAI_ACTIVATION(next_buff, next_buff_len);
+                       break;
+
+               case MMI_FZD_ACTION_HENGAI_ACTIVATION_FEEDBACK:
+                       break;
+               case MMI_FZD_ACTION_HENGAI_SLEEP_DATA:
+                       break;
+
+               #if 0
+               case MMI_FZD_ACTION_GSENSOR_DATA_UPLOAD:
+                       break;
+               case MMI_FZD_SERVER_SET_GSENSOR_UPLOAD_SWITCH:
+                       mmi_protocol_fzd_parse_SERVER_SET_GSENSOR_UPLOAD_SWITCH(next_buff, next_buff_len);
+                       break;
+               case MMI_FZD_SERVER_SET_GSENSOR_DATA:
+                       mmi_protocol_fzd_parse_SERVER_SET_GSENSOR_DATA(next_buff, next_buff_len);
+                       break;
+               case MMI_FZD_ACTION_HENGAI_SLEEP_DATA_TEST:
+                       break;
+               #endif
+       #endif
+
+       #ifdef __MMI_CUSTOM_HENGAI_TCMS__
+               case MMI_FZD_SERVER_SET_HENGAI_TCMS_SWITCH:
+                       mmi_protocol_fzd_parse_SERVER_SET_HENGAI_TCMS_SWITCH(next_buff, next_buff_len);
+                       break;
+                       
+               case MMI_FZD_ACTION_HENGAI_TCMS_DATA:
+                       break;
+       #endif
+
+               case MMI_FZD_ACTION_TCP_HTTP:
+                       mmi_protocol_fzd_parse_ACTION_TCP_HTTP(next_buff, next_buff_len);
+                       break;
+
+               case MMI_FZD_SERVER_SET_BOOTOFF:
+                       mmi_protocol_fzd_parse_SERVER_SET_BOOTOFF(next_buff, next_buff_len);
+                       break;
+
+                        
+               default:
+                       break;
+    }
+    
+    return true;
+}
+
+
+#endif
+
+
diff --git a/2.sdk/sdk/gui/lv_watch/mmi_protocol/mmi_protocol_sms.c b/2.sdk/sdk/gui/lv_watch/mmi_protocol/mmi_protocol_sms.c
new file mode 100644 (file)
index 0000000..48f90a7
--- /dev/null
@@ -0,0 +1,644 @@
+
+
+
+#include "lv_watch.h"
+
+#ifdef __MMI_ZHSX_SUPPORT_SMS__
+
+
+static MMI_PROTOCOL_SMS_PARSE_STRUCT s_sms_parse_info[] = 
+{
+       {"SETIP:", 6, mmi_protocol_sms_parse_set_ip},
+       {"GETIP", 5, mmi_protocol_sms_parse_get_ip},
+       {"SETMD5KEY:", 10, mmi_protocol_sms_parse_set_md5_key},
+       {"SETDEVICENAME:", 14, mmi_protocol_sms_parse_set_device_name},
+       {"SETUPLOAD:", 10, mmi_protocol_sms_parse_set_upload},
+       {"POWEROFF", 8, mmi_protocol_sms_parse_power_off},
+       {"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},
+ /* Function not verified */   {"SETAPN:", 7, mmi_protocol_sms_parse_set_apn}, /* Function not verified */
+       {"ts#", 3, mmi_protocol_sms_parse_get_info},
+       {"TS#", 3, mmi_protocol_sms_parse_get_info},
+       {"SETWHITEPHB:", 12, mmi_protocol_sms_parse_set_white_list_switch},
+
+
+       /*******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)
+{
+       if(NULL == number)
+       {
+               SMS_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               return ;
+       }
+       
+       char * sms_number = (char *)lv_mem_alloc(NV_CONTACTS_MAX_NUMBER_LEN);
+       _lv_memset_00(sms_number, sizeof(sms_number));
+       _lv_memcpy(sms_number, number, NV_CONTACTS_MAX_NUMBER_LEN);
+
+       char * sms_data = (char *)lv_mem_alloc(MMI_REPLY_SMS_DATA_LEN_MAX);
+       _lv_memset_00(sms_data, sizeof(sms_data));
+       if(NULL != content_str)
+       {
+               if(MMI_REPLY_SMS_DATA_LEN_MAX <= strlen(content_str))
+               {
+                       SMS_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: content_str too large\n", __FUNCTION__, __LINE__);
+                       _lv_memset_00(content_str + MMI_REPLY_SMS_DATA_LEN_MAX - 1, sizeof(content_str + MMI_REPLY_SMS_DATA_LEN_MAX - 1));
+               }
+               sprintf(sms_data, "%s", content_str);
+       }
+       else
+       {
+               sprintf(sms_data, "%s OK", fixed_str);
+       }
+
+       uint8_t sms_data_len = strlen(sms_data);
+
+       SMS_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: %s,%s,%d\n", __FUNCTION__, __LINE__, sms_number, sms_data, sms_data_len);
+       
+       app_adaptor_sms_send_req(sms_number, sms_data, sms_data_len, NULL, cb);
+}
+
+//SETIP:api.xcloudtech.com:9000
+static char ip_address[NV_WATCH_HOST_NAME_LEN_MAX] = {0};
+static int ip_port = 0;
+static void mmi_protocol_sms_set_ip_cb(watch_app_adp_sms_send_result_type_t result)
+{
+       SMS_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: %d\n", __FUNCTION__, __LINE__, result);
+       
+       if(APP_SMS_SEND_SUCCESS == result)
+       {
+               mmi_watch_host_name_set(ip_address);
+               mmi_watch_host_port_set(ip_port);
+               
+               send_task_msg_tcp_reconnect(NULL);
+       }
+       else if(APP_SMS_SEND_FAIL == result)
+       {
+               //
+       }
+}
+
+bool mmi_protocol_sms_parse_set_ip(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;
+       }
+
+       uint8_t i = 0;
+
+       _lv_memset_00(ip_address, sizeof(ip_address));
+       ip_port = 0;
+       
+       while(':' != data[i])
+       {
+               ip_address[i] = data[i];
+               i++;
+       }
+       i++;
+       ip_port = atoi(data + i);
+
+       mmi_protocol_sms_parse_sms_reply(NULL, fixed_str, number, mmi_protocol_sms_set_ip_cb);
+
+       return true;
+}
+
+
+//GETIP //api.xcloudtech.com:9000
+bool mmi_protocol_sms_parse_get_ip(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;
+       }
+
+       char content_str[NV_WATCH_HOST_NAME_LEN_MAX + 16] = {0};
+       char * t_host_name = mmi_watch_host_name_get();
+       int t_host_port = mmi_watch_host_port_get();
+
+       sprintf(content_str, "GETIP:%s:%d", t_host_name, t_host_port);
+       
+       mmi_protocol_sms_parse_sms_reply(content_str, NULL, number, NULL);
+
+       return true;
+}
+
+
+// SETMD5KEY:xyz890
+static char s_md5_key[NV_PROTOCOL_MD5_KEY_LEN_MAX] = {0};
+static void mmi_protocol_sms_set_md5_key_cb(watch_app_adp_sms_send_result_type_t result)
+{
+       SMS_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: %d\n", __FUNCTION__, __LINE__, result);
+       
+       if(APP_SMS_SEND_SUCCESS == result)
+       {
+               mmi_protocol_md5_key_str_set(s_md5_key);
+       }
+       else if(APP_SMS_SEND_FAIL == result)
+       {
+               //
+       }
+}
+
+bool mmi_protocol_sms_parse_set_md5_key(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);
+       
+       uint16_t t_data_len = strlen(data);
+       if(0 == t_data_len || NV_PROTOCOL_MD5_KEY_LEN_MAX <= t_data_len)
+       {
+               SMS_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               return false;
+       }
+
+       _lv_memset_00(s_md5_key, sizeof(s_md5_key));
+       _lv_memcpy(s_md5_key, data, t_data_len);
+
+       mmi_protocol_sms_parse_sms_reply(NULL, fixed_str, number, mmi_protocol_sms_set_md5_key_cb);
+
+       return true;
+}
+
+
+// SETDEVICENAME:abc123
+static char s_device_name[NV_PROTOCOL_DEVICE_NAME_LEN_MAX] = {0};
+static void mmi_protocol_sms_set_device_name_cb(watch_app_adp_sms_send_result_type_t result)
+{
+       SMS_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: %d\n", __FUNCTION__, __LINE__, result);
+       
+       if(APP_SMS_SEND_SUCCESS == result)
+       {
+               mmi_protocol_device_name_set(s_device_name);
+       }
+       else if(APP_SMS_SEND_FAIL == result)
+       {
+               //
+       }
+}
+
+bool mmi_protocol_sms_parse_set_device_name(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);
+       
+       uint16_t t_data_len = strlen(data);
+       if(0 == t_data_len || NV_PROTOCOL_DEVICE_NAME_LEN_MAX <= t_data_len)
+       {
+               SMS_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               return false;
+       }
+
+       _lv_memset_00(s_device_name, sizeof(s_device_name));
+       _lv_memcpy(s_device_name, data, t_data_len);
+
+       mmi_protocol_sms_parse_sms_reply(NULL, fixed_str, number, mmi_protocol_sms_set_device_name_cb);
+
+       return true;
+}
+
+
+//SETUPLOAD:300
+static uint32_t upload_interval = 0;
+static void mmi_protocol_sms_set_upload_cb(watch_app_adp_sms_send_result_type_t result)
+{
+       SMS_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: %d\n", __FUNCTION__, __LINE__, result);
+       
+       if(APP_SMS_SEND_SUCCESS == result)
+       {
+               mmi_protocol_watch_location_upload_interval_set(upload_interval);
+       }
+       else if(APP_SMS_SEND_FAIL == result)
+       {
+               //
+       }
+}
+
+bool mmi_protocol_sms_parse_set_upload(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;
+       }
+       
+       upload_interval = atoi(data);
+       mmi_protocol_sms_parse_sms_reply(NULL, fixed_str, number, mmi_protocol_sms_set_upload_cb);
+
+       return true;
+}
+
+//POWEROFF
+static void mmi_protocol_sms_power_off_cb(watch_app_adp_sms_send_result_type_t result)
+{
+       SMS_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: %d\n", __FUNCTION__, __LINE__, result);
+       
+       if(APP_SMS_SEND_SUCCESS == result)
+       {
+               mmi_watch_power_off_aciton();
+       }
+       else if(APP_SMS_SEND_FAIL == result)
+       {
+               //
+       }
+}
+
+bool mmi_protocol_sms_parse_power_off(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_power_off_cb);
+
+       return true;
+}
+
+//SETFACTORY
+static void mmi_protocol_sms_set_factory_cb(watch_app_adp_sms_send_result_type_t result)
+{
+       SMS_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: %d\n", __FUNCTION__, __LINE__, result);
+       
+       if(APP_SMS_SEND_SUCCESS == result)
+       {
+               mmi_watch_factory_aciton();
+       }
+       else if(APP_SMS_SEND_FAIL == result)
+       {
+               //
+       }
+}
+
+bool mmi_protocol_sms_parse_set_factory(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_set_factory_cb);
+
+       return true;
+}
+
+//SETREBOOT
+static void mmi_protocol_sms_set_reboot_cb(watch_app_adp_sms_send_result_type_t result)
+{
+       SMS_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: %d\n", __FUNCTION__, __LINE__, result);
+       
+       if(APP_SMS_SEND_SUCCESS == result)
+       {
+               mmi_watch_restart();
+       }
+       else if(APP_SMS_SEND_FAIL == result)
+       {
+               //
+       }
+}
+
+bool mmi_protocol_sms_parse_set_reboot(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_set_reboot_cb);
+
+       return true;
+}
+
+//GETIMEI
+bool mmi_protocol_sms_parse_get_imei(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;
+       }
+       
+       char content_str[32] = {0};
+    char imei_str[16] = {0};
+       
+       app_adp_get_imei_req(imei_str);
+       sprintf(content_str, "IMEI:%s", imei_str);
+       
+       mmi_protocol_sms_parse_sms_reply(content_str, NULL, number, NULL);
+
+       return true;
+}
+
+//
+static void mmi_protocol_sms_unbind_cb(watch_app_adp_sms_send_result_type_t result)
+{
+       SMS_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: %d\n", __FUNCTION__, __LINE__, result);
+       
+       if(APP_SMS_SEND_SUCCESS == result)
+       {
+               mmi_protocol_action_unbind();
+       }
+       else if(APP_SMS_SEND_FAIL == result)
+       {
+               //
+       }
+}
+
+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 true;
+}
+
+
+//SETAPN:mcc,mnc,name,apn
+static MMI_Modem_Apn_Info_t s_ApnInfo = {0};
+static void mmi_protocol_sms_set_apn_cb(watch_app_adp_sms_send_result_type_t result)
+{
+       SMS_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: %d\n", __FUNCTION__, __LINE__, result);
+       
+       if(APP_SMS_SEND_SUCCESS == result)
+       {
+               watch_modem_set_apn_info(&s_ApnInfo);
+               watch_modem_config_apn(s_ApnInfo.apn, 0);
+       }
+       else if(APP_SMS_SEND_FAIL == result)
+       {
+               //
+       }
+}
+
+bool mmi_protocol_sms_parse_set_apn(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;
+       }
+
+       //{460, 11,     "CTCC",         "ctnet",                ,       "0",    "NONE",         "any",          "any",  "IPV4V6"}
+       //{mcc, mnc£¬"ÔËÓªÉÌÃû¡±,"½ÓÈëµãÃû³Æ¡±,mtu,"ÍøÂçÀàÐÍ","¼øÈ¨ÀàÐÍ","Óû§Ãû¡±,"ÃÜÂ롱,"IPÀàÐÍ¡±}
+       char * temp_ptr = NULL;
+       uint8_t t_offset = 0;
+       char * t_mcc = NULL;
+       char * t_mnc = NULL;
+       char * t_name = NULL;
+       char * t_apn = NULL;
+       char * t_mtu = NULL;
+       char * t_net_type = NULL;
+       char * t_authentication_type = NULL;
+       char * t_user_name = NULL;
+       char * t_user_password = NULL;
+       char * t_ip_type = NULL;
+
+       t_mcc = km_strtok_r(NULL, ",", &data);
+       t_mnc = km_strtok_r(NULL, ",", &data);
+       t_name = km_strtok_r(NULL, ",", &data);
+       t_apn = km_strtok_r(NULL, ",", &data);
+
+       if(NULL == t_mcc || NULL == t_mnc || NULL == t_name || NULL == t_apn)
+       {
+               SMS_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               return false;
+       }
+
+       t_mtu = km_strtok_r(NULL, ",", &data);
+       t_net_type = km_strtok_r(NULL, ",", &data);
+       t_authentication_type = km_strtok_r(NULL, ",", &data);
+       t_user_name = km_strtok_r(NULL, ",", &data);
+       t_user_password = km_strtok_r(NULL, ",", &data);
+       t_ip_type = km_strtok_r(NULL, ",", &data);
+
+       _lv_memset_00(&s_ApnInfo, sizeof(s_ApnInfo));
+       s_ApnInfo.apnflg = 1;
+       s_ApnInfo.iptype = 0;
+
+       temp_ptr = s_ApnInfo.apn;
+       t_offset = 0;
+       
+       sprintf(temp_ptr, "%s,%s,\"%s\",\"%s\"", t_mcc, t_mnc, t_name, t_apn);  
+       t_offset = strlen(temp_ptr);
+       temp_ptr += t_offset;
+       
+       if(NULL != t_mtu)
+       {
+               sprintf(temp_ptr, ",\"%s\"", t_mtu);
+               t_offset = strlen(temp_ptr);
+               temp_ptr += t_offset;
+       }
+       
+       if(NULL != t_net_type)
+       {
+               sprintf(temp_ptr, ",\"%s\"", t_net_type);
+               t_offset = strlen(temp_ptr);
+               temp_ptr += t_offset;
+       }
+
+       if(NULL != t_authentication_type)
+       {
+               sprintf(temp_ptr, ",\"%s\"", t_authentication_type);
+               t_offset = strlen(temp_ptr);
+               temp_ptr += t_offset;
+       }
+
+       if(NULL != t_user_name)
+       {
+               sprintf(temp_ptr, ",\"%s\"", t_user_name);
+               t_offset = strlen(temp_ptr);
+               temp_ptr += t_offset;
+       }
+
+       if(NULL != t_user_password)
+       {
+               sprintf(temp_ptr, ",\"%s\"", t_user_password);
+               t_offset = strlen(temp_ptr);
+               temp_ptr += t_offset;
+       }
+
+       if(NULL != t_ip_type)
+       {
+               sprintf(temp_ptr, ",\"%s\"", t_ip_type);
+               t_offset = strlen(temp_ptr);
+               temp_ptr += t_offset;
+       }
+
+       mmi_protocol_sms_parse_sms_reply(NULL, fixed_str, number, mmi_protocol_sms_set_apn_cb);
+
+       return true;
+}
+
+
+// get device info
+bool mmi_protocol_sms_parse_get_info(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;
+       }
+
+       char content_str[MMI_REPLY_SMS_DATA_LEN_MAX] = {0};
+    char imei_str[16] = {0};
+       char * mode_str = app_adaptor_get_model_id();
+       char * version_str = app_adaptor_get_version();
+       char * host_name_str = mmi_watch_host_name_get();
+       int host_port_value = mmi_watch_host_port_get();
+       uint32_t heartbeat_value = mmi_protocol_watch_heartbeat_action_interval_get();
+       uint32_t upload_value = mmi_protocol_watch_location_upload_interval_get();
+       uint32_t battery_percent = Hal_Battery_Get_Status();
+
+       app_adp_get_imei_req(imei_str);
+
+       sprintf(content_str, "Mode:%s\nVersion:%s\nServer:%s:%d\nIMEI:%s\nConnectTime:%d\nUpload:%d\nBattery:%d",
+                                                       mode_str,
+                                                       version_str,
+                                                       host_name_str,
+                                                       host_port_value,
+                                                       imei_str,
+                                                       heartbeat_value,
+                                                       upload_value,
+                                                       battery_percent);
+       SMS_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: len=%d\n", __FUNCTION__, __LINE__, strlen(content_str));
+       
+       mmi_protocol_sms_parse_sms_reply(content_str, NULL, number, NULL);
+
+       return true;
+}
+
+//SETWHITEPHB:0 / 1
+static uint32_t white_list_switch = 0;
+static void mmi_protocol_sms_set_white_list_switch_cb(watch_app_adp_sms_send_result_type_t result)
+{
+       SMS_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: %d\n", __FUNCTION__, __LINE__, result);
+       
+       if(APP_SMS_SEND_SUCCESS == result)
+       {
+               mmi_white_list_switch_set(white_list_switch);
+       }
+       else if(APP_SMS_SEND_FAIL == result)
+       {
+               //
+       }
+}
+
+bool mmi_protocol_sms_parse_set_white_list_switch(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;
+       }
+       
+       if(0 == atoi(data))
+               white_list_switch = 0;
+       else
+               white_list_switch = 2;
+
+       mmi_protocol_sms_parse_sms_reply(NULL, fixed_str, number, mmi_protocol_sms_set_white_list_switch_cb);
+
+       return true;
+}
+
+
+#endif
+
+
diff --git a/2.sdk/sdk/gui/lv_watch/mmi_protocol/mmi_protocol_sms.h b/2.sdk/sdk/gui/lv_watch/mmi_protocol/mmi_protocol_sms.h
new file mode 100644 (file)
index 0000000..6b9d005
--- /dev/null
@@ -0,0 +1,66 @@
+
+
+
+#ifndef __MMI_PROTOCOL_SMS_H__
+#define __MMI_PROTOCOL_SMS_H__
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif //__cplusplus
+
+#ifdef LV_CONF_INCLUDE_SIMPLE
+#include "lvgl.h"
+#include "lv_watch_conf.h"
+#else
+#include "../../../lvgl/lvgl.h"
+#include "../../../lv_watch_conf.h"
+#endif
+
+#ifdef __MMI_ZHSX_SUPPORT_SMS__
+
+#define __MMI_PROTOCOL_SMS_DEBUG__
+#ifdef __MMI_PROTOCOL_SMS_DEBUG__
+#define SMS_DEBUG_PRINTF(fmt, ...)     printf("[SMS]"fmt, ##__VA_ARGS__)
+#else
+#define SMS_DEBUG_PRINTF(fmt, ...)
+#endif
+
+
+#define MMI_REPLY_SMS_DATA_LEN_MAX     (512)
+
+typedef bool (* SMS_PARSE_CB)(char *, char *, char *);
+
+typedef struct
+{
+       const char * fixed_str;
+       uint8_t fixed_str_len;
+       SMS_PARSE_CB parse_cb;
+} MMI_PROTOCOL_SMS_PARSE_STRUCT;
+
+
+bool mmi_protocol_sms_content_parse(char * sms_content, char * sms_send_number);
+bool mmi_protocol_sms_parse_set_ip(char * fixed_str, char * data, char * number);
+bool mmi_protocol_sms_parse_get_ip(char * fixed_str, char * data, char * number);
+bool mmi_protocol_sms_parse_set_md5_key(char * fixed_str, char * data, char * number);
+bool mmi_protocol_sms_parse_set_device_name(char * fixed_str, char * data, char * number);
+bool mmi_protocol_sms_parse_set_upload(char * fixed_str, char * data, char * number);
+bool mmi_protocol_sms_parse_power_off(char * fixed_str, char * data, char * number);
+bool mmi_protocol_sms_parse_set_factory(char * fixed_str, char * data, char * number);
+bool mmi_protocol_sms_parse_set_reboot(char * fixed_str, char * data, char * number);
+bool mmi_protocol_sms_parse_get_imei(char * fixed_str, char * data, char * number);
+bool mmi_protocol_sms_parse_unbind(char * fixed_str, char * data, char * number);
+bool mmi_protocol_sms_parse_set_apn(char * fixed_str, char * data, char * number);
+bool mmi_protocol_sms_parse_get_info(char * fixed_str, char * data, char * number);
+bool mmi_protocol_sms_parse_set_white_list_switch(char * fixed_str, char * data, char * number);
+
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif //__cplusplus
+
+#endif
+
+#endif
+
+
diff --git a/2.sdk/sdk/gui/lv_watch/mmi_sundry/mmi_common.c b/2.sdk/sdk/gui/lv_watch/mmi_sundry/mmi_common.c
new file mode 100644 (file)
index 0000000..7baf3f5
--- /dev/null
@@ -0,0 +1,293 @@
+
+
+
+#include "lv_watch.h"
+
+#ifdef __MMI_ZHSX_SUPPORT__
+
+char * km_strtok_r(char * s, const char * delim, char ** last)
+{
+    /*----------------------------------------------------------------*/
+    /* Local Variables                                                */
+    /*----------------------------------------------------------------*/
+    char *spanp;
+    int c, sc;
+    char *tok;
+
+    /*----------------------------------------------------------------*/
+    /* Code Body                                                      */
+    /*----------------------------------------------------------------*/
+    if (s == NULL && (s = *last) == NULL)
+    {
+        return (NULL);
+    }
+       
+    c = *s;
+    spanp = (signed char *)delim;
+    sc = *spanp;
+    if(strlen(delim) == 1 && c == sc)
+    {
+          *s++;
+        *last = s;
+        return (NULL);
+    }
+ 
+    if(strlen(delim)==1&&s == NULL)
+    {
+          c = **last;
+          if(c==sc)
+          {            
+                  **last++;
+                  return NULL;
+          }
+    }
+
+    /*
+     * Skip (span) leading delimiters (s += strspn(s, delim), sort of).
+     */
+cont:
+    c = *s++;
+    for (spanp = (signed char *)delim; (sc = *spanp++) != 0;)
+    {
+        if (c == sc &&spanp == 0)
+               
+           goto cont;
+    }
+
+    if (c == 0)                /* no non-delimiter characters */
+    {
+        *last = NULL;
+        return (NULL);
+    }
+    tok = s - 1;
+
+    /*
+     * Scan token (scan for delimiters: s += strcspn(s, delim), sort of).
+     * Note that delim must have one NUL; we stop if we see that, too.
+     */
+    for (;;)
+    {
+        c = *s++;
+        spanp = (signed char *)delim;
+               
+        do
+        {
+            if ((sc = *spanp++) == c)
+            {
+                if (c == 0)
+                {
+                    s = NULL;
+                }
+                else
+                {
+                    s[-1] = 0;
+                }
+                               
+                *last = s;
+                               
+                return (tok);
+            }
+        }
+        while (sc != 0);
+    }
+    /* NOTREACHED */
+}
+
+void mmi_float_to_str(double float_num, uint8_t int_num, char * data_str)
+{
+       uint8_t i = 0;
+       uint32_t high_part = 0;
+       double low_part = 0.0;
+       char high_part_str[16] = {0}, low_part_str[16] = {0};
+
+       high_part = (int)float_num;
+       sprintf(high_part_str, "%d", high_part);
+       
+       low_part = float_num - high_part;
+       for(i = 0; i < int_num; i++)
+       {
+               uint32_t temp_high = 0;
+               
+               low_part = low_part * 10;
+               temp_high = (int)low_part;
+               low_part -= temp_high;
+               low_part_str[i] = '0' + temp_high;
+       }
+       low_part_str[i] = '\0';
+
+       sprintf(data_str, "%s.%s", high_part_str, low_part_str);
+}
+
+signed char mmi_char_to_upper(signed char c)
+{
+       if ( c >= 'a' && c <= 'z' )
+       {
+               c = c - 'a' + 'A';
+       }
+       
+       return c;
+}
+
+void mmi_str_to_upper(signed char *str, signed int len)
+{
+    signed int i = 0;
+
+    for(i = 0; i < len; i++)
+    {
+        str[i] = mmi_char_to_upper(str[i]);
+    }
+}
+
+signed int mmi_hex_string_to_number(signed char* hex_str, unsigned char hex_str_len)
+{
+       int int_value = 0;
+       uint8_t i = 0, t_value = 0;
+       char t_char = 0;
+       
+       if(NULL == hex_str || 0 == hex_str_len)
+               return 0;
+       
+       for(i = 0; i < hex_str_len; i++)
+       {
+               t_char = hex_str[i];
+               if('a' <= t_char && 'z' >= t_char)
+                       t_char = t_char - 'a' + 'A';
+
+               t_value = ('A' <= t_char) ? (t_char - 'A' + 10) : (t_char - '0');
+               int_value = int_value * 16 + t_value;
+       }
+
+       return int_value;
+}
+
+// hex str:4 -> utf8:3
+bool mmi_unicode_hex_str_to_utf8_str(unsigned char * src, uint32_t src_len, unsigned char * dest, uint32_t * dest_len)
+{
+       if ((NULL == src) || (0 == src_len) || (NULL == dest))
+       {
+               return false;
+       }
+
+       if (0 != (src_len % 4))
+       {
+               src_len -= (src_len % 4);
+       }
+
+       uint32_t i = 0, j = 0;
+       uint32_t t_len = 0, t_char = 0;
+       int32_t * t_buff = NULL;
+
+       t_buff = (int32_t *)lv_mem_alloc(sizeof(int32_t) * src_len);
+       if(NULL == t_buff)
+       {
+               return false;
+       }
+
+       for(i = 0; i*4 < src_len; i++)
+       {
+               t_buff[i] = mmi_hex_string_to_number(src + i*4, 4);
+       }
+       t_len = i;
+
+       int32_t ref = 0xe08080;
+       int32_t t_value1 = 0, t_value2 = 0;
+       
+       for(i = 0, j = 0; i < t_len; i++)
+       {
+               int32_t result = ref;
+
+               t_value1 = t_buff[i];
+
+               if(255 >= t_value1)
+               {
+                       dest[j++] = t_value1;
+                       continue;
+               }
+
+               // È¡×îºóÁùλ
+               t_value2 = t_value1 & 0x3f;
+
+               // ½«×îºóÁùλ·ÅÔÚref×îºóÁùλµÄ¿ÕλÖÃ
+               result |= t_value2;
+               t_value1 = t_value1 >> 6;
+
+               // È¡½ÓÏÂÀ´µÄÁùλ
+               t_value2 = t_value1 & 0x3f;
+
+               // ·ÅÔÚref¶ÔÓ¦µÄÁù¸öλÖÃ
+               result |= (t_value2 << 8);
+
+               // ±£Áô×îºóËÄλ
+               t_value1 = t_value1 >> 6;
+
+               // ·ÅÔÚref¶ÔÓ¦µÄËĸöλÖà   
+               result |= (t_value1 << 16);
+
+               dest[j++] = (unsigned char)(result >> 16);
+               dest[j++] = (unsigned char)(result >> 8);
+               dest[j++] = (unsigned char)(result & 0x00FF);
+       }
+
+       if(NULL != dest_len)
+       {
+               * dest_len = j;
+       }
+
+       lv_mem_free(t_buff);
+       return true;
+}
+
+
+bool mmi_debug_info_write_to_file(char * info_buf)
+{
+       lv_fs_file_t file_p;
+       lv_fs_res_t res;
+       uint32_t bytes_write = 0;
+       uint32_t info_size = strlen(info_buf);
+
+       res = lv_fs_open(&file_p, MMI_DEBUG_LOG_FILE, LV_FS_MODE_WR | LV_FS_MODE_APPEND);
+       if(LV_FS_RES_OK != res) 
+       {
+               printf("[@CHENG_DEBUG][%s][%d]: errno=%d\n", __FUNCTION__, __LINE__, res);
+               lv_fs_close(&file_p);
+               return false;
+       }
+
+       hal_rtc_t cur_time = {0};
+       char str_time[24] = {0};
+       
+       Hal_Rtc_Gettime(&cur_time);
+       sprintf(str_time, "\n[%04d%02d%02d_%02d%02d%02d]:", 
+                       cur_time.tm_year,
+                       cur_time.tm_mon,
+                       cur_time.tm_mday,
+                       cur_time.tm_hour,
+                       cur_time.tm_min,
+                       cur_time.tm_sec);
+
+       //lv_fs_seek
+       res = lv_fs_write(&file_p, str_time, strlen(str_time), &bytes_write);
+       if(LV_FS_RES_OK != res)
+       {
+               printf("[@CHENG_DEBUG][%s][%d]: errno=%d\n", __FUNCTION__, __LINE__, res);
+               lv_fs_close(&file_p);
+               return false;
+       }
+       
+       res = lv_fs_write(&file_p, info_buf, info_size, &bytes_write);
+       lv_fs_close(&file_p);
+       if(LV_FS_RES_OK != res)
+       {
+               printf("[@CHENG_DEBUG][%s][%d]: errno=%d\n", __FUNCTION__, __LINE__, res);
+               return false;
+       }
+       printf("[@CHENG_DEBUG][%s][%d]: file_size=%d,write_size=%d\n", __FUNCTION__, __LINE__, info_size, bytes_write);
+
+       return true;
+}
+
+
+
+#endif
+
+
diff --git a/2.sdk/sdk/gui/lv_watch/mmi_sundry/mmi_common.h b/2.sdk/sdk/gui/lv_watch/mmi_sundry/mmi_common.h
new file mode 100644 (file)
index 0000000..ae27a0d
--- /dev/null
@@ -0,0 +1,54 @@
+
+
+
+#ifndef __MMI_COMMON_H__
+#define __MMI_COMMON_H__
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif //__cplusplus
+
+#ifdef LV_CONF_INCLUDE_SIMPLE
+#include "lvgl.h"
+#include "lv_watch_conf.h"
+#else
+#include "../../../lvgl/lvgl.h"
+#include "../../../lv_watch_conf.h"
+#endif
+
+#ifdef __MMI_ZHSX_SUPPORT__
+
+
+#define MMI_DEBUG_LOG_FILE     "C:/debug_log.txt"
+#define MMI_ABS(x)       (((x) < 0) ? (-(x)) : (x))
+
+
+#define LV_COLOR_HEX3(c) LV_COLOR_MAKE((uint8_t) (((c >> 4) & 0xF0) | ((c >> 8) & 0xF)),   \
+                                (uint8_t) ((uint32_t)(c & 0xF0)     | ((c & 0xF0) >> 4)), \
+                                (uint8_t) ((uint32_t)(c & 0xF)      | ((c & 0xF) << 4)))
+
+
+void mmi_float_to_str(double float_num, uint8_t int_num, char * data_str);
+
+char * km_strtok_r(char * s, const char * delim, char ** last);
+
+signed char mmi_char_to_upper(signed char c);
+
+void mmi_str_to_upper(signed char *str, signed int len);
+
+signed int mmi_hex_string_to_number(signed char* hex_str, unsigned char hex_str_len);
+
+bool mmi_unicode_hex_str_to_utf8_str(unsigned char * src, uint32_t src_len, unsigned char * dest, uint32_t * dest_len);
+
+bool mmi_debug_info_write_to_file(char * info_buf);
+
+#endif
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif //__cplusplus
+
+#endif
+
+
diff --git a/2.sdk/sdk/gui/lv_watch/mmi_sundry/mmi_sundry.c b/2.sdk/sdk/gui/lv_watch/mmi_sundry/mmi_sundry.c
new file mode 100644 (file)
index 0000000..c7a2b94
--- /dev/null
@@ -0,0 +1,1423 @@
+
+
+
+#include "lv_watch.h"
+
+#ifdef __MMI_ZHSX_SUPPORT__
+
+bool mmi_active_screen_is_prohibit_interrupted(void)
+{
+       if(MMI_MODEM_CALL_STATE_NULL != phone_get_call_state())
+       {
+               return true;
+       }
+       
+    lv_obj_t * obj = lv_watch_get_activity_obj(ACT_ID_PHONE);
+    if(NULL != obj)
+       {
+               return true;
+       }
+
+    if(NULL != lv_watch_get_activity_obj(ACT_ID_ANYOBJ))
+       {
+               return true;
+       }
+       
+    if(NULL != lv_watch_get_activity_obj(ACT_ID_SHUTDOWN))
+       {
+               return true;
+       }
+
+       if(NULL != lv_watch_get_activity_obj(ACT_ID_RESTART))
+       {
+               return true;
+       }
+
+       if(NULL != lv_watch_get_activity_obj(ACT_ID_POWON_LOGO))
+       {
+               return true;
+       }
+
+       if(NULL != lv_watch_get_activity_obj(ACT_ID_WATCH_FACTORY_RESET))
+       {
+               return true;
+       }
+
+       if(NULL != lv_watch_get_activity_obj(ACT_ID_ALARM))
+       {
+               return true;
+       }
+
+#if USE_LV_WATCH_SOS != 0
+       if(NULL != lv_watch_get_activity_obj(ACT_ID_SOS))
+       {
+               return true;
+       }
+#endif
+       
+#if USE_LV_WATCH_UPGRADE != 0
+    if(NULL != lv_watch_get_activity_obj(ACT_ID_UPGRADE))
+       {
+               return true;
+       }
+#endif
+
+       return false;
+}
+
+void mmi_watch_wake_up(void)
+{
+#if 1
+    if(0 == Hal_Pm_Get_State()) 
+       {
+        Hal_Pm_WakeUp();
+    } 
+       else 
+       {
+        watch_wakeup_lcd(false);
+               watch_wakeup_time_reset();
+    }
+
+#else
+       if(0 == Hal_Pm_Get_State())
+       {
+               extern void onkey_wakeup(void) __attribute__((weak));
+               if (onkey_wakeup != NULL)
+               {
+                       onkey_wakeup();
+               }
+       }
+       else
+       {
+               watch_set_lcd_status(true);
+               watch_wakeup_time_reset();
+       }
+#endif
+}
+
+bool mmi_watch_vibrate_is_permitted(void)
+{
+#ifndef __MMI_ZHSX_NO_VIBRATION_SUPPORT__
+
+#ifdef __MMI_USER_PROFILE_SUPPORT__
+       if(true == mmi_user_profile_is_ring_vib_mode() || true == mmi_user_profile_is_vib_only_mode())
+       {
+               return true;
+       }
+       else
+       {
+               return false;
+       }
+
+#else
+
+       return true;
+#endif
+
+#else
+
+       return false;
+#endif
+}
+
+void mmi_ui_msg_update_watch_factory(void)
+{
+       mmi_watch_reset(NULL);
+}
+
+void mmi_watch_factory_aciton(void)
+{
+       SUNDRY_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+
+       // ui
+    mmi_watch_wake_up();
+       mmi_ui_msg_action_watch_factory();
+}
+
+
+void mmi_ui_msg_update_watch_power_off(void)
+{
+       mmi_watch_power_off();
+}
+
+void mmi_watch_power_off_aciton(void)
+{
+       SUNDRY_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+
+       // ui
+    mmi_watch_wake_up();
+       mmi_ui_msg_action_watch_power_off();
+}
+
+void mmi_ui_msg_update_watch_reboot(void)
+{
+       mmi_watch_restart();
+}
+
+void mmi_watch_reboot_aciton(void)
+{
+       SUNDRY_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+
+    mmi_watch_wake_up();
+       mmi_ui_msg_action_watch_reboot();
+}
+
+
+static TIMER_ID s_watch_search_timer_id = NULL;
+static TIMER_ID s_watch_falldwon_id = NULL;
+
+
+void mmi_watch_search_timer_stop(void)
+{
+       if(NULL != s_watch_search_timer_id)
+       {
+               Hal_Timer_Stop(s_watch_search_timer_id);
+               s_watch_search_timer_id = NULL;
+       }
+}
+
+void mmi_falldwon_timer_stop(void)
+{
+       if(NULL != s_watch_falldwon_id)
+       {
+               Hal_Timer_Stop(s_watch_falldwon_id);
+               s_watch_falldwon_id = NULL;
+       }
+}
+
+
+static void mmi_watch_search_audio_ctrl_callback(AUDIO_CTRL_PRIORITY priority)
+{
+       SUNDRY_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: priority=%d\n", __FUNCTION__, __LINE__, priority);
+       
+    if(AUDIO_CTRL_PRIORITY_SEARCH == priority) 
+       {
+
+    } 
+       else if(AUDIO_CTRL_PRIORITY_SEARCH > priority) 
+       {
+               mmi_watch_search_screen_destroy();
+    }
+}
+
+static void mmi_falldwon_audio_ctrl_callback(AUDIO_CTRL_PRIORITY priority)
+{
+       SUNDRY_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: priority=%d\n", __FUNCTION__, __LINE__, priority);
+       
+    if(AUDIO_CTRL_PRIORITY_9 == priority) 
+       {
+
+    } 
+       else if(AUDIO_CTRL_PRIORITY_9 > priority) 
+       {
+               mmi_falldwon_destroy();
+    }
+}
+
+void mmi_watch_search_timeout_cb(void * para)
+{
+       mmi_watch_search_screen_destroy();
+}
+
+void mmi_falldwon_timeout_cb(void * para)
+{
+       mmi_falldwon_destroy();
+}
+
+void mmi_watch_search_timer_start(void)
+{
+       mmi_watch_search_timer_stop();
+       s_watch_search_timer_id = Hal_Timer_Start(MMI_WATCH_SEARCH_DURATION, mmi_watch_search_timeout_cb, NULL, false);
+}
+
+void mmi_falldwon_timer_start(void)
+{
+       mmi_falldwon_timer_stop();
+       s_watch_falldwon_id = Hal_Timer_Start(MMI_WATCH_SEARCH_DURATION, mmi_falldwon_timeout_cb, NULL, false);
+}
+
+void mmi_watch_search_screen_destroy(void)
+{
+       SUNDRY_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+       
+    //lv_watch_search_ext_t * ext = lv_obj_get_ext_attr(lv_watch_get_activity_obj(ACT_ID_WATCH_SEARCHING));
+       
+       mmi_watch_search_timer_stop();
+
+       Hal_NFFS_File_Play_End();
+    Hal_Audio_Manage_End_Ind(AUDIO_CTRL_PRIORITY_SEARCH);
+       Hal_Vibrator_Play_End();
+       
+       lv_watch_png_cache_all_free();
+       //lv_obj_del_async(lv_watch_get_activity_obj(ACT_ID_WATCH_SEARCHING));
+    lv_obj_t * activity_obj = lv_watch_get_activity_obj(ACT_ID_WATCH_SEARCHING);
+    if(activity_obj)
+       {
+        lv_obj_del(activity_obj);
+    }
+
+       watch_set_suspend_enable(true, ACT_ID_WATCH_SEARCHING, 0);
+    //watch_wakeup_time_reset();
+}
+
+
+void mmi_falldwon_destroy(void)
+{
+       SUNDRY_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+       
+    //lv_watch_search_ext_t * ext = lv_obj_get_ext_attr(lv_watch_get_activity_obj(ACT_ID_WATCH_SEARCHING));
+       
+       mmi_falldwon_timer_stop();
+
+       Hal_NFFS_File_Play_End();
+    Hal_Audio_Manage_End_Ind(AUDIO_CTRL_PRIORITY_SEARCH);
+       Hal_Vibrator_Play_End();
+       
+       lv_watch_png_cache_all_free();
+       //lv_obj_del_async(lv_watch_get_activity_obj(ACT_ID_WATCH_SEARCHING));
+    lv_obj_t * activity_obj = lv_watch_get_activity_obj(ACT_ID_WATCH_FALLDWON);
+    if(activity_obj)
+       {
+        lv_obj_del(activity_obj);
+    }
+
+       watch_set_suspend_enable(true, ACT_ID_WATCH_FALLDWON, 0);
+    //watch_wakeup_time_reset();
+}
+
+
+void mmi_watch_search_screen_event_cb(lv_obj_t * obj, lv_event_t e)
+{      
+    if(LV_EVENT_CLICKED == e)
+       {
+               mmi_watch_search_screen_destroy(); // lv_watch_del_interface(ACT_ID_WATCH_SEARCHING);
+    }
+}
+
+void mmi_falldwon_event_cb(lv_obj_t * obj, lv_event_t e)
+{      
+    if(LV_EVENT_CLICKED == e)
+       {
+
+               mmi_falldwon_destroy(); // lv_watch_del_interface(ACT_ID_WATCH_SEARCHING);
+    }
+}
+
+
+void mmi_falldwon_OK_event_cb(lv_obj_t * obj, lv_event_t e)
+{      
+    if(LV_EVENT_CLICKED == e)
+       {
+               mmi_protocol_action_fall_down();
+               mmi_falldwon_destroy(); // lv_watch_del_interface(ACT_ID_WATCH_SEARCHING);
+    }
+}
+
+
+
+lv_obj_t * mmi_watch_falldwon_create(lv_obj_t * activity_obj)
+{
+       SUNDRY_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+       
+       lv_watch_png_cache_all_free();
+    if(NULL == activity_obj) 
+       {
+        lv_watch_activity_ext_t activity_ext = {0};
+
+        activity_ext.actId = ACT_ID_WATCH_FALLDWON;
+        activity_ext.create = (lv_watch_activity_create_f_t)mmi_watch_falldwon_create;
+        activity_ext.prepare_destory = mmi_falldwon_destroy;
+        activity_obj = lv_watch_creat_activity_obj(&activity_ext);
+        if(NULL == activity_obj)
+            return NULL;
+    }
+
+    lv_obj_t * obj = lv_watch_obj_create(activity_obj);
+    LV_ASSERT_MEM(obj);
+       
+       lv_watch_search_ext_t * searching_ext = lv_obj_allocate_ext_attr(obj, sizeof(lv_watch_search_ext_t));
+
+       lv_obj_t * cont = lv_cont_create(obj, NULL);
+       lv_obj_set_size(cont, lv_obj_get_width(obj), lv_obj_get_height(obj));
+       lv_obj_align(cont, obj, LV_ALIGN_CENTER, 0, 0);
+       lv_obj_set_style_local_bg_color(cont, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, lv_color_make(0, 0, 0)); // LV_COLOR_BLACK
+       lv_obj_set_click(cont, true);
+       lv_obj_set_event_cb(cont, mmi_falldwon_event_cb);       
+       //lv_obj_add_protect(cont, LV_PROTECT_PRESS_LOST);
+
+       lv_obj_t * label = lv_label_create(cont, NULL);
+       lv_obj_add_style(label, LV_LABEL_PART_MAIN, &lv_watch_font20);
+       lv_label_set_text_id(label, WATCH_TEXT_ID_FALLDWON); //lv_lang_get_text(WATCH_TEXT_ID_SERVER_SEARCH_PROMPT)
+       lv_obj_align(label, cont, LV_ALIGN_CENTER, 0, 0);
+
+       lv_obj_t * btn_cancel = lv_btn_create(cont, NULL);
+       lv_obj_set_size(btn_cancel, 100, 56);
+       lv_obj_set_style_local_bg_color(btn_cancel, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_MAKE(0x47, 0xA6, 0xFF));
+       lv_obj_set_style_local_radius(btn_cancel, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 30);
+       lv_obj_set_style_local_bg_color(btn_cancel, LV_BTN_PART_MAIN, LV_STATE_PRESSED, LV_COLOR_MAKE(0x47, 0xA6, 0xFF));
+       lv_obj_set_style_local_radius(btn_cancel, LV_BTN_PART_MAIN, LV_STATE_PRESSED, 30);
+       lv_obj_align(btn_cancel, NULL, LV_ALIGN_IN_BOTTOM_LEFT, 10, -20);
+       lv_obj_set_event_cb(btn_cancel, mmi_falldwon_event_cb);
+       lv_obj_t * label_cancel = lv_label_create(btn_cancel, NULL);
+       lv_label_set_text_id(label_cancel, WATCH_TEXT_ID_CANCEL);
+       lv_obj_add_style(label_cancel, LV_LABEL_PART_MAIN, &lv_watch_font26_black);
+
+       lv_obj_t * btn_ok = lv_btn_create(cont, btn_cancel);
+       lv_obj_set_style_local_bg_color(btn_ok, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_MAKE(0xFF, 0x6F, 0x91));
+       lv_obj_set_style_local_radius(btn_ok, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 30);
+       lv_obj_set_style_local_bg_color(btn_ok, LV_BTN_PART_MAIN, LV_STATE_PRESSED, LV_COLOR_MAKE(0xFF, 0x6F, 0x91));
+       lv_obj_set_style_local_radius(btn_ok, LV_BTN_PART_MAIN, LV_STATE_PRESSED, 30);
+       lv_obj_align(btn_ok, NULL, LV_ALIGN_IN_BOTTOM_RIGHT, -10, -20);
+       lv_obj_set_event_cb(btn_ok, mmi_falldwon_OK_event_cb);
+       lv_obj_t * label_ok = lv_label_create(btn_ok, label_cancel);
+       lv_label_set_text_id(label_ok, WATCH_TEXT_ID_OK);
+
+       //prompt
+    if (AUDIO_CTRL_PRIORITY_9 == Hal_Audio_Manage_Start_Req(AUDIO_CTRL_PRIORITY_9, mmi_falldwon_audio_ctrl_callback))
+    {
+        Hal_NFFS_File_Play_Repeat(AUDIO_FALLDOWN, HAL_AUDIO_SPK_LEVEL_MAX); // query_current_volume()
+    }
+       Hal_Vibrator_Play_Repeat();
+       
+       mmi_falldwon_timer_start();
+
+       watch_set_suspend_enable(false, ACT_ID_WATCH_FALLDWON, 0);
+       
+       return obj;
+}
+
+
+lv_obj_t * mmi_watch_server_search_screen_create(lv_obj_t * activity_obj)
+{
+       SUNDRY_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+       
+       lv_watch_png_cache_all_free();
+    if(NULL == activity_obj) 
+       {
+        lv_watch_activity_ext_t activity_ext = {0};
+
+        activity_ext.actId = ACT_ID_WATCH_SEARCHING;
+        activity_ext.create = (lv_watch_activity_create_f_t)mmi_watch_server_search_screen_create;
+        activity_ext.prepare_destory = mmi_watch_search_screen_destroy;
+        activity_obj = lv_watch_creat_activity_obj(&activity_ext);
+        if(NULL == activity_obj)
+            return NULL;
+    }
+
+    lv_obj_t * obj = lv_watch_obj_create(activity_obj);
+    LV_ASSERT_MEM(obj);
+       
+       lv_watch_search_ext_t * searching_ext = lv_obj_allocate_ext_attr(obj, sizeof(lv_watch_search_ext_t));
+
+       lv_obj_t * cont = lv_cont_create(obj, NULL);
+       lv_obj_set_size(cont, lv_obj_get_width(obj), lv_obj_get_height(obj));
+       lv_obj_align(cont, obj, LV_ALIGN_CENTER, 0, 0);
+       lv_obj_set_style_local_bg_color(cont, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, lv_color_make(0, 0, 0)); // LV_COLOR_BLACK
+       lv_obj_set_click(cont, true);
+       lv_obj_set_event_cb(cont, mmi_watch_search_screen_event_cb);    
+       //lv_obj_add_protect(cont, LV_PROTECT_PRESS_LOST);
+
+       lv_obj_t * label = lv_label_create(cont, NULL);
+#ifdef USE_LV_WATCH_UI_466_466
+       lv_obj_add_style(label, LV_LABEL_PART_MAIN, &lv_watch_font40);
+#else
+       lv_obj_add_style(label, LV_LABEL_PART_MAIN, &lv_watch_font20);
+#endif
+       lv_label_set_text_id(label, WATCH_TEXT_ID_SERVER_SEARCH_PROMPT); //lv_lang_get_text(WATCH_TEXT_ID_SERVER_SEARCH_PROMPT)
+       lv_obj_align(label, cont, LV_ALIGN_CENTER, 0, 0);
+
+       //prompt
+    if (AUDIO_CTRL_PRIORITY_SEARCH == Hal_Audio_Manage_Start_Req(AUDIO_CTRL_PRIORITY_SEARCH, mmi_watch_search_audio_ctrl_callback))
+    {
+               uint8_t volume = 0;
+       #ifdef __MMI_USER_PROFILE_SUPPORT__
+               volume = mmi_user_profile_current_mode_remind_volume_get();
+       #else
+               volume = query_current_volume();
+       #endif
+        Hal_NFFS_File_Play_Repeat(AUDIO_WATCH_SEARCH, volume); // HAL_AUDIO_SPK_LEVEL_MAX);
+    }
+       if(true == mmi_watch_vibrate_is_permitted())
+       {
+               Hal_Vibrator_Play_Repeat();
+       }
+       
+       mmi_watch_search_timer_start();
+
+       watch_set_suspend_enable(false, ACT_ID_WATCH_SEARCHING, 0);
+       
+       return obj;
+}
+
+void mmi_ui_msg_update_watch_server_search(void)
+{
+       mmi_watch_server_search_screen_create(NULL);    
+}
+
+
+void mmi_ui_msg_update_falldwon(void)
+{
+       if(lv_watch_get_activity_obj(ACT_ID_WATCH_FALLDWON)==NULL)
+       {       
+               
+               mmi_watch_falldwon_create(NULL);
+       }
+       
+}
+
+void mmi_watch_searching_aciton(void)
+{
+       SUNDRY_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+       
+    if(true == mmi_active_screen_is_prohibit_interrupted()
+               #ifdef __MMI_ZHSX_SUPPORT_DO_NOT_DISTURB__
+               || true == mmi_watch_is_in_do_not_disturb_time()
+               #endif
+               )
+       {
+               return ;
+       }
+
+#ifdef __MMI_WECHAT_SUPPORT__
+       if(true == wechat_screen_is_prohibit_interrupted())
+       {
+               return;
+       }
+#endif
+
+       if(NULL != lv_watch_get_activity_obj(ACT_ID_WATCH_SEARCHING))
+       {
+               return ;
+       }
+
+       // ui
+    mmi_watch_wake_up();
+       mmi_ui_msg_action_watch_searching();
+}
+
+
+static nv_watch_center_number_t s_center_number = {0};
+
+void mmi_center_number_nv_write(void)
+{
+       uint32_t nv_data_length = sizeof(nv_watch_center_number_t);
+       
+       if(nv_data_length != UI_NV_Write_Req(NV_SECTION_UI_CENTER_NUMBER, 0, nv_data_length, (uint8_t *)&s_center_number))
+       {
+               printf("[@CHENG_DEBUG][%s][%d]: nv write fail\n", __FUNCTION__, __LINE__);
+       }
+}
+
+void mmi_center_number_nv_read(void)
+{
+       uint32_t nv_data_length = sizeof(nv_watch_center_number_t);
+       
+       if(nv_data_length != UI_NV_Read_Req(NV_SECTION_UI_CENTER_NUMBER, 0, nv_data_length, (uint8_t *)&s_center_number))
+       {
+               printf("[@CHENG_DEBUG][%s][%d]: nv read fail\n", __FUNCTION__, __LINE__);
+       }
+}
+
+bool mmi_center_number_is_empty(void)
+{
+       if(0 != strlen(s_center_number.number))
+               return false;
+
+       return true;
+}
+
+void mmi_center_number_set(nv_watch_center_number_t * center_number)
+{
+       _lv_memcpy(&s_center_number, center_number, sizeof(nv_watch_center_number_t));
+
+       mmi_center_number_nv_write();
+}
+
+void mmi_ui_msg_update_ceter_number_dialing(void)
+{
+       char * number = (char *)lv_mem_alloc(NV_CONTACTS_MAX_NUMBER_LEN);
+       if(NULL != number)
+       {
+               _lv_memcpy(number, s_center_number.number, NV_CONTACTS_MAX_NUMBER_LEN);
+               phone_voice_call_req(number);
+       }
+}
+
+void mmi_center_number_dialing_action(void)
+{
+       SUNDRY_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+       
+       if(true == mmi_active_screen_is_prohibit_interrupted()
+               #ifdef __MMI_ZHSX_SUPPORT_DO_NOT_DISTURB__
+               || true == mmi_watch_is_in_do_not_disturb_time()
+               #endif
+               )
+       {
+               return ;
+       }
+
+       if(true == mmi_center_number_is_empty())
+       {
+               return ;
+       }
+
+       // ui
+       mmi_watch_wake_up();
+       mmi_ui_msg_action_center_number_dialing();
+}
+
+
+#ifdef __MMI_ZHSX_SUPPORT_NO_SIM_POWER_OFF__
+
+static void * s_no_sim_power_off_timer = NULL;
+static uint8_t s_no_sim_power_off_seconds = NO_SIM_POWER_OFF_PROMPT_INTERVAL;
+
+void mmi_watch_no_sim_power_off_timer_stop(void)
+{
+       if(NULL != s_no_sim_power_off_timer)
+       {
+               uos_timer_stop(s_no_sim_power_off_timer);
+               uos_timer_delete(s_no_sim_power_off_timer);
+               s_no_sim_power_off_timer = NULL;
+       }
+}
+
+static void mmi_watch_no_sim_power_off_prompt_prepare_destory(lv_obj_t * activity_obj)
+{
+    lv_watch_png_cache_all_free();
+
+       mmi_watch_no_sim_power_off_check_action();
+
+       watch_set_suspend_enable(true, ACT_ID_NO_SIM_POWER_OFF_PROMPT, 0);
+}
+
+static void mmi_watch_no_sim_power_off_ok_btn_event_cb(lv_obj_t * btn, lv_event_t e)
+{
+    if(LV_EVENT_CLICKED == e)
+    {
+               mmi_watch_power_off_aciton();
+    }
+}
+
+static void mmi_watch_no_sim_power_off_cancel_btn_event_cb(lv_obj_t * btn, lv_event_t e)
+{
+    if(LV_EVENT_CLICKED == e)
+    {
+               mmi_watch_no_sim_power_off_prompt_prepare_destory(NULL);
+               lv_obj_t * activity_obj = lv_watch_get_activity_obj(ACT_ID_NO_SIM_POWER_OFF_PROMPT);
+               if(activity_obj)
+               {
+                       lv_obj_del(activity_obj);
+               }
+    }
+}
+
+static void mmi_watch_no_sim_power_off_prompt_status_update(lv_anim_t * anim)
+{
+       char t_text[64] = {0};
+       
+       s_no_sim_power_off_seconds--;
+       if(0 == s_no_sim_power_off_seconds)
+       {
+               mmi_watch_power_off_aciton();
+       }
+       else
+       {
+               sprintf(t_text, "%d%s", s_no_sim_power_off_seconds, lv_lang_get_text(WATCH_TEXT_ID_NO_SIM_POWER_OFF_PROMPT));
+               lv_label_set_text(anim->var, t_text);
+       }
+}
+
+static lv_obj_t * mmi_watch_no_sim_power_off_prompt_create(lv_obj_t * activity_obj)
+{
+    if(activity_obj == NULL) 
+       {
+        lv_watch_activity_ext_t activity_ext;
+        memset(&activity_ext, 0, sizeof(lv_watch_activity_ext_t));
+        activity_ext.actId = ACT_ID_NO_SIM_POWER_OFF_PROMPT;
+        activity_ext.create = NULL;
+        activity_ext.prepare_destory = mmi_watch_no_sim_power_off_prompt_prepare_destory;
+        activity_obj = lv_watch_creat_activity_obj(&activity_ext);
+        LV_ASSERT_MEM(activity_obj);
+        if(activity_obj == NULL) 
+                       return NULL;
+    }
+
+    lv_obj_t * obj = lv_watch_obj_create(activity_obj);
+    LV_ASSERT_MEM(obj);
+    if(obj == NULL) return NULL;
+    lv_watch_obj_set_anim_mode(obj, LV_WATCH_ANIM_HOR_RIGHT_HIDE);
+
+       lv_obj_t * cont = lv_cont_create(obj, NULL);
+       lv_obj_set_size(cont, LV_HOR_RES, LV_VER_RES);
+       lv_obj_set_style_local_bg_color(cont, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
+       lv_obj_set_base_dir(cont, LV_BIDI_DIR_LTR);
+
+       char t_text[64] = {0};
+       lv_obj_t * label = lv_label_create(cont, NULL);
+       s_no_sim_power_off_seconds = NO_SIM_POWER_OFF_PROMPT_INTERVAL;
+       sprintf(t_text, "%d%s", s_no_sim_power_off_seconds, lv_lang_get_text(WATCH_TEXT_ID_NO_SIM_POWER_OFF_PROMPT));
+       lv_label_set_text(label, t_text);
+       lv_label_set_align(label, LV_LABEL_ALIGN_CENTER);
+#ifdef USE_LV_WATCH_UI_466_466
+       lv_obj_add_style(label, LV_LABEL_PART_MAIN, &lv_watch_font40);
+       lv_obj_align(label, NULL, LV_ALIGN_IN_TOP_MID, 0, LV_VER_RES / 3);
+#else
+       lv_obj_add_style(label, LV_LABEL_PART_MAIN, &lv_watch_font26); // &lv_watch_font26_black);
+       lv_obj_align(label, NULL, LV_ALIGN_IN_TOP_MID, 0, 70);
+#endif
+
+       lv_obj_t * btn_cancel = lv_btn_create(cont, NULL);
+#ifdef USE_LV_WATCH_UI_466_466
+       lv_obj_set_size(btn_cancel, 140, 70);
+#else
+       lv_obj_set_size(btn_cancel, 100, 56);
+#endif
+       lv_obj_set_style_local_bg_color(btn_cancel, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_MAKE(0x47, 0xA6, 0xFF));
+       lv_obj_set_style_local_radius(btn_cancel, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 30);
+       lv_obj_set_style_local_bg_color(btn_cancel, LV_BTN_PART_MAIN, LV_STATE_PRESSED, LV_COLOR_MAKE(0x47, 0xA6, 0xFF));
+       lv_obj_set_style_local_radius(btn_cancel, LV_BTN_PART_MAIN, LV_STATE_PRESSED, 30);
+#ifdef USE_LV_WATCH_UI_466_466
+       lv_obj_align(btn_cancel, NULL, LV_ALIGN_IN_BOTTOM_LEFT, 70, -60);
+#else
+       lv_obj_align(btn_cancel, NULL, LV_ALIGN_IN_BOTTOM_LEFT, 10, -20);
+#endif
+       lv_obj_set_event_cb(btn_cancel, mmi_watch_no_sim_power_off_cancel_btn_event_cb);
+       lv_obj_t * label_cancel = lv_label_create(btn_cancel, NULL);
+       lv_label_set_text_id(label_cancel, WATCH_TEXT_ID_CANCEL);
+#ifdef USE_LV_WATCH_UI_466_466
+       lv_obj_add_style(label_cancel, LV_LABEL_PART_MAIN, &lv_watch_font40_black);
+#else
+       lv_obj_add_style(label_cancel, LV_LABEL_PART_MAIN, &lv_watch_font26_black);
+#endif
+
+       lv_obj_t * btn_ok = lv_btn_create(cont, btn_cancel);
+       lv_obj_set_style_local_bg_color(btn_ok, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_MAKE(0xFF, 0x6F, 0x91));
+       lv_obj_set_style_local_radius(btn_ok, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 30);
+       lv_obj_set_style_local_bg_color(btn_ok, LV_BTN_PART_MAIN, LV_STATE_PRESSED, LV_COLOR_MAKE(0xFF, 0x6F, 0x91));
+       lv_obj_set_style_local_radius(btn_ok, LV_BTN_PART_MAIN, LV_STATE_PRESSED, 30);
+#ifdef USE_LV_WATCH_UI_466_466
+       lv_obj_align(btn_ok, NULL, LV_ALIGN_IN_BOTTOM_RIGHT, -70, -60);
+#else
+       lv_obj_align(btn_ok, NULL, LV_ALIGN_IN_BOTTOM_RIGHT, -10, -20);
+#endif
+       lv_obj_set_event_cb(btn_ok, mmi_watch_no_sim_power_off_ok_btn_event_cb);
+       lv_obj_t * label_ok = lv_label_create(btn_ok, label_cancel);
+       lv_label_set_text_id(label_ok, WATCH_TEXT_ID_OK);
+
+       //
+       lv_anim_path_t path;
+       lv_anim_path_init(&path);
+       lv_anim_path_set_cb(&path, lv_anim_path_step);
+
+       lv_anim_t a;
+       lv_anim_init(&a);
+       lv_anim_set_var(&a, label);
+       lv_anim_set_start_cb(&a, (lv_anim_ready_cb_t)mmi_watch_no_sim_power_off_prompt_status_update);
+       lv_anim_set_time(&a, 1);
+       lv_anim_set_repeat_count(&a, LV_ANIM_REPEAT_INFINITE);
+       lv_anim_set_delay(&a,1000);
+       lv_anim_set_repeat_delay(&a, 1000);
+       lv_anim_start(&a);
+
+       watch_set_suspend_enable(false, ACT_ID_NO_SIM_POWER_OFF_PROMPT, 0);
+}
+
+void mmi_ui_msg_update_no_sim_power_off(void)
+{
+       mmi_watch_no_sim_power_off_prompt_create(NULL);
+}
+
+static void mmi_watch_no_sim_power_off_callback(uint32_t para)
+{
+       mmi_watch_no_sim_power_off_timer_stop();
+       
+       if((false == watch_modem_sim_present_check_req())
+               && (NULL == lv_watch_get_activity_obj(ACT_ID_FACTORY_MODE_MAIN))
+               )
+       {
+               // power off prompt
+               SUNDRY_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               
+               mmi_watch_wake_up();
+               mmi_ui_msg_action_no_sim_power_off();
+       }
+       else
+       {
+               // skip this time
+               SUNDRY_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               
+               mmi_watch_no_sim_power_off_check_action();
+       }
+}
+
+void mmi_watch_no_sim_power_off_check_action(void)
+{
+       SUNDRY_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+       
+       mmi_watch_no_sim_power_off_timer_stop();
+       uos_timer_create(&s_no_sim_power_off_timer);
+       uos_timer_start(s_no_sim_power_off_timer, MS_TO_TICKS(NO_SIM_POWER_OFF_INTERVAL), 0, mmi_watch_no_sim_power_off_callback, NULL);
+}
+
+void mmi_watch_no_sim_power_off_check_mission(void)
+{
+
+       if(NULL != s_no_sim_power_off_timer) // is exist ?
+               return;
+
+       if(true == watch_modem_sim_present_check_req())
+               return;
+
+       if((NULL != lv_watch_get_activity_obj(ACT_ID_FACTORY_MODE_MAIN))
+               || (NULL != phone_get_activity_obj())
+               )
+               return;
+
+       SUNDRY_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+       mmi_watch_no_sim_power_off_check_action();
+}
+#endif
+
+
+// charging
+static void * s_watch_charge_prompt_timer = NULL;
+
+static void mmi_watch_charging_prompt_timer_stop(void)
+{
+       if(NULL != s_watch_charge_prompt_timer)
+       {
+               Hal_Timer_Stop(s_watch_charge_prompt_timer);
+               s_watch_charge_prompt_timer = NULL;
+       }
+}
+
+static void mmi_watch_charging_prompt_screen_prepare_destory(lv_obj_t * activity_obj)
+{
+       mmi_watch_charging_prompt_timer_stop();
+       
+    lv_watch_png_cache_all_free();
+}
+
+static void mmi_watch_charging_prompt_cb(void *para)
+{
+       SUNDRY_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+       
+       mmi_watch_charging_prompt_screen_prepare_destory(NULL);
+       lv_obj_t * activity_obj = lv_watch_get_activity_obj(ACT_ID_CHARGING_PROMPT);
+       if(activity_obj)
+       {
+               lv_obj_del(activity_obj);
+       }
+
+#ifdef __MMI_DIAL_WITH_CHARGE_STATE_SUPPORT__
+    dial_clean_canvas(false);
+       dial_clock_update_immediately();
+#endif
+}
+
+static lv_obj_t * mmi_watch_charging_prompt_screen_create(lv_obj_t * activity_obj, uint32_t chg_status)
+{
+       if(activity_obj == NULL) 
+       {
+               lv_watch_activity_ext_t activity_ext;
+               memset(&activity_ext, 0, sizeof(lv_watch_activity_ext_t));
+               activity_ext.actId = ACT_ID_CHARGING_PROMPT;
+               activity_ext.create = NULL;
+               activity_ext.prepare_destory = mmi_watch_charging_prompt_screen_prepare_destory;
+               activity_obj = lv_watch_creat_activity_obj(&activity_ext);
+               LV_ASSERT_MEM(activity_obj);
+               if(activity_obj == NULL) 
+               {
+                       return(NULL);
+               }
+       }
+
+       lv_obj_t * obj = lv_watch_obj_create(activity_obj);
+       LV_ASSERT_MEM(obj);
+       if(obj == NULL) 
+               return NULL;
+       
+    //lv_watch_obj_set_anim_mode(obj, LV_WATCH_ANIM_HOR_RIGHT_HIDE);
+
+#if 0
+       lv_obj_t * mbox = lv_msgbox_create(obj, NULL);
+       lv_msgbox_set_text(mbox, (char *)lv_lang_get_text((HAL_CHG_CONNECTED == (HAL_CHG_STATUS)chg_status) ? WATCH_TEXT_ID_CHARGE_CONNECTED : WATCH_TEXT_ID_CHARGE_REMOVED));
+       lv_obj_align(mbox, obj, LV_ALIGN_CENTER, 0, 0);
+       lv_msgbox_set_anim_time(mbox, 0);
+       lv_msgbox_start_auto_close(mbox, 2000);
+#else
+       lv_obj_t * cont = lv_cont_create(obj, NULL);
+       //lv_obj_set_size(cont, 180, 180);
+       lv_obj_set_size(cont, LV_HOR_RES, LV_VER_RES);
+       lv_obj_set_style_local_bg_color(cont, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
+       //lv_obj_set_style_local_radius(cont, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, 30);
+       lv_obj_align(cont, NULL, LV_ALIGN_CENTER, 0, 0);
+       lv_obj_set_click(cont, false);
+       //lv_watch_obj_add_element(cont);
+
+       lv_obj_t * img = lv_img_create(cont, NULL);
+       lv_img_set_src(img, ((HAL_CHG_CONNECTED == (HAL_CHG_STATUS)chg_status) ? ICON_CHARGE_CONNECTED : ICON_CHARGE_REMOVED));
+       lv_obj_align(img, NULL, LV_ALIGN_CENTER, 0, -LV_VER_RES/10);
+       lv_obj_set_click(img, false);
+       
+       lv_obj_t * label = lv_label_create(cont, NULL);
+       lv_label_set_text_id(label, ((HAL_CHG_CONNECTED == (HAL_CHG_STATUS)chg_status) ? WATCH_TEXT_ID_CHARGE_CONNECTED : WATCH_TEXT_ID_CHARGE_REMOVED));
+#ifdef USE_LV_WATCH_UI_466_466
+       lv_obj_add_style(label, LV_LABEL_PART_MAIN, &lv_watch_font40);
+       lv_label_set_align(label, LV_LABEL_ALIGN_CENTER);
+       lv_obj_align(label, img, LV_ALIGN_OUT_BOTTOM_MID, 0, 30);
+#else
+       lv_obj_add_style(label, LV_LABEL_PART_MAIN, &lv_watch_font26);
+       lv_label_set_align(label, LV_LABEL_ALIGN_CENTER);
+       lv_obj_align(label, img, LV_ALIGN_OUT_BOTTOM_MID, 0, 20);
+#endif
+
+       mmi_watch_charging_prompt_timer_stop();
+       s_watch_charge_prompt_timer = Hal_Timer_Start(1500, mmi_watch_charging_prompt_cb, NULL, false);
+#endif
+
+       return obj;
+}
+
+void mmi_ui_msg_update_charging_prompt(uint32_t chg_status)
+{
+       SUNDRY_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: %d\n", __FUNCTION__, __LINE__, chg_status);
+       
+    if(true == mmi_active_screen_is_prohibit_interrupted()
+               #ifdef __MMI_ZHSX_SUPPORT_DO_NOT_DISTURB__
+               || true == mmi_watch_is_in_do_not_disturb_time()
+               #endif
+               )
+       {
+               return ;
+       }
+       
+       if(HAL_CHG_CONNECTED == (HAL_CHG_STATUS)chg_status || HAL_CHG_DISCONNECTED == (HAL_CHG_STATUS)chg_status)
+       {
+               mmi_watch_charging_prompt_screen_prepare_destory(NULL);
+               lv_obj_t * activity_obj = lv_watch_get_activity_obj(ACT_ID_CHARGING_PROMPT);
+               if(activity_obj)
+               {
+                       lv_obj_del(activity_obj);
+               }
+               mmi_watch_charging_prompt_screen_create(NULL, chg_status);
+       }
+}
+
+
+#ifdef __MMI_ZHSX_SUPPORT_DO_NOT_DISTURB__
+
+//#define DEBUG_DO_NOT_DISTURB
+
+static nv_watch_do_not_disturb_t s_do_not_disturb_data = {0};
+static lv_task_t * s_do_not_disturb_check_task = NULL;
+static int8_t s_do_not_disturb_last_min = -1;
+
+void mmi_watch_do_not_disturb_nv_write(void)
+{
+       uint32_t nv_data_length = sizeof(nv_watch_do_not_disturb_t);
+       
+       if(nv_data_length != UI_NV_Write_Req(NV_SECTION_UI_DO_NOT_DISTURB, 0, nv_data_length, (uint8_t *)&s_do_not_disturb_data))
+       {
+               SUNDRY_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: nv write fail\n", __FUNCTION__, __LINE__);
+       }
+}
+
+void mmi_watch_do_not_disturb_nv_read(void)
+{
+       uint32_t nv_data_length = sizeof(nv_watch_do_not_disturb_t);
+       
+       if(nv_data_length != UI_NV_Read_Req(NV_SECTION_UI_DO_NOT_DISTURB, 0, nv_data_length, (uint8_t *)&s_do_not_disturb_data))
+       {
+               SUNDRY_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: nv read fail\n", __FUNCTION__, __LINE__);
+               _lv_memset_00(&s_do_not_disturb_data, sizeof(nv_watch_do_not_disturb_t));
+       }
+
+#ifdef DEBUG_DO_NOT_DISTURB
+       s_do_not_disturb_data.item_info[0].on_off = 1;
+       s_do_not_disturb_data.item_info[0].begin_hour = 1;
+       s_do_not_disturb_data.item_info[0].begin_min = 0;
+       s_do_not_disturb_data.item_info[0].end_hour = 8;
+       s_do_not_disturb_data.item_info[0].end_min = 0;
+       s_do_not_disturb_data.item_info[0].week_bitmap = 0xff;
+
+       s_do_not_disturb_data.item_info[1].on_off = 1;
+       s_do_not_disturb_data.item_info[1].begin_hour = 8;
+       s_do_not_disturb_data.item_info[1].begin_min = 33;
+       s_do_not_disturb_data.item_info[1].end_hour = 10;
+       s_do_not_disturb_data.item_info[1].end_min = 55;
+       s_do_not_disturb_data.item_info[1].week_bitmap = 0xff;
+
+       s_do_not_disturb_data.item_info[2].on_off = 1;
+       s_do_not_disturb_data.item_info[2].begin_hour = 11;
+       s_do_not_disturb_data.item_info[2].begin_min = 0;
+       s_do_not_disturb_data.item_info[2].end_hour = 23;
+       s_do_not_disturb_data.item_info[2].end_min = 23;
+       s_do_not_disturb_data.item_info[2].week_bitmap = 0xff;
+#endif
+}
+
+void mmi_watch_do_not_disturb_data_set(nv_watch_do_not_disturb_t * data)
+{
+       if(NULL != data)
+       {
+               _lv_memset_00(&s_do_not_disturb_data, sizeof(nv_watch_do_not_disturb_t));
+               _lv_memcpy(&s_do_not_disturb_data, data, sizeof(nv_watch_do_not_disturb_t));
+               mmi_watch_do_not_disturb_nv_write();
+       }
+}
+
+bool mmi_watch_is_in_do_not_disturb_time(void)
+{
+       hal_rtc_t cur_time = {0};
+       uint16_t t_cur_mins = 0;
+       uint8_t i = 0;
+
+#ifndef DEBUG_DO_NOT_DISTURB
+       if(false == watch_modem_sim_present_check_req())
+       {
+               return false;
+       }
+#endif
+
+       Hal_Rtc_Gettime(&cur_time);
+       t_cur_mins = cur_time.tm_hour * 60 + cur_time.tm_min;
+       
+       for(i = 0; i < NV_WATCH_DO_NOT_DISTURB_ITEM_MAX; i++)
+       {
+               if(s_do_not_disturb_data.item_info[i].on_off)
+               {
+                       if((0x01 << (cur_time.tm_wday)) & s_do_not_disturb_data.item_info[i].week_bitmap)
+                       {
+                               uint16_t t_begin_mins = s_do_not_disturb_data.item_info[i].begin_hour * 60 + s_do_not_disturb_data.item_info[i].begin_min;
+                               uint16_t t_end_mins = s_do_not_disturb_data.item_info[i].end_hour * 60 + s_do_not_disturb_data.item_info[i].end_min;
+
+                               if(t_cur_mins >= t_begin_mins && t_cur_mins <= t_end_mins)
+                               {
+                                       SUNDRY_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+                                       return true;
+                               }
+                       }
+               }
+       }
+
+       return false;
+}
+
+static void * mmi_watch_do_not_disturb_ext_get(void)
+{
+    lv_obj_t * activity_obj = lv_watch_get_activity_obj(ACT_ID_DO_NOT_DISTURB);
+       if(NULL == activity_obj) 
+               return NULL;
+
+       lv_obj_t * watch_obj = NULL;
+       lv_watch_get_child_obj(activity_obj, lv_watch_obj_signal, &watch_obj);
+       if(NULL != watch_obj) 
+       {
+               void * ext = lv_obj_get_ext_attr(watch_obj);
+               return ext;
+       }
+
+       return NULL;
+}
+
+static void mmi_watch_do_not_disturb_screen_display(lv_obj_t * cont)
+{      
+       hal_rtc_t cur_time = {0};
+       char t_time_str[16] = {0};
+
+       lv_obj_t * label_time = lv_label_create(cont, NULL);
+       Hal_Rtc_Gettime(&cur_time);
+       sprintf(t_time_str, "%02d:%02d", cur_time.tm_hour, cur_time.tm_min);
+       lv_label_set_text(label_time, t_time_str);
+       lv_obj_add_style(label_time, LV_LABEL_PART_MAIN, &lv_watch_font40);
+       lv_label_set_align(label_time, LV_LABEL_ALIGN_CENTER);
+       #ifdef USE_LV_WATCH_UI_CIRCLE
+       lv_obj_align(label_time, NULL, LV_ALIGN_IN_TOP_MID, 0, 30);
+       #else
+       lv_obj_align(label_time, NULL, LV_ALIGN_IN_TOP_MID, 0, 50);
+       #endif
+
+       lv_obj_t * label_prompt = lv_label_create(cont, NULL);
+       lv_label_set_text_id(label_prompt, WATCH_TEXT_ID_FORBIDDEN_PERIOD);
+       lv_obj_add_style(label_prompt, LV_LABEL_PART_MAIN, &lv_watch_font26);
+       lv_label_set_align(label_prompt, LV_LABEL_ALIGN_CENTER);
+       #ifdef USE_LV_WATCH_UI_CIRCLE
+       lv_obj_align(label_prompt, label_time, LV_ALIGN_OUT_BOTTOM_MID, 0, 5);
+       #else
+       lv_obj_align(label_prompt, label_time, LV_ALIGN_OUT_BOTTOM_MID, 0, 10);
+       #endif
+
+       uint8_t i = 0;
+       uint8_t j = 0;
+       uint8_t t_height = lv_obj_get_height(label_prompt);
+       
+       for(i = 0; i < NV_WATCH_DO_NOT_DISTURB_ITEM_MAX; i++)
+       {
+               if(s_do_not_disturb_data.item_info[i].on_off)
+               {
+                       lv_obj_t * label = lv_label_create(cont, NULL);
+                       memset(t_time_str, 0x0, sizeof(t_time_str));
+                       sprintf(t_time_str, "%02d:%02d--%02d:%02d", 
+                                               s_do_not_disturb_data.item_info[i].begin_hour,
+                                               s_do_not_disturb_data.item_info[i].begin_min,
+                                               s_do_not_disturb_data.item_info[i].end_hour,
+                                               s_do_not_disturb_data.item_info[i].end_min);
+                       lv_label_set_text(label, t_time_str);
+                       lv_obj_add_style(label, LV_LABEL_PART_MAIN, &lv_watch_font26);
+                       lv_label_set_align(label, LV_LABEL_ALIGN_CENTER);
+                       #ifdef USE_LV_WATCH_UI_CIRCLE
+                       lv_obj_align(label, label_prompt, LV_ALIGN_OUT_BOTTOM_MID, 0, 3 + (t_height + 3) * j);
+                       #else
+                       lv_obj_align(label, label_prompt, LV_ALIGN_OUT_BOTTOM_MID, 0, 5 + (t_height + 5) * j);
+                       #endif
+                       j++;
+               }
+       }
+}
+
+static void mmi_watch_do_not_disturb_screen_refresh(void)
+{
+       lv_do_not_disturb_ext_t * ext = (lv_do_not_disturb_ext_t * )mmi_watch_do_not_disturb_ext_get();
+       if(NULL == ext)
+               return;
+       
+       lv_obj_clean(ext->cont);
+       mmi_watch_do_not_disturb_screen_display(ext->cont);
+}
+
+static void mmi_watch_do_not_disturb_screen_prepare_destory(lv_obj_t * activity_obj)
+{
+       SUNDRY_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+       
+    lv_watch_png_cache_all_free();
+}
+
+static lv_obj_t * mmi_watch_do_not_disturb_screen_create(lv_obj_t * activity_obj)
+{
+       SUNDRY_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+       
+       if(NULL == activity_obj) 
+       {
+               lv_watch_activity_ext_t activity_ext;
+               memset(&activity_ext, 0, sizeof(lv_watch_activity_ext_t));
+               activity_ext.actId = ACT_ID_DO_NOT_DISTURB;
+               activity_ext.create = NULL;
+               activity_ext.prepare_destory = mmi_watch_do_not_disturb_screen_prepare_destory;
+               activity_obj = lv_watch_creat_activity_obj(&activity_ext);
+               LV_ASSERT_MEM(activity_obj);
+               if(activity_obj == NULL) 
+               {
+                       return(NULL);
+               }
+       }
+
+       lv_obj_t * obj = lv_watch_obj_create(activity_obj);
+       LV_ASSERT_MEM(obj);
+       if(obj == NULL) 
+               return NULL;
+       
+    lv_watch_obj_set_anim_mode(obj, LV_WATCH_ANIM_NO);
+
+       lv_do_not_disturb_ext_t * ext = (lv_do_not_disturb_ext_t * )lv_obj_allocate_ext_attr(obj, sizeof(lv_do_not_disturb_ext_t));
+       
+       lv_obj_t * cont = lv_cont_create(obj, NULL);
+       lv_obj_set_size(cont, LV_HOR_RES, LV_VER_RES);
+       lv_obj_set_style_local_bg_color(cont, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
+       //lv_obj_set_style_local_radius(cont, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, 30);
+       lv_obj_align(cont, NULL, LV_ALIGN_CENTER, 0, 0);
+       lv_obj_set_click(cont, false);
+       //lv_watch_obj_add_element(cont);
+       ext->cont = cont;
+
+       mmi_watch_do_not_disturb_screen_display(cont);
+
+       return obj;
+}
+
+void mmi_ui_msg_update_do_not_disturb(uint8_t flag)
+{
+       switch(flag)
+       {
+               case 0:
+                       mmi_watch_do_not_disturb_screen_prepare_destory(NULL);
+                       lv_obj_t * activity_obj = lv_watch_get_activity_obj(ACT_ID_DO_NOT_DISTURB);
+                   if(activity_obj)
+                       {
+                       lv_obj_del(activity_obj);
+                   }
+                       break;
+
+               case 1:
+                       mmi_watch_do_not_disturb_screen_create(NULL);
+                       break;
+
+               case 2:
+                       mmi_watch_do_not_disturb_screen_refresh();
+                       break;
+
+               default:
+                       SUNDRY_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: should not run to here\n", __FUNCTION__, __LINE__);
+                       break;
+       }
+}
+
+void mmi_watch_do_not_disturb_check_task_cb(lv_task_t * task)
+{
+    hal_rtc_t cur_time = {0};
+       
+    Hal_Rtc_Gettime(&cur_time);
+       SUNDRY_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: %d,%d,%d\n", __FUNCTION__, __LINE__, cur_time.tm_hour, cur_time.tm_min, cur_time.tm_sec);
+       if(cur_time.tm_min == s_do_not_disturb_last_min)
+       {
+        return;
+       }
+       
+       s_do_not_disturb_last_min = cur_time.tm_min;
+
+       lv_obj_t * activity_obj = lv_watch_get_activity_obj(ACT_ID_DO_NOT_DISTURB);
+       if(true == mmi_watch_is_in_do_not_disturb_time())
+       {
+               SUNDRY_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: 0x%x\n", __FUNCTION__, __LINE__, activity_obj);
+               if(NULL == activity_obj)
+               {
+                       // create
+                       mmi_ui_msg_action_do_not_disturb(1);
+               }
+               else
+               {
+                       // update
+                       mmi_ui_msg_action_do_not_disturb(2);
+               }
+       }
+       else
+       {
+               SUNDRY_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: 0x%x\n", __FUNCTION__, __LINE__, activity_obj);
+               if(NULL != activity_obj)
+               {
+                       // destroy
+                       mmi_ui_msg_action_do_not_disturb(0);
+               }
+       }
+}
+
+void mmi_watch_do_not_disturb_mission_check(void)
+{
+       s_do_not_disturb_check_task = lv_task_create(mmi_watch_do_not_disturb_check_task_cb, 1000 * 5, LV_TASK_PRIO_MID, NULL);
+}
+
+void mmi_watch_do_not_disturb_task_clean(void)
+{
+       if(NULL != s_do_not_disturb_check_task)
+       {
+               lv_task_del(s_do_not_disturb_check_task);
+               s_do_not_disturb_check_task = NULL;
+       }
+}
+#endif
+
+
+#ifdef __MMI_SLEEP_FUNCTION_SUPPORT__
+static nv_watch_sleep_time_t s_sleep_time_data = {0};
+static uint8_t s_sleep_mission_in_progress = 0;
+
+void mmi_watch_sleep_time_nv_write(void)
+{
+       uint32_t nv_data_length = sizeof(nv_watch_sleep_time_t);
+       
+       if(nv_data_length != UI_NV_Write_Req(NV_SECTION_UI_SLEEP_TIME_DATA, 0, nv_data_length, (uint8_t *)&s_sleep_time_data))
+       {
+               SUNDRY_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: nv write fail\n", __FUNCTION__, __LINE__);
+       }
+}
+
+void mmi_watch_sleep_time_nv_read(void)
+{
+       uint32_t nv_data_length = sizeof(nv_watch_sleep_time_t);
+       
+       if(nv_data_length != UI_NV_Read_Req(NV_SECTION_UI_SLEEP_TIME_DATA, 0, nv_data_length, (uint8_t *)&s_sleep_time_data))
+       {
+               SUNDRY_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: nv read fail\n", __FUNCTION__, __LINE__);
+               _lv_memset_00(&s_sleep_time_data, sizeof(nv_watch_sleep_time_t));
+       }
+}
+
+void mmi_watch_sleep_time_data_set(nv_watch_sleep_time_t * data)
+{
+       if(NULL != data)
+       {
+               _lv_memcpy(&s_sleep_time_data, data, sizeof(nv_watch_sleep_time_t));
+               mmi_watch_sleep_time_nv_write();
+       }
+}
+
+bool mmi_watch_time_is_in_sleep_time(void)
+{
+       hal_rtc_t cur_time = {0};
+       uint16_t t_cur_mins = 0;
+
+       if(false == watch_modem_sim_present_check_req())
+       {
+               return false;
+       }
+
+       Hal_Rtc_Gettime(&cur_time);
+       t_cur_mins = cur_time.tm_hour * 60 + cur_time.tm_min;
+       
+       if(1 == s_sleep_time_data.on_off)
+       {
+               // begin_time -- 00:00 -- end_time
+               uint16_t t_begin_mins = s_sleep_time_data.begin_hour * 60 + s_sleep_time_data.begin_min;
+               uint16_t t_end_mins = s_sleep_time_data.end_hour * 60 + s_sleep_time_data.end_min;
+
+               if((t_begin_mins > t_end_mins) && (t_cur_mins >= t_begin_mins || t_cur_mins <= t_end_mins)
+                       || (t_begin_mins < t_end_mins) && (t_cur_mins >= t_begin_mins && t_cur_mins <= t_end_mins)
+                       )
+               {
+                       SUNDRY_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+                       return true;
+               }
+       }
+
+       return false;
+}
+
+static void mmi_watch_get_sleep_data_start(void)
+{
+#ifdef __MMI_CUSTOM_HENGAI_SLEEP__
+       mmi_hengai_get_sleep_data_start();
+#endif
+
+}
+
+static void mmi_watch_get_sleep_data_stop(void)
+{
+#ifdef __MMI_CUSTOM_HENGAI_SLEEP__
+       mmi_hengai_get_sleep_data_stop();
+#endif
+
+}
+
+void mmi_watch_sleep_time_mission_check(void)
+{
+       if(true == mmi_watch_time_is_in_sleep_time())
+       {
+               SUNDRY_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               if(0 == s_sleep_mission_in_progress)
+               {
+                       s_sleep_mission_in_progress = 1;
+                       mmi_watch_get_sleep_data_start();
+               }
+       }
+       else
+       {
+               SUNDRY_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               if(1 == s_sleep_mission_in_progress)
+               {
+                       s_sleep_mission_in_progress = 0;
+                       mmi_watch_get_sleep_data_stop();
+               }
+       }
+}
+#endif
+
+
+#ifdef __MMI_ZHSX_SUPPORT_CHECK_SIM_UNBIND__
+
+static nv_watch_switch_t s_sim_unbind_switch = {0};
+
+void mmi_watch_sim_unbind_switch_nv_write(void)
+{
+       uint32_t nv_data_length = sizeof(nv_watch_switch_t);
+       
+       if(nv_data_length != UI_NV_Write_Req(NV_SECTION_UI_SIM_UNBIND_SWITCH, 0, nv_data_length, (uint8_t *)&s_sim_unbind_switch))
+       {
+               printf("[@CHENG_DEBUG][%s][%d]: nv write fail\n", __FUNCTION__, __LINE__);
+       }
+}
+
+void mmi_watch_sim_unbind_switch_nv_read(void)
+{
+       uint32_t nv_data_length = sizeof(nv_watch_switch_t);
+       
+       if(nv_data_length != UI_NV_Read_Req(NV_SECTION_UI_SIM_UNBIND_SWITCH, 0, nv_data_length, (uint8_t *)&s_sim_unbind_switch))
+       {
+               printf("[@CHENG_DEBUG][%s][%d]: nv read fail\n", __FUNCTION__, __LINE__);
+       }
+}
+
+void mmi_watch_sim_unbind_switch_nv_default(nv_watch_switch_t * data)
+{
+       data->switch_flag = MMI_SIM_UNBIND_SWITCH_DEFAULT;
+}
+
+// 0-close; 1-open
+uint8_t mmi_watch_sim_unbind_switch_get(void)
+{
+       return (s_sim_unbind_switch.switch_flag);
+}
+
+void mmi_watch_sim_unbind_switch_set(uint8_t value)
+{
+       if(0 == value || 1 == value)
+       {
+               s_sim_unbind_switch.switch_flag = value;
+               mmi_watch_sim_unbind_switch_nv_write();
+       }
+}
+
+bool mmi_watch_sim_unbind_info_compare(void)
+{
+       bool result = false;
+       nv_watch_sim_iccid_t old_iccid = {0};
+       char new_iccid_data[NV_WATCH_SIM_ICCID_DATA_LEN + 1] = {0};
+
+       char * p_iccid = app_adaptor_get_iccid_info_req();
+       strncpy(new_iccid_data, p_iccid, NV_WATCH_SIM_ICCID_DATA_LEN);
+       lv_mem_free(p_iccid);
+
+       uint32_t nv_data_length = sizeof(nv_watch_sim_iccid_t);
+       if(nv_data_length != UI_NV_Read_Req(NV_SECTION_UI_SIM_ICCID_DATA, 0, nv_data_length, (uint8_t *)&old_iccid))
+       {
+               _lv_memset_00(&old_iccid, nv_data_length);
+               printf("[@CHENG_DEBUG][%s][%d]: nv read fail\n", __FUNCTION__, __LINE__);
+       }
+
+       if(0 == strlen(old_iccid.data))
+       {
+               strncpy(old_iccid.data, new_iccid_data, NV_WATCH_SIM_ICCID_DATA_LEN);
+               UI_NV_Write_Req(NV_SECTION_UI_SIM_ICCID_DATA, 0, nv_data_length, (uint8_t *)&old_iccid);
+               
+               return false;
+       }
+       else if(0 == strncmp(old_iccid.data, new_iccid_data, NV_WATCH_SIM_ICCID_DATA_LEN))
+       {
+               return false;
+       }
+       else
+       {
+               strncpy(old_iccid.data, new_iccid_data, NV_WATCH_SIM_ICCID_DATA_LEN);
+               UI_NV_Write_Req(NV_SECTION_UI_SIM_ICCID_DATA, 0, nv_data_length, (uint8_t *)&old_iccid);
+
+               return true;
+       }
+}
+
+void mmi_watch_sim_unbind_check(void)
+{
+       if(true == mmi_watch_sim_unbind_info_compare())
+       {
+               if(1 == mmi_watch_sim_unbind_switch_get())
+               {
+                       mmi_watch_factory_aciton();
+               }
+       }
+}
+#endif
+
+
+
+#endif
+
+
diff --git a/2.sdk/sdk/gui/lv_watch/mmi_sundry/mmi_sundry.h b/2.sdk/sdk/gui/lv_watch/mmi_sundry/mmi_sundry.h
new file mode 100644 (file)
index 0000000..ca4d1af
--- /dev/null
@@ -0,0 +1,124 @@
+
+
+
+#ifndef __MMI_SUNDRY_H__
+#define __MMI_SUNDRY_H__
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif //__cplusplus
+
+#ifdef LV_CONF_INCLUDE_SIMPLE
+#include "lvgl.h"
+#include "lv_watch_conf.h"
+#else
+#include "../../../lvgl/lvgl.h"
+#include "../../../lv_watch_conf.h"
+#endif
+
+#ifdef __MMI_ZHSX_SUPPORT__
+
+#define __MMI_SUNDRY_DEBUG__
+#ifdef __MMI_SUNDRY_DEBUG__
+#define SUNDRY_DEBUG_PRINTF(fmt, ...)  printf("[SUNDRY]"fmt, ##__VA_ARGS__)
+#else
+#define SUNDRY_DEBUG_PRINTF(fmt, ...)
+#endif
+
+
+bool mmi_active_screen_is_prohibit_interrupted(void);
+
+void mmi_watch_wake_up(void);
+
+bool mmi_watch_vibrate_is_permitted(void);
+
+
+typedef enum
+{
+       MMI_WATCH_SWITCH_OFF = 0,
+       MMI_WATCH_SWITCH_ON,
+       MMI_WATCH_SWITCH_MAX
+}MMI_WATCH_SWITCH_E;
+
+
+void mmi_ui_msg_update_watch_factory(void);
+void mmi_watch_factory_aciton(void);
+void mmi_ui_msg_update_watch_power_off(void);
+void mmi_watch_power_off_aciton(void);
+void mmi_ui_msg_update_watch_reboot(void);
+void mmi_watch_reboot_aciton(void);
+
+
+#define MMI_WATCH_SEARCH_DURATION      (1000 * 60) // ms
+
+typedef struct
+{
+    lv_watch_obj_ext_t old_ext;
+    lv_obj_t * label;
+} lv_watch_search_ext_t;
+
+void mmi_watch_search_screen_destroy(void);
+void mmi_ui_msg_update_watch_server_search(void);
+void mmi_watch_searching_aciton(void);
+
+void mmi_center_number_nv_read(void);
+void mmi_center_number_set(nv_watch_center_number_t * center_number);
+void mmi_ui_msg_update_ceter_number_dialing(void);
+void mmi_center_number_dialing_action(void);
+
+#ifdef __MMI_ZHSX_SUPPORT_NO_SIM_POWER_OFF__
+#define NO_SIM_POWER_OFF_INTERVAL      (15 * 60 * 1000) // ms
+#define NO_SIM_POWER_OFF_PROMPT_INTERVAL       (15) // s
+
+void mmi_ui_msg_update_no_sim_power_off(void);
+void mmi_watch_no_sim_power_off_check_action(void);
+void mmi_watch_no_sim_power_off_check_mission(void);
+#endif
+
+void mmi_ui_msg_update_charging_prompt(uint32_t chg_status);
+
+#ifdef __MMI_ZHSX_SUPPORT_DO_NOT_DISTURB__
+
+typedef struct
+{
+    lv_watch_obj_ext_t old_ext;
+       
+       lv_obj_t * cont;
+} lv_do_not_disturb_ext_t;
+
+
+void mmi_watch_do_not_disturb_nv_read(void);
+void mmi_watch_do_not_disturb_data_set(nv_watch_do_not_disturb_t * data);
+bool mmi_watch_is_in_do_not_disturb_time(void);
+void mmi_ui_msg_update_do_not_disturb(uint8_t flag);
+void mmi_watch_do_not_disturb_mission_check(void);
+void mmi_watch_do_not_disturb_task_clean(void);
+#endif
+
+#ifdef __MMI_SLEEP_FUNCTION_SUPPORT__
+void mmi_watch_sleep_time_nv_read(void);
+void mmi_watch_sleep_time_data_set(nv_watch_sleep_time_t * data);
+void mmi_watch_sleep_time_mission_check(void);
+#endif
+
+#ifdef __MMI_ZHSX_SUPPORT_CHECK_SIM_UNBIND__
+void mmi_watch_sim_unbind_switch_nv_read(void);
+void mmi_watch_sim_unbind_switch_nv_default(nv_watch_switch_t * data);
+void mmi_watch_sim_unbind_switch_set(uint8_t value);
+void mmi_watch_sim_unbind_check(void);
+#endif
+
+
+
+
+#endif
+
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif //__cplusplus
+
+#endif
+
+