Merge #1174 into sdk602patch0911 from refs/changes/1174/head
author彭磊 <1624952103@qq.com>
Sat, 12 Oct 2024 13:41:09 +0000 (13:41 +0000)
committersnickersun@163.com <accounts_62b90f7fcf51ade33b6f628e@mail.teambition.com>
Sat, 12 Oct 2024 13:41:09 +0000 (13:41 +0000)
Code review from 彭磊

* refs/changes/1174/head: (8 commits squashed)

  - 更新gsensor dml库,修复FATAL ERROR bug与运动数据bug

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

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

  - 修复低电量不触发弹窗的BUG

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

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

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

  - 电池管理:修改TIMER为40秒,增加开机电池自检操作。
    优化小睡数据读取。
    增加产测模式runtime,进入产测模式不弹充电弹窗

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/1174
code/sdk/application/battery/service/battery_service.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/factorytest_service/factorytest_protocol.c
code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp
code/sdk/drivers/peripheral/utils/custom_runtime.c
code/sdk/drivers/peripheral/utils/custom_runtime.h

index f8b7d2d..6faf4cd 100644 (file)
@@ -75,12 +75,13 @@ osTimerId_t g_battery_timer = NULL;
 // static bool g_bat_timer_is_running = false;
 #define CHARGE_CHECK_TIMER_CYCLE_MS 1000 
 #define DISABLE_CHARGE_CHECK_MS 1000
-#define ENABLE_CHARGE_TIMEOUT_MS 10000
+#define ENABLE_CHARGE_TIMEOUT_MS 10000 * 4
 bool last_battery_charge_enable_status=true; // true上次刚设置在充电状态,false 上次设置不在充电状态。注意这个是充电IC的充电开关设置,并非真正处于充电状态的标识。
 static unsigned long g_app_queue;
 #define BATTERY_CMD_CHECK_VOLTAGE 0x11
 #define BATTERY_CMD_CHARGE_PLUG 0x13
 #define BATTERY_CMD_CHARGE_UNPLUG 0x14
+#define BATTERY_CMD_FIRST_CHECK 0x15
 
 #define BATTERY_LOWPOWER_ALARM_POWERLEVEL 10
 #define BATTERY_LOWPOWER_ALARM_SHUTDOWNLEVEL 5
@@ -368,6 +369,10 @@ static void battery_check_task(void *arg)
             disable_charge();
             #endif
             charger_plug_event_ui_sendmsg_toUI(0);
+        }else if(mail.comm.event == BATTERY_CMD_FIRST_CHECK)
+        {
+            battery_check_voltage();
+            battery_check_chargement();
         }
     }// while (1) 
 
@@ -548,7 +553,7 @@ errcode_t uapi_battery_init(void)
     //开始timer
     battery_timer_start_check_released(CHARGE_CHECK_TIMER_CYCLE_MS);
     // PRINT("uapi_battery_init end!\r\n");
-
+    send_battery_svr_cmd_msg(BATTERY_CMD_FIRST_CHECK); //开机电池自检
 
     return ERRCODE_SUCC;
 }
index b1d4b59..6863261 100644 (file)
 // #include "sleep/include/SleepControlPresenter.h"
 #include "string"
 
-#define NAPTEST
-
-
 #define SLEEP_TIME_PATH "/user/userdata/sleep/%s/sleep_time.bin"
 #define SLEEP_STATUS_PATH "/user/userdata/sleep/%s/sleep_status.bin"
 
-#ifndef NAPTEST
-#define NAP_PATH "/user/userdata/sleep/%s/nap_%d.bin"
-#else
 #define NAP_PATH "/user/userdata/sleep/%s/nap.bin"
-#endif
 #define SLEEP_DIR_PATH "/user/userdata/sleep/%s"
 
 #define SLEEP_DATA_DIR "/user/userdata/sleep/"
@@ -61,7 +54,7 @@ namespace OHOS
 #pragma pack (pop)
 
     bool save_nap_data(NAP_T *data);
