From 73663af03e1af26318fde3974b8e9befc9107172 Mon Sep 17 00:00:00 2001 From: penglei <1624952103@qq.com> Date: Sat, 23 Nov 2024 22:27:44 +0800 Subject: [PATCH] =?utf8?q?=E9=BB=98=E8=AE=A4=E5=85=B3=E9=97=AD=E5=BF=83?= =?utf8?q?=E7=8E=87=E5=B9=BF=E6=92=AD=EF=BC=8Cdebug=E7=95=8C=E9=9D=A2?= =?utf8?q?=E5=A2=9E=E5=8A=A0=E5=BF=83=E7=8E=87=E5=B9=BF=E6=92=AD=E5=BC=80?= =?utf8?q?=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../debug_output_notification.cpp | 31 +++++++++++++++++++ .../drivers/peripheral/ppg/hx3695/hx3695.c | 20 ++++++++---- .../drivers/peripheral/ppg/hx3695/hx3695.h | 2 ++ .../peripheral/ppg/service/ppg_service.cpp | 10 ++++++ .../peripheral/ppg/service/ppg_service.h | 6 ++-- 5 files changed, 61 insertions(+), 8 deletions(-) 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 78d7eaf56..13ffba3d5 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 @@ -57,6 +57,7 @@ #include #include #include "displaybrightness/include/DisplayBrightnessModel.h" +#include "ppg_service.h" namespace OHOS { /**************************************************************************************************** */ @@ -158,6 +159,8 @@ namespace OHOS debugOutputItemInfo[index++] = {index, "battery_percent"}; //离线日志开关控制窗口,需要采用 ./autobuild.sh uoffline 【CONFIG_DFX_SUPPORT_OFFLINE_LOG_FILE=1】编译才有效 debugOutputItemInfo[index++] = {index, "offline_log"}; + //心率广播 + debugOutputItemInfo[index++] = {index, "hrs_ble_swtich"}; usedLen = index; /* -------------------------------- Add data -------------------------------- */ @@ -729,6 +732,21 @@ namespace OHOS // viewIndex = GetCurViewIndex(); return true; //进行UI刷新 } + else if (viewId == "hrs_ble_switch") { + if (toggleButtonOffline) { + if (toggleButtonOffline->GetState() == false) { + send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_CLOSE_HRS_BLE); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"hrs_ble_switch false"); + } + else { + send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_OPEN_HRS_BLE); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"hrs_ble_switch true"); + } + } else { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"组件不存在"); + } + return true; //进行UI刷新 + } else // 如果点击的是列表中的itemview { DebugOutputItemView *debugOutputItemView = static_cast(&view); @@ -807,9 +825,22 @@ namespace OHOS if (toggleButtonOffline) { if (toggleButtonOffline->IsVisible() == false) { toggleButtonOffline->SetVisible(true); + toggleButtonOffline->SetViewId("offline_log_switch"); } } break; + case 18: + // str = get_hrs_ble_status(); + str = ""; + if(toggleButtonOffline) + { + if(toggleButtonOffline->IsVisible() == false) + { + toggleButtonOffline->SetViewId("hrs_ble_switch"); + toggleButtonOffline->SetVisible(true); + } + } + break; default: str = "--"; break; diff --git a/code/sdk/drivers/peripheral/ppg/hx3695/hx3695.c b/code/sdk/drivers/peripheral/ppg/hx3695/hx3695.c index efb52c575..bbdbee1e1 100644 --- a/code/sdk/drivers/peripheral/ppg/hx3695/hx3695.c +++ b/code/sdk/drivers/peripheral/ppg/hx3695/hx3695.c @@ -68,7 +68,7 @@ int32_t PPG_buf_vec[8]; // #include "sys_init.h" // #include "cwm_api.h" -#define HANKCREAT_APK 1 +static uint8_t hrs_ble_falg = 0; #define PPG_DATA_LEN_MAX 17 int32_t s_buf[256]; uint32_t cnt_num = 0; @@ -2715,6 +2715,17 @@ static void get_avg_hrs(int32_t hrs) } } +void hx3695_set_hrs_ble_swtich(uint8_t cmd) +{ + hrs_ble_falg = cmd; + // PRINT("hrs_ble_falg : %d \n",hrs_ble_falg); +} + +uint8_t hx3695_get_hrs_ble_swtich(void) +{ + uint8_t cmd = hrs_ble_falg; + return cmd; +} void hx3695_wearstatus_update(void) { @@ -3095,8 +3106,7 @@ void hx3695_hrs_ppg_Int_handle(void) ble_rawdata_send_handler(); #endif - -#if HANKCREAT_APK + if(hrs_ble_falg) { uint8_t encoded_hrm[PPG_DATA_LEN_MAX] = {0};//PPG_DATA_LEN_MAX>17会导致APP连接提示定义设备与所选类型不匹配 uint8_t red_bit = 0; @@ -3146,7 +3156,6 @@ void hx3695_hrs_ppg_Int_handle(void) // sizeof(encoded_hrm)/sizeof(encoded_hrm[0]), ATT_OP_NOTIFY);//heartrate } } -#endif //////////////////////////////////////////////////////////////////////////////////// @@ -3535,7 +3544,7 @@ void hx3695_spo2_ppg_Int_handle(void) } #endif -#if HANKCREAT_APK +if(hrs_ble_falg) { uint8_t encoded_hrm[PPG_DATA_LEN_MAX] = {0};//PPG_DATA_LEN_MAX>17会导致APP连接提示定义设备与所选类型不匹配 @@ -3589,7 +3598,6 @@ void hx3695_spo2_ppg_Int_handle(void) ble_ppgtest_server_send_input_report(encoded_hrm,PPG_DATA_LEN_MAX); } } -#endif ///////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/code/sdk/drivers/peripheral/ppg/hx3695/hx3695.h b/code/sdk/drivers/peripheral/ppg/hx3695/hx3695.h index cd2d55f07..228abb14b 100644 --- a/code/sdk/drivers/peripheral/ppg/hx3695/hx3695.h +++ b/code/sdk/drivers/peripheral/ppg/hx3695/hx3695.h @@ -299,6 +299,8 @@ void wear_mode_timeout_handler(void * p_context); void Efuse_Mode_Check(void); void hx3695_wearstatus_update(void); void hx3695_unwearstatus_update(void); +void hx3695_set_hrs_ble_swtich(uint8_t cmd); +uint8_t hx3695_get_hrs_ble_swtich(void); #include "hx3695_hal.h" #endif diff --git a/code/sdk/drivers/peripheral/ppg/service/ppg_service.cpp b/code/sdk/drivers/peripheral/ppg/service/ppg_service.cpp index 934be6382..0e4634fa3 100644 --- a/code/sdk/drivers/peripheral/ppg/service/ppg_service.cpp +++ b/code/sdk/drivers/peripheral/ppg/service/ppg_service.cpp @@ -331,6 +331,16 @@ static void ppg_service_check_task(void *arg) cmd = "spo2"; enable = 0; } + else if (mail == PPG_SERVICE_CMD_TYPE_OPEN_HRS_BLE) + { + hx3695_set_hrs_ble_swtich(1); + continue ; + } + else if (mail == PPG_SERVICE_CMD_TYPE_CLOSE_HRS_BLE) + { + hx3695_set_hrs_ble_swtich(0); + continue ; + } if (ppg_service_running_stat == true && enable ==1 ) { PRINT_ERR("ppg service already started! \r\n"); diff --git a/code/sdk/drivers/peripheral/ppg/service/ppg_service.h b/code/sdk/drivers/peripheral/ppg/service/ppg_service.h index ff1a26cfa..9e2f8ff80 100644 --- a/code/sdk/drivers/peripheral/ppg/service/ppg_service.h +++ b/code/sdk/drivers/peripheral/ppg/service/ppg_service.h @@ -1,8 +1,8 @@ /* * @Author: penglei 1624952103@qq.com * @Date: 2024-03-27 09:07:00 - * @LastEditors: SnickerSun snickersun@163.com - * @LastEditTime: 2024-07-09 16:49:38 + * @LastEditors: penglei 1624952103@qq.com + * @LastEditTime: 2024-11-23 22:07:09 * @FilePath: /FD230/code/sdk/drivers/peripheral/ppg/service/ppg_service.h * @Description: * @@ -43,6 +43,8 @@ extern "C" { #define PPG_SERVICE_CMD_TYPE_STOP_WEAR_MODE_TEST 0x21 #define PPG_SERVICE_CMD_TYPE_DO_LED_OFF_MODE_TEST 0x22 #define PPG_SERVICE_CMD_TYPE_DO_SINGLE_CHECK_MODE_TEST 0x23 +#define PPG_SERVICE_CMD_TYPE_OPEN_HRS_BLE 0x24 +#define PPG_SERVICE_CMD_TYPE_CLOSE_HRS_BLE 0x25 errcode_t uapi_ppg_service_init(void); void uapi_ppg_service_deinit(void); -- 2.17.1