Merge branch 'backport/cjh_v4.3' into 'release/v4.3'

Fixed some BLE bugs on bluedroid (backport v4.3)

See merge request espressif/esp-idf!20507
This commit is contained in:
Jiang Jiang Jian
2022-10-17 17:05:00 +08:00
18 changed files with 137 additions and 60 deletions

View File

@ -151,6 +151,13 @@ config BT_GATT_MAX_SR_PROFILES
help help
Maximum GATT Server Profiles Count Maximum GATT Server Profiles Count
config BT_GATT_MAX_SR_ATTRIBUTES
int "Max GATT Service Attributes"
depends on BT_GATTS_ENABLE && BT_BLUEDROID_ENABLED
range 1 500
default 100
help
Maximum GATT Service Attributes Count
choice BT_GATTS_SEND_SERVICE_CHANGE_MODE choice BT_GATTS_SEND_SERVICE_CHANGE_MODE
@ -186,6 +193,14 @@ config BT_GATTC_ENABLE
help help
This option can be close when the app work only on gatt server mode This option can be close when the app work only on gatt server mode
config BT_GATTC_MAX_CACHE_CHAR
int "Max gattc cache characteristic for discover"
depends on BT_GATTC_ENABLE
range 1 500
default 40
help
Maximum GATTC cache characteristic count
config BT_GATTC_CACHE_NVS_FLASH config BT_GATTC_CACHE_NVS_FLASH
bool "Save gattc cache data to nvs flash" bool "Save gattc cache data to nvs flash"
depends on BT_GATTC_ENABLE depends on BT_GATTC_ENABLE

View File

