gengxin
author@CHENG <2393524978@qq.com>
Sat, 6 Jan 2024 07:33:11 +0000 (15:33 +0800)
committer@CHENG <2393524978@qq.com>
Sat, 6 Jan 2024 07:33:11 +0000 (15:33 +0800)
2.sdk/sdk/gui/lv_watch/lv_apps/custom_function/heng_ai_blood_pressure.c
2.sdk/sdk/gui/lv_watch/lv_apps/custom_function/heng_ai_http_protocol.c
2.sdk/sdk/gui/lv_watch/lv_apps/custom_function/heng_ai_http_protocol.h

index 6d4e05a..38a1b8e 100644 (file)
@@ -8,7 +8,7 @@
 #if 0
 static lv_obj_t * mmi_heng_ai_warning_screen_create(lv_obj_t * activity_obj)
 {
-       printf("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+       HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
        if(NULL == activity_obj)
        {
                lv_watch_activity_ext_t activity_ext = {0};
@@ -150,17 +150,22 @@ static const lv_point_t s_hengai_bp_valid_pos[] = {{0, 0}, {1, 0}, {2, 0}};
 static uint8_t s_hengai_bp_measure_count = 0;
 static uint8_t s_hengai_bp_calibrate_times = 0;
 static uint16_t s_bp_value_high = 0, s_bp_value_low = 0;
-static uint8_t s_hengai_bp_measuring = 0;
+static bool s_hengai_bp_measuring = false;
 static char s_hengai_bp_begin_time_str[24] = {0}, s_hengai_bp_end_time_str[24] = {0};
 static int * s_hengai_bp_raw_data_ptr = NULL;
 static int s_hengai_bp_raw_data_len = 0;
 
 
-uint8_t mmi_hengai_bp_is_measuring(void)
+bool mmi_hengai_bp_measuring_flag_get(void)
 {
        return (s_hengai_bp_measuring);
 }
 
+void mmi_hengai_bp_measuring_flag_set(bool flag)
+{
+       s_hengai_bp_measuring = flag;
+}
+
 char * mmi_hengai_bp_measure_action_time_string_get(uint8_t is_begin)
 {
        return ((1 == is_begin) ? s_hengai_bp_begin_time_str : s_hengai_bp_end_time_str);
@@ -188,16 +193,23 @@ void mmi_hengai_bp_raw_data_fill(void)
                lv_mem_free(s_hengai_bp_raw_data_ptr);
                s_hengai_bp_raw_data_ptr = NULL;
        }
-       s_hengai_bp_raw_data_ptr = (int *)lv_mem_alloc(MMI_HENGAI_BP_RAW_DATA_SAMPLE_RATE * MMI_BP_MEASURE_TOTAL_COUNT * sizeof(int));
+       s_hengai_bp_raw_data_ptr = (int *)lv_mem_alloc(MMI_HENGAI_BP_RAW_DATA_LEN * sizeof(int));
        _lv_memset_00(s_hengai_bp_raw_data_ptr, sizeof(s_hengai_bp_raw_data_ptr));
 
        _lv_memcpy(s_hengai_bp_raw_data_ptr, fr8012haq_blood_data_get(&s_hengai_bp_raw_data_len), sizeof(s_hengai_bp_raw_data_ptr));
 
-       printf("[@CHENG_DEBUG][%s][%d]: raw_data_len=%d\n", __FUNCTION__, __LINE__, s_hengai_bp_raw_data_len);
+       HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: raw_data_len=%d\n", __FUNCTION__, __LINE__, s_hengai_bp_raw_data_len);
 }
 
 int * mmi_hengai_bp_raw_data_ptr_get(void)
 {
+       HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+       HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG]: [0]=%d,[1]=%d,[2]=%d,[3]=%d\n",
+                                                               s_hengai_bp_raw_data_ptr[0],
+                                                               s_hengai_bp_raw_data_ptr[1],
+                                                               s_hengai_bp_raw_data_ptr[2],
+                                                               s_hengai_bp_raw_data_ptr[3]);
+       
        return s_hengai_bp_raw_data_ptr;
 }
 
