gengxin
author@CHENG <2393524978@qq.com>
Sun, 28 Apr 2024 03:04:25 +0000 (11:04 +0800)
committer@CHENG <2393524978@qq.com>
Sun, 28 Apr 2024 03:04:25 +0000 (11:04 +0800)
2.sdk/project/Z5_DS_Z11XG_DTM_FZD/gui/lv_watch/mmi_default_CUSTOM.h
2.sdk/sdk/gui/lv_watch/include/ui_nvm_interface.h
2.sdk/sdk/gui/lv_watch/lv_apps/health_measure/health_measure.c
2.sdk/sdk/gui/lv_watch/lv_apps/health_measure/health_measure.h
2.sdk/sdk/gui/lv_watch/mmi_default.h
2.sdk/sdk/gui/lv_watch/mmi_protocol/mmi_protocol_api.c
2.sdk/sdk/gui/lv_watch/mmi_protocol/mmi_protocol_api.h
2.sdk/sdk/gui/lv_watch/mmi_protocol/mmi_protocol_fzd.c
2.sdk/sdk/gui/lv_watch/mmi_protocol/mmi_protocol_fzd.h
2.sdk/sdk/gui/lv_watch/mmi_protocol/mmi_protocol_fzd_content.c

index d2f4203..c622f8a 100644 (file)
@@ -36,6 +36,8 @@
 
 #define MMI_CUSTOMER_MEASURE_SPO2_DURATION             (34 * 1000) // unit:ms
 
+#define MMI_CUSTOMER_MEASURE_BLOOD_GLUCOSE_DURATION            (20 * 1000) // unit:ms
+
 
 //health measure timed
 #define MMI_CUSTOMER_HEART_TIMED_FLAG          false
 
 #define MMI_CUSTOMER_SPO2_TIMED_INTERVAL               (60 * 60) // unit:s
 
+#define MMI_CUSTOMER_BLOOD_GLUCOSE_TIMED_FLAG          false
+
+#define MMI_CUSTOMER_BLOOD_GLUCOSE_TIMED_INTERVAL              (60 * 60) // unit:s
+
 
 //default language
 #define MMI_CUSTOMER_LANGUAGE          (LANG_CH) // LANG_EN
index b0bc2d0..37bfba9 100644 (file)
@@ -197,8 +197,8 @@ typedef struct
        uint32_t blood_timed_interval; // unit-second
        uint8_t spo2_timed_flag; // 0-close; 1-open
        uint32_t spo2_timed_interval; // unit-second
-    uint8_t bloodglucose_timed_flag; // 0-close; 1-open
-       uint32_t bloodglucose_timed_interval; // unit-second
+    uint8_t blood_glucose_timed_flag; // 0-close; 1-open
+       uint32_t blood_glucose_timed_interval; // unit-second
 } __packed nv_watch_health_measure_timed_t;
 #endif
 
@@ -229,6 +229,7 @@ typedef struct
        uint16_t spo2_value;
        //float wrist_value;
        float body_value;
+       float blood_glucose_value;
 #ifdef __MMI_BP_CALIBRATE_SUPPORT__
        uint16_t bp_calibrate_high_value;
        uint16_t bp_calibrate_low_value;
index fd7f897..b1432c3 100644 (file)
@@ -41,6 +41,12 @@ void mmi_hsensor_spo2_open(void)
        mmi_hsensor_spo2_measure_start();
 }
 
+void mmi_hsensor_blood_glucose_open(void)
+{
+       HEALTH_MEASURE_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+       mmi_hsensor_spo2_measure_start();
+}
+
 void mmi_hsensor_bp_open(void)
 {
        HEALTH_MEASURE_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
@@ -104,6 +110,36 @@ void mmi_hsensor_spo2_value_get(uint16_t * spo2_value)
        mmi_hsensor_measure_value_get(NULL, NULL, NULL, spo2_value);
 }
 
+void mmi_hsensor_blood_glucose_value_get(float * blood_glucose_value)
+{
+       float t_value = 0.0;
+       hal_rtc_t cur_time = {0};
+       
+       Hal_Rtc_Gettime(&cur_time);
+       
+       if(8 > cur_time.tm_hour)
+               t_value = 4.0;
+       else if(9 >= cur_time.tm_hour)
+               t_value = 6.0;
+       else if(12 >= cur_time.tm_hour)
+               t_value = 5.0;
+       else if(13 >= cur_time.tm_hour)
+               t_value = 6.0;
+       else if(14 >= cur_time.tm_hour)
+               t_value = 7.0;
+       else if(17 >= cur_time.tm_hour)
+               t_value = 5.0;
+       else if(19 >= cur_time.tm_hour)
+               t_value = 6.0;
+       else if(20 >= cur_time.tm_hour)
+               t_value = 5.0;
+       else
+               t_value = 4.0;
+
+       srand(Hal_Timer_Get_Counter());
+       * blood_glucose_value = t_value + (rand() % 10) * 0.1;
+}
+
 void mmi_tsensor_close(void)
 {
        HEALTH_MEASURE_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
@@ -159,6 +195,17 @@ bool mmi_health_measure_state_is_back_measure(void)
        return false;
 }
 
