修复次日运动数据不清零问题,修复每小时运动数据存储异常问题
authorpenglei <1624952103@qq.com>
Thu, 9 Oct 2025 03:45:20 +0000 (11:45 +0800)
committerpenglei <1624952103@qq.com>
Thu, 9 Oct 2025 03:45:20 +0000 (11:45 +0800)
code/sdk/application/wearable/fd230/service/msg_center/src/msg_center_customer.cpp
code/sdk/application/wearable/fd272/service/msg_center/src/msg_center_customer.cpp
code/sdk/application/wearable/n9/service/msg_center/src/msg_center_customer.cpp
code/sdk/zhihui/drivers/cywee/dml/cywee_data.c
code/sdk/zhihui/services/ble_service/blemoder/bleInstruct.cpp

index 39208a4..8ed5d92 100644 (file)
@@ -81,6 +81,7 @@
 #ifdef SUPPORT_CYWEE_SERVICE
 #include "cywee_hal.h"
 #include "cywee_data.h"
+#include "cywee_service.h"
 #endif
 
 #include "cat1_pub_api.h"
@@ -388,6 +389,17 @@ void MsgCenterNotifyNextDayProc(const Topic topic, Request *req)
         std::bind(&OHOS::BloodOxygenModel::CleanAllData,
                   OHOS::BloodOxygenModel::GetInstance()));
     printf("health end\n");
+    /* ---------------------------------- 呼吸训练相关 ---------------------------------- */
+    RespiratoryTrainingModel::GetInstance().ClearTotalRespiratoryTrainingTime();
+
+    // 存储nextday执行日志
+    start_report_nextday_log_end();
+    // 清除popup_windows日志
+    nextday_clear_popup_windows_log();
+
+    printf("******nextday is end******\r\n");
+#endif
+#ifdef SUPPORT_CYWEE_SERVICE
     /* --------------------------------- 每日目标相关 --------------------------------- */
     cywee_reset_history_daily_data(); //清除运动相关数据
 
@@ -402,15 +414,6 @@ void MsgCenterNotifyNextDayProc(const Topic topic, Request *req)
 
     // SendMsgToUIService(UI_UPDATE_GOAL, 0, nullptr, 0);
     printf("sport end\n");
-    /* ---------------------------------- 呼吸训练相关 ---------------------------------- */
-    RespiratoryTrainingModel::GetInstance().ClearTotalRespiratoryTrainingTime();
-
-    // 存储nextday执行日志
-    start_report_nextday_log_end();
-    // 清除popup_windows日志
-    nextday_clear_popup_windows_log();
-
-    printf("******nextday is end******\r\n");
 #endif
 #if defined(BOARD_W9)
     printf("******nextday is begin******\r\n");
@@ -422,7 +425,8 @@ void MsgCenterNotifyONtimeProc(const Topic topic, Request* req)
 {
     unused(req);
     AlarmClockEventData* time=(AlarmClockEventData*)req->data;
-    #ifdef SUPPORT_CYWEE_SERVICE
+
+#ifdef SUPPORT_CYWEE_SERVICE
 
     cywee_save_data(); //暂时没有这个函数
 
@@ -431,7 +435,7 @@ void MsgCenterNotifyONtimeProc(const Topic topic, Request* req)
 
     WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "保存每小时站立数据");
     if(cywee_get_stand_flag())
-    cywee_stand_history_save(time->value);
+        cywee_stand_history_save(time->value);
 
     WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "保存每小时卡路里数据");
     cywee_calories_history_save(time->value);
@@ -441,10 +445,10 @@ void MsgCenterNotifyONtimeProc(const Topic topic, Request* req)
 
     WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "保存每小时燃脂数据");
     cywee_fat_history_save(time->value);
+#endif
     // 保存完增加一次读取数据
     SendMsgToUIService(UI_UPDATE_GOAL, 0, nullptr, 0);
