From: @CHENG <2393524978@qq.com> Date: Tue, 16 Jan 2024 02:40:26 +0000 (+0800) Subject: gengxin X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=597074326ae3b65265d93c9e813a677beb0ab86c;p=mirrors%2FASR3603_Z5.git gengxin --- diff --git a/2.sdk/sdk/gui/lv_watch/include/ui_nvm_interface.h b/2.sdk/sdk/gui/lv_watch/include/ui_nvm_interface.h index e2a58408..25709b42 100644 --- a/2.sdk/sdk/gui/lv_watch/include/ui_nvm_interface.h +++ b/2.sdk/sdk/gui/lv_watch/include/ui_nvm_interface.h @@ -454,15 +454,15 @@ typedef struct #endif #ifdef __MMI_CUSTOM_HENGAI_HEALTH__ -#define NV_HENGAI_HEALTH_REQ_CODE_LEN (128) -#define NV_HENGAI_HEALTH_ACT_CODE_LEN (128) +//#define NV_HENGAI_HEALTH_REQ_CODE_LEN (128) +//#define NV_HENGAI_HEALTH_ACT_CODE_LEN (128) #define NV_HENGAI_HEALTH_TOKEN_LEN (64) typedef struct { - uint8_t is_activated; // 0-not activated; 1-activated - char req_code[NV_HENGAI_HEALTH_REQ_CODE_LEN + 1]; - char act_code[NV_HENGAI_HEALTH_ACT_CODE_LEN + 1]; + //uint8_t is_activated; // 0-not activated; 1-activated + //char req_code[NV_HENGAI_HEALTH_REQ_CODE_LEN + 1]; + //char act_code[NV_HENGAI_HEALTH_ACT_CODE_LEN + 1]; char token[NV_HENGAI_HEALTH_TOKEN_LEN + 1]; uint8_t is_calibrated; // 0-not calibrated; 1-calibrated hal_rtc_t calibrate_time; diff --git a/2.sdk/sdk/gui/lv_watch/lv_apps/custom_function/heng_ai_blood_pressure.c b/2.sdk/sdk/gui/lv_watch/lv_apps/custom_function/heng_ai_blood_pressure.c index 3e0c421d..667bb03a 100644 --- a/2.sdk/sdk/gui/lv_watch/lv_apps/custom_function/heng_ai_blood_pressure.c +++ b/2.sdk/sdk/gui/lv_watch/lv_apps/custom_function/heng_ai_blood_pressure.c @@ -1600,6 +1600,7 @@ lv_obj_t * mmi_heng_ai_bp_calibration_mode_create(lv_obj_t * tileview, uint16_t // +#if 0 void mmi_heng_ai_bp_attempt_mode_btn_event_cb(lv_obj_t * obj, lv_event_t e) { if(LV_EVENT_CLICKED != e) @@ -1640,6 +1641,157 @@ lv_obj_t * mmi_heng_ai_bp_attempt_mode_create(lv_obj_t * tileview, uint16_t id) return tab; } +#else + +void mmi_hengai_bp_calibration_record_screen_prepare_destory(lv_obj_t * activity_obj) +{ + lv_watch_png_cache_all_free(); +} + +void mmi_hengai_bp_calibration_record_screen_clean(void) +{ + HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__); + + lv_obj_t * activity_obj = lv_watch_get_activity_obj(ACT_ID_HENG_AI_BP_RECORD); + if(NULL != activity_obj) + { + mmi_hengai_bp_calibration_record_screen_prepare_destory(NULL); + lv_obj_del(activity_obj); + } +} + +void mmi_hengai_bp_calibration_record_screen_btn_event_cb(lv_obj_t * obj, lv_event_t e) +{ + if(LV_EVENT_CLICKED != e) + return; + + mmi_hengai_bp_calibration_record_screen_clean(); +} + +lv_obj_t * mmi_hengai_bp_calibration_record_screen_create(lv_obj_t * activity_obj) +{ + if(NULL == activity_obj) + { + lv_watch_activity_ext_t activity_ext = {0}; + + activity_ext.actId = ACT_ID_HENG_AI_BP_RECORD; + activity_ext.create = mmi_hengai_bp_calibration_record_screen_create; + activity_ext.prepare_destory = mmi_hengai_bp_calibration_record_screen_prepare_destory; + activity_obj = lv_watch_creat_activity_obj(&activity_ext); + if(NULL == activity_obj) + return NULL; + } + + lv_obj_t * watch_obj = lv_watch_obj_create(activity_obj); + LV_ASSERT_MEM(watch_obj); + if(NULL == watch_obj) + return NULL; + lv_watch_obj_set_anim_mode(watch_obj, LV_WATCH_ANIM_HOR_RIGHT_HIDE); + + lv_obj_t * cont = lv_cont_create(watch_obj, NULL); + lv_obj_set_size(cont, LV_HOR_RES, LV_VER_RES); + //lv_obj_add_style(cont, LV_CONT_PART_MAIN, &lv_style_transp_tight); + lv_obj_set_style_local_bg_color(cont, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK); + lv_obj_set_click(cont, false); + + lv_obj_t * label_title = lv_label_create(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_BP_CALIBRATION_RECORD); + lv_obj_align(label_title, NULL, LV_ALIGN_IN_TOP_MID, 0, 48); + lv_obj_set_click(label_title, false); + + if(0 == mmi_hengai_bp_calibrated_flag_get()) + { + lv_obj_t * label_prompt = lv_label_create(cont, NULL); + lv_obj_add_style(label_prompt, LV_LABEL_PART_MAIN, &lv_watch_font32); + lv_label_set_align(label_prompt, LV_LABEL_ALIGN_CENTER); + lv_label_set_text_id(label_prompt, WATCH_TEXT_ID_BP_NO_RECORD); + lv_obj_align(label_prompt, NULL, LV_ALIGN_CENTER, 0, -20); + } + else + { + lv_obj_t * label_prompt = lv_label_create(cont, NULL); + lv_obj_add_style(label_prompt, LV_LABEL_PART_MAIN, &lv_watch_font32); + 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_label_set_text_id(label_prompt, WATCH_TEXT_ID_BP_LAST_CALIBRATION_RECORD); + lv_obj_align(label_prompt, NULL, LV_ALIGN_IN_TOP_MID, 0, 160); + + lv_obj_t * label_time = lv_label_create(cont, NULL); + lv_obj_add_style(label_time, LV_LABEL_PART_MAIN, &lv_watch_font36); + lv_label_set_align(label_time, LV_LABEL_ALIGN_CENTER); + + hal_rtc_t cur_time = {0}; + char time_str[24] = {0}; + mmi_hengai_bp_calibrated_time_get(&cur_time); + sprintf(time_str, "%02d/%02d/%04d %02d:%02d", + cur_time.tm_mon, + cur_time.tm_mday, + cur_time.tm_year, + cur_time.tm_hour, + cur_time.tm_min); + lv_label_set_text(label_time, time_str); + lv_obj_align(label_time, label_prompt, LV_ALIGN_OUT_BOTTOM_MID, 0, 30); + + /* + lv_obj_t * label_prompt = lv_label_create(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, 400); + lv_label_set_text_id(label_prompt, WATCH_TEXT_ID_BLOOD_PRESSURE_NORMAL_PROMPT); + lv_obj_align(label_prompt, NULL, LV_ALIGN_IN_TOP_MID, 0, 292); + */ + } + + mmi_bp_screen_common_bottom_button_create(cont, WATCH_TEXT_ID_OK, mmi_hengai_bp_calibration_record_screen_btn_event_cb); + + return watch_obj; +} + +void mmi_hengai_bp_calibration_record_btn_event_cb(lv_obj_t * obj, lv_event_t e) +{ + if(LV_EVENT_CLICKED != e) + return; + + mmi_hengai_bp_calibration_record_screen_create(NULL); +} + +lv_obj_t * mmi_heng_ai_bp_calibration_record_create(lv_obj_t * tileview, uint16_t id) +{ + lv_obj_t * tab = mmi_heng_ai_bp_tileview_add_tile(tileview, id); + if(NULL == tab) + return NULL; + + lv_obj_t * label_title = lv_label_create(tab, 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_BP_CALIBRATION_RECORD); + 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(tab, NULL); + lv_img_set_src(img, ICON_HENGAI_BP_CALIBRATION_RECORD); + lv_obj_align(img, NULL, LV_ALIGN_IN_TOP_MID, 0, 104); + + lv_obj_t * imgbtn = lv_imgbtn_create(tab, NULL); + lv_imgbtn_set_src(imgbtn, LV_BTN_STATE_RELEASED, ICON_HENGAI_BP_BTN_BG); + lv_imgbtn_set_src(imgbtn, LV_BTN_STATE_PRESSED, ICON_HENGAI_BP_BTN_BG); + lv_obj_align(imgbtn, NULL, LV_ALIGN_IN_TOP_MID, 0, 300); + lv_obj_set_event_cb(imgbtn, mmi_hengai_bp_calibration_record_btn_event_cb); + + lv_obj_t * btn_label = lv_label_create(imgbtn, NULL); + lv_obj_add_style(btn_label, LV_LABEL_PART_MAIN, &lv_watch_font32); + lv_label_set_align(btn_label, LV_LABEL_ALIGN_CENTER); + lv_label_set_text_id(btn_label, WATCH_TEXT_ID_BP_RECORD_CHECK); + lv_obj_align(btn_label, NULL, LV_ALIGN_CENTER, 0, 0); + + return tab; +} +#endif + void mmi_heng_ai_bp_tileview_led(lv_obj_t * tileview) { @@ -1772,7 +1924,8 @@ lv_obj_t * mmi_heng_ai_bp_screen_create(lv_obj_t * activity_obj) ext->tab_measure_mdoe = NULL; ext->tab_calibration_mode = NULL; - ext->tab_attempt_mode = NULL; + //ext->tab_attempt_mode = NULL; + ext->tab_calibration_record = NULL; ext->led_cont= NULL; ext->led[0] = NULL; ext->led[1] = NULL; @@ -1798,9 +1951,12 @@ lv_obj_t * mmi_heng_ai_bp_screen_create(lv_obj_t * activity_obj) if(NULL == ext->tab_calibration_mode) return NULL; - ext->tab_attempt_mode = mmi_heng_ai_bp_attempt_mode_create(tileview, 2); - LV_ASSERT_MEM(ext->tab_attempt_mode); - if(NULL == ext->tab_attempt_mode) + //ext->tab_attempt_mode = mmi_heng_ai_bp_attempt_mode_create(tileview, 2); + //LV_ASSERT_MEM(ext->tab_attempt_mode); + //if(NULL == ext->tab_attempt_mode) + // return NULL; + ext->tab_calibration_record = mmi_heng_ai_bp_calibration_record_create(tileview, 2); + if(NULL == ext->tab_calibration_record) return NULL; if(0 == mmi_hengai_bp_calibrated_flag_get()) diff --git a/2.sdk/sdk/gui/lv_watch/lv_apps/custom_function/heng_ai_blood_pressure.h b/2.sdk/sdk/gui/lv_watch/lv_apps/custom_function/heng_ai_blood_pressure.h index f2fc8338..73a5ad33 100644 --- a/2.sdk/sdk/gui/lv_watch/lv_apps/custom_function/heng_ai_blood_pressure.h +++ b/2.sdk/sdk/gui/lv_watch/lv_apps/custom_function/heng_ai_blood_pressure.h @@ -42,7 +42,8 @@ typedef struct lv_obj_t * tileview; lv_obj_t * tab_measure_mdoe; lv_obj_t * tab_calibration_mode; - lv_obj_t * tab_attempt_mode; + //lv_obj_t * tab_attempt_mode; + lv_obj_t * tab_calibration_record; lv_obj_t * led_cont; lv_obj_t * led[MMI_HENGAI_BP_TAB_COUNT]; } lv_heng_ai_bp_ext_t; diff --git a/2.sdk/sdk/gui/lv_watch/lv_apps/custom_function/heng_ai_http_protocol.c b/2.sdk/sdk/gui/lv_watch/lv_apps/custom_function/heng_ai_http_protocol.c index 5e76265a..18b705d0 100644 --- a/2.sdk/sdk/gui/lv_watch/lv_apps/custom_function/heng_ai_http_protocol.c +++ b/2.sdk/sdk/gui/lv_watch/lv_apps/custom_function/heng_ai_http_protocol.c @@ -146,6 +146,12 @@ EXIT: int mmi_hengai_http_post_data(char * url, char * post_data, char * token) { + HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: %d\n", __FUNCTION__, __LINE__, strlen(post_data)); + HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG]: %s\n", post_data); + HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG]: %s\n", post_data + 100); + HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG]: %s\n", post_data + 200); + HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG]: %s\n", post_data + 300); + int ret_value = 0; s_hengai_http_post_try_count = 0; @@ -327,6 +333,15 @@ void mmi_hengai_bp_calibrate_model_send(void) char * url_suffix = "/health/bp/model"; sprintf(url, "%s%s", HENGAI_HTTP_POST_URL_COMMON_PREFIX, url_suffix); int ret = mmi_hengai_http_post_data(url, post_data, token); + +/* + if(NULL != post_data) + { + lv_mem_free(post_data); + post_data = NULL; + } +*/ + if(0 == ret) { HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: %d\n", __FUNCTION__, __LINE__, strlen(s_hengai_http_revceive_buf)); @@ -489,7 +504,7 @@ void mmi_hengai_bp_calibrate_raw_data_send(uint8_t calibrate_times, uint16_t bp_ -void mmi_hengai_bp_activation_feedback(void) +void mmi_hengai_health_lib_activation_feedback(void) { char * post_data = NULL; cJSON * json_send = NULL; @@ -508,6 +523,15 @@ void mmi_hengai_bp_activation_feedback(void) char * url_suffix = "/sinklib/activation/feedback"; sprintf(url, "%s%s", HENGAI_HTTP_POST_URL_COMMON_PREFIX, url_suffix); int ret = mmi_hengai_http_post_data(url, post_data, NULL); + +/* + if(NULL != post_data) + { + lv_mem_free(post_data); + post_data = NULL; + } +*/ + if(0 == ret) { cJSON * json_recv = NULL; @@ -519,12 +543,11 @@ void mmi_hengai_bp_activation_feedback(void) if(cJSON_IsTrue(cJSON_GetObjectItem(json_recv, "status"))) { - // true - mmi_hengai_health_activated_flag_set(1); + HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: true\n", __FUNCTION__, __LINE__); } else { - // false + HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: false\n", __FUNCTION__, __LINE__); } } else @@ -547,55 +570,103 @@ void mmi_hengai_bp_activation_feedback(void) } } -void mmi_hengai_bp_activation_check_action(void) +void mmi_hengai_health_lib_activation_check_action(void) { HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__); - if(0 == mmi_hengai_health_activated_flag_get()) + if(0 == mmi_hengai_health_lib_activated_flag_get()) { + #if 0 char * post_data = NULL; cJSON * json_send = NULL; - char * req_code = mmi_hengai_health_req_code_get(); + char * req_code = mmi_hengai_health_lib_req_code_get(); char imei[16 + 1] = {0}; app_adp_get_imei_req(imei); json_send = cJSON_CreateObject(); cJSON_AddItemToObject(json_send, "app_key", cJSON_CreateString(HENGAI_HTTP_POST_APP_KEY)); - cJSON_AddItemToObject(json_send, "name", cJSON_CreateString("Z5_HA_K18")); + cJSON_AddItemToObject(json_send, "name", cJSON_CreateString("Z5")); cJSON_AddItemToObject(json_send, "firm", cJSON_CreateString("HENGAI")); cJSON_AddItemToObject(json_send, "mac", cJSON_CreateString(imei)); - cJSON_AddItemToObject(json_send, "model", cJSON_CreateString("RH303")); - cJSON_AddItemToObject(json_send, "sensor", cJSON_CreateString("VP60")); - cJSON_AddItemToObject(json_send, "sinklib_version", cJSON_CreateString("v0.3.0.072522")); + cJSON_AddItemToObject(json_send, "model", cJSON_CreateString("Z5_HA_K18")); + cJSON * json_sensor = cJSON_CreateObject(); + cJSON_AddItemToObject(json_send, "fs", cJSON_CreateNumber(MMI_HENGAI_BP_RAW_DATA_SAMPLE_RATE)); + cJSON_AddItemToObject(json_send, "model", cJSON_CreateString("VC9202")); + cJSON_AddItemToObject(json_send, "sensor", json_sensor); + cJSON_AddItemToObject(json_send, "sinklib_version", cJSON_CreateString("v0.1.0.020623")); cJSON_AddItemToObject(json_send, "request_code", cJSON_CreateString(req_code)); + post_data = cJSON_Print(json_send); + + cJSON_Delete(json_sensor); + json_sensor = NULL; cJSON_Delete(json_send); json_send = NULL; + #else + int temp_len = 0; + int post_data_len = 512; + char * post_data = lv_mem_alloc(post_data_len); + if(NULL == post_data) + return ; + _lv_memset_00(post_data, post_data_len); + + temp_len += sprintf(post_data + temp_len, "{\"app_key\":\"%s\",", HENGAI_HTTP_POST_APP_KEY); + + temp_len += sprintf(post_data + temp_len, "\"name\":\"%s\",", "Z5"); + + temp_len += sprintf(post_data + temp_len, "\"firm\":\"%s\",", "HENGAI"); + + char imei[16 + 1] = {0}; + app_adp_get_imei_req(imei); + temp_len += sprintf(post_data + temp_len, "\"mac\":\"%s\",", imei); + + temp_len += sprintf(post_data + temp_len, "\"model\":\"%s\",", "Z5_HA_K18"); + + temp_len += sprintf(post_data + temp_len, "\"sensor\":{\"fs\":%d,\"model\":\"%s\"},", MMI_HENGAI_BP_RAW_DATA_SAMPLE_RATE, "VC9202"); + + temp_len += sprintf(post_data + temp_len, "\"sinklib_version\":\"%s\",", "v0.1.0.020623"); + + char * req_code = mmi_hengai_health_lib_req_code_get(); + temp_len += sprintf(post_data + temp_len, "\"request_code\":\"%s\"}", req_code); + + HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: %d\n", __FUNCTION__, __LINE__, temp_len); + #endif + char url[256] = {0}; char * url_suffix = "/sinklib/activation"; sprintf(url, "%s%s", HENGAI_HTTP_POST_URL_COMMON_PREFIX, url_suffix); int ret = mmi_hengai_http_post_data(url, post_data, NULL); + + if(NULL != post_data) + { + lv_mem_free(post_data); + post_data = NULL; + } + if(0 == ret) { - cJSON * json_recv = NULL; + 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); - json_recv = cJSON_Parse(s_hengai_http_revceive_buf); + cJSON * json_recv = cJSON_Parse(s_hengai_http_revceive_buf); if(NULL != json_recv) { - HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: json file\n", __FUNCTION__, __LINE__); - - // true if(cJSON_IsTrue(cJSON_GetObjectItem(json_recv, "status"))) { + HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: true\n", __FUNCTION__, __LINE__); + 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); + mmi_hengai_health_lib_act_code_set(act_code); } - else // false + else { - + HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: false\n", __FUNCTION__, __LINE__); } } else @@ -623,7 +694,8 @@ void mmi_hengai_algorithm_interface_login_action(void) { HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__); - if(0 == mmi_hengai_health_activated_flag_get()) + char * token = mmi_hengai_health_token_get(); + if(0 == strlen(token)) { cJSON * json_send = json_send = cJSON_CreateObject(); cJSON_AddItemToObject(json_send, "app_key", cJSON_CreateString(HENGAI_HTTP_POST_APP_KEY)); @@ -643,6 +715,15 @@ void mmi_hengai_algorithm_interface_login_action(void) char * url_suffix = "/entrance/user/login"; sprintf(url, "%s%s", HENGAI_HTTP_POST_URL_COMMON_PREFIX, url_suffix); int ret = mmi_hengai_http_post_data(url, post_data, NULL); + + /* + if(NULL != post_data) + { + lv_mem_free(post_data); + post_data = NULL; + } + */ + if(0 == ret) { HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: %d\n", __FUNCTION__, __LINE__, strlen(s_hengai_http_revceive_buf)); @@ -715,24 +796,36 @@ void mmi_hengai_health_data_nv_read(void) } } -uint8_t mmi_hengai_health_activated_flag_get(void) +uint8_t mmi_hengai_health_lib_activated_flag_get(void) { - return (s_hengai_health_data.is_activated); + //return (s_hengai_health_data.is_activated); + uint8_t flag = get_is_HA_activate(); + HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: flag=%d\n", __FUNCTION__, __LINE__, flag); + + return flag; } void mmi_hengai_health_activated_flag_set(uint8_t flag) { +/* s_hengai_health_data.is_activated = flag; mmi_hengai_health_data_nv_write(); +*/ } -char * mmi_hengai_health_req_code_get(void) +char * mmi_hengai_health_lib_req_code_get(void) { - return (s_hengai_health_data.req_code); + //return (s_hengai_health_data.req_code); + char * req_code = get_HA_req_code(); + HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: req_code=\n", __FUNCTION__, __LINE__); + HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG]: %s\n", req_code); + + return req_code; } void mmi_hengai_health_req_code_set(char * req_code) { +/* if(NULL == req_code) return; @@ -743,32 +836,34 @@ void mmi_hengai_health_req_code_set(char * req_code) 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(); +*/ } char * mmi_hengai_health_act_code_get(void) { - return (s_hengai_health_data.act_code); + //return (s_hengai_health_data.act_code); } -void mmi_hengai_health_act_code_set(char * act_code) +void mmi_hengai_health_lib_act_code_set(char * act_code) { + HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: act_code=\n", __FUNCTION__, __LINE__); + HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG]: %s\n", 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(); - -/* - if() +*/ + int ret = HA_lib_activate(act_code); + HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: ret=%d\n", __FUNCTION__, __LINE__, ret); + if(ret) { - mmi_hengai_bp_activation_feedback(); + mmi_hengai_health_lib_activation_feedback(); } -*/ } char * mmi_hengai_health_token_get(void) @@ -800,14 +895,28 @@ void mmi_hengai_bp_calibrated_flag_set(uint8_t flag) HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: %d\n", __FUNCTION__, __LINE__, flag); s_hengai_health_data.is_calibrated = flag; + + if(1 == flag) + { + hal_rtc_t cur_time = {0}; + + Hal_Rtc_Gettime(&cur_time); + _lv_memcpy(&(s_hengai_health_data.calibrate_time), &cur_time, sizeof(hal_rtc_t)); + } + mmi_hengai_health_data_nv_write(); } +void mmi_hengai_bp_calibrated_time_get(hal_rtc_t * time_ptr) +{ + if(NULL == time_ptr) + return; - - - - + if(1 != s_hengai_health_data.is_calibrated) + return; + + _lv_memcpy(time_ptr, &(s_hengai_health_data.calibrate_time), sizeof(hal_rtc_t)); +} #endif diff --git a/2.sdk/sdk/gui/lv_watch/lv_apps/custom_function/heng_ai_http_protocol.h b/2.sdk/sdk/gui/lv_watch/lv_apps/custom_function/heng_ai_http_protocol.h index 78c930eb..ba0f0543 100644 --- a/2.sdk/sdk/gui/lv_watch/lv_apps/custom_function/heng_ai_http_protocol.h +++ b/2.sdk/sdk/gui/lv_watch/lv_apps/custom_function/heng_ai_http_protocol.h @@ -50,20 +50,18 @@ extern "C" { +void mmi_hengai_health_lib_activation_check_action(void); void mmi_hengai_algorithm_interface_login_action(void); void mmi_hengai_health_data_nv_read(void); -uint8_t mmi_hengai_health_activated_flag_get(void); -void mmi_hengai_health_activated_flag_set(uint8_t flag); +uint8_t mmi_hengai_health_lib_activated_flag_get(void); -char * mmi_hengai_health_req_code_get(void); -void mmi_hengai_health_req_code_set(char * req_code); +char * mmi_hengai_health_lib_req_code_get(void); -char * mmi_hengai_health_act_code_get(void); -void mmi_hengai_health_act_code_set(char * act_code); +void mmi_hengai_health_lib_act_code_set(char * act_code); char * mmi_hengai_health_token_get(void); void mmi_hengai_health_token_set(char * token); @@ -71,8 +69,7 @@ void mmi_hengai_health_token_set(char * token); uint8_t mmi_hengai_bp_calibrated_flag_get(void); void mmi_hengai_bp_calibrated_flag_set(uint8_t flag); - - +void mmi_hengai_bp_calibrated_time_get(hal_rtc_t * time_ptr); diff --git a/2.sdk/sdk/gui/lv_watch/mmi_protocol/mmi_protocol_api.c b/2.sdk/sdk/gui/lv_watch/mmi_protocol/mmi_protocol_api.c index 471b35d2..595b2bec 100644 --- a/2.sdk/sdk/gui/lv_watch/mmi_protocol/mmi_protocol_api.c +++ b/2.sdk/sdk/gui/lv_watch/mmi_protocol/mmi_protocol_api.c @@ -313,6 +313,7 @@ bool mmi_protocol_watch_link_action(void) { #ifdef __MMI_CUSTOM_HENGAI_HEALTH__ mmi_hengai_algorithm_interface_login_action(); + mmi_hengai_health_lib_activation_check_action(); #endif return mmi_protocol_fzd_action_LINK();