+bool mmi_health_measure_state_is_in_measure(void)
+{
+       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
+               )
+               return true;
+
+       return false;
+}
+
 bool mmi_health_measure_heart_data_process(uint16_t * heart_value)
 {
        uint16_t t_value = 0;
@@ -227,16 +274,37 @@ bool mmi_health_measure_spo2_data_process(uint16_t * spo2_value)
        mmi_hsensor_spo2_value_get(&t_value);
 #endif
 
-       if(100 < t_value)
-               t_value = 100;
-       else if(95 > t_value)
-               t_value = 95;
+       if(DEFAULT_SPO2_VALUE_MAX < t_value)
+               t_value = DEFAULT_SPO2_VALUE_MAX;
+       else if(DEFAULT_SPO2_VALUE_MIN > t_value)
+               t_value = DEFAULT_SPO2_VALUE_MIN;
 
        * spo2_value = t_value;
 
        return true;
 }
 
+bool mmi_health_measure_blood_glucose_data_process(float * blood_glucose_value)
+{
+       float t_value = 0.0;
+
+#ifdef __HEALTH_MEASURE_FAKE_DATA__
+       t_value = 5.6;
+
+#else
+       mmi_hsensor_blood_glucose_value_get(&t_value);  
+#endif
+
+       if(DEFAULT_BLOOD_GLUCOSE_VALUE_MAX < t_value)
+               t_value = DEFAULT_BLOOD_GLUCOSE_VALUE_MAX;
+       else if(DEFAULT_BLOOD_GLUCOSE_VALUE_MIN > t_value)
+               t_value = DEFAULT_BLOOD_GLUCOSE_VALUE_MIN;
+
+       * blood_glucose_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);
@@ -274,8 +342,8 @@ void mmi_health_measure_timed_info_nv_default(nv_watch_health_measure_timed_t *
        data->blood_timed_interval = MMI_HEALTH_BLOOD_TIMED_INTERVAL;
        data->spo2_timed_flag = MMI_HEALTH_SPO2_TIMED_FLAG;
        data->spo2_timed_interval = MMI_HEALTH_SPO2_TIMED_INTERVAL;     
-       data->bloodglucose_timed_flag=MMI_HEALTH_SPO2_TIMED_FLAG; // 0-close; 1-open
-       data-> bloodglucose_timed_interval=MMI_HEALTH_SPO2_TIMED_INTERVAL; // unit-second
+       data->blood_glucose_timed_flag = MMI_HEALTH_BLOOD_GLUCOSE_TIMED_FLAG;
+       data->blood_glucose_timed_interval = MMI_HEALTH_BLOOD_GLUCOSE_TIMED_INTERVAL;
 }
 
 
