From: @CHENG <2393524978@qq.com> Date: Mon, 1 Apr 2024 07:26:46 +0000 (+0800) Subject: gengxin X-Git-Url: http://git.snicker.com.cn/?a=commitdiff_plain;h=53402a433d90c8d33d96143fe18be4c3227fbd92;p=mirrors%2FASR3603_Z5.git gengxin --- diff --git a/2.sdk/project/Z5_HA_K18/gui/lv_watch/mmi_default_CUSTOM.h b/2.sdk/project/Z5_HA_K18/gui/lv_watch/mmi_default_CUSTOM.h index 3dd91c12..c3877344 100644 --- a/2.sdk/project/Z5_HA_K18/gui/lv_watch/mmi_default_CUSTOM.h +++ b/2.sdk/project/Z5_HA_K18/gui/lv_watch/mmi_default_CUSTOM.h @@ -32,7 +32,7 @@ #define MMI_CUSTOMER_MEASURE_TEMPERATURE_DURATION (24 * 1000) // unit:ms -#define MMI_CUSTOMER_MEASURE_BLOOD_DURATION (63 * 1000) // unit:ms +#define MMI_CUSTOMER_MEASURE_BLOOD_DURATION (50 * 1000) // unit:ms #define MMI_CUSTOMER_MEASURE_SPO2_DURATION (54 * 1000) // unit:ms 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 34bdf98f..8975e3ee 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 @@ -15,6 +15,139 @@ static int * s_hengai_bp_raw_data_ptr = NULL; static int s_hengai_bp_raw_data_len = 0; +#ifdef __PPG_DATA_TEST_SEND__ + +#define __SEND_DATA_TIME_INTERVAL (5 * 1000) +#define __SEND_DATA_BUFF_LEN (MMI_HENGAI_BP_RAW_DATA_SAMPLE_RATE * (__SEND_DATA_TIME_INTERVAL / 1000 + 3) * sizeof(int)) + +static int * __send_raw_data_ptr = NULL; +static int __send_raw_data_num = 0; +static int __send_offset_data_num = 0; +static TIMER_ID __send_per_5s_timer_id = NULL; +static char __begin_time_str[24] = {0}, __end_time_str[24] = {0}; + +void __hengai_raw_data_fill(void) +{ + if(NULL == __send_raw_data_ptr) + { + HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__); + return; + } + _lv_memset_00(__send_raw_data_ptr, __SEND_DATA_BUFF_LEN); + + int total_num = 0; + char * total_data = fr8012haq_blood_data_get(&total_num); + + __send_raw_data_num = total_num - __send_offset_data_num; + _lv_memcpy(__send_raw_data_ptr, total_data + __send_offset_data_num * sizeof(int), __send_raw_data_num * sizeof(int)); + __send_offset_data_num = total_num; + + HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: raw_data_num=%d, total_num=%d\n", __FUNCTION__, __LINE__, __send_raw_data_num, total_num); +} + +int * __hengai_raw_data_ptr_get(void) +{ + return __send_raw_data_ptr; +} + +int __hengai_raw_data_len_get(void) +{ + return __send_raw_data_num; +} + +char * __hengai_data_send_begin_time(void) +{ + return __begin_time_str; +} + +char * __hengai_data_send_end_time(void) +{ + return __end_time_str; +} + +void __hengai_data_send_per_5s_stop(void) +{ + HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__); + + if(NULL != __send_per_5s_timer_id) + { + Hal_Timer_Stop(__send_per_5s_timer_id); + __send_per_5s_timer_id = NULL; + } + + if(NULL != __send_raw_data_ptr) + { + lv_mem_free(__send_raw_data_ptr); + __send_raw_data_ptr = NULL; + } + __send_raw_data_num = 0; + __send_offset_data_num = 0; +} + +void __hengai_data_send_per_5s_cb(void * para) +{ + HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__); + + __hengai_raw_data_fill(); + if(true == mmi_protocol_check_state_before_send_action()) + { + hal_rtc_t cur_time = {0}; + Hal_Rtc_Gettime(&cur_time); + sprintf(__end_time_str, "%04d-%02d-%02d %02d:%02d:%02d", + cur_time.tm_year, + cur_time.tm_mon, + cur_time.tm_mday, + cur_time.tm_hour, + cur_time.tm_min, + cur_time.tm_sec); + + __hengai_tcp_bp_measure_raw_data_send(); + + sprintf(__begin_time_str, "%04d-%02d-%02d %02d:%02d:%02d", + cur_time.tm_year, + cur_time.tm_mon, + cur_time.tm_mday, + cur_time.tm_hour, + cur_time.tm_min, + cur_time.tm_sec); + } +} + +void __hengai_data_send_per_5s_action(void) +{ + HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__); + + __hengai_data_send_per_5s_stop(); + + if(NULL != __send_raw_data_ptr) + { + lv_mem_free(__send_raw_data_ptr); + __send_raw_data_ptr = NULL; + } + __send_raw_data_ptr = (int *)lv_mem_alloc(__SEND_DATA_BUFF_LEN); + if(NULL == __send_raw_data_ptr) + { + HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__); + return; + } + _lv_memset_00(__send_raw_data_ptr, __SEND_DATA_BUFF_LEN); + __send_raw_data_num = 0; + __send_offset_data_num = 0; + + hal_rtc_t cur_time = {0}; + Hal_Rtc_Gettime(&cur_time); + sprintf(__begin_time_str, "%04d-%02d-%02d %02d:%02d:%02d", + cur_time.tm_year, + cur_time.tm_mon, + cur_time.tm_mday, + cur_time.tm_hour, + cur_time.tm_min, + cur_time.tm_sec); + __send_per_5s_timer_id = Hal_Timer_Start(__SEND_DATA_TIME_INTERVAL, __hengai_data_send_per_5s_cb, NULL, true); +} +#endif + + bool mmi_hengai_bp_measuring_flag_get(void) { return (s_hengai_bp_measuring); @@ -244,6 +377,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(); + +#ifdef __PPG_DATA_TEST_SEND__ + __hengai_data_send_per_5s_stop(); +#endif + + if(mmi_hengai_bp_measuring_flag_get()) { mmi_hsensor_close(); @@ -455,6 +594,11 @@ void mmi_ui_msg_update_hengai_bp_measure_result(bool state, uint16_t bp_value_hi void mmi_hengai_bp_measure_data_send_task_cb(lv_task_t * task) { +#ifdef __PPG_DATA_TEST_SEND__ + __hengai_data_send_per_5s_stop(); + +#else + if(true == mmi_protocol_check_state_before_send_action()) { #ifdef __MMI_CUSTOM_HENGAI_HEALTH_UPLOAD_USE_TCP__ @@ -467,6 +611,7 @@ void mmi_hengai_bp_measure_data_send_task_cb(lv_task_t * task) { mmi_hengai_bp_measure_result_timeout(NULL); } +#endif } void mmi_hengai_bp_measure_finish_screen(void) @@ -604,6 +749,12 @@ void mmi_hengai_bp_measure_start_btn_event_cb(lv_obj_t * obj, lv_event_t e) mmi_hengai_bp_measuring_flag_set(true); s_hengai_bp_measure_count = 0; + + #ifdef __PPG_DATA_TEST_SEND__ + __hengai_data_send_per_5s_action(); + #endif + + 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); 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 bf45ba7d..80d68317 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 @@ -18,9 +18,19 @@ extern "C" { #ifdef __MMI_CUSTOM_HENGAI_HEALTH__ + +///#define __PPG_DATA_TEST_SEND__ // just for hengai test +#ifdef __PPG_DATA_TEST_SEND__ +int * __hengai_raw_data_ptr_get(void); +int __hengai_raw_data_len_get(void); +char * __hengai_data_send_begin_time(void); +char * __hengai_data_send_end_time(void); +#endif + + #define MMI_HENGAI_BP_TAB_COUNT (3) -#define MMI_BP_MEASURE_TOTAL_COUNT (63) // (60) // times +#define MMI_BP_MEASURE_TOTAL_COUNT (50) // times #define MMI_BP_WAIT_RESULT_TIMEOUT (1000 * 10) // ms 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 33e014f0..110ba4b5 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 @@ -14,6 +14,157 @@ static HENGAI_HEALTH_SEND_TYPE_ENUM s_hengai_bp_send_code = HENGAI_HEALTH_SEND_NONE; // +#ifdef __PPG_DATA_TEST_SEND__ +void __hengai_tcp_bp_measure_raw_data_send(void) +{ + HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__); + + char * data_ptr = NULL; + uint32_t data_len = 0; + char * encode_str = NULL; + uint32_t encode_len = 0; + char * encode_header_str = NULL; + uint32_t encode_header_len = 0; + uint32_t output_len = 0; + uint32_t output_header_len = 0; + int temp_len = 0; + int json_data_len = MMI_HENGAI_BP_RAW_DATA_LEN * 11 + 256; + char * json_data = NULL; + + // json body + json_data = lv_mem_alloc(json_data_len); + if(NULL == json_data) + { + HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: memory alloc failed\n", __FUNCTION__, __LINE__); + goto FREE_AND_EXIT; + } + _lv_memset_00(json_data, json_data_len); + + temp_len = 0; + temp_len += sprintf(json_data + temp_len, "{\"app_key\":\"%s\",", HENGAI_HTTP_POST_APP_KEY); + + char imei[16 + 1] = {0}; + app_adp_get_imei_req(imei); + temp_len += sprintf(json_data + temp_len, "\"mac\":\"%s\",", imei); + + char * begin_time_str = __hengai_data_send_begin_time(); + temp_len += sprintf(json_data + temp_len, "\"begin_time\":\"%s\",", begin_time_str); + + char * end_time_str = __hengai_data_send_end_time(); + temp_len += sprintf(json_data + temp_len, "\"end_time\":\"%s\",", end_time_str); + + uint16_t i = 0; + int * temp_int_ptr = __hengai_raw_data_ptr_get(); + int temp_int_len = __hengai_raw_data_len_get(); + temp_len += sprintf(json_data + temp_len, "\"pulse_wave\":["); + for(i = 0; i < temp_int_len; i++) + { + if(i == (temp_int_len - 1)) + { + temp_len += sprintf(json_data + temp_len, "%d],", temp_int_ptr[i]); + } + else + { + temp_len += sprintf(json_data + temp_len, "%d,", temp_int_ptr[i]); + } + } + + temp_len += sprintf(json_data + temp_len, "\"sample_rate\":%d}", MMI_HENGAI_BP_RAW_DATA_SAMPLE_RATE); + + HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: %d\n", __FUNCTION__, __LINE__, temp_len); + + // base64 body + encode_len = temp_len * 3 / 2; + encode_str = lv_mem_alloc(encode_len); + if(NULL == encode_str) + { + HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: memory alloc failed\n", __FUNCTION__, __LINE__); + goto FREE_AND_EXIT; + } + _lv_memset_00(encode_str, encode_len); + if(0 != mbedtls_base64_encode(encode_str, encode_len, &output_len, json_data, temp_len)) + { + HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: base64 encode failed\n", __FUNCTION__, __LINE__); + goto FREE_AND_EXIT; + } + + // json header + _lv_memset_00(json_data, json_data_len); + + temp_len = 0; + temp_len += sprintf(json_data + temp_len, "{\"headers\":["); + + temp_len += sprintf(json_data + temp_len, "{\"key\":\"token\","); + + char * token = mmi_hengai_health_token_get(); + temp_len += sprintf(json_data + temp_len, "\"value\":\"%s\"}", token); + + temp_len += sprintf(json_data + temp_len, "]}"); + + HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: %d\n", __FUNCTION__, __LINE__, temp_len); + + // base64 header + encode_header_len = temp_len * 3 / 2; + encode_header_str = lv_mem_alloc(encode_header_len); + if(NULL == encode_header_str) + { + HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: memory alloc failed\n", __FUNCTION__, __LINE__); + goto FREE_AND_EXIT; + } + _lv_memset_00(encode_header_str, encode_header_len); + if(0 != mbedtls_base64_encode(encode_header_str, encode_header_len, &output_header_len, json_data, temp_len)) + { + HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: base64 encode failed\n", __FUNCTION__, __LINE__); + goto FREE_AND_EXIT; + } + + // content + data_len = output_len + output_header_len + 128; + data_ptr = lv_mem_alloc(data_len); + if(NULL == data_ptr) + { + HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: memory alloc failed\n", __FUNCTION__, __LINE__); + goto FREE_AND_EXIT; + } + _lv_memset_00(data_ptr, data_len); + + #if 1 + sprintf(data_ptr, ",POST,%s%s,%s,%s", HENGAI_HTTP_POST_URL_COMMON_PREFIX, "/health/bp/measurement", encode_header_str, encode_str); + #else + sprintf(data_ptr, "POST,%s%s,%s,%s", HENGAI_HTTP_POST_URL_COMMON_PREFIX, "/health/bp/measurement", encode_header_str, encode_str); + #endif + data_len = strlen(data_ptr); + HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: %d\n", __FUNCTION__, __LINE__, data_len); + + s_hengai_bp_send_code = HENGAI_HEALTH_SEND_MEASURE_DATA; + mmi_protocol_fzd_action_tcp_http(data_ptr, data_len); + +FREE_AND_EXIT: + if(NULL != json_data) + { + lv_mem_free(json_data); + json_data = NULL; + } + if(NULL != encode_str) + { + lv_mem_free(encode_str); + encode_str = NULL; + } + if(NULL != encode_header_str) + { + lv_mem_free(encode_header_str); + encode_header_str = NULL; + } + if(NULL != data_ptr) + { + lv_mem_free(data_ptr); + data_ptr = NULL; + } +} +#endif + + + // back measure data void mmi_hengai_tcp_bp_back_measure_raw_data_send(void) { diff --git a/2.sdk/sdk/gui/lv_watch/mmi_protocol/mmi_protocol_fzd.c b/2.sdk/sdk/gui/lv_watch/mmi_protocol/mmi_protocol_fzd.c index 8b7cc2a3..04da9c86 100644 --- a/2.sdk/sdk/gui/lv_watch/mmi_protocol/mmi_protocol_fzd.c +++ b/2.sdk/sdk/gui/lv_watch/mmi_protocol/mmi_protocol_fzd.c @@ -2194,7 +2194,6 @@ bool mmi_protocol_fzd_parse_ACTION_GET_APP_QRCODE(unsigned char * next_buff, uns } - #ifdef __MMI_ZHSX_SUPPORT_VIDEO_CALL__ #ifdef __MMI_ZHSX_SUPPORT_VIDEO_CALL_WULIAN__ bool mmi_protocol_fzd_action_get_vc_config(void)