240X320 size modify
authorCCC <2393524978@qq.com>
Mon, 17 Apr 2023 07:11:49 +0000 (15:11 +0800)
committerCCC <2393524978@qq.com>
Mon, 17 Apr 2023 07:11:49 +0000 (15:11 +0800)
45 files changed:
2.sdk/gui/lv_watch/CMakeLists.txt
2.sdk/gui/lv_watch/app_adaptor/app_adaptor.c
2.sdk/gui/lv_watch/framework/language/lang_ch.c
2.sdk/gui/lv_watch/framework/language/lang_en.c
2.sdk/gui/lv_watch/framework/nvm/ui_nvm.h
2.sdk/gui/lv_watch/framework/nvm/ui_nvm_api.c
2.sdk/gui/lv_watch/include/app_adaptor_interface.h
2.sdk/gui/lv_watch/include/ui_nvm_interface.h
2.sdk/gui/lv_watch/include/ui_textid.h
2.sdk/gui/lv_watch/lv_apps/dial/dial.h
2.sdk/gui/lv_watch/lv_apps/dial/dial_element.c
2.sdk/gui/lv_watch/lv_apps/factory_mode/factory_mode.h
2.sdk/gui/lv_watch/lv_apps/factory_mode/factory_mode_reset.c
2.sdk/gui/lv_watch/lv_apps/health_measure/health_heart_rate.c
2.sdk/gui/lv_watch/lv_apps/health_measure/health_heart_rate.h
2.sdk/gui/lv_watch/lv_apps/health_measure/health_measure.c [new file with mode: 0644]
2.sdk/gui/lv_watch/lv_apps/health_measure/health_measure.h [new file with mode: 0644]
2.sdk/gui/lv_watch/lv_apps/health_measure/health_spo2.c
2.sdk/gui/lv_watch/lv_apps/health_measure/health_spo2.h
2.sdk/gui/lv_watch/lv_apps/health_measure/health_temperature.c
2.sdk/gui/lv_watch/lv_apps/health_measure/health_temperature.h
2.sdk/gui/lv_watch/lv_apps/phonebook/phonebook.c
2.sdk/gui/lv_watch/lv_apps/phonebook/phonebook.h
2.sdk/gui/lv_watch/lv_apps/restart_and_reset/restart_and_reset.c
2.sdk/gui/lv_watch/lv_apps/restart_and_reset/restart_and_reset.h
2.sdk/gui/lv_watch/lv_apps/shutdown/shutdown.c
2.sdk/gui/lv_watch/lv_apps/shutdown/shutdown.h
2.sdk/gui/lv_watch/lv_apps/wechat/wechat.h
2.sdk/gui/lv_watch/lv_apps/wechat/wechat_ui.c
2.sdk/gui/lv_watch/lv_watch.c
2.sdk/gui/lv_watch/lv_watch.h
2.sdk/gui/lv_watch/lv_watch_res.h
2.sdk/gui/lv_watch/mmi_location/mmi_location.c [new file with mode: 0644]
2.sdk/gui/lv_watch/mmi_location/mmi_location.h [new file with mode: 0644]
2.sdk/gui/lv_watch/mmi_protocol/mmi_protocol_api.c [new file with mode: 0644]
2.sdk/gui/lv_watch/mmi_protocol/mmi_protocol_api.h [new file with mode: 0644]
2.sdk/gui/lv_watch/mmi_protocol/mmi_protocol_fzd.c [new file with mode: 0644]
2.sdk/gui/lv_watch/mmi_protocol/mmi_protocol_fzd.h [new file with mode: 0644]
2.sdk/gui/lv_watch/modem/mmi_modem_tcp/mmi_modem_tcp_msg_handler_impl.c
2.sdk/gui/lv_watch/modem/mmi_modem_tcp/mmi_modem_tcp_msg_handler_impl.h
2.sdk/gui/lv_watch/modem/mmi_modem_tcp/mmi_modem_tcp_msg_handler_interface.c
2.sdk/gui/lv_watch/resource/gif/anim_temperature_measuring.gif [new file with mode: 0644]
2.sdk/gui/lv_watch/resource/png/health_measure/icon_temperature_measure_done.png [new file with mode: 0644]
2.sdk/gui/lv_watch/resource/png/health_measure/icon_temperature_measure_fail.png [new file with mode: 0644]
2.sdk/product/craneg_modem/config/watch/lv_watch_conf.h

index c96b077..72c598e 100644 (file)
@@ -194,14 +194,19 @@ set(lv_watch_sources
 #sms
   lv_apps/sms_msg/sms_msg.c
   lv_apps/upgrade/upgrade_rs.c
+
+#CHENG_MODIFY
+       mmi_protocol/mmi_protocol_api.c
+       mmi_protocol/mmi_protocol_fzd.c
 #wechat
-  lv_apps/wechat/wechat_ui.c
+       lv_apps/wechat/wechat_ui.c
 #primary menu data
-  lv_apps/primary_menu/primary_menu_data.c
+       lv_apps/primary_menu/primary_menu_data.c
 #health_measure
-  lv_apps/health_measure/health_heart_rate.c
-  lv_apps/health_measure/health_spo2.c
-  lv_apps/health_measure/health_temperature.c
+       lv_apps/health_measure/health_measure.c
+       lv_apps/health_measure/health_heart_rate.c
+       lv_apps/health_measure/health_spo2.c
+       lv_apps/health_measure/health_temperature.c
 )
 
 set(lv_watch_font_sources
index fe10439..3f19617 100644 (file)
 /**********************
  *  GLOBAL FUNCTION
  **********************/
+#ifdef __MMI_ZHSX_SUPPORT__
+static char city_buff[MMI_WEATHER_CITY_NAME_LEN_MAX] = {0}; 
+static app_adaptor_weather_t s_weather_info = {0};
+
+void mmi_weather_info_set(app_adaptor_weather_t * weather)
+{
+       s_weather_info.weather_id = weather->weather_id;
+       s_weather_info.current_temperature = weather->current_temperature;
+       s_weather_info.lowest_temperature = weather->lowest_temperature;
+       s_weather_info.highest_temperature = weather->highest_temperature;
+       _lv_memcpy(s_weather_info.city, weather->city, MMI_WEATHER_CITY_NAME_LEN_MAX);
+}
+
+
+static mmi_health_info_t s_health_info = {0};
+void mmi_health_info_get(mmi_health_info_t * health_info)
+{
+       health_info->heart_value = s_health_info.heart_value;
+       health_info->blood_high_value = s_health_info.blood_high_value;
+       health_info->blood_low_value = s_health_info.blood_low_value;
+       health_info->spo2_value = s_health_info.spo2_value;
+       health_info->body_value = s_health_info.body_value;
+}
+
+void mmi_health_info_set(mmi_health_info_t * health_info)
+{
+       s_health_info.heart_value = health_info->heart_value;
+       s_health_info.blood_high_value = health_info->blood_high_value;
+       s_health_info.blood_low_value = health_info->blood_low_value;
+       s_health_info.spo2_value = health_info->spo2_value;
+       s_health_info.body_value = health_info->body_value;
+}
+#endif
+
 void app_adaptor_get_weather_req(app_adaptor_weather_t * weather)
 {
+#ifdef __MMI_ZHSX_SUPPORT__
+       s_weather_info.city = city_buff;
+       if(0 != strlen(s_weather_info.city))
+       {
+               _lv_memcpy(weather, &s_weather_info, sizeof(app_adaptor_weather_t));
+       }
+       
+#else
     static uint8_t dummy_read_count = 1;
     static char city[20] = "大连";
 
@@ -56,6 +98,7 @@ void app_adaptor_get_weather_req(app_adaptor_weather_t * weather)
     }
 
     dummy_read_count++;
+#endif
 }
 
 char * app_adaptor_get_model_id(void)
index 728e1da..528cd32 100644 (file)
@@ -844,6 +844,7 @@ const void * lang_text_ch[] = {
     "当前腕温",
     "血氧",
     "体温",
+    "℃", // WATCH_TEXT_ID_TEMPERATURE_UNIT
 
     //CHENG_MODIFY
 
index b6377e0..142cece 100644 (file)
@@ -844,6 +844,8 @@ const void * lang_text_en[] = {
     "Wrist temperature",
     "SPO2",
     "Temperature",
+    "℃", // WATCH_TEXT_ID_TEMPERATURE_UNIT
+    
     //CHENG_MODIFY
 
 
index 20a4b8a..e2455b2 100644 (file)
@@ -34,9 +34,13 @@ extern "C" {
 #define NV_SECTION_UI_AGNSS_LEN                 (sizeof(nv_watch_agnss_t))
 #define NV_SECTION_UI_SMSMSG_LEN                (sizeof(nv_watch_sms_msg_t))
 #define NV_SECTION_UI_GPS_AIDPOS_LEN            (sizeof(nv_watch_gps_aidpos_t))
+//#if __MMI_ZHSX_SUPPORT__
 //#if USE_LV_WATCH_WECHAT != 0
 #define NV_SECTION_UI_WEHAT_MSG_LEN            (sizeof(nv_watch_wechat_msg_info_t))
 //#endif
+#define NV_SECTION_UI_HEALTH_MEASURE_LEN            (sizeof(nv_watch_health_measure_timed_t))
+#define NV_SECTION_UI_PROTOCOL_DATA_LEN                     (sizeof(nv_watch_protocol_data_t))
+//#endif
 #define NV_SECTION_LEN(sectionid)    (sectionid ## _LEN)
 
 /* definition of section start address */
@@ -114,8 +118,13 @@ typedef lv_fs_dir_t  ui_dir_t;
 #define NV_SECTION_UI_AGNSS_FILE                 "ui_agnss.nv"
 #define NV_SECTION_UI_SMSMSG_FILE                "ui_smsmsg.nv"
 #define NV_SECTION_UI_GPS_AIDPOS_FILE            "ui_gps_aidpos.nv"
+//#if __MMI_ZHSX_SUPPORT__
 //#if USE_LV_WATCH_WECHAT != 0
 #define NV_SECTION_UI_WEHAT_MSG_FILE            "ui_wechat_msg.nv"
+//#endif
+#define NV_SECTION_UI_HEALTH_MEASURE_FILE           "ui_health_measure.nv"
+#define NV_SECTION_UI_PROTOCOL_DATA_FILE            "ui_protocol_data.nv"
+
 //#endif
 #define NV_SECTION_FILE_PATH(sectionid)    (sectionid ## _FILE)
 
index 87f76c3..18feeac 100644 (file)
@@ -71,10 +71,16 @@ uint32_t UI_NV_Get_Section_Len(NV_UI_SECTION_ID SectionId)
         case NV_SECTION_UI_GPS_AIDPOS:
             return(NV_SECTION_LEN(NV_SECTION_UI_GPS_AIDPOS));
 
+       //#if __MMI_ZHSX_SUPPORT__
        //#if USE_LV_WATCH_WECHAT != 0
                case NV_SECTION_UI_WEHAT_MSG:
                        return(NV_SECTION_LEN(NV_SECTION_UI_WEHAT_MSG));
        //#endif
+               case NV_SECTION_UI_HEALTH_MEASURE:
+                       return(NV_SECTION_LEN(NV_SECTION_UI_HEALTH_MEASURE));
+               case NV_SECTION_UI_PROTOCOL_DATA:
+                       return(NV_SECTION_LEN(NV_SECTION_UI_PROTOCOL_DATA));
+       //#endif
 
         default:
             printf("SectionId wrong\n");
@@ -144,10 +150,16 @@ char * UI_NV_Get_Section_path(NV_UI_SECTION_ID SectionId)
         case NV_SECTION_UI_GPS_AIDPOS:
             return(NV_SECTION_FILE_PATH(NV_SECTION_UI_GPS_AIDPOS));
 
+       //#if __MMI_ZHSX_SUPPORT__
        //#if USE_LV_WATCH_WECHAT != 0
                case NV_SECTION_UI_WEHAT_MSG:
                        return(NV_SECTION_FILE_PATH(NV_SECTION_UI_WEHAT_MSG));
        //#endif
+               case NV_SECTION_UI_HEALTH_MEASURE:
+                       return(NV_SECTION_FILE_PATH(NV_SECTION_UI_HEALTH_MEASURE));
+               case NV_SECTION_UI_PROTOCOL_DATA:
+                       return(NV_SECTION_FILE_PATH(NV_SECTION_UI_PROTOCOL_DATA));
+       //#endif
 
         default:
             printf("SectionId wrong\n");
@@ -184,9 +196,13 @@ uint8_t UI_NV_Reset_Default(NV_UI_SECTION_ID SectionId)
        nv_watch_agnss_t * agnss;
     nv_watch_sms_msg_t * smsmsg;
     nv_watch_gps_aidpos_t * gps_aidpos;
+//#if __MMI_ZHSX_SUPPORT__
 //#if USE_LV_WATCH_WECHAT != 0
        nv_watch_wechat_msg_info_t * wechat_msg;
 //#endif
+       nv_watch_health_measure_timed_t * health_measure;
+       nv_watch_protocol_data_t * protocol_data;
+//#endif
 
     switch(SectionId) {
         case NV_SECTION_UI_SETTINGS:
@@ -336,6 +352,7 @@ uint8_t UI_NV_Reset_Default(NV_UI_SECTION_ID SectionId)
             memset(gps_aidpos, 0, SectionLen);
             TempData = (char *)gps_aidpos;
             break;
+       //#if __MMI_ZHSX_SUPPORT__
        //#if USE_LV_WATCH_WECHAT != 0
                case NV_SECTION_UI_WEHAT_MSG:
                        wechat_msg = lv_mem_alloc(SectionLen);
@@ -343,6 +360,19 @@ uint8_t UI_NV_Reset_Default(NV_UI_SECTION_ID SectionId)
             TempData = (char *)wechat_msg;
             break;
        //#endif
+
+               case NV_SECTION_UI_HEALTH_MEASURE:
+                       health_measure = lv_mem_alloc(SectionLen);
+                       memset(health_measure, 0, SectionLen);
+                       TempData = (char *)health_measure;
+                       break;
+
+               case NV_SECTION_UI_PROTOCOL_DATA:
+                       protocol_data = lv_mem_alloc(SectionLen);
+                       memset(protocol_data, 0, SectionLen);
+                       TempData = (char *)protocol_data;
+                       break;
+       //#endif
         default:
             TempData = NULL;
             break;
index 6a35314..38a86c4 100644 (file)
@@ -380,6 +380,27 @@ typedef struct
     uint8_t active[ACTIVITY_OCLOCK_CNT];  //0 or 1
 } app_adaptor_activity_info_t;
 
+
+#ifdef __MMI_ZHSX_SUPPORT__
+#define MMI_WEATHER_CITY_NAME_LEN_MAX  (64)
+
+void mmi_weather_info_set(app_adaptor_weather_t * weather);
+
+
+typedef struct
+{
+       uint16_t heart_value;
+       uint16_t blood_high_value;
+       uint16_t blood_low_value;
+       uint16_t spo2_value;
+       //float wrist_value;
+       float body_value;
+}mmi_health_info_t;    
+
+void mmi_health_info_get(mmi_health_info_t * health_info);
+void mmi_health_info_set(mmi_health_info_t * health_info);
+#endif
+
 /**
  * get weather information
  * param (out) weather: app_adaptor_weather_t * 255 means no weather information
index 1303e62..01f5010 100644 (file)
@@ -142,6 +142,7 @@ typedef struct
                                                     *default 0*/
 } __packed nv_watch_voice_msg_t;
 
+//#if __MMI_ZHSX_SUPPORT__
 //#if USE_LV_WATCH_WECHAT != 0
 
 #define NV_WATCH_WECHAT_NUM_MAX                (20)
@@ -174,6 +175,28 @@ typedef struct
 } __packed nv_watch_wechat_msg_info_t;
 //#endif
 
+typedef struct
+{
+       uint8_t heart_timed_flag; // 0-close; 1-open
+       uint32_t heart_timed_interval; // unit-second
+       uint8_t temperature_timed_flag;
+       uint32_t temperature_timed_interval;
+       uint8_t blood_timed_flag;
+       uint32_t blood_timed_interval;
+       uint8_t spo2_timed_flag;
+       uint32_t spo2_timed_interval;
+} __packed nv_watch_health_measure_timed_t;
+
+typedef struct
+{
+       uint32_t heartbeat_action_interval; // second
+       uint32_t location_upload_interval; // second
+       uint32_t weather_update_interval; // second
+} __packed nv_watch_protocol_data_t;
+
+
+//#endif
+
 typedef struct
 {
     uint8_t autoanswerflg;                                                // 1: auto answer enable, 0: auto answer disable
@@ -349,8 +372,13 @@ enum
     NV_SECTION_UI_AGNSS,                                // nv_watch_agnss_t
     NV_SECTION_UI_SMSMSG,                               // nv_watch_sms_msg_t
     NV_SECTION_UI_GPS_AIDPOS,                           // nv_watch_gps_aidpos_t
+//#if __MMI_ZHSX_SUPPORT__
 //#if USE_LV_WATCH_WECHAT != 0
        NV_SECTION_UI_WEHAT_MSG,                                                        // nv_watch_wechat_msg_info_t
+//#endif
+       NV_SECTION_UI_HEALTH_MEASURE,                                   // nv_watch_health_measure_timed_t
+       NV_SECTION_UI_PROTOCOL_DATA,                                    // nv_watch_protocol_data_t
+
 //#endif
     NV_SECTION_UI_MAX_NUM
 };
index 7158fd1..31f71fd 100644 (file)
@@ -851,6 +851,8 @@ enum
     WATCH_TEXT_ID_CURRENT_WRIST_TEMPERATURE,                   // 当前腕温
     WATCH_TEXT_ID_SPO2,                                 /* "血氧"       "SPO2" */
     WATCH_TEXT_ID_TEMPERATURE,                          /* "体温"       "Temperature" */
+    WATCH_TEXT_ID_TEMPERATURE_UNIT,                     /* "℃"       "℃" */
+
 
     //CHENG_MODIFY
 
index a82e2ea..5d83c38 100644 (file)
@@ -71,6 +71,7 @@ enum {
     ELEMENT_TYPE_PRESSURE,          //12
     ELEMENT_TYPE_HEART_RATE,        //13
     ELEMENT_TYPE_BLOOD_OXYGEN,      //14
+       ELEMENT_TYPE_USER,
     ELEMENT_TYPE_BG_SWITCH,         //15  /*except when updating all elements, always at the last*/
     ELEMENT_TYPE_MAX
 };
@@ -160,12 +161,15 @@ enum {
     IMG_TYPE_HEART_RATE_TENS,       //132
     IMG_TYPE_HEART_RATE_UNIT,       //133
     IMG_TYPE_HEART_RATE_BPM,        //134
+       IMG_TYPE_HEART_RATE_IMAGE,
 
     IMG_TYPE_BLOOD_OXYGEN = ELEMENT_TYPE_BLOOD_OXYGEN * 10,  //140
     IMG_TYPE_BLOOD_OXYGEN_TENS,     //141
     IMG_TYPE_BLOOD_OXYGEN_UNIT,     //142
     IMG_TYPE_BLOOD_OXYGEN_PERCENT,  //143
 
+       IMG_TYPE_USER_PNG = ELEMENT_TYPE_USER * 10, // display a static image
+
     IMG_TYPE_BG = ELEMENT_TYPE_BG_SWITCH * 10, //150
 };
 typedef uint8_t watch_img_type_t;
index dcb1ae5..9f73af6 100644 (file)
@@ -508,7 +508,8 @@ static void dial_update_canvas_label(watch_element_base_t * base)
     char infotxt[len];
     app_adaptor_weather_t weather;
     app_adaptor_pedometer_record_t record;
-    app_adaptor_health_info_t health;
+    //app_adaptor_health_info_t health;
+       mmi_health_info_t health_info = {0};
     lv_point_t pos;
 
     if(ELEMENT_TYPE_WEEK == base->element_type || ELEMENT_TYPE_DATE == base->element_type
@@ -523,7 +524,8 @@ static void dial_update_canvas_label(watch_element_base_t * base)
     }
     if(ELEMENT_TYPE_HEART_RATE == base->element_type || ELEMENT_TYPE_SLEEP_QUALITY == base->element_type || ELEMENT_TYPE_BLOOD_OXYGEN == base->element_type
             || ELEMENT_TYPE_PRESSURE == base->element_type) {
-        app_adaptor_get_health_info_req(&health);
+        //app_adaptor_get_health_info_req(&health);
+               mmi_health_info_get(&health_info);
     }
 
     dial_get_element_pos(base->element_type, &pos);
@@ -614,7 +616,10 @@ static void dial_update_canvas_label(watch_element_base_t * base)
                 break;
             case LABEL_TYPE_HEART_RATE:
                 //snprintf(infotxt, len, "%.3d", health.heartrate);
-                snprintf(infotxt, len, "%-3d", health.heartrate);
+                               if(health_info.heart_value)
+                       sprintf(infotxt, "%-3d", health_info.heart_value);
+                               else
+                       sprintf(infotxt, "%--");
                 dial_create_canvas_text(infotxt, label_dsc->label_font, label_dsc->text_color, pos.x + label_dsc->text_pos.x, pos.y + label_dsc->text_pos.y);
                 break;
             case LABEL_TYPE_DISTANCE:
@@ -622,17 +627,24 @@ static void dial_update_canvas_label(watch_element_base_t * base)
                 dial_create_canvas_text(infotxt, label_dsc->label_font, label_dsc->text_color, pos.x + label_dsc->text_pos.x, pos.y + label_dsc->text_pos.y);
                 break;
             case LABEL_TYPE_BLOOD_OXYGEN:
-                snprintf(infotxt, len, "%d%%", health.bloodoxygen);
+                //snprintf(infotxt, len, "%d%%", health.bloodoxygen);
+                               if(health_info.spo2_value)
+                       sprintf(infotxt, "%d%%", health_info.spo2_value);
+                               else
+                       sprintf(infotxt, "%--");
                 dial_create_canvas_text(infotxt, label_dsc->label_font, label_dsc->text_color, pos.x + label_dsc->text_pos.x, pos.y + label_dsc->text_pos.y);
                 break;
             case LABEL_TYPE_PRESSURE:
                 //snprintf(infotxt, len, "%.3d", health.pressure);
-                snprintf(infotxt, len, "%-3d", health.pressure);
+                               if(health_info.blood_low_value && health_info.blood_high_value)
+                       sprintf(infotxt, "%-3d-%-3d", health_info.blood_low_value, health_info.blood_high_value);
+                               else
+                       sprintf(infotxt, "%--");
                 dial_create_canvas_text(infotxt, label_dsc->label_font, label_dsc->text_color, pos.x + label_dsc->text_pos.x, pos.y + label_dsc->text_pos.y);
                 break;
             case LABEL_TYPE_SLEEP_QUALITY:
-                snprintf(infotxt, len, "%d", health.sleep);
-                dial_create_canvas_text(infotxt, label_dsc->label_font, label_dsc->text_color, pos.x + label_dsc->text_pos.x, pos.y + label_dsc->text_pos.y);
+                //snprintf(infotxt, len, "%d", health.sleep);
+                //dial_create_canvas_text(infotxt, label_dsc->label_font, label_dsc->text_color, pos.x + label_dsc->text_pos.x, pos.y + label_dsc->text_pos.y);
                 break;
             default:
                 break;
@@ -645,7 +657,8 @@ static void dial_update_canvas_img(watch_element_base_t * base)
     watch_element_img_dsc_t * img_dsc;
     app_adaptor_weather_t weather;
     app_adaptor_pedometer_record_t record;
-    app_adaptor_health_info_t health;
+    //app_adaptor_health_info_t health;
+       //mmi_health_info_t health_info = {0};
     void * sub_img = NULL;
     int16_t angle = 0;
     hal_rtc_t tm;
@@ -663,7 +676,8 @@ static void dial_update_canvas_img(watch_element_base_t * base)
     }
     if(ELEMENT_TYPE_HEART_RATE == base->element_type || ELEMENT_TYPE_SLEEP_QUALITY == base->element_type || ELEMENT_TYPE_BLOOD_OXYGEN == base->element_type
             || ELEMENT_TYPE_PRESSURE == base->element_type) {
-        app_adaptor_get_health_info_req(&health);
+        //app_adaptor_get_health_info_req(&health);
+               //mmi_health_info_get(&health_info);
     }
 
     dial_get_element_pos(base->element_type, &pos);