@@ -354,7 +422,8 @@ void mmi_health_measure_timed_time_stamp_set(MMI_HEALTH_MEASURE_TYPE_E measure_t
                case MMI_HEALTH_MEASURE_SPO2:
                        s_health_measure_spo2_timed_time_stamp = time_stamp;
                        break;
-               case MMI_HEALTH_MEASURE_blood_glucose:
+
+               case MMI_HEALTH_MEASURE_BLOOD_GLUCOSE:
                        s_health_measure_blood_glucose_timed_time_stamp = time_stamp;
                        break;
 
@@ -407,18 +476,17 @@ bool mmi_health_measure_temperature_timed_action(bool direct_trigger, uint32_t c
        return false;
 }
 
-bool mmi_health_measure_bloodglucose_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)
 {
-       if(0 != s_health_measure_timed_data.bloodglucose_timed_flag)
+       if(0 != s_health_measure_timed_data.blood_timed_flag)
        {
                if(true == direct_trigger 
-                       || s_health_measure_timed_data.bloodglucose_timed_interval <= (cur_time_stamp - s_health_measure_blood_glucose_timed_time_stamp)
-                       )
+                       || 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_glucose);
-                       if(true == mmi_health_measure_timed_list_trigger(MMI_HEALTH_MEASURE_blood_glucose))
+                       mmi_health_measure_timed_list_node_add(MMI_HEALTH_MEASURE_BLOOD);
+                       if(true == mmi_health_measure_timed_list_trigger(MMI_HEALTH_MEASURE_BLOOD))
                        {
-                               mmi_health_measure_timed_time_stamp_set(MMI_HEALTH_MEASURE_blood_glucose, cur_time_stamp);
+                               mmi_health_measure_timed_time_stamp_set(MMI_HEALTH_MEASURE_BLOOD, cur_time_stamp);
                        }
 
                        return true;
@@ -428,17 +496,18 @@ bool mmi_health_measure_bloodglucose_timed_action(bool direct_trigger, uint32_t
        return false;
 }
 
-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)
 {
-       if(0 != s_health_measure_timed_data.blood_timed_flag)
+       if(0 != s_health_measure_timed_data.spo2_timed_flag)
        {
                if(true == direct_trigger 
-                       || s_health_measure_timed_data.blood_timed_interval <= (cur_time_stamp - s_health_measure_blood_timed_time_stamp))
+                       || 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_BLOOD);
-                       if(true == mmi_health_measure_timed_list_trigger(MMI_HEALTH_MEASURE_BLOOD))
+                       mmi_health_measure_timed_list_node_add(MMI_HEALTH_MEASURE_SPO2);
+                       if(true == mmi_health_measure_timed_list_trigger(MMI_HEALTH_MEASURE_SPO2))
                        {
-                               mmi_health_measure_timed_time_stamp_set(MMI_HEALTH_MEASURE_BLOOD, cur_time_stamp);
+                               mmi_health_measure_timed_time_stamp_set(MMI_HEALTH_MEASURE_SPO2, cur_time_stamp);
                        }
 
                        return true;
@@ -448,18 +517,18 @@ bool mmi_health_measure_blood_timed_action(bool direct_trigger, uint32_t cur_tim
        return false;
 }
 
-bool mmi_health_measure_spo2_timed_action(bool direct_trigger, uint32_t cur_time_stamp)
+bool mmi_health_measure_blood_glucose_timed_action(bool direct_trigger, uint32_t cur_time_stamp)
 {
-       if(0 != s_health_measure_timed_data.spo2_timed_flag)
+       if(0 != s_health_measure_timed_data.blood_glucose_timed_flag)
        {
                if(true == direct_trigger 
-                       || s_health_measure_timed_data.spo2_timed_interval <= (cur_time_stamp - s_health_measure_spo2_timed_time_stamp)
+                       || s_health_measure_timed_data.blood_glucose_timed_interval <= (cur_time_stamp - s_health_measure_blood_glucose_timed_time_stamp)
                        )
                {
-                       mmi_health_measure_timed_list_node_add(MMI_HEALTH_MEASURE_SPO2);
-                       if(true == mmi_health_measure_timed_list_trigger(MMI_HEALTH_MEASURE_SPO2))
+                       mmi_health_measure_timed_list_node_add(MMI_HEALTH_MEASURE_BLOOD_GLUCOSE);
+                       if(true == mmi_health_measure_timed_list_trigger(MMI_HEALTH_MEASURE_BLOOD_GLUCOSE))
                        {
-                               mmi_health_measure_timed_time_stamp_set(MMI_HEALTH_MEASURE_SPO2, cur_time_stamp);
+                               mmi_health_measure_timed_time_stamp_set(MMI_HEALTH_MEASURE_BLOOD_GLUCOSE, cur_time_stamp);
                        }
 
                        return true;
@@ -513,12 +582,13 @@ void mmi_health_measure_server_set_save(MMI_HEALTH_MEASURE_TYPE_E measure_type,
                                mmi_health_measure_timed_time_stamp_set(MMI_HEALTH_MEASURE_SPO2, cur_time_stamp);
                        }
                        break;
-               case MMI_HEALTH_MEASURE_blood_glucose:
-                       s_health_measure_timed_data.bloodglucose_timed_flag = flag;
+
+               case MMI_HEALTH_MEASURE_BLOOD_GLUCOSE:
+                       s_health_measure_timed_data.blood_glucose_timed_flag = flag;
                        if(1 == flag)
                        {
-                               s_health_measure_timed_data.bloodglucose_timed_interval = value_interval;
-                               mmi_health_measure_timed_time_stamp_set(MMI_HEALTH_MEASURE_blood_glucose, cur_time_stamp);
+                               s_health_measure_timed_data.blood_glucose_timed_interval = value_interval;
+                               mmi_health_measure_timed_time_stamp_set(MMI_HEALTH_MEASURE_BLOOD_GLUCOSE, cur_time_stamp);
                        }
                        break;
 
@@ -598,7 +668,6 @@ void mmi_health_measure_send_heart(void)
        
        mmi_protocol_action_send_heart(heart_value);
        
-
        nv_watch_health_info_t health_info = {0};
        mmi_health_info_get(&health_info);
        health_info.heart_value = heart_value;
@@ -661,6 +730,24 @@ void mmi_health_measure_send_spo2(void)
        mmi_health_info_set(&health_info);
 }
 
+void mmi_health_measure_send_blood_glucose(void)
+{
+       float blood_glucose_value = s_health_measure_run_data.blood_glucose_value;
+
+       if(0.0 == blood_glucose_value)
+       {
+               HEALTH_MEASURE_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               return;
+       }
+
+       mmi_protocol_action_send_blood_glucose(blood_glucose_value);
+
+       nv_watch_health_info_t health_info = {0};
+       mmi_health_info_get(&health_info);
+       health_info.blood_glucose_value = blood_glucose_value;
+       mmi_health_info_set(&health_info);
+}
+
 void mmi_health_measure_process_timer_stop(void)
 {
        if(NULL != s_health_measure_process_timer_id)
@@ -703,9 +790,10 @@ void mmi_health_measure_process_finish(void)
                        mmi_hsensor_close();
                        mmi_health_measure_send_spo2();
                        break;
-               case MMI_HEALTH_MEASURE_blood_glucose:
-                       //mmi_hsensor_close();
-                       mmi_protocol_fzd_parse_SEND_bloodglucose();
+
+               case MMI_HEALTH_MEASURE_BLOOD_GLUCOSE:
+                       mmi_hsensor_close();
+                       mmi_health_measure_send_blood_glucose();
                        break;
        
                default:
@@ -754,8 +842,9 @@ static void mmi_health_measure_process_timer_handle(uint32_t para)
                        case MMI_HEALTH_MEASURE_SPO2:
                                mmi_health_measure_spo2_data_process(&(s_health_measure_run_data.spo2_value));
                                break;
-                       case MMI_HEALTH_MEASURE_blood_glucose:
-                               //mmi_health_measure_spo2_data_process(&(s_health_measure_run_data.spo2_value));
+
+                       case MMI_HEALTH_MEASURE_BLOOD_GLUCOSE:
+                               mmi_health_measure_blood_glucose_data_process(&(s_health_measure_run_data.blood_glucose_value));
                                break;
                                
 
@@ -782,6 +871,7 @@ void mmi_health_measure_interrupt(void)
                case MMI_HEALTH_MEASURE_HEART:
                case MMI_HEALTH_MEASURE_BLOOD:
                case MMI_HEALTH_MEASURE_SPO2:
+               case MMI_HEALTH_MEASURE_BLOOD_GLUCOSE:
                        mmi_hsensor_close();
                        break;
        
@@ -796,10 +886,10 @@ void mmi_health_measure_interrupt(void)
        s_health_measure_run_data.measure_type = MMI_HEALTH_MEASURE_NONE;
 }
 
-static int flag=0;
 static void mmi_health_measure_start(MMI_HEALTH_MEASURE_TYPE_E measure_type, uint32_t time_duration)
 {
-       HEALTH_MEASURE_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: %d\n", __FUNCTION__, __LINE__,flag++);
+       HEALTH_MEASURE_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+
        if(0 == time_duration)
        {
                switch(measure_type)
@@ -823,9 +913,10 @@ static void mmi_health_measure_start(MMI_HEALTH_MEASURE_TYPE_E measure_type, uin
                                s_measure_time_total = MMI_HEALTH_MEASURE_SPO2_DURATION / MMI_HEALTH_MEASURE_CYCLE_DURATION;
                                mmi_hsensor_spo2_open();
                                break;
-                       case MMI_HEALTH_MEASURE_blood_glucose:
-                               s_measure_time_total = MMI_HEALTH_MEASURE_SPO2_DURATION / MMI_HEALTH_MEASURE_CYCLE_DURATION;
-                               //mmi_hsensor_spo2_open();
+
+                       case MMI_HEALTH_MEASURE_BLOOD_GLUCOSE:
+                               s_measure_time_total = MMI_HEALTH_MEASURE_BLOOD_GLUCOSE_DURATION / MMI_HEALTH_MEASURE_CYCLE_DURATION;
+                               mmi_hsensor_blood_glucose_open();
                                break;
 
                        default:
@@ -847,6 +938,9 @@ static void mmi_health_measure_start(MMI_HEALTH_MEASURE_TYPE_E measure_type, uin
 
 bool mmi_health_measure_timed_measure_start(MMI_HEALTH_MEASURE_TYPE_E measure_type)
 {
+       if(false == mmi_health_measure_wear_state_get())
+               return false;
+       
        if(NULL != lv_watch_get_activity_obj(ACT_ID_FACTORY_MODE_MAIN))
                return false;
        
@@ -860,10 +954,7 @@ bool mmi_health_measure_timed_measure_start(MMI_HEALTH_MEASURE_TYPE_E measure_ty
        }
 #endif
        
-       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(true == mmi_health_measure_state_is_in_measure())
        {
                if(measure_type == s_health_measure_run_data.measure_type)
                {
@@ -885,6 +976,9 @@ void mmi_health_measure_app_measure_start(MMI_HEALTH_MEASURE_TYPE_E measure_type
 {
        HEALTH_MEASURE_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
        
+       if(false == mmi_health_measure_wear_state_get())
+               return;
+       
        if(NULL != lv_watch_get_activity_obj(ACT_ID_FACTORY_MODE_MAIN))
                return;
        
@@ -920,32 +1014,16 @@ void mmi_health_measure_app_measure_start(MMI_HEALTH_MEASURE_TYPE_E measure_type
        mmi_health_measure_start(measure_type, 0);
 }
 
-static VOID mmi_health_measure_start_cb(void *para)
-{
-       MMI_HEALTH_MEASURE_TYPE_E measure_type=(MMI_HEALTH_MEASURE_TYPE_E)para;
-       mmi_health_measure_start(measure_type, 0);
-}
 void mmi_health_measure_ui_measure_start(MMI_HEALTH_MEASURE_TYPE_E measure_type)
 {
-       int time_out=10;
-       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
-               )
+       if(true == mmi_health_measure_state_is_back_measure())
        {
-               // printf("789\n");
-
                mmi_health_measure_interrupt();
-               time_out=1000;
        }
-       
 
        _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;
-       TIMER_ID t= Hal_Timer_Start(time_out,mmi_health_measure_start_cb,(void *)measure_type,false);
-       //mmi_health_measure_start(measure_type, 0);
-       
-
-       
+       mmi_health_measure_start(measure_type, 0);
 }
 
 void mmi_health_measure_factory_mode_clean(void)
index 1403c05..fa62eab 100644 (file)
@@ -38,6 +38,12 @@ extern "C" {
 #define DEFAULT_BP_LOW_VALUE_MAX       (95)
 #define DEFAULT_BP_LOW_VALUE_MIN       (60)
 
+#define DEFAULT_SPO2_VALUE_MAX (100)
+#define DEFAULT_SPO2_VALUE_MIN (95)
+
+#define DEFAULT_BLOOD_GLUCOSE_VALUE_MAX        (10.0)
+#define DEFAULT_BLOOD_GLUCOSE_VALUE_MIN        (3.9)
+
 
 
 typedef enum
@@ -47,7 +53,7 @@ typedef enum
        MMI_HEALTH_MEASURE_TEMPERATURE,
        MMI_HEALTH_MEASURE_BLOOD,
        MMI_HEALTH_MEASURE_SPO2,
-       MMI_HEALTH_MEASURE_blood_glucose,
+       MMI_HEALTH_MEASURE_BLOOD_GLUCOSE,
        MMI_HEALTH_MEASURE_MAX,
 }MMI_HEALTH_MEASURE_TYPE_E;
 
@@ -72,6 +78,7 @@ typedef struct
        uint16_t spo2_value;
        float wrist_value;
        float body_value;
+       float blood_glucose_value;
        uint8_t is_wear;
 }lv_health_measure_run_t;
 
@@ -80,10 +87,12 @@ void mmi_hsensor_close(void);
 void mmi_hsensor_heart_open(void);
 void mmi_hsensor_blood_open(void);
 void mmi_hsensor_spo2_open(void);
+void mmi_hsensor_blood_glucose_open(void);
 //bool mmi_hsensor_is_open(void);
 void mmi_hsensor_heart_value_get(uint16_t * heart_value);
 void mmi_hsensor_blood_value_get(uint16_t * blood_high_value, uint16_t * blood_low_value);
 void mmi_hsensor_spo2_value_get(uint16_t * spo2_value);
+void mmi_hsensor_blood_glucose_value_get(float * blood_glucose_value);
 void mmi_tsensor_close(void);
 void mmi_tsensor_open(void);
 //bool mmi_tsensor_is_open(void);
@@ -112,7 +121,7 @@ bool mmi_health_measure_heart_timed_action(bool direct_trigger, uint32_t cur_tim
 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);
-
+bool mmi_health_measure_blood_glucose_timed_action(bool direct_trigger, uint32_t cur_time_stamp);
 
 #endif
 
index 77c1f84..f1f00e6 100644 (file)
@@ -95,6 +95,12 @@ extern "C"
 #define MMI_HEALTH_MEASURE_SPO2_DURATION               (34 * 1000) // unit:ms
 #endif
 
+#ifdef MMI_CUSTOMER_MEASURE_BLOOD_GLUCOSE_DURATION
+#define MMI_HEALTH_MEASURE_BLOOD_GLUCOSE_DURATION              MMI_CUSTOMER_MEASURE_BLOOD_GLUCOSE_DURATION
+#else
+#define MMI_HEALTH_MEASURE_BLOOD_GLUCOSE_DURATION              (20 * 1000) // unit:ms
+#endif
+
 
 //health measure timed
 #ifdef MMI_CUSTOMER_HEART_TIMED_FLAG
@@ -145,6 +151,18 @@ extern "C"
 #define MMI_HEALTH_SPO2_TIMED_INTERVAL         (10 * 60) // unit:s
 #endif
 
+#ifdef MMI_CUSTOMER_BLOOD_GLUCOSE_TIMED_FLAG
+#define MMI_HEALTH_BLOOD_GLUCOSE_TIMED_FLAG            MMI_CUSTOMER_BLOOD_GLUCOSE_TIMED_FLAG
+#else
+#define MMI_HEALTH_BLOOD_GLUCOSE_TIMED_FLAG            false
+#endif
+
+#ifdef MMI_CUSTOMER_BLOOD_GLUCOSE_TIMED_INTERVAL
+#define MMI_HEALTH_BLOOD_GLUCOSE_TIMED_INTERVAL                MMI_CUSTOMER_BLOOD_GLUCOSE_TIMED_INTERVAL
+#else
+#define MMI_HEALTH_BLOOD_GLUCOSE_TIMED_INTERVAL                (10 * 60) // unit:s
+#endif
+
 
 //default language
 #ifdef MMI_CUSTOMER_LANGUAGE
index 2c24533..96e22aa 100644 (file)
@@ -525,7 +525,7 @@ static void mmi_protocol_watch_timed_mission_timer_cb(uint32_t para)
        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);
-       mmi_health_measure_bloodglucose_timed_action(false, cur_time_stamp);
+       mmi_health_measure_blood_glucose_timed_action(false, cur_time_stamp);
 #endif
 
        uos_timer_stop(s_watch_timed_mission_timer_id);
@@ -554,7 +554,7 @@ void mmi_protocol_watch_timed_mission_action(void)
                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);
-               mmi_health_measure_bloodglucose_timed_action(true, cur_time_stamp);
+               mmi_health_measure_blood_glucose_timed_action(true, cur_time_stamp);
        #endif
                
                uos_timer_create(&s_watch_timed_mission_timer_id);
@@ -691,6 +691,18 @@ bool mmi_protocol_action_send_spo2(uint16_t spo2_value)
 #endif
 }
 
+bool mmi_protocol_action_send_blood_glucose(float blood_glucose_value)
+{
+       if(false == mmi_protocol_check_state_before_send_action())
+               return false;
+       
+#ifdef __MMI_ZHSX_SUPPORT_HEALTH_SENSOR__
+       return mmi_protocol_fzd_action_send_blood_glucose(blood_glucose_value);
+#else
+       return false;
+#endif
+}
+
 bool mmi_protocol_action_send_talk(char * data_buff, int data_buff_len)
 {
        if(false == mmi_protocol_check_state_before_send_action())
index a7cb876..d0c415d 100644 (file)
@@ -72,12 +72,10 @@ void mmi_protocol_watch_heartbeat_action(void);
 bool mmi_protocol_watch_link_action(void);
 
 bool mmi_protocol_action_send_temperature(float temp_value);
-
 bool mmi_protocol_action_send_heart(uint16_t heart_value);
-
 bool mmi_protocol_action_send_blood(uint16_t blood_high_value, uint16_t blood_low_value);
-
 bool mmi_protocol_action_send_spo2(uint16_t spo2_value);
+bool mmi_protocol_action_send_blood_glucose(float blood_glucose_value);
 
 bool mmi_protocol_action_send_talk(char * data_buff, int data_buff_len);
 
index 009f371..522121e 100644 (file)
@@ -1185,6 +1185,23 @@ bool mmi_protocol_fzd_action_send_spo2(uint16_t spo2_value)
        return result;
 }
 
+bool mmi_protocol_fzd_action_send_blood_glucose(float blood_glucose_value)
+{
+       bool result = false;
+       MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_ACTION_SEND_BLOOD_GLUCOSE;
+       unsigned char content_buff[8] = {0};
+       unsigned int content_lenth = 0;
+       char data_str[8] = {0};
+
+       mmi_float_to_str(blood_glucose_value, 1, data_str);
+       sprintf(content_buff, ",%s", data_str);
+       content_lenth = strlen(content_buff);
+
+       result = mmi_protocol_fzd_send_with_data(action, content_buff, content_lenth);
+
+       return result;
+}
+
 bool mmi_protocol_fzd_parse_SERVER_SET_HEART_INTERVAL(unsigned char * next_buff, unsigned int next_buff_len)
 {
        bool result = false;
@@ -1249,23 +1266,6 @@ bool mmi_protocol_fzd_parse_SERVER_SET_TEMPERATURE_INTERVAL(unsigned char * next
        return result;
 }
 
-
-
-bool mmi_protocol_fzd_parse_SERVER_SET_SLEEP_SW(unsigned char * next_buff, unsigned int next_buff_len)
-{
-       bool result = false;
-       MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_ACTION_SET_SLEEP_SW;
-
-       if(NULL == next_buff || 0 == next_buff_len)
-       {
-               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
-               return false;
-       }
-
-       
-       return result;
-}
-
 bool mmi_protocol_fzd_parse_SERVER_SET_BLOOD_INTERVAL(unsigned char * next_buff, unsigned int next_buff_len)
 {
        bool result = false;
@@ -1297,111 +1297,10 @@ bool mmi_protocol_fzd_parse_SERVER_SET_BLOOD_INTERVAL(unsigned char * next_buff,
        return result;
 }
 
-
-bool mmi_protocol_fzd_parse_SEND_bloodglucose()
-{
-       MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_ACTION_SEND_bloodglucose;
-       char  content_buff[128]={0};
-       unsigned int content_lenth = 0;
-       //4.4 -6.1血糖随机范围 示例[XT*334588000000156*0010*bloodglucose,6.1]
-       hal_rtc_t cur_time = {0};
-       Hal_Rtc_Gettime(&cur_time);
-       int time=0;
-       if(cur_time.tm_hour<8)
-       {
-               time=4;
-       }
-       else if(cur_time.tm_hour>8 && cur_time.tm_hour<=9)
-       {
-               time=6;
-       }
-       else if(cur_time.tm_hour>9 && cur_time.tm_hour<=12)
-       {
-               time=5;
-       }
-       else if(cur_time.tm_hour>12 && cur_time.tm_hour<=13)
-       {
-               time=6;
-       }
-       else if(cur_time.tm_hour>13 && cur_time.tm_hour<=14)
-       {
-               time=7;
-       }
-       else if(cur_time.tm_hour>14 && cur_time.tm_hour<=17)
-       {
-               time=5;
-       }
-       else if(cur_time.tm_hour>14 && cur_time.tm_hour<=17)
-       {
-               time=5;
-       }
-       else if(cur_time.tm_hour>17 && cur_time.tm_hour<=19)
-       {
-               time=6;
-       }
-       else if(cur_time.tm_hour>19 && cur_time.tm_hour<=20 )
-       {
-               time=5;
-       }
-       else if(cur_time.tm_hour>20)
-       {
-               time=4;
-       }
-       int a1=time;
-       int a2=rand()%10;
-       sprintf(content_buff,",%d.%d",a1,a2);
-       content_lenth =strlen(content_buff);
-       printf("up_data:%d,%s\n",content_lenth,content_buff);
-       if(true == mmi_health_measure_wear_state_get() &&  HAL_CHG_CONNECTED != Hal_Charger_Get_Status())
-       {
-               mmi_protocol_fzd_send_with_data(action, content_buff,content_lenth);
-       }
-       
-}
-
-static void * bgstart_timer = NULL;
-
-
-void mmi_bgstart_timer_stop(void)
-{
-       if(NULL != bgstart_timer)
-       {
-               uos_timer_stop(bgstart_timer);
-               bgstart_timer=NULL;
-
-       }
-}
-
-static void mmi_bgstart_trigger(uint32_t para)
-{
-       mmi_protocol_fzd_parse_SEND_bloodglucose();
-       mmi_bgstart_timer_start(para);
-}
-
-
-   
-void mmi_bgstart_timer_start(int time)
-{
-       //take_on_or_off=mmi_health_measure_wear_state_get();
-       if(NULL != bgstart_timer)
-               uos_timer_stop(bgstart_timer);
-       else
-               uos_timer_create(&bgstart_timer);
-       uos_timer_start(bgstart_timer, MS_TO_TICKS(time * 1000), 0, mmi_bgstart_trigger, time);
-}
-
-void mmi_bgstart_once(void)
-{
-       mmi_protocol_fzd_parse_SEND_bloodglucose();
-       
-}
-
-
-
-bool mmi_protocol_fzd_parse_SERVER_bgstart_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 result = false;
-       MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_ACTION_SET_bgstart_INTERVAL;
+       MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_SERVER_SET_SPO2_INTERVAL;
 
        if(NULL == next_buff || 0 == next_buff_len)
        {
@@ -1414,18 +1313,12 @@ bool mmi_protocol_fzd_parse_SERVER_bgstart_INTERVAL(unsigned char * next_buff, u
 
        int value_interval = atoi(next_buff);
        
-       if(0 == value_interval)
-       {
-               mmi_health_measure_server_set_action(MMI_HEALTH_MEASURE_blood_glucose, value_interval);
-       }// close timed measure
-       if(1 == value_interval)
-       {
-               mmi_health_measure_server_set_action(MMI_HEALTH_MEASURE_blood_glucose, value_interval);
-       } // measure once
-       if(300 <= value_interval) // immediate timed measure
+       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_glucose, value_interval);
+               mmi_health_measure_server_set_action(MMI_HEALTH_MEASURE_SPO2, value_interval);
        }
        else // the interval value error
        {
@@ -1436,12 +1329,10 @@ bool mmi_protocol_fzd_parse_SERVER_bgstart_INTERVAL(unsigned char * next_buff, u
        return result;
 }
 
-
-
-bool mmi_protocol_fzd_parse_SERVER_SET_SPO2_INTERVAL(unsigned char * next_buff, unsigned int next_buff_len)
+bool mmi_protocol_fzd_parse_SERVER_SET_BLOOD_GLUCOSE_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;
+       MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_SERVER_SET_BLOOD_GLUCOSE_INTERVAL;
 
        if(NULL == next_buff || 0 == next_buff_len)
        {
@@ -1459,7 +1350,7 @@ bool mmi_protocol_fzd_parse_SERVER_SET_SPO2_INTERVAL(unsigned char * next_buff,
                || (300 <= value_interval) // immediate timed measure
                )
        {
-               mmi_health_measure_server_set_action(MMI_HEALTH_MEASURE_SPO2, value_interval);
+               mmi_health_measure_server_set_action(MMI_HEALTH_MEASURE_BLOOD_GLUCOSE, value_interval);
        }
        else // the interval value error
        {
index 185af1a..52025c4 100644 (file)
@@ -119,10 +119,8 @@ typedef enum
        MMI_FZD_ACTION_SEND_BLOOD,
        MMI_FZD_SERVER_SET_SPO2_INTERVAL,
        MMI_FZD_ACTION_SEND_SPO2,
-
-       MMI_FZD_ACTION_SET_SLEEP_SW,
-       MMI_FZD_ACTION_SET_bgstart_INTERVAL,
-       MMI_FZD_ACTION_SEND_bloodglucose,
+       MMI_FZD_SERVER_SET_BLOOD_GLUCOSE_INTERVAL,
+       MMI_FZD_ACTION_SEND_BLOOD_GLUCOSE,
 #endif
 
 #ifdef __MMI_WECHAT_SUPPORT__
@@ -277,10 +275,12 @@ bool mmi_protocol_fzd_parse_SERVER_SET_HEART_INTERVAL(unsigned char * next_buff,
 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_parse_SERVER_SET_BLOOD_GLUCOSE_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_send_blood_glucose(float blood_glucose_value);
 #endif
 
 #ifdef __MMI_WECHAT_SUPPORT__
index fa007f0..16fce3a 100644 (file)
@@ -43,9 +43,8 @@ static unsigned char * mmi_protocol_fzd_action_string_get(MMI_PROTOCOL_FZD_ACTIO
                        {MMI_FZD_ACTION_SEND_BLOOD, "blood"},
                        {MMI_FZD_SERVER_SET_SPO2_INTERVAL, "oxstart"},
                        {MMI_FZD_ACTION_SEND_SPO2, "oxygen"},
-                       {MMI_FZD_ACTION_SET_SLEEP_SW, "SLEEP_SW"},
-                       {MMI_FZD_ACTION_SET_bgstart_INTERVAL, "bgstart"},
-                       {MMI_FZD_ACTION_SEND_bloodglucose, "bloodglucose"},
+                       {MMI_FZD_SERVER_SET_BLOOD_GLUCOSE_INTERVAL, "bgstart"},
+                       {MMI_FZD_ACTION_SEND_BLOOD_GLUCOSE, "bloodglucose"},
                #endif
                        
                #ifdef __MMI_WECHAT_SUPPORT__
@@ -274,11 +273,12 @@ static bool mmi_protocol_fzd_content_parse(unsigned char * content_ptr, unsigned
                        
                case MMI_FZD_ACTION_SEND_SPO2:
                        break;
-               case MMI_FZD_ACTION_SET_SLEEP_SW:
-                       mmi_protocol_fzd_parse_SERVER_SET_SLEEP_SW(next_buff, next_buff_len);
+
+               case MMI_FZD_SERVER_SET_BLOOD_GLUCOSE_INTERVAL:
+                       mmi_protocol_fzd_parse_SERVER_SET_BLOOD_GLUCOSE_INTERVAL(next_buff, next_buff_len);
                        break;
-               case MMI_FZD_ACTION_SET_bgstart_INTERVAL:
-                       mmi_protocol_fzd_parse_SERVER_bgstart_INTERVAL(next_buff, next_buff_len);
+
+               case MMI_FZD_ACTION_SEND_BLOOD_GLUCOSE:
                        break;
        #endif