From 3b97ceb9c933d5c856158447e19b5e9d517f3e40 Mon Sep 17 00:00:00 2001 From: hcj <1224667075@qq.com> Date: Tue, 11 Jun 2024 16:44:24 +0800 Subject: [PATCH] =?utf8?q?=E8=A1=80=E6=B0=A7=E5=BF=83=E7=8E=87=E4=BF=AE?= =?utf8?q?=E6=94=B9=E8=A1=A5=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../health_service/health_service.cpp | 11 +++++-- .../health_service/health_service.h | 3 +- .../service/ble_service/blemoder/bletest.cpp | 30 ++++++++++++++++++- .../service/ble_service/blemoder/bletest.h | 3 ++ .../service/ble_service/bleservice/bleEvent.c | 16 ++-------- 5 files changed, 45 insertions(+), 18 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/heart_blood/health_service/health_service.cpp b/code/sdk/application/wearable/fd230app/nativeui/heart_blood/health_service/health_service.cpp index 75cb9bdf4..09d869f24 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/heart_blood/health_service/health_service.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/heart_blood/health_service/health_service.cpp @@ -8,9 +8,9 @@ namespace OHOS { static HealthService *g_pHealthService = nullptr; - static constexpr const char *HEALTH_JSON_PATH_HEART = "/user/userdata/health/heart"; + static constexpr const char *HEALTH_JSON_PATH_HEART = "/user/userdata/health/heart/"; - static constexpr const char *HEALTH_JSON_PATH_OXYGEN = "/user/userdata/health/oxygen"; + static constexpr const char *HEALTH_JSON_PATH_OXYGEN = "/user/userdata/health/oxygen/"; std::string GetCurrentDate() { @@ -21,11 +21,16 @@ namespace OHOS return std::string(date); } //static char *JSON_F_buf=NULL; - const char *GET_HEALTH_JSON_PATH_C_STR() + const char *GET_HEALTH_JSON_PATH_C_STR_HEART() { return HEALTH_JSON_PATH_HEART; } + const char *GET_HEALTH_JSON_PATH_C_STR_OXYGEN() + { + return HEALTH_JSON_PATH_OXYGEN; + } + cJSON *heart_root = NULL; cJSON *oxygen_root = NULL; HealthService::HealthService() diff --git a/code/sdk/application/wearable/fd230app/nativeui/heart_blood/health_service/health_service.h b/code/sdk/application/wearable/fd230app/nativeui/heart_blood/health_service/health_service.h index b6e990196..2929060f1 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/heart_blood/health_service/health_service.h +++ b/code/sdk/application/wearable/fd230app/nativeui/heart_blood/health_service/health_service.h @@ -7,7 +7,8 @@ #define HEART_MAX_POINTS 360 namespace OHOS { - const char * GET_HEALTH_JSON_PATH_C_STR(); + const char * GET_HEALTH_JSON_PATH_C_STR_HEART(); + const char * GET_HEALTH_JSON_PATH_C_STR_OXYGEN(); typedef enum { HEALTH_TYPE_HEART, diff --git a/code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp b/code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp index 54ee72788..2512104fc 100644 --- a/code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp +++ b/code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp @@ -757,7 +757,7 @@ const char *get_health_data_path(void) char day[20]; strftime(day, sizeof(day), "%Y%m%d", ltm); char buf[PATH_MAX_LEN]={0}; - sprintf_s(buf,PATH_MAX_LEN-1,"%s%s.json",OHOS::GET_HEALTH_JSON_PATH_C_STR(),day); + sprintf_s(buf,PATH_MAX_LEN-1,"%s%s.json",OHOS::GET_HEALTH_JSON_PATH_C_STR_HEART(),day); if(JSON_F_buf != NULL) { free(JSON_F_buf); @@ -775,7 +775,35 @@ const char *get_health_data_path(void) WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s",JSON_F_buf); #endif return JSON_F_buf; +} + +const char *get_health_OXYGEN_data_path(void) +{ + #ifdef FD230 + time_t now = time(0); + tm *ltm = localtime(&now); + char day[20]; + strftime(day, sizeof(day), "%Y%m%d", ltm); + char buf[PATH_MAX_LEN]={0}; + sprintf_s(buf,PATH_MAX_LEN-1,"%s%s.json",OHOS::GET_HEALTH_JSON_PATH_C_STR_OXYGEN(),day); + if(JSON_F_buf != NULL) + { + free(JSON_F_buf); + JSON_F_buf=NULL; + + } + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "!!!!!!!!!!!%x strlen(buf):%d",JSON_F_buf,strlen(buf)); + uint8_t len = PATH_MAX_LEN+1; + JSON_F_buf=(char *)malloc(len); + memset(JSON_F_buf,0,len); + if(JSON_F_buf != NULL)// + { + strcpy(JSON_F_buf,buf); + } + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s",JSON_F_buf); + #endif + return JSON_F_buf; } void set_weather_now_data(int humidity, char* windScale, char* textNight,int uvIndex,int temp,int iconNight) diff --git a/code/sdk/application/wearable/service/ble_service/blemoder/bletest.h b/code/sdk/application/wearable/service/ble_service/blemoder/bletest.h index bae86503a..ad65e0bae 100644 --- a/code/sdk/application/wearable/service/ble_service/blemoder/bletest.h +++ b/code/sdk/application/wearable/service/ble_service/blemoder/bletest.h @@ -116,7 +116,10 @@ uint8_t ble_is_connect_ready(void); char *addressbook(void); void addressbookToRead(char*); void addressbookTowrite(void); + const char *get_health_data_path(void); +const char *get_health_OXYGEN_data_path(void); + void add_addressbookToRead(char *data); void set_user_data(msg_user_info_t *data); diff --git a/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c b/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c index 7d094c748..a4e5e67e6 100644 --- a/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c +++ b/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c @@ -4298,28 +4298,18 @@ void Read_JSON_file_buf_send_bin_Data(uint8_t num,uint16_t id,char *data_item) dataBit = 1;//心率数据字节1个字节 uint8_t break; case 0x41://同步血氧历史数据 - path=NULL; + path=get_health_OXYGEN_data_path(); dataBit = 1;//血氧数据字节1个字节 uint8_t break; - case 0x43: //同步步数历史数据 - path=NULL; - dataBit = 4;//心率数据字节4个字节 uint32_t - break; case 0x44://同步燃脂时间数据 path=NULL; break; - case 0x45://同步站立历史数据 - path=NULL; - break; case 0x46://同步卡路里历史数据 path=NULL; break; case 0x47://同步距离历史数据 path=NULL; break; - case 0x49://同步基础训练历史数据 - path=NULL; - break; case 0x4b://睡眠历史数据 path=NULL; break; @@ -4387,7 +4377,7 @@ void Read_JSON_file_buf_send_bin_Data(uint8_t num,uint16_t id,char *data_item) { cJSON * heart_data_item=cJSON_GetArrayItem(heart_data_list,i); uint32 timestamp=cJSON_GetObjectItem(heart_data_item,"timestamp")->valueint; - uint32_t value=cJSON_GetObjectItem(heart_data_item,"heart_value")->valueint; + uint32_t value=cJSON_GetObjectItem(heart_data_item,"value")->valueint; // value =450; printf("value :%d\r\n",value); printf("timestamp :%d\r\n",timestamp); @@ -4549,7 +4539,7 @@ void readDevDataBle(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totalData,u printf("同步血氧数据\r\n"); EACH_DATA_LEN = SPO2_DATA_LEN; num=(ble_nus_max_data_len-18)/EACH_DATA_LEN; - Read_JSON_file_buf_send_bin_Data(num,0x41,"heart_data_list"); + Read_JSON_file_buf_send_bin_Data(num,0x41,"spo2_data_list"); break; case 0x43: //同步步数历史数据 -- 2.17.1