@ -85,7 +85,7 @@ esp_err_t esp_ble_gatts_create_service(esp_gatt_if_t gatts_if,
esp_err_t esp_ble_gatts_create_attr_tab(const esp_gatts_attr_db_t *gatts_attr_db, esp_err_t esp_ble_gatts_create_attr_tab(const esp_gatts_attr_db_t *gatts_attr_db,
esp_gatt_if_t gatts_if, esp_gatt_if_t gatts_if,
uint8_t max_nb_attr, uint16_t max_nb_attr,
uint8_t srvc_inst_id) uint8_t srvc_inst_id)
{ {
btc_msg_t msg = {0}; btc_msg_t msg = {0};
@ -93,6 +93,11 @@ esp_err_t esp_ble_gatts_create_attr_tab(const esp_gatts_attr_db_t *gatts_attr_db
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED); ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
if (max_nb_attr > ESP_GATT_ATTR_HANDLE_MAX) {
LOG_ERROR("The number of attribute should not be greater than CONFIG_BT_GATT_MAX_SR_ATTRIBUTES\n");
return ESP_ERR_INVALID_ARG;
}
msg.sig = BTC_SIG_API_CALL; msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_GATTS; msg.pid = BTC_PID_GATTS;
msg.act = BTC_GATTS_ACT_CREATE_ATTR_TAB; msg.act = BTC_GATTS_ACT_CREATE_ATTR_TAB;

View File

@ -26,7 +26,7 @@ extern "C" {
/// GATT INVALID HANDLE /// GATT INVALID HANDLE
#define ESP_GATT_ILLEGAL_HANDLE 0 #define ESP_GATT_ILLEGAL_HANDLE 0
/// GATT attribute max handle /// GATT attribute max handle
#define ESP_GATT_ATTR_HANDLE_MAX 100 #define ESP_GATT_ATTR_HANDLE_MAX UC_CONFIG_BT_GATT_MAX_SR_ATTRIBUTES
#define ESP_GATT_MAX_READ_MULTI_HANDLES 10 /* Max attributes to read in one request */ #define ESP_GATT_MAX_READ_MULTI_HANDLES 10 /* Max attributes to read in one request */

View File

@ -359,7 +359,7 @@ esp_err_t esp_ble_gatts_create_service(esp_gatt_if_t gatts_if,
*/ */
esp_err_t esp_ble_gatts_create_attr_tab(const esp_gatts_attr_db_t *gatts_attr_db, esp_err_t esp_ble_gatts_create_attr_tab(const esp_gatts_attr_db_t *gatts_attr_db,
esp_gatt_if_t gatts_if, esp_gatt_if_t gatts_if,
uint8_t max_nb_attr, uint16_t max_nb_attr,
uint8_t srvc_inst_id); uint8_t srvc_inst_id);
/** /**
* @brief This function is called to add an included service. This function have to be called between * @brief This function is called to add an included service. This function have to be called between

View File

@ -541,7 +541,6 @@ void bta_gattc_start_disc_char_dscp(UINT16 conn_id, tBTA_GATTC_SERV *p_srvc_cb)
if (bta_gattc_discover_procedure(conn_id, p_srvc_cb, GATT_DISC_CHAR_DSCPT) != 0) { if (bta_gattc_discover_procedure(conn_id, p_srvc_cb, GATT_DISC_CHAR_DSCPT) != 0) {
bta_gattc_char_dscpt_disc_cmpl(conn_id, p_srvc_cb); bta_gattc_char_dscpt_disc_cmpl(conn_id, p_srvc_cb);
} }
} }
void bta_gattc_update_include_service(const list_t *services) { void bta_gattc_update_include_service(const list_t *services) {
@ -693,7 +692,9 @@ static void bta_gattc_char_dscpt_disc_cmpl(UINT16 conn_id, tBTA_GATTC_SERV *p_sr
{ {
tBTA_GATTC_ATTR_REC *p_rec = NULL; tBTA_GATTC_ATTR_REC *p_rec = NULL;
if (--p_srvc_cb->total_char > 0) { /* Recursive function will cause BTU stack overflow when there are a large number of characteristic
* without descriptor to discover. So replace it with while function */
while (--p_srvc_cb->total_char > 0) {
p_rec = p_srvc_cb->p_srvc_list + (++ p_srvc_cb->cur_char_idx); p_rec = p_srvc_cb->p_srvc_list + (++ p_srvc_cb->cur_char_idx);
/* add the next characteristic into cache */ /* add the next characteristic into cache */
bta_gattc_add_char_to_cache (p_srvc_cb, bta_gattc_add_char_to_cache (p_srvc_cb,
@ -701,11 +702,14 @@ static void bta_gattc_char_dscpt_disc_cmpl(UINT16 conn_id, tBTA_GATTC_SERV *p_sr
p_rec->s_handle, p_rec->s_handle,
&p_rec->uuid, &p_rec->uuid,
p_rec->property); p_rec->property);
/* start to discover next characteristic for descriptor */
if (bta_gattc_discover_procedure(conn_id, p_srvc_cb, GATT_DISC_CHAR_DSCPT) == 0) {
/* send att req and wait for att rsp */
break;
}
}
/* start discoverying next characteristic for char descriptor */ if (p_srvc_cb->total_char == 0) /* all characteristic has been explored, start with next service if any */
bta_gattc_start_disc_char_dscp(conn_id, p_srvc_cb);
} else
/* all characteristic has been explored, start with next service if any */
{ {
#if (defined BTA_GATT_DEBUG && BTA_GATT_DEBUG == TRUE) #if (defined BTA_GATT_DEBUG && BTA_GATT_DEBUG == TRUE)
APPL_TRACE_ERROR("all char has been explored"); APPL_TRACE_ERROR("all char has been explored");
@ -772,7 +776,7 @@ static tBTA_GATT_STATUS bta_gattc_add_srvc_to_list(tBTA_GATTC_SERV *p_srvc_cb,
/* allocate bigger buffer ?? */ /* allocate bigger buffer ?? */
status = GATT_DB_FULL; status = GATT_DB_FULL;
APPL_TRACE_ERROR("service not added, no resources or wrong state"); APPL_TRACE_ERROR("service not added, no resources or wrong state, see CONFIG_BT_GATTC_MAX_CACHE_CHAR");
} }
return status; return status;
} }
@ -814,7 +818,7 @@ static tBTA_GATT_STATUS bta_gattc_add_char_to_list(tBTA_GATTC_SERV *p_srvc_cb,
} }
p_srvc_cb->next_avail_idx ++; p_srvc_cb->next_avail_idx ++;
} else { } else {
APPL_TRACE_ERROR("char not added, no resources"); APPL_TRACE_ERROR("char not added, no resources, see CONFIG_BT_GATTC_MAX_CACHE_CHAR");
/* allocate bigger buffer ?? */ /* allocate bigger buffer ?? */
status = BTA_GATT_DB_FULL; status = BTA_GATT_DB_FULL;
} }

View File

@ -270,7 +270,6 @@ typedef struct {
} tBTA_GATTC_ATTR_REC; } tBTA_GATTC_ATTR_REC;
#define BTA_GATTC_MAX_CACHE_CHAR 40
#define BTA_GATTC_ATTR_LIST_SIZE (BTA_GATTC_MAX_CACHE_CHAR * sizeof(tBTA_GATTC_ATTR_REC)) #define BTA_GATTC_ATTR_LIST_SIZE (BTA_GATTC_MAX_CACHE_CHAR * sizeof(tBTA_GATTC_ATTR_REC))
#ifndef BTA_GATTC_CACHE_SRVR_SIZE #ifndef BTA_GATTC_CACHE_SRVR_SIZE
@ -305,10 +304,10 @@ typedef struct {
tBTA_GATTC_ATTR_REC *p_srvc_list; tBTA_GATTC_ATTR_REC *p_srvc_list;
UINT8 cur_srvc_idx; UINT8 cur_srvc_idx;
UINT8 cur_char_idx; UINT16 cur_char_idx;
UINT8 next_avail_idx; UINT16 next_avail_idx;
UINT8 total_srvc; UINT8 total_srvc;
UINT8 total_char; UINT16 total_char;
UINT16 total_attr; UINT16 total_attr;
UINT8 srvc_hdl_chg; /* service handle change indication pending */ UINT8 srvc_hdl_chg; /* service handle change indication pending */
UINT16 attr_index; /* cahce NV saving/loading attribute index */ UINT16 attr_index; /* cahce NV saving/loading attribute index */

View File

@ -127,7 +127,7 @@ void btc_gatts_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
break; break;
} }
case BTC_GATTS_ACT_CREATE_ATTR_TAB: { case BTC_GATTS_ACT_CREATE_ATTR_TAB: {
uint8_t num_attr = src->create_attr_tab.max_nb_attr; uint16_t num_attr = src->create_attr_tab.max_nb_attr;
if (src->create_attr_tab.gatts_attr_db && (num_attr > 0)) { if (src->create_attr_tab.gatts_attr_db && (num_attr > 0)) {
dst->create_attr_tab.gatts_attr_db = (esp_gatts_attr_db_t *) osi_malloc(sizeof(esp_gatts_attr_db_t) * num_attr); dst->create_attr_tab.gatts_attr_db = (esp_gatts_attr_db_t *) osi_malloc(sizeof(esp_gatts_attr_db_t) * num_attr);
if (dst->create_attr_tab.gatts_attr_db) { if (dst->create_attr_tab.gatts_attr_db) {
@ -217,7 +217,7 @@ void btc_gatts_arg_deep_free(btc_msg_t *msg)
static void btc_gatts_act_create_attr_tab(esp_gatts_attr_db_t *gatts_attr_db, static void btc_gatts_act_create_attr_tab(esp_gatts_attr_db_t *gatts_attr_db,
esp_gatt_if_t gatts_if, esp_gatt_if_t gatts_if,
uint8_t max_nb_attr, uint16_t max_nb_attr,
uint8_t srvc_inst_id) uint8_t srvc_inst_id)
{ {
uint16_t uuid = 0; uint16_t uuid = 0;
@ -568,24 +568,24 @@ static void btc_gatts_inter_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data)
//save the service handle to the btc module after used //save the service handle to the btc module after used
//the attribute table method to creat a service //the attribute table method to creat a service
bta_to_btc_uuid(&btc_creat_tab_env.svc_uuid, &p_data->create.uuid); bta_to_btc_uuid(&btc_creat_tab_env.svc_uuid, &p_data->create.uuid);
uint8_t index = btc_creat_tab_env.handle_idx; uint16_t index = btc_creat_tab_env.handle_idx;
btc_creat_tab_env.svc_start_hdl = p_data->create.service_id; btc_creat_tab_env.svc_start_hdl = p_data->create.service_id;
btc_creat_tab_env.handles[index] = p_data->create.service_id; btc_creat_tab_env.handles[index] = p_data->create.service_id;
break; break;
} }
case BTA_GATTS_ADD_INCL_SRVC_EVT: { case BTA_GATTS_ADD_INCL_SRVC_EVT: {
uint8_t index = btc_creat_tab_env.handle_idx; uint16_t index = btc_creat_tab_env.handle_idx;
btc_creat_tab_env.handles[index] = p_data->add_result.attr_id; btc_creat_tab_env.handles[index] = p_data->add_result.attr_id;
break; break;
} }
case BTA_GATTS_ADD_CHAR_EVT: { case BTA_GATTS_ADD_CHAR_EVT: {
uint8_t index = btc_creat_tab_env.handle_idx; uint16_t index = btc_creat_tab_env.handle_idx;
btc_creat_tab_env.handles[index] = p_data->add_result.attr_id - 1; btc_creat_tab_env.handles[index] = p_data->add_result.attr_id - 1;
btc_creat_tab_env.handles[index+1] = p_data->add_result.attr_id; btc_creat_tab_env.handles[index+1] = p_data->add_result.attr_id;
break; break;
} }
case BTA_GATTS_ADD_CHAR_DESCR_EVT: { case BTA_GATTS_ADD_CHAR_DESCR_EVT: {
uint8_t index = btc_creat_tab_env.handle_idx; uint16_t index = btc_creat_tab_env.handle_idx;
btc_creat_tab_env.handles[index] = p_data->add_result.attr_id; btc_creat_tab_env.handles[index] = p_data->add_result.attr_id;
break; break;
} }

View File

@ -63,7 +63,7 @@ typedef union {
struct create_attr_tab_args{ struct create_attr_tab_args{
esp_gatt_if_t gatts_if; esp_gatt_if_t gatts_if;
uint8_t srvc_inst_id; uint8_t srvc_inst_id;
uint8_t max_nb_attr; uint16_t max_nb_attr;
esp_gatts_attr_db_t *gatts_attr_db; esp_gatts_attr_db_t *gatts_attr_db;
}create_attr_tab; }create_attr_tab;
@ -157,8 +157,8 @@ typedef struct {
esp_bt_uuid_t svc_uuid; esp_bt_uuid_t svc_uuid;
bool is_tab_creat_svc; bool is_tab_creat_svc;
bool is_use_svc; bool is_use_svc;
uint8_t num_handle; uint16_t num_handle;
uint8_t handle_idx; uint16_t handle_idx;
uint16_t handles[ESP_GATT_ATTR_HANDLE_MAX]; uint16_t handles[ESP_GATT_ATTR_HANDLE_MAX];
} esp_btc_creat_tab_t; } esp_btc_creat_tab_t;

View File

@ -121,6 +121,12 @@
#endif #endif
//GATTC CACHE //GATTC CACHE
#ifdef CONFIG_BT_GATTC_MAX_CACHE_CHAR
#define UC_BT_GATTC_MAX_CACHE_CHAR CONFIG_BT_GATTC_MAX_CACHE_CHAR
#else
#define UC_BT_GATTC_MAX_CACHE_CHAR 40
#endif
#ifdef CONFIG_BT_GATTC_CACHE_NVS_FLASH #ifdef CONFIG_BT_GATTC_CACHE_NVS_FLASH
#define UC_BT_GATTC_CACHE_NVS_FLASH_ENABLED CONFIG_BT_GATTC_CACHE_NVS_FLASH #define UC_BT_GATTC_CACHE_NVS_FLASH_ENABLED CONFIG_BT_GATTC_CACHE_NVS_FLASH
#else #else
@ -245,6 +251,11 @@
#define UC_CONFIG_BT_GATT_MAX_SR_PROFILES 8 #define UC_CONFIG_BT_GATT_MAX_SR_PROFILES 8
#endif #endif
#ifdef CONFIG_BT_GATT_MAX_SR_ATTRIBUTES
#define UC_CONFIG_BT_GATT_MAX_SR_ATTRIBUTES CONFIG_BT_GATT_MAX_SR_ATTRIBUTES
#else
#define UC_CONFIG_BT_GATT_MAX_SR_ATTRIBUTES 100
#endif
#ifdef CONFIG_BT_GATTS_SEND_SERVICE_CHANGE_MODE #ifdef CONFIG_BT_GATTS_SEND_SERVICE_CHANGE_MODE
#define UC_BT_GATTS_SEND_SERVICE_CHANGE_MODE CONFIG_BT_GATTS_SEND_SERVICE_CHANGE_MODE #define UC_BT_GATTS_SEND_SERVICE_CHANGE_MODE CONFIG_BT_GATTS_SEND_SERVICE_CHANGE_MODE

View File

@ -21,7 +21,6 @@
#define BT_TARGET_H #define BT_TARGET_H
#include <bt_common.h> #include <bt_common.h>
#include "soc/soc_caps.h"
#ifndef BUILDCFG #ifndef BUILDCFG
#define BUILDCFG #define BUILDCFG
@ -258,11 +257,6 @@
#define BLE_ESTABLISH_LINK_CONNECTION_TIMEOUT UC_BT_BLE_ESTAB_LINK_CONN_TOUT #define BLE_ESTABLISH_LINK_CONNECTION_TIMEOUT UC_BT_BLE_ESTAB_LINK_CONN_TOUT
#endif #endif
#ifdef SOC_BLE_DONT_UPDATE_OWN_RPA
#define BLE_UPDATE_BLE_ADDR_TYPE_RPA FALSE
#else
#define BLE_UPDATE_BLE_ADDR_TYPE_RPA TRUE
#endif
//------------------Added from bdroid_buildcfg.h--------------------- //------------------Added from bdroid_buildcfg.h---------------------
#ifndef L2CAP_EXTFEA_SUPPORTED_MASK #ifndef L2CAP_EXTFEA_SUPPORTED_MASK
#define L2CAP_EXTFEA_SUPPORTED_MASK (L2CAP_EXTFEA_ENH_RETRANS | L2CAP_EXTFEA_STREAM_MODE | L2CAP_EXTFEA_NO_CRC | L2CAP_EXTFEA_FIXED_CHNLS) #define L2CAP_EXTFEA_SUPPORTED_MASK (L2CAP_EXTFEA_ENH_RETRANS | L2CAP_EXTFEA_STREAM_MODE | L2CAP_EXTFEA_NO_CRC | L2CAP_EXTFEA_FIXED_CHNLS)
@ -1171,15 +1165,27 @@
#endif #endif
#ifndef BTM_BLE_ADV_TX_POWER #ifndef BTM_BLE_ADV_TX_POWER
#if defined(CONFIG_IDF_TARGET_ESP32) || defined(CONFIG_IDF_TARGET_ESP32S3)
#define BTM_BLE_ADV_TX_POWER {-12, -9, -6, -3, 0, 3, 6, 9} #define BTM_BLE_ADV_TX_POWER {-12, -9, -6, -3, 0, 3, 6, 9}
#else
#define BTM_BLE_ADV_TX_POWER {-27, -21, -18, -15, -12, -9, -6, -3, 0, 3, 6, 9, 12, 15, 18}
#endif
#endif #endif
#ifndef BTM_TX_POWER #ifndef BTM_TX_POWER
#if defined(CONFIG_IDF_TARGET_ESP32) || defined(CONFIG_IDF_TARGET_ESP32S3)
#define BTM_TX_POWER {-12, -9, -6, -3, 0, 3, 6, 9} #define BTM_TX_POWER {-12, -9, -6, -3, 0, 3, 6, 9}
#else
#define BTM_TX_POWER {-27, -24, -21, -18, -15, -12, -9, -6, -3, 0, 3, 6, 9, 12, 15, 18}
#endif
#endif #endif
#ifndef BTM_TX_POWER_LEVEL_MAX #ifndef BTM_TX_POWER_LEVEL_MAX
#if defined(CONFIG_IDF_TARGET_ESP32) || defined(CONFIG_IDF_TARGET_ESP32S3)
#define BTM_TX_POWER_LEVEL_MAX 7 #define BTM_TX_POWER_LEVEL_MAX 7
#else
#define BTM_TX_POWER_LEVEL_MAX 15
#endif
#endif #endif
@ -2119,6 +2125,10 @@ The maximum number of payload octets that the local device can receive in a sing
#define BTA_DM_AVOID_A2DP_ROLESWITCH_ON_INQUIRY FALSE #define BTA_DM_AVOID_A2DP_ROLESWITCH_ON_INQUIRY FALSE
#endif #endif
#ifndef BTA_GATTC_MAX_CACHE_CHAR
#define BTA_GATTC_MAX_CACHE_CHAR UC_BT_GATTC_MAX_CACHE_CHAR
#endif
/****************************************************************************** /******************************************************************************
** **
** Tracing: Include trace header file here. ** Tracing: Include trace header file here.

View File

@ -56,8 +56,9 @@ static void btm_gen_resolve_paddr_cmpl(tSMP_ENC *p)
p_cb->private_addr[5] = p->param_buf[0]; p_cb->private_addr[5] = p->param_buf[0];
p_cb->private_addr[4] = p->param_buf[1]; p_cb->private_addr[4] = p->param_buf[1];
p_cb->private_addr[3] = p->param_buf[2]; p_cb->private_addr[3] = p->param_buf[2];
/* set it to controller */ /* set it to controller */
btsnd_hcic_ble_set_random_addr(p_cb->private_addr); btm_ble_set_random_addr(p_cb->private_addr);
p_cb->exist_addr_bit |= BTM_BLE_GAP_ADDR_BIT_RESOLVABLE; p_cb->exist_addr_bit |= BTM_BLE_GAP_ADDR_BIT_RESOLVABLE;
memcpy(p_cb->resolvale_addr, p_cb->private_addr, BD_ADDR_LEN); memcpy(p_cb->resolvale_addr, p_cb->private_addr, BD_ADDR_LEN);
@ -66,23 +67,6 @@ static void btm_gen_resolve_paddr_cmpl(tSMP_ENC *p)
p_cb->set_local_privacy_cback = NULL; p_cb->set_local_privacy_cback = NULL;
} }
if (btm_cb.ble_ctr_cb.inq_var.adv_mode == BTM_BLE_ADV_ENABLE){
BTM_TRACE_DEBUG("Advertise with new resolvable private address, now.");
/**
* Restart advertising, using new resolvable private address
*/
btm_ble_stop_adv();
btm_ble_start_adv();
}
if (btm_cb.ble_ctr_cb.inq_var.state == BTM_BLE_SCANNING){
BTM_TRACE_DEBUG("Scan with new resolvable private address, now.");
/**
* Restart scaning, using new resolvable private address
*/
btm_ble_stop_scan();
btm_ble_start_scan();
}
/* start a periodical timer to refresh random addr */ /* start a periodical timer to refresh random addr */
btu_stop_timer_oneshot(&p_cb->raddr_timer_ent); btu_stop_timer_oneshot(&p_cb->raddr_timer_ent);
#if (BTM_BLE_CONFORMANCE_TESTING == TRUE) #if (BTM_BLE_CONFORMANCE_TESTING == TRUE)

View File

@ -1018,9 +1018,7 @@ uint32_t BTM_BleUpdateOwnType(uint8_t *own_bda_type, tBTM_START_ADV_CMPL_CBACK *
} }
} else if(*own_bda_type == BLE_ADDR_PUBLIC_ID || *own_bda_type == BLE_ADDR_RANDOM_ID) { } else if(*own_bda_type == BLE_ADDR_PUBLIC_ID || *own_bda_type == BLE_ADDR_RANDOM_ID) {
if((btm_cb.ble_ctr_cb.addr_mgnt_cb.exist_addr_bit & BTM_BLE_GAP_ADDR_BIT_RESOLVABLE) == BTM_BLE_GAP_ADDR_BIT_RESOLVABLE) { if((btm_cb.ble_ctr_cb.addr_mgnt_cb.exist_addr_bit & BTM_BLE_GAP_ADDR_BIT_RESOLVABLE) == BTM_BLE_GAP_ADDR_BIT_RESOLVABLE) {
#if (BLE_UPDATE_BLE_ADDR_TYPE_RPA)
*own_bda_type = BLE_ADDR_RANDOM; *own_bda_type = BLE_ADDR_RANDOM;
#endif
btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type = BLE_ADDR_RANDOM; btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type = BLE_ADDR_RANDOM;
memcpy(btm_cb.ble_ctr_cb.addr_mgnt_cb.private_addr, btm_cb.ble_ctr_cb.addr_mgnt_cb.resolvale_addr, BD_ADDR_LEN); memcpy(btm_cb.ble_ctr_cb.addr_mgnt_cb.private_addr, btm_cb.ble_ctr_cb.addr_mgnt_cb.resolvale_addr, BD_ADDR_LEN);
btsnd_hcic_ble_set_random_addr(btm_cb.ble_ctr_cb.addr_mgnt_cb.resolvale_addr); btsnd_hcic_ble_set_random_addr(btm_cb.ble_ctr_cb.addr_mgnt_cb.resolvale_addr);
@ -4121,6 +4119,59 @@ tBTM_STATUS btm_ble_stop_adv(void)
return rt; return rt;
} }
tBTM_STATUS btm_ble_set_random_addr(BD_ADDR random_bda)
{
tBTM_STATUS rt = BTM_SUCCESS;
osi_mutex_lock(&adv_enable_lock, OSI_MUTEX_MAX_TIMEOUT);
osi_mutex_lock(&scan_enable_lock, OSI_MUTEX_MAX_TIMEOUT);
if (btm_cb.ble_ctr_cb.inq_var.adv_mode == BTM_BLE_ADV_ENABLE) {
if (btsnd_hcic_ble_set_adv_enable (BTM_BLE_ADV_DISABLE)) {
osi_sem_take(&adv_enable_sem, OSI_SEM_MAX_TIMEOUT);
rt = adv_enable_status;
} else {
rt = BTM_BAD_VALUE_RET;
}
}
if (BTM_BLE_IS_DISCO_ACTIVE(btm_cb.ble_ctr_cb.scan_activity)) {
if (btsnd_hcic_ble_set_scan_enable (BTM_BLE_SCAN_DISABLE, BTM_BLE_SCAN_DUPLICATE_DISABLE)) {
osi_sem_take(&scan_enable_sem, OSI_SEM_MAX_TIMEOUT);
rt = scan_enable_status;
} else {
rt = BTM_BAD_VALUE_RET;
}
}
if (rt == BTM_SUCCESS) {
btsnd_hcic_ble_set_random_addr(random_bda);
}
if (btm_cb.ble_ctr_cb.inq_var.adv_mode == BTM_BLE_ADV_ENABLE) {
if (btsnd_hcic_ble_set_adv_enable (BTM_BLE_ADV_ENABLE)) {
osi_sem_take(&adv_enable_sem, OSI_SEM_MAX_TIMEOUT);
rt = adv_enable_status;
} else {
rt = BTM_BAD_VALUE_RET;
}
}
if (BTM_BLE_IS_DISCO_ACTIVE(btm_cb.ble_ctr_cb.scan_activity)) {
if (btsnd_hcic_ble_set_scan_enable (BTM_BLE_SCAN_ENABLE, btm_cb.ble_ctr_cb.inq_var.scan_duplicate_filter)) {
osi_sem_take(&scan_enable_sem, OSI_SEM_MAX_TIMEOUT);
rt = scan_enable_status;
} else {
rt = BTM_BAD_VALUE_RET;
}
}
osi_mutex_unlock(&adv_enable_lock);
osi_mutex_unlock(&scan_enable_lock);
return rt;
}
/******************************************************************************* /*******************************************************************************
** **

View File

@ -240,12 +240,6 @@ BOOLEAN BTM_SecRegister(tBTM_APPL_INFO *p_cb_info)
if (memcmp(btm_cb.devcb.id_keys.ir, &temp_value, sizeof(BT_OCTET16)) == 0) { if (memcmp(btm_cb.devcb.id_keys.ir, &temp_value, sizeof(BT_OCTET16)) == 0) {
btm_ble_reset_id(); btm_ble_reset_id();
} }
#if (!BLE_UPDATE_BLE_ADDR_TYPE_RPA)
BD_ADDR peer_addr = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0};
BT_OCTET16 peer_irk = {0x0};
/* add local irk to controller */
btsnd_hcic_ble_add_device_resolving_list (BLE_ADDR_PUBLIC, peer_addr, peer_irk, btm_cb.devcb.id_keys.irk);
#endif
} else { } else {
BTM_TRACE_WARNING("%s p_cb_info->p_le_callback == NULL\n", __func__); BTM_TRACE_WARNING("%s p_cb_info->p_le_callback == NULL\n", __func__);
} }