@@ -813,19 +827,19 @@ static void dial_update_canvas_img(watch_element_base_t * base)
                     dial_update_canvas(sub_img, 0, pos.x + img_dsc->img_pos.x, pos.y + img_dsc->img_pos.y);
                 break;
             case IMG_TYPE_HEART_RATE_HUNDRED:
-                sub_img = dial_get_sub_img(img_dsc, health.heartrate / 100);
-                if(sub_img)
-                    dial_update_canvas(sub_img, 0, pos.x + img_dsc->img_pos.x, pos.y + img_dsc->img_pos.y);
+                //sub_img = dial_get_sub_img(img_dsc, health.heartrate / 100);
+                //if(sub_img)
+                //    dial_update_canvas(sub_img, 0, pos.x + img_dsc->img_pos.x, pos.y + img_dsc->img_pos.y);
                 break;
             case IMG_TYPE_HEART_RATE_TENS:
-                sub_img = dial_get_sub_img(img_dsc, health.heartrate % 100 / 10);
-                if(sub_img)
-                    dial_update_canvas(sub_img, 0, pos.x + img_dsc->img_pos.x, pos.y + img_dsc->img_pos.y);
+                //sub_img = dial_get_sub_img(img_dsc, health.heartrate % 100 / 10);
+                //if(sub_img)
+                //    dial_update_canvas(sub_img, 0, pos.x + img_dsc->img_pos.x, pos.y + img_dsc->img_pos.y);
                 break;
             case IMG_TYPE_HEART_RATE_UNIT:
-                sub_img = dial_get_sub_img(img_dsc, health.heartrate % 10);
-                if(sub_img)
-                    dial_update_canvas(sub_img, 0, pos.x + img_dsc->img_pos.x, pos.y + img_dsc->img_pos.y);
+                //sub_img = dial_get_sub_img(img_dsc, health.heartrate % 10);
+                //if(sub_img)
+                //    dial_update_canvas(sub_img, 0, pos.x + img_dsc->img_pos.x, pos.y + img_dsc->img_pos.y);
                 break;
             case IMG_TYPE_WEATHER:
                 if(WATCH_WEATHER_ID_NO_INFO == weather.weather_id || WATCH_WEATHER_ID_OTHERS == weather.weather_id) {
@@ -896,46 +910,46 @@ static void dial_update_canvas_img(watch_element_base_t * base)
                     dial_update_canvas(sub_img, 0, pos.x + img_dsc->img_pos.x, pos.y + img_dsc->img_pos.y);
                 break;
             case IMG_TYPE_BLOOD_OXYGEN_TENS:
-                sub_img = dial_get_sub_img(img_dsc, health.bloodoxygen / 10);
-                if(sub_img)
-                    dial_update_canvas(sub_img, 0, pos.x + img_dsc->img_pos.x, pos.y + img_dsc->img_pos.y);
+                //sub_img = dial_get_sub_img(img_dsc, health.bloodoxygen / 10);
+                //if(sub_img)
+                //    dial_update_canvas(sub_img, 0, pos.x + img_dsc->img_pos.x, pos.y + img_dsc->img_pos.y);
                 break;
             case IMG_TYPE_BLOOD_OXYGEN_UNIT:
-                sub_img = dial_get_sub_img(img_dsc, health.bloodoxygen % 10);
-                if(sub_img)
-                    dial_update_canvas(sub_img, 0, pos.x + img_dsc->img_pos.x, pos.y + img_dsc->img_pos.y);
+                //sub_img = dial_get_sub_img(img_dsc, health.bloodoxygen % 10);
+                //if(sub_img)
+                //    dial_update_canvas(sub_img, 0, pos.x + img_dsc->img_pos.x, pos.y + img_dsc->img_pos.y);
                 break;
             case IMG_TYPE_SLEEP_QUALITY_VALUE:
-                sub_img = dial_get_sub_img(img_dsc, health.sleep);
-                if(sub_img)
-                    dial_update_canvas(sub_img, 0, pos.x + img_dsc->img_pos.x, pos.y + img_dsc->img_pos.y);
+                //sub_img = dial_get_sub_img(img_dsc, health.sleep);
+                //if(sub_img)
+                //    dial_update_canvas(sub_img, 0, pos.x + img_dsc->img_pos.x, pos.y + img_dsc->img_pos.y);
                 break;
             case IMG_TYPE_PRESSURE_HUNDRED:
-                sub_img = dial_get_sub_img(img_dsc, health.pressure / 100);
-                if(sub_img)
-                    dial_update_canvas(sub_img, 0, pos.x + img_dsc->img_pos.x, pos.y + img_dsc->img_pos.y);
+                //sub_img = dial_get_sub_img(img_dsc, health.pressure / 100);
+                //if(sub_img)
+                //    dial_update_canvas(sub_img, 0, pos.x + img_dsc->img_pos.x, pos.y + img_dsc->img_pos.y);
                 break;
             case IMG_TYPE_PRESSURE_TENS:
-                sub_img = dial_get_sub_img(img_dsc, (health.pressure % 100) / 10);
-                if(sub_img)
-                    dial_update_canvas(sub_img, 0, pos.x + img_dsc->img_pos.x, pos.y + img_dsc->img_pos.y);
+                //sub_img = dial_get_sub_img(img_dsc, (health.pressure % 100) / 10);
+                //if(sub_img)
+                //    dial_update_canvas(sub_img, 0, pos.x + img_dsc->img_pos.x, pos.y + img_dsc->img_pos.y);
                 break;
             case IMG_TYPE_PRESSURE_UNIT:
-                sub_img = dial_get_sub_img(img_dsc, health.pressure % 10);
-                if(sub_img)
-                    dial_update_canvas(sub_img, 0, pos.x + img_dsc->img_pos.x, pos.y + img_dsc->img_pos.y);
+                //sub_img = dial_get_sub_img(img_dsc, health.pressure % 10);
+                //if(sub_img)
+                //    dial_update_canvas(sub_img, 0, pos.x + img_dsc->img_pos.x, pos.y + img_dsc->img_pos.y);
                 break;
             case IMG_TYPE_PRESSURE_LEVEL:
-                if(health.pressure >= PRESSURE_LEVEL_HIGH)
-                    sub_img = dial_get_sub_img(img_dsc, 0);
-                else if(health.pressure < PRESSURE_LEVEL_HIGH && health.pressure >= PRESSURE_LEVEL_MEDIUM)
-                    sub_img = dial_get_sub_img(img_dsc, 1);
-                else if(health.pressure < PRESSURE_LEVEL_MEDIUM && health.pressure >= PRESSURE_LEVEL_LOW)
-                    sub_img = dial_get_sub_img(img_dsc, 2);
-                else
-                    sub_img = dial_get_sub_img(img_dsc, 3);
-                if(sub_img)
-                    dial_update_canvas(sub_img, 0, pos.x + img_dsc->img_pos.x, pos.y + img_dsc->img_pos.y);
+                //if(health.pressure >= PRESSURE_LEVEL_HIGH)
+                //    sub_img = dial_get_sub_img(img_dsc, 0);
+                //else if(health.pressure < PRESSURE_LEVEL_HIGH && health.pressure >= PRESSURE_LEVEL_MEDIUM)
+                //    sub_img = dial_get_sub_img(img_dsc, 1);
+                //else if(health.pressure < PRESSURE_LEVEL_MEDIUM && health.pressure >= PRESSURE_LEVEL_LOW)
+                //    sub_img = dial_get_sub_img(img_dsc, 2);
+                //else
+                //    sub_img = dial_get_sub_img(img_dsc, 3);
+                //if(sub_img)
+                //    dial_update_canvas(sub_img, 0, pos.x + img_dsc->img_pos.x, pos.y + img_dsc->img_pos.y);
                 break;
             case IMG_TYPE_TIME_CENTER_DOT:
                 sub_img = dial_get_sub_img(img_dsc, 0);
index 64eb6a4..a136525 100644 (file)
@@ -223,6 +223,11 @@ void camera_preview_test_start(void);
 void camera_preview_test_stop(void);
 /*for camera driver test end*/
 
+
+#ifdef __MMI_ZHSX_SUPPORT__
+void mmi_watch_reset(void);
+#endif
+
 /**********************
  *      MACROS
  **********************/
index 0bdffdc..401ac2a 100644 (file)
@@ -188,4 +188,26 @@ static void factoryreset_no_btn_event_cb(lv_obj_t * btn, lv_event_t e)
     }
 }
 
+
+#ifdef __MMI_ZHSX_SUPPORT__
+void mmi_watch_reset(void)
+{
+       //lv_watch_go_home();
+    lv_obj_t * par = lv_scr_act();
+       
+       lv_obj_clean(par);
+       lv_obj_t * label = lv_label_create(par, NULL);
+       lv_obj_add_style(label, LV_LABEL_PART_MAIN, &lv_watch_font20);
+       lv_label_set_text_id(label, WATCH_TEXT_ID_FACTORY_RESETING);
+       lv_label_set_long_mode(label, LV_LABEL_LONG_BREAK);
+       lv_obj_set_width(label, LV_HOR_RES * 2 / 3);
+       lv_obj_align(label, par, LV_ALIGN_CENTER, 0, 0);
+
+       // delay reset for 50ms to ensure text displaying
+       lv_task_t *task_p = lv_task_create(factory_reset_handle, 50, LV_TASK_PRIO_HIGHEST, NULL);
+       lv_task_once(task_p);
+}
+#endif
+
+
 #endif /*USE_LV_WATCH_FACTORY_MODE*/
index 1b4816d..cbc8368 100644 (file)
 #include <stdio.h>
 
 
-
-void heart_rate_sensor_open(void)
-{
-
-}
-
-void heart_rate_sensor_close(void)
-{
-
-}
-
-uint16 heart_rate_sensor_value_get(void)
-{
-       srand(Hal_Timer_Get_Counter());
-    uint16 value = 50 + rand() % 150;
-       
-       return value;
-}
-
-BOOL heart_rate_sensor_wear_state_get(void)
-{
-       BOOL is_wear = TRUE;
-
-       return is_wear;
-}
-
 lv_heart_rate_obj_ext_t * heart_rate_get_ext(void)
 {
     lv_obj_t * activity_obj = lv_watch_get_activity_obj(ACT_ID_HEALTH_MEASURE_HEART);
@@ -114,73 +88,61 @@ static void heart_rate_measure_cycle_timeout(void * para)
        lv_heart_rate_obj_ext_t * ext = heart_rate_get_ext();
     if(NULL != ext) 
        {
-               if(FALSE == heart_rate_sensor_wear_state_get())
+               if(false == mmi_health_measure_wear_state_get())
                {
                        if(NULL != ext->cycle_timer_id)
                        {
                                Hal_Timer_Stop(ext->cycle_timer_id);
                                ext->cycle_timer_id = NULL;
                        }
-                       if(NULL != ext->total_timer_id)
-                       {
-                               Hal_Timer_Stop(ext->total_timer_id);
-                               ext->total_timer_id = NULL;
-                       }
                        if(NULL != ext->gif_info)
                        {
                                gif_close(ext->gif_info);
                                ext->gif_info = NULL;
                        }
                        lv_obj_del(ext->gif_cont);
+
+                       if(STATE_HEART_RATE_MEASURING == ext->measure_state)
+                       {
+                               mmi_health_measure_interrupt();
+                       }
                        ext->measure_state = STATE_HEART_RATE_MEASURE_FAIL;
                        watch_set_suspend_enable(true, ACT_ID_HEALTH_MEASURE_HEART, 0);
                }
                else
                {
-                       uint16 value = heart_rate_sensor_value_get();
-                       if(value)
+                       if(MMI_HEALTH_MEASURE_STATE_UI == mmi_health_measure_state_get())
                        {
-                               sprintf(ext->heart_rate, "%d bpm", value);
+                               uint16 value = 0;
+                               
+                               mmi_health_measure_heart_data_ui_get(&value);
+                               if(value)
+                               {
+                                       sprintf(ext->heart_rate, "%d bpm", value);
+                               }
+                               //else
+                               //{
+                               //      sprintf(ext->heart_rate, "-- bpm");
+                               //}
+                               ext->measure_state = STATE_HEART_RATE_MEASURING;
+                       }
+                       else
+                       {
+                               if(NULL != ext->cycle_timer_id)
+                               {
+                                       Hal_Timer_Stop(ext->cycle_timer_id);
+                                       ext->cycle_timer_id = NULL;
+                               }
+                               if(NULL != ext->gif_info)
+                               {
+                                       gif_close(ext->gif_info);
+                                       ext->gif_info = NULL;
+                               }
+                               lv_obj_del(ext->gif_cont);
+                               ext->measure_state = STATE_HEART_RATE_MEASURE_DONE;
+                               watch_set_suspend_enable(true, ACT_ID_HEALTH_MEASURE_HEART, 0);
                        }
-                       //else
-                       //{
-                       //      sprintf(ext->heart_rate, "-- bpm");
-                       //}
-                       ext->measure_state = STATE_HEART_RATE_MEASURING;
-               }
-    }
-
-       heart_rate_display_update();
-}
-
-static void heart_rate_measure_timeout(void * para)
-{
-    (void) para;
-
-       //sensor
-       heart_rate_sensor_close();
-
-       lv_heart_rate_obj_ext_t * ext = heart_rate_get_ext();
-    if(NULL != ext) 
-       {
-               if(NULL != ext->cycle_timer_id)
-               {
-                       Hal_Timer_Stop(ext->cycle_timer_id);
-                       ext->cycle_timer_id = NULL;
-               }
-               if(NULL != ext->total_timer_id)
-               {
-                       Hal_Timer_Stop(ext->total_timer_id);
-                       ext->total_timer_id = NULL;
-               }
-               if(NULL != ext->gif_info)
-               {
-                       gif_close(ext->gif_info);
-                       ext->gif_info = NULL;
                }
-               lv_obj_del(ext->gif_cont);
-               ext->measure_state = STATE_HEART_RATE_MEASURE_DONE;
-               watch_set_suspend_enable(true, ACT_ID_HEALTH_MEASURE_HEART, 0);
     }
 
        heart_rate_display_update();
@@ -188,7 +150,7 @@ static void heart_rate_measure_timeout(void * para)
 
 static void heart_rate_prepare_destory(lv_obj_t * activity_obj)
 {
-       HEART_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+       HEALTH_MEASURE_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
        
     watch_set_suspend_enable(true, ACT_ID_HEALTH_MEASURE_HEART, 0);
     lv_watch_png_cache_all_free();
@@ -205,18 +167,17 @@ static void heart_rate_prepare_destory(lv_obj_t * activity_obj)
                        Hal_Timer_Stop(ext->cycle_timer_id);
                        ext->cycle_timer_id = NULL;
                }
-               if(NULL != ext->total_timer_id)
-               {
-                       Hal_Timer_Stop(ext->total_timer_id);
-                       ext->total_timer_id = NULL;
-               }
                if(NULL != ext->gif_info)
                {
                        gif_close(ext->gif_info);
                        ext->gif_info = NULL;
                }
+               if(STATE_HEART_RATE_MEASURING == ext->measure_state)
+               {
+                       mmi_health_measure_interrupt();
+               }
 
-               HEART_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               HEALTH_MEASURE_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
        }
 }
 
@@ -283,14 +244,14 @@ lv_obj_t * health_heart_rate_create(lv_obj_t * activity_obj)
        lv_obj_set_click(label_value, false);
        ext->label_value = label_value;
 
