修复睡眠异常数据BUG,优化产测mic测试,支持不带屏测试,debug界面添加详细睡眠数据 1468/1 1468/head 1470/target/1
authorpenglei <1624952103@qq.com>
Wed, 27 Nov 2024 06:44:40 +0000 (14:44 +0800)
committerpenglei <1624952103@qq.com>
Wed, 27 Nov 2024 06:44:40 +0000 (14:44 +0800)
code/sdk/application/wearable/fd230app/nativeui/producttest/src/testmicrophone.cpp
code/sdk/application/wearable/fd230app/nativeui/sleep/include/SleepModel.h
code/sdk/application/wearable/fd230app/nativeui/sleep/src/SleepModel.cpp
code/sdk/application/wearable/service/msg_center/include/notify/findwatch_notification.h
code/sdk/application/wearable/service/msg_center/src/notify/debug_output_notification/debug_output_notification.cpp
code/sdk/application/wearable/service/msg_center/src/notify/findwatch_notification.cpp
code/sdk/drivers/peripheral/cywee/src/main_dml.c

index 58fd595..f084d39 100644 (file)
@@ -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();
         }
 
index 49ab135..2a4f8fa 100644 (file)
@@ -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
index 0e58805..e5b0549 100644 (file)
@@ -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)
   {
index 7bc6632..0aee891 100644 (file)
@@ -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);
index 2f3eb37..c6589d2 100644 (file)
@@ -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; // 返回结果字符串  
     } 
index 3baa2e1..07dffb3 100644 (file)
@@ -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;
index a6a9d42..45a1ebb 100644 (file)
@@ -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;
                 }