增加系统的日志记录宏 1968/1 1968/head 1971/target/1
authorCaisking <Casiking@zhihuishixun.com>
Tue, 15 Jul 2025 06:47:29 +0000 (14:47 +0800)
committerCaisking <Casiking@zhihuishixun.com>
Tue, 15 Jul 2025 06:47:29 +0000 (14:47 +0800)
code/sdk/application/wearable/fd230/nativeapp/nativeui/bloodoxygen/src/BloodOxygenModel.cpp
code/sdk/application/wearable/fd230/nativeapp/nativeui/bloodoxygen/src/BloodResultView.cpp
code/sdk/application/wearable/fd230/nativeapp/nativeui/heartrate/src/HeartModel.cpp
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/src/TraingModel.cpp
code/sdk/application/wearable/fd230/service/msg_center/src/msg_center_customer.cpp

index 7abcf4b..a762368 100644 (file)
@@ -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 <custom_save_runtime.h>
@@ -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();
+        }
     }
 }
index 500ccff..7cb38d8 100644 (file)
@@ -9,15 +9,15 @@
 #include "ui_resource_image.h"
 #include <ui_scroll_view.h>
 #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"
index 830eb53..7672ae9 100644 (file)
@@ -439,37 +439,41 @@ void HeartModel::Heart_Control(HeartState state, HeartCheck check) {
       sensorstate = false;\r
       uapi_dev_runtime_set_heartrate_detect_status(0);\r
     }\r
-\r
+#ifdef SYSTEM_LOG_SERVICE\r
     //记录日志\r
     if (checkstate == HeartCheck::PASSIVITY) {\r
       uapi_save_runtime_log(RUNTIME_LOG_OXYGEN_PASSIVE_MEASURE_END);\r
     } else {\r
       uapi_save_runtime_log(RUNTIME_LOG_HEART_MEASURE_END);\r
     }\r
+#endif\r
 \r
     // 复原检测状态\r
     checkstate = HeartCheck::RESTSTSTE;\r
+    heart_stop_data_timer(); //关闭数据获取\r
   } else if (state == HeartState::Start && heartstate == false) {\r
     /*充电状态下不进行检测*/\r
     bool isCharging = get_charge_stat(); // 获取充电状态\r
     if (isCharging) {\r
-      WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "充电不能检测");\r
+      WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "充电不能检测");\r
       return;\r
     }\r
-    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "HeartState Start");\r
+\r
 #ifdef SUPPORT_PPG_SERVICE\r
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "HeartState Start");\r
     uint8_t md = PPG_SERVICE_CMD_TYPE_DO_PPG_TEST;\r
     send_ppg_cmd_msg(md);\r
 #endif\r
     heartstate = true;\r
     checkstate = check;\r
-\r
+#ifdef SYSTEM_LOG_SERVICE\r
     //记录日志\r
     if (checkstate == HeartCheck::PASSIVITY) {\r
       uapi_save_runtime_log(RUNTIME_LOG_HEART_PASSIVE_MEASURE);\r
     } else {\r
       uapi_save_runtime_log(RUNTIME_LOG_HEART_MEASURE);\r
     }\r
+#endif\r
   }\r
 }\r
 // 开始检测\r
