Merge #922 into sdk602patch0626 from refs/changes/922/head 924/target/1 925/target/1
author彭磊 <1624952103@qq.com>
Mon, 9 Sep 2024 12:49:49 +0000 (12:49 +0000)
committersnickersun@163.com <accounts_62b90f7fcf51ade33b6f628e@mail.teambition.com>
Mon, 9 Sep 2024 12:49:49 +0000 (12:49 +0000)
Code review from 彭磊

* refs/changes/922/head: (5 commits squashed)

  - 设置录音回环测试默认音量为30

  - Merge branch &#39;sdk602patch0626&#39; of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0626

  - Merge branch &#39;sdk602patch0626&#39; of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0626

  - 优化多段睡眠文件存储,优化添加cywee密钥的AT指令

  - 优化多段睡眠文件存储,优化添加cywee密钥的AT指令(补交)

Signed-off-by: aliyun6865282430 <1624952103@qq.com>
Reviewed-by: snickersun@163.com <accounts_62b90f7fcf51ade33b6f628e@mail.teambition.com>
Merged-by: snickersun@163.com <accounts_62b90f7fcf51ade33b6f628e@mail.teambition.com>
link: https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230/change/922
code/sdk/application/wearable/fd230app/nativeui/sleep/src/SleepModel.cpp
code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp
code/sdk/drivers/peripheral/cywee/src/main_dml.c
code/sdk/drivers/peripheral/utils/custom_utils_at_cmd.c

index 5fa4183..c481d6d 100644 (file)
@@ -1,8 +1,8 @@
 /*
  * @Author: penglei 1624952103@qq.com
  * @Date: SLEPPNOTIFY24-06-26 19:36:48
- * @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-09-07 17:56:51
+ * @LastEditors: penglei 1624952103@qq.com
+ * @LastEditTime: 2024-09-09 18:25:14
  * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/sleep/src/SleepModel.cpp
  * @Description:
  *
@@ -251,29 +251,34 @@ namespace OHOS
             memset(status_file_path,0,sizeof(status_file_path));
             sprintf_s(status_file_path, 64, SLEEP_STATUS_PATH, day);
             fp = fopen(status_file_path, "wb+");
-
+            if(fp == NULL)
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "save_sleep_data fopen fail");
+                return false;
+            }
             history_wake_up_timestamp = data->wake_up_timestamp;
+            fwrite(data->sleep_status, sizeof(SLEEP_STATE_T), data->status_num, fp);
         }
         else
         {        
-            fp = fopen(status_file_path, "ab+");
+            fp = fopen(status_file_path, "rb+");
+            if(fp == NULL)
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "save_sleep_data fopen fail");
+                return false;
+            }
+
             if(history_wake_up_timestamp != data->wake_up_timestamp)
             {
+                fseek(fp, -sizeof(SLEEP_STATE_T), SEEK_END);
                 SLEEP_STATE_T sleep_status = {0,0};
                 sleep_status.stat = 3; //清醒状态
-                sleep_status.timestamp = history_wake_up_timestamp + 60; //时间戳为上一次的出睡时间 加 1分钟
+                sleep_status.timestamp = history_wake_up_timestamp; //清醒状态时间为上一次的出睡时间
                 history_wake_up_timestamp = data->wake_up_timestamp; //更新历史出睡时间戳
-                fwrite(&sleep_status, sizeof(SLEEP_STATE_T), 1, fp);
+                fwrite(&sleep_status, sizeof(SLEEP_STATE_T), 1, fp); //替换历史出睡数据 改为清醒状态
+                fwrite(&data->sleep_status[1], sizeof(SLEEP_STATE_T), data->status_num - 1, fp); //跳过入睡状态写入文件
             }
         }
-
-        if (fp == NULL)
-        {
-            WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "save_sleep_data fopen fail");
-            return false;
-        }
-        fwrite(data->sleep_status, sizeof(SLEEP_STATE_T), data->status_num, fp);
-
         fclose(fp);
         return true;
     }
index 61fed1c..e22e786 100644 (file)
@@ -1295,7 +1295,7 @@ void MsgCenterNotifyInactivityProc(const Topic topic, Request *req)
             {
                 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].stat = cywee_Inactivity_Info->status;
-                if(sleep_data.sleep_status[state_num].stat == 6 || sleep_data.sleep_status[state_num].stat == 13)
+                if(sleep_data.sleep_status[state_num].stat == 7 || sleep_data.sleep_status[state_num].stat == 13)
                 {
                     uapi_get_timestampe_ss(&timestamp);
                     sleep_data.sleep_status[state_num].timestamp = timestamp;
index 7460368..7d584c6 100644 (file)
@@ -834,6 +834,7 @@ void CWM_AP_SensorListen(pSensorEVT_t sensorEVT) {
                 {
                     uapi_dev_runtime_set_sleep_status(1);
                     uapi_get_timestampe_ss(&asleep_timestampe);
+                    break; //入睡通知不发消息,直接退出
                 }
                 else if(c_inactivity_result_t.status == 4 || c_inactivity_result_t.status == 13)
                 {
index be8844a..3e15bce 100644 (file)
@@ -1129,10 +1129,11 @@ static uint32_t custom_cywee_save_mac_key(uint8_t *para, uint32_t paraLen, char
 {
 
     UNUSED(strCommonCmd);
+#ifdef CYWEE_MAC_ACTIVE
     uint8_t argv[CUSTOM_UTILS_MAX_ARGC][CUSTOM_UTILS_MAX_ARGV_LEN] = { 0 };
     uint32_t argc = 0;
-    uint8_t send_data[8] = {0};
-
+    uint8_t *send_data = NULL;
+    uint8_t *tmp_data = NULL;
 
     int ret = ConvertCmdToParam(para, paraLen, argv, &argc);
     if (ret != CUSTOM_UTILS_SUCCESS) {
@@ -1145,9 +1146,41 @@ static uint32_t custom_cywee_save_mac_key(uint8_t *para, uint32_t paraLen, char
         return ERRCODE_FAIL;
     }
     int16_t len = atol((char*)argv[0]);
+    tmp_data = (uint8_t *)malloc(len * 2);
+    if(tmp_data == NULL)
+    {
+        wstp_print("MALLOC FAILED\r\n");
+        return ERRCODE_FAIL;
+    }
 
-    uapi_cywee_save_mac_key(argv[1],len);
+    
+    for(int i = 0; i < len * 2; i++)
+    {
+        if(argv[1][i] >=65)
+            argv[1][i] = argv[1][i] - 65 + 10;
+        else
+            argv[1][i] = argv[1][i] - 48;
+        tmp_data[i] = argv[1][i];
 
+    }
+    send_data = (uint8_t *)malloc(len);
+    if(send_data == NULL)
+    {
+        free(tmp_data);
+        wstp_print("MALLOC FAILED\r\n");
+        return ERRCODE_FAIL;
+    }
+
+
+    for(int i = 0,j = 0; i < len * 2 ; i+=2 , j++)
+    {
+        send_data[j] =  tmp_data[i] * 16 | tmp_data[i+1];
+        wstp_print("send_data[%d] : 0X%2X\n",j,send_data[j]);
+    }
+    uapi_cywee_save_mac_key(send_data,len);
+    free(send_data);
+    free(tmp_data);
+#endif
     return ERRCODE_SUCC;
 }