From: SnickerSun Date: Tue, 19 Mar 2024 01:55:25 +0000 (+0800) Subject: 修复心率血氧佩戴消息错误问题,血氧还遗留提醒检测失败,后台仍然工作的bug X-Git-Tag: release_V1.2.70_20241020_135402~1293^2~7 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=3c4aff746e830468e51c43eee8427571ce8a879c;p=mirrors%2FFD230.git 修复心率血氧佩戴消息错误问题,血氧还遗留提醒检测失败,后台仍然工作的bug --- diff --git a/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodOxygenModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodOxygenModel.cpp index 0c185ef88..f426c36ea 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodOxygenModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodOxygenModel.cpp @@ -6,7 +6,7 @@ #include "health_service.h" #include "custom_utils.h" extern "C" errcode_t uapi_get_timestamp_ms(uint64_t *tm); - +#define MAX_UNWARE_COUNT 30 namespace OHOS { /** @@ -126,17 +126,21 @@ namespace OHOS */ void BloodOxygenModel::SetWearStatus(int32_t wear) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Weartest::%d", wear); - wear_ = wear; - if (wear_ != 1) + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodOxygenModel Weartest::%d", wear); + + if (wear_ != 1 && wear != 1) { wear_error++; - if (wear_error >= 10) + if (wear_error >= MAX_UNWARE_COUNT) { WearStatus = false; } + }else{ + wear_error = 0; + WearStatus = true; } - WearStatus = true; + wear_ = wear; + } /** diff --git a/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodOxygenPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodOxygenPresenter.cpp index d90a60c41..3348fe8aa 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodOxygenPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodOxygenPresenter.cpp @@ -216,6 +216,21 @@ namespace OHOS } void BloodOxygenPresenter::ProgressNotify(void) { + + // 当检测状态为结束检测,结束检测 + if (BloodOxygenModel::GetInstance()->GetCheckStatus() == false) + { + if (startspo2 == false) + { + uint8_t md = PPG_SERVICE_CMD_TYPE_STOP_SPO2_TEST; + send_ppg_cmd_msg(md); + startspo2 = true; + BloodOxygenModel::GetInstance()->StopTest(); + } + } + + if (BloodOxygenModel::GetInstance()->GetBloodCheckViewStatus() == false) + return ; // 当检测状态为开始检测,开始检测 if (BloodOxygenModel::GetInstance()->GetCheckStatus() == true) { @@ -229,19 +244,8 @@ namespace OHOS } } - // 当检测状态为结束检测,结束检测 - if (BloodOxygenModel::GetInstance()->GetCheckStatus() == false) - { - BloodOxygenView::GetInstance()->Upspo2data(); // 更新主界面 - if (startspo2 == false) - { - uint8_t md = PPG_SERVICE_CMD_TYPE_STOP_SPO2_TEST; - send_ppg_cmd_msg(md); - startspo2 = true; - BloodOxygenModel::GetInstance()->StopTest(); - } - } + // 长时间未佩戴,则停止检测 if (BloodOxygenModel::GetInstance()->GetWearStatus() == false) { BloodOxygenView::GetInstance()->ChangeView(BLOODCHECKVIEW, BLOODRESULT); @@ -280,6 +284,7 @@ namespace OHOS else { BloodOxygenView::GetInstance()->ChangeView(BLOODCHECKVIEW, BLOODVIEW); + BloodOxygenView::GetInstance()->Upspo2data(); // 更新主界面 } BloodOxygenModel::GetInstance()->SetCheckStatus(false); // 关闭检测 BloodOxygenModel::GetInstance()->SetBloodCheckViewStatus(false); 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 d9a6e698c..9ae55a0b1 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 @@ -44,6 +44,7 @@ namespace OHOS cJSON *latestData = cJSON_GetObjectItem(root, "spo2_latest_data"); data->SPO2 = cJSON_GetObjectItem(latestData, "oxygen_value")->valueint; data->timestamp = cJSON_GetObjectItem(latestData, "timestamp")->valuedouble; + cJSON_Delete(root); return data; } @@ -70,8 +71,10 @@ namespace OHOS if (UpdateJsonData() == false) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "UpdateJsonData is error"); + cJSON_Delete(root); return false; } + cJSON_Delete(root); return true; } HeartRateData *HeartService::ReadHeartRateData() @@ -81,6 +84,7 @@ namespace OHOS cJSON *latestData = cJSON_GetObjectItem(root, "heart_latest_data"); data->Heart = cJSON_GetObjectItem(latestData, "heart_value")->valueint; data->timestamp = cJSON_GetObjectItem(latestData, "timestamp")->valuedouble; + cJSON_Delete(root); return data; } @@ -107,8 +111,10 @@ namespace OHOS if (UpdateJsonData() == false) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "UpdateJsonData is error"); + cJSON_Delete(root); return false; } + cJSON_Delete(root); return true; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/heartrate/include/HeartModel.h b/code/sdk/application/wearable/fd230app/nativeui/heartrate/include/HeartModel.h index 64dd9fdc7..d24ef9d2e 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/heartrate/include/HeartModel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/heartrate/include/HeartModel.h @@ -144,7 +144,7 @@ extern "C" uint16_t preMinX{NUM_1}; uint16_t countMax{0}; uint16_t countMin{0}; - bool wearStatus{false}; + bool wearStatus{true}; uint16_t index_ = 0; bool HeartView; @@ -157,10 +157,9 @@ extern "C" uint64 TIME_; // 检测时间(存(时、分),大于24小时,改为1天前,小于1分钟为刚刚) bool initstatus = true; - bool wearstatus; uint8_t wear_; uint8_t valid_counter_ = 0;//有效数计数器 - uint8_t wear_counter_ = 0;//佩戴错误计数器 + uint8_t unwear_counter_ = 0;//佩戴错误计数器 }; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartModel.cpp index 491264c4a..97bda4ef6 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartModel.cpp @@ -19,6 +19,8 @@ extern "C" { #endif +#define MAX_UNWEAR_COUNT 30 +#define MAX_VALID_HRS_COUNT 30 /* 佩戴检测结果 */ enum { @@ -138,16 +140,16 @@ extern "C" uint32 wearStatus = *((uint32 *)request->data); if (wearStatus == SENSOR_WEAR_OFF) { - OHOS::HeartModel::GetInstance()->SetWearStatus(false); - OHOS::HeartModel::GetInstance()->SetHeartRatePerSec(0); - if (OHOS::MainClockView::GetInstance() != nullptr) - { + // OHOS::HeartModel::GetInstance()->SetWearStatus(false); + // OHOS::HeartModel::GetInstance()->SetHeartRatePerSec(0); + // if (OHOS::MainClockView::GetInstance() != nullptr) + // { // OHOS::MainClockView::GetInstance()->RefreshHeartRate(*(uint16_t *)request->data); - } + // } } else { - OHOS::HeartModel::GetInstance()->SetWearStatus(true); + // OHOS::HeartModel::GetInstance()->SetWearStatus(true); } } } @@ -481,21 +483,26 @@ namespace OHOS void HeartModel::Heart_Stop() { valid_counter_ = 0; - wear_counter_ = 0; + unwear_counter_ = 0; SetCheckStatus(false); - SetWearStatus(true); + SetWearStatus(1); } void HeartModel::SetWearStatus(uint8_t wear) { // 设置佩戴状态 - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Weartest::%d", wear); - wear_ = wear_; - if (wear_ != 1) + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "HeartModel Weartest::%d", wear); + if (wear_ != 1 && wear !=1) { - wear_counter_++; // 佩戴错误计时器计数 + unwear_counter_++; // 佩戴错误计时器计数 + }else{ + unwear_counter_ = 0; } - if (wear_counter_ >= 10) + + wear_ = wear; + + + if (unwear_counter_ >= MAX_UNWEAR_COUNT) { wearStatus = false; // 计数达到10次,停止检测 } @@ -593,7 +600,7 @@ namespace OHOS valid_counter_ = 0; // 清零有效计数器 } - if (valid_counter_ >= 10) + if (valid_counter_ >= MAX_VALID_HRS_COUNT) { // 结束本次测试,将最后一次有效数作为本次测量结果 Heart_Stop(); @@ -604,6 +611,7 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%d %lld", heart, data->timestamp); SetCheckTime(data->timestamp); HeartService::GetInstance()->UpdateHeartRateData(*data); + /* -------------------------------------------------------------------------- */ } } diff --git a/code/sdk/drivers/peripheral/ppg/hx3695/hx3695.c b/code/sdk/drivers/peripheral/ppg/hx3695/hx3695.c index cad40dd96..2a67dee49 100644 --- a/code/sdk/drivers/peripheral/ppg/hx3695/hx3695.c +++ b/code/sdk/drivers/peripheral/ppg/hx3695/hx3695.c @@ -2700,7 +2700,7 @@ void hx3695_hrs_ppg_Int_handle(void) if(func != NULL) { hrsresult.wearstatus = hrs_wear_status; - func(HX3695_MSG_TYPE_WEARSTAT_UPDATE,&hrsresult.wearstatus,sizeof(int32_t)); + func(HX3695_MSG_TYPE_WEARSTAT_UPDATE,&hrsresult,sizeof(FT_CUSTOM_RESULTS_t)); func(HX3695_MSG_TYPE_HRS_UPDATE,&hrsresult,sizeof(FT_CUSTOM_RESULTS_t)); } //////////////////////////////////////////////////////////////////////////////////// @@ -3000,7 +3000,7 @@ void hx3695_spo2_ppg_Int_handle(void) hx3695_msg_callback_t func = hx3695_get_send_msg_callback_func(); if(func != NULL) { - func(HX3695_MSG_TYPE_WEARSTAT_UPDATE,&hrsresult.wearstatus,sizeof(spo2_wear_status)); + func(HX3695_MSG_TYPE_WEARSTAT_UPDATE,&hrsresult,sizeof(FT_CUSTOM_RESULTS_t)); func(HX3695_MSG_TYPE_SPO2_UPDATE,&hrsresult,sizeof(FT_CUSTOM_RESULTS_t)); }