From: @CHENG <2393524978@qq.com> Date: Wed, 24 Jan 2024 06:49:51 +0000 (+0800) Subject: gengxin X-Git-Url: http://git.snicker.com.cn/?a=commitdiff_plain;h=0c321fb3a0834cfc782b539cd621371e60ee2e84;p=mirrors%2FASR3603_Z5.git gengxin --- 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 fd88e782..8b2ce74c 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 @@ -186,6 +186,117 @@ int mmi_hengai_http_post_data(char * url, char * post_data, char * token) } +// emotion data +void mmi_hengai_emotion_raw_data_send(void) +{ +#if 0 + 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_emotion_action_time_string_get(1); + char * end_time_str = mmi_hengai_emotion_action_time_string_get(0); +#if 0 // def HENGAI_HTTP_TEST + char * token = "dc5aed59e2fce3060cd1118b41b19552"; +#else + char * token = mmi_hengai_health_token_get(); +#endif + + int temp_len = 0; + int post_data_len = MMI_HENGAI_BP_RAW_DATA_LEN * 11 + 256; + 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, "\"mac\":\"%s\",", imei); + + temp_len += sprintf(post_data + temp_len, "\"begin_time\":\"%s\",", begin_time_str); + + temp_len += sprintf(post_data + temp_len, "\"end_time\":\"%s\",", end_time_str); + + uint16_t i = 0; + int * temp_int_ptr = mmi_hengai_bp_raw_data_ptr_get(); + int temp_int_len = mmi_hengai_bp_raw_data_len_get(); + temp_len += sprintf(post_data + temp_len, "\"middle_value\":["); + for(i = 0; i < temp_int_len; i++) + { + if(i == (temp_int_len - 1)) + { + temp_len += sprintf(post_data + temp_len, "%d],", temp_int_ptr[i]); + } + else + { + temp_len += sprintf(post_data + temp_len, "%d,", temp_int_ptr[i]); + } + } + + temp_len += sprintf(post_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); + + char url[256] = {0}; + char * url_suffix = "/health/emotion/measurement"; + 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)); + 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_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"); + uint16_t emo_status = cJSON_GetIntValue(cJSON_GetObjectItem(json_data, "emo_status")); + uint16_t pressure = cJSON_GetIntValue(cJSON_GetObjectItem(json_data, "pressure")); + uint16_t anxiety = cJSON_GetIntValue(cJSON_GetObjectItem(json_data, "anxiety")); + uint16_t depression = cJSON_GetIntValue(cJSON_GetObjectItem(json_data, "depression")); + + + } + else + { + HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: false\n", __FUNCTION__, __LINE__); + } + } + else + { + HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: not json file\n", __FUNCTION__, __LINE__); + } + + if(NULL != json_recv) + { + HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: free json root\n", __FUNCTION__, __LINE__); + cJSON_Delete(json_recv); + json_recv = NULL; + } + } + + if(NULL != s_hengai_http_revceive_buf) + { + lv_mem_free(s_hengai_http_revceive_buf); + s_hengai_http_revceive_buf = NULL; + } +#endif +} + + // measure data void mmi_hengai_bp_measure_raw_data_send(void) { 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 ba0f0543..a7fd21e2 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 @@ -49,6 +49,11 @@ extern "C" { #define HENGAI_HTTP_POST_TRY_COUNT_MAX (3) +void mmi_hengai_emotion_raw_data_send(void); + +void mmi_hengai_bp_measure_raw_data_send(void); + +void mmi_hengai_bp_calibrate_raw_data_send(uint8_t calibrate_times, uint16_t bp_value_high, uint16_t bp_value_low); void mmi_hengai_health_lib_activation_check_action(void); diff --git a/2.sdk/sdk/gui/lv_watch/lv_apps/custom_function/heng_ai_tcms.c b/2.sdk/sdk/gui/lv_watch/lv_apps/custom_function/heng_ai_tcms.c index 8760bfaa..e980475b 100644 --- a/2.sdk/sdk/gui/lv_watch/lv_apps/custom_function/heng_ai_tcms.c +++ b/2.sdk/sdk/gui/lv_watch/lv_apps/custom_function/heng_ai_tcms.c @@ -19,22 +19,16 @@ void mmi_hengai_tcms_mission_check(void) HENGAI_TCMS_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: counter=%d\n", __FUNCTION__, __LINE__, s_hengai_tcms_counter); if(HENGAI_TCMS_COUNTER_MAX <= s_hengai_tcms_counter) { - uint8_t data_num = 0; - HENGAI_TCMS_DATA_T * data_ptr = NULL; - uint32_t data_len = (HENGAI_TCMS_COUNTER_MAX + 2) * sizeof(HENGAI_TCMS_DATA_T); - - data_ptr = lv_mem_alloc(data_len); - if(NULL == data_ptr) - return; - _lv_memset_00(data_ptr, data_len); - - data_num = fr8012haq_YYL_data_get(data_ptr); - HENGAI_TCMS_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: array num=%d\n", __FUNCTION__, __LINE__, data_num); - if(0 != data_num) + char * data_ptr = NULL; + uint32_t data_len = 0; + + data_ptr = fr8012haq_YYL_data_get(&data_len); + HENGAI_TCMS_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: data_len=%d\n", __FUNCTION__, __LINE__, data_len); + if(NULL != data_ptr) { - mmi_protocol_fzd_action_hengai_tcms_data(data_ptr, data_num); + mmi_protocol_fzd_action_hengai_tcms_data(data_ptr, data_len); } - lv_mem_free(data_ptr); + fr8012haq_YYL_data_clean(); s_hengai_tcms_counter = 0; } diff --git a/2.sdk/sdk/gui/lv_watch/lv_apps/custom_function/heng_ai_tcms.h b/2.sdk/sdk/gui/lv_watch/lv_apps/custom_function/heng_ai_tcms.h index 1f5fbb9e..9681a646 100644 --- a/2.sdk/sdk/gui/lv_watch/lv_apps/custom_function/heng_ai_tcms.h +++ b/2.sdk/sdk/gui/lv_watch/lv_apps/custom_function/heng_ai_tcms.h @@ -27,22 +27,7 @@ extern "C" { #endif -#define HENGAI_TCMS_COUNTER_MAX (30) - -// yylPFE_OutputData -typedef struct -{ - uint32_t time; - uint32_t timestamp; - uint32_t areaUP; - uint16_t areaUPBase; - uint16_t areaUPHeight; - uint32_t areaDOWN; - uint16_t areaDOWNBase; - uint16_t areaDOWNHeight; - uint16_t RRI; - uint16_t motion; -}HENGAI_TCMS_DATA_T; +#define HENGAI_TCMS_COUNTER_MAX (5) // minutes void mmi_hengai_tcms_mission_check(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 1a4540d0..90052c92 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 @@ -3739,7 +3739,7 @@ bool mmi_protocol_fzd_action_hengai_sleep_data_test(char * file_buf, uint32_t fi #endif #ifdef __MMI_CUSTOM_HENGAI_TCMS__ -bool mmi_protocol_fzd_action_hengai_tcms_data(HENGAI_TCMS_DATA_T * data_ptr, uint8_t data_num) +bool mmi_protocol_fzd_action_hengai_tcms_data(char * data_ptr, uint32_t data_len) { bool result = false; MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_ACTION_HENGAI_TCMS_DATA; @@ -3747,44 +3747,27 @@ bool mmi_protocol_fzd_action_hengai_tcms_data(HENGAI_TCMS_DATA_T * data_ptr, uin unsigned int content_lenth = 0; unsigned char * temp_ptr = NULL; unsigned int temp_lenth = 0; - uint32_t data_len = data_num * 100 + 64; uint32_t cur_time_stamp = 0; - uint8_t i = 0; - content_buff = (unsigned char *)lv_mem_alloc(data_len); + content_lenth = data_len + 128; + content_buff = (unsigned char *)lv_mem_alloc(content_lenth); if(NULL == content_buff) { PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__); return false; } - _lv_memset_00(content_buff, data_len); + _lv_memset_00(content_buff, content_lenth); Hal_Rtc_Gettime_Count(&cur_time_stamp); temp_lenth = 0; temp_ptr = content_buff + temp_lenth; - sprintf(temp_ptr, ",%d,%d", data_num, cur_time_stamp); + sprintf(temp_ptr, ",%d,%d,", 0, cur_time_stamp); temp_lenth = strlen(temp_ptr); temp_ptr += temp_lenth; - for(i = 0; i < data_num; i++) - { - sprintf(temp_ptr, ",%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", - data_ptr[i].time, - data_ptr[i].timestamp, - data_ptr[i].areaUP, - data_ptr[i].areaUPBase, - data_ptr[i].areaUPHeight, - data_ptr[i].areaDOWN, - data_ptr[i].areaDOWNBase, - data_ptr[i].areaDOWNHeight, - data_ptr[i].RRI, - data_ptr[i].motion); - - temp_lenth = strlen(temp_ptr); - temp_ptr += temp_lenth; - } + _lv_memcpy(temp_ptr, data_ptr, data_len - 1); // not copy the last char(',') content_lenth = strlen(content_buff); diff --git a/2.sdk/sdk/gui/lv_watch/mmi_protocol/mmi_protocol_fzd.h b/2.sdk/sdk/gui/lv_watch/mmi_protocol/mmi_protocol_fzd.h index 5a828210..f84e5757 100644 --- a/2.sdk/sdk/gui/lv_watch/mmi_protocol/mmi_protocol_fzd.h +++ b/2.sdk/sdk/gui/lv_watch/mmi_protocol/mmi_protocol_fzd.h @@ -347,8 +347,8 @@ bool mmi_protocol_fzd_parse_ACTION_HENGAI_ACTIVATION(unsigned char * next_buff, bool mmi_protocol_fzd_action_hengai_activation_feedback(void); bool mmi_protocol_fzd_action_hengai_sleep_data(char * file_buf, uint32_t file_size); #endif -#if 0 //def __MMI_CUSTOM_HENGAI_TCMS__ -bool mmi_protocol_fzd_action_hengai_tcms_data(HENGAI_TCMS_DATA_T * data_ptr, uint8_t data_num); +#ifdef __MMI_CUSTOM_HENGAI_TCMS__ +bool mmi_protocol_fzd_action_hengai_tcms_data(char * data_ptr, uint32_t data_len); #endif #endif