-    uint8_t get_nap_data_size(void);
+    uint32_t get_nap_data_size(void);
     // bool sleep_mutex_init(void);
     uint32_t read_sleep_nap_data(char *data, uint32_t size, FILE *fp);
     void set_nap_data(NAP_T *data);
index d12bd66..bb733a4 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-10-08 17:50:46
+ * @LastEditTime: 2024-10-12 20:32:23
  * @FilePath:
  * /FD230/code/sdk/application/wearable/fd230app/nativeui/sleep/src/SleepModel.cpp
  * @Description:
@@ -96,11 +96,10 @@ namespace OHOS
   static char nap_file_path[64] = {0};
   
   //获取小睡数据长度(协议用)
-  uint8_t get_nap_data_size(void)
+  uint32_t get_nap_data_size(void)
   {
-  #ifdef NAPTEST
       FILE *fp;
-      uint8_t size = 0;
+      uint32_t size = 0;
       fp = fopen(nap_file_path, "rb"); 
       if (fp == NULL) 
       {
@@ -112,9 +111,6 @@ namespace OHOS
       size = ftell(fp);
       fclose(fp);
       return size;
-  #else
-      return 0;
-  #endif
   }
 
   bool save_nap_data(NAP_T *data)
@@ -142,28 +138,13 @@ namespace OHOS
         return false; // Failed to create folder
       }
     }
-    uint32_t creationTime;
-    uapi_get_timestampe_ss(&creationTime);
 
-    sprintf_s(nap_file_path, 64, NAP_PATH, day, creationTime);
+    sprintf_s(nap_file_path, 64, NAP_PATH, day);
 
-    FILE *fp;
-
-    fp = fopen(nap_file_path, "rb+"); //小睡数据全部存入一个文件
-    uint32_t size=0;
-    if (fp)
-    {
-      fseek(fp, 0, SEEK_END); // 将文件指针移动到文件末尾
-      uint32_t size= ftell(fp);       // 获取当前文件指针位置,即文件大小
-      fseek(fp, 0, SEEK_SET); // 将文件指针移回文件开头
-      fclose(fp);
-    }
+    uint32_t size = get_nap_data_size();
 
-#ifdef NAPTEST
+    FILE *fp;
     fp = fopen(nap_file_path, "ab+"); //小睡数据全部存入一个文件
-#else 
-    fp = fopen(nap_file_path, "wb+");
-#endif
     if(fp==NULL)
     {
       WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "save_nap_sleep_data %s fopen fail ", nap_file_path);
@@ -598,6 +579,10 @@ namespace OHOS
 
   bool read_nap_data(NAP_T *data)
   {
+    char day[12] = {0};
+    uapi_get_YYMMDD_Time(day, '\0');
+
+    sprintf_s(nap_file_path, 64, NAP_PATH, day);
 
     FILE *fp = fopen(nap_file_path, "rb");
     if (fp == NULL)
@@ -606,7 +591,11 @@ namespace OHOS
       return false;
     }
 
-#ifndef NAPTEST
+    if(get_nap_data_size() > 14) //存在多段小睡 UI显示最新的一次数据
+       fseek(fp, -14, SEEK_END);//移到最后一段数据
+
+    fseek(fp, 3, SEEK_CUR); // 将文件指针移动到睡眠类型
+
     //读取睡眠类型
     uint8_t sleep_type;
     fread(&sleep_type, 1, 1, fp);
@@ -617,10 +606,6 @@ namespace OHOS
       fclose(fp);
       return false;
     }
-#else
-    if(get_nap_data_size() > 10) //存在多段小睡 UI显示最新的一次数据
-       fseek(fp, -10, SEEK_END);//移到最后一段数据
-#endif
     // 入睡时间
     uint32_t fall_asleep_timestamp;
     fread(&fall_asleep_timestamp, 1, 4, fp);