-       if(FALSE == heart_rate_sensor_wear_state_get())
+       if(false == mmi_health_measure_wear_state_get())
        {
                ext->measure_state = STATE_HEART_RATE_MEASURE_FAIL;
                watch_set_suspend_enable(true, ACT_ID_HEALTH_MEASURE_HEART, 0);
        }
        else
        {
-               heart_rate_sensor_open();
+               mmi_health_measure_ui_measure_start(MMI_HEALTH_MEASURE_HEART);
 
                lv_obj_t * gif_cont = lv_cont_create(cont, NULL);
                lv_obj_set_size(gif_cont, LV_HOR_RES, 120);
@@ -301,10 +262,9 @@ lv_obj_t * health_heart_rate_create(lv_obj_t * activity_obj)
                ext->gif_info = gif_open(gif_cont, ANIM_HEART_RATE_MEASURING, 0);
                if(!ext->gif_info) 
                {
-                       HEART_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: gif open fail\n", __FUNCTION__, __LINE__);
+                       HEALTH_MEASURE_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: gif open fail\n", __FUNCTION__, __LINE__);
                }
                
-               ext->total_timer_id = Hal_Timer_Start(HEALTH_HEART_MEASURE_DURATION, heart_rate_measure_timeout, NULL, FALSE);
                ext->cycle_timer_id = Hal_Timer_Start(HEALTH_HEART_MEASURE_CYCLE, heart_rate_measure_cycle_timeout, NULL, TRUE);
        
                ext->measure_state = STATE_HEART_RATE_MEASURING;
index 0fdbacb..c7d24b8 100644 (file)
@@ -23,15 +23,6 @@ extern "C" {
 #ifdef __MMI_HEALTH_MEASURE_HEART_SUPPORT__
 
 
-#define __HEALTH_HEART_DEBUG__
-#ifdef __HEALTH_HEART_DEBUG__
-#define HEART_DEBUG_PRINTF(fmt, ...)   printf(fmt, ##__VA_ARGS__)
-#else
-#define HEART_DEBUG_PRINTF(fmt, ...)
-#endif
-
-
-#define HEALTH_HEART_MEASURE_DURATION          (1000 * 40) // 40 sec
 #define HEALTH_HEART_MEASURE_CYCLE             (1000 * 1)
 
 
@@ -60,11 +51,12 @@ typedef enum
        STATE_HEART_RATE_MEASURE_MAX,
 }lv_heart_rate_state_e;
 
-typedef struct {
+typedef struct 
+{
        lv_watch_obj_ext_t lv_watch_obj;
        /*New data for this type */
        gif_info_t * gif_info;
-       TIMER_ID total_timer_id, cycle_timer_id;
+       TIMER_ID cycle_timer_id;
        lv_obj_t * cont;
        lv_obj_t * img;
        lv_obj_t * label_info;
diff --git a/2.sdk/gui/lv_watch/lv_apps/health_measure/health_measure.c b/2.sdk/gui/lv_watch/lv_apps/health_measure/health_measure.c
new file mode 100644 (file)
index 0000000..141b1e2
--- /dev/null
@@ -0,0 +1,747 @@
+
+
+
+#include "lv_watch.h"
+
+#include <stdio.h>
+
+
+static nv_watch_health_measure_timed_t s_health_measure_timed_data = {0};
+static lv_ll_t s_health_measure_timed_ll = {0};
+static lv_health_measure_run_t s_health_measure_run_data = {0};
+static TIMER_ID s_process_timer_id = NULL;
+static uint8_t s_measure_time_total = 0, s_measure_time_count = 0;
+static uint32_t s_health_measure_heart_timed_time_stamp = 0, s_health_measure_temperature_timed_time_stamp = 0, 
+               s_health_measure_blood_timed_time_stamp = 0, s_health_measure_spo2_timed_time_stamp = 0;
+
+
+void mmi_hsensor_close(void)
+{
+       asl_hr_bp_bo_measure_stop();
+}
+
+void mmi_hsensor_heart_open(void)
+{
+       asl_hr_measure_start(0);
+}
+
+void mmi_hsensor_blood_open(void)
+{
+       asl_hr_measure_start(0);
+}
+
+void mmi_hsensor_spo2_open(void)
+{
+       asl_bo_measure_start(0);
+}
+
+bool mmi_hsensor_is_open(void)
+{
+
+       return true;
+}
+
+static void mmi_hsensor_heart_value_get(uint16 * heart_value)
+{
+       asl_hr_bp_bo_value_get(heart_value, NULL, NULL, NULL);
+}
+
+static void mmi_hsensor_blood_value_get(uint16 * blood_high_value, uint16 * blood_low_value)
+{
+       asl_hr_bp_bo_value_get(NULL, blood_high_value, blood_low_value, NULL);
+}
+
+static void mmi_hsensor_spo2_value_get(uint16 * spo2_value)
+{
+       asl_hr_bp_bo_value_get(NULL, NULL, NULL, spo2_value);
+}
+
+void mmi_tsensor_close(void)
+{
+       asl_temperature_measure_stop();
+}
+
+void mmi_tsensor_open(void)
+{
+       asl_temperature_measure_start();
+}
+
+bool mmi_tsensor_is_open(void)
+{
+
+       return true;
+}
+
+static void mmi_tsensor_wrist_value_get(float * wrist_value)
+{
+//
+}
+
+static void mmi_tsensor_body_value_get(float * body_value)
+{
+       * body_value = asl_body_temperature_get();
+}
+
+bool mmi_health_measure_wear_state_get(void)
+{
+       bool is_wear = TRUE;
+
+       return is_wear;
+}
+
+MMI_HEALTH_MEASURE_STATE_E mmi_health_measure_state_get(void)
+{
+       return s_health_measure_run_data.measure_state;
+}
+
+bool mmi_health_measure_heart_data_process(uint16_t * heart_value)
+{
+       uint16_t t_value = 0;
+       
+#ifdef __HEALTH_MEASURE_FAKE_DATA__
+       srand(Hal_Timer_Get_Counter());
+       t_value = 50 + rand() % 150;
+
+       if(220 < t_value)
+               t_value = 220;
+       else if(50 > t_value)
+               t_value = 50;
+
+#else
+       mmi_hsensor_heart_value_get(&t_value);
+#endif
+
+       * heart_value = t_value;
+
+       return true;
+}
+
+bool mmi_health_measure_temperature_data_process(float * body_value, float * wrist_value)
+{
+       float t_body_value = 0.0, t_wrist_value = 0.0;
+       
+#ifdef __HEALTH_MEASURE_FAKE_DATA__
+       srand(Hal_Timer_Get_Counter());
+       t_body_value = 36.0 + rand() % 4 * 0.1;
+       t_wrist_value = t_body_value - 10.0;
+
+#else
+       mmi_tsensor_body_value_get(&t_body_value);
+       t_body_value = t_wrist_value;
+       t_wrist_value = t_body_value - 10.0;
+#endif
+
+       * body_value = t_body_value;
+       * wrist_value = t_wrist_value;
+       
+       return true;
+}
+
+bool mmi_health_measure_blood_data_process(uint16_t * blood_high_value, uint16_t * blood_low_value)
+{
+       uint16_t t_high_value = 0, t_low_value = 0;
+       
+#ifdef __HEALTH_MEASURE_FAKE_DATA__
+       srand(Hal_Timer_Get_Counter());
+       t_high_value = 120 + rand() % 100;
+       t_low_value = 60 + rand() % 50;
+
+       if(180 < t_high_value)
+               t_high_value = 180;
+       else if(120 > t_high_value)
+               t_high_value = 120;
+
+       if(110 < t_low_value)
+               t_low_value = 120;
+       else if(60 > t_low_value)
+               t_low_value = 60;
+
+#else
+       mmi_hsensor_blood_value_get(&t_high_value, &t_low_value);
+#endif
+
+       * blood_high_value = t_high_value;
+       * blood_low_value = t_low_value;
+       
+       return true;
+}
+
+bool mmi_health_measure_spo2_data_process(uint16_t * spo2_value)
+{
+       uint16_t t_value = 0;
+
+#ifdef __HEALTH_MEASURE_FAKE_DATA__
+       srand(Hal_Timer_Get_Counter());
+       t_value = 95 + rand() % 6;
+       if(100 < t_value)
+               t_value = 100;
+       else if(95 > t_value)
+               t_value = 95;
+
+#else
+       mmi_hsensor_spo2_value_get(&t_value);
+#endif
+
+       * spo2_value = t_value;
+
+       return true;
+}
+
+void mmi_health_measure_timed_info_nv_write(void)
+{
+       uint32_t nv_data_length = sizeof(nv_watch_health_measure_timed_t);
+       
+       HEALTH_MEASURE_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+       
+       if(nv_data_length != UI_NV_Write_Req(NV_SECTION_UI_HEALTH_MEASURE, 0, nv_data_length, (uint8_t *)&s_health_measure_timed_data))
+       {
+               HEALTH_MEASURE_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: nv write fail\n", __FUNCTION__, __LINE__);
+       }
+}
+
+void mmi_health_measure_timed_info_init(void)
+{
+       uint32_t nv_data_length = sizeof(nv_watch_health_measure_timed_t);
+       
+       if(nv_data_length != UI_NV_Read_Req(NV_SECTION_UI_HEALTH_MEASURE, 0, nv_data_length, (uint8_t *)&s_health_measure_timed_data))
+       {
+               HEALTH_MEASURE_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: nv read fail\n", __FUNCTION__, __LINE__);
+       }
+
+       //_lv_ll_clear(&s_health_measure_timed_ll);
+       _lv_ll_init(&s_health_measure_timed_ll, sizeof(MMI_HEALTH_MEASURE_TYPE_E));
+}
+
+
+void mmi_health_measure_timed_list_node_remove(MMI_HEALTH_MEASURE_TYPE_E measure_type)
+{
+       if(true == _lv_ll_is_empty(&s_health_measure_timed_ll))
+               return;
+       
+    MMI_HEALTH_MEASURE_TYPE_E * node = _lv_ll_get_tail(&s_health_measure_timed_ll);
+       
+    while(NULL != node)
+       {
+               if(measure_type == * node)
+               {
+                       _lv_ll_remove(&s_health_measure_timed_ll, node);
+                       lv_mem_free(node);
+                       return ; // delete
+               }
+        node = _lv_ll_get_prev(&s_health_measure_timed_ll, node);
+    }
+}
+
+void mmi_health_measure_timed_list_node_add(MMI_HEALTH_MEASURE_TYPE_E measure_type)
+{
+    MMI_HEALTH_MEASURE_TYPE_E * node = _lv_ll_get_head(&s_health_measure_timed_ll);
+       
+    while(NULL != node)
+       {
+               if(measure_type == * node)
+               {
+                       return ; // exist
+               }
+        node = _lv_ll_get_next(&s_health_measure_timed_ll, node);
+    }
+       
+       MMI_HEALTH_MEASURE_TYPE_E * new_node = _lv_ll_ins_head(&s_health_measure_timed_ll);
+       * new_node = measure_type;
+}
+
+void mmi_health_measure_timed_list_trigger(void)
+{
+       if(true == _lv_ll_is_empty(&s_health_measure_timed_ll))
+               return;
+
+    MMI_HEALTH_MEASURE_TYPE_E * node = _lv_ll_get_tail(&s_health_measure_timed_ll);
+       if(NULL == node)
+               return;
+
+       mmi_health_measure_timed_measure_start(* node);
+}
+
+void mmi_health_measure_timed_time_stamp_set(MMI_HEALTH_MEASURE_TYPE_E measure_type, uint32_t time_stamp)
+{
+       switch(measure_type)
+       {
+               case MMI_HEALTH_MEASURE_HEART:
+                       s_health_measure_heart_timed_time_stamp = time_stamp;
+                       break;
+
+               case MMI_HEALTH_MEASURE_TEMPERATURE:
+                       s_health_measure_temperature_timed_time_stamp = time_stamp;
+                       break;
+
+               case MMI_HEALTH_MEASURE_BLOOD:
+                       s_health_measure_blood_timed_time_stamp = time_stamp;
+                       break;
+                       
+               case MMI_HEALTH_MEASURE_SPO2:
+                       s_health_measure_spo2_timed_time_stamp = time_stamp;
+                       break;
+
+               default:
+                       break;
+       }
+}
+
+bool mmi_health_measure_heart_timed_action(bool direct_trigger, uint32_t cur_time_stamp)
+{
+       if(0 != s_health_measure_timed_data.heart_timed_flag)
+       {
+               if(true == direct_trigger 
+                       || s_health_measure_timed_data.heart_timed_interval <= (cur_time_stamp - s_health_measure_heart_timed_time_stamp))
+               {
+                       mmi_health_measure_timed_list_node_add(MMI_HEALTH_MEASURE_HEART);
+                       mmi_health_measure_timed_list_trigger();
+                       mmi_health_measure_timed_time_stamp_set(MMI_HEALTH_MEASURE_HEART, cur_time_stamp);
+
+                       return true;
+               }
+       }
+
+       return false;
+}
+
+bool mmi_health_measure_temperature_timed_action(bool direct_trigger, uint32_t cur_time_stamp)
+{
+       if(0 != s_health_measure_timed_data.temperature_timed_flag)
+       {
+               if(true == direct_trigger 
+                       || s_health_measure_timed_data.temperature_timed_interval <= (cur_time_stamp - s_health_measure_temperature_timed_time_stamp))
+               {
+                       mmi_health_measure_timed_list_node_add(MMI_HEALTH_MEASURE_TEMPERATURE);
+                       mmi_health_measure_timed_list_trigger();
+                       mmi_health_measure_timed_time_stamp_set(MMI_HEALTH_MEASURE_TEMPERATURE, cur_time_stamp);
+
+                       return true;
+               }
+       }
+
+       return false;
+}
+
+bool mmi_health_measure_blood_timed_action(bool direct_trigger, uint32_t cur_time_stamp)
+{
+       if(0 != s_health_measure_timed_data.blood_timed_flag)
+       {
+               if(true == direct_trigger 
+                       || s_health_measure_timed_data.blood_timed_interval <= (cur_time_stamp - s_health_measure_blood_timed_time_stamp))
+               {
+                       mmi_health_measure_timed_list_node_add(MMI_HEALTH_MEASURE_BLOOD);
+                       mmi_health_measure_timed_list_trigger();
+                       mmi_health_measure_timed_time_stamp_set(MMI_HEALTH_MEASURE_BLOOD, cur_time_stamp);
+
+                       return true;
+               }
+       }
+
+       return false;
+}
+
+bool mmi_health_measure_spo2_timed_action(bool direct_trigger, uint32_t cur_time_stamp)
+{
+       if(0 != s_health_measure_timed_data.spo2_timed_flag)
+       {
+               if(true == direct_trigger 
+                       || s_health_measure_timed_data.spo2_timed_interval <= (cur_time_stamp - s_health_measure_spo2_timed_time_stamp)
+                       )
+               {
+                       mmi_health_measure_timed_list_node_add(MMI_HEALTH_MEASURE_SPO2);
+                       mmi_health_measure_timed_list_trigger();
+                       mmi_health_measure_timed_time_stamp_set(MMI_HEALTH_MEASURE_SPO2, cur_time_stamp);
+
+                       return true;
+               }
+       }
+
+       return false;
+}
+
+void mmi_health_measure_server_set_save(MMI_HEALTH_MEASURE_TYPE_E measure_type, int value_interval)
+{
+       uint8_t flag = (0 == value_interval) ? 0 : 1;
+       uint32_t cur_time_stamp = 0;
+       
+       Hal_Rtc_Gettime_Count(&cur_time_stamp);
+       
+       switch(measure_type)
+       {
+               case MMI_HEALTH_MEASURE_HEART:
+                       s_health_measure_timed_data.heart_timed_flag = flag;
+                       if(1 == flag)
+                       {
+                               s_health_measure_timed_data.heart_timed_interval = value_interval;
+                               mmi_health_measure_timed_time_stamp_set(MMI_HEALTH_MEASURE_HEART, cur_time_stamp);
+                       }
+                       break;
+
+               case MMI_HEALTH_MEASURE_TEMPERATURE:
+                       s_health_measure_timed_data.temperature_timed_flag = flag;
+                       if(1 == flag)
+                       {
+                               s_health_measure_timed_data.temperature_timed_interval = value_interval;
+                               mmi_health_measure_timed_time_stamp_set(MMI_HEALTH_MEASURE_TEMPERATURE, cur_time_stamp);
+                       }
+                       break;
+
+               case MMI_HEALTH_MEASURE_BLOOD:
+                       s_health_measure_timed_data.blood_timed_flag = flag;
+                       if(1 == flag)
+                       {
+                               s_health_measure_timed_data.blood_timed_interval = value_interval;
+                               mmi_health_measure_timed_time_stamp_set(MMI_HEALTH_MEASURE_BLOOD, cur_time_stamp);
+                       }
+                       break;
+                       
+               case MMI_HEALTH_MEASURE_SPO2:
+                       s_health_measure_timed_data.spo2_timed_flag = flag;
+                       if(1 == flag)
+                       {
+                               s_health_measure_timed_data.spo2_timed_interval = value_interval;
+                               mmi_health_measure_timed_time_stamp_set(MMI_HEALTH_MEASURE_SPO2, cur_time_stamp);
+                       }
+                       break;
+
+               default:
+                       break;
+       }
+
+       mmi_health_measure_timed_info_nv_write();
+}
+
+void mmi_health_measure_server_set_action(MMI_HEALTH_MEASURE_TYPE_E measure_type, int value_interval)
+{
+       if(0 == value_interval) // close timed measure
+       {
+               mmi_health_measure_server_set_save(measure_type, value_interval);
+       }
+       else if(1 == value_interval) // measure once
+       {
+               mmi_health_measure_app_measure_start(measure_type);
+       }
+       else if(300 <= value_interval) // immediate timed measure
+       {
+               //mmi_health_measure_start(measure_type);
+               mmi_health_measure_server_set_save(measure_type, value_interval);
+       }
+       else
+       {
+               HEALTH_MEASURE_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: should not run to here\n", __FUNCTION__, __LINE__);
+       }
+}
+
+bool mmi_health_measure_heart_data_ui_get(uint16_t * heart_value)
+{
+       if(NULL != heart_value)
+               * heart_value = s_health_measure_run_data.heart_value;
+
+       return true;
+}
+
+bool mmi_health_measure_temperature_data_ui_get(float * body_value, float * wrist_value)
+{
+       if(NULL != body_value)
+               * body_value = s_health_measure_run_data.body_value;
+       if(NULL != wrist_value)
+               * wrist_value = s_health_measure_run_data.wrist_value;
+       
+       return true;
+}
+
+bool mmi_health_measure_blood_data_ui_get(uint16_t * blood_high_value, uint16_t * blood_low_value)
+{
+       if(NULL != blood_high_value)
+               * blood_high_value = s_health_measure_run_data.blood_high_value;
+       if(NULL != blood_low_value)
+               * blood_low_value = s_health_measure_run_data.blood_low_value;
+       
+       return true;
+}
+
+bool mmi_health_measure_spo2_data_ui_get(uint16_t * spo2_value)
+{
+       if(NULL != spo2_value)
+               * spo2_value = s_health_measure_run_data.spo2_value;
+
+       return true;
+}
+
+void mmi_health_measure_send_heart(void)
+{
+       uint16_t heart_value = s_health_measure_run_data.heart_value;
+
+       if(0 == heart_value)
+               return;
+       
+       mmi_protocol_action_send_heart(heart_value);
+
+       mmi_health_info_t health_info = {0};
+       mmi_health_info_get(&health_info);
+       health_info.heart_value = heart_value;
+       mmi_health_info_set(&health_info);
+}
+
+void mmi_health_measure_send_temperature(void)
+{
+       float body_value = s_health_measure_run_data.body_value;
+
+       if(0.0 == body_value)
+               return;
+       
+       mmi_protocol_action_send_temperature(body_value);
+
+       mmi_health_info_t health_info = {0};
+       mmi_health_info_get(&health_info);
+       health_info.body_value = body_value;
+       mmi_health_info_set(&health_info);
+}
+
+void mmi_health_measure_send_blood(void)
+{
+       uint16_t blood_high_value = s_health_measure_run_data.blood_high_value;
+       uint16_t blood_low_value = s_health_measure_run_data.blood_low_value;
+
+       if(0 == blood_high_value || 0 == blood_low_value)
+               return;
+       
+       mmi_protocol_action_send_blood(blood_high_value, blood_low_value);
+
+       mmi_health_info_t health_info = {0};
+       mmi_health_info_get(&health_info);
+       health_info.blood_high_value = blood_high_value;
+       health_info.blood_low_value = blood_low_value;
+       mmi_health_info_set(&health_info);
+}
+
+void mmi_health_measure_send_spo2(void)
+{
+       uint16_t spo2_value = s_health_measure_run_data.spo2_value;
+
+       if(0 == spo2_value)
+               return;
+       
+       mmi_protocol_action_send_spo2(spo2_value);
+
+       mmi_health_info_t health_info = {0};
+       mmi_health_info_get(&health_info);
+       health_info.spo2_value = spo2_value;
+       mmi_health_info_set(&health_info);
+}
+
+void mmi_health_measure_process_timer_stop(void)
+{
+       if(NULL != s_process_timer_id)
+       {
+               Hal_Timer_Stop(s_process_timer_id);
+               s_process_timer_id = NULL;
+       }
+}
+
+void mmi_health_measure_process_finish(void)
+{
+       s_health_measure_run_data.measure_state = MMI_HEALTH_MEASURE_STATE_FINISH;
+       s_measure_time_count = 0;
+       s_measure_time_total = 0;
+       
+       mmi_health_measure_process_timer_stop();
+       mmi_health_measure_timed_list_node_remove(s_health_measure_run_data.measure_type);
+
+       switch(s_health_measure_run_data.measure_type)
+       {
+               case MMI_HEALTH_MEASURE_HEART:
+                       mmi_hsensor_close();
+                       mmi_health_measure_send_heart();
+                       break;
+       
+               case MMI_HEALTH_MEASURE_TEMPERATURE:
+                       mmi_tsensor_close();
+                       mmi_health_measure_send_temperature();
+                       break;
+       
+               case MMI_HEALTH_MEASURE_BLOOD:
+                       mmi_hsensor_close();
+                       mmi_health_measure_send_blood();
+                       break;
+                       
+               case MMI_HEALTH_MEASURE_SPO2:
+                       mmi_hsensor_close();
+                       mmi_health_measure_send_spo2();
+                       break;
+       
+               default:
+                       break;
+       }
+
+       s_health_measure_run_data.measure_type = MMI_HEALTH_MEASURE_NONE;
+}
+
+void mmi_health_measure_process_timer_handle(void *para)
+{
+       if(false == mmi_health_measure_wear_state_get())
+       {
+               HEALTH_MEASURE_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: should not run to here\n", __FUNCTION__, __LINE__);
+               mmi_health_measure_interrupt();
+               return;
+       }
+       
+       s_measure_time_count++;
+       if(s_measure_time_total <= s_measure_time_count)
+       {
+               mmi_health_measure_process_finish();
+       }
+       else
+       {
+               switch(s_health_measure_run_data.measure_type)
+               {
+                       case MMI_HEALTH_MEASURE_HEART:
+                               mmi_health_measure_heart_data_process(&(s_health_measure_run_data.heart_value));
+                               break;
+
+                       case MMI_HEALTH_MEASURE_TEMPERATURE:
+                               mmi_health_measure_temperature_data_process(&(s_health_measure_run_data.body_value), &(s_health_measure_run_data.wrist_value));
+                               break;
+
+                       case MMI_HEALTH_MEASURE_BLOOD:
+                               mmi_health_measure_blood_data_process(&(s_health_measure_run_data.blood_high_value), &(s_health_measure_run_data.blood_low_value));
+                               break;
+
+                       case MMI_HEALTH_MEASURE_SPO2:
+                               mmi_health_measure_spo2_data_process(&(s_health_measure_run_data.spo2_value));
+                               break;
+
+                       default:
+                               break;
+               }
+       }
+}
+
+void mmi_health_measure_interrupt(void)
+{
+       s_health_measure_run_data.measure_state = MMI_HEALTH_MEASURE_STATE_ABNORMAL;
+       s_measure_time_count = 0;
+       s_measure_time_total = 0;
+       
+       mmi_health_measure_process_timer_stop();
+       mmi_health_measure_timed_list_node_remove(s_health_measure_run_data.measure_type);
+
+       switch(s_health_measure_run_data.measure_type)
+       {
+               case MMI_HEALTH_MEASURE_HEART:
+               case MMI_HEALTH_MEASURE_BLOOD:
+               case MMI_HEALTH_MEASURE_SPO2:
+                       mmi_hsensor_close();
+                       break;
+       
+               case MMI_HEALTH_MEASURE_TEMPERATURE:
+                       mmi_tsensor_close();
+                       break;
+               
+               default:
+                       break;
+       }
+       
+       s_health_measure_run_data.measure_type = MMI_HEALTH_MEASURE_NONE;
+}
+
+void mmi_health_measure_start(MMI_HEALTH_MEASURE_TYPE_E measure_type, uint32_t time_duration)
+{
+       if(0 == time_duration)
+       {
+               switch(measure_type)
+               {
+                       case MMI_HEALTH_MEASURE_HEART:
+                               s_measure_time_total = MMI_HEALTH_MEASURE_HEART_DURATION;
+                               mmi_hsensor_heart_open();
+                               break;
+
+                       case MMI_HEALTH_MEASURE_TEMPERATURE:
+                               s_measure_time_total = MMI_HEALTH_MEASURE_TEMPERATURE_DURATION;
+                               mmi_tsensor_open();
+                               break;
+
+                       case MMI_HEALTH_MEASURE_BLOOD:
+                               s_measure_time_total = MMI_HEALTH_MEASURE_BLOOD_DURATION;
+                               mmi_hsensor_blood_open();
+                               break;
+                               
+                       case MMI_HEALTH_MEASURE_SPO2:
+                               s_measure_time_total = MMI_HEALTH_MEASURE_SPO2_DURATION;
+                               mmi_hsensor_spo2_open();
+                               break;
+
+                       default:
+                               break;
+               }
+       }
+       else
+       {
+               s_measure_time_total = time_duration;
+       }
+
+       s_health_measure_run_data.measure_type = measure_type;
+       s_measure_time_count = 0;
+       s_process_timer_id = Hal_Timer_Start(1000 * 1, mmi_health_measure_process_timer_handle, NULL, true);
+}
+
+void mmi_health_measure_timed_measure_start(MMI_HEALTH_MEASURE_TYPE_E measure_type)
+{
+       if(MMI_HEALTH_MEASURE_STATE_UI == s_health_measure_run_data.measure_state
+               || MMI_HEALTH_MEASURE_STATE_APP == s_health_measure_run_data.measure_state
+               || MMI_HEALTH_MEASURE_STATE_TIMED == s_health_measure_run_data.measure_state
+               )
+       {
+               if(measure_type == s_health_measure_run_data.measure_type)
+               {
+                       mmi_health_measure_timed_list_node_remove(measure_type);
+               }
+
+               return;
+       }
+
+       _lv_memset_00(&s_health_measure_run_data, sizeof(s_health_measure_run_data));
+       s_health_measure_run_data.measure_state = MMI_HEALTH_MEASURE_STATE_TIMED;       
+       mmi_health_measure_start(measure_type, 0);
+}
+
+void mmi_health_measure_app_measure_start(MMI_HEALTH_MEASURE_TYPE_E measure_type)
+{
+       if(MMI_HEALTH_MEASURE_STATE_UI == s_health_measure_run_data.measure_state)
+       {
+               return;
+       }
+       
+       if(MMI_HEALTH_MEASURE_STATE_TIMED == s_health_measure_run_data.measure_state)
+       {
+               if(measure_type == s_health_measure_run_data.measure_type)
+               {
+                       return;
+               }
+               else
+               {
+                       mmi_health_measure_interrupt();
+               }
+       }
+
+       _lv_memset_00(&s_health_measure_run_data, sizeof(s_health_measure_run_data));
+       s_health_measure_run_data.measure_state = MMI_HEALTH_MEASURE_STATE_APP;
+       mmi_health_measure_start(measure_type, 0);
+}
+
+void mmi_health_measure_ui_measure_start(MMI_HEALTH_MEASURE_TYPE_E measure_type)
+{
+       if(MMI_HEALTH_MEASURE_STATE_APP == s_health_measure_run_data.measure_state
+               || MMI_HEALTH_MEASURE_STATE_TIMED == s_health_measure_run_data.measure_state
+               )
+       {
+               mmi_health_measure_interrupt();
+       }
+
+       _lv_memset_00(&s_health_measure_run_data, sizeof(s_health_measure_run_data));
+       s_health_measure_run_data.measure_state = MMI_HEALTH_MEASURE_STATE_UI;
+       mmi_health_measure_start(measure_type, 0);
+}
+
+
+
diff --git a/2.sdk/gui/lv_watch/lv_apps/health_measure/health_measure.h b/2.sdk/gui/lv_watch/lv_apps/health_measure/health_measure.h
new file mode 100644 (file)
index 0000000..47fc56d
--- /dev/null
@@ -0,0 +1,102 @@
+
+
+
+#ifndef __HEALTH_MEASURE_H__
+#define __HEALTH_MEASURE_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*********************
+ *      INCLUDES
+ *********************/
+
+#ifdef LV_CONF_INCLUDE_SIMPLE
+#include "lvgl.h"
+#include "lv_ex_conf.h"
+#else
+#include "../../../lvgl/lvgl.h"
+#include "../../../lv_ex_conf.h"
+#endif
+
+
+#define __HEALTH_MEASURE_DEBUG__
+#ifdef __HEALTH_MEASURE_DEBUG__
+#define HEALTH_MEASURE_DEBUG_PRINTF(fmt, ...)  printf("[HEALTH_MEASURE]"fmt, ##__VA_ARGS__)
+#else
+#define HEALTH_MEASURE_DEBUG_PRINTF(fmt, ...)
+#endif
+
+#define __HEALTH_MEASURE_FAKE_DATA__
+
+
+#define MMI_HEALTH_MEASURE_HEART_DURATION      (44 * 1000) // ms
+#define MMI_HEALTH_MEASURE_TEMPERATURE_DURATION        (24 * 1000) // ms
+#define MMI_HEALTH_MEASURE_BLOOD_DURATION      (34 * 1000) // ms
+#define MMI_HEALTH_MEASURE_SPO2_DURATION       (34 * 1000) // ms
+
+
+
+typedef enum
+{
+       MMI_HEALTH_MEASURE_NONE,
+       MMI_HEALTH_MEASURE_HEART,
+       MMI_HEALTH_MEASURE_TEMPERATURE,
+       MMI_HEALTH_MEASURE_BLOOD,
+       MMI_HEALTH_MEASURE_SPO2,
+       MMI_HEALTH_MEASURE_MAX,
+}MMI_HEALTH_MEASURE_TYPE_E;
+
+typedef enum
+{
+       MMI_HEALTH_MEASURE_STATE_NONE,
+       MMI_HEALTH_MEASURE_STATE_FINISH,
+       MMI_HEALTH_MEASURE_STATE_UI,
+       MMI_HEALTH_MEASURE_STATE_TIMED,
+       MMI_HEALTH_MEASURE_STATE_APP,
+       MMI_HEALTH_MEASURE_STATE_ABNORMAL,
+}MMI_HEALTH_MEASURE_STATE_E;
+
+
+typedef struct
+{
+       MMI_HEALTH_MEASURE_TYPE_E measure_type;
+       MMI_HEALTH_MEASURE_STATE_E measure_state;
+       uint16_t heart_value;
+       uint16_t blood_high_value;
+       uint16_t blood_low_value;
+       uint16_t spo2_value;
+       float wrist_value;
+       float body_value;
+       uint8_t is_wear;
+}lv_health_measure_run_t;
+
+
+bool mmi_health_measure_wear_state_get(void);
+MMI_HEALTH_MEASURE_STATE_E mmi_health_measure_state_get(void);
+
+bool mmi_health_measure_heart_data_ui_get(uint16_t * heart_value);
+bool mmi_health_measure_temperature_data_ui_get(float * body_value, float * wrist_value);
+bool mmi_health_measure_blood_data_ui_get(uint16_t * blood_high_value, uint16_t * blood_low_value);
+bool mmi_health_measure_spo2_data_ui_get(uint16_t * spo2_value);
+
+void mmi_health_measure_interrupt(void);
+
+void mmi_health_measure_timed_measure_start(MMI_HEALTH_MEASURE_TYPE_E measure_type);
+void mmi_health_measure_app_measure_start(MMI_HEALTH_MEASURE_TYPE_E measure_type);
+void mmi_health_measure_ui_measure_start(MMI_HEALTH_MEASURE_TYPE_E measure_type);
+
+void mmi_health_measure_timed_info_init(void);
+bool mmi_health_measure_heart_timed_action(bool direct_trigger, uint32_t cur_time_stamp);
+bool mmi_health_measure_temperature_timed_action(bool direct_trigger, uint32_t cur_time_stamp);
+bool mmi_health_measure_blood_timed_action(bool direct_trigger, uint32_t cur_time_stamp);
+bool mmi_health_measure_spo2_timed_action(bool direct_trigger, uint32_t cur_time_stamp);
+
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif
+
index 084cb68..90a4d75 100644 (file)
 #include <stdio.h>
 
 
-
-void health_spo2_sensor_open(void)
-{
-
-}
-
-void health_spo2_sensor_close(void)
-{
-
-}
-
-uint16 health_spo2_sensor_value_get(void)
-{
-       srand(Hal_Timer_Get_Counter());
-    uint16 value = 95 + rand() % 6;
-       
-       return value;
-}
-
-BOOL health_spo2_sensor_wear_state_get(void)
-{
-       BOOL is_wear = TRUE;
-
-       return is_wear;
-}
-
 lv_spo2_obj_ext_t * health_spo2_get_ext(void)
 {
     lv_obj_t * activity_obj = lv_watch_get_activity_obj(ACT_ID_HEALTH_MEASURE_SPO2);
@@ -63,7 +37,7 @@ void health_spo2_display_update(void)
                return;
        }
 
-       SPO2_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+       HEALTH_MEASURE_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
 
        switch(ext->measure_state)
        {
@@ -116,73 +90,62 @@ static void health_spo2_measure_cycle_timeout(void * para)
        lv_spo2_obj_ext_t * ext = health_spo2_get_ext();
     if(NULL != ext) 
        {
-               if(FALSE == health_spo2_sensor_wear_state_get())
+               if(FALSE == mmi_health_measure_wear_state_get())
                {
                        if(NULL != ext->cycle_timer_id)
                        {
                                Hal_Timer_Stop(ext->cycle_timer_id);
                                ext->cycle_timer_id = NULL;
                        }
-                       if(NULL != ext->total_timer_id)
-                       {
-                               Hal_Timer_Stop(ext->total_timer_id);
-                               ext->total_timer_id = NULL;
-                       }
                        if(NULL != ext->gif_info)
                        {
                                gif_close(ext->gif_info);
                                ext->gif_info = NULL;
                        }
                        lv_obj_del(ext->gif_cont);
+
+                       if(STATE_SPO2_MEASURING == ext->measure_state)
+                       {
+                               mmi_health_measure_interrupt();
+                       }
                        ext->measure_state = STATE_SPO2_MEASURE_FAIL;
                        watch_set_suspend_enable(true, ACT_ID_HEALTH_MEASURE_SPO2, 0);
                }
                else
                {
-                       uint16 value = health_spo2_sensor_value_get();
-                       if(value)
+                       if(MMI_HEALTH_MEASURE_STATE_UI == mmi_health_measure_state_get())
                        {
-                               sprintf(ext->spo2, "%d %%", value);
+                               uint16 value = 0;
+                               
+                               mmi_health_measure_spo2_data_ui_get(&value);
+                               if(value)
+                               {
+                                       sprintf(ext->spo2, "%d %%", value);
+                               }
+                               //else
+                               //{
+                               //      sprintf(ext->spo2, "-- %%");
+                               //}
+                               ext->measure_state = STATE_SPO2_MEASURING;
+                       }
+                       else
+                       {
+                               if(NULL != ext->cycle_timer_id)
+                               {
+                                       Hal_Timer_Stop(ext->cycle_timer_id);
+                                       ext->cycle_timer_id = NULL;
+                               }
+                               if(NULL != ext->gif_info)
+                               {
+                                       gif_close(ext->gif_info);
+                                       ext->gif_info = NULL;
+                               }
+                               lv_obj_del(ext->gif_cont);
+               
+                               ext->measure_state = STATE_SPO2_MEASURE_DONE;
+                               watch_set_suspend_enable(true, ACT_ID_HEALTH_MEASURE_SPO2, 0);
                        }
-                       //else
-                       //{
-                       //      sprintf(ext->spo2, "-- %%");
-                       //}
-                       ext->measure_state = STATE_SPO2_MEASURING;
-               }
-    }
-
-       health_spo2_display_update();
-}
-
-static void health_spo2_measure_timeout(void * para)
-{
-    (void) para;
-
-       //sensor
-       health_spo2_sensor_close();
-
-       lv_spo2_obj_ext_t * ext = health_spo2_get_ext();
-    if(ext) 
-       {
-               if(NULL != ext->cycle_timer_id)
-               {
-                       Hal_Timer_Stop(ext->cycle_timer_id);
-                       ext->cycle_timer_id = NULL;
-               }
-               if(NULL != ext->total_timer_id)
-               {
-                       Hal_Timer_Stop(ext->total_timer_id);
-                       ext->total_timer_id = NULL;
-               }
-               if(NULL != ext->gif_info)
-               {
-                       gif_close(ext->gif_info);
-                       ext->gif_info = NULL;
                }
-               lv_obj_del(ext->gif_cont);
-               ext->measure_state = STATE_SPO2_MEASURE_DONE;
-               watch_set_suspend_enable(true, ACT_ID_HEALTH_MEASURE_SPO2, 0);
     }
 
        health_spo2_display_update();
@@ -203,18 +166,18 @@ static void health_spo2_prepare_destory(lv_obj_t * activity_obj)
                        Hal_Timer_Stop(ext->cycle_timer_id);
                        ext->cycle_timer_id = NULL;
                }
-               if(NULL != ext->total_timer_id)
-               {
-                       Hal_Timer_Stop(ext->total_timer_id);
-                       ext->total_timer_id = NULL;
-               }
                if(NULL != ext->gif_info)
                {
                        gif_close(ext->gif_info);
                        ext->gif_info = NULL;
                }
 
-               SPO2_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               if(STATE_SPO2_MEASURING == ext->measure_state)
+               {
+                       mmi_health_measure_interrupt();
+               }
+
+               HEALTH_MEASURE_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
        }
 }
 
@@ -277,14 +240,14 @@ lv_obj_t * health_spo2_create(lv_obj_t * activity_obj)
        lv_obj_set_click(label_value, false);
        ext->label_value = label_value;
 
-       if(FALSE == health_spo2_sensor_wear_state_get())
+       if(false == mmi_health_measure_wear_state_get())
        {
                ext->measure_state = STATE_SPO2_MEASURE_FAIL;
                watch_set_suspend_enable(true, ACT_ID_HEALTH_MEASURE_SPO2, 0);
        }
        else
        {
-               health_spo2_sensor_open();
+               mmi_health_measure_ui_measure_start(MMI_HEALTH_MEASURE_SPO2);
 
                lv_obj_t * gif_cont = lv_cont_create(cont, NULL);
                lv_obj_set_size(gif_cont, LV_HOR_RES, 120);
@@ -295,10 +258,9 @@ lv_obj_t * health_spo2_create(lv_obj_t * activity_obj)
                ext->gif_info = gif_open(gif_cont, ANIM_SPO2_MEASURING, 0);
                if(!ext->gif_info) 
                {
-                       SPO2_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: gif open fail\n", __FUNCTION__, __LINE__);
+                       HEALTH_MEASURE_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: gif open fail\n", __FUNCTION__, __LINE__);
                }
                
-               ext->total_timer_id = Hal_Timer_Start(HEALTH_SPO2_MEASURE_DURATION, health_spo2_measure_timeout, NULL, FALSE);
                ext->cycle_timer_id = Hal_Timer_Start(HEALTH_SPO2_MEASURE_CYCLE, health_spo2_measure_cycle_timeout, NULL, TRUE);
        
                ext->measure_state = STATE_SPO2_MEASURING;
index 10dc316..2ae5147 100644 (file)
@@ -23,15 +23,6 @@ extern "C" {
 #ifdef __MMI_HEALTH_MEASURE_SPO2_SUPPORT__
 
 
-#define __HEALTH_SPO2_DEBUG__
-#ifdef __HEALTH_SPO2_DEBUG__
-#define SPO2_DEBUG_PRINTF(fmt, ...)    printf(fmt, ##__VA_ARGS__)
-#else
-#define SPO2_DEBUG_PRINTF(fmt, ...)
-#endif
-
-
-#define HEALTH_SPO2_MEASURE_DURATION           (1000 * 40) // 40 sec
 #define HEALTH_SPO2_MEASURE_CYCLE              (1000 * 1)
 
 
@@ -60,11 +51,12 @@ typedef enum
        STATE_SPO2_MEASURE_MAX,
 }lv_spo2_state_e;
 
-typedef struct {
+typedef struct 
+{
        lv_watch_obj_ext_t lv_watch_obj;
 
        gif_info_t * gif_info;
-       TIMER_ID total_timer_id, cycle_timer_id;
+       TIMER_ID cycle_timer_id;
        lv_obj_t * cont;
        lv_obj_t * img;
        lv_obj_t * label_info;
index 983c1d8..f6e1e5c 100644 (file)
 #include <stdio.h>
 
 
+#if 1
+lv_temperature_obj_ext_t * health_temperature_get_ext(void)
+{
+    lv_obj_t * activity_obj = lv_watch_get_activity_obj(ACT_ID_HEALTH_MEASURE_TEMPERATURE);
+    if(NULL == activity_obj)
+       {
+               return NULL;
+       }
+
+    lv_obj_t * watch_obj;
+    lv_watch_get_child_obj(activity_obj, lv_watch_obj_signal, &watch_obj);
+    if(NULL != watch_obj) 
+       {
+        lv_temperature_obj_ext_t * ext = lv_obj_get_ext_attr(watch_obj);
+        return ext;
+    }
+    return NULL;
+}
 
-void health_temperature_sensor_open(void)
+void health_temperature_display_update(void)
 {
+       lv_temperature_obj_ext_t * ext = health_temperature_get_ext();
+       if(NULL == ext)
+       {
+               return;
+       }
 
+       switch(ext->measure_state)
+       {
+               case STATE_TEMPERATURE_MEASURING:
+                       lv_obj_set_hidden(ext->img, TRUE);
+
+                       lv_label_set_text_id(ext->label_info, WATCH_TEXT_ID_MEASURING);
+                       lv_obj_align(ext->label_info, ext->cont, LV_ALIGN_IN_TOP_MID, 0, TEMPERATURE_LABEL_INFO_Y);
+
+                       lv_label_set_text(ext->label_value, ext->body_value);
+                       lv_obj_align(ext->label_value, ext->cont, LV_ALIGN_IN_TOP_MID, 0, TEMPERATURE_LABEL_VALUE_Y);
+                       lv_obj_set_hidden(ext->label_value, ((strlen(ext->body_value)) ? FALSE : TRUE));
+                       break;
+
+               case STATE_TEMPERATURE_MEASURE_FAIL:
+                       lv_img_set_src(ext->img, ICON_TEMPERATURE_MEASURE_FAIL);
+                       lv_obj_set_hidden(ext->img, FALSE);
+
+                       lv_label_set_text_id(ext->label_info, WATCH_TEXT_ID_MEASURE_FAIL);
+                       lv_obj_align(ext->label_info, ext->cont, LV_ALIGN_IN_TOP_MID, 0, TEMPERATURE_LABEL_INFO_Y);
+
+                       lv_obj_remove_style(ext->label_value, LV_LABEL_PART_MAIN, &lv_watch_font40);
+                       lv_obj_add_style(ext->label_value, LV_LABEL_PART_MAIN, &lv_watch_font30);
+                       lv_label_set_text_id(ext->label_value, WATCH_TEXT_ID_NOT_WEAR);
+                       lv_obj_align(ext->label_value, ext->cont, LV_ALIGN_IN_TOP_MID, 0, TEMPERATURE_LABEL_VALUE_Y);
+                       lv_obj_set_hidden(ext->label_value, FALSE);
+                       break;
+
+               case STATE_TEMPERATURE_MEASURE_DONE:
+                       lv_img_set_src(ext->img, ICON_TEMPERATURE_MEASURE_DONE);
+                       lv_obj_set_hidden(ext->img, FALSE);
+
+                       lv_label_set_text_id(ext->label_info, WATCH_TEXT_ID_MEASURE_DONE);
+                       lv_obj_align(ext->label_info, ext->cont, LV_ALIGN_IN_TOP_MID, 0, TEMPERATURE_LABEL_INFO_Y);
+
+                       lv_label_set_text(ext->label_value, ext->body_value);
+                       lv_obj_align(ext->label_value, ext->cont, LV_ALIGN_IN_TOP_MID, 0, TEMPERATURE_LABEL_VALUE_Y);
+                       lv_obj_set_hidden(ext->label_value, FALSE);
+                       break;
+
+               default:
+                       break;
+       }
 }
 
-void health_temperature_sensor_close(void)
+static void health_temperature_measure_cycle_timeout(void * para)
 {
+    (void) para;
+
+       lv_temperature_obj_ext_t * ext = health_temperature_get_ext();
+    if(NULL != ext) 
+       {
+               if(false == mmi_health_measure_wear_state_get())
+               {
+                       if(NULL != ext->cycle_timer_id)
+                       {
+                               Hal_Timer_Stop(ext->cycle_timer_id);
+                               ext->cycle_timer_id = NULL;
+                       }
+                       if(NULL != ext->gif_info)
+                       {
+                               gif_close(ext->gif_info);
+                               ext->gif_info = NULL;
+                       }
+                       lv_obj_del(ext->gif_cont);
+
+                       if(STATE_TEMPERATURE_MEASURING == ext->measure_state)
+                       {
+                               mmi_health_measure_interrupt();
+                       }
+                       ext->measure_state = STATE_TEMPERATURE_MEASURE_FAIL;
+                       watch_set_suspend_enable(true, ACT_ID_HEALTH_MEASURE_TEMPERATURE, 0);
+               }
+               else
+               {
+                       if(MMI_HEALTH_MEASURE_STATE_UI == mmi_health_measure_state_get())
+                       {
+                               float value = 0.0;
+                               
+                               mmi_health_measure_temperature_data_ui_get(&value, NULL);
+                               if(value)
+                               {
+                                       sprintf(ext->body_value, "%.1f %s", value, lang_get_text_by_id(WATCH_TEXT_ID_TEMPERATURE_UNIT)); // 0x2103
+                               }
+                               ext->measure_state = STATE_TEMPERATURE_MEASURING;
+                       }
+                       else
+                       {
+                               if(NULL != ext->cycle_timer_id)
+                               {
+                                       Hal_Timer_Stop(ext->cycle_timer_id);
+                                       ext->cycle_timer_id = NULL;
+                               }
+                               if(NULL != ext->gif_info)
+                               {
+                                       gif_close(ext->gif_info);
+                                       ext->gif_info = NULL;
+                               }
+                               lv_obj_del(ext->gif_cont);
+                               ext->measure_state = STATE_TEMPERATURE_MEASURE_DONE;
+                               watch_set_suspend_enable(true, ACT_ID_HEALTH_MEASURE_TEMPERATURE, 0);
+                       }
+               }
+    }
 
+       health_temperature_display_update();
 }
 
-void health_temperature_sensor_value_get(float * body_value, float * wrist_value)
+static void health_temperature_prepare_destory(lv_obj_t * activity_obj)
 {
-       srand(Hal_Timer_Get_Counter());
-    float value = 36.0 + rand() % 4 * 0.1;
+       HEALTH_MEASURE_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+       
+    watch_set_suspend_enable(true, ACT_ID_HEALTH_MEASURE_TEMPERATURE, 0);
+    lv_watch_png_cache_all_free();
        
-       * body_value = value;
-       * wrist_value = value - 10;
+    //lv_obj_t * watch_obj = NULL;
+    //lv_watch_get_child_obj(act, lv_watch_obj_signal, &watch_obj);
+    //lv_obj_t * cont = lv_obj_get_child(watch_obj, NULL);
+
+       lv_temperature_obj_ext_t * ext = health_temperature_get_ext();
+    if(NULL != ext) 
+       {
+               if(NULL != ext->cycle_timer_id)
+               {
+                       Hal_Timer_Stop(ext->cycle_timer_id);
+                       ext->cycle_timer_id = NULL;
+               }
+               if(NULL != ext->gif_info)
+               {
+                       gif_close(ext->gif_info);
+                       ext->gif_info = NULL;
+               }
+               if(STATE_TEMPERATURE_MEASURING == ext->measure_state)
+               {
+                       mmi_health_measure_interrupt();
+               }
+
+               HEALTH_MEASURE_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+       }
 }
 
-BOOL health_temperature_sensor_wear_state_get(void)
+lv_obj_t * health_temperature_create(lv_obj_t * activity_obj)
 {
-       BOOL is_wear = TRUE;
+    if(NULL == activity_obj) 
+       {
+        lv_watch_activity_ext_t activity_ext = {0};
+               
+        activity_ext.actId = ACT_ID_HEALTH_MEASURE_TEMPERATURE;
+        activity_ext.create = health_temperature_create;
+        activity_ext.prepare_destory = health_temperature_prepare_destory;
+               
+        activity_obj = lv_watch_creat_activity_obj(&activity_ext);
+        LV_ASSERT_MEM(activity_obj);
+        if(NULL == activity_obj) 
+                       return NULL;
+    }
+
+    lv_obj_t * watch_obj = lv_watch_obj_create(activity_obj);
+    if(NULL == watch_obj)
+        return NULL;
+
+       lv_temperature_obj_ext_t * ext = lv_obj_allocate_ext_attr(watch_obj, sizeof(lv_temperature_obj_ext_t));
+    if(NULL == ext)
+        return NULL;
+
+       _lv_memset_00(ext->body_value, sizeof(ext->body_value));
 
-       return is_wear;
+       lv_obj_t * cont = lv_cont_create(watch_obj, NULL);
+       lv_obj_set_size(cont, LV_HOR_RES, LV_VER_RES);
+       lv_obj_align(cont, watch_obj, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
+       lv_obj_set_style_local_bg_color(cont, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
+       lv_obj_set_style_local_bg_opa(cont, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_TRANSP);
+       lv_obj_set_style_local_pad_left(cont, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, 0);
+       lv_obj_set_style_local_pad_right(cont, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, 0);
+       //lv_cont_set_layout(cont, LV_LAYOUT_ROW_MID);
+       lv_obj_set_click(cont, false);
+    //lv_obj_set_base_dir(cont, LV_BIDI_DIR_LTR);
+       lv_watch_obj_add_element(cont);
+       ext->cont = cont;
+
+       lv_obj_t * img = lv_img_create(cont, NULL);
+       lv_img_set_src(img, ICON_TEMPERATURE_MEASURE_FAIL);
+    lv_obj_align(img, NULL, LV_ALIGN_IN_TOP_MID, 0, 40);
+       lv_obj_set_hidden(img, true);
+       ext->img = img;
+
+       lv_obj_t * label_info = lv_label_create(cont, NULL);
+    //lv_obj_set_size(label_info, LV_HOR_RES, 30);
+       lv_obj_add_style(label_info, LV_LABEL_PART_MAIN, &lv_watch_font20);
+       lv_label_set_text_id(label_info, WATCH_TEXT_ID_MEASURING);
+    //lv_label_set_align(label_info, LV_LABEL_ALIGN_CENTER);
+    lv_obj_align(label_info, cont, LV_ALIGN_IN_TOP_MID, 0, TEMPERATURE_LABEL_INFO_Y);
+    lv_obj_set_click(label_info, false);
+       ext->label_info = label_info;
+
+       lv_obj_t * label_value = lv_label_create(cont, NULL);
+    //lv_obj_set_size(label_value, LV_HOR_RES, 40);
+       lv_obj_add_style(label_value, LV_LABEL_PART_MAIN, &lv_watch_font40);
+       lv_label_set_text(label_value, ext->body_value);
+    //lv_label_set_align(label_value, LV_LABEL_ALIGN_CENTER);
+    lv_obj_align(label_value, cont, LV_ALIGN_IN_TOP_MID, 0, TEMPERATURE_LABEL_VALUE_Y);
+       lv_obj_set_click(label_value, false);
+       ext->label_value = label_value;
+
+       if(false == mmi_health_measure_wear_state_get())
+       {
+               ext->measure_state = STATE_TEMPERATURE_MEASURE_FAIL;
+               watch_set_suspend_enable(true, ACT_ID_HEALTH_MEASURE_TEMPERATURE, 0);
+       }
+       else
+       {
+               mmi_health_measure_ui_measure_start(MMI_HEALTH_MEASURE_TEMPERATURE);
+
+               lv_obj_t * gif_cont = lv_cont_create(cont, NULL);
+               lv_obj_set_size(gif_cont, LV_HOR_RES, 120);
+               lv_obj_set_style_local_bg_color(gif_cont, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
+               lv_obj_align(gif_cont, cont, LV_ALIGN_IN_TOP_MID, 0, 40);
+               ext->gif_cont = gif_cont;
+
+               ext->gif_info = gif_open(gif_cont, ANIM_TEMPERATURE_MEASURING, 0);
+               if(!ext->gif_info) 
+               {
+                       HEALTH_MEASURE_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: gif open fail\n", __FUNCTION__, __LINE__);
+               }
+               
+               ext->cycle_timer_id = Hal_Timer_Start(TEMPERATURE_MEASURE_CYCLE, health_temperature_measure_cycle_timeout, NULL, TRUE);
+       
+               ext->measure_state = STATE_TEMPERATURE_MEASURING;
+               watch_set_suspend_enable(false, ACT_ID_HEALTH_MEASURE_TEMPERATURE, 0);
+       }
+       
+       health_temperature_display_update();
+
+    return watch_obj;
 }
 
+void health_temperature_create_event_cb(lv_obj_t * btn, lv_event_t e)
+{
+    (void)btn;
+       
+    if(LV_EVENT_CLICKED == e) 
+       {
+        lv_obj_t * obj = health_temperature_create(NULL);
+        LV_ASSERT_MEM(obj);
+    }
+}
+
+#else
+
 lv_temperature_obj_ext_t * health_temperature_get_ext(void)
 {
     lv_obj_t * activity_obj = lv_watch_get_activity_obj(ACT_ID_HEALTH_MEASURE_TEMPERATURE);
@@ -102,17 +350,16 @@ static void health_temperature_measure_cycle_timeout(void * para)
        lv_temperature_obj_ext_t * ext = health_temperature_get_ext();
     if(ext) 
        {
-               if(FALSE == health_temperature_sensor_wear_state_get())
+               if(false == mmi_health_measure_wear_state_get())
                {
                        if(NULL != ext->cycle_timer_id)
                        {
                                Hal_Timer_Stop(ext->cycle_timer_id);
                                ext->cycle_timer_id = NULL;
                        }
-                       if(NULL != ext->total_timer_id)
+                       if(STATE_TEMPERATURE_MEASURING == ext->measure_state)
                        {
-                               Hal_Timer_Stop(ext->total_timer_id);
-                               ext->total_timer_id = NULL;
+                               mmi_health_measure_interrupt();
                        }
 
                        ext->measure_state = STATE_TEMPERATURE_MEASURE_FAIL;
@@ -120,55 +367,42 @@ static void health_temperature_measure_cycle_timeout(void * para)
                }
                else
                {
-                       float body_value, wrist_value;
-                       health_temperature_sensor_value_get(&body_value, &wrist_value);
-                       if(body_value)
+                       if(MMI_HEALTH_MEASURE_STATE_UI == mmi_health_measure_state_get())
                        {
-                               sprintf(ext->body_value, "%.1f C", body_value);
+                               float body_value = 0.0, wrist_value = 0.0;
+                               
+                               mmi_health_measure_temperature_data_ui_get(&body_value, &wrist_value);
+                               if(body_value)
+                               {
+                                       sprintf(ext->body_value, "%.1f C", body_value);
+                               }
+                               if(wrist_value)
+                               {
+                                       sprintf(ext->wrist_value, "%.1f C", wrist_value);
+                               }
+
+                               ext->measure_state = STATE_TEMPERATURE_MEASURING;
                        }
-                       if(wrist_value)
+                       else
                        {
-                               sprintf(ext->wrist_value, "%.1f C", wrist_value);
+                               if(NULL != ext->cycle_timer_id)
+                               {
+                                       Hal_Timer_Stop(ext->cycle_timer_id);
+                                       ext->cycle_timer_id = NULL;
+                               }
+               
+                               ext->measure_state = STATE_TEMPERATURE_MEASURE_DONE;
+                               watch_set_suspend_enable(true, ACT_ID_HEALTH_MEASURE_TEMPERATURE, 0);
                        }
-
-                       ext->measure_state = STATE_TEMPERATURE_MEASURING;
                }
     }
 
        health_temperature_display_update();
 }
 
-static void health_temperature_measure_timeout(void * para)
-{
-    (void) para;
-
-       //sensor
-       health_temperature_sensor_close();
-
-       lv_temperature_obj_ext_t * ext = health_temperature_get_ext();
-    if(ext) 
-       {
-               if(NULL != ext->cycle_timer_id)
-               {
-                       Hal_Timer_Stop(ext->cycle_timer_id);
-                       ext->cycle_timer_id = NULL;
-               }
-               if(NULL != ext->total_timer_id)
-               {
-                       Hal_Timer_Stop(ext->total_timer_id);
-                       ext->total_timer_id = NULL;
-               }
-
-               ext->measure_state = STATE_TEMPERATURE_MEASURE_DONE;
-               watch_set_suspend_enable(true, ACT_ID_HEALTH_MEASURE_TEMPERATURE, 0);
-    }
-
-       health_temperature_display_update();
-}
-
 static void health_temperature_prepare_destory(lv_obj_t * activity_obj)
 {
-       TEMPERATURE_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+       HEALTH_MEASURE_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
        
     watch_set_suspend_enable(true, ACT_ID_HEALTH_MEASURE_TEMPERATURE, 0);
     lv_watch_png_cache_all_free();
@@ -185,13 +419,12 @@ static void health_temperature_prepare_destory(lv_obj_t * activity_obj)
                        Hal_Timer_Stop(ext->cycle_timer_id);
                        ext->cycle_timer_id = NULL;
                }
-               if(NULL != ext->total_timer_id)
+               if(STATE_TEMPERATURE_MEASURING == ext->measure_state)
                {
-                       Hal_Timer_Stop(ext->total_timer_id);
-                       ext->total_timer_id = NULL;
+                       mmi_health_measure_interrupt();
                }
 
-               TEMPERATURE_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               HEALTH_MEASURE_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
        }
 }
 
@@ -276,18 +509,17 @@ lv_obj_t * health_temperature_create(lv_obj_t * activity_obj)
     lv_obj_align(ext->label_prompt_info, cont, LV_ALIGN_IN_BOTTOM_MID, 0, -70);
     lv_obj_set_click(ext->label_prompt_info, false);
 
-       if(FALSE == health_temperature_sensor_wear_state_get())
+       if(false == mmi_health_measure_wear_state_get())
        {
                ext->measure_state = STATE_TEMPERATURE_MEASURE_FAIL;
                watch_set_suspend_enable(true, ACT_ID_HEALTH_MEASURE_TEMPERATURE, 0);
        }
        else
        {
-               health_temperature_sensor_open();
+               mmi_health_measure_ui_measure_start(MMI_HEALTH_MEASURE_TEMPERATURE);
 
-               TEMPERATURE_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               HEALTH_MEASURE_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
                
-               ext->total_timer_id = Hal_Timer_Start(TEMPERATURE_MEASURE_DURATION, health_temperature_measure_timeout, NULL, FALSE);
                ext->cycle_timer_id = Hal_Timer_Start(TEMPERATURE_MEASURE_CYCLE, health_temperature_measure_cycle_timeout, NULL, TRUE);
        
                ext->measure_state = STATE_TEMPERATURE_MEASURING;
@@ -308,6 +540,6 @@ void health_temperature_create_event_cb(lv_obj_t * btn, lv_event_t e)
         LV_ASSERT_MEM(obj);
     }
 }
-
+#endif
 
 #endif
index 3948c48..dadd44a 100644 (file)
@@ -23,18 +23,26 @@ extern "C" {
 #ifdef __MMI_HEALTH_MEASURE_TEMPERATURE_SUPPORT__
 
 
-#define __HEALTH_TEMPERATURE_DEBUG__
-#ifdef __HEALTH_TEMPERATURE_DEBUG__
-#define TEMPERATURE_DEBUG_PRINTF(fmt, ...)     printf(fmt, ##__VA_ARGS__)
-#else
-#define TEMPERATURE_DEBUG_PRINTF(fmt, ...)
-#endif
+#define TEMPERATURE_MEASURE_CYCLE              (1000 * 1)
 
 
-#define TEMPERATURE_MEASURE_DURATION           (1000 * 30) // 30 sec
-#define TEMPERATURE_MEASURE_CYCLE              (1000 * 1)
+#if 1
+#if USE_LV_WATCH_UI_240_320
+#define TEMPERATURE_LABEL_INFO_X               (0)
+#define TEMPERATURE_LABEL_INFO_Y               (180)
+#define TEMPERATURE_LABEL_INFO_W               (LV_HOR_RES - TEMPERATURE_LABEL_INFO_X)
+#define TEMPERATURE_LABEL_INFO_H               (30)
 
+#define TEMPERATURE_LABEL_VALUE_X              (0)
+#define TEMPERATURE_LABEL_VALUE_Y              (220)
+#define TEMPERATURE_LABEL_VALUE_W              (LV_HOR_RES - TEMPERATURE_LABEL_VALUE_X)
+#define TEMPERATURE_LABEL_VALUE_H              (50)
 
+#else
+
+#endif
+
+#else
 #if USE_LV_WATCH_UI_240_320
 #define TEMPERATURE_LABEL_BODY_INFO_X          (75)
 #define TEMPERATURE_LABEL_BODY_INFO_Y          (35)
@@ -58,6 +66,7 @@ extern "C" {
 #else
 
 #endif
+#endif
 
 
 typedef enum
@@ -69,11 +78,27 @@ typedef enum
        STATE_TEMPERATURE_MEASURE_MAX,
 }lv_temperature_state_e;
 
+#if 1
+typedef struct 
+{
+       lv_watch_obj_ext_t lv_watch_obj;
+
+       gif_info_t * gif_info;
+       TIMER_ID cycle_timer_id;
+       lv_obj_t * cont;
+       lv_obj_t * img;
+       lv_obj_t * label_info;
+       lv_obj_t * label_value;
+       lv_obj_t * gif_cont;
+       lv_spo2_state_e measure_state;
+       char body_value[8];
+} lv_temperature_obj_ext_t;
+#else
 typedef struct {
        lv_watch_obj_ext_t lv_watch_obj;
 
        //gif_info_t * gif_info;
-       TIMER_ID total_timer_id, cycle_timer_id;
+       TIMER_ID cycle_timer_id;
        lv_obj_t * label_prompt_info;
        lv_obj_t * label_body_value;
        lv_obj_t * label_wrist_value;
@@ -81,7 +106,7 @@ typedef struct {
        char body_value[8];
        char wrist_value[8];
 } lv_temperature_obj_ext_t;
-
+#endif
 
 
 void health_temperature_create_event_cb(lv_obj_t * btn, lv_event_t e);
index 1d730a9..3d7e962 100644 (file)
@@ -1070,4 +1070,35 @@ static lv_obj_t * phonebook_create(lv_obj_t * activity_obj)
     return obj;
 }
 
+#ifdef __MMI_ZHSX_SUPPORT__
+void mmi_phonebook_contact_list_set(app_adaptor_contact_t * contact_list, uint8_t count)
+{
+    if(NULL == contact_list) 
+       {
+        printf("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+        return;
+    }
+
+    nv_watch_phonebook_t * nvm_contact_list = phonebook_read_nvm();
+       uint8_t i = 0;
+
+       _lv_memset_00(nvm_contact_list, sizeof(nv_watch_phonebook_t));
+
+       if(NV_WATCH_MAX_CONTACT_NUM <= count)
+               count = NV_WATCH_MAX_CONTACT_NUM;
+       
+       for(i = 0; i < count; i++)
+       {
+               phonebook_copy_contact(&(nvm_contact_list->info[i]), &(contact_list[i]));
+       }
+
+    phonebook_write_nvm(nvm_contact_list);
+
+    phonebook_update_ui(contact_list, count, 0, 0);
+
+    lv_mem_free(nvm_contact_list);
+}
+#endif
+
+
 #endif /*USE_LV_WATCH_PHONEBOOK*/
index 6df9b18..7f36403 100644 (file)
@@ -67,9 +67,11 @@ void phonebook_init(void);
 void phonebook_create_btn_event_cb(lv_obj_t * btn, lv_event_t e);
 phonebook_contact_t * phonebook_get_contact_info(char * number);
 char * phonebook_get_phone_number(uint8_t id); /*[0, NV_WATCH_MAX_CONTACT_NUM - 1]*/
-/**********************
- *      MACROS
- **********************/
+
+#ifdef __MMI_ZHSX_SUPPORT__
+void mmi_phonebook_contact_list_set(app_adaptor_contact_t * contact_list, uint8_t count);
+#endif
+
 
 #endif /*USE_LV_WATCH_PHONEBOOK*/
 
index c6abc50..df9b8c3 100644 (file)
@@ -289,4 +289,17 @@ void restart_no_btn_action(lv_obj_t * btn, lv_event_t event)
  *   STATIC FUNCTIONS
  **********************/
 
+
+#ifdef __MMI_ZHSX_SUPPORT__
+void mmi_watch_restart(void)
+{
+       lv_watch_go_home();
+#if USE_LV_BLUETOOTH != 0
+       bt_power_off();
+#endif
+       dial_poweroff();
+       play_anim_power_off();
+}
+#endif
+
 #endif /*USE_LV_WATCH_RESTART_AND_RESET*/
index c20af2b..bf09fac 100644 (file)
@@ -41,6 +41,10 @@ void restart_yes_btn_action(lv_obj_t * btn, lv_event_t event);
 void restart_no_btn_action(lv_obj_t * btn, lv_event_t event);
 uint8_t play_anim_power_off(void);
 
+#ifdef __MMI_ZHSX_SUPPORT__
+void mmi_watch_restart(void);
+#endif
+
 /**********************
  *      MACROS
  **********************/
index e53eef7..c1aa254 100644 (file)
@@ -208,4 +208,56 @@ void shutdown_confirm_btn_action(lv_obj_t * btn, lv_event_t event)
     return;
 }
 
+
+#ifdef __MMI_ZHSX_SUPPORT__
+void mmi_watch_power_off(void)
+{
+       if(WATCH_SHUTDOWN_UNPERFORMED == shutdown_performance_flg) {
+               shutdown_performance_flg = WATCH_SHUTDOWN_PERFORMING;
+               printf("shutdown start\n");
+       } else {
+               printf("shutdown has been performed\n");
+               return;
+       }
+
+       lv_task_del(lowbattery_task_p);
+       lowbattery_task_p = NULL;
+#if USE_LV_WATCH_SIMCHECK
+       lv_task_del(checksim_task_p);
+       checksim_task_p = NULL;
+#endif
+
+       lv_watch_go_home();
+#if USE_LV_BLUETOOTH != 0
+       bt_power_off();
+#endif
+       dial_poweroff();
+       watch_set_ready_state(false);
+       watch_set_suspend_enable(false, ACT_ID_SHUTDOWN, 0);
+#if USE_POWER_OFF_GIF
+       shutdown_music();
+
+       lv_obj_t * 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_ANYOBJ;
+       activity_obj = lv_watch_creat_activity_obj(&activity_ext);
+       LV_ASSERT_MEM(activity_obj);
+       if(activity_obj == NULL) return;
+
+       gif_info_t * gif_info = gif_open(activity_obj, ANIM_POWER_OFF, 1);
+       if(!gif_info) {
+               printf("shutdown gif failed.\n");
+               return;
+       }
+       shutdown_task_p = lv_task_create(shutdown_task, 100, LV_TASK_PRIO_MID, (void *)gif_info);
+#else
+       printf("shutdown without power off gif.\n");
+       Hal_Backlight_Off();
+       lv_task_del(lowbattery_task_p);
+       Hal_Power_Off(HAL_TYPE_POWER_OFF);
+#endif
+}
+#endif
+
 #endif /*USE_LV_WATCH_SHUTDOWN*/
index 321ad8f..6e05aed 100644 (file)
@@ -44,6 +44,10 @@ void shutdown_music(void);
 void shutdown_confirm_btn_action(lv_obj_t * btn, lv_event_t event);
 uint8_t get_shutdown_performance_flg(void);
 
+#ifdef __MMI_ZHSX_SUPPORT__
+void mmi_watch_power_off(void);
+#endif
+
 /**********************
  *      MACROS
  **********************/
index 3095e93..b9b5c56 100644 (file)
@@ -8,9 +8,6 @@
 extern "C" {
 #endif
 
-/*********************
-*      INCLUDES
-*********************/
 
 #ifdef LV_CONF_INCLUDE_SIMPLE
 #include "lvgl.h"
@@ -23,19 +20,9 @@ extern "C" {
 #ifdef __MMI_WECHAT_SUPPORT__
 
 
-#if 0
-
-#define VOICE_MSG_AMR_HEAD_SIZE 6
-#define VOICE_MSG_EXPRESSION_WIDTH 120
-#define VOICE_MSG_EXPRESSION_HEIGHT 120
-#define VOICE_MSG_PHOTO_WIDTH 120
-#define VOICE_MSG_PHOTO_HEIGHT 120
-
-#endif
-
 #define __WECHAT_DEBUG__
 #ifdef __WECHAT_DEBUG__
-#define WECHAT_DEBUG_PRINTF(fmt, ...)  printf(fmt, ##__VA_ARGS__)
+#define WECHAT_DEBUG_PRINTF(fmt, ...)  printf("[WECHAT]"fmt, ##__VA_ARGS__)
 #else
 #define WECHAT_DEBUG_PRINTF(fmt, ...)
 #endif
@@ -115,37 +102,21 @@ typedef struct
 
 
 void wechat_chat_list_set_slide_enable(lv_watch_obj_ext_t * ext, bool enable);
-void wechat_msg_info_init(void);
+void mmi_wechat_msg_info_init(void);
 void wechat_msg_voice_item_playing_stop(lv_wechat_ext_t * ext);
 void wechat_chat_list_msg_item_style_reset(lv_wechat_ext_t * ext);
 void wechat_main_screen_refresh(void);
 void wechat_create_event_cb(lv_obj_t * btn, lv_event_t e);
 
-
-
 #if 0
-
-void voice_msg_call_end(void);
-void voice_msg_alarm_end(void);
-void voice_msg_speech_recog_end(void);
-void voice_msg_alarm_ind(void);
-
-void voice_msg_audio_ctrl_callback(AUDIO_CTRL_PRIORITY priority);
-void voice_msg_shut_down(void);
-void * voice_msg_get_ext(lv_watch_Activity_Id_t actId);
-uint32_t voice_msg_read_file_size(char * file_name);
-void * voice_msg_read_file_data(char * file_name, uint8_t msg_type, uint32_t * data_size);
-void voice_msg_fill_chat_id(app_adaptor_voice_msg_chat_id_t * id, voice_msg_contact_t * contact);
-void voice_msg_send_photo(void * buf, uint32_t size, voice_msg_contact_t * contact);
-void voice_msg_enlarge_photo(void * small_photo);
-void app_adaptor_voice_msg_handle_rcv_ind(app_adaptor_voice_msg_t * msg);
-void app_adaptor_voice_msg_handle_send_cnf(watch_app_adp_voice_msg_result_t result);
-                            void * para);
-
+#define AMR_HEAD_SIZE 6
+#define EXPRESSION_WIDTH 120
+#define EXPRESSION_HEIGHT 120
+#define PHOTO_WIDTH 120
+#define PHOTO_HEIGHT 120
 
 /*extern phone api*/
 bool phone_is_monitor_on(void);
-
 #endif
 
 
index c3efb71..5613c63 100644 (file)
@@ -1,15 +1,11 @@
 
 
 
-/*********************
-*      INCLUDES
-*********************/
 #include "lv_watch.h"
 
 #ifdef __MMI_WECHAT_SUPPORT__
 
 
-
 static lv_signal_cb_t ancient_scrl_signal;
 
 static uint8_t s_wechat_msg_init_flag = 0;
@@ -19,17 +15,6 @@ static uint8_t s_wechat_play_anim_count = 0;
 char s_wechat_selected_item_index = -1;
 
 
-
-#ifdef __WECHAT_DEBUG__
-bool mmi_protocol_action_talk(char * file_buf)
-{
-       //for debug
-
-       return true;
-}
-#endif
-
-
 void wechat_msg_info_nv_write(void)
 {
        uint32_t nv_data_length = sizeof(nv_watch_wechat_msg_info_t);
@@ -42,7 +27,7 @@ void wechat_msg_info_nv_write(void)
        }
 }
 
-void wechat_msg_info_init(void)
+void mmi_wechat_msg_info_init(void)
 {
        if(0 == s_wechat_msg_init_flag)
        {
@@ -272,13 +257,63 @@ void wechat_receive_audio_play_over_cb(void *para)
        Hal_Audio_Manage_End_Ind(AUDIO_CTRL_PRIORITY_5);
 }
 
-void wechat_msg_receive_from_server(nv_watch_wechat_msg_item_info_t * wechat_msg_item_info)
+bool wechat_msg_receive_from_server(char * data_buff, int data_buff_len)
 {
-       wechat_msg_info_new_item_add(wechat_msg_item_info);
+       if(NULL == data_buff || 0 == data_buff_len)
+       {
+               WECHAT_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               return false;
+       }
+       
+       nv_watch_wechat_msg_item_info_t wechat_msg_item_info = {0};
+       hal_rtc_t cur_time = {0};
+       
+       Hal_Rtc_Gettime(&cur_time);
+       wechat_msg_item_info.msg_time.tm_year = cur_time.tm_year;
+       wechat_msg_item_info.msg_time.tm_mon = cur_time.tm_mon;
+       wechat_msg_item_info.msg_time.tm_mday = cur_time.tm_mday;
+       wechat_msg_item_info.msg_time.tm_hour = cur_time.tm_hour;
+       wechat_msg_item_info.msg_time.tm_min = cur_time.tm_min;
+       wechat_msg_item_info.msg_time.tm_sec = cur_time.tm_sec;
+       
+       wechat_msg_item_info.msg_from = 1;
+       wechat_msg_item_info.unread_flag = 1;
+       wechat_msg_item_info.msg_type = WECHAT_MSG_TYPE_VOICE;
+       sprintf(wechat_msg_item_info.msg_data_full_file_name, "C:/wechat_r%04d%02d%02d_%02d%02d%02d.amr", /*WECHAT_MSG_DATA_FILE_PATH, */
+                       wechat_msg_item_info.msg_time.tm_year, wechat_msg_item_info.msg_time.tm_mon, wechat_msg_item_info.msg_time.tm_mday,
+                       wechat_msg_item_info.msg_time.tm_hour, wechat_msg_item_info.msg_time.tm_min, wechat_msg_item_info.msg_time.tm_sec);
+
+       lv_fs_file_t file_p = {0};
+       lv_fs_res_t res = 0;
+       uint32_t bytes_write = 0;
+
+       res = lv_fs_open(&file_p, wechat_msg_item_info.msg_data_full_file_name, LV_FS_MODE_WR);
+       if(LV_FS_RES_OK != res)
+       {
+               WECHAT_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: errno=%d\n", __FUNCTION__, __LINE__, res);
+               lv_fs_close(&file_p);
+               
+               return false;
+       }
+       
+       lv_fs_seek(&file_p, 0);
+       res = lv_fs_write(&file_p, data_buff, data_buff_len, &bytes_write);
+       if(LV_FS_RES_OK != res)
+       {
+               WECHAT_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: errno=%d\n", __FUNCTION__, __LINE__, res);
+               lv_fs_close(&file_p);
+               
+               return false;
+       }
+       lv_fs_close(&file_p);
+       
+       wechat_msg_info_new_item_add(&wechat_msg_item_info);
 
        if(false == wechat_msg_voice_is_playing() && false == wechat_msg_voice_is_recording())
        {
                //prompt 
+               app_adaptor_wake_up_short_time();
+               
                if(AUDIO_CTRL_PRIORITY_5 == Hal_Audio_Manage_Start_Req(AUDIO_CTRL_PRIORITY_5, wechat_receive_audio_play_audio_ctrl_callback))
                {
                        Hal_NFFS_File_Play_Onetime(AUDIO_WECHAT_RECEIVE, (HAL_SPEAKER_GAIN)query_current_volume(), wechat_receive_audio_play_over_cb, 0);
@@ -291,6 +326,8 @@ void wechat_msg_receive_from_server(nv_watch_wechat_msg_item_info_t * wechat_msg
                        wechat_main_screen_refresh();
                }
        }
+
+       return true;
 }
 
 bool wechat_msg_send_to_server(void)
@@ -323,7 +360,7 @@ bool wechat_msg_send_to_server(void)
        }
        else
        {
-               if(true == mmi_protocol_action_talk(file_buf))
+               if(true == mmi_protocol_action_send_talk(file_buf, file_size))
                {
                        wechat_msg_info_new_item_add(&s_wechat_msg_item_info);
                        result = true;
@@ -532,7 +569,7 @@ lv_obj_t * wechat_msg_sending_screen_create(lv_obj_t * activity_obj)
         lv_watch_activity_ext_t activity_ext = {0};
 
         activity_ext.actId = ACT_ID_WECHAT_SENDING;
-        activity_ext.create = wechat_msg_sending_screen_create;
+        activity_ext.create = (lv_watch_activity_create_f_t)wechat_msg_sending_screen_create;
         activity_ext.prepare_destory = wechat_msg_sending_screen_prepare_destory;
         activity_obj = lv_watch_creat_activity_obj(&activity_ext);
         LV_ASSERT_MEM(activity_obj);
@@ -818,7 +855,7 @@ void wechat_msg_recording_screen_create(void)
        s_wechat_msg_item_info.msg_time.tm_sec = cur_time.tm_sec;
 #endif
        s_wechat_msg_item_info.msg_type = WECHAT_MSG_TYPE_VOICE;
-       sprintf(s_wechat_msg_item_info.msg_data_full_file_name, "C:/wechat_%04d%02d%02d_%02d%02d%02d", /*WECHAT_MSG_DATA_FILE_PATH, */
+       sprintf(s_wechat_msg_item_info.msg_data_full_file_name, "C:/wechat_s%04d%02d%02d_%02d%02d%02d.amr", /*WECHAT_MSG_DATA_FILE_PATH, */
                                s_wechat_msg_item_info.msg_time.tm_year, s_wechat_msg_item_info.msg_time.tm_mon, s_wechat_msg_item_info.msg_time.tm_mday,
                                s_wechat_msg_item_info.msg_time.tm_hour, s_wechat_msg_item_info.msg_time.tm_min, s_wechat_msg_item_info.msg_time.tm_sec);
        
@@ -1428,7 +1465,6 @@ void wechat_chat_list_create(lv_obj_t * obj, lv_wechat_ext_t * ext)
        uint8_t i = 0;
        uint8_t msg_count = wechat_msg_info_count_get();
     hal_rtc_t cur_time = {0}, last_msg_item_time = {0}, msg_time = {0};
-       //lv_wechat_msg_item_t * msg_item = (lv_wechat_msg_item_t *)_lv_ll_get_head(ext->msg_list);
        
     Hal_Rtc_Gettime(&cur_time);        
        for(i = 0; i < msg_count; i++)
@@ -1513,7 +1549,7 @@ lv_obj_t * wechat_create(lv_obj_t * activity_obj, lv_wechat_created_from_e from)
                
                _lv_memset_00(&activity_ext, sizeof(lv_watch_activity_ext_t));
         activity_ext.actId = ACT_ID_WECHAT_MAIN;
-        activity_ext.create = wechat_create; //NULL;
+        activity_ext.create = (lv_watch_activity_create_f_t)wechat_create; //NULL;
         activity_ext.prepare_destory = wechat_prepare_destory;
         activity_obj = lv_watch_creat_activity_obj(&activity_ext);
         LV_ASSERT_MEM(activity_obj);
@@ -1521,11 +1557,11 @@ lv_obj_t * wechat_create(lv_obj_t * activity_obj, lv_wechat_created_from_e from)
 
     lv_obj_t * obj = lv_watch_obj_create(activity_obj);
        if(NULL == obj)
-               return;
+               return NULL;
     /*Allocate the tab type specific extended data*/
        lv_wechat_ext_t * ext = lv_obj_allocate_ext_attr(obj, sizeof(lv_wechat_ext_t));
        if(NULL == ext)
-               return;
+               return NULL;
 
 #ifndef __WECHAT_DEBUG__
     if((false == watch_modem_sim_present_check_req())
index 26c684b..9eebf40 100644 (file)
@@ -174,8 +174,11 @@ void watch_power_on_req(void)
     //init steps from nv when power on
     asl_pedometer_poweron_on_init();
 
+#ifdef __MMI_ZHSX_SUPPORT__
 #ifdef __MMI_WECHAT_SUPPORT__
-       wechat_msg_info_init();
+       mmi_wechat_msg_info_init();
+#endif
+
 #endif
 
        if((HAL_POWERUP_ONKEY == reason) || (HAL_POWERUP_REBOOT == reason)) {
index 3c38516..4d05543 100644 (file)
@@ -164,9 +164,15 @@ extern "C" {
 #include "../../product/craneg_modem/softutil/fotacomm/inc/fota_interface.h"
 #endif
 
+
+#ifdef __MMI_ZHSX_SUPPORT__
+
+#include "mmi_protocol/mmi_protocol_api.h"
+#include "mmi_protocol/mmi_protocol_fzd.h"
 #ifdef __MMI_WECHAT_SUPPORT__
 #include "lv_apps/wechat/wechat.h"
 #endif
+#include "lv_apps/health_measure/health_measure.h"
 #ifdef __MMI_HEALTH_MEASURE_HEART_SUPPORT__
 #include "lv_apps/health_measure/health_heart_rate.h"
 #endif
@@ -177,6 +183,8 @@ extern "C" {
 #include "lv_apps/health_measure/health_temperature.h"
 #endif
 
+#endif
+
 
 
 //simware end
index 18e358f..866e221 100644 (file)
@@ -707,7 +707,10 @@ LV_IMG_DECLARE(img_poweron_logo);
 #endif
 #ifdef __MMI_HEALTH_MEASURE_TEMPERATURE_SUPPORT__
 #define ICON_TEMPERATURE                                                               "R:/png/primary_function/ICON_TEMPERATURE.png"
-#define ICON_TEMPERATURE_MEASURE_BG                    "R:/png/health_measure/icon_temperature_measure_bg.png"
+#define ANIM_TEMPERATURE_MEASURING                                             "R:/gif/anim_temperature_measuring.gif"
+#define ICON_TEMPERATURE_MEASURE_DONE                    "R:/png/health_measure/icon_temperature_measure_done.png"
+#define ICON_TEMPERATURE_MEASURE_FAIL                    "R:/png/health_measure/icon_temperature_measure_fail.png"
+//#define ICON_TEMPERATURE_MEASURE_BG                    "R:/png/health_measure/icon_temperature_measure_bg.png"
 #endif
 
 
diff --git a/2.sdk/gui/lv_watch/mmi_location/mmi_location.c b/2.sdk/gui/lv_watch/mmi_location/mmi_location.c
new file mode 100644 (file)
index 0000000..bfd3545
--- /dev/null
@@ -0,0 +1,288 @@
+
+
+
+#include "lv_watch.h"
+
+#ifdef __MMI_ZHSX_SUPPORT__
+
+static uint8_t s_watch_location_state = 0; // 0-init; 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 TIMER_ID s_watch_location_timer_id = NULL;
+static uint8_t s_watch_location_times_check_count = 0;
+
+
+void mmi_watch_location_mission_list_init(void)
+{
+       _lv_ll_init(&s_watch_location_mission_ll, sizeof(MMI_WATCH_LOCATION_TYPE_E));
+}
+
+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);
+    }
+}
+
+void mmi_watch_location_mission_list_node_add(MMI_WATCH_LOCATION_TYPE_E location_type)
+{
+    MMI_WATCH_LOCATION_TYPE_E * node = _lv_ll_get_head(&s_watch_location_mission_ll);
+       
+    while(NULL != node)
+       {
+               if(location_type == * node)
+               {
+                       return ; // exist
+               }
+        node = _lv_ll_get_next(&s_watch_location_mission_ll, node);
+    }
+       
+       MMI_WATCH_LOCATION_TYPE_E * new_node = _lv_ll_ins_head(&s_watch_location_mission_ll);
+       * new_node = location_type;
+}
+
+void mmi_watch_location_mission_list_data_send(void)
+{
+       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)
+       {
+               switch(* node)
+               {
+                       case MMI_WATCH_LOCATION_UD:
+                               mmi_protocol_action_send_location(&s_watch_location_data);
+                               break;
+                               
+                       case MMI_WATCH_LOCATION_CRUD:
+                               mmi_protocol_action_send_cur_location(&s_watch_location_data);
+                               break;
+                               
+                       case MMI_WATCH_LOCATION_WT:
+                               mmi_protocol_action_send_get_weather(&s_watch_location_data);
+                               break;
+                               
+                       case MMI_WATCH_LOCATION_ALERT:
+
+                               break;
+                               
+                       default:
+                               break;
+               }
+
+               MMI_WATCH_LOCATION_TYPE_E * old_node = node;
+               node = _lv_ll_get_prev(&s_watch_location_mission_ll, node);
+               _lv_ll_remove(&s_watch_location_mission_ll, old_node);
+               lv_mem_free(old_node);
+               old_node = NULL;
+       }
+}
+
+
+void mmi_watch_location_gps_finsh_cb(void *param)
+{
+       if(NULL != param)
+       {
+               double gpsLon = 0, gpsLat = 0;
+               gpsNmeaDataT *gpsNmeaData = (gpsNmeaDataT *)param;
+               
+               if('A' == gpsNmeaData->NmeaRmcData.Status) 
+               {
+                       gps2wgs84(gpsNmeaData->NmeaRmcData.Latitude, gpsNmeaData->NmeaRmcData.Longitude, &gpsLat, &gpsLon);
+
+                       s_watch_location_data.gps_data.status = '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;
+               }
+       }
+}
+
+void mmi_watch_location_gps_stop(void)
+{
+       gps_request_locate_stop();
+}
+
+void mmi_watch_location_gps_start(void)
+{
+       s_watch_location_gps_state = MMI_WATCH_LOCATION_STATE_PROCESS;
+       
+       gps_request_locate_start(mmi_watch_location_gps_finsh_cb);
+}
+
+void mmi_watch_location_cell_stop(void)
+{
+
+}
+
+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.cell_num = cell_list->gncell_num;
+       s_watch_location_data.cell_data.mcc = cell_list->scell.mcc;
+       s_watch_location_data.cell_data.mnc = cell_list->scell.mnc;
+       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_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.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)
+{
+       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)
+{
+       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)
+       {
+               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++)
+               {
+                       _lv_memcpy(&(s_watch_location_data.wifi_data.item[i]), wifi_info->WifiHotspot[i], sizeof(app_adp_wifi_ap_item));
+               }
+       }
+       else
+       {
+               wifi_scan_start();
+       }
+}
+
+void mmi_watch_location_wifi_start(void)
+{
+       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)
+{
+       s_watch_location_state = 0;
+       if(NULL != s_watch_location_timer_id)
+       {
+               Hal_Timer_Stop(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();
+}
+
+void mmi_watch_location_mission_timer_cb(void * para)
+{
+       s_watch_location_times_check_count++;
+       if(MMI_WATCH_LOCATION_CHECK_TIMES_COUNT_MAX <= s_watch_location_times_check_count)
+       {
+               mmi_watch_location_mission_list_data_send();
+               mmi_watch_location_mission_stop();
+       }
+       else
+       {
+               if(MMI_WATCH_LOCATION_STATE_SUCCESS == s_watch_location_cell_state
+                       &&MMI_WATCH_LOCATION_STATE_SUCCESS == s_watch_location_gps_state
+                       )
+               {
+                       mmi_watch_location_mission_list_data_send();
+                       mmi_watch_location_mission_stop();
+               }
+       }
+}
+
+void mmi_watch_location_mission_start(void)
+{
+       if(0 == s_watch_location_state)
+       {
+               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;
+               s_watch_location_timer_id = Hal_Timer_Start(MMI_WATCH_LOCATION_PROCESS_DURATION, mmi_watch_location_mission_timer_cb, NULL, true);
+               
+               mmi_watch_location_gps_start();
+               mmi_watch_location_cell_start();
+               mmi_watch_location_wifi_start();
+       }
+}
+
+void mmi_watch_location_mission_timed_location_action(void)
+{
+       mmi_watch_location_mission_list_node_add(MMI_WATCH_LOCATION_UD);
+       mmi_watch_location_mission_start();
+}
+
+void mmi_watch_location_mission_current_location_action(void)
+{
+       mmi_watch_location_mission_list_node_add(MMI_WATCH_LOCATION_CRUD);
+       mmi_watch_location_mission_start();
+}
+
+void mmi_watch_location_mission_get_weather_action(void)
+{
+       mmi_watch_location_mission_list_node_add(MMI_WATCH_LOCATION_WT);
+       mmi_watch_location_mission_start();
+}
+
+#endif
+
+
diff --git a/2.sdk/gui/lv_watch/mmi_location/mmi_location.h b/2.sdk/gui/lv_watch/mmi_location/mmi_location.h
new file mode 100644 (file)
index 0000000..04ddbb2
--- /dev/null
@@ -0,0 +1,125 @@
+
+
+
+#ifdef __MMI_ZHSX_SUPPORT__
+
+#ifndef __MMI_LOCATION_H__
+#define __MMI_LOCATION_H__
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif //__cplusplus
+
+
+#include "lv_watch.h"
+
+
+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) // 4000 ms
+
+
+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
+{
+       uint8_t cell_num;
+    uint16_t mcc;
+    uint16_t mnc;
+    uint16_t lac[APP_ADP_MAX_GSM_NCELL_NUM];
+    uint32_t cell_id[APP_ADP_MAX_GSM_NCELL_NUM];
+    uint8_t rxlev[APP_ADP_MAX_GSM_NCELL_NUM];
+} MMI_WATCH_CELL_DATA_T;
+
+typedef struct
+{
+       //gps
+       MMI_WATCH_GPS_DATA_T gps_data;
+       
+       //cell
+       MMI_WATCH_CELL_DATA_T cell_data;
+
+       //wifi
+       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_ALERT, // alert
+       MMI_WATCH_LOCATION_MAX,
+}MMI_WATCH_LOCATION_TYPE_E;
+
+
+void mmi_watch_location_mission_list_init(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);
+
+
+
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif //__cplusplus
+
+#endif
+
+#endif
+
+
diff --git a/2.sdk/gui/lv_watch/mmi_protocol/mmi_protocol_api.c b/2.sdk/gui/lv_watch/mmi_protocol/mmi_protocol_api.c
new file mode 100644 (file)
index 0000000..99302cc
--- /dev/null
@@ -0,0 +1,293 @@
+
+
+
+#include "lv_watch.h"
+
+#ifdef __MMI_ZHSX_SUPPORT__
+
+#include "../modem/mmi_modem_tcp/mmi_modem_tcp_net.h"
+
+
+
+static nv_watch_protocol_data_t s_watch_protocol_data = {0};
+static bool s_watch_bind_state = false;
+
+static TIMER_ID s_watch_timed_mission_timer_id = NULL;
+static uint32_t s_watch_timed_location_time_stamp = 0, s_watch_timed_weather_time_stamp = 0;
+
+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_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_init(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__);
+               s_watch_protocol_data.heartbeat_action_interval = MMI_PROTOCOL_HEARTBEAT_ACTION_INTERVAL;
+               s_watch_protocol_data.location_upload_interval = MMI_PROTOCOL_LOCATION_UPLOAD_INTERVAL;
+               s_watch_protocol_data.weather_update_interval = MMI_PROTOCOL_WEATHER_UPDATE_INTERVAL;
+       }
+}
+
+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 = 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 mmi_protocol_watch_timed_mission_timer_cb(void * para)
+{
+       uint32_t cur_time_stamp = 0;
+
+       Hal_Rtc_Gettime_Count(&cur_time_stamp);
+       
+       //location
+       if(mmi_protocol_watch_location_upload_interval_get() <= (cur_time_stamp - s_watch_timed_location_time_stamp))
+       {
+               mmi_protocol_action_location();
+               s_watch_timed_location_time_stamp = cur_time_stamp;
+       }
+
+       //weather
+       if(mmi_protocol_watch_weather_update_interval_get() <= (cur_time_stamp - s_watch_timed_weather_time_stamp))
+       {
+               mmi_protocol_action_get_weather();
+               s_watch_timed_weather_time_stamp = cur_time_stamp;
+       }
+
+       //health measure
+       mmi_health_measure_heart_timed_action(false, cur_time_stamp);
+       mmi_health_measure_temperature_timed_action(false, cur_time_stamp);
+       mmi_health_measure_blood_timed_action(false, cur_time_stamp);
+       mmi_health_measure_spo2_timed_action(false, cur_time_stamp);
+}
+
+void mmi_protocol_watch_timed_mission_action(void)
+{
+       if(NULL == s_watch_timed_mission_timer_id)
+       {
+               uint32_t cur_time_stamp = 0;
+               
+               Hal_Rtc_Gettime_Count(&cur_time_stamp);
+               
+               mmi_watch_location_mission_list_init();
+               mmi_protocol_action_location();
+               s_watch_timed_location_time_stamp = cur_time_stamp;
+
+               mmi_protocol_action_get_weather();
+               s_watch_timed_weather_time_stamp = cur_time_stamp;
+
+               mmi_health_measure_timed_info_init();
+               mmi_health_measure_heart_timed_action(true, cur_time_stamp);
+               mmi_health_measure_temperature_timed_action(true, cur_time_stamp);
+               mmi_health_measure_blood_timed_action(true, cur_time_stamp);
+               mmi_health_measure_spo2_timed_action(true, cur_time_stamp);
+               
+               s_watch_timed_mission_timer_id = Hal_Timer_Start(1000 * 20, mmi_protocol_watch_timed_mission_timer_cb, NULL, TRUE);
+       }
+}
+
+static TIMER_ID s_watch_heartbeat_action_timer_id = NULL;
+static uint32_t s_watch_heartbeat_action_time_stamp = 0;
+
+void mmi_protocol_watch_heartbeat_stop(void)
+{
+       if(NULL != s_watch_heartbeat_action_timer_id)
+       {
+               Hal_Timer_Stop(s_watch_heartbeat_action_timer_id);
+               s_watch_heartbeat_action_timer_id = NULL;
+       }
+}
+
+static void mmi_protocol_watch_heartbeat_timer_cb(void * para)
+{
+       uint32_t cur_time_stamp = 0;
+
+       Hal_Rtc_Gettime_Count(&cur_time_stamp);
+       if(mmi_protocol_watch_heartbeat_action_interval_get() <= (cur_time_stamp - s_watch_heartbeat_action_time_stamp))
+       {
+               mmi_protocol_action_link();
+               s_watch_heartbeat_action_time_stamp = cur_time_stamp;
+       }
+}
+
+void mmi_protocol_watch_heartbeat_action(void)
+{
+       if(NULL == s_watch_heartbeat_action_timer_id)
+       {
+               mmi_watch_protocol_data_init();
+               
+               mmi_protocol_action_link();
+               
+               Hal_Rtc_Gettime_Count(&s_watch_heartbeat_action_time_stamp);
+               s_watch_heartbeat_action_timer_id = Hal_Timer_Start(1000 * 20, mmi_protocol_watch_heartbeat_timer_cb, NULL, TRUE);
+       }
+}
+
+bool mmi_protocol_action_link(void)
+{
+       return mmi_protocol_fzd_action_link();
+}
+
+bool mmi_protocol_action_bind(void)
+{
+       return mmi_protocol_fzd_action_bind();
+}
+
+bool mmi_protocol_check_state_before_send_action(void)
+{
+       if((false == watch_modem_sim_present_check_req()) 
+               || (false == mmi_watch_tcp_connect_state_get())
+               || (false == mmi_protocol_watch_bind_state_get())
+               )
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \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;
+       
+       return mmi_protocol_fzd_action_send_temperature(temp_value);
+}
+
+bool mmi_protocol_action_send_heart(uint16_t heart_value)
+{
+       if(false == mmi_protocol_check_state_before_send_action())
+               return false;
+       
+       return mmi_protocol_fzd_action_send_heart(heart_value);
+}
+
+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;
+       
+       return mmi_protocol_fzd_action_send_blood(blood_high_value, blood_low_value);
+}
+
+bool mmi_protocol_action_send_spo2(uint16_t spo2_value)
+{
+       if(false == mmi_protocol_check_state_before_send_action())
+               return false;
+       
+       return mmi_protocol_fzd_action_send_spo2(spo2_value);
+}
+
+bool mmi_protocol_action_send_talk(char * data_buff, int data_buff_len)
+{
+       if(false == mmi_protocol_check_state_before_send_action())
+               return false;
+       
+       return mmi_protocol_fzd_ACTION_TALK(data_buff, data_buff_len);
+}
+
+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)
+{
+    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;
+}
+
+
+
+
+
+
+
+
+
+#endif
+
+
diff --git a/2.sdk/gui/lv_watch/mmi_protocol/mmi_protocol_api.h b/2.sdk/gui/lv_watch/mmi_protocol/mmi_protocol_api.h
new file mode 100644 (file)
index 0000000..19f0d23
--- /dev/null
@@ -0,0 +1,80 @@
+
+
+
+#ifdef __MMI_ZHSX_SUPPORT__
+
+#ifndef __MMI_PROTOCOL_API_H__
+#define __MMI_PROTOCOL_API_H__
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif //__cplusplus
+
+
+#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
+
+
+//Server address and port
+//#define HOST_NAME  "api.xcloudtech.com"
+//#define HOST_PORT (9000)
+
+
+#define MMI_PROTOCOL_HEARTBEAT_ACTION_INTERVAL (60 * 5) // s
+
+#define MMI_PROTOCOL_LOCATION_UPLOAD_INTERVAL  (60 * 20) // s
+
+#define MMI_PROTOCOL_WEATHER_UPDATE_INTERVAL   (60 * 60 * 6) // s
+
+
+
+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_watch_timed_mission_action(void);
+
+void mmi_protocol_watch_heartbeat_stop(void);
+void mmi_protocol_watch_heartbeat_action(void);
+
+bool mmi_protocol_action_bind(void);
+
+bool mmi_protocol_action_link(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);
+
+
+
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif //__cplusplus
+
+#endif
+
+#endif
+
+
diff --git a/2.sdk/gui/lv_watch/mmi_protocol/mmi_protocol_fzd.c b/2.sdk/gui/lv_watch/mmi_protocol/mmi_protocol_fzd.c
new file mode 100644 (file)
index 0000000..dcec12e
--- /dev/null
@@ -0,0 +1,2518 @@
+
+
+
+#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
+
+
+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_request_without_data(MMI_PROTOCOL_FZD_ACTION_ENUM action);
+static bool mmi_protocol_fzd_respond_without_data(MMI_PROTOCOL_FZD_ACTION_ENUM action);
+static unsigned char * mmi_protocol_fzd_action_string_get(MMI_PROTOCOL_FZD_ACTION_ENUM action);
+static bool mmi_protocol_fzd_content_parse(unsigned char * content_ptr, unsigned int content_length);
+
+
+signed char km_char_toupper(signed char c)
+{
+       if ( c >= 'a' && c <= 'z' )
+       {
+               c = c - 'a' + 'A';
+       }
+       
+       return c;
+}
+
+void km_str_toupper(signed char *str, signed int len)
+{
+    signed int i = 0;
+
+    for(i=0;i<len;i++)
+    {
+        str[i] = km_char_toupper(str[i]);
+    }
+}
+
+signed int km_str_hex_string_to_number(signed char* hex_str, unsigned char hex_str_len)
+{
+    unsigned char i = 0, temp_num = 0;
+    signed char upper = 0;
+    signed int number = 0;
+
+    if(hex_str == NULL || hex_str_len == 0)
+    {
+        return 0;
+    }
+    
+    for(i=0;i<hex_str_len;i++)
+    {
+        upper = km_char_toupper(hex_str[i]);
+        temp_num = (upper >= 'A')?upper - 'A' + 10:upper - '0';
+        number = number*16 + temp_num;
+    }
+       
+    return number;
+}
+
+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 */
+}
+
+
+
+//
+// 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;
+       strcpy(action_str, mmi_protocol_fzd_action_string_get(action));
+       action_str_len = strlen(action_str);
+
+       //device name
+       sprintf(convert_md5_str, "%s", MMI_PROTOCOL_FZD_DEVICE_NAME);
+
+       //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_FZD_MD5_KEY_LEN + 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_FZD_MD5_KEY_STR, MMI_PROTOCOL_FZD_MD5_KEY_LEN);
+               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)
+{
+       PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: action=%d\n", __FUNCTION__, __LINE__, action);
+       
+    if (NULL != s_send_space_struct[action].ptr)
+    {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: ptr=0x%x\n", __FUNCTION__, __LINE__, s_send_space_struct[action].ptr);
+       lv_mem_free(s_send_space_struct[action].ptr);
+               s_send_space_struct[action].size = 0;
+    }
+}
+
+void mmi_protocol_fzd_send_action_do(MMI_PROTOCOL_FZD_ACTION_ENUM action)
+{
+       unsigned char * send_space_ptr = (unsigned char *)mmi_protocol_fzd_send_space_ptr_get(action);
+       int send_space_size = mmi_protocol_fzd_send_space_size_get(action);
+       
+       PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: size=%d, content=%s\n", __FUNCTION__, __LINE__, send_space_size, send_space_ptr);
+
+       if(send_space_size > 0)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: action=%d\n", __FUNCTION__, __LINE__, action);
+               
+               //send_tcp_cmdmsg(int cmd_type, void* cmd_param)
+               send_tcp_cmdmsg(send_space_size, send_space_ptr);
+       }
+       
+       mmi_protocol_fzd_send_space_deinit(action);
+}
+
+// [MD5_DATADEVICE_NAME*DEVICE_ID*CONTENT_LEN*ACTION_STRING,ACTION_CONTENT]
+bool mmi_protocol_fzd_send_content_construct(MMI_PROTOCOL_FZD_ACTION_ENUM action, unsigned char * content_ptr, int content_len)
+{
+       unsigned char * send_space_ptr = NULL;
+       int send_space_size = 0, curr_offset = 0;
+       unsigned char convert_md5_str[48] = {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()) || (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;
+}
+
+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)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: incomplete buffer is not null\n", __FUNCTION__, __LINE__);
+
+               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
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: incomplete buffer is null\n", __FUNCTION__, __LINE__);
+               
+               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;
+    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][%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(MMI_PROTOCOL_FZD_RECEIVE_FIXED_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;
+       }
+
+       // [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_FZD_DEVICE_NAME_LEN;
+       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 - MMI_PROTOCOL_FZD_RECEIVE_FIXED_CONTENT_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_FZD_DEVICE_NAME, MMI_PROTOCOL_FZD_DEVICE_NAME_LEN)) // 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 = km_str_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(MMI_PROTOCOL_FZD_RECEIVE_FIXED_CONTENT_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_request_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_respond_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 unsigned char * mmi_protocol_fzd_action_string_get(MMI_PROTOCOL_FZD_ACTION_ENUM action)
+{
+    unsigned char* action_string[MMI_FZD_ACTION_MAX] =
+    {
+               "NONE",                 //MMI_FZD_ACTION_NONE
+               
+        "KA",                  //MMI_FZD_ACTION_LINK
+               "PING",                 //MMI_FZD_ACTION_BIND
+               "LGZONE",               //MMI_FZD_ACTION_GET_TIME
+               "UD",                   //MMI_FZD_ACTION_SEND_LOCATION
+               "CRUD",                 //MMI_FZD_ACTION_SEND_CUR_LOCATION
+               "CR",                   //MMI_FZD_SERVER_GET_CUR_LOCATION
+               "UPLOAD",               //MMI_FZD_SERVER_SET_UD_INTERVAL
+               "AL",                   //MMI_FZD_ACTION_ALERT
+               "FACTORY",              //MMI_FZD_SERVER_SET_FACTORY
+               "POWEROFF",             //MMI_FZD_SERVER_SET_POWEROFF
+               
+               "FIND",                 //MMI_FZD_SERVER_FIND_WATCH
+               "VERNO",                //MMI_FZD_SERVER_GET_VERSION
+        "PHL",         //MMI_FZD_SERVER_SET_PHONEBOOK
+               "CALL",                 //MMI_FZD_SERVER_SET_CALL
+               "REMIND",               //MMI_FZD_SERVER_SET_REMIND
+               
+        "hrtstart",            //MMI_FZD_SERVER_SET_HEART_INTERVAL
+               "heart",                //MMI_FZD_ACTION_SEND_HEART
+               "wdstart",              //MMI_FZD_SERVER_SET_TEMPERATURE_INTERVAL
+               "temp",                 //MMI_FZD_ACTION_SEND_TEMPERATURE
+        "bldstart",            //MMI_FZD_SERVER_SET_BLOOD_INTERVAL
+               "blood",                //MMI_FZD_ACTION_SEND_BLOOD
+               "oxstart",              //MMI_FZD_SERVER_SET_SPO2_INTERVAL
+               "oxygen",               //MMI_FZD_ACTION_SEND_SPO2
+               
+       #ifdef __MMI_WECHAT_SUPPORT__
+               "TK",                   //MMI_FZD_ACTION_TALK
+       #endif
+
+               "WT",                   //MMI_FZD_ACTION_GET_WEATHER
+
+
+       
+       /*******add before this line*******/
+               "", // MMI_FZD_ACTION_MAX
+    };
+
+    return action_string[action];
+}
+
+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_ACTION_LINK(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;
+                       
+               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;
+                       
+       #ifdef __MMI_WECHAT_SUPPORT__
+               case MMI_FZD_ACTION_TALK:
+                       mmi_protocol_fzd_parse_ACTION_TALK(next_buff, next_buff_len);
+                       break;
+       #endif
+
+               case MMI_FZD_ACTION_GET_WEATHER:
+                       mmi_protocol_fzd_parse_ACTION_GET_WEATHER(next_buff, next_buff_len);
+                       break;
+
+
+                        
+               default:
+                       break;
+    }
+    
+    return true;
+}
+
+
+bool mmi_protocol_fzd_action_link(void)
+{
+       bool result = false;
+       MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_ACTION_LINK;
+       unsigned char * content_buff = NULL;
+       unsigned int content_lenth = 0;
+    hal_rtc_t cur_time = {0};
+       int step_num = 0;
+       int roll_num = 0;
+       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_content_construct(action, content_buff, content_lenth);
+       lv_mem_free(content_buff);
+
+       return result;
+}
+
+bool mmi_protocol_fzd_parse_ACTION_LINK(unsigned char * next_buff, unsigned int next_buff_len)
+{
+       if(true != mmi_protocol_watch_bind_state_get())
+       {
+               mmi_protocol_fzd_action_bind();
+       }
+       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_request_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(50);
+                       mmi_watch_reset();
+               }
+       }
+       else
+       {
+               if(1 == value)
+               {
+                       mmi_protocol_watch_bind_state_set(true);
+                       mmi_protocol_watch_timed_mission_action();
+               }
+       }
+
+       return true;
+}
+
+bool mmi_protocol_fzd_action_get_time(void)
+{
+       return mmi_protocol_fzd_request_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_respond_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;
+       
+       result = true;
+       mmi_protocol_fzd_respond_without_data(action);
+
+    //////////
+    //////////
+    //////////
+    //function
+    //////////
+    //////////
+    //////////
+       
+       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_respond_without_data(action);
+       uos_sleep(30);
+       mmi_watch_reset();
+
+       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_respond_without_data(action);
+       uos_sleep(30);
+       mmi_watch_power_off();
+
+       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_respond_without_data(action);
+
+    //////////
+    //////////
+    //////////
+    //function
+    //////////
+    //////////
+    //////////
+       //mmi_watch_server_find_screen_create();
+
+       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_content_construct(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_respond_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));
+               }
+               else
+               {
+                       break;
+               }
+               
+               temp_ptr = km_strtok_r(NULL, ",", &next_buff);
+               if (NULL != temp_ptr)
+               {
+                       uint8_t j = 0;
+
+                       for(j = 0; j*4 < strlen(temp_ptr); j++)
+                       {
+                               server_set_contact[i].contact_name[j] = km_str_hex_string_to_number(temp_ptr + j*4, 4);
+                       }
+               }
+               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_respond_without_data(action);
+       uos_sleep(30);
+
+    char * number = (char *)lv_mem_alloc(next_buff_len + 1);
+       if(NULL == number)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               return false;
+       }
+       _lv_memset_00(number, next_buff_len + 1);
+       _lv_memcpy(number, next_buff, next_buff_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]
+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_respond_without_data(action);
+
+       app_adaptor_alarm_t server_set_alarm[NV_ALARM_MAX_ALARM_NUM] = {0};
+       char * temp_ptr1 = NULL, temp_ptr2 = NULL;
+       uint8_t i = 0;
+
+       temp_ptr1 = km_strtok_r(NULL, ",", &next_buff);
+       while(NULL != temp_ptr1)
+       {
+               server_set_alarm[i].valid = 1;
+               
+               temp_ptr2 = km_strtok_r(NULL, ":", &temp_ptr1);
+               server_set_alarm[i].hour = atoi(temp_ptr2);
+               
+               temp_ptr2 = km_strtok_r(NULL, "-", &temp_ptr1);
+               server_set_alarm[i].min = atoi(temp_ptr2);
+
+               temp_ptr2 = km_strtok_r(NULL, "-", &temp_ptr1);
+               server_set_alarm[i].on_off = atoi(temp_ptr2);
+               
+               temp_ptr2 = km_strtok_r(NULL, "-", &temp_ptr1);
+               if(1 == atoi(temp_ptr2))
+               {
+                       server_set_alarm[i].repeat_bitmap = 0;
+               }
+               else
+               {
+                       server_set_alarm[i].repeat_bitmap = 0xff;
+                       if(NULL != temp_ptr1)
+                       {
+                               uint8_t j = 0;
+                               for(j = 0; j < 7; j++)
+                               {
+                                       server_set_alarm[i].repeat_bitmap &= ((('0' == *(temp_ptr1 + j)) ? 0 : 1) << j);
+                               }
+                       }
+               }
+
+               i++;
+               if(NV_ALARM_MAX_ALARM_NUM <= i)
+               {
+                       break;
+               }
+               
+               temp_ptr1 = km_strtok_r(NULL, ",", &next_buff);
+       }
+
+       alarm_set_alarm_by_ui(&server_set_alarm, i);
+
+       return result;
+}
+
+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;
+
+       sprintf(content_buff, ",%.1f", temp_value);
+       content_lenth = strlen(content_buff);
+
+       result = mmi_protocol_fzd_send_content_construct(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_content_construct(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_content_construct(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_content_construct(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_respond_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_respond_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_respond_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_respond_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;
+}
+
+#ifdef __MMI_WECHAT_SUPPORT__
+
+#define ENCRYPT_EXT_MIN  100
+#define ENCRYPT_EXT_COEF  10
+
+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;
+}
+
+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;
+}
+
+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= FZD_MAX(data_buff_len * ENCRYPT_EXT_COEF/100, FZD_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);
+       
+       content_lenth = mmi_protocol_fzd_voice_data_encrypt(data_buff, data_buff_len, content_buff);
+       
+       result = mmi_protocol_fzd_send_content_construct(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_content_construct(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);
+       }
+
+       return result;
+}
+#endif
+
+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};
+       unsigned int battery_value = Hal_Battery_Get_Status();
+       unsigned int sleep_roll_value = 0;
+       unsigned int step_value = 0;
+       uint8_t i = 0;
+
+       t_ptr = content_buff;
+
+       //seperator & time
+       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);
+       t_count = strlen(t_ptr);
+
+    //gps
+       t_ptr += t_count;
+    sprintf(t_ptr, ",%c,%02.06f,%c,%03.06f,%c,%01.02f,%03.01f,%03.01f,%u",
+                                       location_data->gps_data.state,
+                                       location_data->gps_data.latitude,
+                                       location_data->gps_data.ns,
+                                       location_data->gps_data.longitude,
+                                       location_data->gps_data.ew,
+                                       location_data->gps_data.speed,
+                                       location_data->gps_data.degree,
+                                       location_data->gps_data.altitude,
+                                       location_data->gps_data.satellite_num);
+       t_count = strlen(t_ptr);
+
+       //
+       t_ptr += t_count;
+    sprintf(t_ptr, ",%u,%u,%u,%u",
+                                       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_content_construct(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_content_construct(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_content_construct(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]
+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};
+       char city_name[MMI_WEATHER_CITY_NAME_LEN_MAX] = {0};
+       uint8_t i = 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
+    for(i = 0; i*4 < strlen(next_buff); i++)
+       {
+               city_name[i] = km_str_hex_string_to_number(next_buff + i*4, 4);
+    }
+       weather_info.city = city_name;
+
+       mmi_weather_info_set(&weather_info);
+
+       return result;
+}
+
+
+
+
+
+
+
+
+#if 0
+signed char* km_strcpy(char* des,const char* source)
+{
+       signed char* r=des;
+
+       if (source == NULL)
+       {
+
+               if (des)
+               {
+                       *(des) = '\0';
+               }
+
+               return r;
+       }
+
+       if (source == NULL || des == NULL)
+       {
+               return NULL;
+       }
+
+       while((*des++ = *source++)!='\0');
+       
+       return r;
+
+}
+
+void km_FZD_filename_delete_invalid_symbol(signed char *nameout,signed char *filename)
+{
+       int i=0;
+       int j=0;
+       
+       if(nameout==NULL||filename==NULL)
+       {
+          return;
+       }
+       
+       for(i=0;i<strlen(filename);i++)
+       {
+               if(!( filename[i]==':' || filename[i]=='\\'|| filename[i]=='/'|| filename[i]=='*'
+                       || filename[i]=='?'|| filename[i]=='"'|| filename[i]=='<'|| filename[i]=='>'|| filename[i]=='|'))
+               {
+                       nameout[j]= filename[i];
+                       j++;
+               }                       
+       }
+       
+       KM_FZD_TRACE_INFO("%s",nameout);
+}
+/*****************************************************************************
+ * FUNCTION
+ *  applib_dt_decrease_time
+ * DESCRIPTION
+ *  Decrease a reference time by some time
+ * PARAMETERS
+ *  timeToDecrement     [IN]            Time to be decreased
+ *  decrement           [IN]            Time to decrease
+ *  Result              [IN/OUT]        Result of compuatation
+ * RETURNS
+ *  void
+ *****************************************************************************/
+void applib_dt_decrease_time(
+        applib_time_struct *timeToDecrement,
+        applib_time_struct *decrement,
+        applib_time_struct *Result)
+{
+    /*----------------------------------------------------------------*/
+    /* Local Variables                                                */
+    /*----------------------------------------------------------------*/
+    applib_time_struct decrement_local;
+    applib_time_struct *decrement_local_ptr = &decrement_local;
+    
+    /*----------------------------------------------------------------*/
+    /* Code Body                                                      */
+    /*----------------------------------------------------------------*/
+    memset(&decrement_local, 0x00, sizeof(applib_time_struct));
+    memcpy(&decrement_local, decrement, sizeof(applib_time_struct));
+    
+    if (decrement_local_ptr->nSec != 0)
+    {
+        if (timeToDecrement->nSec >= decrement_local_ptr->nSec)
+        {
+            Result->nSec = timeToDecrement->nSec - decrement_local_ptr->nSec;
+        }
+        else
+        {
+            Result->nSec = DT_MIN_PER_HR + timeToDecrement->nSec - decrement_local_ptr->nSec;
+            decrement_local_ptr->nMin++;
+        }
+    }
+    else
+    {
+        Result->nSec = timeToDecrement->nSec;
+    }
+
+    if (decrement_local_ptr->nMin != 0)
+    {
+        if (timeToDecrement->nMin >= decrement_local_ptr->nMin)
+        {
+            Result->nMin = timeToDecrement->nMin - decrement_local_ptr->nMin;
+        }
+        else
+        {
+            Result->nMin = DT_MIN_PER_HR + timeToDecrement->nMin - decrement_local_ptr->nMin;
+            decrement_local_ptr->nHour++;
+        }
+    }
+    else
+    {
+        Result->nMin = timeToDecrement->nMin;
+    }
+
+    if (decrement_local_ptr->nHour != 0)
+    {
+        if (timeToDecrement->nHour >= decrement_local_ptr->nHour)
+        {
+            Result->nHour = timeToDecrement->nHour - decrement_local_ptr->nHour;
+        }
+        else
+        {
+            Result->nHour = DT_HRS_PRE_DAY + timeToDecrement->nHour - decrement_local_ptr->nHour;
+            decrement_local_ptr->nDay++;
+        }
+    }
+    else
+    {
+        Result->nHour = timeToDecrement->nHour;
+    }
+
+    if (decrement_local_ptr->nDay != 0)
+    {
+        if (timeToDecrement->nDay > decrement_local_ptr->nDay)
+        {
+            Result->nDay = timeToDecrement->nDay - decrement_local_ptr->nDay;
+        }
+        else
+        {
+            decrement_local_ptr->nMonth++;
+            if (timeToDecrement->nMonth != 1)
+            {
+                Result->nDay = applib_dt_last_day_of_mon(
+                                (kal_uint8) (timeToDecrement->nMonth - 1),
+                                timeToDecrement->nYear) + timeToDecrement->nDay - decrement_local_ptr->nDay;
+            }
+            else
+            {
+                Result->nDay = 31 + timeToDecrement->nDay - decrement_local_ptr->nDay;
+            }
+        }
+    }
+    else
+    {
+        Result->nDay = timeToDecrement->nDay;
+    }
+
+    if (decrement_local_ptr->nMonth != 0)
+    {
+        if (timeToDecrement->nMonth > decrement_local_ptr->nMonth)
+        {
+            Result->nMonth = timeToDecrement->nMonth - decrement_local_ptr->nMonth;
+        }
+        else
+        {
+            Result->nMonth = DT_MONTH_PER_YEAR + timeToDecrement->nMonth - decrement_local_ptr->nMonth;
+            decrement_local_ptr->nYear++;
+        }
+    }
+    else
+    {
+        Result->nMonth = timeToDecrement->nMonth;
+    }
+
+    Result->nYear = timeToDecrement->nYear - decrement_local_ptr->nYear;
+
+    Result->DayIndex = applib_dt_dow(Result->nYear, Result->nMonth, Result->nDay);
+
+}
+/*****************************************************************************
+ * FUNCTION
+ *  applib_dt_increase_time
+ * DESCRIPTION
+ *  Increase a reference time by some time
+ * PARAMETERS
+ *  timeToIncrement     [IN]        Time to be increased
+ *  increment           [?]         
+ *  Result              [?]         
+ *  decrement(?)        [IN]        Time to increase
+ * RETURNS
+ *  result of computation(?)
+ *****************************************************************************/
+void applib_dt_increase_time(
+        applib_time_struct *timeToIncrement,
+        applib_time_struct *increment,
+        applib_time_struct *Result)
+{
+    /*----------------------------------------------------------------*/
+    /* Local Variables                                                */
+    /*----------------------------------------------------------------*/
+    kal_int16 NumOfDays;
+
+    /*----------------------------------------------------------------*/
+    /* Code Body                                                      */
+    /*----------------------------------------------------------------*/
+    /* second */
+    Result->nSec = (timeToIncrement->nSec + increment->nSec);
+
+    /* minute */
+    Result->nMin = (timeToIncrement->nMin + increment->nMin);
+    if (Result->nSec >= DT_MIN_PER_HR)
+    {
+        Result->nSec -= DT_MIN_PER_HR;
+        Result->nMin += 1;
+    }
+
+    /* hour */
+    Result->nHour = (timeToIncrement->nHour + increment->nHour);
+    if (Result->nMin >= DT_MIN_PER_HR)
+    {
+        Result->nMin -= DT_MIN_PER_HR;
+        Result->nHour += 1;
+    }
+
+    /* day */
+    Result->nDay = (timeToIncrement->nDay + increment->nDay);
+    if (Result->nHour >= DT_HRS_PRE_DAY)
+    {
+        Result->nHour -= DT_HRS_PRE_DAY;
+        Result->nDay += +1;
+    }
+
+    /* month, year */
+    Result->nMonth = timeToIncrement->nMonth + increment->nMonth;
+    Result->nYear = timeToIncrement->nYear + increment->nYear;
+
+    if (Result->nMonth > DT_MONTH_PER_YEAR)
+    {
+        Result->nMonth -= DT_MONTH_PER_YEAR;
+        Result->nYear++;
+    }
+
+    /* correct day */
+    NumOfDays = applib_dt_last_day_of_mon(timeToIncrement->nMonth, timeToIncrement->nYear);
+
+    if (Result->nDay > NumOfDays)
+    {
+        Result->nDay -= NumOfDays;
+
+        if (Result->nMonth != 12)
+        {
+            Result->nMonth += 1;
+        }
+        else
+        {
+            Result->nMonth = 1;
+            Result->nYear += 1;
+        }
+    }
+
+    Result->DayIndex = applib_dt_dow(Result->nYear, Result->nMonth, Result->nDay);
+}
+
+static int km_FZD_net_parse_TK(signed char *next_buf,int next_buf_len,signed char seq)
+{
+       signed char send_temp[20] = {0};
+       signed int content_lenth = 0;
+    uint16 record_id = 0;
+       
+       if(next_buf_len == 1)
+       {
+               //SG*5678901234*0004*TK,1
+               //this is rsp.
+               unsigned char send_result = (*next_buf == '1')?1:0;
+               MMIAPI_SetSendWechatContentResult(send_result);
+       }
+       else
+       {
+       #if defined(MMI_C51_NO_LCD_DISPLAY_SUPPORT)
+        sprintf(send_temp, ",%d", record_id);
+               content_lenth = strlen(send_temp);
+               km_FZD_net_construct_and_do_rsp(KM_FZD_NET_PT_ACTION_TK, send_temp, content_lenth, seq);
+               
+       #else
+               //SG*5678901234*0256*TK,data
+               //convert send buff to TK buff.
+               next_buf_len = km_FZD_net_untextdata_decrypt((unsigned char *)next_buf, (unsigned int)next_buf_len);
+               record_id = MMIAPI_SaveWechatAudioData(next_buf, next_buf_len, PNULL);
+
+               //send rsp.
+               sprintf(send_temp, ",%d", (0xFFFF != record_id));
+               content_lenth = strlen(send_temp);
+               km_FZD_net_construct_and_do_rsp(KM_FZD_NET_PT_ACTION_TK, send_temp, content_lenth, seq);
+
+               if(FALSE == km_FZD_currtime_is_in_dnd_cfg())
+               {
+                       #if defined(DRV_RGB_LED_SUPPORT)
+                       MMIAPI_SetRgbledEvent(RGBLED_PRIORITY_WECHAT_NEW_MSG, TRUE);
+                       #endif
+               #if defined(MMI_D10_NO_LCD_DISPLAY_SUPPORT)
+                       MMIAPI_PlayNewVoice();
+                       MMIAPI_StartWechatMsgNoReadTimer();
+               #else
+                       MMIAPI_PlayWechatNewMsgRing();
+               #endif
+               }
+       #endif
+       }
+}
+static int km_FZD_net_parse_TKOne(signed char *next_buf,int next_buf_len,signed char seq)
+{
+   //Todolist
+   KM_TRACE_INFO("km_FZD_net_parse_TKOne: is need parse !");
+   
+       if(FALSE == km_FZD_currtime_is_in_dnd_cfg())
+       {
+       #if !defined(MMI_C51_NO_LCD_DISPLAY_SUPPORT)
+              #if defined(MMI_D10_NO_LCD_DISPLAY_SUPPORT)
+               MMIAPI_PlayNewVoice();
+               MMIAPI_StartWechatMsgNoReadTimer();
+               #else
+               MMIAPI_PlayWechatNewMsgRing();
+               #endif
+          #endif
+       }
+}
+static int km_FZD_net_parse_TKIMG(signed char *next_buf,int next_buf_len,signed char seq)
+{
+   signed char send_temp[20] = {0};
+   signed int content_lenth = 0;
+   uint16 record_id = 0;
+               
+   KM_TRACE_INFO("km_FZD_net_parse_TKIMG: next_buf_len = %d, next_buf = %s !", next_buf_len, next_buf);
+   
+   if(next_buf_len == 1)
+   {
+               //SG*5678901234*0004*TKIMG,1
+               //this is rsp.
+               unsigned char send_result = (*next_buf == '1')?1:0;
+               MMIAPI_SetSendWechatContentResult(send_result);
+   }
+   else
+   {
+        #if defined(MMI_C51_NO_LCD_DISPLAY_SUPPORT)
+        sprintf(send_temp, ",%d", record_id);
+               content_lenth = strlen(send_temp);
+               km_FZD_net_construct_and_do_rsp(KM_FZD_NET_PT_ACTION_TKIMG, send_temp, content_lenth, seq);
+               
+       #else
+               //SG*5678901234*0256*TKIMG,data
+               //convert send buff to TKIMG buff.
+               next_buf_len = km_FZD_net_untextdata_decrypt((unsigned char *)next_buf, (unsigned int)next_buf_len);
+               record_id = MMIAPI_SaveWechatImageData(next_buf, next_buf_len, PNULL);
+
+               //send rsp.
+               sprintf(send_temp, ",%d", (0xFFFF != record_id));
+               content_lenth = strlen(send_temp);
+               km_FZD_net_construct_and_do_rsp(KM_FZD_NET_PT_ACTION_TKIMG, send_temp, content_lenth, seq);
+
+               if(FALSE == km_FZD_currtime_is_in_dnd_cfg())
+               {
+                       #if defined(MMI_D10_NO_LCD_DISPLAY_SUPPORT)
+                       MMIAPI_PlayNewVoice();
+                       MMIAPI_StartWechatMsgNoReadTimer();
+                       #else
+                       MMIAPI_PlayWechatNewMsgRing();
+                       #endif
+               }
+       #endif
+   }   
+}
+
+void ic_fzd_net_parse_wt(signed char *next_buf,int next_buf_len,signed char seq)
+{
+       //[XT*334588000000156*009F*WT,Äê-ÔÂ-ÈÕ,ʱ:·Ö:Ãë,ÌìÆøÃèÊö,ÌìÆø±àºÅ,µ±Ç°Î¶È,×îµÍÎÂ,×î¸ß ÎÂ,³ÇÊÐÃû]
+       signed char *phead = NULL;
+       signed char *ptail = NULL;
+       signed char *p1 = NULL;
+       signed char *p2 = NULL;
+       WEATHER_NVRAM_STRUCT fzd_weather = {0};
+       signed char len = 0;
+       unsigned char i = 0;
+
+       if ((NULL == next_buf) || (next_buf_len <= 0))
+       {
+               KM_FZD_TRACE_ERROR("parameter error!");
+               return ;
+       }
+
+       KM_FZD_TRACE_INFO("WT: (%s)(%d)", next_buf, next_buf_len);
+
+       phead = ptail = next_buf;
+
+       //parse date
+       if (ptail = strstr(phead, ","))
+       {
+               *(ptail++) = '\0';
+
+               //year
+               p2 = p1 = phead;
+               if (p2 = strstr(p1, "-"))
+               {
+                       *(p2++) = '\0';
+                       fzd_weather.weather_desc[0].time.nYear = atoi(p1);
+               }
+
+               //month
+               p1 = p2;
+               if (p2 = strstr(p1, "-"))
+               {
+                       *(p2++) = '\0';
+                       fzd_weather.weather_desc[0].time.nMonth = atoi(p1);
+               }
+
+               //day
+               p1 = p2;
+               fzd_weather.weather_desc[0].time.nDay = atoi(p1);
+       }
+
+       //parse time
+       phead = ptail;
+       if (ptail = strstr(phead, ","))
+       {
+               *(ptail++) = '\0';
+
+               //hour
+               p2 = p1 = phead;
+               if (p2 = strstr(p1, ":"))
+               {
+                       *(p2++) = '\0';
+                       fzd_weather.weather_desc[0].time.nHour = atoi(p1);
+               }
+
+               //min
+               p1 = p2;
+               if (p2 = strstr(p1, ":"))
+               {
+                       *(p2++) = '\0';
+                       fzd_weather.weather_desc[0].time.nMin = atoi(p1);
+               }
+
+               //sec
+               p1 = p2;
+               fzd_weather.weather_desc[0].time.nSec = atoi(p1);
+       }
+
+       //parse weather decription
+       phead = ptail;
+       if (ptail = strstr(phead, ","))
+       {
+               *(ptail++) = '\0';
+       }
+
+       //parse weather num
+       phead = ptail;
+       if (ptail = strstr(phead, ","))
+       {
+               *(ptail++) = '\0';
+               fzd_weather.weather_desc[0].weater_No = atoi(phead);
+       }
+
+       //parse current temperature
+       phead = ptail;
+       if (ptail = strstr(phead, ","))
+       {
+               uint8 is_negative = 0;
+               if(*phead == '-')
+               {
+                       is_negative = 1;
+                       phead++;
+               }
+               
+               *(ptail++) = '\0';
+               fzd_weather.weather_desc[0].curr_temperature = is_negative ? (0 - atoi(phead)) : atoi(phead);
+       }
+
+       //parse min temperature
+       phead = ptail;
+       if (ptail = strstr(phead, ","))
+       {
+               uint8 is_negative = 0;
+               if(*phead == '-')
+               {
+                       is_negative = 1;
+                       phead++;
+               }
+               
+               *(ptail++) = '\0';
+               fzd_weather.weather_desc[0].min_temperature = is_negative ? (0 - atoi(phead)) : atoi(phead);
+       }
+
+       //parse max temperature
+       phead = ptail;
+       if (ptail = strstr(phead, ","))
+       {
+               uint8 is_negative = 0;
+               if(*phead == '-')
+               {
+                       is_negative = 1;
+                       phead++;
+               }
+               
+               *(ptail++) = '\0';
+               fzd_weather.weather_desc[0].max_temperature = is_negative ? (0 - atoi(phead)) : atoi(phead);
+       }
+
+       //parse city
+       phead = ptail;
+       len = strlen(phead);
+    for(i = 0; i*4 < len; i++){
+        fzd_weather.city_name[i] = km_str_hex_string_to_number(phead+i*4,4);
+        KM_FZD_TRACE_INFO("fzd_weather.city_name[%d]:%04x", i, fzd_weather.city_name[i]);
+    }
+
+       KM_FZD_TRACE_INFO("{\n");
+       KM_FZD_TRACE_INFO("\t date: %02d-%02d-%02d", \
+                       fzd_weather.weather_desc[0].time.nYear, \
+                       fzd_weather.weather_desc[0].time.nMonth,\
+                       fzd_weather.weather_desc[0].time.nDay);
+       KM_FZD_TRACE_INFO("\t time: %02d:%02d:%02d", \
+                       fzd_weather.weather_desc[0].time.nMonth, \
+                       fzd_weather.weather_desc[0].time.nMin, \
+                       fzd_weather.weather_desc[0].time.nSec);
+       KM_FZD_TRACE_INFO("\t weather code: %d", fzd_weather.weather_desc[0].weater_No);
+       KM_FZD_TRACE_INFO("\t current temperature : %d", fzd_weather.weather_desc[0].curr_temperature);
+       KM_FZD_TRACE_INFO("\t min temperature : %d", fzd_weather.weather_desc[0].min_temperature);
+       KM_FZD_TRACE_INFO("\t max temperature : %d", fzd_weather.weather_desc[0].max_temperature);
+       KM_FZD_TRACE_INFO("\t city : %s", fzd_weather.city_name);
+       KM_FZD_TRACE_INFO("\t city_name_len : %d", fzd_weather.city_name_len);
+       KM_FZD_TRACE_INFO("\t real_data_num : %d", fzd_weather.real_data_num);
+       KM_FZD_TRACE_INFO("}\n");
+
+       if((3 > s_parse_wt_count) 
+               && (0 == fzd_weather.weather_desc[0].curr_temperature && 0 == fzd_weather.weather_desc[0].min_temperature && 0 == fzd_weather.weather_desc[0].max_temperature))
+       {
+               s_parse_wt_count++;
+               MMIAPI_StartWeatherFreshFromNet();
+       }
+       else
+       {
+               s_parse_wt_count = 0;
+               MMIAPI_SetWeatherDataToNv(&fzd_weather);
+       }
+
+       return;
+}
+/*****************************************************************************
+ Prototype    : ic_fzd_convert_and_save_to_file
+ Description  £º×ª»»½ÓÊÕµ½µÄÊý¾Ý£¬±£´æµ½Îļþ
+ Input        : None
+ Output       : None
+ Return Value :
+ Calls        :
+ Called By    :
+
+  History        :
+  1.Date         : 2019/3/2
+    Author       : leihj
+    Modification : Created function
+
+    0X7D 0X01 --> 0X7D
+       0X7D 0X02 --> 0X5B
+       0X7D 0X03 --> 0X5D
+       0X7D 0X04 --> 0X2C
+       0X7D 0X05 --> 0X2A
+
+*****************************************************************************/
+char ic_fzd_convert_and_save_to_file(wchar *file_path, char *buf, int buf_len)
+{
+       int dir_fd = 0;
+       int fd = 0;
+       int i = 0;
+       char tmp1 = 0;
+       char tmp2 = 0;
+       char value = 0;
+       char w_data[100] = {0};
+       char w_len = 0;
+       MMIFILE_HANDLE file_handle;
+    uint32 bytes_to_write = 0;
+
+       if ((NULL == file_path) || (NULL == buf) || (buf_len <= 0))
+       {
+               KM_FZD_TRACE_ERROR("parameter error");
+               return -1;
+       }
+
+    file_handle = MMIFILE_CreateFile(file_path, SFS_MODE_CREATE_ALWAYS | SFS_MODE_WRITE, NULL, NULL);
+       for (i = 0; i < buf_len - 1; i++)
+       {
+
+               tmp1 = buf[i];
+               tmp2 = buf[i + 1];
+               w_data[w_len] = tmp1;
+               if ((0x7d == tmp1) && ((tmp2 >= 0x01) && (tmp2 <= 0x05)))
+               {
+                       switch (tmp2)
+                       {
+                               case 0x01:
+                                       value = 0x7d;
+                                       break;
+
+                               case 0x02:
+                                       value = 0x5b;
+                                       break;
+
+                               case 0x03:
+                                       value = 0x5d;
+                                       break;
+
+                               case 0x04:
+                                       value = 0x2c;
+                                       break;
+
+                               case 0x05:
+                                       value = 0x2a;
+                                       break;
+                       }
+
+                       //save new value and skip tmp2
+                       w_data[w_len] = value;
+                       i++;
+               }
+
+               //when buffer w_data is full, it need to write buffer to specific file.
+               w_len++;
+               if (sizeof(w_data) == w_len)
+               {
+                       MMIFILE_WriteFile(file_handle, (void *)w_data, (uint32)w_len, &bytes_to_write, NULL);
+                       w_len = 0;
+               }
+       }
+    KM_FZD_TRACE_INFO("ic_fzd_convert_and_save_to_file -111:  buf_len = %d, i = %d",buf_len,i);
+       //save the last data
+       //×îºóµÄÁ½¸öÊý¾ÝÊÇÎÞÐè×ªÒÆµÄ£¬ÐèÒª°Ñ×îºóµÄÒ»¸öÊý¾Ý±£´æÆðÀ´
+       //µ±i == next_buf_lenʱ£¬±íʾ×îºóÒ»¸öÊý¾ÝÊÇÐèҪתÒåµÄ£¬ÎÞÐè±£´æÕâ¸öÊý¾Ý
+       if (i == buf_len - 1)
+       {
+               w_data[w_len++] = buf[buf_len - 1];
+       }
+
+       //±£´æÊ£ÓàµÄÊý¾Ý
+       if (w_len > 0)
+       {
+               MMIFILE_WriteFile(file_handle, (void *)w_data, (uint32)w_len, &bytes_to_write, NULL);
+               w_len = 0;
+       }
+    MMIFILE_CloseFile(file_handle);
+       KM_FZD_TRACE_ERROR("cid: %s", file_path);
+
+       return 0;
+}
+/*****************************************************************************
+ Prototype    : ic_fzd_net_parse_cid
+ Description  :
+ Input        : None
+ Output       : None
+ Return Value :
+    len of receiver data: 2048bytes
+
+       //      0X7D 0X01 --> 0x7D
+       //      0X7D 0X02 --> 0x5B
+       //      0X7D 0X03 --> 0x5D
+       //      0X7D 0X04 --> 0x2C
+       //      0X7D 0X05 --> 0x2A
+*****************************************************************************/
+void ic_fzd_net_parse_cid(signed char *next_buf,int next_buf_len,signed char seq)
+{
+    if(MMIFILE_IsFileExist((wchar *)MMI_FZD_FLODER_FILE_PNG, MMIAPICOM_Wstrlen((wchar *)MMI_FZD_FLODER_FILE_PNG)))
+    {
+      MMIFILE_DeleteFile ((wchar *)MMI_FZD_FLODER_FILE_PNG, NULL);
+    }
+       ic_fzd_convert_and_save_to_file((wchar *)MMI_FZD_FLODER_FILE_PNG, next_buf, next_buf_len);
+}
+/*****************************************************************************
+ Prototype    : ic_fzd_net_parse_cid_jpg
+ Description  :
+ Input        : None
+ Output       : None
+ Return Value :
+       len of receiver data: 1378bytes
+
+       //      0X7D 0X01 --> 0x7D
+       //      0X7D 0X02 --> 0x5B
+       //      0X7D 0X03 --> 0x5D
+       //      0X7D 0X04 --> 0x2C
+       //      0X7D 0X05 --> 0x2A
+*****************************************************************************/
+void ic_fzd_net_parse_cid_jpg(signed char *next_buf,int next_buf_len,signed char seq)
+{
+       if(MMIFILE_IsFileExist((wchar *)MMI_FZD_FLODER_FILE_JPG, MMIAPICOM_Wstrlen((wchar *)MMI_FZD_FLODER_FILE_JPG)))
+       {
+      MMIFILE_DeleteFile ((wchar *)MMI_FZD_FLODER_FILE_JPG, NULL);
+       }
+       ic_fzd_convert_and_save_to_file((wchar *)MMI_FZD_FLODER_FILE_JPG, next_buf, next_buf_len);
+}
+/*****************************************************************************
+ Prototype    : ic_fzd_net_parse_voice
+ Description  : parse response
+ Input        : None
+ Output       : None
+ Return Value :
+ Calls        :
+ Called By    :
+
+        Æ½Ì¨»ØÓ¦ÓïÒô:
+       ½âÎöÓïÒôʧ°Ü£¬·µ»Ø[XT*YYYYYYYYYYYYYYY*0007*VOICE,´íÎóÂë]
+       ´íÂëÂë·Ö±ðΪ 0,1,2£º0 ±íʾ·Ç amr ÒôƵÊý¾Ý¡¢1 ±íʾÓïÒôʶ±ð²»³ö¡¢2 ±íʾÓïÒô²»¶ÔÓ¦ÈκÎÖ¸Áî
+
+*****************************************************************************/
+void ic_fzd_net_parse_voice(signed char *next_buf,int next_buf_len,signed char seq)
+{
+       signed char value = 0;
+
+       if ((NULL == next_buf) || (next_buf_len <= 0))
+       {
+        KM_FZD_TRACE_ERROR("parameter error");
+        return ;
+       }
+
+       //value ·Ö±ðΪ 0,1,2£º0 ±íʾ·Ç amr ÒôƵÊý¾Ý¡¢1 ±íʾÓïÒôʶ±ð²»³ö¡¢2 ±íʾÓïÒô²»¶ÔÓ¦ÈκÎÖ¸Áî
+       value = atoi(next_buf);
+
+}
+#endif
+
+
+#endif
+
+
diff --git a/2.sdk/gui/lv_watch/mmi_protocol/mmi_protocol_fzd.h b/2.sdk/gui/lv_watch/mmi_protocol/mmi_protocol_fzd.h
new file mode 100644 (file)
index 0000000..ffebe29
--- /dev/null
@@ -0,0 +1,213 @@
+
+
+
+#ifdef __MMI_ZHSX_SUPPORT_FZD__
+
+#ifndef __MMI_PROTOCOL_FZD_H__
+#define __MMI_PROTOCOL_FZD_H__
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif //__cplusplus
+
+
+#include "lv_watch.h"
+
+
+
+//#define __MMI_PROTOCOL_DEBUG__
+//#ifdef __MMI_PROTOCOL_DEBUG__
+//#define PROTOCOL_DEBUG_PRINTF(fmt, ...)      printf("[FZD]"fmt, ##__VA_ARGS__)
+//#else
+//#define PROTOCOL_DEBUG_PRINTF(fmt, ...)
+//#endif
+
+
+//Server address and port
+//#define HOST_NAME  "api.xcloudtech.com"
+//#define HOST_PORT (9000)
+
+
+/****************************************
+
+Êý¾Ý¸ñʽ : [MD5_DATA³§ÉÌ*É豸ID*ÄÚÈݳ¤¶È*ÄÚÈݱêʶ,ÄÚÈÝÊý¾Ý]
+
+****************************************/
+
+#define MMI_PROTOCOL_FZD_MD5_KEY_STR   "bZld0ALsZTt15tKEZhOlLPgbsO75BLTP" // "FDF9532BB5914C0F9D0999CAF99DEBB9" // "XMQcHi0lGIdru6xzW7lygBwBT8N0c09P"
+#define MMI_PROTOCOL_FZD_MD5_KEY_LEN   (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))
+#define MMI_PROTOCOL_FZD_DEVICE_NAME           "SZKW" // "ZHSX"
+#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)
+#define MMI_PROTOCOL_FZD_CONTENT_LEN_LEN       (4)
+
+// total:[MD5_DATADEVICE_NAME*DEVICE_ID*CONTENT_LEN*ACTION_STRING,ACTION_CONTENT]
+// send fixed:[MD5_DATADEVICE_NAME*DEVICE_ID*CONTENT_LEN*]
+#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_LEN*]
+#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            (15) // "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, // 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,
+       MMI_FZD_SERVER_GET_VERSION,
+       MMI_FZD_SERVER_SET_PHONEBOOK,
+       MMI_FZD_SERVER_SET_CALL,
+       MMI_FZD_SERVER_SET_REMIND,
+       
+       MMI_FZD_SERVER_SET_HEART_INTERVAL,
+       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,
+
+#ifdef __MMI_WECHAT_SUPPORT__
+       MMI_FZD_ACTION_TALK, // wechat
+#endif
+
+       MMI_FZD_ACTION_GET_WEATHER,
+
+
+
+/*******add before this line*******/
+    MMI_FZD_ACTION_MAX
+} MMI_PROTOCOL_FZD_ACTION_ENUM;
+
+
+//strtok
+char *km_strtok_r(char *s, const char *delim, char **last);
+
+//convert hex string to number
+signed int km_str_hex_string_to_number(signed char* hex_str, unsigned char hex_str_len);
+
+void mmi_protocol_fzd_receive_data_process(char * recv_str, int recv_len);
+
+bool mmi_protocol_fzd_action_link(void);
+
+bool mmi_protocol_fzd_parse_ACTION_LINK(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_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);
+
+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);
+
+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_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 __cplusplus
+} /* extern "C" */
+#endif //__cplusplus
+
+#endif
+
+#endif
+
+
index 5902438..81dd327 100644 (file)
@@ -7,10 +7,10 @@
 #include <string.h>
 #include "mmi_modem_tcp_net.h"
 #include "mmi_modem_tcp_msg_handler_impl.h"
