From 0c32bf065af87d91e8f8b62794fcfab717bb1e69 Mon Sep 17 00:00:00 2001 From: penglei <1624952103@qq.com> Date: Wed, 27 Nov 2024 14:44:40 +0800 Subject: [PATCH] =?utf8?q?=E4=BF=AE=E5=A4=8D=E7=9D=A1=E7=9C=A0=E5=BC=82?= =?utf8?q?=E5=B8=B8=E6=95=B0=E6=8D=AEBUG=EF=BC=8C=E4=BC=98=E5=8C=96?= =?utf8?q?=E4=BA=A7=E6=B5=8Bmic=E6=B5=8B=E8=AF=95=EF=BC=8C=E6=94=AF?= =?utf8?q?=E6=8C=81=E4=B8=8D=E5=B8=A6=E5=B1=8F=E6=B5=8B=E8=AF=95=EF=BC=8Cd?= =?utf8?q?ebug=E7=95=8C=E9=9D=A2=E6=B7=BB=E5=8A=A0=E8=AF=A6=E7=BB=86?= =?utf8?q?=E7=9D=A1=E7=9C=A0=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../producttest/src/testmicrophone.cpp | 4 +- .../nativeui/sleep/include/SleepModel.h | 1 + .../nativeui/sleep/src/SleepModel.cpp | 137 +++++++++++++++++- .../include/notify/findwatch_notification.h | 4 +- .../debug_output_notification.cpp | 5 +- .../src/notify/findwatch_notification.cpp | 11 +- .../drivers/peripheral/cywee/src/main_dml.c | 9 +- 7 files changed, 163 insertions(+), 8 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testmicrophone.cpp b/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testmicrophone.cpp index 58fd5951b..f084d39e9 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testmicrophone.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testmicrophone.cpp @@ -375,13 +375,13 @@ extern "C" { // AlarmClockModel::GetInstance()->testPlayerStart("/user/userdata/microphone.mp3"); FindWatchViewEventListener::GetInstance().setVolumeVal(100); - FindWatchViewEventListener::GetInstance().PopInterPlayMusic("/user/userdata/microphone.mp3"); + FindWatchViewEventListener::GetInstance().PopInterPlayMusic_product("/user/userdata/microphone.mp3"); // AlarmClockModel::GetInstance()->AlarmPlayerStart(); } else { // AlarmClockModel::GetInstance()->AlarmPlayerStop(); - FindWatchViewEventListener::GetInstance().PopInterCancelMusic(); + FindWatchViewEventListener::GetInstance().PopInterCancelMusic_product(); // AlarmClockModel::GetInstance()->AlarmPlayerStop(); } diff --git a/code/sdk/application/wearable/fd230app/nativeui/sleep/include/SleepModel.h b/code/sdk/application/wearable/fd230app/nativeui/sleep/include/SleepModel.h index 49ab135fc..2a4f8faa5 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/sleep/include/SleepModel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/sleep/include/SleepModel.h @@ -61,6 +61,7 @@ namespace OHOS std::string get_sleep_asleep_time_str(void); std::string get_sleep_wake_time_str(void); std::string get_wear_status_str(void); + std::string get_sleep_star_str(void); //void clean_sleep_file(void); // 睡眠状态 enum class SLEEPSTATE diff --git a/code/sdk/application/wearable/fd230app/nativeui/sleep/src/SleepModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/sleep/src/SleepModel.cpp index 0e58805cf..e5b054971 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/sleep/src/SleepModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/sleep/src/SleepModel.cpp @@ -2,7 +2,7 @@ * @Author: penglei 1624952103@qq.com * @Date: SLEPPNOTIFY24-06-26 19:36:48 * @LastEditors: penglei 1624952103@qq.com - * @LastEditTime: 2024-11-11 16:59:29 + * @LastEditTime: 2024-11-27 11:15:14 * @FilePath: * /FD230/code/sdk/application/wearable/fd230app/nativeui/sleep/src/SleepModel.cpp * @Description: @@ -135,7 +135,142 @@ namespace OHOS return result; // 返回结果字符串 } + std::string get_sleep_star_str(void) + { + + std::string result; + + uint16_t datelen = 0; + uint8_t sleep_data[256] = {0}; + + uint32_t asleep_time = 0; + uint32_t wake_up_time = 0; + uint16_t total_time = 0; + uint16_t total_deep_sleep_time = 0; + uint16_t total_mild_sleep_time = 0; + uint16_t total_rem_sleep_time = 0; + uint16_t total_wake_time = 0; + uint32_t timestampe = 0; + int status = -1; + uint8_t index = 0; + char timestampe_str[10] = {0}; + char status_str[20] = {0}; + + char day[12] = {0}; + uapi_get_YYMMDD_Time(day, '\0'); + + char file_path[64] = {0}; + sprintf_s(file_path, 64, SLEEP_TIME_PATH, day); + + uapi_get_file_data(file_path,sleep_data,&datelen); + + if(datelen == 0) + { + PRINT("fread error datelen == 0 \n"); + return "没有文件"; + } + + asleep_time = *(uint32_t*)&sleep_data[1]; + wake_up_time = *(uint32_t*)&sleep_data[5]; + + total_time = sleep_data[9] * 60 + sleep_data[10]; + total_deep_sleep_time = sleep_data[11] * 60 + sleep_data[12]; + total_mild_sleep_time = sleep_data[13] * 60 + sleep_data[14]; + total_rem_sleep_time = sleep_data[15] * 60 + sleep_data[16]; + total_wake_time = sleep_data[17] * 60 + sleep_data[18]; + + char asleep_time_str[10] = {0}; + uapi_get_TIME_STR(asleep_time,asleep_time_str, '.', ':',DATE_H_M); + + char wake_up_time_str[10] = {0}; + uapi_get_TIME_STR(wake_up_time,wake_up_time_str, '.', ':',DATE_H_M); + + result += std::string("入睡时间: ") + asleep_time_str + " " + std::to_string(asleep_time) + "\n"; + result += std::string("出睡时间: ") + wake_up_time_str + " " + std::to_string(wake_up_time) + "\n"; + result += std::string("总时长: ") + std::to_string(total_time) + "\n"; + result += std::string("深睡时长: ") + std::to_string(total_deep_sleep_time) + "\n"; + result += std::string("浅睡时长: ") + std::to_string(total_mild_sleep_time) + "\n"; + result += std::string("快速眼动时长: ") + std::to_string(total_rem_sleep_time) + "\n"; + result += std::string("清醒时长: ") + std::to_string(total_wake_time) + "\n"; + + // PRINT("入睡时间 : %s %d \n",asleep_time_str,asleep_time); + // PRINT("出睡时间 : %s %d \n",wake_up_time_str,wake_up_time); + // PRINT("总时长 : %d 分钟\n",total_time); + // PRINT("深睡时长 : %d 分钟\n",total_deep_sleep_time); + // PRINT("浅睡时长 : %d 分钟\n",total_mild_sleep_time); + // PRINT("快速眼动时长 : %d 分钟\n",total_rem_sleep_time); + // PRINT("清醒时长 : %d 分钟\n",total_wake_time); + + char statuspath[64] = {0}; + uapi_get_YYMMDD_Time(day, '\0'); + sprintf_s(statuspath, 64, SLEEP_STATUS_PATH, day); + + + memset(sleep_data,0,sizeof(sleep_data)); + datelen = 0; + uapi_get_file_data(statuspath,sleep_data,&datelen); + + if(datelen == 0) + { + PRINT("fread error datelen == 0 \n"); + return result += "\n 没有状态文件"; + } + + while(datelen) + { + memset(timestampe_str,0,sizeof(timestampe_str)); + memset(status_str,0,sizeof(status_str)); + timestampe = *(uint32_t*)&sleep_data[index]; + uapi_get_TIME_STR(timestampe,timestampe_str, '.', ':',DATE_H_M); + status = sleep_data[index + 4]; + //0进入睡眠 1潜睡 2深睡 3清醒 4结束睡眠 6入睡 7出睡最后一笔输出 8未出睡最后一笔输出 12快速动眼 13取消入睡 + switch(status) + { + case 0: + strcpy(status_str,"进入睡眠"); + break; + case 1: + strcpy(status_str,"浅睡"); + break; + case 2: + strcpy(status_str,"深睡"); + break; + case 3: + strcpy(status_str,"清醒"); + break; + case 4: + strcpy(status_str,"结束睡眠"); + break; + case 6: + strcpy(status_str,"入睡通知"); + break; + case 7: + strcpy(status_str,"出睡最后一笔输出"); + break; + case 9: + strcpy(status_str,"未出睡最后一笔输出"); + break; + case 12: + strcpy(status_str,"快速动眼"); + break; + case 13: + strcpy(status_str,"取消入睡"); + break; + default: + break; + + } + + // PRINT("时间 : %d %s 状态:%s\n",timestampe,timestampe_str,status_str); + + result += std::string(status_str) + std::to_string(timestampe) + "\n"; + + index+=5; + datelen -= 5; + } + return result; + } std::string get_sleep_asleep_time_str(void) { diff --git a/code/sdk/application/wearable/service/msg_center/include/notify/findwatch_notification.h b/code/sdk/application/wearable/service/msg_center/include/notify/findwatch_notification.h index 7bc6632e6..0aee89176 100644 --- a/code/sdk/application/wearable/service/msg_center/include/notify/findwatch_notification.h +++ b/code/sdk/application/wearable/service/msg_center/include/notify/findwatch_notification.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-03-25 17:31:19 * @LastEditors: penglei 1624952103@qq.com - * @LastEditTime: 2024-11-20 20:50:00 + * @LastEditTime: 2024-11-27 10:44:16 * @FilePath: /FD230/code/sdk/application/wearable/service/msg_center/include/notify/findwatch_notification.h */ #ifndef FIND_WATCH_NOTIFICATION_H @@ -68,6 +68,8 @@ namespace OHOS static FindWatchViewEventListener &GetInstance(void); void PopInterCancelMusic(void); void PopInterPlayMusic(const char *path); + void PopInterPlayMusic_product(const char *path); + void PopInterCancelMusic_product(); int FindWatchRingPlayStop(void); int FindWatchRingPlayStart(const char *path); int FindWatchRingPlayerInit(const char *path); diff --git a/code/sdk/application/wearable/service/msg_center/src/notify/debug_output_notification/debug_output_notification.cpp b/code/sdk/application/wearable/service/msg_center/src/notify/debug_output_notification/debug_output_notification.cpp index 2f3eb3706..c6589d240 100644 --- a/code/sdk/application/wearable/service/msg_center/src/notify/debug_output_notification/debug_output_notification.cpp +++ b/code/sdk/application/wearable/service/msg_center/src/notify/debug_output_notification/debug_output_notification.cpp @@ -455,8 +455,9 @@ namespace OHOS result += "--------------------\n"; // 获取当天最新的入睡与醒来时间 - result += "asleep_time: " + get_sleep_asleep_time_str() + " "; - result += "wake_time: " + get_sleep_wake_time_str() + " "; + // result += "asleep_time: " + get_sleep_asleep_time_str() + " "; + // result += "wake_time: " + get_sleep_wake_time_str() + " "; + result += get_sleep_star_str(); return result; // 返回结果字符串 } diff --git a/code/sdk/application/wearable/service/msg_center/src/notify/findwatch_notification.cpp b/code/sdk/application/wearable/service/msg_center/src/notify/findwatch_notification.cpp index 3baa2e149..07dffb342 100644 --- a/code/sdk/application/wearable/service/msg_center/src/notify/findwatch_notification.cpp +++ b/code/sdk/application/wearable/service/msg_center/src/notify/findwatch_notification.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-03-25 17:33:47 * @LastEditors: penglei 1624952103@qq.com - * @LastEditTime: 2024-11-20 21:06:21 + * @LastEditTime: 2024-11-27 10:53:09 * @FilePath: /FD230/code/sdk/application/wearable/service/msg_center/src/notify/findwatch_notification.cpp * @details:实现查找手表的功能一般需要手表和智能手机之间的配合,通常是通过手机上的应用(App)或其他设备发送指令给手表,触发手表的查找功能。 * 以下是基本的实现步骤: @@ -329,6 +329,15 @@ namespace OHOS std::bind(&FindWatchViewEventListener::FindWatchRingPlayStart, &FindWatchViewEventListener::GetInstance(), path_)); } + void FindWatchViewEventListener::PopInterCancelMusic_product() + { + FindWatchRingPlayStop(); + } + void FindWatchViewEventListener::PopInterPlayMusic_product(const char *path) + { + FindWatchRingPlayStart(path); + } + // 声明定时器变量 static osTimerId_t g_timer = nullptr; static bool findwatch_time = true; diff --git a/code/sdk/drivers/peripheral/cywee/src/main_dml.c b/code/sdk/drivers/peripheral/cywee/src/main_dml.c index a6a9d42e0..45a1ebbe1 100644 --- a/code/sdk/drivers/peripheral/cywee/src/main_dml.c +++ b/code/sdk/drivers/peripheral/cywee/src/main_dml.c @@ -120,6 +120,8 @@ static uint8_t wear_status = 0;//佩戴状态 static uint8_t timeout = 0; +static uint8_t wake_up_flag = 0; + #ifdef CYWEE_MAC_ACTIVE int cm__hs1__mac_c1_init(void); int cm__hs1__deinit(void); @@ -187,6 +189,7 @@ void clean_sleep_data(void) memset(status_file_path, 0, sizeof(status_file_path)); memset(dir_path, 0, sizeof(dir_path)); memset(nap_file_path, 0, sizeof(nap_file_path)); + wake_up_flag = 0; } void cywee_save_nap_data(cywee_inactivity_accumulate_time_t c_inactivity_accumulate_time_t) @@ -385,6 +388,9 @@ void cywee_save_sleep_stat_data(void) stat_num = 0; memset(sleep_stat,0,SLEEP_STATUS_LENGTH * sizeof(SLEEP_STAT_T)); + if(wake_up_flag) + uapi_dev_runtime_set_sleep_status(0); + } void cywee_set_sleep_stat_data(cywee_inactivity_result_t c_inactivity_result_t) { @@ -1256,6 +1262,7 @@ void CWM_AP_SensorListen(pSensorEVT_t sensorEVT) { { if(c_inactivity_result_t.status == 6) { + wake_up_flag = 0; uapi_dev_runtime_set_sleep_status(1); uapi_get_timestampe_ss(&asleep_timestampe); } @@ -1267,7 +1274,7 @@ void CWM_AP_SensorListen(pSensorEVT_t sensorEVT) { } else if(c_inactivity_result_t.status == 4 || c_inactivity_result_t.status == 13) { - uapi_dev_runtime_set_sleep_status(0); + wake_up_flag = 1; if(c_inactivity_result_t.status == 13) break; } -- 2.17.1