From 2a0abdee7ea5a2c53453b1c1e2a273dfe77c0d72 Mon Sep 17 00:00:00 2001 From: Caisking Date: Tue, 15 Jul 2025 14:47:29 +0800 Subject: [PATCH] =?utf8?q?=E5=A2=9E=E5=8A=A0=E7=B3=BB=E7=BB=9F=E7=9A=84?= =?utf8?q?=E6=97=A5=E5=BF=97=E8=AE=B0=E5=BD=95=E5=AE=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../bloodoxygen/src/BloodOxygenModel.cpp | 94 ++++---- .../bloodoxygen/src/BloodResultView.cpp | 8 +- .../nativeui/heartrate/src/HeartModel.cpp | 33 ++- .../nativeui/traing/src/TraingModel.cpp | 204 ++++++++---------- .../msg_center/src/msg_center_customer.cpp | 7 +- 5 files changed, 173 insertions(+), 173 deletions(-) diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/bloodoxygen/src/BloodOxygenModel.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/bloodoxygen/src/BloodOxygenModel.cpp index 7abcf4bd5..a762368fc 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/bloodoxygen/src/BloodOxygenModel.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/bloodoxygen/src/BloodOxygenModel.cpp @@ -1,7 +1,7 @@ #include "bloodoxygen/include/BloodOxygenModel.h" #include "bloodoxygen/include/BloodResultPresenter.h" -// #include "DialModelSPO2.h" +#include "DialModelSPO2.h" #include "wearable_log.h" #include "heart_blood/health_service/health_service.h" @@ -19,8 +19,8 @@ extern "C" errcode_t uapi_get_timestamp_ms(uint32_t *tm); #include "ConfigModel.h" #include "AppViewIDs.h" #include "NativeAbility.h" -// #include "battery_hal.h" -// #include "heart_blood/BloodCardView.h" +#include "battery_hal.h" +#include "heart_blood/BloodCardView.h" #include "MainViewSample.h" #include @@ -35,20 +35,20 @@ namespace OHOS */ BloodOxygenModel::BloodOxygenModel() { - // BloodOxygenData *data = HealthService::GetInstance()->ReadBloodOxygenData(); - // if (data) - // { - // currentspo2 = data->SPO2; - // timestamp_ms = data->timestamp; - // // 更新表盘血氧数据 - // DialModelSPO2::GetInstance()->UpdateSPO2(currentspo2); - // delete data; - // } - // else - // { + BloodOxygenData *data = HealthService::GetInstance()->ReadBloodOxygenData(); + if (data) + { + currentspo2 = data->SPO2; + timestamp_ms = data->timestamp; + // 更新表盘血氧数据 + DialModelSPO2::GetInstance()->UpdateSPO2(currentspo2); + delete data; + } + else + { currentspo2 = 0; timestamp_ms = 0; - // } + } } BloodOxygenModel::~BloodOxygenModel() {} BloodOxygenModel *BloodOxygenModel::GetInstance(void) @@ -70,32 +70,34 @@ namespace OHOS { if (state == BloodState::End && startspo2 == true) { - // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "startspo2 End"); - // uint16_t md = PPG_SERVICE_CMD_TYPE_STOP_SPO2_TEST; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "startspo2 End"); + uint16_t md = PPG_SERVICE_CMD_TYPE_STOP_SPO2_TEST; #ifdef SUPPORT_PPG_SERVICE - // send_ppg_cmd_msg(md); + send_ppg_cmd_msg(md); +#endif + startspo2 = false; +#ifdef SYSTEM_LOG_SERVICE + uapi_save_runtime_log(RUNTIME_LOG_OXYGEN_MEASURE_END); #endif - // startspo2 = false; - - // uapi_save_runtime_log(RUNTIME_LOG_OXYGEN_MEASURE_END); } else if (state == BloodState::Start && startspo2 == false) { /*充电状态下不进行检测*/ - // bool isCharging = get_charge_stat(); // 获取充电状态 - // if (isCharging) - // { - // WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "充电不能检测"); - // return; - // } - // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "startspo2 Start"); - // uint16_t md = PPG_SERVICE_CMD_TYPE_DO_SPO2_TEST; + bool isCharging = get_charge_stat(); // 获取充电状态 + if (isCharging) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "充电不能检测"); + return; + } + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "startspo2 Start"); + uint16_t md = PPG_SERVICE_CMD_TYPE_DO_SPO2_TEST; #ifdef SUPPORT_PPG_SERVICE - // send_ppg_cmd_msg(md); + send_ppg_cmd_msg(md); +#endif + startspo2 = true; +#ifdef SYSTEM_LOG_SERVICE + uapi_save_runtime_log(RUNTIME_LOG_OXYGEN_MEASURE); #endif - // startspo2 = true; - - // uapi_save_runtime_log(RUNTIME_LOG_OXYGEN_MEASURE); } } @@ -166,14 +168,13 @@ namespace OHOS data.timestamp = timestamp_ms; HealthService::GetInstance()->UpdateHealthData(data); #else - // HealthService::GetInstance()->send_blood_save(); + HealthService::GetInstance()->send_blood_save(); #endif } // 显示检测结果// 显示检测结果 void BloodOxygenModel::Blood_Result() { -#if 0 uint16_t MiniBlood = ConfigModel::GetInstance()->get_configData_int(ConfigModel::CONFIGMODEL_ITEM_OXYGEN_THRESHOLD_VALUE); // 检查当前血氧值并设置结果 需要检测成功 @@ -233,7 +234,6 @@ namespace OHOS break; } } - #endif } // 更新佩戴状态 void BloodOxygenModel::SetWearStatus(int32_t wear) @@ -301,16 +301,16 @@ namespace OHOS // 更新血氧数据 void BloodOxygenModel::CleanAllData(void) { - // WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Nextday!"); - // if (MainViewSample::GetInstance() != nullptr && BloodCardView::GetInstance() != nullptr) - // { - // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "更新主界面血氧卡片"); - // BloodCardView::GetInstance()->UpSPO2Text(); - // } - // if (BloodResultView::GetInstance() != nullptr) - // { - // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "更新测量血氧卡片"); - // BloodResultView::GetInstance()->UpSPO2Text(); - // } + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Nextday!"); + if (MainViewSample::GetInstance() != nullptr && BloodCardView::GetInstance() != nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "更新主界面血氧卡片"); + BloodCardView::GetInstance()->UpSPO2Text(); + } + if (BloodResultView::GetInstance() != nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "更新测量血氧卡片"); + BloodResultView::GetInstance()->UpSPO2Text(); + } } } diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/bloodoxygen/src/BloodResultView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/bloodoxygen/src/BloodResultView.cpp index 500ccffba..7cb38d8b1 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/bloodoxygen/src/BloodResultView.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/bloodoxygen/src/BloodResultView.cpp @@ -9,15 +9,15 @@ #include "ui_resource_image.h" #include #include "components/ui_button.h" -// #include "MainViewSample.h" +#include "MainViewSample.h" #include "components/ui_view_group.h" -// #include "DialModelSPO2.h" -// #include "DialModelHeartRate.h" +#include "DialModelSPO2.h" +#include "DialModelHeartRate.h" #include "BloodOxygenModel.h" #include "UiConfig.h" #include "uicomponents/UIComponents.h" -// #include "MainPresenterSample.h" +#include "MainPresenterSample.h" #include "bloodoxygen/include/BloodResultPresenter.h" #include "bloodoxygen/include/BloodResultView.h" diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/heartrate/src/HeartModel.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/heartrate/src/HeartModel.cpp index 830eb5355..7672ae955 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/heartrate/src/HeartModel.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/heartrate/src/HeartModel.cpp @@ -439,37 +439,41 @@ void HeartModel::Heart_Control(HeartState state, HeartCheck check) { sensorstate = false; uapi_dev_runtime_set_heartrate_detect_status(0); } - +#ifdef SYSTEM_LOG_SERVICE //记录日志 if (checkstate == HeartCheck::PASSIVITY) { uapi_save_runtime_log(RUNTIME_LOG_OXYGEN_PASSIVE_MEASURE_END); } else { uapi_save_runtime_log(RUNTIME_LOG_HEART_MEASURE_END); } +#endif // 复原检测状态 checkstate = HeartCheck::RESTSTSTE; + heart_stop_data_timer(); //关闭数据获取 } else if (state == HeartState::Start && heartstate == false) { /*充电状态下不进行检测*/ bool isCharging = get_charge_stat(); // 获取充电状态 if (isCharging) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "充电不能检测"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "充电不能检测"); return; } - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "HeartState Start"); + #ifdef SUPPORT_PPG_SERVICE + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "HeartState Start"); uint8_t md = PPG_SERVICE_CMD_TYPE_DO_PPG_TEST; send_ppg_cmd_msg(md); #endif heartstate = true; checkstate = check; - +#ifdef SYSTEM_LOG_SERVICE //记录日志 if (checkstate == HeartCheck::PASSIVITY) { uapi_save_runtime_log(RUNTIME_LOG_HEART_PASSIVE_MEASURE); } else { uapi_save_runtime_log(RUNTIME_LOG_HEART_MEASURE); } +#endif } } // 开始检测 @@ -498,8 +502,6 @@ void HeartModel::Heart_Stop() { disvalid_counter_ = 0; unwear_counter_ = 0; - heart_stop_data_timer(); //关闭数据获取 - /*主界面卡片检测 或者 被动检测*/ if (checkstate == HeartCheck::PASSIVITY) { if (heartresult_ == HeartResult::SUCCESS) { @@ -683,8 +685,9 @@ void HeartModel::SetWearStatus() { return; unwear_counter_++; +#ifdef SYSTEM_LOG_SERVICE uapi_save_runtime_log(RUNTIME_LOG_HEART_NOT_WEAR); - +#endif // 设置佩戴状态 if (checkstate == HeartCheck::CARDCHECK) { if (unwear_counter_ > MAX_UNWEAR_COUNT) { @@ -692,14 +695,18 @@ void HeartModel::SetWearStatus() { //只有在心率卡片界面才触发 if (MainViewSample::GetInstance()->GetHorCurrentCard() == HEART_RATE) { SetResult(HeartResult::NOT_WORN); +#ifdef SYSTEM_LOG_SERVICE uapi_save_runtime_log(RUNTIME_LOG_HEART_ERROR_NOT_WEAR); +#endif Heart_Stop(); } } } } else { SetResult(HeartResult::NOT_WORN); +#ifdef SYSTEM_LOG_SERVICE uapi_save_runtime_log(RUNTIME_LOG_HEART_ERROR_NOT_WEAR); +#endif Heart_Stop(); } } @@ -729,11 +736,15 @@ void HeartModel::UpHeartdata(uint16_t heart) { currentheart = displayheart; // 更新当前心率 valid_counter_++; // 增加有效计数器 disvalid_counter_ = 0; // 清空无效计数器 +#ifdef SYSTEM_LOG_SERVICE uapi_save_runtime_log(RUNTIME_LOG_HEART_VALID_VALUE); +#endif } else { disvalid_counter_++; // 增加无效计数器 valid_counter_ = 0; // 清零有效计数器 +#ifdef SYSTEM_LOG_SERVICE uapi_save_runtime_log(RUNTIME_LOG_HEART_INVALID_VALUE); +#endif } // 检查无效计数器是否达标 @@ -746,7 +757,9 @@ void HeartModel::UpHeartdata(uint16_t heart) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "检测结果:无效数达标 disvalid_counter:%d", disvalid_counter_); SetResult(HeartResult::INVALID_DATA); // 标记为无效数据 +#ifdef SYSTEM_LOG_SERVICE uapi_save_runtime_log(RUNTIME_LOG_HEAR_ERROR_INVALID_VALUE); +#endif Heart_Stop(); return; } @@ -756,7 +769,9 @@ void HeartModel::UpHeartdata(uint16_t heart) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "检测结果:成功 valid_counter:%d currentheart:%d", valid_counter_, currentheart); +#ifdef SYSTEM_LOG_SERVICE uapi_save_runtime_log(RUNTIME_LOG_HEAR_SUCCESS); +#endif SetResult(HeartResult::SUCCESS); // 标记为成功检测 Heart_Stop(); return; @@ -1022,8 +1037,8 @@ static void heart_data_callbackProc(int data) { //更新佩戴 uint8_t wear = 1; #ifdef SUPPORT_PPG_SERVICE - wear = ppg_get_wear_status(); - wear = 1;//暂时屏蔽 + wear = ppg_get_wear_status(); + wear = 1; //暂时屏蔽 // printf("heart_data_callbackProc::wear = %d\n", wear); #endif if (wear == 0) { diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/src/TraingModel.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/src/TraingModel.cpp index 7597c4fc9..6d347df1f 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/src/TraingModel.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/src/TraingModel.cpp @@ -31,7 +31,6 @@ #include "bleService.h" #endif - #include "broadcast_feature.h" #include "broadcast_service.h" #include "custom_runtime.h" @@ -58,7 +57,6 @@ #include #include - #include "chip_system_time.h" #include @@ -124,7 +122,7 @@ void TraingUnsubscribeTopic(Topic topic) { } int flag = 0; static void Training_Notify(void *args, const Topic topic, Request *request) { - #ifdef CYWEE_ACTIVITY_ENABLE +#ifdef CYWEE_ACTIVITY_ENABLE UNUSED(args); UNUSED(topic); if (request == NULL) { @@ -148,7 +146,8 @@ static void Training_Notify(void *args, const Topic topic, Request *request) { delete traingbleInfo; } //增加训练runtime控制 - if (uapi_dev_runtime_get_train_status() == 0 || TraingModel::GetInstance()->GetSportState() == ExerciseState::End) { + if (uapi_dev_runtime_get_train_status() == 0 || + TraingModel::GetInstance()->GetSportState() == ExerciseState::End) { return; } //训练基本信息更新 @@ -170,17 +169,14 @@ static void Training_Notify(void *args, const Topic topic, Request *request) { } //训练额外信息 if (request->msgId == TOPIC_EVENT_ACTIVITY_EXTRA_INFO_UPDATE) { - act_ext_result_t *cyweeInfo_ext = - new act_ext_result_t(); - int rets = memcpy_s( - cyweeInfo_ext, sizeof(act_ext_result_t), - (act_ext_result_t *)request->data, request->len); + act_ext_result_t *cyweeInfo_ext = new act_ext_result_t(); + int rets = memcpy_s(cyweeInfo_ext, sizeof(act_ext_result_t), + (act_ext_result_t *)request->data, request->len); if (rets != EOK) { delete cyweeInfo_ext; // 处理内存分配失败的情况 cyweeInfo_ext = NULL; WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, - "memcpy_s act_ext_result_t fail ret = %d", - rets); + "memcpy_s act_ext_result_t fail ret = %d", rets); return; } TraingModel::GetInstance()->AnalysisExtraData(cyweeInfo_ext); @@ -191,7 +187,7 @@ static void Training_Notify(void *args, const Topic topic, Request *request) { uint8_t heart = *((u_int8_t *)(request->data)); // 进行类型转换 TraingModel::GetInstance()->AnalysisHeartData(heart); } - #endif +#endif } #ifdef __cplusplus } @@ -455,13 +451,13 @@ void TraingModel::SetSportState(ExerciseState state) { if (state == ExerciseState::Start) { sportdata->duration = 0; } - #ifdef BLE_SERVER_ENABLE +#ifdef BLE_SERVER_ENABLE sendtraningstatedata(static_cast(state), sportdata->duration); - #endif +#endif } } sportState_ = state; - +#ifdef SYSTEM_LOG_SERVICE // 记录运动状态 if (state == ExerciseState::End) { uapi_save_runtime_log(RUNTIME_LOG_SPORT_END); @@ -470,6 +466,7 @@ void TraingModel::SetSportState(ExerciseState state) { } else if (state == ExerciseState::Pause) { uapi_save_runtime_log(RUNTIME_LOG_SPORT_PAUSE); } +#endif } /*获取运动状态*/ ExerciseState TraingModel::GetSportState() { return sportState_; } @@ -562,8 +559,7 @@ void TraingModel::AnalysisData(act_result_t *cyweeInfo) { /*分析activity extra info数据*/ #ifdef CYWEE_ACTIVITY_ENABLE -void TraingModel::AnalysisExtraData( - act_ext_result_t *cyweeInfo) { +void TraingModel::AnalysisExtraData(act_ext_result_t *cyweeInfo) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[apc:%d fpc:%d cdc:%d std:%d]", cyweeInfo->avg_pace, cyweeInfo->max_pace, @@ -574,7 +570,7 @@ void TraingModel::AnalysisExtraData( } //最快配速 if (cyweeInfo->max_pace != 0) { - sportdata->fpc =cyweeInfo->max_pace; + sportdata->fpc = cyweeInfo->max_pace; } //平均步频 if (cyweeInfo->avg_step_freq != 0) { @@ -634,7 +630,7 @@ void TraingModel::SetSportdata(SportData *data) { sportdata->spc = data->spc; sportdata->std = data->std; sportdata->cdc = data->cdc; - printf_data(data);//打印该运动数据 + printf_data(data); //打印该运动数据 IsSpecialSport(sportdata->sportId); // 配置训练特殊性 } } @@ -731,7 +727,7 @@ void TraingModel::SetTimestamp() { Endstate = false; // 确保"开始"和"结束"状态互斥 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "开始运动"); - +#ifdef SYSTEM_LOG_SERVICE //日志记录 if (Openingway) { uapi_save_runtime_log(RUNTIME_LOG_APP_SPORT_LAUNCH); // app发起运动 @@ -743,7 +739,7 @@ void TraingModel::SetTimestamp() { } else { uapi_save_runtime_log(RUNTIME_LOG_SPORT_NORMAL_START); //普通运动 } - +#endif } else if (currentState == ExerciseState::End && !Endstate) { // 设置训练 runtime 为 0 训练结束 uapi_dev_runtime_set_train_status(0); @@ -777,15 +773,15 @@ void TraingModel::SetTimestamp() { #endif /*运动结束并且是手表发起的运动*/ if (Openingway == false) { - #ifdef BLE_SERVER_ENABLE +#ifdef BLE_SERVER_ENABLE sendtraningstateend(); - #endif +#endif } /*运动结束并且是app发起的运动*/ else { - #ifdef BLE_SERVER_ENABLE +#ifdef BLE_SERVER_ENABLE sendtraningstatedata(0, sportdata->duration); - #endif +#endif } WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "结束运动"); @@ -859,7 +855,7 @@ void TraingModel::RecordSportData() { if (MomentumFlag) { // GetGoaldegree(); // 设置目标完成度 if (SaveSportData()) { - TraingRecordModel::GetInstance().SetJsonStatus(true); + TraingRecordModel::GetInstance().SetJsonStatus(true); WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SaveSportData ok!"); } else { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SaveSportData error!"); @@ -2362,8 +2358,6 @@ bool TraingModel::LoadDataFormJson(std::vector &sportDataVector) { return true; } - - #ifdef BLE_INSTRUCT #include "bleEvent.h" @@ -2376,98 +2370,88 @@ extern "C" { #endif /* __cplusplus */ #endif /* __cplusplus */ -bool get_training_spead_path_(char *path ,uint32_t time,uint32_t max_len) -{ +bool get_training_spead_path_(char *path, uint32_t time, uint32_t max_len) { std::string str = OHOS::TraingModel::GetInstance()->GetPaceTablePath(time); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"get_training_spead:%s\r\n",str.c_str()); - if(str.length()<=3) - { - return false; - } - memcpy_s(path,max_len,str.c_str(),str.length()); - return true; - + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "get_training_spead:%s\r\n", + str.c_str()); + if (str.length() <= 3) { + return false; + } + memcpy_s(path, max_len, str.c_str(), str.length()); + return true; } - -bool get_training_heart_path_(char *path ,uint32_t time,uint32_t max_len) -{ +bool get_training_heart_path_(char *path, uint32_t time, uint32_t max_len) { std::string str = OHOS::TraingModel::GetInstance()->GetHeartTablePath(time); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"get_training_heart:%s\r\n",str.c_str()); - if(str.length()<=3) - { - return false; - } - memcpy_s(path,max_len,str.c_str(),str.length()); - return true; -} - -char * struct_to_json_buf_malloc_(uint8_t day) -{ - cJSON *dataJSON = cJSON_CreateObject(); - cJSON* data_arryJSON = cJSON_CreateArray(); - struct Trainingdata * data=NULL; - int i=0; - //char file_path[128] = {0}; - char timeday[12] = {0}; - uapi_get_YYMMDD_Time_extend(timeday, '_',day); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,"%s\r\n",timeday); - //sprintf(file_path, "%s%s.bin", TRAINING_PATH_BLE, timeday); - - while(data=read_Trainingdata_data(timeday, i)) - { - cJSON* itemJSON = cJSON_CreateObject(); - if(data!=NULL) - { - cJSON_AddNumberToObject(itemJSON,"src",data->src); - cJSON_AddNumberToObject(itemJSON,"bt",data->bt); - cJSON_AddNumberToObject(itemJSON,"ty",data->ty); - cJSON_AddNumberToObject(itemJSON,"st",data->st); - cJSON_AddNumberToObject(itemJSON,"sp",data->sp); - cJSON_AddNumberToObject(itemJSON,"tgt",data->tgt); - cJSON_AddNumberToObject(itemJSON,"tg",data->tg); - cJSON_AddNumberToObject(itemJSON,"pg",data->pg); - cJSON_AddNumberToObject(itemJSON,"du",data->du); - cJSON_AddNumberToObject(itemJSON,"ca",data->ca); - cJSON_AddNumberToObject(itemJSON,"di",data->di); - cJSON_AddNumberToObject(itemJSON,"hr",data->hr); - cJSON_AddNumberToObject(itemJSON,"stp",data->stp); - cJSON_AddNumberToObject(itemJSON,"ti",data->ti); - cJSON_AddNumberToObject(itemJSON,"cir",data->cir); - cJSON_AddNumberToObject(itemJSON,"alt",data->alt); - cJSON_AddNumberToObject(itemJSON,"apc",data->apc); - cJSON_AddNumberToObject(itemJSON,"fpc",data->fpc); - cJSON_AddNumberToObject(itemJSON,"spc",data->spc); - cJSON_AddNumberToObject(itemJSON,"std",data->std); - cJSON_AddNumberToObject(itemJSON,"cdc",data->cdc); - - cJSON_AddItemReferenceToArray(data_arryJSON,itemJSON); - free(data); - data=NULL; - } - else{ - break; - } - i++; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "get_training_heart:%s\r\n", + str.c_str()); + if (str.length() <= 3) { + return false; + } + memcpy_s(path, max_len, str.c_str(), str.length()); + return true; +} + +char *struct_to_json_buf_malloc_(uint8_t day) { + cJSON *dataJSON = cJSON_CreateObject(); + cJSON *data_arryJSON = cJSON_CreateArray(); + struct Trainingdata *data = NULL; + int i = 0; + // char file_path[128] = {0}; + char timeday[12] = {0}; + uapi_get_YYMMDD_Time_extend(timeday, '_', day); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "%s\r\n", timeday); + // sprintf(file_path, "%s%s.bin", TRAINING_PATH_BLE, timeday); + + while (data = read_Trainingdata_data(timeday, i)) { + cJSON *itemJSON = cJSON_CreateObject(); + if (data != NULL) { + cJSON_AddNumberToObject(itemJSON, "src", data->src); + cJSON_AddNumberToObject(itemJSON, "bt", data->bt); + cJSON_AddNumberToObject(itemJSON, "ty", data->ty); + cJSON_AddNumberToObject(itemJSON, "st", data->st); + cJSON_AddNumberToObject(itemJSON, "sp", data->sp); + cJSON_AddNumberToObject(itemJSON, "tgt", data->tgt); + cJSON_AddNumberToObject(itemJSON, "tg", data->tg); + cJSON_AddNumberToObject(itemJSON, "pg", data->pg); + cJSON_AddNumberToObject(itemJSON, "du", data->du); + cJSON_AddNumberToObject(itemJSON, "ca", data->ca); + cJSON_AddNumberToObject(itemJSON, "di", data->di); + cJSON_AddNumberToObject(itemJSON, "hr", data->hr); + cJSON_AddNumberToObject(itemJSON, "stp", data->stp); + cJSON_AddNumberToObject(itemJSON, "ti", data->ti); + cJSON_AddNumberToObject(itemJSON, "cir", data->cir); + cJSON_AddNumberToObject(itemJSON, "alt", data->alt); + cJSON_AddNumberToObject(itemJSON, "apc", data->apc); + cJSON_AddNumberToObject(itemJSON, "fpc", data->fpc); + cJSON_AddNumberToObject(itemJSON, "spc", data->spc); + cJSON_AddNumberToObject(itemJSON, "std", data->std); + cJSON_AddNumberToObject(itemJSON, "cdc", data->cdc); + + cJSON_AddItemReferenceToArray(data_arryJSON, itemJSON); + free(data); + data = NULL; + } else { + break; } - cJSON_AddItemToObject(dataJSON,"recs",data_arryJSON); + i++; + } + cJSON_AddItemToObject(dataJSON, "recs", data_arryJSON); - char *json_format = cJSON_PrintUnformatted(dataJSON); - - int pSize = cJSON_GetArraySize(dataJSON); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"训练历史数据:%s\r\n",json_format); - cJSON_Delete(dataJSON); - return json_format; -} + char *json_format = cJSON_PrintUnformatted(dataJSON); + int pSize = cJSON_GetArraySize(dataJSON); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "训练历史数据:%s\r\n", json_format); + cJSON_Delete(dataJSON); + return json_format; +} extern bleInstruct_t_ bleInstruct_t; -void ble_training_init(void) -{ - bleInstruct_t.get_training_spead_path_cb= get_training_spead_path_; - bleInstruct_t.get_training_heart_path_cb= get_training_heart_path_; - bleInstruct_t.struct_to_json_buf_malloc= struct_to_json_buf_malloc_; +void ble_training_init(void) { + bleInstruct_t.get_training_spead_path_cb = get_training_spead_path_; + bleInstruct_t.get_training_heart_path_cb = get_training_heart_path_; + bleInstruct_t.struct_to_json_buf_malloc = struct_to_json_buf_malloc_; } #ifdef __cplusplus diff --git a/code/sdk/application/wearable/fd230/service/msg_center/src/msg_center_customer.cpp b/code/sdk/application/wearable/fd230/service/msg_center/src/msg_center_customer.cpp index 5baf89a76..5890416a5 100644 --- a/code/sdk/application/wearable/fd230/service/msg_center/src/msg_center_customer.cpp +++ b/code/sdk/application/wearable/fd230/service/msg_center/src/msg_center_customer.cpp @@ -443,9 +443,9 @@ void MsgCenterNotifyChargePlugProc(const Topic topic, Request* req) { unused(req); WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "MsgCenterNotifyProc:: CHarger Plug !"); - +#ifdef SYSTEM_LOG_SERVICE uapi_save_runtime_log(RUNTIME_LOG_CHARGE_START);//充电开始事件 - +#endif const power_display_svr_api_t *display_api = power_display_svr_get_api(); if (display_api->get_screen_state() != SCREEN_ON) { @@ -489,9 +489,10 @@ void MsgCenterNotifyChargeUnPlugProc(const Topic topic, Request* req) unused(req); unused(topic); WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "MsgCenterNotifyProc:: CHarger UnPlug !"); +#ifdef SYSTEM_LOG_SERVICE //充电停止事件 uapi_save_runtime_log(RUNTIME_LOG_CHARGE_STOP);//TOOD* - +#endif if(PullUpDownView::GetInstance()) { GraphicService::GetInstance()->PostGraphicEvent(std::bind(&OHOS::PullUpDownView::UpdateBatteryProcess, OHOS::PullUpDownView::GetInstance() )); -- 2.17.1