-#endif
-    }
+}
 //设备绑定通知
 void MsgCenterNotifyDeviceBindProc(const Topic topic, Request* req)
 {
index f7e32a4..f8c18b7 100644 (file)
 
 #ifdef SUPPORT_CYWEE_SERVICE
 #include "cywee_hal.h"
+#include "cywee_data.h"
+#include "cywee_service.h"
 #endif
 
 #include "cat1_pub_api.h"
+#include "uiservice/include/ui_service.h"
 
 namespace OHOS {
 
@@ -382,6 +385,17 @@ void MsgCenterNotifyNextDayProc(const Topic topic, Request *req)
         std::bind(&OHOS::BloodOxygenModel::CleanAllData,
                   OHOS::BloodOxygenModel::GetInstance()));
     printf("health end\n");
+    /* ---------------------------------- 呼吸训练相关 ---------------------------------- */
+    RespiratoryTrainingModel::GetInstance().ClearTotalRespiratoryTrainingTime();
+
+    // 存储nextday执行日志
+    start_report_nextday_log_end();
+    // 清除popup_windows日志
+    nextday_clear_popup_windows_log();
+
+    printf("******nextday is end******\r\n");
+#endif
+#ifdef SUPPORT_CYWEE_SERVICE
     /* --------------------------------- 每日目标相关 --------------------------------- */
     cywee_reset_history_daily_data(); //清除运动相关数据
 
@@ -396,15 +410,6 @@ void MsgCenterNotifyNextDayProc(const Topic topic, Request *req)
 
     // SendMsgToUIService(UI_UPDATE_GOAL, 0, nullptr, 0);
     printf("sport end\n");
-    /* ---------------------------------- 呼吸训练相关 ---------------------------------- */
-    RespiratoryTrainingModel::GetInstance().ClearTotalRespiratoryTrainingTime();
-
-    // 存储nextday执行日志
-    start_report_nextday_log_end();
-    // 清除popup_windows日志
-    nextday_clear_popup_windows_log();
-
-    printf("******nextday is end******\r\n");
 #endif
 #if defined(BOARD_W9)
     printf("******nextday is begin******\r\n");
@@ -416,24 +421,27 @@ void MsgCenterNotifyONtimeProc(const Topic topic, Request* req)
 {
     unused(req);
     AlarmClockEventData* time=(AlarmClockEventData*)req->data;
-    #ifdef SUPPORT_CYWEE_SERVICE
-#if 0
-    cywee_save_data(); //暂时没有这个函数
+#ifdef SUPPORT_CYWEE_SERVICE
+    cywee_save_data();
+
     WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "保存每小时步数");
-    step_history_save(time->value);
+    cywee_step_history_save(time->value);
+
     WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "保存每小时站立数据");
-    if(get_stand_falg())
-        stand_history_save(time->value);
+    if(cywee_get_stand_flag())
+        cywee_stand_history_save(time->value);
+
     WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "保存每小时卡路里数据");
-    calories_history_save(time->value);
+    cywee_calories_history_save(time->value);
+
     WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "保存每小时距离数据");
-    distances_history_save(time->value);
+    cywee_distances_history_save(time->value);
+    
     WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "保存每小时燃脂数据");
-    fat_history_save(time->value);
+    cywee_fat_history_save(time->value);
+#endif
     // 保存完增加一次读取数据
     SendMsgToUIService(UI_UPDATE_GOAL, 0, nullptr, 0);
-#endif
-    #endif
 }
 //设备绑定通知
 void MsgCenterNotifyDeviceBindProc(const Topic topic, Request* req)
index f7e32a4..ac3946b 100644 (file)
 
 #ifdef SUPPORT_CYWEE_SERVICE
 #include "cywee_hal.h"
+#include "cywee_data.h"
+#include "cywee_service.h"
 #endif
 
 #include "cat1_pub_api.h"
+#include "uiservice/include/ui_service.h"
 
 namespace OHOS {
 
@@ -382,6 +385,17 @@ void MsgCenterNotifyNextDayProc(const Topic topic, Request *req)
         std::bind(&OHOS::BloodOxygenModel::CleanAllData,
                   OHOS::BloodOxygenModel::GetInstance()));
     printf("health end\n");
+    /* ---------------------------------- 呼吸训练相关 ---------------------------------- */
+    RespiratoryTrainingModel::GetInstance().ClearTotalRespiratoryTrainingTime();
+
+    // 存储nextday执行日志
+    start_report_nextday_log_end();
+    // 清除popup_windows日志
+    nextday_clear_popup_windows_log();
+
+    printf("******nextday is end******\r\n");
+#endif
+#ifdef SUPPORT_CYWEE_SERVICE
     /* --------------------------------- 每日目标相关 --------------------------------- */
     cywee_reset_history_daily_data(); //清除运动相关数据
 
@@ -396,15 +410,6 @@ void MsgCenterNotifyNextDayProc(const Topic topic, Request *req)
 
     // SendMsgToUIService(UI_UPDATE_GOAL, 0, nullptr, 0);
     printf("sport end\n");
-    /* ---------------------------------- 呼吸训练相关 ---------------------------------- */
-    RespiratoryTrainingModel::GetInstance().ClearTotalRespiratoryTrainingTime();
-
-    // 存储nextday执行日志
-    start_report_nextday_log_end();
-    // 清除popup_windows日志
-    nextday_clear_popup_windows_log();
-
-    printf("******nextday is end******\r\n");
 #endif
 #if defined(BOARD_W9)
     printf("******nextday is begin******\r\n");
@@ -416,24 +421,27 @@ void MsgCenterNotifyONtimeProc(const Topic topic, Request* req)
 {
     unused(req);
     AlarmClockEventData* time=(AlarmClockEventData*)req->data;
-    #ifdef SUPPORT_CYWEE_SERVICE
-#if 0
-    cywee_save_data(); //暂时没有这个函数
+#ifdef SUPPORT_CYWEE_SERVICE
+    cywee_save_data();
+
     WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "保存每小时步数");