-#if defined(MBEDTLS_MD5_C)
-#include "mbedtls/md5.h"
-#endif
-#define SEND_BUFF_MAX_LEN 1500
+//#if defined(MBEDTLS_MD5_C)
+//#include "mbedtls/md5.h"
+//#endif
+//#define SEND_BUFF_MAX_LEN 1500
 
 /**
 * Initialize interface when connection is established
@@ -26,9 +26,33 @@ void cmdmsg_handler_init_impl(void *param)
 */
 void cmdmsg_handler_login_impl(void *param)
 {
+       printf("fun = %s, line = %d\n",__FUNCTION__,__LINE__);
+       
+#ifdef __MMI_ZHSX_SUPPORT__
+       mmi_protocol_watch_heartbeat_action();
+
+#else
+
        //todo
+#endif 
+}
+
+void cmdmsg_handler_disconnect_impl(void *param)
+{
+       printf("fun = %s, line = %d\n",__FUNCTION__,__LINE__);
        
+#ifdef __MMI_ZHSX_SUPPORT__
+       mmi_protocol_watch_bind_state_set(false);
+
+       mmi_protocol_watch_heartbeat_stop();
+
+#else
+
+       //todo
+#endif
 }
+
+/*
 static void hex_to_ascii(unsigned char *input ,int len,char *output)
 {
        for(int i = 0;i<len;i++)
@@ -49,14 +73,41 @@ static void pack_MD5_head(char *input,int len,char *output)
        hex_to_ascii(digest,16,output);
        Hal_Mem_Free(input_buff);
 }
+*/
 
 /**
 * Send data specific processing interface
 */
 void send_tcp_cmdmsg_handler_impl(void *param)
 {
+       printf("fun = %s, line = %d\n",__FUNCTION__,__LINE__);
+
+#ifdef __MMI_ZHSX_SUPPORT__
        
-       printf("-------> %s, line = %d\n",__FUNCTION__,__LINE__);
+       send_cmdmsg_t *cmdmsg = (send_cmdmsg_t *)param;
+       if(NULL == cmdmsg->cmd_param || 0 == cmdmsg->cmd_type)
+       {
+               printf("fun = %s, line = %d\n",__FUNCTION__,__LINE__);
+               return;
+       }
+
+       if(!watch_modem_sim_present_check_req())
+       {
+               printf("fun = %s, line = %d\n",__FUNCTION__,__LINE__);
+               return;
+       }
+
+       char *send_cmdmsg_buff = Hal_Mem_Alloc(SEND_BUFF_MAX_LEN);
+       if(NULL != send_cmdmsg_buff)
+       {
+               memset(send_cmdmsg_buff, 0x00, SEND_BUFF_MAX_LEN);
+               memcpy(send_cmdmsg_buff, cmdmsg->cmd_param, cmdmsg->cmd_type);
+               mmi_modem_tcp_send(send_cmdmsg_buff, strlen(send_cmdmsg_buff));
+               Hal_Mem_Free(send_cmdmsg_buff);
+       }
+
+#else
+
        if(param == NULL)
                return;
        
@@ -99,6 +150,7 @@ void send_tcp_cmdmsg_handler_impl(void *param)
        //todo
        free_res:
        Hal_Mem_Free(send_cmdmsg_buff);
+#endif
 }
 
 /**
@@ -107,6 +159,39 @@ void send_tcp_cmdmsg_handler_impl(void *param)
 void read_tcp_cmdmsg_handler_impl(void *msg)
 {
        printf("fun = %s, line = %d\n",__FUNCTION__,__LINE__);
+
+#ifdef __MMI_ZHSX_SUPPORT__
+
+       tcp_manage_socket_fd_t *msgRead = (tcp_manage_socket_fd_t *)msg;
+       if((msgRead == NULL) || (msgRead->socket_fd < 0))
+               return;
+
+       signed long recv_ret;
+       int recv_len = 0;
+       //char *recv_str = (char *)malloc(PKG_LEN);
+       char *recv_str = (char *)Hal_Mem_Alloc(PKG_LEN);
+       if(NULL == recv_str)
+       {
+               printf("fun = %s, line = %d\n",__FUNCTION__,__LINE__);
+               return;
+       }
+       memset(recv_str , 0x00, PKG_LEN);
+       recv_ret = mmi_modem_tcp_read(recv_str, PKG_LEN, &recv_len);
+       
+       printf("[@CHENG_DEBUG][%s][%d]: ret=%d,len=%d,ptr=0x%x,str=%s\n", __FUNCTION__, __LINE__, recv_ret, recv_len, recv_str, recv_str);
+
+       if(0 <= recv_ret)
+       {
+               mmi_protocol_receive_data_process(recv_str, recv_len);
+       }
+
+       printf("[@CHENG_DEBUG][%s][%d]: recv_str=0x%x\n", __FUNCTION__, __LINE__, recv_str);
+       //free(recv_str);
+       Hal_Mem_Free(recv_str);
+       return;
+
+#else
+
        tcp_manage_socket_fd_t *msgRead = (tcp_manage_socket_fd_t *)msg;
        if((msgRead == NULL) || (msgRead->socket_fd < 0))
                return;
@@ -130,6 +215,6 @@ void read_tcp_cmdmsg_handler_impl(void *msg)
 free_res:
        if(recv_str != NULL)
                free(recv_str);
-       
+#endif 
 }
 
index 9d9b7c6..e6f78c0 100644 (file)
 extern "C" {
 #endif
 
+
+#ifdef __MMI_ZHSX_SUPPORT__
+#define SEND_BUFF_MAX_LEN (1024 * 2)
+#else
+#define SEND_BUFF_MAX_LEN 1500
+#endif
+
+
 typedef enum
 {
        TCPMSG_CMD_START = 0,
@@ -21,6 +29,7 @@ typedef enum
 
 void cmdmsg_handler_init_impl(void *param);
 void cmdmsg_handler_login_impl(void *param);
+void cmdmsg_handler_disconnect_impl(void *param);
 void read_tcp_cmdmsg_handler_impl(void *msg);
 void send_tcp_cmdmsg_handler_impl(void *param);
 
index 8f57bfc..09e849b 100644 (file)
@@ -18,6 +18,7 @@ void mmi_tcp_connected_interface(void *param)
 
 void mmi_tcp_disconnect_interface(void *param)
 {
+       cmdmsg_handler_disconnect_impl(param);
        //todo
 }
 
diff --git a/2.sdk/gui/lv_watch/resource/gif/anim_temperature_measuring.gif b/2.sdk/gui/lv_watch/resource/gif/anim_temperature_measuring.gif
new file mode 100644 (file)
index 0000000..5b3cb0a
Binary files /dev/null and b/2.sdk/gui/lv_watch/resource/gif/anim_temperature_measuring.gif differ
diff --git a/2.sdk/gui/lv_watch/resource/png/health_measure/icon_temperature_measure_done.png b/2.sdk/gui/lv_watch/resource/png/health_measure/icon_temperature_measure_done.png
new file mode 100644 (file)
index 0000000..379a1d7
Binary files /dev/null and b/2.sdk/gui/lv_watch/resource/png/health_measure/icon_temperature_measure_done.png differ
diff --git a/2.sdk/gui/lv_watch/resource/png/health_measure/icon_temperature_measure_fail.png b/2.sdk/gui/lv_watch/resource/png/health_measure/icon_temperature_measure_fail.png
new file mode 100644 (file)
index 0000000..8f54b60
Binary files /dev/null and b/2.sdk/gui/lv_watch/resource/png/health_measure/icon_temperature_measure_fail.png differ
index 4bf7d55..a9aecc6 100644 (file)
 
 
 //CHENG_MODIFY
-#define __CHENG_DEBUG__
+#define __CHENG_DEBUG__ // for ui print log
 
 #define __MMI_ZHSX_SUPPORT__
 
+#define __MMI_ZHSX_SUPPORT_FZD__
+
+
 #if 1 //def MMI_WECHAT_SUPPORT
 #define __MMI_WECHAT_SUPPORT__
 #endif