From bffabf0f756b1fd1cf07c9c20879b0a75f048744 Mon Sep 17 00:00:00 2001 From: penglei <1624952103@qq.com> Date: Thu, 4 Jul 2024 20:42:38 +0800 Subject: [PATCH] =?utf8?q?=E6=B7=BB=E5=8A=A0=E4=B9=85=E5=9D=90=E6=8F=90?= =?utf8?q?=E9=86=92=E9=97=B9=E9=92=9F=EF=BC=8C=E4=BC=98=E5=8C=96cat1?= =?utf8?q?=E8=93=9D=E7=89=99=E4=BA=A7=E6=B5=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../include/AlarmClockTimerConfig.h | 3 +- .../src/AlarmClockTimerConfig.cpp | 31 +++++++++- .../nativeui/sleep/include/SleepModel.h | 6 +- .../service/ble_service/blemoder/bletest.cpp | 2 + .../factorytest_protocol.c | 59 ++++++++----------- .../src/notify/sleep_notification.cpp | 2 +- .../peripheral/config/include/ConfigModelC.h | 5 +- .../peripheral/config/src/ConfigModel.cpp | 15 +++++ 8 files changed, 80 insertions(+), 43 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/alarmclocktimerconfig/include/AlarmClockTimerConfig.h b/code/sdk/application/wearable/fd230app/nativeui/alarmclocktimerconfig/include/AlarmClockTimerConfig.h index 978755cbc..c386badd5 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/alarmclocktimerconfig/include/AlarmClockTimerConfig.h +++ b/code/sdk/application/wearable/fd230app/nativeui/alarmclocktimerconfig/include/AlarmClockTimerConfig.h @@ -2,7 +2,7 @@ * @Author: penglei 1624952103@qq.com * @Date: 2024-06-07 11:18:25 * @LastEditors: penglei 1624952103@qq.com - * @LastEditTime: 2024-06-29 14:34:23 + * @LastEditTime: 2024-07-04 20:35:41 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/alarmclocktimerconfig/include/AlarmClockTimerConfig.h * @Description: * @@ -67,6 +67,7 @@ int32_t SetZeroAlarm(void); int32_t SetAlarm(AlarmType type, uint8_t week, uint8_t hour, uint8_t minute); int32_t AlarmGetCurrentTimeInfo(struct tm *timeInfo); void set_sleep_and_wake_time(void); +void set_sedentary_data(void); void get_sleep_time_notify(void); #ifdef __cplusplus } diff --git a/code/sdk/application/wearable/fd230app/nativeui/alarmclocktimerconfig/src/AlarmClockTimerConfig.cpp b/code/sdk/application/wearable/fd230app/nativeui/alarmclocktimerconfig/src/AlarmClockTimerConfig.cpp index 53f27d467..8aa3e0af0 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/alarmclocktimerconfig/src/AlarmClockTimerConfig.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/alarmclocktimerconfig/src/AlarmClockTimerConfig.cpp @@ -46,13 +46,21 @@ extern "C" static int sleep_notify_time = 0; static int sleep_time_hour = 0; static int sleep_time_min = 0; - + static int sedentary_switch = 0; + static int sedentary_time = 0; // 设置目标睡眠时间 void set_sleep_and_wake_time(void) { sleep_time = get_sleep_time_from_config_model(); wake_up_time = get_wake_up_time_from_config_model(); } + + void set_sedentary_data(void) + { + sedentary_switch = get_sedentary_switch_from_config_model(); + sedentary_time = get_sedentary_time_from_config_model(); + } + // 设置睡眠提醒时间 void get_sleep_time_notify(void) { @@ -266,17 +274,33 @@ extern "C" do_cywee_service_check_msg(CYWEE_SERVICE_CMD_SLEEPING_MODE, NULL); } // 退出睡眠模式 - if (curTime.tm_hour == ((wake_up_time & 0XFFFF0000) >> 16) && curTime.tm_min == (wake_up_time & 0X0000FFFF) && curTime.tm_sec == 0) + else if (curTime.tm_hour == ((wake_up_time & 0XFFFF0000) >> 16) && curTime.tm_min == (wake_up_time & 0X0000FFFF) && curTime.tm_sec == 0) { do_cywee_service_check_msg(CYWEE_SERVICE_CMD_GET_SLEEP_DATA, NULL); printf("起床啦!\r\n"); // 早安提醒 AlarmEventPublish(TOPIC_EVENT_SLEEPNOTE, (uint8_t *)sleep_notify_time, 4); // 设置状态为小睡 - OHOS::SleepModel::GetInstance().set_sleep_state(OHOS::SLEEPSTATE::WALK); + OHOS::SleepModel::GetInstance().set_sleep_state(OHOS::SLEEPSTATE::WAKE); LOS_Msleep(1000); do_cywee_service_check_msg(CYWEE_SERVICE_CMD_NAP_MODE, NULL); } + + if(sedentary_switch) + { + if (curTime.tm_hour == ((sedentary_time & 0XFF000000) >> 24) && curTime.tm_min == ((sedentary_time & 0X00FF0000) >> 16) && curTime.tm_sec == 0) + { + do_cywee_service_check_msg(CYWEE_SERVICE_CMD_GET_SLEEP_DATA, NULL); + LOS_Msleep(1000); + do_cywee_service_check_msg(CYWEE_SERVICE_CMD_NAP_SEDENTARY_MODE, NULL); + } + else if (curTime.tm_hour == ((sedentary_time & 0X0000FF00) >> 8) && curTime.tm_min == (sedentary_time & 0X000000FF) && curTime.tm_sec == 0) + { + do_cywee_service_check_msg(CYWEE_SERVICE_CMD_GET_SLEEP_DATA, NULL); + LOS_Msleep(1000); + do_cywee_service_check_msg(CYWEE_SERVICE_CMD_NAP_MODE, NULL); + } + } } // 心率周期检测 [0 1 5 10] @@ -333,6 +357,7 @@ extern "C" return ERRCODE_FAIL; } set_sleep_and_wake_time(); + set_sedentary_data(); get_sleep_time_notify(); 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 bedeebdfd..64a3af579 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/sleep/include/SleepModel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/sleep/include/SleepModel.h @@ -2,7 +2,7 @@ * @Author: penglei 1624952103@qq.com * @Date: 2024-06-26 19:36:48 * @LastEditors: penglei 1624952103@qq.com - * @LastEditTime: 2024-06-28 15:51:01 + * @LastEditTime: 2024-07-04 20:12:47 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/sleep/include/SleepModel.h * @Description: * @@ -71,7 +71,7 @@ namespace OHOS // 睡眠状态 enum class SLEEPSTATE { - WALK = 0, + WAKE = 0, SLEEPNOTIFY, SLEPP, }; @@ -125,7 +125,7 @@ namespace OHOS uint8_t sleep_total_time = 0; uint8_t goal_total_time = 0; - SLEEPSTATE sleepstate_ = SLEEPSTATE::WALK; + SLEEPSTATE sleepstate_ = SLEEPSTATE::WAKE; }; } diff --git a/code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp b/code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp index 36d6eed10..3b9c7c844 100644 --- a/code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp +++ b/code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp @@ -556,6 +556,8 @@ void set_sedent_param( msg_sedent_set_param_info_t * data) p_ConfigModel->set_condigData_Int(OHOS::ConfigModel::CONFIGMODEL_ITEM_SEDENTARY_INTERVAL,data->frequenc); + set_sedentary_data(); + return; } 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 1cd748dfa..698408ccd 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-07-02 17:31:37 + * @LastEditTime: 2024-07-04 17:33:35 * @FilePath: /FD230/code/sdk/application/wearable/service/factorytest_service/factorytest_protocol.c * @Description: * @@ -84,6 +84,8 @@ static uint32_t aging_time = 0; static uint8_t pwr_button_result = 0; static uint8_t func_button_result = 1; +static uint8_t hx3695_chip_id = 0; + static int CRC16_XMODEM(uint8_t *bytes,uint16_t length) { int crc = 0x0000; // initial value int polynomial = 0x1021; @@ -529,22 +531,10 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint if (testitem == 0x02) { //获取蓝牙地址 - uint8_t btaddr[64]={0}; - uint32_t len = 64; uint8_t send_data[7] = {0}; - uint8_t i = 1; - char *buf; - - uapi_get_btaddr((uint8_t*)btaddr,&len); + uint32_t len = 6; - PRINT("btaddr : %s \r\n",btaddr); - buf= strtok((char *)btaddr,":"); - - while(buf != NULL) - { - send_data[i++] = strtoul(buf,NULL,16); - buf = strtok(NULL,":"); - } + uapi_get_nv_btaddr(&send_data[1], &len); factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, BLE_TEST_CMD_SOFT_TEST_SUB_MODE_BLE, @@ -1151,12 +1141,13 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint //获取 ppg_id uint8_t ppg_id; uapi_ppg_get_id(&ppg_id); - + if(ppg_id == 0x65) + hx3695_chip_id = ppg_id; factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, BLE_TEST_CMD_SOFT_TEST_SUB_MODE_HRS, 0x01, - &ppg_id, - sizeof(ppg_id)); + &hx3695_chip_id, + sizeof(hx3695_chip_id)); } else if(testitem == 0x02) { @@ -1466,38 +1457,36 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint } else if(testitem == 0x03) { //查看sim卡插入状态 - uint8_t send_data[2] = {0}; - uint16_t len = sizeof(send_data); - - send_data[1] = uapi_dev_runtime_get_cat1_simstat(); + uint8_t send_data = 0; + send_data = uapi_dev_runtime_get_cat1_simstat(); factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, BLE_TEST_CMD_SOFT_TEST_SUB_MODE_CAT1, 0x03, - send_data, - 2); + &send_data, + 1); } else if(testitem == 0x04) { //查看信号强度 - uint8_t send_data[2] = {0}; + uint8_t send_data = 0; - send_data[1] = uapi_dev_runtime_get_cat1_signal(); + send_data = uapi_dev_runtime_get_cat1_signal(); factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, BLE_TEST_CMD_SOFT_TEST_SUB_MODE_CAT1, 0x04, - send_data, - 2); + &send_data, + 1); } else if(testitem == 0x05) { //查看网络类型 - uint8_t send_data[2] = {0}; - send_data[1] = uapi_dev_runtime_get_cat1_networtype(); + uint8_t send_data = 0; + send_data = uapi_dev_runtime_get_cat1_networtype(); factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, BLE_TEST_CMD_SOFT_TEST_SUB_MODE_CAT1, 0x05, - send_data, - 2); + &send_data, + 1); } else if(testitem == 0x06) { //查看iMei号 @@ -1514,8 +1503,12 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint //拨打电话 uint8_t send_data = 0x00; + char phone_number[12] = {0}; + for(int i = 0; i < 11; i++) + phone_number[i] = data[i] + '0'; + phone_number[11] = '\0'; - cat1_call_dial((char *)data); + cat1_call_dial(phone_number); factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, BLE_TEST_CMD_SOFT_TEST_SUB_MODE_CAT1, 0x07, diff --git a/code/sdk/application/wearable/service/msg_center/src/notify/sleep_notification.cpp b/code/sdk/application/wearable/service/msg_center/src/notify/sleep_notification.cpp index 9f955f901..4a3a3c4b5 100644 --- a/code/sdk/application/wearable/service/msg_center/src/notify/sleep_notification.cpp +++ b/code/sdk/application/wearable/service/msg_center/src/notify/sleep_notification.cpp @@ -81,7 +81,7 @@ namespace OHOS textId = STR_DISTURBNOTE; // 开启勿扰 ConfigModel::GetInstance()->SetDnotdisturb(true); break; - case SLEEPSTATE::WALK: + case SLEEPSTATE::WAKE: titleStr = SleepModel::GetInstance().get_walk_notifiy(); textId = STR_MORNNING; ConfigModel::GetInstance()->SetDnotdisturb(false); // 关闭勿扰 diff --git a/code/sdk/drivers/peripheral/config/include/ConfigModelC.h b/code/sdk/drivers/peripheral/config/include/ConfigModelC.h index dbcd21222..92f0412e7 100644 --- a/code/sdk/drivers/peripheral/config/include/ConfigModelC.h +++ b/code/sdk/drivers/peripheral/config/include/ConfigModelC.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-04-17 09:32:03 * @LastEditors: penglei 1624952103@qq.com - * @LastEditTime: 2024-06-28 18:27:45 + * @LastEditTime: 2024-07-04 20:08:17 * @FilePath: /FD230/code/sdk/drivers/peripheral/config/include/ConfigModelC.h */ #ifndef _CONFIG_MODEL_C_H_ @@ -97,7 +97,8 @@ void get_user_info_from_config_model(int user_info[5]); int get_sleep_time_from_config_model(void); int get_wake_up_time_from_config_model(void); - +int get_sedentary_switch_from_config_model(void); +int get_sedentary_time_from_config_model(void); //设置睡眠频率 void set_config_heart(int heartRateDetectionFreq); diff --git a/code/sdk/drivers/peripheral/config/src/ConfigModel.cpp b/code/sdk/drivers/peripheral/config/src/ConfigModel.cpp index 7223f9d5b..d95e91f26 100644 --- a/code/sdk/drivers/peripheral/config/src/ConfigModel.cpp +++ b/code/sdk/drivers/peripheral/config/src/ConfigModel.cpp @@ -1465,6 +1465,21 @@ void set_config_heart(int heartRateDetectionFreq) // 设置心率检测频率 OHOS::ConfigModel::GetInstance()->set_condigData_Int(OHOS::ConfigModel::CONFIGMODEL_ITEM_HEARTRATE_DETECTED, heartRateDetectionFreq); } +//获取久坐提醒开关 +int get_sedentary_switch_from_config_model(void) +{ + int sedentary_switch = 0; + sedentary_switch = OHOS::ConfigModel::GetInstance()->get_configData_int(OHOS::ConfigModel::CONFIGMODEL_ITEM_SEDENTARY_SWITCH); + return sedentary_switch; +} +//获取久坐提醒时间 +int get_sedentary_time_from_config_model(void) +{ + int sedentary_time = 0; + sedentary_time = OHOS::ConfigModel::GetInstance()->get_configData_int(OHOS::ConfigModel::CONFIGMODEL_ITEM_SEDENTARY_REMINDERTIME); + return sedentary_time; +} + #ifdef __cplusplus #if __cplusplus } -- 2.17.1