-    step_history_save(time->value);
+    cywee_step_history_save(time->value);
+
     WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "保存每小时站立数据");
-    if(get_stand_falg())
-        stand_history_save(time->value);
+    if(cywee_get_stand_flag())
+        cywee_stand_history_save(time->value);
+
     WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "保存每小时卡路里数据");
-    calories_history_save(time->value);
+    cywee_calories_history_save(time->value);
+
     WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "保存每小时距离数据");
-    distances_history_save(time->value);
+    cywee_distances_history_save(time->value);
+    
     WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "保存每小时燃脂数据");
-    fat_history_save(time->value);
+    cywee_fat_history_save(time->value);
     // 保存完增加一次读取数据
-    SendMsgToUIService(UI_UPDATE_GOAL, 0, nullptr, 0);
 #endif
-    #endif
+    SendMsgToUIService(UI_UPDATE_GOAL, 0, nullptr, 0);
 }
 //设备绑定通知
 void MsgCenterNotifyDeviceBindProc(const Topic topic, Request* req)
index b3f6fca..094a7de 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: penglei 1624952103@qq.com
  * @Date: 2024-04-08 14:53:31
  * @LastEditors: penglei 1624952103@qq.com
- * @LastEditTime: 2025-09-30 18:03:35
+ * @LastEditTime: 2025-10-09 11:43:54
  * @FilePath: /FD230/code/sdk/drivers/peripheral/cywee/service/cywee_dml.c
  * @Description: 
  * 
@@ -124,7 +124,7 @@ static void CWM_OS_saveData(int* data, uint32_t len,uint8_t type){
     }
     int ret =fwrite(data,1,len,fp);
    
-    PRINT("CWM_OS_saveData fwrite failed %d %d\n",ret,*data);
+    PRINT("CWM_OS_saveData fwrite type:%d data:%d ret:%d\n",type,ret,*data);
     
     fclose(fp);
 }
@@ -262,7 +262,7 @@ void cywee_save_data(void)
     }
     uapi_dev_runtime_set_goal_storage_status(1);
 
-    int step = cywee_get_sport_data(STEP);
+    int step = cywee_get_sport_data(STEP) + cywee_get_sport_data(HISTORY_STEP);
     int calories = cywee_get_sport_data(NEW_CALORIES) + cywee_get_sport_data(HISTORY_CALORIES);
     int distances = cywee_get_sport_data(NEW_DISTANCE) + cywee_get_sport_data(HISTORY_DISTANCE);
     int fat = cywee_get_sport_data(NEW_FAT) + cywee_get_sport_data(HISTORY_FAT);
@@ -795,6 +795,7 @@ void cywee_calories_history_save(uint32_t time)
     float history_calories_ = cywee_get_sport_data(HISTORY_CALORIES_);
     // CWM_OS_dbgPrintf("history_calories is saving\n");
     CWM_OS_saveData_history(&history_calories,&history_calories_,sizeof(float),CALORIES,time);
+    cywee_set_sport_data(history_calories_,HISTORY_CALORIES_);
 }
 
 void cywee_distances_history_save(uint32_t time)
@@ -804,6 +805,7 @@ void cywee_distances_history_save(uint32_t time)
     float history_distances_ = cywee_get_sport_data(HISTORY_DISTANCE_);
     // CWM_OS_dbgPrintf("history_distances is saving\n");
     CWM_OS_saveData_history(&history_distances_now,&history_distances_,sizeof(float),DISTANCE,time);
+    cywee_set_sport_data(history_distances_,HISTORY_DISTANCE_);
 }
 
 void cywee_fat_history_save(uint32_t time)
@@ -820,6 +822,7 @@ void cywee_fat_history_save(uint32_t time)
     }
     int history_fat_ = cywee_get_sport_data(HISTORY_FAT_);
     CWM_OS_saveData_history(&temp_data,&history_fat_,sizeof(uint16_t),FAT,time);
+    cywee_set_sport_data(history_fat_,HISTORY_FAT_);
 }
 
 
@@ -829,6 +832,7 @@ void cywee_step_history_save(uint32_t time)
     int history_step_ = cywee_get_sport_data(HISTORY_STEP_);
     // CWM_OS_dbgPrintf("step_history is saving\n");
     CWM_OS_saveData_history(&data,&history_step_,sizeof(int),STEP,time);
+    cywee_set_sport_data(history_step_,HISTORY_STEP_);
 }
 
 
index 0a18739..0695c70 100644 (file)
@@ -674,7 +674,7 @@ char * ble_sywee_history(uint8_t day,uint16_t *len ,uint8_t type)
                 break;
             case 0x45://同步站立历史数据
 
-                // if(cywee_get_stand_falg())
+                // if(cywee_get_stand_flag())
                 // {
                 //     memcpy(buf+size,&creationTime,4);
                     //     size+=4;