From 3d8c01a4601a2d205693844562c9aca5df72af8a Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E8=83=A1=E4=BC=A0=E5=86=9B?= <1224667075@qq.com> Date: Mon, 30 Sep 2024 04:45:14 +0000 Subject: [PATCH] Merge #1066 into sdk602patch0626 from refs/changes/1066/head MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Code review from 胡传军 * refs/changes/1066/head: (5 commits squashed) - 天气数据解析增加安全防护 防止数组越界 - Merge branch 'sdk602patch0626' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into 0626 - Merge branch 'sdk602patch0626' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into 0626 - ble解绑恢复出厂修改,仅清除配对,不做多余处理 - ble 配对修改 Signed-off-by: aliyun8003852482 <1224667075@qq.com> Reviewed-by: snickersun@163.com Merged-by: snickersun@163.com CR-link: https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230/change/1066 --- .../service/ble_service/bleservice/bleEvent.c | 15 ++++++++++++++- .../service/ble_service/bleservice/bleEvent.h | 2 ++ .../service/ble_service/bleservice/bleService.c | 4 +--- .../drivers/peripheral/utils/custom_cmd_service.c | 3 ++- 4 files changed, 19 insertions(+), 5 deletions(-) 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 fda66f29a..882d37105 100644 --- a/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c +++ b/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c @@ -606,6 +606,18 @@ errcode_t UnbindSucessCmd(uint8_t flag)//发送解绑指令,解绑界面调用 return sendok; } + +void watch_clean_pairs(void) +{ + if(0!=remove(PHONE_WATCH_CONFIG_PATH)) + { + printf("json remove fail\r\n"); + } + gap_ble_remove_all_pairs(); + gap_remove_all_pairs(); +} + + void getDeviceState(void)//获取设备状态 { bd_addr_t addr={0}; @@ -633,6 +645,7 @@ void clearPaireFlag(uint8_t flag) sendBleData(value,19); UnbindSucessCmd(1);//1确认解绑; + do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_TYPE_RESTORE_FACTORY_SETTING, NULL, 0);//恢复出厂 //uapi_reboot_device(); } @@ -2790,7 +2803,7 @@ uint8_t read_jsonHistory_weather(void) fclose(fp); return 0; } - + char *str = fgets((char *)buf,size + 1,fp); if(str!=NULL) { 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 675d7bb0a..e46f1927d 100644 --- a/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.h +++ b/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.h @@ -831,6 +831,8 @@ void reply_APP_SportPasueResetCmd(uint16_t time); void reply_APP_SportStopModeCmd(uint16_t time); +void watch_clean_pairs(void); + ///////////////////////////自定义文件传输协议///////////////////////////// #define OTA_FILE_MSG_CMD 0x0601 #define OTA_FILE_DATA_CMD 0x0602 diff --git a/code/sdk/application/wearable/service/ble_service/bleservice/bleService.c b/code/sdk/application/wearable/service/ble_service/bleservice/bleService.c index a4fb0d0fd..a5be1cc21 100644 --- a/code/sdk/application/wearable/service/ble_service/bleservice/bleService.c +++ b/code/sdk/application/wearable/service/ble_service/bleservice/bleService.c @@ -462,7 +462,7 @@ void svr_pair_result_cbt_cb(uint16_t conn_id, const bd_addr_t *addr, errcode_t s if(get_br_is_pair()) { bd_addr_t bdaddr={0}; - uapi_get_br_address(&addr); + uapi_get_br_address(&bdaddr); if(false==(bt_is_acl_connected(&bdaddr))) { if(cm_get_A2DP_switch() || cm_get_HFP_switch()) @@ -479,8 +479,6 @@ void svr_pair_result_cbt_cb(uint16_t conn_id, const bd_addr_t *addr, errcode_t s WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "uapi_a2dp_snk_connect!!! \r\n"); } } - int ret = gap_connect_remote_device(addr); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "gap_connect_remote_device!!! %X\r\n",ret); } } hand_watch_first_time_Paired(); diff --git a/code/sdk/drivers/peripheral/utils/custom_cmd_service.c b/code/sdk/drivers/peripheral/utils/custom_cmd_service.c index 854b1a6cf..23a4bd0a2 100644 --- a/code/sdk/drivers/peripheral/utils/custom_cmd_service.c +++ b/code/sdk/drivers/peripheral/utils/custom_cmd_service.c @@ -149,7 +149,8 @@ static void custom_cmd_service_check_task(void const *arg) case CUSTOM_CMD_MSG_TYPE_RESTORE_FACTORY_SETTING: { ble_Alipayunbind(); - UnbindSucessCmd(1);//1确认解绑 + // UnbindSucessCmd(1);//1确认解绑 + watch_clean_pairs(); uapi_restore_factory_setting(); } break; -- 2.17.1