From d0747c7cfb22d8ded7901a4a5a0f647d1eec781b Mon Sep 17 00:00:00 2001 From: hcj <1224667075@qq.com> Date: Tue, 18 Jun 2024 15:32:35 +0800 Subject: [PATCH] =?utf8?q?=E5=AF=B9=E6=8E=A5=E6=89=8B=E8=A1=A8=E5=AF=86?= =?utf8?q?=E7=A0=81=E5=8D=8F=E8=AE=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../service/ble_service/blemoder/bletest.cpp | 27 +++++++ .../service/ble_service/blemoder/bletest.h | 5 +- .../service/ble_service/bleservice/bleEvent.c | 75 +++++++++++++++++-- .../service/ble_service/bleservice/bleEvent.h | 1 + 4 files changed, 100 insertions(+), 8 deletions(-) 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 5f7eeff7f..e18f92d66 100644 --- a/code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp +++ b/code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp @@ -6,6 +6,10 @@ * History: \n * 2022-08-16, Create file. \n */ +#include +#include +#include +#include #include "wearable_log.h" #include "securec.h" #include "broadcast_service.h" @@ -63,6 +67,29 @@ extern "C" { #include "bletest.h" #include + + +void ble_set_password(uint8_t falg, char * data) +{ + OHOS::ConfigModel *p_ConfigModel = OHOS::ConfigModel::GetInstance(); + + p_ConfigModel->set_condigData_Int(OHOS::ConfigModel::CONFIGMODEL_ITEM_PASSWORD_SWITCH,falg); + + p_ConfigModel->set_condigData_String(OHOS::ConfigModel::CONFIGMODEL_ITEM_PASSWORD,data); + return; +} + +uint8_t ble_get_password(void) +{ + OHOS::ConfigModel *p_ConfigModel = OHOS::ConfigModel::GetInstance(); + std::string str =p_ConfigModel->get_configData_string(OHOS::ConfigModel::CONFIGMODEL_ITEM_PASSWORD); + + uint8_t falg =p_ConfigModel->get_configData_int(OHOS::ConfigModel::CONFIGMODEL_ITEM_PASSWORD_SWITCH); + + return falg; + +} + void set_sedent_param( msg_sedent_set_param_info_t * data) { OHOS::ConfigModel *p_ConfigModel = OHOS::ConfigModel::GetInstance(); diff --git a/code/sdk/application/wearable/service/ble_service/blemoder/bletest.h b/code/sdk/application/wearable/service/ble_service/blemoder/bletest.h index 37bae6960..136b771cd 100644 --- a/code/sdk/application/wearable/service/ble_service/blemoder/bletest.h +++ b/code/sdk/application/wearable/service/ble_service/blemoder/bletest.h @@ -227,8 +227,9 @@ bool dial_file_save(void); void set_sedent_param( msg_sedent_set_param_info_t * data); void get_sedent_param( msg_sedent_set_param_info_t * data); - - +///////////////////////手表密码////////////////////////// +void ble_set_password(uint8_t falg, char * data); +uint8_t ble_get_password(void); #ifdef __cplusplus #if __cplusplus } diff --git a/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c b/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c index ccf32a5f6..6018a59ab 100644 --- a/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c +++ b/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c @@ -1534,6 +1534,39 @@ void SetAlarmDataCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totalData, } +void SetpasswordCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totalData,uint8_t crcvalue)//获取app下发的屏幕参数 +{ + uint32_t tmp = 1; + uint16_t tmp_data = 1; + uint8_t sendBuf[19]; + memset(sendBuf,0,19); + sendBuf[0] = 0x72; + sendBuf[1] = 0x02; + sendBuf[2] = 0x1c; + memcpy(sendBuf+3,&tmp,4); + memcpy(sendBuf+7,&tmp,4); + memcpy(sendBuf+11,&tmp,4); + memcpy(sendBuf+15,&tmp_data,2); + + if(Check_CRC(data,len,crcvalue)) + { + char* buf[6]={0}; + memcpy(buf,&data[1],6);// + + ble_set_password(data[0],buf); + printf("%s\r\n",&data[1]); + + sendBuf[17] = 1; + sendBuf[18] = Calculate_CRC(sendBuf,18); + sendBleData(sendBuf,19); + } + else + { + sendBuf[17] = 0; + sendBuf[18] = Calculate_CRC(sendBuf,18); + sendBleData(sendBuf,19); + } +} void GetWatchLcdParamCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totalData,uint8_t crcvalue)//获取app下发的屏幕参数 @@ -2268,14 +2301,13 @@ void type2AE4Data(ble_read_data *buffer_handle,uint8_t *buf_cmd,uint8_t *data,ui getAPPaddressbook(typeID,data,datalen,totalData,crcvalue); break; case SET_ALARM_DATA_CMD: - SetAlarmDataCmd(typeID,data,datalen,totalData,crcvalue); break; case SET_OTHER_TARGET_CMD: GetOtherTarget(typeID,data,datalen,totalData,crcvalue); break; case SET_PASSWORD_CMD: - + SetpasswordCmd(typeID,data,datalen,totalData,crcvalue); break; case SET_SEDENTARINESS_PARAM_CMD: SetsedentarinessSetParamCmd(typeID,data,datalen,totalData,crcvalue); @@ -3483,9 +3515,6 @@ static void GetPowerOffCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *tota } - - - //app发送公英制单位 static void GetMetricCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totaldata,uint8_t crcvalue) { @@ -3707,8 +3736,36 @@ static void GetTargetOtherCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *t value[18] = Calculate_CRC(value,18); sendBleData(value,19); } -} +} +static void GetPasswordCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totaldata,uint8_t crcvalue) +{ + uint8_t value[26]; + memset(value,0,26); + uint32_t tmp = 1; + uint32_t datalen = 6; + uint16_t tmp_data = 6; + value[0] = 0x72; + value[1] = 0x01; + value[2] = 0x2f; + memcpy(value+3,&tmp,4); + memcpy(value+7,&datalen,4); + memcpy(value+11,&tmp,4); + memcpy(value+15,&tmp_data,2); + if(1) + { + uint8_t data=ble_get_password(); + memcpy(&value[17],&data,1);// + + value[18] = Calculate_CRC(value,18); + sendBleData(value,19); + }else + { + value[17] = 0; + value[18] = Calculate_CRC(value,18); + sendBleData(value,19); + } +} //app发送解除配对消息 static void UnpairMessCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totaldata,uint8_t crcvalue) { @@ -4319,6 +4376,10 @@ void type2AE3Data(ble_read_data *buffer_handle,uint8_t *cmd_buf ,uint8_t *data,u case SYN_DATA_END_CMD: //app发送同步数据结束消息 GetSynDataEndCmd(cmd,data,datalen,totaldata,crcvalue); break; + case GET_PASSWORD_CMD: //获取手表密码 + GetPasswordCmd(cmd,data,datalen,totaldata,crcvalue); + break; + case SYN_HEART_HISTORY_DATA_CMD://同步心率历史数据 //heartDataCmd(cmd,data,datalen,totaldata,crcvalue); case SYN_SPO2_HISTORY_DATA_CMD://同步血氧历史数据 @@ -5453,6 +5514,8 @@ static errcode_t install_dial(void) install_Register_dial(namebuf,ble_dial_uid); + ble_set_dial_by_id(ble_dial_uid); + if ( ret == ERRCODE_SUCC) return ERRCODE_SUCC; else diff --git a/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.h b/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.h index 0657e1995..7571f8015 100644 --- a/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.h +++ b/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.h @@ -80,6 +80,7 @@ void cameram_send_data(void); #define GET_OTHER_TARGET_CMD 0x012C //其他目标设置 #define GET_UNPAIR_CMD 0x012D //发送解除配对消息 #define SYN_DATA_END_CMD 0x012E //app发送同步数据结束消息 +#define GET_PASSWORD_CMD 0x012F //app获取手机密码 #define ENTER_FACTORY_TEST_CMD 0x0130 //进入工厂测试模式 #define GET_SEDENT_CMD 0x0131 //获取久坐提醒设置 #define SYN_HEART_HISTORY_DATA_CMD 0x0140 //同步心率历史数据 -- 2.17.1