@@ -274,7 +286,7 @@ static lv_heng_ai_bp_ext_t * mmi_heng_ai_bp_ext_get(void)
 
 static void mmi_heng_ai_bp_screen_prepare_destory(lv_obj_t * activity_obj)
 {
-       printf("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+       HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
                
        mmi_hengai_bp_raw_data_free();
        
@@ -291,7 +303,7 @@ void mmi_heng_ai_bp_screen_clean(void)
        lv_obj_t * activity_obj = lv_watch_get_activity_obj(ACT_ID_HENG_AI_BP);
        if(NULL != activity_obj)
        {
-               printf("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
                mmi_heng_ai_bp_screen_prepare_destory(NULL);
                lv_obj_del(activity_obj);
        }
@@ -333,6 +345,12 @@ void mmi_heng_ai_bp_measure_screen_prepare_destory(lv_obj_t * activity_obj)
     watch_set_suspend_enable(true, ACT_ID_HENG_AI_BP_MEASURE, 0);
     lv_watch_png_cache_all_free();
 
+       if(mmi_hengai_bp_measuring_flag_get())
+       {
+               mmi_hsensor_close();
+               mmi_hengai_bp_measuring_flag_set(false);
+       }
+
        lv_heng_ai_bp_measure_ext_t * watch_ext = (lv_heng_ai_bp_measure_ext_t *)mmi_heng_ai_bp_measure_screen_ext_get();
        if(NULL != watch_ext)
        {
@@ -359,7 +377,7 @@ void mmi_heng_ai_bp_measure_screen_clean(void)
        lv_obj_t * activity_obj = lv_watch_get_activity_obj(ACT_ID_HENG_AI_BP_MEASURE);
        if(NULL != activity_obj)
        {
-               printf("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
                mmi_heng_ai_bp_measure_screen_prepare_destory(NULL);
                lv_obj_del(activity_obj);
        }
@@ -370,7 +388,7 @@ void mmi_hengai_bp_measure_result_screen_event_cb(lv_obj_t * obj, lv_event_t e)
        if(LV_EVENT_CLICKED != e)
                return;
 
-    printf("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+    HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
        mmi_heng_ai_bp_measure_screen_clean();
 }
 
@@ -431,10 +449,10 @@ void mmi_hengai_bp_measure_result_screen(uint8_t result)
        else
        {
                lv_obj_t * label_title_high = lv_label_create(watch_ext->cont, NULL);
-               lv_obj_add_style(label_title_high, LV_LABEL_PART_MAIN, &lv_watch_font24);
+               lv_obj_add_style(label_title_high, LV_LABEL_PART_MAIN, &lv_watch_font24_gray);
                lv_label_set_align(label_title_high, LV_LABEL_ALIGN_CENTER);
                lv_label_set_text_id(label_title_high, WATCH_TEXT_ID_SYSTOLIC_BP);
-               lv_obj_align(label_title_high, NULL, LV_ALIGN_IN_TOP_LEFT, 103, 104);
+               lv_obj_align(label_title_high, NULL, LV_ALIGN_IN_TOP_LEFT, 103, 104 + 20);
                lv_obj_set_click(label_title_high, false);
 
                lv_obj_t * label_value_high = lv_label_create(watch_ext->cont, NULL);
@@ -447,15 +465,15 @@ void mmi_hengai_bp_measure_result_screen(uint8_t result)
                lv_obj_set_click(label_value_high, false);
 
                lv_obj_t * label_uint_high = lv_label_create(watch_ext->cont, NULL);
-               lv_obj_add_style(label_uint_high, LV_LABEL_PART_MAIN, &lv_watch_font24);
+               lv_obj_add_style(label_uint_high, LV_LABEL_PART_MAIN, &lv_watch_font24_gray);
                lv_label_set_align(label_uint_high, LV_LABEL_ALIGN_CENTER);
                lv_label_set_text(label_uint_high, "mmHg");
-               lv_obj_align(label_uint_high, label_value_high, LV_ALIGN_OUT_BOTTOM_MID, 0, 15);
+               lv_obj_align(label_uint_high, label_value_high, LV_ALIGN_OUT_BOTTOM_MID, 0, 10);
                lv_obj_set_click(label_uint_high, false);
 
                lv_obj_t * label_title_low = lv_label_create(watch_ext->cont, label_title_high);
                lv_label_set_text_id(label_title_low, WATCH_TEXT_ID_DIASTOLIC_BP);
-               lv_obj_align(label_title_low, NULL, LV_ALIGN_IN_TOP_LEFT, 280, 104);
+               lv_obj_align(label_title_low, NULL, LV_ALIGN_IN_TOP_LEFT, 280, 104 + 20);
 
                lv_obj_t * label_value_low = lv_label_create(watch_ext->cont, label_value_high);
                sprintf(value_str, "%d", s_bp_value_low);
@@ -464,7 +482,7 @@ void mmi_hengai_bp_measure_result_screen(uint8_t result)
                
                lv_obj_t * label_uint_low = lv_label_create(watch_ext->cont, label_uint_high);
                lv_label_set_text(label_uint_low, "mmHg");
-               lv_obj_align(label_uint_low, label_value_low, LV_ALIGN_OUT_BOTTOM_MID, 0, 15);
+               lv_obj_align(label_uint_low, label_value_low, LV_ALIGN_OUT_BOTTOM_MID, 0, 10);
 
                hal_rtc_t cur_time = {0};
                char time_str[24] = {0};
@@ -485,11 +503,14 @@ void mmi_hengai_bp_measure_result_screen(uint8_t result)
 
 void mmi_hengai_bp_measure_result_timeout(void * para)
 {
+       HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
        mmi_hengai_bp_measure_result_screen(3);
 }
 
-void mmi_hengai_bp_measure_update_result(bool state, uint16_t bp_value_high, uint16_t bp_value_low, char * description)
+void mmi_ui_msg_update_hengai_bp_measure_result(bool state, uint16_t bp_value_high, uint16_t bp_value_low)
 {
+       HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+
        lv_heng_ai_bp_measure_ext_t * watch_ext = (lv_heng_ai_bp_measure_ext_t *)mmi_heng_ai_bp_measure_screen_ext_get();
        if(NULL == watch_ext)
                return;
@@ -497,15 +518,18 @@ void mmi_hengai_bp_measure_update_result(bool state, uint16_t bp_value_high, uin
        if(true != watch_ext->is_watting_result)
                return;
 
+       if(NULL != watch_ext->result_timer_id)
+       {
+               Hal_Timer_Stop(watch_ext->result_timer_id);
+               watch_ext->result_timer_id = NULL;
+       }
+       
        if(true == state)
        {
                s_bp_value_high = bp_value_high;
                s_bp_value_low = bp_value_low;
-               if(NULL != description)
-               {
-
-               }
                
+               mmi_protocol_action_send_blood(s_bp_value_high, s_bp_value_low);
                mmi_hengai_bp_measure_result_screen(0);
        }
        else
@@ -514,11 +538,13 @@ void mmi_hengai_bp_measure_update_result(bool state, uint16_t bp_value_high, uin
        }
 }
 
-void mmi_hengai_bp_measure_finish_screen(void)
+void mmi_hengai_bp_measure_data_send_task_cb(lv_task_t * task)
 {
-       mmi_hsensor_close();
-       mmi_hengai_bp_measure_action_time_string_set(0);
+       mmi_hengai_bp_measure_raw_data_send();
+}
 
+void mmi_hengai_bp_measure_finish_screen(void)
+{
        lv_heng_ai_bp_measure_ext_t * watch_ext = (lv_heng_ai_bp_measure_ext_t *)mmi_heng_ai_bp_measure_screen_ext_get();
        if(NULL == watch_ext)
                return;
@@ -561,8 +587,17 @@ void mmi_hengai_bp_measure_finish_screen(void)
        lv_label_set_text_id(label_prompt, WATCH_TEXT_ID_WAIT_RESULT);
        lv_obj_align(label_prompt, NULL, LV_ALIGN_IN_TOP_MID, 0, 292);
 #endif
-       
+
+       HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
        watch_ext->result_timer_id = Hal_Timer_Start(MMI_BP_WAIT_RESULT_TIMEOUT, mmi_hengai_bp_measure_result_timeout, NULL, false);
+       
+       mmi_hengai_bp_raw_data_fill();
+       mmi_hengai_bp_measure_action_time_string_set(0);
+       mmi_hsensor_close();
+       mmi_hengai_bp_measuring_flag_set(false);
+
+       lv_task_t * data_send_task = lv_task_create(mmi_hengai_bp_measure_data_send_task_cb, 2000, LV_TASK_PRIO_HIGH, NULL);
+       lv_task_once(data_send_task);
 }
 
 void mmi_hengai_bp_measure_cycle_timeout(void * para)
@@ -571,8 +606,6 @@ void mmi_hengai_bp_measure_cycle_timeout(void * para)
 
        if(MMI_BP_MEASURE_TOTAL_COUNT < s_hengai_bp_measure_count) // stop action when 60s
        {
-               mmi_hengai_bp_raw_data_fill();
-               mmi_hengai_bp_measure_raw_data_send();
                mmi_hengai_bp_measure_finish_screen();
        }
        else
@@ -597,7 +630,7 @@ void mmi_hengai_bp_measure_start_btn_event_cb(lv_obj_t * obj, lv_event_t e)
        if(LV_EVENT_CLICKED != e)
                return;
 
-       printf("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+       HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
        lv_heng_ai_bp_measure_ext_t * watch_ext = (lv_heng_ai_bp_measure_ext_t *)mmi_heng_ai_bp_measure_screen_ext_get();
        if(NULL == watch_ext)
                return;
@@ -609,7 +642,7 @@ void mmi_hengai_bp_measure_start_btn_event_cb(lv_obj_t * obj, lv_event_t e)
        
        if(false == mmi_health_measure_wear_state_get())
        {
-               printf("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
                lv_obj_t * img = lv_img_create(cont, NULL);
                lv_img_set_src(img, ICON_HENGAI_BP_ALERT);
                lv_obj_align(img, NULL, LV_ALIGN_IN_TOP_MID, 0, 90);
@@ -623,11 +656,19 @@ void mmi_hengai_bp_measure_start_btn_event_cb(lv_obj_t * obj, lv_event_t e)
        }
        else
        {
-               printf("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
                mmi_hsensor_bp_open();
                mmi_hengai_bp_measure_action_time_string_set(1);
+               mmi_hengai_bp_measuring_flag_set(true);
                s_hengai_bp_measure_count = 0;
 
+               lv_obj_t * label_title = lv_label_create(watch_ext->cont, NULL);
+               lv_obj_add_style(label_title, LV_LABEL_PART_MAIN, &lv_watch_font32);
+               lv_label_set_align(label_title, LV_LABEL_ALIGN_CENTER);
+               lv_label_set_text_id(label_title, WATCH_TEXT_ID_IN_MEASURING);
+               lv_obj_align(label_title, NULL, LV_ALIGN_IN_TOP_MID, 0, 48);
+               lv_obj_set_click(label_title, false);
+
                gif_info_t * gif_info = gif_open(cont, ANIM_HENGAI_BP_MEASURE, 0);
                if(NULL == gif_info)
                        return;
@@ -665,7 +706,7 @@ void mmi_hengai_bp_measure_prompt_switch_event_cb(lv_obj_t * obj, lv_event_t e)
        if(LV_EVENT_CLICKED != e)
                return;
 
-       printf("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+       HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
 
        lv_heng_ai_bp_measure_ext_t * watch_ext = (lv_heng_ai_bp_measure_ext_t *)mmi_heng_ai_bp_measure_screen_ext_get();
        if(NULL == watch_ext)
@@ -706,7 +747,7 @@ void mmi_hengai_bp_measure_prompt_0(lv_obj_t * cont)
        lv_label_set_text_id(label_prompt, WATCH_TEXT_ID_CALIBRATE_PROMPT_0);
        lv_obj_align(label_prompt, NULL, LV_ALIGN_IN_TOP_MID, 0, 292);
 
-       lv_obj_t * imgbtn = mmi_bp_screen_common_right_button_create(cont, 0, 0, mmi_hengai_bp_measure_prompt_switch_event_cb);
+       lv_obj_t * imgbtn = mmi_bp_screen_common_right_button_create(cont, 0, -5, mmi_hengai_bp_measure_prompt_switch_event_cb);
        lv_watch_set_free_num(imgbtn, 0);
 
        mmi_bp_screen_common_bottom_button_create(cont, WATCH_TEXT_ID_START_MEASURE, mmi_hengai_bp_measure_start_btn_event_cb);
@@ -733,7 +774,7 @@ void mmi_hengai_bp_measure_prompt_1(lv_obj_t * cont)
        lv_label_set_text_id(label_prompt, WATCH_TEXT_ID_CALIBRATE_PROMPT_1);
        lv_obj_align(label_prompt, NULL, LV_ALIGN_IN_TOP_MID, 0, 292);
 
-       lv_obj_t * imgbtn = mmi_bp_screen_common_left_button_create(cont, 0, 0, mmi_hengai_bp_measure_prompt_switch_event_cb);
+       lv_obj_t * imgbtn = mmi_bp_screen_common_left_button_create(cont, 0, -5, mmi_hengai_bp_measure_prompt_switch_event_cb);
        lv_watch_set_free_num(imgbtn, 1);
 
        mmi_bp_screen_common_bottom_button_create(cont, WATCH_TEXT_ID_START_MEASURE, mmi_hengai_bp_measure_start_btn_event_cb);
@@ -862,6 +903,12 @@ void mmi_heng_ai_bp_calibrate_screen_prepare_destory(lv_obj_t * activity_obj)
     watch_set_suspend_enable(true, ACT_ID_HENG_AI_BP_CALIBRATE, 0);
     lv_watch_png_cache_all_free();
 
+       if(mmi_hengai_bp_measuring_flag_get())
+       {
+               mmi_hsensor_close();
+               mmi_hengai_bp_measuring_flag_set(false);
+       }
+
        lv_heng_ai_bp_calibrate_ext_t * watch_ext = (lv_heng_ai_bp_calibrate_ext_t *)mmi_heng_ai_bp_calibrate_screen_ext_get();
        if(NULL == watch_ext)
                return;
@@ -888,7 +935,7 @@ void mmi_heng_ai_bp_calibrate_screen_clean(void)
        lv_obj_t * activity_obj = lv_watch_get_activity_obj(ACT_ID_HENG_AI_BP_CALIBRATE);
        if(NULL != activity_obj)
        {
-               printf("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
                mmi_heng_ai_bp_calibrate_screen_prepare_destory(NULL);
                lv_obj_del(activity_obj);
        }
@@ -961,7 +1008,7 @@ void mmi_hengai_bp_calibrate_result_timeout(void * para)
        mmi_hengai_bp_calibrate_result_screen(false);
 }
 
-void mmi_hengai_bp_calibrate_update_result(bool is_success)
+void mmi_ui_msg_update_hengai_bp_calibrate_result(bool is_success)
 {
        lv_heng_ai_bp_calibrate_ext_t * watch_ext = (lv_heng_ai_bp_calibrate_ext_t *)mmi_heng_ai_bp_calibrate_screen_ext_get();
        if(NULL == watch_ext)
@@ -970,6 +1017,12 @@ void mmi_hengai_bp_calibrate_update_result(bool is_success)
        if(true != watch_ext->is_watting_result)
                return;
 
+       if(NULL != watch_ext->result_timer_id)
+       {
+               Hal_Timer_Stop(watch_ext->result_timer_id);
+               watch_ext->result_timer_id = NULL;
+       }
+       
        mmi_hengai_bp_calibrated_flag_set(is_success ? 1 : 0);
        mmi_hengai_bp_calibrate_result_screen(is_success);
 }
@@ -1008,7 +1061,10 @@ void mmi_hengai_bp_calibrate_finish_screen(void)
        lv_obj_align(label_prompt, NULL, LV_ALIGN_IN_TOP_MID, 0, 292);
 #endif
 
+       HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
        watch_ext->result_timer_id = Hal_Timer_Start(MMI_BP_WAIT_RESULT_TIMEOUT, mmi_hengai_bp_calibrate_result_timeout, NULL, false);
+
+       mmi_hengai_bp_calibrate_raw_data_send(s_hengai_bp_calibrate_times, s_bp_value_high, s_bp_value_low);
 }
 
 void mmi_hengai_bp_calibrate_end_input_event_cb(lv_obj_t * obj, lv_event_t e)
@@ -1016,11 +1072,9 @@ void mmi_hengai_bp_calibrate_end_input_event_cb(lv_obj_t * obj, lv_event_t e)
        if(LV_EVENT_CLICKED != e)
                return;
 
-       // send vaule
-       mmi_hengai_bp_calibrate_raw_data_send(s_hengai_bp_calibrate_times, s_bp_value_high, s_bp_value_low);
-       
        if(1 == s_hengai_bp_calibrate_times)
        {
+               mmi_hengai_bp_calibrate_raw_data_send(s_hengai_bp_calibrate_times, s_bp_value_high, s_bp_value_low);
                // once again
                mmi_heng_ai_bp_calibrate_start_screen();
        }
@@ -1296,10 +1350,7 @@ void mmi_hengai_bp_calibrate_end_btn_event_cb(lv_obj_t * obj, lv_event_t e)
 }
 
 void mmi_hengai_bp_calibrate_end_screen(void)
-{
-       mmi_hsensor_close();
-       mmi_hengai_bp_measure_action_time_string_set(0);
-       
+{      
        lv_heng_ai_bp_calibrate_ext_t * watch_ext = (lv_heng_ai_bp_calibrate_ext_t *)mmi_heng_ai_bp_calibrate_screen_ext_get();
        if(NULL == watch_ext)
                return;
@@ -1323,15 +1374,26 @@ void mmi_hengai_bp_calibrate_end_screen(void)
        lv_obj_align(label_title, NULL, LV_ALIGN_IN_TOP_MID, 0, 48);
        lv_obj_set_click(label_title, false);
 
+       lv_obj_t * img = lv_img_create(watch_ext->cont, NULL);
+       lv_img_set_src(img, ICON_HENGAI_BP_PROMPT_2);
+       lv_obj_align(img, NULL, LV_ALIGN_IN_TOP_MID, 0, 104);
+
        lv_obj_t * label_prompt = lv_label_create(watch_ext->cont, NULL);
        lv_obj_add_style(label_prompt, LV_LABEL_PART_MAIN, &lv_watch_font28);
        lv_label_set_align(label_prompt, LV_LABEL_ALIGN_CENTER);
        lv_label_set_long_mode(label_prompt, LV_LABEL_LONG_BREAK);
-       lv_obj_set_width(label_prompt, 360); // 400);
+       lv_obj_set_width(label_prompt, 320); // 400);
        lv_label_set_text_id(label_prompt, WATCH_TEXT_ID_CALIBRATE_PROMPT_3);
-       lv_obj_align(label_prompt, NULL, LV_ALIGN_IN_TOP_MID, 0, 200); // 104);
+       lv_obj_align(label_prompt, NULL, LV_ALIGN_IN_TOP_MID, 0, 292); // 104);
 
-       mmi_bp_screen_common_bottom_button_create(watch_ext->cont, WATCH_TEXT_ID_OK, mmi_hengai_bp_calibrate_end_btn_event_cb);
+       //
+       s_hengai_bp_calibrate_times++;
+       mmi_hengai_bp_raw_data_fill();
+       mmi_hengai_bp_measure_action_time_string_set(0);
+       mmi_hsensor_close();
+       mmi_hengai_bp_measuring_flag_set(false);
+
+       mmi_bp_screen_common_bottom_button_create(watch_ext->cont, WATCH_TEXT_ID_IN_CALIBRATE_PROMPT_BTN, mmi_hengai_bp_calibrate_end_btn_event_cb);
 }
 
 void mmi_hengai_bp_calibrate_cycle_timeout(void * para)
@@ -1340,8 +1402,6 @@ void mmi_hengai_bp_calibrate_cycle_timeout(void * para)
                
        if(MMI_BP_MEASURE_TOTAL_COUNT < s_hengai_bp_measure_count) // stop action when 60s
        {
-               s_hengai_bp_calibrate_times++;
-               mmi_hengai_bp_raw_data_fill();
                mmi_hengai_bp_calibrate_end_screen();           
        }
 }
@@ -1368,9 +1428,10 @@ void mmi_heng_ai_bp_calibrate_start_screen(void)
        }
        else
        {
-               printf("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
                mmi_hsensor_bp_open();
                mmi_hengai_bp_measure_action_time_string_set(1);
+               mmi_hengai_bp_measuring_flag_set(true);
                s_hengai_bp_measure_count = 0;
                
                lv_obj_t * label_title = lv_label_create(watch_ext->cont, NULL);
@@ -1433,7 +1494,7 @@ void mmi_hengai_bp_calibrate_prompt_switch_event_cb(lv_obj_t * obj, lv_event_t e
        if(LV_EVENT_CLICKED != e)
                return;
 
-       printf("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+       HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
 
        lv_heng_ai_bp_calibrate_ext_t * watch_ext = (lv_heng_ai_bp_calibrate_ext_t *)mmi_heng_ai_bp_calibrate_screen_ext_get();
        if(NULL == watch_ext)
@@ -1482,7 +1543,7 @@ void mmi_hengai_bp_calibrate_prompt_0(lv_obj_t * cont)
        lv_label_set_text_id(label_prompt, WATCH_TEXT_ID_CALIBRATE_PROMPT_0);
        lv_obj_align(label_prompt, NULL, LV_ALIGN_IN_TOP_MID, 0, 292);
 
-       lv_obj_t * imgbtn = mmi_bp_screen_common_right_button_create(cont, 0, 0, mmi_hengai_bp_calibrate_prompt_switch_event_cb);
+       lv_obj_t * imgbtn = mmi_bp_screen_common_right_button_create(cont, 0, -5, mmi_hengai_bp_calibrate_prompt_switch_event_cb);
        lv_watch_set_free_num(imgbtn, 0);
 
        mmi_bp_screen_common_bottom_button_create(cont, WATCH_TEXT_ID_START_CALIBRATE, mmi_hengai_bp_calibrate_start_btn_event_cb);
@@ -1510,10 +1571,10 @@ void mmi_hengai_bp_calibrate_prompt_1(lv_obj_t * cont)
        lv_obj_align(label_prompt, NULL, LV_ALIGN_IN_TOP_MID, 0, 292);
 
        lv_obj_t * imgbtn = NULL;
-       imgbtn = mmi_bp_screen_common_left_button_create(cont, 0, 0, mmi_hengai_bp_calibrate_prompt_switch_event_cb);
+       imgbtn = mmi_bp_screen_common_left_button_create(cont, 0, -5, mmi_hengai_bp_calibrate_prompt_switch_event_cb);
        lv_watch_set_free_num(imgbtn, 1);
        
-       imgbtn = mmi_bp_screen_common_right_button_create(cont, 0, 0, mmi_hengai_bp_calibrate_prompt_switch_event_cb);
+       imgbtn = mmi_bp_screen_common_right_button_create(cont, 0, -5, mmi_hengai_bp_calibrate_prompt_switch_event_cb);
        lv_watch_set_free_num(imgbtn, 2);
 
        mmi_bp_screen_common_bottom_button_create(cont, WATCH_TEXT_ID_START_CALIBRATE, mmi_hengai_bp_calibrate_start_btn_event_cb);
@@ -1532,11 +1593,11 @@ void mmi_hengai_bp_calibrate_prompt_2(lv_obj_t * cont)
        lv_obj_add_style(label_prompt, LV_LABEL_PART_MAIN, &lv_watch_font28);
        lv_label_set_align(label_prompt, LV_LABEL_ALIGN_CENTER);
        lv_label_set_long_mode(label_prompt, LV_LABEL_LONG_BREAK);
-       lv_obj_set_width(label_prompt, 400);
+       lv_obj_set_width(label_prompt, 320);
        lv_label_set_text_id(label_prompt, WATCH_TEXT_ID_CALIBRATE_PROMPT_2);
-       lv_obj_align(label_prompt, NULL, LV_ALIGN_IN_TOP_MID, 0, 104);
+       lv_obj_align(label_prompt, NULL, LV_ALIGN_IN_TOP_MID, 0, 130); // 104);
 
-       lv_obj_t * imgbtn = mmi_bp_screen_common_left_button_create(cont, 0, 0, mmi_hengai_bp_calibrate_prompt_switch_event_cb);
+       lv_obj_t * imgbtn = mmi_bp_screen_common_left_button_create(cont, 0, -5, mmi_hengai_bp_calibrate_prompt_switch_event_cb);
        lv_watch_set_free_num(imgbtn, 3);
        
        mmi_bp_screen_common_bottom_button_create(cont, WATCH_TEXT_ID_START_CALIBRATE, mmi_hengai_bp_calibrate_start_btn_event_cb);
@@ -1695,7 +1756,6 @@ lv_obj_t * mmi_heng_ai_bp_attempt_mode_create(lv_obj_t * tileview, uint16_t id)
 
 void mmi_heng_ai_bp_tileview_led(lv_obj_t * tileview)
 {
-#if 0
        lv_heng_ai_bp_ext_t * ext = mmi_heng_ai_bp_ext_get();
        if(NULL == ext)
            return NULL;
@@ -1719,19 +1779,18 @@ void mmi_heng_ai_bp_tileview_led(lv_obj_t * tileview)
         }
                
         lv_led_off(ext->led[i]);
-        lv_obj_set_size(ext->led[i], 6, 6);
+        lv_obj_set_size(ext->led[i], 8, 8);
     }
        
        lv_coord_t x = -1, y = -1;
        lv_tileview_get_tile_act(tileview, &x, &y);
        lv_led_on(ext->led[x]);
-       lv_obj_set_size(ext->led[x], 10, 10);
+       lv_obj_set_size(ext->led[x], 12, 12);
 
     PHONEBOOK_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: x=%d\n", __FUNCTION__, __LINE__, x);
        
     lv_obj_set_pos(ext->led_cont, LV_HOR_RES * x + (LV_HOR_RES - lv_obj_get_width(ext->led_cont)) / 2,
                                        LV_VER_RES - lv_obj_get_width(ext->led_cont) - 10);
-#endif
 }
 
 void mmi_heng_ai_bp_tileview_event_cb(lv_obj_t * tileview, lv_event_t e)
@@ -1739,7 +1798,7 @@ void mmi_heng_ai_bp_tileview_event_cb(lv_obj_t * tileview, lv_event_t e)
        if(LV_EVENT_VALUE_CHANGED != e)
                return;
 
-       //mmi_heng_ai_bp_tileview_led(tileview);
+       mmi_heng_ai_bp_tileview_led(tileview);
 }
 
 lv_obj_t * mmi_heng_ai_bp_screen_create(lv_obj_t * activity_obj)
@@ -1763,6 +1822,7 @@ lv_obj_t * mmi_heng_ai_bp_screen_create(lv_obj_t * activity_obj)
         return NULL;
 
 #if 0
+#if 1
     if(false == watch_modem_sim_present_check_req())
     {
                lv_watch_obj_set_anim_mode(watch_obj, LV_WATCH_ANIM_HOR_RIGHT_HIDE);
@@ -1779,6 +1839,8 @@ lv_obj_t * mmi_heng_ai_bp_screen_create(lv_obj_t * activity_obj)
                lv_obj_align(label_1, NULL, LV_ALIGN_IN_TOP_MID, 0, 278);
                lv_obj_set_click(label_1, false);
     }
+#endif
+#if 1
        else if(true != mmi_watch_tcp_connect_state_get()
                || true != mmi_protocol_watch_bind_state_get()
                )
@@ -1797,6 +1859,8 @@ lv_obj_t * mmi_heng_ai_bp_screen_create(lv_obj_t * activity_obj)
                lv_obj_align(label_1, NULL, LV_ALIGN_IN_TOP_MID, 0, 278);
                lv_obj_set_click(label_1, false);
     }
+#endif
+#if 1
        else if(false == mmi_health_measure_wear_state_get())
        {
                lv_watch_obj_set_anim_mode(watch_obj, LV_WATCH_ANIM_HOR_RIGHT_HIDE);
@@ -1814,6 +1878,7 @@ lv_obj_t * mmi_heng_ai_bp_screen_create(lv_obj_t * activity_obj)
                lv_obj_set_click(label_1, false);
        }
        else
+#endif
 #endif
        {
                lv_watch_obj_set_anim_mode(watch_obj, LV_WATCH_ANIM_NO);
@@ -1862,9 +1927,9 @@ lv_obj_t * mmi_heng_ai_bp_screen_create(lv_obj_t * activity_obj)
                
            lv_watch_obj_add_element(tileview);
            lv_watch_obj_add_element(lv_page_get_scrl(tileview));
-               //lv_obj_set_event_cb(tileview, mmi_heng_ai_bp_tileview_event_cb);
+               lv_obj_set_event_cb(tileview, mmi_heng_ai_bp_tileview_event_cb);
 
-               //mmi_heng_ai_bp_tileview_led(tileview);
+               mmi_heng_ai_bp_tileview_led(tileview);
        }
 
        return watch_obj;
@@ -1892,13 +1957,13 @@ void __debug_timer_cb(void * param)
 {
        char temp_buff[128] = {0};
        
-       //»ñÈ¡48×Ö½ÚaslccÂëµÄÊ®Áù½øÖÆÑªÑ¹Êý¾Ýµ½blood_buf£¬×¢Òâ:blood_buf³¤¶ÈÒª´óÓÚµÈÓÚ48*2×Ö½Ú
+       //��ȡ48�ֽ�aslcc���ʮ������Ѫѹ���ݵ�blood_buf��ע��:blood_buf����Ҫ���ڵ���48*2�ֽ�
        //void fr8012haq_blood_data_get(char *blood_buf)
        fr8012haq_blood_data_get(temp_buff);
        
-       printf("[@CHENG_DEBUG][%s][%d]: %s\n", __FUNCTION__, __LINE__, temp_buff);
-       printf("[@CHENG_DEBUG][%d]: %s\n", __LINE__, temp_buff + 31);
-       printf("[@CHENG_DEBUG][%d]: %s\n", __LINE__, temp_buff + 63);
+       HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: %s\n", __FUNCTION__, __LINE__, temp_buff);
+       HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%d]: %s\n", __LINE__, temp_buff + 31);
+       HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%d]: %s\n", __LINE__, temp_buff + 63);
 
        __debug_timer_start();
 }
index 4e9cb56..d633c23 100644 (file)
@@ -28,11 +28,11 @@ static void response_cb(char * data, int len, int num, void *cbdata)
 {
        char * temp;
 
-       printf("[@CHENG_DEBUG][%s][%d]: data_len=%d\n", __FUNCTION__, __LINE__, len);
+       HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: data_len=%d\n", __FUNCTION__, __LINE__, len);
 
        temp = (void*)malloc(response_len + len);
        if (!temp) {
-        printf("Malloc failed...\n");
+        HENGAI_HEALTH_DEBUG_PRINTF("Malloc failed...\n");
                return;
        }
        memset(temp, 0, response_len + len);
@@ -44,7 +44,7 @@ static void response_cb(char * data, int len, int num, void *cbdata)
        response_data = temp;
        response_len += len;
 
-       printf("[@CHENG_DEBUG][%s][%d]: response_len=%d\n", __FUNCTION__, __LINE__, response_len);
+       HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: response_len=%d\n", __FUNCTION__, __LINE__, response_len);
 }
 
 void mmi_hengai_http_post_resource_free(void)
@@ -91,7 +91,6 @@ int mmi_hengai_http_post_json_data(char * url, char * post_data, char * token)
                sprintf(temp_str, "token: %s\r\n", token);
                s_hengai_http_client_list_header = http_client_list_append(s_hengai_http_client_list_header, temp_str);
        }
-       // "dc5aed59e2fce3060cd1118b41b19552"
        s_hengai_http_client_list_header = http_client_list_append(s_hengai_http_client_list_header, "Content-Type: application/json\r\n");
     s_hengai_http_client_list_header = http_client_list_append(s_hengai_http_client_list_header, "Accept: */*\r\n");
     http_client_setopt(s_hengai_http_client, HTTPCLIENT_OPT_HTTPHEADER, s_hengai_http_client_list_header);
@@ -99,7 +98,7 @@ int mmi_hengai_http_post_json_data(char * url, char * post_data, char * token)
     http_client_getinfo(s_hengai_http_client, HTTPCLIENT_GETINFO_TCP_STATE, &response_code);
     if(response_code != HTTP_TCP_ESTABLISHED)
        {
-        printf("http tcp not connecting\n");
+        HENGAI_HEALTH_DEBUG_PRINTF("http tcp not connecting\n");
         ret = -1;
         goto EXIT;
     }
@@ -107,7 +106,7 @@ int mmi_hengai_http_post_json_data(char * url, char * post_data, char * token)
     response_code = http_client_perform(s_hengai_http_client);    /*execute http send and recv*/
     if(response_code != HTTP_CLIENT_OK)
        {
-        printf("http perform have some wrong=%d\n", response_code);
+        HENGAI_HEALTH_DEBUG_PRINTF("http perform have some wrong=%d\n", response_code);
         ret = -3;
         goto EXIT;
        }
@@ -115,7 +114,7 @@ int mmi_hengai_http_post_json_data(char * url, char * post_data, char * token)
     http_client_getinfo(s_hengai_http_client, HTTPCLIENT_GETINFO_RESPONSE_CODE, &response_code);
     if (response_code != 200 && response_code != 204)
        {
-        printf("response is not 'HTTP OK'=%d\n", response_code);
+        HENGAI_HEALTH_DEBUG_PRINTF("response is not 'HTTP OK'=%d\n", response_code);
     }
        
        if(NULL != s_hengai_http_revceive_buf)
@@ -126,7 +125,7 @@ int mmi_hengai_http_post_json_data(char * url, char * post_data, char * token)
        s_hengai_http_revceive_buf = lv_mem_alloc(response_len + 1);
        _lv_memset_00(s_hengai_http_revceive_buf, response_len + 1);
        _lv_memcpy(s_hengai_http_revceive_buf, response_data, response_len);
-       printf("[@CHENG_DEBUG][%s][%d]: data_len=%d\n", __FUNCTION__, __LINE__, response_len);
+       HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: data_len=%d\n", __FUNCTION__, __LINE__, response_len);
 
 EXIT:
        mmi_hengai_http_post_resource_free();
@@ -145,10 +144,10 @@ int mmi_hengai_http_post_data(char * url, char * post_data, char * token)
                s_hengai_http_post_try_count++;
 
                int ret = mmi_hengai_http_post_json_data(url, post_data, token);
-               printf("[@CHENG_DEBUG][%s][%d]: ret=%d\n", __FUNCTION__, __LINE__, ret);
+               HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: ret=%d\n", __FUNCTION__, __LINE__, ret);
                if(0 == ret)
                {
-                       printf("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+                       HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
                        ret_value = 0;
                        break;
                }
@@ -156,7 +155,7 @@ int mmi_hengai_http_post_data(char * url, char * post_data, char * token)
                {
                        if(HENGAI_HTTP_POST_TRY_COUNT_MAX <= s_hengai_http_post_try_count)
                        {
-                               printf("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+                               HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
                                mmi_hengai_http_post_resource_free();
                                ret_value = -1;
                                break;
@@ -173,12 +172,18 @@ int mmi_hengai_http_post_data(char * url, char * post_data, char * token)
 // measure data
 void mmi_hengai_bp_measure_raw_data_send(void)
 {
+       HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+       
        char imei[16 + 1] = {0};
        app_adp_get_imei_req(imei);
 
        char * begin_time_str = mmi_hengai_bp_measure_action_time_string_get(1);
        char * end_time_str = mmi_hengai_bp_measure_action_time_string_get(0);
+#if 0 // def HENGAI_HTTP_TEST
        char * token = "dc5aed59e2fce3060cd1118b41b19552";
+#else
+       char * token = mmi_hengai_health_token_get();
+#endif
        //int test_number_array[] = {1012744,864594,698914,532908,402542,317532,235462,168856,142664,109818,42654};
        
        cJSON * json_send = cJSON_CreateObject();
@@ -198,17 +203,16 @@ void mmi_hengai_bp_measure_raw_data_send(void)
        int ret = mmi_hengai_http_post_data(url, post_data, token);
        if(0 == ret)
        {
-               printf("[@CHENG_DEBUG][%s][%d]: %d\n", __FUNCTION__, __LINE__, strlen(s_hengai_http_revceive_buf));
-               printf("[@CHENG_DEBUG][%d]: %s\n", __LINE__, s_hengai_http_revceive_buf);
-               printf("[@CHENG_DEBUG][%d]: %s\n", __LINE__, s_hengai_http_revceive_buf + 63);
+               HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: %d\n", __FUNCTION__, __LINE__, strlen(s_hengai_http_revceive_buf));
+               HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG]: %s\n", s_hengai_http_revceive_buf);
+               HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG]: %s\n", s_hengai_http_revceive_buf + 100);
                
                cJSON * json_recv = cJSON_Parse(s_hengai_http_revceive_buf);
                if(NULL != json_recv)
                {
-                       if(cJSON_GetIntValue(cJSON_GetObjectItem(json_recv, "status")))
+                       if(cJSON_IsTrue(cJSON_GetObjectItem(json_recv, "status")))
                        {
-                               // true
-                               printf("[@CHENG_DEBUG][%s][%d]: true\n", __FUNCTION__, __LINE__);
+                               HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: true\n", __FUNCTION__, __LINE__);
                                
                                cJSON * json_data = cJSON_GetObjectItem(json_recv, "data");
                                uint16_t bp_value_high = cJSON_GetIntValue(cJSON_GetObjectItem(json_data, "sbp"));
@@ -216,24 +220,23 @@ void mmi_hengai_bp_measure_raw_data_send(void)
                                char * description = cJSON_GetStringValue(cJSON_GetObjectItem(json_data, "description"));
 
                                // update
-                               mmi_hengai_bp_measure_update_result(true, bp_value_high, bp_value_low, description);
+                               mmi_ui_msg_action_hengai_bp_measure_result(true, bp_value_high, bp_value_low);
                        }
                        else
                        {
-                               // false
-                               printf("[@CHENG_DEBUG][%s][%d]: false\n", __FUNCTION__, __LINE__);
+                               HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: false\n", __FUNCTION__, __LINE__);
                                // update
-                               mmi_hengai_bp_measure_update_result(false, 0, 0, NULL);
+                               mmi_ui_msg_action_hengai_bp_measure_result(false, 0, 0);
                        }
                }
                else
                {
-                       printf("[@CHENG_DEBUG][%s][%d]: not json file\n", __FUNCTION__, __LINE__);
+                       HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: not json file\n", __FUNCTION__, __LINE__);
                }
                
                if(NULL != json_recv)
                {
-                       printf("[@CHENG_DEBUG][%s][%d]: free json root\n", __FUNCTION__, __LINE__);
+                       HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: free json root\n", __FUNCTION__, __LINE__);
                        cJSON_Delete(json_recv);
                        json_recv = NULL;
                }
@@ -249,7 +252,11 @@ void mmi_hengai_bp_measure_raw_data_send(void)
 // calibrate mode
 void mmi_hengai_bp_calibrate_model_send(void)
 {
+#if 0 // def HENGAI_HTTP_TEST
        char * token = "dc5aed59e2fce3060cd1118b41b19552";
+#else
+       char * token = mmi_hengai_health_token_get();
+#endif
        char imei[16 + 1] = {0};
        app_adp_get_imei_req(imei);
        
@@ -266,26 +273,26 @@ void mmi_hengai_bp_calibrate_model_send(void)
        int ret = mmi_hengai_http_post_data(url, post_data, token);
        if(0 == ret)
        {
-               printf("[@CHENG_DEBUG][%s][%d]: %d\n", __FUNCTION__, __LINE__, strlen(s_hengai_http_revceive_buf));
-               printf("[@CHENG_DEBUG][%d]: %s\n", __LINE__, s_hengai_http_revceive_buf);
-               printf("[@CHENG_DEBUG][%d]: %s\n", __LINE__, s_hengai_http_revceive_buf + 63);
+               HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: %d\n", __FUNCTION__, __LINE__, strlen(s_hengai_http_revceive_buf));
+               HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG]: %s\n", s_hengai_http_revceive_buf);
+               HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG]: %s\n", s_hengai_http_revceive_buf + 100);
                
                cJSON * json_recv = cJSON_Parse(s_hengai_http_revceive_buf);
                if(NULL != json_recv)
                {
-                       printf("[@CHENG_DEBUG][%s][%d]: json file\n", __FUNCTION__, __LINE__);
+                       HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: json file\n", __FUNCTION__, __LINE__);
                        
-                       bool status_value = cJSON_GetIntValue(cJSON_GetObjectItem(json_recv, "status"));
-                       mmi_hengai_bp_calibrate_update_result(status_value);
+                       bool status_value = cJSON_IsTrue(cJSON_GetObjectItem(json_recv, "status"));
+                       mmi_ui_msg_action_hengai_bp_calibrate_result(status_value);
                }
                else
                {
-                       printf("[@CHENG_DEBUG][%s][%d]: not json file\n", __FUNCTION__, __LINE__);
+                       HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: not json file\n", __FUNCTION__, __LINE__);
                }
                
                if(NULL != json_recv)
                {
-                       printf("[@CHENG_DEBUG][%s][%d]: free json root\n", __FUNCTION__, __LINE__);
+                       HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: free json root\n", __FUNCTION__, __LINE__);
                        cJSON_Delete(json_recv);
                        json_recv = NULL;
                }
@@ -300,7 +307,11 @@ void mmi_hengai_bp_calibrate_model_send(void)
 
 void mmi_hengai_bp_calibrate_raw_data_send(uint8_t calibrate_times, uint16_t bp_value_high, uint16_t bp_value_low)
 {
+#if 0 // def HENGAI_HTTP_TEST
        char * token = "dc5aed59e2fce3060cd1118b41b19552";
+#else
+       char * token = mmi_hengai_health_token_get();
+#endif
        char imei[16 + 1] = {0};
        app_adp_get_imei_req(imei);
 
@@ -326,16 +337,16 @@ void mmi_hengai_bp_calibrate_raw_data_send(uint8_t calibrate_times, uint16_t bp_
        int ret = mmi_hengai_http_post_data(url, post_data, token);
        if(0 == ret)
        {
-               printf("[@CHENG_DEBUG][%s][%d]: %d\n", __FUNCTION__, __LINE__, strlen(s_hengai_http_revceive_buf));
-               printf("[@CHENG_DEBUG][%d]: %s\n", __LINE__, s_hengai_http_revceive_buf);
-               printf("[@CHENG_DEBUG][%d]: %s\n", __LINE__, s_hengai_http_revceive_buf + 63);
+               HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: %d\n", __FUNCTION__, __LINE__, strlen(s_hengai_http_revceive_buf));
+               HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG]: %s\n", s_hengai_http_revceive_buf);
+               HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG]: %s\n", s_hengai_http_revceive_buf + 100);
                
                cJSON * json_recv = cJSON_Parse(s_hengai_http_revceive_buf);
                if(NULL != json_recv)
                {
-                       if(cJSON_GetIntValue(cJSON_GetObjectItem(json_recv, "status")))
+                       if(cJSON_IsTrue(cJSON_GetObjectItem(json_recv, "status")))
                        {
-                               printf("[@CHENG_DEBUG][%s][%d]: true\n", __FUNCTION__, __LINE__);
+                               HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: true\n", __FUNCTION__, __LINE__);
                                if(2 <= calibrate_times)
                                {
                                        mmi_hengai_bp_calibrate_model_send();
@@ -343,17 +354,21 @@ void mmi_hengai_bp_calibrate_raw_data_send(uint8_t calibrate_times, uint16_t bp_
                        }
                        else
                        {
-                               printf("[@CHENG_DEBUG][%s][%d]: false\n", __FUNCTION__, __LINE__);
+                               HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: false\n", __FUNCTION__, __LINE__);
+                               if(2 <= calibrate_times)
+                               {
+                                       mmi_ui_msg_action_hengai_bp_calibrate_result(false);
+                               }
                        }
                }
                else
                {
-                       printf("[@CHENG_DEBUG][%s][%d]: not json file\n", __FUNCTION__, __LINE__);
+                       HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: not json file\n", __FUNCTION__, __LINE__);
                }
                
                if(NULL != json_recv)
                {
-                       printf("[@CHENG_DEBUG][%s][%d]: free json root\n", __FUNCTION__, __LINE__);
+                       HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: free json root\n", __FUNCTION__, __LINE__);
                        cJSON_Delete(json_recv);
                        json_recv = NULL;
                }
@@ -394,9 +409,9 @@ void mmi_hengai_bp_activation_feedback(void)
                json_recv = cJSON_Parse(s_hengai_http_revceive_buf);
                if(NULL != json_recv)
                {
-                       printf("[@CHENG_DEBUG][%s][%d]: json file\n", __FUNCTION__, __LINE__);
+                       HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: json file\n", __FUNCTION__, __LINE__);
                        
-                       if(cJSON_GetIntValue(cJSON_GetObjectItem(json_recv, "status")))
+                       if(cJSON_IsTrue(cJSON_GetObjectItem(json_recv, "status")))
                        {
                                // true
                                mmi_hengai_health_activated_flag_set(1);
@@ -408,12 +423,12 @@ void mmi_hengai_bp_activation_feedback(void)
                }
                else
                {
-                       printf("[@CHENG_DEBUG][%s][%d]: not json file\n", __FUNCTION__, __LINE__);
+                       HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: not json file\n", __FUNCTION__, __LINE__);
                }
                
                if(NULL != json_recv)
                {
-                       printf("[@CHENG_DEBUG][%s][%d]: free json root\n", __FUNCTION__, __LINE__);
+                       HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: free json root\n", __FUNCTION__, __LINE__);
                        cJSON_Delete(json_recv);
                        json_recv = NULL;
                }
@@ -428,7 +443,7 @@ void mmi_hengai_bp_activation_feedback(void)
 
 void mmi_hengai_bp_activation_check_action(void)
 {
-       printf("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+       HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
        
        if(0 == mmi_hengai_bp_is_activated())
        {
@@ -462,17 +477,17 @@ void mmi_hengai_bp_activation_check_action(void)
                        json_recv = cJSON_Parse(s_hengai_http_revceive_buf);
                        if(NULL != json_recv)
                        {
-                               printf("[@CHENG_DEBUG][%s][%d]: json file\n", __FUNCTION__, __LINE__);
+                               HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: json file\n", __FUNCTION__, __LINE__);
                                
                                // true
-                               if(cJSON_GetIntValue(cJSON_GetObjectItem(json_recv, "status")))
+                               if(cJSON_IsTrue(cJSON_GetObjectItem(json_recv, "status")))
                                {
                                        cJSON * json_data = cJSON_GetObjectItem(json_recv, "data");
                                        char * act_code = cJSON_GetStringValue(cJSON_GetObjectItem(json_data, "activation_code"));
                                                
                                        mmi_hengai_health_act_code_set(act_code);
 
-                                       // »ñµÃÁ˼¤»îÂ룬·¢Ë͸øÏ³Á¿â£¬²¢µÃµ½ÕýÈ··µ»ØºóÇëÇó
+                                       // ����˼����룬���͸��³��⣬���õ���ȷ���غ�����
                                        // if()
                                        {
                                                mmi_hengai_bp_activation_feedback();
@@ -485,12 +500,12 @@ void mmi_hengai_bp_activation_check_action(void)
                        }
                        else
                        {
-                               printf("[@CHENG_DEBUG][%s][%d]: not json file\n", __FUNCTION__, __LINE__);
+                               HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: not json file\n", __FUNCTION__, __LINE__);
                        }
                        
                        if(NULL != json_recv)
                        {
-                               printf("[@CHENG_DEBUG][%s][%d]: free json root\n", __FUNCTION__, __LINE__);
+                               HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: free json root\n", __FUNCTION__, __LINE__);
                                cJSON_Delete(json_recv);
                                json_recv = NULL;
                        }
@@ -508,15 +523,15 @@ void mmi_hengai_bp_activation_check_action(void)
 
 void mmi_hengai_algorithm_interface_login_action(void)
 {
-       printf("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+       HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
        
-       //if(0 == mmi_hengai_bp_is_activated())
+       if(0 == mmi_hengai_health_activated_flag_get())
        {
                cJSON * json_send = json_send = cJSON_CreateObject();
                cJSON_AddItemToObject(json_send, "app_key", cJSON_CreateString(HENGAI_HTTP_POST_APP_KEY));
                cJSON_AddItemToObject(json_send, "account_type", cJSON_CreateNumber(0));
-               cJSON_AddItemToObject(json_send, "account", cJSON_CreateString("18912345678"));
-               cJSON_AddItemToObject(json_send, "name", cJSON_CreateString("18912345678"));
+               cJSON_AddItemToObject(json_send, "account", cJSON_CreateString("18912345670"));
+               cJSON_AddItemToObject(json_send, "name", cJSON_CreateString("18912345670"));
                cJSON_AddItemToObject(json_send, "password", cJSON_CreateString("123456"));
                cJSON_AddItemToObject(json_send, "gender", cJSON_CreateNumber(3));
                cJSON_AddItemToObject(json_send, "birthday", cJSON_CreateString("2000-10-01"));
@@ -532,31 +547,37 @@ void mmi_hengai_algorithm_interface_login_action(void)
                int ret = mmi_hengai_http_post_data(url, post_data, NULL);
                if(0 == ret)
                {
+                       HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: %d\n", __FUNCTION__, __LINE__, strlen(s_hengai_http_revceive_buf));
+                       HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG]: %s\n", s_hengai_http_revceive_buf);
+                       HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG]: %s\n", s_hengai_http_revceive_buf + 100);
+                       HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG]: %s\n", s_hengai_http_revceive_buf + 200);
+                       HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG]: %s\n", s_hengai_http_revceive_buf + 300);
+                       
                        cJSON * json_recv = cJSON_Parse(s_hengai_http_revceive_buf);
                        if(NULL != json_recv)
                        {
-                               if(cJSON_GetIntValue(cJSON_GetObjectItem(json_recv, "status")))
+                               if(cJSON_IsTrue(cJSON_GetObjectItem(json_recv, "status")))
                                {
-                                       printf("[@CHENG_DEBUG][%s][%d]: true\n", __FUNCTION__, __LINE__);
+                                       HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: true\n", __FUNCTION__, __LINE__);
                                        
                                        cJSON * json_data = cJSON_GetObjectItem(json_recv, "data");
                                        char * token = cJSON_GetStringValue(cJSON_GetObjectItem(json_data, "token"));
-                                       // save token
-                                       
+
+                                       mmi_hengai_health_token_set(token);
                                }
                                else
                                {
-                                       printf("[@CHENG_DEBUG][%s][%d]: false\n", __FUNCTION__, __LINE__);
+                                       HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: false\n", __FUNCTION__, __LINE__);
                                }
                        }
                        else
                        {
-                               printf("[@CHENG_DEBUG][%s][%d]: not json file\n", __FUNCTION__, __LINE__);
+                               HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: not json file\n", __FUNCTION__, __LINE__);
                        }
                        
                        if(NULL != json_recv)
                        {
-                               printf("[@CHENG_DEBUG][%s][%d]: free json root\n", __FUNCTION__, __LINE__);
+                               HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: free json root\n", __FUNCTION__, __LINE__);
                                cJSON_Delete(json_recv);
                                json_recv = NULL;
                        }
@@ -581,7 +602,7 @@ void mmi_hengai_health_data_nv_write(void)
        
        if(nv_data_length != UI_NV_Write_Req(NV_SECTION_UI_HENGAI_HEALTH_DATA, 0, nv_data_length, (uint8_t *)&s_hengai_health_data))
        {
-               printf("[@CHENG_DEBUG][%s][%d]: nv write fail\n", __FUNCTION__, __LINE__);
+               HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: nv write fail\n", __FUNCTION__, __LINE__);
        }
 }
 
@@ -591,7 +612,7 @@ void mmi_hengai_health_data_nv_read(void)
        
        if(nv_data_length != UI_NV_Read_Req(NV_SECTION_UI_HENGAI_HEALTH_DATA, 0, nv_data_length, (uint8_t *)&s_hengai_health_data))
        {
-               printf("[@CHENG_DEBUG][%s][%d]: nv read fail\n", __FUNCTION__, __LINE__);
+               HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: nv read fail\n", __FUNCTION__, __LINE__);
                _lv_memset_00(&s_hengai_health_data, sizeof(nv_watch_hengai_health_data_t));
        }
 }
@@ -614,6 +635,14 @@ char * mmi_hengai_health_req_code_get(void)
 
 void mmi_hengai_health_req_code_set(char * req_code)
 {
+       if(NULL == req_code)
+               return;
+       
+       if(NV_HENGAI_HEALTH_REQ_CODE_LEN < strlen(req_code))
+               return;
+
+       HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+       HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG]: %s\n", req_code);
        _lv_memcpy(s_hengai_health_data.req_code, req_code, strlen(req_code));
        mmi_hengai_health_data_nv_write();
 }
@@ -625,6 +654,14 @@ char * mmi_hengai_health_act_code_get(void)
 
 void mmi_hengai_health_act_code_set(char * act_code)
 {
+       if(NULL == act_code)
+               return;
+       
+       if(NV_HENGAI_HEALTH_ACT_CODE_LEN < strlen(act_code))
+               return;
+
+       HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+       HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG]: %s\n", act_code);
        _lv_memcpy(s_hengai_health_data.act_code, act_code, strlen(act_code));
        mmi_hengai_health_data_nv_write();
 }
@@ -636,6 +673,14 @@ char * mmi_hengai_health_token_get(void)
 
 void mmi_hengai_health_token_set(char * token)
 {
+       if(NULL == token)
+               return;
+       
+       if(NV_HENGAI_HEALTH_TOKEN_LEN < strlen(token))
+               return;
+       
+       HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+       HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG]: %s\n", token);
        _lv_memcpy(s_hengai_health_data.token, token, strlen(token));
        mmi_hengai_health_data_nv_write();
 }
index 78c930e..eae84c8 100644 (file)
@@ -18,7 +18,7 @@ extern "C" {
 
 #ifdef __MMI_CUSTOM_HENGAI_HEALTH__
 
-#define __HENGAI_HEALTH_DEBUG__
+//#define __HENGAI_HEALTH_DEBUG__
 #ifdef __HENGAI_HEALTH_DEBUG__
 #define HENGAI_HEALTH_DEBUG_PRINTF(fmt, ...)   printf(fmt, ##__VA_ARGS__)
 #else