@@ -498,8 +502,6 @@ void HeartModel::Heart_Stop() {
   disvalid_counter_ = 0;\r
   unwear_counter_ = 0;\r
 \r
-  heart_stop_data_timer(); //关闭数据获取\r
-\r
   /*主界面卡片检测 或者 被动检测*/\r
   if (checkstate == HeartCheck::PASSIVITY) {\r
     if (heartresult_ == HeartResult::SUCCESS) {\r
@@ -683,8 +685,9 @@ void HeartModel::SetWearStatus() {
     return;\r
 \r
   unwear_counter_++;\r
+#ifdef SYSTEM_LOG_SERVICE\r
   uapi_save_runtime_log(RUNTIME_LOG_HEART_NOT_WEAR);\r
-\r
+#endif\r
   // 设置佩戴状态\r
   if (checkstate == HeartCheck::CARDCHECK) {\r
     if (unwear_counter_ > MAX_UNWEAR_COUNT) {\r
@@ -692,14 +695,18 @@ void HeartModel::SetWearStatus() {
         //只有在心率卡片界面才触发\r
         if (MainViewSample::GetInstance()->GetHorCurrentCard() == HEART_RATE) {\r
           SetResult(HeartResult::NOT_WORN);\r
+#ifdef SYSTEM_LOG_SERVICE\r
           uapi_save_runtime_log(RUNTIME_LOG_HEART_ERROR_NOT_WEAR);\r
+#endif\r
           Heart_Stop();\r
         }\r
       }\r
     }\r
   } else {\r
     SetResult(HeartResult::NOT_WORN);\r
+#ifdef SYSTEM_LOG_SERVICE\r
     uapi_save_runtime_log(RUNTIME_LOG_HEART_ERROR_NOT_WEAR);\r
+#endif\r
     Heart_Stop();\r
   }\r
 }\r
@@ -729,11 +736,15 @@ void HeartModel::UpHeartdata(uint16_t heart) {
     currentheart = displayheart; // 更新当前心率\r
     valid_counter_++;            // 增加有效计数器\r
     disvalid_counter_ = 0;       // 清空无效计数器\r
+#ifdef SYSTEM_LOG_SERVICE\r
     uapi_save_runtime_log(RUNTIME_LOG_HEART_VALID_VALUE);\r
+#endif\r
   } else {\r
     disvalid_counter_++; // 增加无效计数器\r
     valid_counter_ = 0;  // 清零有效计数器\r
+#ifdef SYSTEM_LOG_SERVICE\r
     uapi_save_runtime_log(RUNTIME_LOG_HEART_INVALID_VALUE);\r
+#endif\r
   }\r
 \r
   // 检查无效计数器是否达标\r
@@ -746,7 +757,9 @@ void HeartModel::UpHeartdata(uint16_t heart) {
     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,\r
                   "检测结果:无效数达标 disvalid_counter:%d", disvalid_counter_);\r
     SetResult(HeartResult::INVALID_DATA); // 标记为无效数据\r
+#ifdef SYSTEM_LOG_SERVICE\r
     uapi_save_runtime_log(RUNTIME_LOG_HEAR_ERROR_INVALID_VALUE);\r
+#endif\r
     Heart_Stop();\r
     return;\r
   }\r
@@ -756,7 +769,9 @@ void HeartModel::UpHeartdata(uint16_t heart) {
     WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,\r
                   "检测结果:成功 valid_counter:%d currentheart:%d",\r
                   valid_counter_, currentheart);\r
+#ifdef SYSTEM_LOG_SERVICE\r
     uapi_save_runtime_log(RUNTIME_LOG_HEAR_SUCCESS);\r
+#endif\r
     SetResult(HeartResult::SUCCESS); // 标记为成功检测\r
     Heart_Stop();\r
     return;\r
@@ -1022,8 +1037,8 @@ static void heart_data_callbackProc(int data) {
   //更新佩戴\r
   uint8_t wear = 1;\r
 #ifdef SUPPORT_PPG_SERVICE\r
-  wear = ppg_get_wear_status(); \r
-  wear = 1;//暂时屏蔽\r
+  wear = ppg_get_wear_status();\r
+  wear = 1; //暂时屏蔽\r
   // printf("heart_data_callbackProc::wear = %d\n", wear);\r
 #endif\r
   if (wear == 0) {\r
index 7597c4f..6d347df 100644 (file)
@@ -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 <sys/time.h>
 #include <vector>
 
-
 #include "chip_system_time.h"
 #include <custom_save_runtime.h>
 
@@ -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<uint8_t>(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<SportData> &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
index 5baf89a..5890416 100644 (file)
@@ -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() ));