优化睡眠状态时间戳接收 495/1 495/head
authorpenglei <1624952103@qq.com>
Wed, 10 Jul 2024 08:58:59 +0000 (16:58 +0800)
committerpenglei <1624952103@qq.com>
Wed, 10 Jul 2024 08:58:59 +0000 (16:58 +0800)
code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp

index 518f6ff..3c26e1e 100644 (file)
@@ -1032,8 +1032,7 @@ void MsgCenterNotifyInactivityProc(const Topic topic, Request *req)
         time(&rawtime);
         timeinfo = localtime(&rawtime);
         uapi_get_timestampe_ss(&timestamp);
-        day_timestamp = timestamp - (timeinfo->tm_hour * 60 * 60 + timeinfo->tm_min * 60 + timeinfo->tm_sec);
-        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, ", = %d", day_timestamp);
+        day_timestamp = timestamp - (timeinfo->tm_mday * 24 * 60 * 60 + timeinfo->tm_hour * 60 * 60 + timeinfo->tm_min * 60 + timeinfo->tm_sec);
     }
 #endif
     OHOS::SLEEP_STATE_T state_data = {0};
@@ -1080,17 +1079,17 @@ void MsgCenterNotifyInactivityProc(const Topic topic, Request *req)
 #ifdef FD230
             if(state_num < 20)
             {
-                sleep_data.sleep_status[state_num].timestamp = day_timestamp + cywee_Inactivity_Info->hour * 60 * 60 + cywee_Inactivity_Info->minute * 60;
+                sleep_data.sleep_status[state_num].timestamp = day_timestamp + cywee_Inactivity_Info->day * 24 * 60 * 60 + cywee_Inactivity_Info->hour * 60 * 60 + cywee_Inactivity_Info->minute * 60;
                 sleep_data.sleep_status[state_num].stat = cywee_Inactivity_Info->status;
                 state_num ++;
             }
             if(cywee_Inactivity_Info->status == 0) //0进入睡眠  1潜睡 2深睡 3清醒 4结束睡眠 6入睡 7出睡最后一笔输出 8未出睡最后一笔输出 12快速动眼 13取消入睡
             {
-                sleep_data.fall_asleep_timestamp = day_timestamp + cywee_Inactivity_Info->hour * 60 * 60 + cywee_Inactivity_Info->minute * 60;
+                sleep_data.fall_asleep_timestamp = day_timestamp + cywee_Inactivity_Info->day * 24 * 60 * 60 + cywee_Inactivity_Info->hour * 60 * 60 + cywee_Inactivity_Info->minute * 60;
             }
             else if(cywee_Inactivity_Info->status == 4)
             {
-                sleep_data.wake_up_timestamp = day_timestamp + cywee_Inactivity_Info->hour * 60 * 60 + cywee_Inactivity_Info->minute * 60;
+                sleep_data.wake_up_timestamp = day_timestamp + cywee_Inactivity_Info->day * 24 * 60 * 60 + cywee_Inactivity_Info->hour * 60 * 60 + cywee_Inactivity_Info->minute * 60;
             }
 #endif
             break;
@@ -1100,13 +1099,13 @@ void MsgCenterNotifyInactivityProc(const Topic topic, Request *req)
             if(cywee_Inactivity_Info->status == 0) //0进入睡眠  1潜睡 2深睡 3清醒 4结束睡眠 6入睡 7出睡最后一笔输出 8未出睡最后一笔输出 12快速动眼 13取消入睡
             {
 #ifdef FD230
-                nap_data.fall_asleep_timestamp = day_timestamp + cywee_Inactivity_Info->hour * 60 * 60 + cywee_Inactivity_Info->minute * 60;
+                nap_data.fall_asleep_timestamp = day_timestamp + cywee_Inactivity_Info->day * 24 * 60 * 60 + cywee_Inactivity_Info->hour * 60 * 60 + cywee_Inactivity_Info->minute * 60;
 #endif
             }
             else if(cywee_Inactivity_Info->status == 14)
             {
 #ifdef FD230
-                nap_data.wake_up_timestamp = day_timestamp + cywee_Inactivity_Info->hour * 60 * 60 + cywee_Inactivity_Info->minute * 60;
+                nap_data.wake_up_timestamp = day_timestamp + cywee_Inactivity_Info->day * 24 * 60 * 60 + cywee_Inactivity_Info->hour * 60 * 60 + cywee_Inactivity_Info->minute * 60;
 #endif
             }
             break;