index 2e72bc5..56ee2aa 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: penglei 1624952103@qq.com\r
  * @Date: 2024-06-17 14:31:08\r
  * @LastEditors: penglei 1624952103@qq.com\r
- * @LastEditTime: 2024-09-18 20:10:26\r
+ * @LastEditTime: 2024-10-12 20:34:45\r
  * @FilePath: /FD230/code/sdk/application/wearable/service/factorytest_service/factorytest_protocol.c\r
  * @Description: \r
  * \r
@@ -37,7 +37,7 @@
 #include "bletest.h"\r
 #include "battery_service.h"\r
 #include "cywee_service.h"\r
-\r
+#include "broadcast_feature.h"\r
 #ifdef SUPPORT_TCPIP\r
 #include "lwip/api_shell.h"\r
 #endif\r
@@ -329,7 +329,8 @@ void factorytest_protocol_common_decode(uint8_t submode,uint8_t testitem,uint8_t
                 uint8_t send_data=0;\r
 \r
                 factorytest_mode_flag = 1;\r
-\r
+                ChargerEventPublish(TOPIC_EVENT_CHARGE_UNPLUG,0); //进入产测模式 关闭充电弹窗\r
+                uapi_dev_runtime_set_factory_test_status(1); //设置产测模式runtime\r
                 factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_COMMON,\r
                         BLE_TEST_CMD_COMMON_SUB_MODE_SWITCH_MODE,\r
                         0x01,\r
@@ -1776,7 +1777,7 @@ errcode_t factorytest_protocol_decode(uint8_t *buf, uint16_t event_size)
                 \r
             printf("crc16 0x%04X vs 0x%04X\n",crc16,crc16_2);\r
 \r
-            //if( crc16 == crc16_2) //校验通过,开始正式解析\r
+            if( crc16 == crc16_2) //校验通过,开始正式解析\r
             {\r
                 if(factorytest_mode_flag == 0 && header.submod != BLE_TEST_CMD_COMMON_SUB_MODE_SWITCH_MODE)\r
                     return ERRCODE_FAIL;\r
index 3108827..46eaaee 100644 (file)
@@ -439,7 +439,7 @@ void MsgCenterNotifyChargePlugProc(const Topic topic, Request* req)
     }
     else
     {
-        if (CheckPriority(topic))
+        if (CheckPriority(topic) && !uapi_dev_runtime_get_factory_test_status_flag()) //产测模式不弹充电弹窗
         {
             NotificationManager::GetInstance()->ShowNotify(ShowChargeingNotify, (uint16_t)topic, true);
         }
index 1b5e8b4..50c0685 100644 (file)
@@ -98,7 +98,7 @@ typedef struct
 
     uint8_t respiratory_training_status; //呼吸训练开始状态
     uint8_t heartrate_detect_status;//主动检测心率状态
-    
+    uint8_t factory_test_status;//产测模式状态
 
 } runtime_status_t;
 
@@ -573,3 +573,14 @@ uint8_t uapi_dev_runtime_get_mmc_status_flag(void)
 {
     return g_runtime.mmc_status;
 }
+
+// 设置是否为产测模式
+void uapi_dev_runtime_set_factory_test_status(uint8_t status)
+{
+    g_runtime.factory_test_status = status;
+}
+// 获取是否为产测模式
+uint8_t uapi_dev_runtime_get_factory_test_status_flag(void)
+{
+    return g_runtime.factory_test_status;
+}
index b59af35..ef2b6cb 100644 (file)
@@ -286,6 +286,11 @@ void uapi_dev_runtime_set_mmc_status(uint8_t status);
 // 获取指南针页面状态
 uint8_t uapi_dev_runtime_get_mmc_status_flag(void);
 
+// 设置是否为产测模式
+void uapi_dev_runtime_set_factory_test_status(uint8_t status);
+// 获取是否为产测模式
+uint8_t uapi_dev_runtime_get_factory_test_status_flag(void);
+
 #ifdef __cplusplus
 #if __cplusplus
 }