View File

@ -422,6 +422,7 @@ tBTM_STATUS btm_ble_stop_adv(void);
tBTM_STATUS btm_ble_start_scan(void); tBTM_STATUS btm_ble_start_scan(void);
void btm_ble_create_ll_conn_complete (UINT8 status); void btm_ble_create_ll_conn_complete (UINT8 status);
void btm_ble_create_conn_cancel_complete (UINT8 *p); void btm_ble_create_conn_cancel_complete (UINT8 *p);
tBTM_STATUS btm_ble_set_random_addr(BD_ADDR random_bda);
/* LE security function from btm_sec.c */ /* LE security function from btm_sec.c */
#if SMP_INCLUDED == TRUE #if SMP_INCLUDED == TRUE

View File

@ -385,7 +385,7 @@ typedef UINT8 tBTM_BLE_AD_TYPE;
/* adv tx power level */ /* adv tx power level */
#define BTM_BLE_ADV_TX_POWER_MIN 0 /* minimum tx power */ #define BTM_BLE_ADV_TX_POWER_MIN 0 /* minimum tx power */
#define BTM_BLE_ADV_TX_POWER_MAX 7 /* maximum tx power */ #define BTM_BLE_ADV_TX_POWER_MAX BTM_TX_POWER_LEVEL_MAX /* maximum tx power */
typedef UINT8 tBTM_BLE_ADV_TX_POWER; typedef UINT8 tBTM_BLE_ADV_TX_POWER;
/* adv tx power in dBm */ /* adv tx power in dBm */

