From ebc4ef40d16bea3ec066a40814ee324d5296b2fb Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E5=BD=AD=E7=A3=8A?= <1624952103@qq.com> Date: Wed, 3 Jul 2024 06:54:49 +0000 Subject: [PATCH] Merge #441 into sdk602patch0626 from refs/changes/441/head MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 优化小睡与睡眠消息接收 * refs/changes/441/head: (1 commits squashed) - 优化小睡与睡眠消息接收 Signed-off-by: aliyun6865282430 <1624952103@qq.com> Reviewed-by: snickersun@163.com Merged-by: snickersun@163.com CR-link: https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230/change/441 --- .../msg_center/src/msg_center_customer.cpp | 29 +++++++++---------- .../drivers/peripheral/cywee/Inc/cywee_hal.h | 5 ++-- .../drivers/peripheral/cywee/src/main_dml.c | 6 ++-- 3 files changed, 21 insertions(+), 19 deletions(-) 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 5d0943264..78450fc67 100644 --- 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 @@ -1137,26 +1137,25 @@ void MsgCenterNotifyInactivityAccumulateTimeProc(const Topic topic, Request* req return; } #ifdef FD230 - if(nap_data.wake_up_timestamp != 0) + if(cywee_Inactivity_Accumulate_Time_Info->output_number == INACTIVITY_MODE_NAP_ACCUMULATE_TIME_OUTPUT) { nap_data.total_time = cywee_Inactivity_Accumulate_Time_Info->total_time; set_nap_data(&nap_data); memset(&nap_data,0,sizeof(NAP_T)); - free(cywee_Inactivity_Accumulate_Time_Info); - cywee_Inactivity_Accumulate_Time_Info = NULL; - return ; } - - sleep_data.total_time = cywee_Inactivity_Accumulate_Time_Info->total_time; - sleep_data.total_deep_sleep_time = cywee_Inactivity_Accumulate_Time_Info->total_deep_sleep_time; - sleep_data.total_mild_sleep_time = cywee_Inactivity_Accumulate_Time_Info->total_mild_sleep_time; - sleep_data.total_wake_time = cywee_Inactivity_Accumulate_Time_Info->total_wake_time; - sleep_data.total_rem_sleep_time = cywee_Inactivity_Accumulate_Time_Info->total_rem_sleep_time; - sleep_data.status_num = state_num; - - set_sleep_data(&sleep_data); - memset(&sleep_data,0,sizeof(SLEEP_T)); - state_num = 0; + else if(cywee_Inactivity_Accumulate_Time_Info->output_number == INACTIVITY_MODE_SLEEPING_ACCUMULATE_TIME_OUTPUT) + { + sleep_data.total_time = cywee_Inactivity_Accumulate_Time_Info->total_time; + sleep_data.total_deep_sleep_time = cywee_Inactivity_Accumulate_Time_Info->total_deep_sleep_time; + sleep_data.total_mild_sleep_time = cywee_Inactivity_Accumulate_Time_Info->total_mild_sleep_time; + sleep_data.total_wake_time = cywee_Inactivity_Accumulate_Time_Info->total_wake_time; + sleep_data.total_rem_sleep_time = cywee_Inactivity_Accumulate_Time_Info->total_rem_sleep_time; + sleep_data.status_num = state_num; + + set_sleep_data(&sleep_data); + memset(&sleep_data,0,sizeof(SLEEP_T)); + state_num = 0; + } #endif free(cywee_Inactivity_Accumulate_Time_Info); cywee_Inactivity_Accumulate_Time_Info = NULL; diff --git a/code/sdk/drivers/peripheral/cywee/Inc/cywee_hal.h b/code/sdk/drivers/peripheral/cywee/Inc/cywee_hal.h index f9d8d538d..9a1dea593 100644 --- a/code/sdk/drivers/peripheral/cywee/Inc/cywee_hal.h +++ b/code/sdk/drivers/peripheral/cywee/Inc/cywee_hal.h @@ -62,9 +62,9 @@ extern void CWM_OS_restoreData(int* data, uint32_t len,uint8_t type); #define INACTIVITY_MODE_SEDENTARY_OUTPUT 20 // 久坐和有效站立 #define INACTIVITY_MODE_SLEEPING_OUTPUT 21 // 睡眠 -#define INACTIVITY_MODE_SLEEPING_ACCUMULATE_TIME_OUTPUT 31 // 久坐、有效站立和小睡 +#define INACTIVITY_MODE_SLEEPING_ACCUMULATE_TIME_OUTPUT 31 // 睡眠累计 #define INACTIVITY_MODE_NAP_OUTPUT 22 // 小睡 -#define INACTIVITY_MODE_NAP_ACCUMULATE_TIME_OUTPUT 32 +#define INACTIVITY_MODE_NAP_ACCUMULATE_TIME_OUTPUT 32 // 小睡累计 #pragma pack(1) @@ -490,6 +490,7 @@ typedef struct typedef struct { + int output_number; int total_time;//总共睡眠时间 int total_mild_sleep_time;//总共浅睡时间 int total_deep_sleep_time;//总共深睡时间 diff --git a/code/sdk/drivers/peripheral/cywee/src/main_dml.c b/code/sdk/drivers/peripheral/cywee/src/main_dml.c index de3bc37c6..de474aff6 100644 --- a/code/sdk/drivers/peripheral/cywee/src/main_dml.c +++ b/code/sdk/drivers/peripheral/cywee/src/main_dml.c @@ -666,7 +666,8 @@ void CWM_AP_SensorListen(pSensorEVT_t sensorEVT) { }else if((int)sensorEVT->fData[0] == 31){ memset(&c_inactivity_accumulate_time_t,0,sizeof(cywee_inactivity_accumulate_time_t)); - + + c_inactivity_accumulate_time_t.output_number = (int)sensorEVT->fData[0]; c_inactivity_accumulate_time_t.total_time = (int)sensorEVT->fData[1]; c_inactivity_accumulate_time_t.total_mild_sleep_time = (int)sensorEVT->fData[2]; c_inactivity_accumulate_time_t.total_deep_sleep_time = (int)sensorEVT->fData[3]; @@ -691,7 +692,8 @@ void CWM_AP_SensorListen(pSensorEVT_t sensorEVT) { }else if((int)sensorEVT->fData[0] == 32){ memset(&c_inactivity_accumulate_time_t,0,sizeof(cywee_inactivity_accumulate_time_t)); - + + c_inactivity_accumulate_time_t.output_number = (int)sensorEVT->fData[0]; c_inactivity_accumulate_time_t.total_time = (int)sensorEVT->fData[1]; c_inactivity_accumulate_time_t.total_mild_sleep_time = (int)sensorEVT->fData[2]; c_inactivity_accumulate_time_t.total_deep_sleep_time = (int)sensorEVT->fData[3]; -- 2.17.1