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_LEN * sizeof(int));
- _lv_memset_00(s_hengai_bp_raw_data_ptr, MMI_HENGAI_BP_RAW_DATA_LEN * sizeof(int));
- _lv_memcpy(s_hengai_bp_raw_data_ptr, fr8012haq_blood_data_get(&s_hengai_bp_raw_data_len), MMI_HENGAI_BP_RAW_DATA_LEN * sizeof(int));
- HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: raw_data_len=%d\n", __FUNCTION__, __LINE__, s_hengai_bp_raw_data_len);
+ int temp_len = MMI_HENGAI_BP_RAW_DATA_LEN * sizeof(int);
+ s_hengai_bp_raw_data_ptr = (int *)lv_mem_alloc(temp_len);
+ _lv_memset_00(s_hengai_bp_raw_data_ptr, temp_len);
+ _lv_memcpy(s_hengai_bp_raw_data_ptr, fr8012haq_blood_data_get(&s_hengai_bp_raw_data_len), temp_len);
+
+ HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: raw_data_len=%d, temp_len=%d\n", __FUNCTION__, __LINE__, s_hengai_bp_raw_data_len, temp_len);
}
int * mmi_hengai_bp_raw_data_ptr_get(void)
{
int response_code= 0;
int ret = 0;
- struct http_client_list * header = NULL;
- if (s_hengai_http_client != NULL)
- return -2;
+
+ if (NULL != s_hengai_http_client)
+ {
+ HENGAI_HEALTH_DEBUG_PRINTF("client not null\n");
+ ret = -2;
+ goto EXIT;
+ }
s_hengai_http_client = http_client_init();
http_client_setopt(s_hengai_http_client, HTTPCLIENT_OPT_URL, url); /*set URL:support http/https and ip4/ip6*/
json_send = NULL;
#else
-int temp_len = 0;
- char * post_data = lv_mem_alloc(MMI_HENGAI_BP_RAW_DATA_LEN * 9 + 256);
+ int temp_len = 0;
+ int post_data_len = MMI_HENGAI_BP_RAW_DATA_LEN * 9 + 256;
+ char * post_data = lv_mem_alloc(post_data_len);
if(NULL == post_data)
return ;
- _lv_memset_00(post_data, (MMI_HENGAI_BP_RAW_DATA_LEN * 9 + 256));
+ _lv_memset_00(post_data, post_data_len);
temp_len += sprintf(post_data + temp_len, "{\"app_key\":\"%s\",", HENGAI_HTTP_POST_APP_KEY);
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
cJSON * json_send = cJSON_CreateObject();
cJSON_AddItemToObject(json_send, "app_key", cJSON_CreateString(HENGAI_HTTP_POST_APP_KEY));
cJSON_AddItemToObject(json_send, "mac", cJSON_CreateString(imei));
char * post_data = cJSON_Print(json_send);
cJSON_Delete(json_send);
json_send = NULL;
+#else
+ int temp_len = 0;
+ int post_data_len = MMI_HENGAI_BP_RAW_DATA_LEN * 9 + 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, "\"pulse_wave\":[");
+ 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);
+
+ temp_len += sprintf(post_data + temp_len, "\"sbp\":%d,", bp_value_high);
+
+ temp_len += sprintf(post_data + temp_len, "\"dbp\":%d}", bp_value_low);
+
+#endif
char url[256] = {0};
char * url_suffix = "/health/bp/calibration";