Commit 07a32852 authored by 王金亮's avatar 王金亮

🐞 fix: 根据代码评审意见修改,蓝牙断连前先判断是否有蓝牙连接,获取最新蓝牙设备列表后,不再存入peer_addr中

parent 0bf6fdee
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "bt_app_main.h" #include "bt_app_main.h"
#include "esp_gap_bt_api.h" #include "esp_gap_bt_api.h"
#include <string.h> #include <string.h>
#include "app_Ble_User.h"
extern esp_bd_addr_t peer_addr; extern esp_bd_addr_t peer_addr;
#define TAG "APP_BLE_USER" #define TAG "APP_BLE_USER"
...@@ -139,7 +140,10 @@ void BT_User_Process(void ) ...@@ -139,7 +140,10 @@ void BT_User_Process(void )
/* */ /* */
uint8_t ODO_Clear_BLEinfo(void ) uint8_t ODO_Clear_BLEinfo(void )
{ {
if (Ble_User.Ble_Sts == Ble_Conn)
{
esp_hf_client_disconnect(peer_addr); esp_hf_client_disconnect(peer_addr);
}
uint8_t ret = 0; uint8_t ret = 0;
uint8_t bond_dev_num = esp_bt_gap_get_bond_device_num(); uint8_t bond_dev_num = esp_bt_gap_get_bond_device_num();
...@@ -149,7 +153,6 @@ uint8_t ODO_Clear_BLEinfo(void ) ...@@ -149,7 +153,6 @@ uint8_t ODO_Clear_BLEinfo(void )
if (dev_list != NULL) if (dev_list != NULL)
{ {
esp_bt_gap_get_bond_device_list(&bond_dev_num, dev_list); esp_bt_gap_get_bond_device_list(&bond_dev_num, dev_list);
memcpy(peer_addr, dev_list[0], 6);
if(bond_dev_num > 0) if(bond_dev_num > 0)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment