From: Caisking <3449750381@qq.com> Date: Tue, 12 Mar 2024 02:46:22 +0000 (+0800) Subject: 搭建心率存储以及检测监控流程 X-Git-Tag: release_V1.2.70_20241020_135402~1274^2~24 X-Git-Url: http://git.snicker.com.cn/Users/apple/Desktop/static/gitweb.css?a=commitdiff_plain;h=5d84bd31fb2300725ae70c02739dcd0350ea3a33;p=mirrors%2FFD230.git 搭建心率存储以及检测监控流程 --- diff --git a/code/sdk/application/wearable/fd230app/CMakeLists.txt b/code/sdk/application/wearable/fd230app/CMakeLists.txt index 761d9657d..8176c3420 100644 --- a/code/sdk/application/wearable/fd230app/CMakeLists.txt +++ b/code/sdk/application/wearable/fd230app/CMakeLists.txt @@ -42,6 +42,7 @@ set(PRIVATE_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/UIInitializer/ ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/InitComponent/include ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/uisample/uitest/framework/include + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/heart_blood/health_service/ ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/alipay/include ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/alipay/include/AlipayList @@ -243,6 +244,7 @@ set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/screennotify/src/ui_screennotify.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/heart_blood/src/BloodCardView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/heart_blood/src/HeartCardView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/heart_blood/health_service/health_service.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TraingView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/language/LanguageInit.cpp diff --git a/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/include/BloodOxygenModel.h b/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/include/BloodOxygenModel.h index c2dee4806..24f3f49ee 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/include/BloodOxygenModel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/include/BloodOxygenModel.h @@ -28,23 +28,32 @@ namespace OHOS bool GetCheckStatus(); void SetCheckStatus(bool checkstatus); + void UpSPO2data(uint16_t spo2); uint16_t GetSPO2data(); uint16_t GetShowSPO2data(); uint16_t GetCheckTime(); // 获取距离上传测试时间 void SetCheckTime(uint16_t time); // 设置本次测试完的时间 - + void StartTest(); // 开始检测 + void SetWearStatus(int32_t wear); // 佩戴检测 + bool GetWearStatus(void); + bool StopTest(); // 结束检测 private: BloodOxygenModel(); bool OxygenView; bool BandoffView; bool CheckView; bool ResultView; - bool CheckStatus; // 检测状态标志 - uint16_t Show_SPO2_; // 显示血氧 - uint16_t SPO2_; // 保存血氧 - uint16_t TIME_; // 检测时间(存(时、分),大于24小时,改为1天前,小于1分钟为刚刚) - bool initstatus = true; + bool CheckStatus; // 检测状态标志 + bool WearStatus; // 佩戴状态 + uint16_t Show_SPO2_; // 显示血氧 + uint16_t SPO2_; // 保存血氧 + uint64_t timestamp_ms; // 时间戳 + int32_t wear_; // 佩戴状态 + + uint8_t wear_error = 0; // 佩戴错误计数器 + uint8_t spo2_count = 0; // 有效血氧结果计数器 + bool initstatus = true; }; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/include/BloodOxygenPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/include/BloodOxygenPresenter.h index 4ea4da9bd..4a88c2ded 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/include/BloodOxygenPresenter.h +++ b/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/include/BloodOxygenPresenter.h @@ -1,3 +1,4 @@ + /* * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. * Description: bloodOxygen view @@ -49,8 +50,8 @@ namespace OHOS bool OnClick(UIView &view, const ClickEvent &event) override; bool OnKeyAct(UIView &view, const KeyEvent &event) override; // 增加按键事件 - uint16_t GetCurrentTime(); - std::string GetTDOA(uint16_t new_time, uint16_t old_time); + uint64_t GetCurrentTime(); + std::string GetTDOA(uint64_t new_time, uint64_t old_time); private: bool CheckPointersValue(void); 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 198257f03..0c185ef88 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodOxygenModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodOxygenModel.cpp @@ -2,33 +2,88 @@ #include "DialModelSPO2.h" #include "wearable_log.h" #include "BloodOxygenPresenter.h" +#include "wearable_log.h" +#include "health_service.h" +#include "custom_utils.h" +extern "C" errcode_t uapi_get_timestamp_ms(uint64_t *tm); namespace OHOS { - BloodOxygenModel::BloodOxygenModel() : OxygenView(false), BandoffView(false), CheckView(false), ResultView(false), CheckStatus(false), SPO2_(DialModelSPO2::GetInstance()->GetSPO2Data()) + /** + * @brief Constructor for the BloodOxygenModel class. + */ + BloodOxygenModel::BloodOxygenModel() : OxygenView(false), BandoffView(false), CheckView(false), ResultView(false), CheckStatus(false), WearStatus(true) { + BloodOxygenData *data = new BloodOxygenData; + data = HeartService::GetInstance()->ReadBloodOxygenData(); + SPO2_ = data->SPO2; + timestamp_ms = data->timestamp; } + /** + * @brief Get the status of the BloodOxygenView. + * @return The status of the BloodOxygenView. + */ bool BloodOxygenModel::GetBloodOxygenViewStatus() { return OxygenView; } + /** + * @brief Get the status of the BandoffView. + * @return The status of the BandoffView. + */ bool BloodOxygenModel::GetBloodBandoffViewStatus() { return BandoffView; } + /** + * @brief Get the status of the CheckView. + * @return The status of the CheckView. + */ bool BloodOxygenModel::GetBloodCheckViewStatus() { return CheckView; } + /** + * @brief Set the status of the BandoffView. + * @param bandoffViewStatus The status to set. + */ void BloodOxygenModel::SetBloodBandoffViewStatus(bool bandoffViewStatus) { BandoffView = bandoffViewStatus; } + /** + * @brief Set the status of the BloodOxygenView. + * @param oxygenViewStatus The status to set. + */ void BloodOxygenModel::SetBloodOxygenViewStatus(bool oxygenViewStatus) { OxygenView = oxygenViewStatus; } + /** + * @brief Set the status of the CheckView. + * @param checkViewStatus The status to set. + */ void BloodOxygenModel::SetBloodCheckViewStatus(bool checkViewStatus) { CheckView = checkViewStatus; } + /** + * @brief Get the CheckStatus. + * @return The CheckStatus. + */ bool BloodOxygenModel::GetCheckStatus() { return CheckStatus; } + /** + * @brief Set the CheckStatus. + * @param checkstatus The status to set. + */ void BloodOxygenModel::SetCheckStatus(bool checkstatus) { CheckStatus = checkstatus; } + /** + * @brief Get the SPO2 data. + * @return The SPO2 data. + */ uint16_t BloodOxygenModel::GetSPO2data() { return SPO2_; } + /** + * @brief Get the Show SPO2 data. + * @return The Show SPO2 data. + */ uint16_t BloodOxygenModel::GetShowSPO2data() { return Show_SPO2_; } + /** + * @brief Update the SPO2 data. + * @param spo2 The SPO2 value to update. + */ void BloodOxygenModel::UpSPO2data(uint16_t spo2) { Show_SPO2_ = spo2; @@ -38,18 +93,72 @@ namespace OHOS } } + /** + * @brief Get the timestamp of the last check. + * @return The timestamp of the last check. + */ uint16_t BloodOxygenModel::GetCheckTime() { - if (initstatus) + return timestamp_ms; + } + + /** + * @brief Set the timestamp of the last check. + * @param time The timestamp to set. + */ + void BloodOxygenModel::SetCheckTime(uint16_t time) + { + timestamp_ms = time; + } + + /** + * @brief Start the blood oxygen test. + */ + void BloodOxygenModel::StartTest() + { + wear_error = 0; + spo2_count = 0; + } + + /** + * @brief Set the wear status. + * @param wear The wear status to set. + */ + void BloodOxygenModel::SetWearStatus(int32_t wear) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Weartest::%d", wear); + wear_ = wear; + if (wear_ != 1) { - TIME_ = BloodOxygenPresenter::GetInstance()->GetCurrentTime(); - initstatus = false; + wear_error++; + if (wear_error >= 10) + { + WearStatus = false; + } } - return TIME_; + WearStatus = true; } - void BloodOxygenModel::SetCheckTime(uint16_t time) { TIME_ = time; } + /** + * @brief Get the wear status. + * @return The wear status. + */ + bool BloodOxygenModel::GetWearStatus() { return WearStatus; } + + /** + * @brief Stop the blood oxygen test. + * @return The status of stopping the test. + */ + bool BloodOxygenModel::StopTest() + { + wear_error = 0; + spo2_count = 0; + } + /** + * @brief Get an instance of the BloodOxygenModel. + * @return An instance of the BloodOxygenModel. + */ BloodOxygenModel *BloodOxygenModel::GetInstance() { static BloodOxygenModel instance; 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 b635c66ba..d90a60c41 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodOxygenPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodOxygenPresenter.cpp @@ -30,6 +30,8 @@ #include "ppg_service.h" #include "displaybrightness/include/DisplayBrightnessModel.h" #include "power_display_service.h" +#include "custom_utils.h" +extern "C" errcode_t uapi_get_timestampe_ms(uint64_t *tm); #define BLOODKEYABLE 0 namespace OHOS @@ -41,16 +43,14 @@ namespace OHOS static constexpr uint16_t PROGRESS_VALUE_MAX = 10; /* -------------------------------------------------------------------------- */ // 获取当前的"时间分" - uint16_t BloodOxygenPresenter::GetCurrentTime() + uint64_t BloodOxygenPresenter::GetCurrentTime() { - time_t now = time(0); - struct tm *tblock = localtime(&now); - - uint16_t current_time = tblock->tm_hour * 60 + tblock->tm_min; - return current_time; + uint64_t timestamp_ms; + errcode_t result = uapi_get_timestampe_ms(×tamp_ms); + return timestamp_ms; } - // 获取时间差 - std::string BloodOxygenPresenter::GetTDOA(uint16_t new_time, uint16_t old_time) + // 获取时间差,现在传进来的是两个时间戳 + std::string BloodOxygenPresenter::GetTDOA(uint64_t new_time, uint64_t old_time) { if (new_time == old_time) { @@ -58,25 +58,26 @@ namespace OHOS } int time_diff = new_time - old_time; - if (time_diff > 60) + int hours = time_diff / 3600000; // 将毫秒转换为小时 + int minutes = (time_diff % 3600000) / 60000; // 将剩余的毫秒转换为分钟 + + std::stringstream ss; + if (hours > 0) { - int hours = time_diff / 60; - int minutes = time_diff % 60; - std::stringstream ss; ss << hours << "小时"; - if (minutes > 0) - { - ss << minutes << "分钟"; - } - return ss.str() + "前"; } - else + if (minutes > 0) + { + ss << minutes << "分钟"; + } + if (hours == 0 && minutes == 0) { - std::stringstream ss; - ss << time_diff << "分钟前"; - return ss.str(); + ss << "不到1分钟"; } + ss << "前"; + return ss.str(); } + /* -------------------------------------------------------------------------- */ BloodOxygenPresenter::BloodOxygenPresenter() { @@ -224,6 +225,7 @@ namespace OHOS uint8_t md = PPG_SERVICE_CMD_TYPE_DO_SPO2_TEST; send_ppg_cmd_msg(md); startspo2 = false; + BloodOxygenModel::GetInstance()->StartTest(); } } @@ -236,8 +238,16 @@ namespace OHOS 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); + BloodOxygenModel::GetInstance()->SetCheckStatus(false); // 关闭检测 + BloodOxygenModel::GetInstance()->SetBloodCheckViewStatus(false); + } } void BloodOxygenPresenter::ReturnInterface() @@ -273,9 +283,9 @@ namespace OHOS } BloodOxygenModel::GetInstance()->SetCheckStatus(false); // 关闭检测 BloodOxygenModel::GetInstance()->SetBloodCheckViewStatus(false); + uint64_t timestamp_ms = GetCurrentTime(); + BloodOxygenModel::GetInstance()->SetCheckTime(timestamp_ms); // 更新时间 } - uint16_t time = GetCurrentTime(); - BloodOxygenModel::GetInstance()->SetCheckTime(time); // 更新时间 } } void BloodOxygenPresenter::Notify(void) diff --git a/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodOxygenView.cpp b/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodOxygenView.cpp index 0ec393d28..5c0f1eaf5 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodOxygenView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodOxygenView.cpp @@ -81,16 +81,16 @@ namespace OHOS // 更新数据 std::string bloodoxygenStr = std::to_string(spo2_); percent->SetText(bloodoxygenStr.c_str()); - // 更新时间 - uint16_t time = BloodOxygenPresenter::GetInstance()->GetCurrentTime(); - uint16_t check_time = BloodOxygenModel::GetInstance()->GetCheckTime(); - std::string TimeStr = BloodOxygenPresenter::GetInstance()->GetTDOA(time, check_time) + "检测"; - timeLabel->SetText(TimeStr.c_str()); } else { percent->SetText("--"); - timeLabel->SetText("暂无检测结果"); + // 更新时间 + uint32_t time = BloodOxygenPresenter::GetInstance()->GetCurrentTime(); + uint32_t check_time = BloodOxygenModel::GetInstance()->GetCheckTime(); + std::string TimeStr = BloodOxygenPresenter::GetInstance()->GetTDOA(time, check_time) + "检测"; + timeLabel->SetText(TimeStr.c_str()); + // timeLabel->SetText("暂无检测结果"); } } @@ -114,15 +114,16 @@ namespace OHOS { std::string bloodoxygenStr = std::to_string(spo2_); percent->SetText(bloodoxygenStr.c_str()); - // 更新时间 - uint16_t time = BloodOxygenPresenter::GetInstance()->GetCurrentTime(); - uint16_t check_time = BloodOxygenModel::GetInstance()->GetCheckTime(); - TimeStr = BloodOxygenPresenter::GetInstance()->GetTDOA(time, check_time); } else { percent->SetText("--"); - TimeStr = "暂无测量数据"; + // 更新时间 + uint64_t time = BloodOxygenPresenter::GetInstance()->GetCurrentTime(); + uint64_t check_time = BloodOxygenModel::GetInstance()->GetCheckTime(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "time:%lld check_time:%lld", time, check_time); + TimeStr = BloodOxygenPresenter::GetInstance()->GetTDOA(time, check_time); + // TimeStr = "暂无测量数据"; } percent->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS); percent->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); diff --git a/code/sdk/application/wearable/fd230app/nativeui/heart_blood/health_service/defult_health.json b/code/sdk/application/wearable/fd230app/nativeui/heart_blood/health_service/defult_health.json new file mode 100644 index 000000000..50b82dbb8 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/heart_blood/health_service/defult_health.json @@ -0,0 +1,46 @@ +{ + "spo2_latest_data": { + "oxygen_value": 98, + "timestamp": 1646769855 + }, + "spo2_data_list": [ + { + "oxygen_value": 95, + "timestamp": 1646769823 + }, + { + "oxygen_value": 97, + "timestamp": 1646769844 + }, + { + "oxygen_value": 96, + "timestamp": 1646769849 + }, + { + "oxygen_value": 98, + "timestamp": 1646769855 + } + ], + "heart_latest_data": { + "heart_value": 88, + "timestamp": 1646769855 + }, + "heart_data_list": [ + { + "heart_value": 95, + "timestamp": 1646769823 + }, + { + "heart_value": 57, + "timestamp": 1646769844 + }, + { + "heart_value": 86, + "timestamp": 1646769849 + }, + { + "heart_value": 88, + "timestamp": 1646769855 + } + ] +} \ No newline at end of file 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 new file mode 100644 index 000000000..d9a6e698c --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/heart_blood/health_service/health_service.cpp @@ -0,0 +1,133 @@ +#include "health_service.h" +#include +#include +#include "wearable_log.h" +#include "cJSON.h" +namespace OHOS +{ + static HeartService *g_pHeartService = nullptr; + cJSON *root = NULL; + HeartService::HeartService() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "HeartService::HeartService"); + g_pHeartService = this; + } + + HeartService::~HeartService() + { + g_pHeartService = nullptr; + } + + HeartService *HeartService::GetInstance() + { + static HeartService instance; + return &instance; + } + + bool HeartService::LoadJsonData() + { + std::ifstream inFile(HEALTH_JSON_PATH); + if (!inFile.is_open()) + { + return -1; + } + std::string jsonDataString((std::istreambuf_iterator(inFile)), std::istreambuf_iterator()); + const char *jsonData = jsonDataString.c_str(); + root = cJSON_Parse(jsonData); + return true; + } + + BloodOxygenData *HeartService::ReadBloodOxygenData() + { + LoadJsonData(); + BloodOxygenData *data = new BloodOxygenData(); + cJSON *latestData = cJSON_GetObjectItem(root, "spo2_latest_data"); + data->SPO2 = cJSON_GetObjectItem(latestData, "oxygen_value")->valueint; + data->timestamp = cJSON_GetObjectItem(latestData, "timestamp")->valuedouble; + return data; + } + + bool HeartService::UpdateBloodOxygenData(const BloodOxygenData &data) + { + LoadJsonData(); + cJSON *latestData = cJSON_GetObjectItem(root, "spo2_latest_data"); + if (latestData == NULL) + { + return false; + } + cJSON_ReplaceItemInObject(latestData, "oxygen_value", cJSON_CreateNumber(data.SPO2)); + cJSON_ReplaceItemInObject(latestData, "timestamp", cJSON_CreateNumber(data.timestamp)); + + // 将数据添加到列表的最后 + cJSON *dataList = cJSON_GetObjectItem(root, "spo2_data_list"); + if (dataList != NULL && cJSON_IsArray(dataList)) + { + cJSON *newData = cJSON_CreateObject(); + cJSON_AddItemToObject(newData, "oxygen_value", cJSON_CreateNumber(data.SPO2)); + cJSON_AddItemToObject(newData, "timestamp", cJSON_CreateNumber(data.timestamp)); + cJSON_AddItemToArray(dataList, newData); + } + if (UpdateJsonData() == false) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "UpdateJsonData is error"); + return false; + } + return true; + } + HeartRateData *HeartService::ReadHeartRateData() + { + LoadJsonData(); + HeartRateData *data = new HeartRateData(); + cJSON *latestData = cJSON_GetObjectItem(root, "heart_latest_data"); + data->Heart = cJSON_GetObjectItem(latestData, "heart_value")->valueint; + data->timestamp = cJSON_GetObjectItem(latestData, "timestamp")->valuedouble; + return data; + } + + bool HeartService::UpdateHeartRateData(const HeartRateData &data) + { + LoadJsonData(); + cJSON *latestData = cJSON_GetObjectItem(root, "heart_latest_data"); + if (latestData == NULL) + { + return false; + } + cJSON_ReplaceItemInObject(latestData, "heart_value", cJSON_CreateNumber(data.Heart)); + cJSON_ReplaceItemInObject(latestData, "timestamp", cJSON_CreateNumber(data.timestamp)); + + // 将数据添加到列表的最后 + cJSON *dataList = cJSON_GetObjectItem(root, "heart_data_list"); + if (dataList != NULL && cJSON_IsArray(dataList)) + { + cJSON *newData = cJSON_CreateObject(); + cJSON_AddItemToObject(newData, "heart_value", cJSON_CreateNumber(data.Heart)); + cJSON_AddItemToObject(newData, "timestamp", cJSON_CreateNumber(data.timestamp)); + cJSON_AddItemToArray(dataList, newData); + } + if (UpdateJsonData() == false) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "UpdateJsonData is error"); + return false; + } + return true; + } + + bool HeartService::UpdateJsonData() + { + std::ofstream outFile(HEALTH_JSON_PATH); + if (!outFile.is_open()) + { + return false; + } + char *jsonData = cJSON_Print(root); + if (jsonData == NULL) + { + outFile.close(); + return false; + } + outFile << jsonData; + outFile.close(); + cJSON_free(jsonData); + return true; + } +} \ No newline at end of file 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 new file mode 100644 index 000000000..cbbe4a38a --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/heart_blood/health_service/health_service.h @@ -0,0 +1,56 @@ +#ifndef HEART_SERVICE_H +#define HEART_SERVICE_H + +#include "stdio.h" +#include "string" + +#define HEART_MAX_POINTS 360 +namespace OHOS +{ + typedef struct + { + uint16_t SPO2; // 血氧值 + uint64_t timestamp; // 最近一次检测时间 + } BloodOxygenData; + + typedef struct + { + uint16_t index; // x + uint16_t value; // y + } HeartPoints; + + typedef struct + { + uint16_t perSec; // 每秒心率 + uint16_t rest; // 静息心率 + uint16_t minX; // 最小心率点 + uint16_t minValue; // 最小心率 + uint16_t maxX; // 最大心率点 + uint16_t maxValue; // 最大心率 + uint16_t index; // 最近一次测量的点位值,每次遍历数组到这里 + HeartPoints heartvalue[HEART_MAX_POINTS]; // 心率点 + } HeartData; + + typedef struct + { + uint16_t Heart; // 心率值 + uint64_t timestamp; // 最近一次检测时间 + } HeartRateData; + + class HeartService + { + public: + HeartService(); + ~HeartService(); + static HeartService *GetInstance(void); + bool LoadJsonData(); // 加载json + BloodOxygenData *ReadBloodOxygenData(); // 读取血氧数据 + bool UpdateBloodOxygenData(const BloodOxygenData &data); // 更新血氧数据 + HeartRateData *ReadHeartRateData(); // 读取心率数据 + bool UpdateHeartRateData(const HeartRateData &data); // 更新心率数据 + bool UpdateJsonData(); // 更新json + private: + static constexpr const char *HEALTH_JSON_PATH = "/user/userdata/health.json"; + }; +} +#endif // HEALTH_MODEL_H \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/heart_blood/src/BloodCardView.cpp b/code/sdk/application/wearable/fd230app/nativeui/heart_blood/src/BloodCardView.cpp index c2be257cd..b0ea244c4 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/heart_blood/src/BloodCardView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/heart_blood/src/BloodCardView.cpp @@ -93,8 +93,8 @@ namespace OHOS if (bloodoxygen != 0) { // 更新时间 - uint16_t time = BloodOxygenPresenter::GetInstance()->GetCurrentTime(); - uint16_t check_time = BloodOxygenModel::GetInstance()->GetCheckTime(); + uint64_t time = BloodOxygenPresenter::GetInstance()->GetCurrentTime(); + uint64_t check_time = BloodOxygenModel::GetInstance()->GetCheckTime(); std::string TimeStr = BloodOxygenPresenter::GetInstance()->GetTDOA(time, check_time) + "检测"; timeLabel->SetText(TimeStr.c_str()); } 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 246d0476b..a6f1174b3 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/heartrate/include/HeartModel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/heartrate/include/HeartModel.h @@ -104,8 +104,6 @@ extern "C" void HandleMaxHeart(uint16_t coord, uint16_t value); void HandleMinHeart(uint16_t coord, uint16_t value); void SetHeartRatePerSec(uint32_t sec); - void SetWearStatus(bool status); - bool GetWearStatus(void); uint16_t GetHeartRateMax(void); uint16_t GetHeartRateMin(void); @@ -121,12 +119,17 @@ extern "C" bool GetCheckStatus(); void SetCheckStatus(bool checkstatus); + void SetWearStatus(uint8_t wear); + bool GetWearStatus(void); + + void Heart_Start(); + void Heart_Stop(); void UpHeartdata(uint16_t heart); uint16_t GetHeartdata(); uint16_t GetShowHeartdata(); - uint16_t GetCheckTime(); // 获取距离上传测试时间 - void SetCheckTime(uint16_t time); // 设置本次测试完的时间 + uint64_t GetCheckTime(); // 获取距离上传测试时间 + void SetCheckTime(uint64_t time); // 设置本次测试完的时间 uint16_t GetIndex(); // 测试点位 void SetIndex(uint16_t index); @@ -151,9 +154,13 @@ extern "C" bool CheckStatus; // 检测状态标志 uint16_t Show_Heart_; // 显示血氧 uint16_t Heart_; // 保存血氧 - uint16_t TIME_; // 检测时间(存(时、分),大于24小时,改为1天前,小于1分钟为刚刚) + uint64 TIME_; // 检测时间(存(时、分),大于24小时,改为1天前,小于1分钟为刚刚) bool initstatus = true; + bool wearstatus; + uint8_t wear_; + uint64 timestamp_ms; + uint8_t wear_error; }; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/heartrate/include/HeartView.h b/code/sdk/application/wearable/fd230app/nativeui/heartrate/include/HeartView.h index 59bf6e80e..947438acf 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/heartrate/include/HeartView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/heartrate/include/HeartView.h @@ -49,6 +49,7 @@ namespace OHOS void ChangeView(int16_t hideView, int16_t showView); UIScrollView *GetHeartScrollView(int ViewId); void UpHeartText(); // 更新心率结果文本 + private: bool InitImageDisplay(void); // 初始化背景图片 bool InitLabel(void); // 初始化标签 diff --git a/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartCheckView.cpp b/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartCheckView.cpp index 3f44ae496..d310eac87 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartCheckView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartCheckView.cpp @@ -119,7 +119,7 @@ namespace OHOS return nullptr; } imageAnimator->SetImageAnimatorSrc(g_imageAnimatorInfo_Time, CHECKIMAGEANIMATORVIEW_SIZE, CHECKIMAGEANIMATORVIEW_SPEED); - imageAnimator->SetRepeatTimes(20); + imageAnimator->SetRepeatTimes(30); imageAnimator->SetRepeat(false); imageAnimator->Start(); HeartCheckScrollView->Add(imageAnimator); @@ -153,8 +153,8 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "HeartView::new HeartText fail"); return nullptr; } - HeartText->SetPosition(133, 110); // widget's left position and top position - HeartText->Resize(200, 200); // widget's width and height + HeartText->SetPosition(83, 110); // widget's left position and top position + HeartText->Resize(300, 250); // widget's width and height HeartText->SetViewId("label"); // Set style HeartText->SetStyle(STYLE_TEXT_FONT, 140); uint16_t heart_ = HeartModel::GetInstance()->GetHeartdata(); 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 fe9bc7c7f..5bc380a3b 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartModel.cpp @@ -1,15 +1,19 @@ -#include "HeartModel.h" +#include "heartrate/include/HeartModel.h" #include "wearable_log.h" #include "graphic_service.h" #include "IndoorWalkPreparedView.h" #include "IndoorWalkPresenter.h" #include "MainViewSample.h" -#include "HeartRateView.h" +#include "heartrate/include/HeartRateView.h" #include #include #include "heartrate/include/HeartView.h" #include "heartrate/include/HeartPresenter.h" #include "DialModelHeartRate.h" +#include "health_service.h" +#include "custom_utils.h" + +extern "C" errcode_t uapi_get_timestampe_ms(uint64_t *tm); #ifdef __cplusplus extern "C" { @@ -192,7 +196,10 @@ namespace OHOS ResultView = false; CheckStatus = false; // 初始化血氧值 - Heart_ = DialModelHeartRate::GetInstance()->GetHeartData(); + HeartRateData *data = new HeartRateData; + data = HeartService::GetInstance()->ReadHeartRateData(); + Heart_ = data->Heart; + TIME_ = data->timestamp; } HeartModel::~HeartModel() @@ -427,16 +434,6 @@ namespace OHOS aveCount = value; } - void HeartModel::SetWearStatus(bool status) - { - wearStatus = status; - } - - bool HeartModel::GetWearStatus(void) - { - return wearStatus; - } - void HeartModel::RefreshHeartRateScreen(uint16_t perSec, uint16_t rest, uint16_t maxRate, uint16_t minRate) { UNUSED(rest); @@ -472,66 +469,144 @@ namespace OHOS } } } - bool HeartModel::GetHeartViewStatus() - { - return HeartView; - } - - bool HeartModel::GetHeartBandoffViewStatus() - { - return BandoffView; - } - - bool HeartModel::GetHeartCheckViewStatus() - { - return CheckView; - } - - void HeartModel::SetHeartBandoffViewStatus(bool bandoffViewStatus) - { - BandoffView = bandoffViewStatus; - } - - bool HeartModel::GetHeartResultViewStaus() - { - return ResultView; - } - - void HeartModel::SetHeartResultViewStatus(bool resultViewStatus) + /* ---------------------------------- 状态检测 ---------------------------------- */ + /** + * @brief 设置佩戴状态 + */ + void HeartModel::Heart_Start() { - ResultView = resultViewStatus; - } + //进行初始化操作 + timestamp_ms=0; - void HeartModel::SetHeartViewStatus(bool heartViewStatus) - { - HeartView = heartViewStatus; } - - void HeartModel::SetHeartCheckViewStatus(bool checkViewStatus) + /** + * @brief 设置结束状态 + */ + void HeartModel::Heart_Stop() { - CheckView = checkViewStatus; } - bool HeartModel::GetCheckStatus() + /** + * @brief 设置佩戴状态 + * + * @param wear 佩戴状态值 + */ + void HeartModel::SetWearStatus(uint8_t wear) { - return CheckStatus; - } - - void HeartModel::SetCheckStatus(bool checkStatus) - { - CheckStatus = checkStatus; - } - - uint16_t HeartModel::GetHeartdata() - { - return Heart_; - } - - uint16_t HeartModel::GetShowHeartdata() - { - return Show_Heart_; - } + // 设置佩戴状态 + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Weartest::%d", wear); + wear_ = wear_; + // 佩戴信息为错误 + if (wear_ != 1) + { + // 佩戴错误计时器计数 + wear_error++; + // 计数达到10次,停止检测 + if (wear_error >= 10) + { + wearStatus = false; + } + } + wearStatus = true; + } + + /** + * @brief 获取佩戴状态 + * + * @return 佩戴状态 + */ + bool HeartModel::GetWearStatus(void) { return wearStatus; } + + /** + * @brief 设置心率带视图状态 + * + * @param bandoffViewStatus 心率带视图状态值 + */ + void HeartModel::SetHeartBandoffViewStatus(bool bandoffViewStatus) { BandoffView = bandoffViewStatus; } + + /** + * @brief 获取心率带视图状态 + * + * @return 心率带视图状态 + */ + bool HeartModel::GetHeartBandoffViewStatus() { return BandoffView; } + + /** + * @brief 获取心率视图状态 + * + * @return 心率视图状态 + */ + bool HeartModel::GetHeartViewStatus() { return HeartView; } + + /** + * @brief 设置心率视图状态 + * + * @param heartViewStatus 心率视图状态值 + */ + void HeartModel::SetHeartViewStatus(bool heartViewStatus) { HeartView = heartViewStatus; } + + /** + * @brief 获取心率检测视图状态 + * + * @return 心率检测视图状态 + */ + bool HeartModel::GetHeartCheckViewStatus() { return CheckView; } + + /** + * @brief 设置心率检测视图状态 + * + * @param checkViewStatus 心率检测视图状态值 + */ + void HeartModel::SetHeartCheckViewStatus(bool checkViewStatus) { CheckView = checkViewStatus; } + + /** + * @brief 获取心率结果视图状态 + * + * @return 心率结果视图状态 + */ + bool HeartModel::GetHeartResultViewStaus() { return ResultView; } + + /** + * @brief 设置心率结果视图状态 + * + * @param resultViewStatus 心率结果视图状态值 + */ + void HeartModel::SetHeartResultViewStatus(bool resultViewStatus) { ResultView = resultViewStatus; } + + /** + * @brief 获取检测状态 + * + * @return 检测状态 + */ + bool HeartModel::GetCheckStatus() { return CheckStatus; } + + /** + * @brief 设置检测状态 + * + * @param checkStatus 检测状态值 + */ + void HeartModel::SetCheckStatus(bool checkStatus) { CheckStatus = checkStatus; } + + /** + * @brief 获取心率数据 + * + * @return 心率数据 + */ + uint16_t HeartModel::GetHeartdata() { return Heart_; } + + /** + * @brief 获取显示的心率数据 + * + * @return 显示的心率数据 + */ + uint16_t HeartModel::GetShowHeartdata() { return Show_Heart_; } + + /** + * @brief 更新心率数据 + * + * @param heart 心率值 + */ void HeartModel::UpHeartdata(uint16_t heart) { Show_Heart_ = heart; @@ -541,18 +616,27 @@ namespace OHOS } } - uint16_t HeartModel::GetCheckTime() + /** + * @brief 获取检测时间 + * + * @return 检测时间 + */ + uint64_t HeartModel::GetCheckTime() { if (initstatus) { + // 获取当前时间 TIME_ = HeartPresenter::GetInstance()->GetCurrentTime(); initstatus = false; } return TIME_; } - void HeartModel::SetCheckTime(uint16_t time) - { - TIME_ = time; - } + /** + * @brief 设置检测时间 + * + * @param time 检测时间值 + */ + void HeartModel::SetCheckTime(uint64_t time) { TIME_ = time; } + } diff --git a/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartPresenter.cpp index faa4d4bf3..e895a6e43 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartPresenter.cpp @@ -1,4 +1,4 @@ -#include "HeartPresenter.h" + #include "common/task_manager.h" #include "components/ui_label.h" #include "ChangeSliceListener.h" @@ -20,9 +20,11 @@ #include "power_display_service.h" #include "heartrate/include/HeartView.h" -#include "HeartModel.h" -#include "HeartCheckView.h" -#include "HeartBandoffView.h" +#include "heartrate/include/HeartModel.h" +#include "heartrate/include/HeartPresenter.h" +#include "heartrate/include/HeartCheckView.h" +#include "heartrate/include/HeartBandoffView.h" +#include "health_service.h" #define HEARTKEYABLE 0 diff --git a/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartView.cpp b/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartView.cpp index d4197111c..f13f09e70 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartView.cpp @@ -24,7 +24,7 @@ namespace OHOS static constexpr uint16_t BUTTON_HEIGHT2 = 80; // 标签设置 - static constexpr uint16_t PERCENT_X = 133; + static constexpr uint16_t PERCENT_X = 83; static constexpr uint16_t PERCENT_Y = 103; static constexpr uint16_t PERCENT_FONT_SIZE = 140; static constexpr uint16_t TIMELABEL_X = 90; @@ -105,7 +105,7 @@ namespace OHOS return false; } percent->SetPosition(PERCENT_X, PERCENT_Y); // widget's left position and top position - percent->Resize(200, 200); // widget's width and height + percent->Resize(300, 250); // widget's width and height percent->SetViewId("label2"); // Set style percent->SetStyle(STYLE_TEXT_FONT, PERCENT_FONT_SIZE); uint16_t heart_ = HeartModel::GetInstance()->GetHeartdata(); diff --git a/code/sdk/application/wearable/fd230app/nativeui/main/src/MainViewSample.cpp b/code/sdk/application/wearable/fd230app/nativeui/main/src/MainViewSample.cpp index 89e59bb85..7cd771ab7 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/main/src/MainViewSample.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/main/src/MainViewSample.cpp @@ -332,18 +332,17 @@ namespace OHOS { #if USE_OFFLINE_DIAL mainClockView = new DialViewGroup(); -#if 0 +#if 1 std::string filePath = dynamic_cast(presenter_)->GetDialPath(); if (filePath.size() == 0) { - filePath = RES_PATH "/dials/dog.bin"; + filePath = RES_PATH "/dials/Dynamic_cat.bin"; } #endif // DialUpdateModel::GetInstance()->LoadDialConfigFromJson(); - uint8_t fileid = DialUpdateModel::GetInstance()->GetDialConfigPath(); - std::string filePath = dialInfo[fileid].dialPath; + //uint8_t fileid = DialUpdateModel::GetInstance()->GetDialConfigPath(); + //std::string filePath = dialInfo[fileid].dialPath; mainClockView->SetDial(filePath); - #else mainClockView = new MainClockView(); #endif diff --git a/code/sdk/application/wearable/fd230app/nativeui/main/src/dial/parser/DialBinParser.cpp b/code/sdk/application/wearable/fd230app/nativeui/main/src/dial/parser/DialBinParser.cpp index dbb6bfae7..a027a9818 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/main/src/dial/parser/DialBinParser.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/main/src/dial/parser/DialBinParser.cpp @@ -132,7 +132,7 @@ int32_t DialBinParser::ParseDialHeader(FILE* file) } } /* -------------------------------------------------------------------------- */ - #if 0 + #if 1 uint32_t resId = dialHeader->previewImgId | dirId_; uint32_t curReadPt = ftell(file); ImageInfo* info = ImageCacheManager::GetInstance().LoadOneInMultiRes(resId, file_, file, false, imageOffset_); diff --git a/code/sdk/application/wearable/service/msg_center/CMakeLists.txt b/code/sdk/application/wearable/service/msg_center/CMakeLists.txt index f7a7eb6ff..9ac37d862 100755 --- a/code/sdk/application/wearable/service/msg_center/CMakeLists.txt +++ b/code/sdk/application/wearable/service/msg_center/CMakeLists.txt @@ -13,6 +13,7 @@ set(PRIVATE_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/../../nativeapp/nativeui/phoneservice/include ${CMAKE_CURRENT_SOURCE_DIR}/../../fd230app/nativeui/main/include/dial ${CMAKE_CURRENT_SOURCE_DIR}/../../fd230app/nativeui/bloodoxygen/include + ${CMAKE_CURRENT_SOURCE_DIR}/../../fd230app/nativeui/heartrate/include ${CMAKE_CURRENT_SOURCE_DIR}/../../nativeapp/nativeui/main/include ${CMAKE_CURRENT_SOURCE_DIR}/../../nativeapp/nativeui/player/include ${CMAKE_CURRENT_SOURCE_DIR}/../../nativeapp/nativeui/bluetooth/include @@ -105,6 +106,10 @@ set(PRIVATE_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/../../nativeapp/nativeui/main/include ${CMAKE_CURRENT_SOURCE_DIR}/../../fd230app/nativeui/main/include/dial ${CMAKE_CURRENT_SOURCE_DIR}/../../fd230app/nativeui/bloodoxygen/include + ${CMAKE_CURRENT_SOURCE_DIR}/../../fd230app/nativeui/heartrate/include + ${CMAKE_CURRENT_SOURCE_DIR}/../../fd230app/nativeui/clock/include + ${CMAKE_CURRENT_SOURCE_DIR}/../../fd230app/nativeui/activity/include + ${CMAKE_CURRENT_SOURCE_DIR}/../../fd230app/nativeui/rtcservice/include ${CMAKE_CURRENT_SOURCE_DIR}/../../nativeapp/nativeui/player/include ${CMAKE_CURRENT_SOURCE_DIR}/../../nativeapp/nativeui/bluetooth/include ${CMAKE_CURRENT_SOURCE_DIR}/../../nativeapp/nativelauncher/include diff --git a/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp b/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp index 6a96e665b..176097b6a 100755 --- a/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp +++ b/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp @@ -20,6 +20,7 @@ #include "DialModelHeartRate.h" #include "DialModelSPO2.h" #include "BloodOxygenModel.h" +#include "HeartModel.h" #include "ppg_service.h" #include "CallerLogModel.h" #include "notification_manager.h" @@ -235,7 +236,10 @@ void MsgCenterNotifyWearStateProc(const Topic topic, Request* req) unused(req); if ( topic == TOPIC_EVENT_WEARSTATE_UPDATE) { - // req->msgId + int32_t wear = *((int32_t*)(req->data)); // 进行类型转换 + + BloodOxygenModel::GetInstance()->SetWearStatus(wear); + HeartModel::GetInstance()->SetWearStatus(wear); } } //心率 @@ -248,6 +252,7 @@ void MsgCenterNotifyHeartRateProc(const Topic topic, Request* req) u_int8_t heart = *((u_int8_t*)(req->data)); // 进行类型转换 //通知对应信息进行更新 DialModelHeartRate::GetInstance()->UpdateHeartRate(heart); + HeartModel::GetInstance()->UpHeartdata(heart); } } //开始检测心率 diff --git a/code/sdk/application/wstp/at_service/app/app_at_process.c b/code/sdk/application/wstp/at_service/app/app_at_process.c index 36d0ef55c..a06084614 100755 --- a/code/sdk/application/wstp/at_service/app/app_at_process.c +++ b/code/sdk/application/wstp/at_service/app/app_at_process.c @@ -722,7 +722,7 @@ static uint32_t mcu_get_wstp_version(uint8_t *para, uint32_t para_len) (void)sprintf_s(str, VER_STR_MAX, "\r\nVersion:%s %s %s\r\n", get_version_string(), TARGET_NAME, BUILD_TIME); #else -#warning no BUILD_TIME +//#warning no BUILD_TIME (void)sprintf_s(str, VER_STR_MAX, "\r\nVersion:%s\r\n", get_version_string()); #endif wstp_print(str); diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/userdata/health.json b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/userdata/health.json new file mode 100644 index 000000000..50b82dbb8 --- /dev/null +++ b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/userdata/health.json @@ -0,0 +1,46 @@ +{ + "spo2_latest_data": { + "oxygen_value": 98, + "timestamp": 1646769855 + }, + "spo2_data_list": [ + { + "oxygen_value": 95, + "timestamp": 1646769823 + }, + { + "oxygen_value": 97, + "timestamp": 1646769844 + }, + { + "oxygen_value": 96, + "timestamp": 1646769849 + }, + { + "oxygen_value": 98, + "timestamp": 1646769855 + } + ], + "heart_latest_data": { + "heart_value": 88, + "timestamp": 1646769855 + }, + "heart_data_list": [ + { + "heart_value": 95, + "timestamp": 1646769823 + }, + { + "heart_value": 57, + "timestamp": 1646769844 + }, + { + "heart_value": 86, + "timestamp": 1646769849 + }, + { + "heart_value": 88, + "timestamp": 1646769855 + } + ] +} \ No newline at end of file diff --git a/code/sdk/drivers/peripheral/ppg/hx3695/hx3695.c b/code/sdk/drivers/peripheral/ppg/hx3695/hx3695.c index fff8e98c1..b1e1c2e69 100644 --- a/code/sdk/drivers/peripheral/ppg/hx3695/hx3695.c +++ b/code/sdk/drivers/peripheral/ppg/hx3695/hx3695.c @@ -2682,6 +2682,7 @@ void hx3695_hrs_ppg_Int_handle(void) hx3695_msg_callback_t func = hx3695_get_send_msg_callback_func(); if(func != NULL) { + hrsresult.wearstatus = hrs_wear_status; func(HX3695_MSG_TYPE_WEARSTAT_UPDATE,&hrsresult.wearstatus,sizeof(int32_t)); func(HX3695_MSG_TYPE_HRS_UPDATE,&hrsresult,sizeof(FT_CUSTOM_RESULTS_t)); } diff --git a/code/sdk/drivers/peripheral/ppg/service/ppg_service.cpp b/code/sdk/drivers/peripheral/ppg/service/ppg_service.cpp index f79c48120..a3ad04e12 100644 --- a/code/sdk/drivers/peripheral/ppg/service/ppg_service.cpp +++ b/code/sdk/drivers/peripheral/ppg/service/ppg_service.cpp @@ -135,6 +135,20 @@ errcode_t update_hrs_event_sendmsg_toUI(uint8_t hrs) return ERRCODE_SUCC; } + +//穿戴状态 +errcode_t update_wearstatus_event_notify(int32_t wearstatus) +{ + CustomEventPublish(TOPIC_EVENT_WEARSTATE_UPDATE,(uint8_t*)&wearstatus,sizeof(wearstatus)); + return 0; +} +errcode_t update_wearstatus_event_sendmsg_toUI(int32_t wearstatus) +{ + /**通过UI事件发送Notify*/ + GraphicService::GetInstance()->PostGraphicEvent(std::bind(update_wearstatus_event_notify, wearstatus)); + return ERRCODE_SUCC; +} + #include "hx3695_hal.h" void hx3695_msg_callback(uint8_t msg_type, uint8_t *msg_data, int32_t msg_datalen) @@ -168,7 +182,7 @@ void hx3695_msg_callback(uint8_t msg_type, uint8_t *msg_data, int32_t msg_datale break; case HX3695_MSG_TYPE_WEARSTAT_UPDATE: WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "HX3695_MSG_TYPE_WEARSTATUS_UPDATE = %d", sensor_data.wearstatus); - //update_wearstatus_event_sendmsg_toUI(sensor_data.wearstatus); + update_wearstatus_event_sendmsg_toUI(sensor_data.wearstatus); break; default: WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Unknown sensor message type"); diff --git a/code/sdk/drivers/peripheral/utils/custom_utils.c b/code/sdk/drivers/peripheral/utils/custom_utils.c index b76323585..0ea79e474 100644 --- a/code/sdk/drivers/peripheral/utils/custom_utils.c +++ b/code/sdk/drivers/peripheral/utils/custom_utils.c @@ -260,9 +260,6 @@ errcode_t uapi_set_time_from_cat1(char* cat1time) tz.tz_minuteswest = zone*60; settimeofday(&tv, &tz); - - - }else{ printf("convert to time failed ret %d!\n",ret); return ERRCODE_FAIL;