From cb4d628ee4263c72ea378a57c1578b579ff3794b Mon Sep 17 00:00:00 2001 From: penglei <1624952103@qq.com> Date: Mon, 11 Nov 2024 17:13:57 +0800 Subject: [PATCH] =?utf8?q?debug=E7=95=8C=E9=9D=A2=E6=B7=BB=E5=8A=A0?= =?utf8?q?=E4=BD=A9=E6=88=B4=E4=BF=A1=E6=81=AF,=E4=BC=98=E5=8C=96=E5=BF=83?= =?utf8?q?=E7=8E=87=E9=87=87=E6=A0=B7=E5=A4=84=E7=90=86=EF=BC=8C=E5=8A=A0?= =?utf8?q?=E5=BF=AB=E8=BF=9B=E5=85=A5=E4=BA=A7=E6=B5=8B=E6=8C=87=E4=BB=A4?= =?utf8?q?=E8=BF=94=E5=9B=9E=E6=95=B0=E6=8D=AE=E9=80=9F=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../nativeui/sleep/include/SleepModel.h | 8 ++ .../nativeui/sleep/include/SleepModelC.h | 1 + .../nativeui/sleep/src/SleepModel.cpp | 80 ++++++++++++++++++- .../factorytest_protocol.c | 14 ++-- .../debug_output_notification.h | 5 +- .../debug_output_notification.cpp | 11 +++ .../drivers/peripheral/cywee/Inc/cywee_hal.h | 2 + .../drivers/peripheral/cywee/src/main_dml.c | 16 +++- .../peripheral/ppg/hx3695/hx3695_hrs_agc.c | 2 +- .../utils/custom_fileoperate_service.c | 9 +++ 10 files changed, 135 insertions(+), 13 deletions(-) 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 0b700654c..49ab135fc 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/sleep/include/SleepModel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/sleep/include/SleepModel.h @@ -38,6 +38,12 @@ namespace OHOS uint16_t total_time; // 总时长 } SLEEP_T; + typedef struct + { + uint32_t timestamp; //时间戳 + uint8_t stat; // 状态 + } SLEEP_STAT_T; + #pragma pack (pop) // bool save_nap_data(NAP_T *data); @@ -48,11 +54,13 @@ namespace OHOS void set_sleep_data(SLEEP_T *data); // bool save_sleep_data(SLEEP_T *data); bool read_sleep_data(SLEEP_T *data); + void read_wear_data(void); bool read_nap_data(NAP_T *data); // void clean_sleep_data(void); // bool create_sleep_folder(void); std::string get_sleep_asleep_time_str(void); std::string get_sleep_wake_time_str(void); + std::string get_wear_status_str(void); //void clean_sleep_file(void); // 睡眠状态 enum class SLEEPSTATE diff --git a/code/sdk/application/wearable/fd230app/nativeui/sleep/include/SleepModelC.h b/code/sdk/application/wearable/fd230app/nativeui/sleep/include/SleepModelC.h index 78dd4da61..9a2874675 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/sleep/include/SleepModelC.h +++ b/code/sdk/application/wearable/fd230app/nativeui/sleep/include/SleepModelC.h @@ -22,6 +22,7 @@ extern "C" void custom_sleep_model_updata(void); void update_sleep_data(uint32_t sleep_timestamp,uint32_t wake_timestamp,uint32_t totaltime); void update_nap_data(uint32_t sleep_timestamp,uint32_t wake_timestamp,uint32_t totaltime); + void custom_read_wear_data(void); #ifdef __cplusplus #if __cplusplus } 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 bb52bff36..0e58805cf 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-11-08 20:05:21 + * @LastEditTime: 2024-11-11 16:59:29 * @FilePath: * /FD230/code/sdk/application/wearable/fd230app/nativeui/sleep/src/SleepModel.cpp * @Description: @@ -53,6 +53,9 @@ extern "C" errcode_t uapi_get_TIME_STR(uint32_t time, char *p_time, extern "C" int get_sleep_time_from_config_model(void); extern "C" int get_wake_up_time_from_config_model(); + +static uint32_t len = 0; +static OHOS::SLEEP_STAT_T *wear_stat; namespace OHOS { #define SLEPPNOTIFY 20 @@ -94,6 +97,46 @@ namespace OHOS return S_ISREG(file_stat.st_mode); // 检查文件是否为普通文件 } + std::string get_wear_status_str(void) + { + std::string result; + std::string wear_status; + // 进行文件读取 + do_custom_fileoperate_service_check_msg( + CUSTOM_FILEOPERATE_MSG_TYPE_WEAR_DATA_READ, nullptr, 0); + LOS_Msleep(100); // 等待文件系统准备 + + if(len == 0) + return result; + + for(int i = 0; i < len/5; i++) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,"data.timestamp : %d , data.stat : %d", wear_stat[i].timestamp,wear_stat[i].stat); + if(wear_stat[i].stat) + wear_status = "已配戴"; + else + wear_status = "未配戴"; + + std::string timestr; + char labelTime[20] = {0}; + + if (uapi_get_TIME_STR(wear_stat[i].timestamp, labelTime, '.', ':', DATE_Y_M_D_H_M) != ERRCODE_SUCC) + { + timestr = "--"; + } + else + { + timestr = labelTime; + } + + result += wear_status + ":"+ timestr + "\n"; + } + free(wear_stat); + return result; // 返回结果字符串 + } + + + std::string get_sleep_asleep_time_str(void) { std::string timestr; @@ -126,6 +169,33 @@ namespace OHOS return timestr; } + void read_wear_data(void) + { + uint32_t size = 0; + len = uapi_get_file_size("user/userdata/wear.bin"); + if(!len) + return; + + wear_stat = (SLEEP_STAT_T *)malloc(len); + FILE *fp; + + fp = fopen("user/userdata/wear.bin", "rb"); + if (fp == NULL) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "wear file open failed"); + free(wear_stat); + return; + } + + size = fread(wear_stat, 1, len, fp); + if(size != len) + { + free(wear_stat); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "wear file read failed"); + } + fclose(fp); + } + bool read_sleep_data(SLEEP_T *data) { char day[12] = {0}; @@ -767,8 +837,6 @@ namespace OHOS #endif /* __cplusplus */ #endif /* __cplusplus */ - - void custom_read_sleep_data(void) { memset(&sleep_data, 0, sizeof(SLEEP_T)); @@ -781,6 +849,11 @@ namespace OHOS read_nap_data(&nap_data); } + void custom_read_wear_data(void) + { + read_wear_data(); + } + void custom_sleep_model_updata(void) { OHOS::SleepModel::GetInstance().ReInitData(); @@ -802,6 +875,7 @@ namespace OHOS nap_update_timestamp = nap_data.wake_up_timestamp; } + #ifdef __cplusplus #if __cplusplus } 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 f7fcaa719..d250bfb2f 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-11-05 17:18:36 + * @LastEditTime: 2024-11-11 17:08:33 * @FilePath: /FD230/code/sdk/application/wearable/service/factorytest_service/factorytest_protocol.c * @Description: * @@ -485,17 +485,19 @@ 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 svr_ble_adv_factory_test_start_param(); //设置蓝牙广播 避免出现连接问题 + + factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_COMMON, + BLE_TEST_CMD_COMMON_SUB_MODE_SWITCH_MODE, + 0x01, + send_data, + 1); uapi_hfp_connect_(); LOS_Msleep(500); uapi_a2dp_snk_connect_(); - factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_COMMON, - BLE_TEST_CMD_COMMON_SUB_MODE_SWITCH_MODE, - 0x01, - send_data, - 1); } else if (testitem == 0x02) { diff --git a/code/sdk/application/wearable/service/msg_center/include/notify/debug_output_notification/debug_output_notification.h b/code/sdk/application/wearable/service/msg_center/include/notify/debug_output_notification/debug_output_notification.h index 8720702b1..a48baba48 100644 --- a/code/sdk/application/wearable/service/msg_center/include/notify/debug_output_notification/debug_output_notification.h +++ b/code/sdk/application/wearable/service/msg_center/include/notify/debug_output_notification/debug_output_notification.h @@ -1,8 +1,8 @@ /* * @Author: luozheng 1732036298@qq.com * @Date: 2024-10-02 14:12:12 - * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-11-04 17:36:14 + * @LastEditors: penglei 1624952103@qq.com + * @LastEditTime: 2024-11-11 15:03:39 * @FilePath: /FD230/code/sdk/application/wearable/service/msg_center/include/notify/debug_output_notification.h */ #ifndef DEBUG_OUTPUT_NOTIFICATION_H @@ -40,6 +40,7 @@ namespace OHOS std::string get_battery_info(void); std::string get_shutdown_info(void); std::string get_sleep_time(void); + std::string get_wear_status(void); std::string get_free_memory(void); std::string get_nextday_log(void); std::string get_heart_rate(void); diff --git a/code/sdk/application/wearable/service/msg_center/src/notify/debug_output_notification/debug_output_notification.cpp b/code/sdk/application/wearable/service/msg_center/src/notify/debug_output_notification/debug_output_notification.cpp index a02b1c04a..0946b3bf2 100644 --- a/code/sdk/application/wearable/service/msg_center/src/notify/debug_output_notification/debug_output_notification.cpp +++ b/code/sdk/application/wearable/service/msg_center/src/notify/debug_output_notification/debug_output_notification.cpp @@ -151,6 +151,8 @@ namespace OHOS debugOutputItemInfo[index++] = {index, "uart_service_status"}; //Vote状态服务 debugOutputItemInfo[index++] = {index, "vote_service_status"}; + // 佩戴状态 + debugOutputItemInfo[index++] = {index, "wear_status"}; usedLen = index; /* -------------------------------- Add data -------------------------------- */ for (uint8_t i = 0; i < usedLen; i++) @@ -448,6 +450,12 @@ namespace OHOS return result; // 返回结果字符串 } + + // 获取佩戴状态 + std::string DebugOutputViewEventListener::get_wear_status(void) { + return get_wear_status_str(); // 返回结果字符串 + } + // 获取系统free内存 std::string DebugOutputViewEventListener::get_free_memory() { @@ -714,6 +722,9 @@ namespace OHOS case 14: str = get_current_vote_status(); break; + case 15: + str = get_wear_status(); + break; default: str = "--"; break; diff --git a/code/sdk/drivers/peripheral/cywee/Inc/cywee_hal.h b/code/sdk/drivers/peripheral/cywee/Inc/cywee_hal.h index 38c05a0ae..4f66b6416 100644 --- a/code/sdk/drivers/peripheral/cywee/Inc/cywee_hal.h +++ b/code/sdk/drivers/peripheral/cywee/Inc/cywee_hal.h @@ -579,6 +579,8 @@ void cywee_custom_save_sleep_data(void); void cywee_custom_save_nap_data(void); void cywee_reset_history_daily_data(void); void cywee_check_acc(void); + +void cywee_custom_save_wear_data(void); #pragma pack() diff --git a/code/sdk/drivers/peripheral/cywee/src/main_dml.c b/code/sdk/drivers/peripheral/cywee/src/main_dml.c index 33499daf5..9c25a5730 100644 --- a/code/sdk/drivers/peripheral/cywee/src/main_dml.c +++ b/code/sdk/drivers/peripheral/cywee/src/main_dml.c @@ -833,8 +833,12 @@ void cywee_wearstatus_update(int wearstatus) memset(&csd, 0, sizeof(CUSTOM_OFFBODY_DETECT)); csd.sensorType = CUSTOM_OFFBODY_DETECT; csd.fData[0] = wearstatus; + wear_status = wearstatus; CWM_CustomSensorInput(&csd); // CWM_OS_dbgPrintf("111wearstatus : %d\r\n",wearstatus); + + do_custom_fileoperate_service_check_msg( + CUSTOM_FILEOPERATE_MSG_TYPE_WEAR_DATA_SAVE, NULL, 0); #endif } @@ -1878,4 +1882,14 @@ void cywee_custom_save_nap_data(void) cywee_save_nap_data(sleep_time); uapi_dev_runtime_set_sleep_storage_status(0); } - \ No newline at end of file + +void cywee_custom_save_wear_data(void) +{ + SLEEP_STAT_T data; + uint32_t tm = 0; + uapi_get_timestampe_ss(&tm); + data.timestamp = tm; + data.stat = wear_status; + // CWM_OS_dbgPrintf("data.timestamp : %d , data.stat : %d\n", data.timestamp,data.stat); + uapi_save_file_data("user/userdata/wear.bin",&data,sizeof(SLEEP_STAT_T),"ab"); +} diff --git a/code/sdk/drivers/peripheral/ppg/hx3695/hx3695_hrs_agc.c b/code/sdk/drivers/peripheral/ppg/hx3695/hx3695_hrs_agc.c index ad21679e2..fe829129e 100644 --- a/code/sdk/drivers/peripheral/ppg/hx3695/hx3695_hrs_agc.c +++ b/code/sdk/drivers/peripheral/ppg/hx3695/hx3695_hrs_agc.c @@ -469,7 +469,7 @@ void hx3695_hrs_cal_init(void) void hx3695_hrs_cal_off(void) { uint16_t sample_rate = 25; /*config the data rate of chip alps2_fm ,uint is Hz*/ - uint32_t prf_clk_num = 32000/sample_rate*24/25; /*period in clk num, num = Fclk/fs */ + uint32_t prf_clk_num = 32000/sample_rate; /*period in clk num, num = Fclk/fs */ uint8_t data_avg_num = 0; hx3695_write_reg(0X2a, (uint8_t)prf_clk_num); // prf bit<7:0> hx3695_write_reg(0X2b, (uint8_t)(prf_clk_num>>8)); // prf bit<15:8> diff --git a/code/sdk/drivers/peripheral/utils/custom_fileoperate_service.c b/code/sdk/drivers/peripheral/utils/custom_fileoperate_service.c index 5dc455d01..32a02c4af 100644 --- a/code/sdk/drivers/peripheral/utils/custom_fileoperate_service.c +++ b/code/sdk/drivers/peripheral/utils/custom_fileoperate_service.c @@ -174,6 +174,15 @@ static void custom_fileoperate_service_check_task(void const *arg) // printf("[%d] %d\r\n",__LINE__,mail.data[0]); save_popup_windows_log_c(mail.data[0]); break; + + case CUSTOM_FILEOPERATE_MSG_TYPE_WEAR_DATA_READ: + custom_read_wear_data(); + break; + + case CUSTOM_FILEOPERATE_MSG_TYPE_WEAR_DATA_SAVE: + cywee_custom_save_wear_data(); + break; + default: PRINT("Unknown CUSTOM_FILE_OPERATE_MSG cmd 0x%02X \r\n", mail.cmd); break; -- 2.17.1