View File

@ -276,6 +276,3 @@
# define CAN_BRP_DIV_SUPPORTED SOC_TWAI_BRP_DIV_SUPPORTED # define CAN_BRP_DIV_SUPPORTED SOC_TWAI_BRP_DIV_SUPPORTED
# define CAN_BRP_DIV_THRESH SOC_TWAI_BRP_DIV_THRESH # define CAN_BRP_DIV_THRESH SOC_TWAI_BRP_DIV_THRESH
#endif #endif
/*------------------------------ BLE --------------------------------------------*/
#define SOC_BLE_DONT_UPDATE_OWN_RPA (1)

View File

@ -268,3 +268,6 @@
#define SOC_PM_SUPPORT_WIFI_PD (1) #define SOC_PM_SUPPORT_WIFI_PD (1)
#define SOC_PM_SUPPORT_BT_PD (1) #define SOC_PM_SUPPORT_BT_PD (1)
/*------------------------------ BLE --------------------------------------------*/
#define SOC_BLE_UPDATE_OWN_RPA (1)

View File

@ -184,3 +184,6 @@
#define SOC_SPI_MEM_SUPPORT_SW_SUSPEND (1) #define SOC_SPI_MEM_SUPPORT_SW_SUSPEND (1)
/*-------------------------- COEXISTENCE HARDWARE PTI CAPS -------------------------------*/ /*-------------------------- COEXISTENCE HARDWARE PTI CAPS -------------------------------*/
#define SOC_COEX_HW_PTI (1) #define SOC_COEX_HW_PTI (1)
/*------------------------------ BLE --------------------------------------------*/
#define SOC_BLE_UPDATE_OWN_RPA (1)