From d5fe88a4769a9c46c1ccee6288ab1da0c117cf46 Mon Sep 17 00:00:00 2001 From: penglei <1624952103@qq.com> Date: Sat, 12 Oct 2024 20:47:11 +0800 Subject: [PATCH] =?utf8?q?=E7=94=B5=E6=B1=A0=E7=AE=A1=E7=90=86=EF=BC=9A?= =?utf8?q?=E4=BF=AE=E6=94=B9TIMER=E4=B8=BA40=E7=A7=92=EF=BC=8C=E5=A2=9E?= =?utf8?q?=E5=8A=A0=E5=BC=80=E6=9C=BA=E7=94=B5=E6=B1=A0=E8=87=AA=E6=A3=80?= =?utf8?q?=E6=93=8D=E4=BD=9C=E3=80=82=20=E4=BC=98=E5=8C=96=E5=B0=8F?= =?utf8?q?=E7=9D=A1=E6=95=B0=E6=8D=AE=E8=AF=BB=E5=8F=96=E3=80=82=20?= =?utf8?q?=E5=A2=9E=E5=8A=A0=E4=BA=A7=E6=B5=8B=E6=A8=A1=E5=BC=8Fruntime?= =?utf8?q?=EF=BC=8C=E8=BF=9B=E5=85=A5=E4=BA=A7=E6=B5=8B=E6=A8=A1=E5=BC=8F?= =?utf8?q?=E4=B8=8D=E5=BC=B9=E5=85=85=E7=94=B5=E5=BC=B9=E7=AA=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../battery/service/battery_service.cpp | 9 +++- .../nativeui/sleep/include/SleepModel.h | 9 +--- .../nativeui/sleep/src/SleepModel.cpp | 45 +++++++------------ .../factorytest_protocol.c | 9 ++-- .../msg_center/src/msg_center_customer.cpp | 2 +- .../drivers/peripheral/utils/custom_runtime.c | 13 +++++- .../drivers/peripheral/utils/custom_runtime.h | 5 +++ 7 files changed, 46 insertions(+), 46 deletions(-) diff --git a/code/sdk/application/battery/service/battery_service.cpp b/code/sdk/application/battery/service/battery_service.cpp index f8b7d2d0f..6faf4cd71 100644 --- a/code/sdk/application/battery/service/battery_service.cpp +++ b/code/sdk/application/battery/service/battery_service.cpp @@ -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; } 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 b1d4b598b..68632617e 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/sleep/include/SleepModel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/sleep/include/SleepModel.h @@ -11,17 +11,10 @@ // #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); 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 d12bd6626..bb733a4cf 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-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); diff --git a/code/sdk/application/wearable/service/factorytest_service/factorytest_protocol.c b/code/sdk/application/wearable/service/factorytest_service/factorytest_protocol.c index 2e72bc50f..56ee2aaf1 100644 --- a/code/sdk/application/wearable/service/factorytest_service/factorytest_protocol.c +++ b/code/sdk/application/wearable/service/factorytest_service/factorytest_protocol.c @@ -2,7 +2,7 @@ * @Author: penglei 1624952103@qq.com * @Date: 2024-06-17 14:31:08 * @LastEditors: penglei 1624952103@qq.com - * @LastEditTime: 2024-09-18 20:10:26 + * @LastEditTime: 2024-10-12 20:34:45 * @FilePath: /FD230/code/sdk/application/wearable/service/factorytest_service/factorytest_protocol.c * @Description: * @@ -37,7 +37,7 @@ #include "bletest.h" #include "battery_service.h" #include "cywee_service.h" - +#include "broadcast_feature.h" #ifdef SUPPORT_TCPIP #include "lwip/api_shell.h" #endif @@ -329,7 +329,8 @@ void factorytest_protocol_common_decode(uint8_t submode,uint8_t testitem,uint8_t uint8_t send_data=0; factorytest_mode_flag = 1; - + ChargerEventPublish(TOPIC_EVENT_CHARGE_UNPLUG,0); //进入产测模式 关闭充电弹窗 + uapi_dev_runtime_set_factory_test_status(1); //设置产测模式runtime factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_COMMON, BLE_TEST_CMD_COMMON_SUB_MODE_SWITCH_MODE, 0x01, @@ -1776,7 +1777,7 @@ errcode_t factorytest_protocol_decode(uint8_t *buf, uint16_t event_size) printf("crc16 0x%04X vs 0x%04X\n",crc16,crc16_2); - //if( crc16 == crc16_2) //校验通过,开始正式解析 + if( crc16 == crc16_2) //校验通过,开始正式解析 { if(factorytest_mode_flag == 0 && header.submod != BLE_TEST_CMD_COMMON_SUB_MODE_SWITCH_MODE) return ERRCODE_FAIL; diff --git a/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp b/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp index 0b3241acf..f3987458e 100644 --- a/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp +++ b/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp @@ -511,7 +511,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); } diff --git a/code/sdk/drivers/peripheral/utils/custom_runtime.c b/code/sdk/drivers/peripheral/utils/custom_runtime.c index 1b5e8b484..50c068595 100644 --- a/code/sdk/drivers/peripheral/utils/custom_runtime.c +++ b/code/sdk/drivers/peripheral/utils/custom_runtime.c @@ -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; +} diff --git a/code/sdk/drivers/peripheral/utils/custom_runtime.h b/code/sdk/drivers/peripheral/utils/custom_runtime.h index b59af358c..ef2b6cb3c 100644 --- a/code/sdk/drivers/peripheral/utils/custom_runtime.h +++ b/code/sdk/drivers/peripheral/utils/custom_runtime.h @@ -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 } -- 2.17.1