Merge branch 'bugfix/fix_blecibr25_119_v5.3' into 'release/v5.3'

fix(ble/bluedroid): Fixed extended adv restart failure during reconnection (v5.3)

See merge request espressif/esp-idf!39776
This commit is contained in:
Island
2025-06-13 10:59:27 +08:00
25 changed files with 429 additions and 278 deletions

View File

@ -1417,6 +1417,13 @@ config BT_BLE_FEAT_CONN_SUBRATING
help
Enable BLE connection subrating feature
config BT_BLE_VENDOR_HCI_EN
bool "Enable BLE Vendor HCI command and event"
depends on BT_BLE_ENABLED
default y
help
This enables BLE vendor HCI command and event
config BT_BLE_HIGH_DUTY_ADV_INTERVAL
bool "Enable BLE high duty advertising interval feature"
depends on BT_BLE_ENABLED

View File

@ -131,19 +131,6 @@ esp_err_t esp_ble_gap_stop_advertising(void)
return (btc_transfer_context(&msg, NULL, 0, NULL, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_gap_clear_advertising(void)
{
btc_msg_t msg;
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_GAP_BLE;
msg.act = BTC_GAP_BLE_ACT_CLEAR_ADV;
return (btc_transfer_context(&msg, NULL, 0, NULL, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
#endif // #if (BLE_42_ADV_EN == TRUE)
#endif // #if (BLE_42_FEATURE_SUPPORT == TRUE)
@ -1013,23 +1000,6 @@ esp_err_t esp_ble_gap_set_privacy_mode(esp_ble_addr_type_t addr_type, esp_bd_add
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_gap_set_csa_support(uint8_t csa_select)
{
btc_msg_t msg;
btc_ble_gap_args_t arg;
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_GAP_BLE;
msg.act = BTC_GAP_BLE_SET_CSA_SUPPORT;
arg.set_csa_support.csa_select = csa_select;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), NULL, NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
#if (BLE_50_FEATURE_SUPPORT == TRUE)
esp_err_t esp_ble_gap_read_phy(esp_bd_addr_t bd_addr)
@ -1713,6 +1683,7 @@ esp_err_t esp_ble_gap_set_periodic_adv_sync_trans_params(esp_bd_addr_t addr, con
}
#endif //#if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
#if (BLE_VENDOR_HCI_EN == TRUE)
esp_err_t esp_ble_gap_vendor_command_send(esp_ble_vendor_cmd_params_t *vendor_cmd_param)
{
btc_msg_t msg = {0};
@ -1741,7 +1712,7 @@ esp_err_t esp_ble_gap_vendor_command_send(esp_ble_vendor_cmd_params_t *vendor_cm
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_gap_set_vendor_event_mask(uint32_t event_mask)
esp_err_t esp_ble_gap_set_vendor_event_mask(esp_ble_vendor_evt_mask_t event_mask)
{
btc_msg_t msg = {0};
btc_ble_gap_args_t arg;
@ -1759,6 +1730,37 @@ esp_err_t esp_ble_gap_set_vendor_event_mask(uint32_t event_mask)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_gap_clear_advertising(void)
{
btc_msg_t msg;
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_GAP_BLE;
msg.act = BTC_GAP_BLE_ACT_CLEAR_ADV;
return (btc_transfer_context(&msg, NULL, 0, NULL, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_gap_set_csa_support(uint8_t csa_select)
{
btc_msg_t msg;
btc_ble_gap_args_t arg;
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_GAP_BLE;
msg.act = BTC_GAP_BLE_SET_CSA_SUPPORT;
arg.set_csa_support.csa_select = csa_select;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), NULL, NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
#endif // (BLE_VENDOR_HCI_EN == TRUE)
#if (BLE_FEAT_POWER_CONTROL_EN == TRUE)
esp_err_t esp_ble_gap_enhanced_read_transmit_power_level(uint16_t conn_handle, esp_ble_tx_power_phy_t phy)
{

View File

@ -282,8 +282,11 @@ typedef enum {
/// white list address type
typedef enum {
BLE_WL_ADDR_TYPE_PUBLIC = 0x00,
BLE_WL_ADDR_TYPE_RANDOM = 0x01,
BLE_WL_ADDR_TYPE_PUBLIC = 0x00, /*!< Public Device Address */
BLE_WL_ADDR_TYPE_RANDOM = 0x01, /*!< Random Device Address */
#if (CONFIG_BT_BLE_50_FEATURES_SUPPORTED)
BLE_WL_ADDR_TYPE_ANONYMOUS = 0xFF, /*!< Devices sending anonymous advertisements, use to enable anonymous advertising report for scanning */
#endif // (CONFIG_BT_BLE_50_FEATURES_SUPPORTED)
} esp_ble_wl_addr_type_t;
/// Used to exchange the encryption key in the init key & response key

View File

@ -1102,11 +1102,58 @@ typedef struct {
} esp_ble_gap_past_params_t;
#endif // #if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
typedef enum{
typedef enum {
ESP_BLE_NETWORK_PRIVACY_MODE = 0X00, /*!< Network Privacy Mode for peer device (default) */
ESP_BLE_DEVICE_PRIVACY_MODE = 0X01, /*!< Device Privacy Mode for peer device */
} esp_ble_privacy_mode_t;
#define ESP_BLE_VENDOR_SCAN_REQ_RECV_EVT_MASK BIT(0) /*!< Vendor BLE legacy SCAN_REQ received event mask */
#define ESP_BLE_VENDOR_CHMAP_UPDATE_EVT_MASK BIT(1) /*!< Vendor BLE channel map update event mask */
#define ESP_BLE_VENDOR_SLEEP_WAKEUP_EVT_MASK BIT(3) /*!< Vendor BLE sleep wakeup event mask */
#define ESP_BLE_VENDOR_CONN_REQ_RECV_EVT_MASK BIT(4) /*!< Vendor BLE CONNECT_IND and AUX_CONNECT_REQ received event mask */
#define ESP_BLE_VENDOR_CONN_RSP_RECV_EVT_MASK BIT(5) /*!< Vendor BLE AUX_CONNECT_RSP received event mask */
typedef uint32_t esp_ble_vendor_evt_mask_t;
#define ESP_BLE_VENDOR_PDU_RECV_EVT (0) /*!< Vendor BLE specify PDU received event */
#define ESP_BLE_VENDOR_CHAN_MAP_UPDATE_EVT (1) /*!< Vendor BLE channel map update complete event */
#define ESP_BLE_VENDOR_SLEEP_WAKEUP_EVT (2) /*!< Vendor BLE sleep wakeup event */
typedef uint8_t esp_ble_vendor_evt_t;
typedef enum {
ESP_BLE_VENDOR_PDU_SCAN_REQ = 0, /*!< SCAN_REQ PDU type */
ESP_BLE_VENDOR_PDU_CONN_REQ, /*!< CONNECT_IND and AUX_CONNECT_REQ PDU type */
ESP_BLE_VENDOR_PDU_CONN_RSP, /*!< AUX_CONNECT_RSP PDU type */
} esp_ble_vendor_pdu_t;
/**
* @brief BLE vendor event parameters union
*/
typedef union {
/**
* @brief ESP_BLE_VENDOR_PDU_RECV_EVT
*/
struct ble_pdu_recv_evt_param {
esp_ble_vendor_pdu_t type; /*!< The type of LE PDU */
uint8_t handle; /*!< The handle of advertising set */
esp_ble_addr_type_t addr_type; /*!< The address type of peer device */
esp_bd_addr_t peer_addr; /*!< The address of peer device */
} pdu_recv; /*!< Event parameter of ESP_BLE_VENDOR_PDU_RECV_EVT */
/**
* @brief ESP_BLE_VENDOR_CHAN_MAP_UPDATE_EVT
*/
struct ble_chan_map_update_evt_param {
uint8_t status; /*!< Indicate the channel map update status (HCI error code) */
uint16_t conn_handle; /*!< The connection handle */
esp_gap_ble_channels ch_map; /*!< The channel map after updated */
} chan_map_update; /*!< Event parameter of ESP_BLE_VENDOR_CHAN_MAP_UPDATE_EVT */
/**
* @brief ESP_BLE_VENDOR_SLEEP_WAKEUP_EVT
*/
struct ble_sleep_wakeup_evt_param {
// No parameters
} sleep_wakeup; /*!< Event parameter of ESP_BLE_VENDOR_SLEEP_WAKEUP_EVT */
} esp_ble_vendor_evt_param_t;
/**
* @brief path loss report parameters
*/
@ -1258,12 +1305,6 @@ typedef union {
struct ble_adv_stop_cmpl_evt_param {
esp_bt_status_t status; /*!< Indicate adv stop operation success status */
} adv_stop_cmpl; /*!< Event parameter of ESP_GAP_BLE_ADV_STOP_COMPLETE_EVT */
/**
* @brief ESP_GAP_BLE_ADV_CLEAR_COMPLETE_EVT
*/
struct ble_adv_clear_cmpl_evt_param {
esp_bt_status_t status; /*!< Indicate adv clear operation success status */
} adv_clear_cmpl; /*!< Event parameter of ESP_GAP_BLE_ADV_CLEAR_COMPLETE_EVT */
#endif // #if (BLE_42_FEATURE_SUPPORT == TRUE)
/**
* @brief ESP_GAP_BLE_SET_STATIC_RAND_ADDR_EVT
@ -1665,6 +1706,19 @@ typedef union {
esp_ble_dtm_update_evt_t update_evt; /*!< DTM state change event, 0x00: DTM TX start, 0x01: DTM RX start, 0x02:DTM end */
uint16_t num_of_pkt; /*!< number of packets received, only valid if update_evt is DTM_TEST_STOP_EVT and shall be reported as 0 for a transmitter */
} dtm_state_update; /*!< Event parameter of ESP_GAP_BLE_DTM_TEST_UPDATE_EVT */
/**
* @brief ESP_GAP_BLE_SET_PRIVACY_MODE_COMPLETE_EVT
*/
struct ble_set_privacy_mode_cmpl_evt_param {
esp_bt_status_t status; /*!< Indicate privacy mode set operation success status */
} set_privacy_mode_cmpl; /*!< Event parameter of ESP_GAP_BLE_SET_PRIVACY_MODE_COMPLETE_EVT */
#if (BLE_VENDOR_HCI_EN == TRUE)
/**
* @brief ESP_GAP_BLE_ADV_CLEAR_COMPLETE_EVT
*/
struct ble_adv_clear_cmpl_evt_param {
esp_bt_status_t status; /*!< Indicate adv clear operation success status */
} adv_clear_cmpl; /*!< Event parameter of ESP_GAP_BLE_ADV_CLEAR_COMPLETE_EVT */
/**
* @brief ESP_GAP_BLE_VENDOR_CMD_COMPLETE_EVT
*/
@ -1673,12 +1727,6 @@ typedef union {
uint16_t param_len; /*!< The length of parameter buffer */
uint8_t *p_param_buf; /*!< The point of parameter buffer */
} vendor_cmd_cmpl; /*!< Event parameter of ESP_GAP_BLE_VENDOR_CMD_COMPLETE_EVT */
/**
* @brief ESP_GAP_BLE_SET_PRIVACY_MODE_COMPLETE_EVT
*/
struct ble_set_privacy_mode_cmpl_evt_param {
esp_bt_status_t status; /*!< Indicate privacy mode set operation success status */
} set_privacy_mode_cmpl; /*!< Event parameter of ESP_GAP_BLE_SET_PRIVACY_MODE_COMPLETE_EVT */
/**
* @brief ESP_GAP_BLE_SET_CSA_SUPPORT_COMPLETE_EVT
*/
@ -1695,10 +1743,12 @@ typedef union {
* @brief ESP_GAP_BLE_VENDOR_HCI_EVT
*/
struct ble_vendor_hci_event_evt_param {
uint8_t subevt_code; /*!< Subevent code for vendor HCI event, the range is 0xC0 to 0xFF */
uint8_t param_len; /*!< The length of the event parameter buffer */
uint8_t *param_buf; /*!< The pointer of the event parameter buffer */
} vendor_hci_evt; /*!< Event parameter buffer of ESP_GAP_BLE_VENDOR_HCI_EVT */
esp_ble_vendor_evt_t subevt_code; /*!< Subevent code for BLE vendor HCI event */
esp_ble_vendor_evt_param_t param; /*!< Event parameter of BLE vendor HCI subevent */
uint8_t param_len; /*!< The length of the event parameter buffer (for internal use only) */
uint8_t *param_buf; /*!< The pointer of the event parameter buffer (for internal use only) */
} vendor_hci_evt; /*!< Event parameter of ESP_GAP_BLE_VENDOR_HCI_EVT */
#endif // #if (BLE_VENDOR_HCI_EN == TRUE)
#if (BLE_FEAT_POWER_CONTROL_EN == TRUE)
/**
* @brief ESP_GAP_BLE_ENH_READ_TRANS_PWR_LEVEL_EVT
@ -3032,14 +3082,13 @@ esp_err_t esp_ble_gap_set_csa_support(uint8_t csa_select);
/**
* @brief This function is used to control which vendor events are generated by the HCI for the Host.
*
* @param[in] event_mask: Bit0: Legacy scan request received event
* Bit1: Vendor channel map update complete event
* @param[in] event_mask: The BLE vendor HCI event mask
*
* @return
* - ESP_OK : success
* - other : failed
*/
esp_err_t esp_ble_gap_set_vendor_event_mask(uint32_t event_mask);
esp_err_t esp_ble_gap_set_vendor_event_mask(esp_ble_vendor_evt_mask_t event_mask);
/**
* @brief This function is used to read the current and maximum transmit power levels of the local Controller.

View File

@ -733,6 +733,7 @@ void bta_dm_cfg_coex_status (tBTA_DM_MSG *p_data)
}
#endif
#if (BLE_VENDOR_HCI_EN == TRUE)
void bta_dm_send_vendor_hci(tBTA_DM_MSG *p_data)
{
BTM_VendorSpecificCommand(p_data->vendor_hci_cmd.opcode,
@ -741,6 +742,28 @@ void bta_dm_send_vendor_hci(tBTA_DM_MSG *p_data)
p_data->vendor_hci_cmd.vendor_hci_cb);
}
void bta_dm_ble_gap_clear_adv(tBTA_DM_MSG *p_data)
{
if (BTM_BleClearAdv(p_data->ble_clear_adv.p_clear_adv_cback) == FALSE) {
if (p_data->ble_clear_adv.p_clear_adv_cback) {
(*p_data->ble_clear_adv.p_clear_adv_cback)(BTA_FAILURE);
}
}
}
void bta_dm_ble_gap_set_csa_support(tBTA_DM_MSG *p_data)
{
APPL_TRACE_API("%s, csa_select = %d", __func__, p_data->ble_set_csa_support.csa_select);
BTM_BleSetCsaSupport(p_data->ble_set_csa_support.csa_select, p_data->ble_set_csa_support.p_cback);
}
void bta_dm_ble_gap_set_vendor_evt_mask(tBTA_DM_MSG *p_data)
{
APPL_TRACE_API("%s, evt_mask = %d", __func__, p_data->ble_set_vendor_evt_mask.evt_mask);
BTM_BleSetVendorEventMask(p_data->ble_set_vendor_evt_mask.evt_mask, p_data->ble_set_vendor_evt_mask.p_cback);
}
#endif // #if (BLE_VENDOR_HCI_EN == TRUE)
/*******************************************************************************
**
** Function bta_dm_set_afh_channels
@ -5812,15 +5835,6 @@ void bta_dm_ble_gap_dtm_stop(tBTA_DM_MSG *p_data)
}
#endif // #if ((BLE_42_DTM_TEST_EN == TRUE) || (BLE_50_DTM_TEST_EN == TRUE))
void bta_dm_ble_gap_clear_adv(tBTA_DM_MSG *p_data)
{
if (BTM_BleClearAdv(p_data->ble_clear_adv.p_clear_adv_cback) == FALSE) {
if (p_data->ble_clear_adv.p_clear_adv_cback) {
(*p_data->ble_clear_adv.p_clear_adv_cback)(BTA_FAILURE);
}
}
}
void bta_dm_ble_gap_set_rpa_timeout(tBTA_DM_MSG *p_data)
{
APPL_TRACE_API("%s, rpa_timeout = %d", __func__, p_data->set_rpa_timeout.rpa_timeout);
@ -5843,18 +5857,6 @@ void bta_dm_ble_gap_set_privacy_mode(tBTA_DM_MSG *p_data)
p_data->ble_set_privacy_mode.privacy_mode, p_data->ble_set_privacy_mode.p_cback);
}
void bta_dm_ble_gap_set_csa_support(tBTA_DM_MSG *p_data)
{
APPL_TRACE_API("%s, csa_select = %d", __func__, p_data->ble_set_csa_support.csa_select);
BTM_BleSetCsaSupport(p_data->ble_set_csa_support.csa_select, p_data->ble_set_csa_support.p_cback);
}
void bta_dm_ble_gap_set_vendor_evt_mask(tBTA_DM_MSG *p_data)
{
APPL_TRACE_API("%s, evt_mask = %d", __func__, p_data->ble_set_vendor_evt_mask.evt_mask);
BTM_BleSetVendorEventMask(p_data->ble_set_vendor_evt_mask.evt_mask, p_data->ble_set_vendor_evt_mask.p_cback);
}
void bta_dm_read_ble_channel_map(tBTA_DM_MSG *p_data)
{
if (p_data && p_data->ch_map.read_ch_map_cb) {

View File

@ -231,6 +231,7 @@ void BTA_DmCfgCoexStatus(UINT8 op, UINT8 type, UINT8 status)
}
#endif
#if (BLE_VENDOR_HCI_EN == TRUE)
void BTA_DmsendVendorHciCmd(UINT16 opcode, UINT8 param_len, UINT8 *p_param_buf, tBTA_SEND_VENDOR_HCI_CMPL_CBACK p_vendor_cmd_complete_cback)
{
tBTA_DM_API_SEND_VENDOR_HCI_CMD *p_msg;
@ -246,6 +247,57 @@ void BTA_DmsendVendorHciCmd(UINT16 opcode, UINT8 param_len, UINT8 *p_param_buf,
}
}
/*******************************************************************************
**
** Function BTA_DmBleClearAdv
**
** Description This function is called to clear Advertising
**
** Parameters p_adv_data_cback : clear adv complete callback.
**
** Returns None
**
*******************************************************************************/
void BTA_DmBleClearAdv (tBTA_CLEAR_ADV_CMPL_CBACK *p_clear_adv_cback)
{
tBTA_DM_API_CLEAR_ADV *p_msg;
if ((p_msg = (tBTA_DM_API_CLEAR_ADV *)
osi_malloc(sizeof(tBTA_DM_API_CLEAR_ADV))) != NULL) {
p_msg->hdr.event = BTA_DM_API_BLE_CLEAR_ADV_EVT;
p_msg->p_clear_adv_cback = p_clear_adv_cback;
bta_sys_sendmsg(p_msg);
}
}
void BTA_DmBleGapSetCsaSupport(uint8_t csa_select, tBTA_SET_CSA_SUPPORT_CMPL_CBACK *p_callback)
{
tBTA_DM_API_BLE_SET_CSA_SUPPORT *p_msg;
if ((p_msg = (tBTA_DM_API_BLE_SET_CSA_SUPPORT *)osi_malloc(sizeof(tBTA_DM_API_BLE_SET_CSA_SUPPORT)))
!= NULL) {
p_msg->hdr.event = BTA_DM_API_BLE_SET_CSA_SUPPORT_EVT;
p_msg->csa_select = csa_select;
p_msg->p_cback = p_callback;
bta_sys_sendmsg(p_msg);
}
}
void BTA_DmBleGapSetVendorEventMask(uint32_t evt_mask, tBTA_SET_VENDOR_EVT_MASK_CBACK *p_callback)
{
tBTA_DM_API_BLE_SET_VENDOR_EVT_MASK *p_msg;
if ((p_msg = (tBTA_DM_API_BLE_SET_VENDOR_EVT_MASK *)osi_malloc(sizeof(tBTA_DM_API_BLE_SET_VENDOR_EVT_MASK)))
!= NULL) {
p_msg->hdr.event = BTA_DM_API_BLE_SET_VENDOR_EVT_MASK_EVT;
p_msg->evt_mask = evt_mask;
p_msg->p_cback = p_callback;
bta_sys_sendmsg(p_msg);
}
}
#endif // #if (BLE_VENDOR_HCI_EN == TRUE)
#if (CLASSIC_BT_INCLUDED == TRUE)
void BTA_DmConfigEir(tBTA_DM_EIR_CONF *eir_config)
@ -1896,30 +1948,6 @@ extern void BTA_DmBleBroadcast (BOOLEAN start, tBTA_START_STOP_ADV_CMPL_CBACK *p
bta_sys_sendmsg(p_msg);
}
}
/*******************************************************************************
**
** Function BTA_DmBleClearAdv
**
** Description This function is called to clear Advertising
**
** Parameters p_adv_data_cback : clear adv complete callback.
**
** Returns None
**
*******************************************************************************/
void BTA_DmBleClearAdv (tBTA_CLEAR_ADV_CMPL_CBACK *p_clear_adv_cback)
{
tBTA_DM_API_CLEAR_ADV *p_msg;
if ((p_msg = (tBTA_DM_API_CLEAR_ADV *)
osi_malloc(sizeof(tBTA_DM_API_CLEAR_ADV))) != NULL) {
p_msg->hdr.event = BTA_DM_API_BLE_CLEAR_ADV_EVT;
p_msg->p_clear_adv_cback = p_clear_adv_cback;
bta_sys_sendmsg(p_msg);
}
}
#endif // #if (BLE_42_ADV_EN == TRUE)
#endif
@ -3014,32 +3042,6 @@ void BTA_DmClearRandAddress(void)
}
}
void BTA_DmBleGapSetCsaSupport(uint8_t csa_select, tBTA_SET_CSA_SUPPORT_CMPL_CBACK *p_callback)
{
tBTA_DM_API_BLE_SET_CSA_SUPPORT *p_msg;
if ((p_msg = (tBTA_DM_API_BLE_SET_CSA_SUPPORT *)osi_malloc(sizeof(tBTA_DM_API_BLE_SET_CSA_SUPPORT)))
!= NULL) {
p_msg->hdr.event = BTA_DM_API_BLE_SET_CSA_SUPPORT_EVT;
p_msg->csa_select = csa_select;
p_msg->p_cback = p_callback;
bta_sys_sendmsg(p_msg);
}
}
void BTA_DmBleGapSetVendorEventMask(uint32_t evt_mask, tBTA_SET_VENDOR_EVT_MASK_CBACK *p_callback)
{
tBTA_DM_API_BLE_SET_VENDOR_EVT_MASK *p_msg;
if ((p_msg = (tBTA_DM_API_BLE_SET_VENDOR_EVT_MASK *)osi_malloc(sizeof(tBTA_DM_API_BLE_SET_VENDOR_EVT_MASK)))
!= NULL) {
p_msg->hdr.event = BTA_DM_API_BLE_SET_VENDOR_EVT_MASK_EVT;
p_msg->evt_mask = evt_mask;
p_msg->p_cback = p_callback;
bta_sys_sendmsg(p_msg);
}
}
#if (BLE_FEAT_POWER_CONTROL_EN == TRUE)
void BTA_DmBleGapEnhReadTransPwrLevel(uint16_t conn_handle, uint8_t phy)
{

View File

@ -67,7 +67,12 @@ const tBTA_DM_ACTION bta_dm_action[BTA_DM_MAX_EVT] = {
#if (ESP_COEX_VSC_INCLUDED == TRUE)
bta_dm_cfg_coex_status, /* BTA_DM_API_CFG_COEX_ST_EVT */
#endif
#if (BLE_VENDOR_HCI_EN == TRUE)
bta_dm_send_vendor_hci, /* BTA_DM_API_SEND_VENDOR_HCI_CMD_EVT */
bta_dm_ble_gap_clear_adv, /* BTA_DM_API_BLE_CLEAR_ADV_EVT */
bta_dm_ble_gap_set_csa_support, /* BTA_DM_API_BLE_SET_CSA_SUPPORT_EVT */
bta_dm_ble_gap_set_vendor_evt_mask, /* BTA_DM_API_BLE_SET_VENDOR_EVT_MASK_EVT */
#endif // #if (BLE_VENDOR_HCI_EN == TRUE)
#if (CLASSIC_BT_INCLUDED == TRUE)
bta_dm_config_eir, /* BTA_DM_API_CONFIG_EIR_EVT */
bta_dm_set_page_timeout, /* BTA_DM_API_PAGE_TO_SET_EVT */
@ -278,14 +283,9 @@ const tBTA_DM_ACTION bta_dm_action[BTA_DM_MAX_EVT] = {
#if ((BLE_42_DTM_TEST_EN == TRUE) || (BLE_50_DTM_TEST_EN == TRUE))
bta_dm_ble_gap_dtm_stop, /* BTA_DM_API_DTM_STOP_EVT */
#endif // #if ((BLE_42_DTM_TEST_EN == TRUE) || (BLE_50_DTM_TEST_EN == TRUE))
#if (BLE_42_ADV_EN == TRUE)
bta_dm_ble_gap_clear_adv, /* BTA_DM_API_BLE_CLEAR_ADV_EVT */
#endif // #if (BLE_42_ADV_EN == TRUE)
bta_dm_ble_gap_set_rpa_timeout, /* BTA_DM_API_SET_RPA_TIMEOUT_EVT */
bta_dm_ble_gap_add_dev_to_resolving_list, /* BTA_DM_API_ADD_DEV_TO_RESOLVING_LIST_EVT */
bta_dm_ble_gap_set_privacy_mode, /* BTA_DM_API_SET_PRIVACY_MODE_EVT */
bta_dm_ble_gap_set_csa_support, /* BTA_DM_API_BLE_SET_CSA_SUPPORT_EVT */
bta_dm_ble_gap_set_vendor_evt_mask, /* BTA_DM_API_BLE_SET_VENDOR_EVT_MASK_EVT */
bta_dm_read_ble_channel_map, /* BTA_DM_API_BLE_READ_CH_MAP_EVT */
#endif
#if (BLE_FEAT_ISO_EN == TRUE)

View File

@ -57,7 +57,12 @@ enum {
#if (ESP_COEX_VSC_INCLUDED == TRUE)
BTA_DM_API_CFG_COEX_ST_EVT,
#endif
#if (BLE_VENDOR_HCI_EN == TRUE)
BTA_DM_API_SEND_VENDOR_HCI_CMD_EVT,
BTA_DM_API_BLE_CLEAR_ADV_EVT,
BTA_DM_API_BLE_SET_CSA_SUPPORT_EVT,
BTA_DM_API_BLE_SET_VENDOR_EVT_MASK_EVT,
#endif // #if (BLE_VENDOR_HCI_EN == TRUE)
#if (CLASSIC_BT_INCLUDED == TRUE)
BTA_DM_API_CONFIG_EIR_EVT,
BTA_DM_API_PAGE_TO_SET_EVT,
@ -269,14 +274,9 @@ enum {
#if ((BLE_42_DTM_TEST_EN == TRUE) || (BLE_50_DTM_TEST_EN == TRUE))
BTA_DM_API_DTM_STOP_EVT,
#endif // #if ((BLE_42_DTM_TEST_EN == TRUE) || (BLE_50_DTM_TEST_EN == TRUE))
#if (BLE_42_ADV_EN == TRUE)
BTA_DM_API_BLE_CLEAR_ADV_EVT,
#endif // #if (BLE_42_ADV_EN == TRUE)
BTA_DM_API_SET_RPA_TIMEOUT_EVT,
BTA_DM_API_ADD_DEV_TO_RESOLVING_LIST_EVT,
BTA_DM_API_SET_PRIVACY_MODE_EVT,
BTA_DM_API_BLE_SET_CSA_SUPPORT_EVT,
BTA_DM_API_BLE_SET_VENDOR_EVT_MASK_EVT,
BTA_DM_API_BLE_READ_CH_MAP_EVT,
#endif
#if (BLE_FEAT_ISO_EN == TRUE)

View File

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@ -146,6 +146,18 @@ uint32_t btc_get_ble_status(void)
status |= BIT(BTC_BLE_STATUS_CONN);
}
// Number of active ACL connection
extern uint8_t btm_ble_acl_active_count(void);
if (btm_ble_acl_active_count()) {
status |= BIT(BTC_BLE_STATUS_CONN);
}
// Number of active L2C plcb
extern uint8_t l2cu_ble_plcb_active_count(void);
if (l2cu_ble_plcb_active_count()) {
status |= BIT(BTC_BLE_STATUS_CONN);
}
// Address resolve status
extern uint8_t btm_get_ble_addr_resolve_disable_status(void);
if (btm_get_ble_addr_resolve_disable_status()) {
@ -182,18 +194,6 @@ uint32_t btc_get_ble_status(void)
}
#endif
// Number of active ACL connection
extern uint8_t btm_acl_active_count(void);
if (btm_acl_active_count()) {
status |= BIT(BTC_BLE_STATUS_CONN);
}
// Number of active L2C plcb
extern uint8_t l2cu_plcb_active_count(void);
if (l2cu_plcb_active_count()) {
status |= BIT(BTC_BLE_STATUS_CONN);
}
#if (GATTC_INCLUDED == TRUE)
// Number of registered GATTC APP
extern uint8_t bta_gattc_cl_rcb_active_count(void);

View File

@ -467,25 +467,6 @@ static void btc_stop_adv_callback(uint8_t status)
BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__);
}
}
static void btc_clear_adv_callback(uint8_t status)
{
esp_ble_gap_cb_param_t param;
bt_status_t ret;
btc_msg_t msg = {0};
msg.sig = BTC_SIG_API_CB;
msg.pid = BTC_PID_GAP_BLE;
msg.act = ESP_GAP_BLE_ADV_CLEAR_COMPLETE_EVT;
param.adv_clear_cmpl.status = btc_hci_to_esp_status(status);
ret = btc_transfer_context(&msg, &param,
sizeof(esp_ble_gap_cb_param_t), NULL, NULL);
if (ret != BT_STATUS_SUCCESS) {
BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__);
}
}
#endif // #if (BLE_42_ADV_EN == TRUE)
void btc_update_duplicate_exceptional_list_callback(tBTA_STATUS status, uint8_t subcode, uint32_t length, uint8_t *device_info)
@ -1406,6 +1387,45 @@ void btc_dtm_stop_callback(void *p1)
}
#endif // #if ((BLE_42_DTM_TEST_EN == TRUE) || (BLE_50_DTM_TEST_EN == TRUE))
static void btc_ble_set_privacy_mode_callback(UINT8 status)
{
esp_ble_gap_cb_param_t param;
bt_status_t ret;
btc_msg_t msg = {0};
msg.sig = BTC_SIG_API_CB;
msg.pid = BTC_PID_GAP_BLE;
msg.act = ESP_GAP_BLE_SET_PRIVACY_MODE_COMPLETE_EVT;
param.set_privacy_mode_cmpl.status = btc_btm_status_to_esp_status(status);
ret = btc_transfer_context(&msg, &param, sizeof(esp_ble_gap_cb_param_t), NULL, NULL);
if (ret != BT_STATUS_SUCCESS) {
BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__);
}
}
#if (BLE_VENDOR_HCI_EN == TRUE)
static void btc_clear_adv_callback(uint8_t status)
{
esp_ble_gap_cb_param_t param;
bt_status_t ret;
btc_msg_t msg = {0};
msg.sig = BTC_SIG_API_CB;
msg.pid = BTC_PID_GAP_BLE;
msg.act = ESP_GAP_BLE_ADV_CLEAR_COMPLETE_EVT;
param.adv_clear_cmpl.status = btc_hci_to_esp_status(status);
ret = btc_transfer_context(&msg, &param,
sizeof(esp_ble_gap_cb_param_t), NULL, NULL);
if (ret != BT_STATUS_SUCCESS) {
BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__);
}
}
static void btc_ble_vendor_hci_cmd_complete_callback(tBTA_VSC_CMPL *p_param)
{
bool param_invalid = false;
@ -1442,25 +1462,6 @@ static void btc_ble_vendor_hci_cmd_complete_callback(tBTA_VSC_CMPL *p_param)
}
}
static void btc_ble_set_privacy_mode_callback(UINT8 status)
{
esp_ble_gap_cb_param_t param;
bt_status_t ret;
btc_msg_t msg = {0};
msg.sig = BTC_SIG_API_CB;
msg.pid = BTC_PID_GAP_BLE;
msg.act = ESP_GAP_BLE_SET_PRIVACY_MODE_COMPLETE_EVT;
param.set_privacy_mode_cmpl.status = btc_btm_status_to_esp_status(status);
ret = btc_transfer_context(&msg, &param, sizeof(esp_ble_gap_cb_param_t), NULL, NULL);
if (ret != BT_STATUS_SUCCESS) {
BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__);
}
}
static void btc_ble_set_csa_support_callback(UINT8 status)
{
esp_ble_gap_cb_param_t param;
@ -1490,7 +1491,7 @@ static void btc_ble_set_vendor_evt_mask_callback(UINT8 status)
msg.pid = BTC_PID_GAP_BLE;
msg.act = ESP_GAP_BLE_SET_VENDOR_EVT_MASK_COMPLETE_EVT;
param.set_csa_support_cmpl.status = btc_btm_status_to_esp_status(status);
param.set_vendor_evt_mask_cmpl.status = btc_btm_status_to_esp_status(status);
ret = btc_transfer_context(&msg, &param, sizeof(esp_ble_gap_cb_param_t), NULL, NULL);
@ -1504,20 +1505,52 @@ static void btc_ble_vendor_hci_event_callback(UINT8 subevt_code, UINT8 param_len
esp_ble_gap_cb_param_t param = {0};
bt_status_t ret;
btc_msg_t msg = {0};
esp_ble_vendor_evt_param_t *evt_param = &param.vendor_hci_evt.param;
bool copy_param = false;
msg.sig = BTC_SIG_API_CB;
msg.pid = BTC_PID_GAP_BLE;
msg.act = ESP_GAP_BLE_VENDOR_HCI_EVT;
param.vendor_hci_evt.subevt_code = subevt_code;
param.vendor_hci_evt.param_len = param_len;
param.vendor_hci_evt.param_buf = params;
ret = btc_transfer_context(&msg, &param, sizeof(esp_ble_gap_cb_param_t), btc_gap_ble_cb_deep_copy, btc_gap_ble_cb_deep_free);
param.vendor_hci_evt.param_len = 0;
param.vendor_hci_evt.param_buf = NULL;
switch (subevt_code) {
case BLE_VENDOR_PDU_RECV_EVT:
param.vendor_hci_evt.subevt_code = ESP_BLE_VENDOR_PDU_RECV_EVT;
STREAM_TO_UINT8(evt_param->pdu_recv.type, params);
STREAM_TO_UINT8(evt_param->pdu_recv.handle, params);
STREAM_TO_UINT8(evt_param->pdu_recv.addr_type, params);
STREAM_TO_BDADDR(evt_param->pdu_recv.peer_addr, params);
break;
case BLE_VENDOR_CHMAP_UPDATE_EVT:
param.vendor_hci_evt.subevt_code = ESP_BLE_VENDOR_CHAN_MAP_UPDATE_EVT;
STREAM_TO_UINT8(evt_param->chan_map_update.status, params);
STREAM_TO_UINT16(evt_param->chan_map_update.conn_handle, params);
REVERSE_STREAM_TO_ARRAY(evt_param->chan_map_update.ch_map, params, ESP_GAP_BLE_CHANNELS_LEN);
break;
case BLE_VENDOR_SLEEP_WAKEUP_EVT:
param.vendor_hci_evt.subevt_code = ESP_BLE_VENDOR_SLEEP_WAKEUP_EVT;
// No parameters
break;
default:
copy_param = true;
break;
}
if (copy_param) {
param.vendor_hci_evt.param_len = param_len;
param.vendor_hci_evt.param_buf = (param_len) ? params : NULL;
ret = btc_transfer_context(&msg, &param, sizeof(esp_ble_gap_cb_param_t), btc_gap_ble_cb_deep_copy, btc_gap_ble_cb_deep_free);
} else {
ret = btc_transfer_context(&msg, &param, sizeof(esp_ble_gap_cb_param_t), NULL, NULL);
}
if (ret != BT_STATUS_SUCCESS) {
BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__);
}
}
#endif // #if (BLE_VENDOR_HCI_EN == TRUE)
void btc_get_whitelist_size(uint16_t *length)
{
@ -1552,11 +1585,6 @@ static void btc_ble_stop_advertising(tBTA_START_STOP_ADV_CMPL_CBACK *stop_adv_cb
BTA_DmBleBroadcast(stop_adv, stop_adv_cb);
}
static void btc_ble_clear_advertising(tBTA_CLEAR_ADV_CMPL_CBACK *clear_adv_cb)
{
BTA_DmBleClearAdv(clear_adv_cb);
}
#endif // #if (BLE_42_ADV_EN == TRUE)
#endif // #if (BLE_42_FEATURE_SUPPORT == TRUE)
@ -1899,6 +1927,7 @@ void btc_gap_ble_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
}
#endif // #if (BLE_50_EXTEND_ADV_EN == TRUE)
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
#if (BLE_VENDOR_HCI_EN == TRUE)
case BTC_GAP_BLE_ACT_VENDOR_HCI_CMD_EVT: {
btc_ble_gap_args_t *src = (btc_ble_gap_args_t *)p_src;
btc_ble_gap_args_t *dst = (btc_ble_gap_args_t *)p_dest;
@ -1912,6 +1941,7 @@ void btc_gap_ble_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
}
break;
}
#endif // #if (BLE_VENDOR_HCI_EN == TRUE)
case BTC_GAP_BLE_ACT_SET_DEV_NAME:{
btc_ble_gap_args_t *src = (btc_ble_gap_args_t *)p_src;
btc_ble_gap_args_t *dst = (btc_ble_gap_args_t *)p_dest;
@ -2065,6 +2095,7 @@ void btc_gap_ble_arg_deep_free(btc_msg_t *msg)
}
#endif // #if (BLE_50_EXTEND_ADV_EN == TRUE)
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
#if (BLE_VENDOR_HCI_EN == TRUE)
case BTC_GAP_BLE_ACT_VENDOR_HCI_CMD_EVT: {
uint8_t *p_param_buf = ((btc_ble_gap_args_t *)msg->arg)->vendor_cmd_send.p_param_buf;
if (p_param_buf) {
@ -2072,6 +2103,7 @@ void btc_gap_ble_arg_deep_free(btc_msg_t *msg)
}
break;
}
#endif // #if (BLE_VENDOR_HCI_EN == TRUE)
case BTC_GAP_BLE_ACT_SET_DEV_NAME:{
char *p_name = ((btc_ble_gap_args_t *)msg->arg)->set_dev_name.device_name;
if (p_name) {
@ -2156,9 +2188,6 @@ void btc_gap_ble_call_handler(btc_msg_t *msg)
case BTC_GAP_BLE_ACT_STOP_ADV:
btc_ble_stop_advertising(btc_stop_adv_callback);
break;
case BTC_GAP_BLE_ACT_CLEAR_ADV:
btc_ble_clear_advertising(btc_clear_adv_callback);
break;
#endif // #if (BLE_42_ADV_EN == TRUE)
#endif // #if (BLE_42_FEATURE_SUPPORT == TRUE)
case BTC_GAP_BLE_ACT_UPDATE_CONN_PARAM:
@ -2618,22 +2647,27 @@ void btc_gap_ble_call_handler(btc_msg_t *msg)
btc_ble_dtm_enhance_rx_start(arg_5->dtm_enh_rx_start.rx_channel, arg_5->dtm_enh_rx_start.phy, arg_5->dtm_enh_rx_start.modulation_index, btc_dtm_rx_start_callback);
break;
#endif // #if (BLE_50_DTM_TEST_EN == TRUE)
case BTC_GAP_BLE_SET_PRIVACY_MODE:
btc_ble_set_privacy_mode(arg->set_privacy_mode.addr_type, arg->set_privacy_mode.addr,
arg->set_privacy_mode.privacy_mode, btc_ble_set_privacy_mode_callback);
break;
#if (BLE_VENDOR_HCI_EN == TRUE)
case BTC_GAP_BLE_ACT_CLEAR_ADV:
BTA_DmBleClearAdv(btc_clear_adv_callback);
break;
case BTC_GAP_BLE_ACT_VENDOR_HCI_CMD_EVT:
BTA_DmsendVendorHciCmd(arg->vendor_cmd_send.opcode,
arg->vendor_cmd_send.param_len,
arg->vendor_cmd_send.p_param_buf,
btc_ble_vendor_hci_cmd_complete_callback);
break;
case BTC_GAP_BLE_SET_PRIVACY_MODE:
btc_ble_set_privacy_mode(arg->set_privacy_mode.addr_type, arg->set_privacy_mode.addr,
arg->set_privacy_mode.privacy_mode, btc_ble_set_privacy_mode_callback);
break;
case BTC_GAP_BLE_SET_CSA_SUPPORT:
BTA_DmBleGapSetCsaSupport(arg->set_csa_support.csa_select, btc_ble_set_csa_support_callback);
break;
case BTC_GAP_BLE_ACT_SET_VENDOR_EVT_MASK:
BTA_DmBleGapSetVendorEventMask(arg->set_vendor_evt_mask.evt_mask, btc_ble_set_vendor_evt_mask_callback);
break;
#endif // #if (BLE_VENDOR_HCI_EN == TRUE)
#if (BLE_FEAT_POWER_CONTROL_EN == TRUE)
case BTC_GAP_BLE_ENH_READ_TRANS_POWER_LEVEL:
BTA_DmBleGapEnhReadTransPwrLevel(arg_5->enh_read_trans_pwr_level.conn_handle, arg_5->enh_read_trans_pwr_level.phy);
@ -2682,7 +2716,9 @@ void btc_gap_callback_init(void)
#if (BLE_50_FEATURE_SUPPORT == TRUE)
BTM_BleGapRegisterCallback(btc_ble_5_gap_callback);
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
#if (BLE_VENDOR_HCI_EN == TRUE)
BTM_BleRegisterVendorHciEventCallback(btc_ble_vendor_hci_event_callback);
#endif // #if (BLE_VENDOR_HCI_EN == TRUE)
}
bool btc_gap_ble_init(void)

View File

@ -24,6 +24,10 @@ extern tBTA_BLE_ADV_DATA *gl_bta_scan_rsp_data_ptr;
#define BLE_ISVALID_PARAM(x, min, max) (((x) >= (min) && (x) <= (max)))
#define BLE_VENDOR_PDU_RECV_EVT (0xC0)
#define BLE_VENDOR_CHMAP_UPDATE_EVT (0xC1)
#define BLE_VENDOR_SLEEP_WAKEUP_EVT (0xC3)
typedef enum {
#if (BLE_42_FEATURE_SUPPORT == TRUE)
BTC_GAP_BLE_ACT_CFG_ADV_DATA = 0,
@ -113,15 +117,15 @@ typedef enum {
BTC_GAP_BLE_DTM_RX_START,
#endif // #if (BLE_42_DTM_TEST_EN == TRUE)
BTC_GAP_BLE_DTM_STOP,
#if (BLE_42_FEATURE_SUPPORT == TRUE)
#if (BLE_VENDOR_HCI_EN == TRUE)
BTC_GAP_BLE_ACT_CLEAR_ADV,
#endif // #if (BLE_42_FEATURE_SUPPORT == TRUE)
BTC_GAP_BLE_ACT_SET_RESOLVABLE_PRIVATE_ADDRESS_TIMEOUT,
BTC_GAP_BLE_ACT_ADD_DEVICE_TO_RESOLVING_LIST,
BTC_GAP_BLE_ACT_VENDOR_HCI_CMD_EVT,
BTC_GAP_BLE_SET_PRIVACY_MODE,
BTC_GAP_BLE_SET_CSA_SUPPORT,
BTC_GAP_BLE_ACT_SET_VENDOR_EVT_MASK,
#endif // #if (BLE_VENDOR_HCI_EN == TRUE)
BTC_GAP_BLE_ACT_SET_RESOLVABLE_PRIVATE_ADDRESS_TIMEOUT,
BTC_GAP_BLE_ACT_ADD_DEVICE_TO_RESOLVING_LIST,
BTC_GAP_BLE_SET_PRIVACY_MODE,
#if (BLE_FEAT_POWER_CONTROL_EN == TRUE)
BTC_GAP_BLE_ENH_READ_TRANS_POWER_LEVEL,
BTC_GAP_BLE_READ_REM_TRANS_POWER_LEVEL,

View File

@ -306,6 +306,12 @@
#define UC_BT_BLE_FEAT_CONN_SUBRATING FALSE
#endif
#ifdef CONFIG_BT_BLE_VENDOR_HCI_EN
#define UC_BT_BLE_VENDOR_HCI_EN CONFIG_BT_BLE_VENDOR_HCI_EN
#else
#define UC_BT_BLE_VENDOR_HCI_EN FALSE
#endif
#ifdef CONFIG_BT_BLE_HIGH_DUTY_ADV_INTERVAL
#define UC_BT_BLE_HIGH_DUTY_ADV_INTERVAL CONFIG_BT_BLE_HIGH_DUTY_ADV_INTERVAL
#else

View File

@ -377,6 +377,12 @@
#define BLE_FEAT_CONN_SUBRATING FALSE
#endif
#if (UC_BT_BLE_VENDOR_HCI_EN == TRUE)
#define BLE_VENDOR_HCI_EN TRUE
#else
#define BLE_VENDOR_HCI_EN FALSE
#endif
#if (UC_BT_BLE_HIGH_DUTY_ADV_INTERVAL == TRUE)
#define BLE_HIGH_DUTY_ADV_INTERVAL TRUE
#else

View File

@ -613,6 +613,7 @@ tBTM_STATUS BTM_BleStartExtAdvRestart(uint8_t con_handle)
}
if((index >= MAX_BLE_ADV_INSTANCE) || (!adv_record[index].invalid)) {
BTM_TRACE_WARNING("%s failed to find extend adv, adv_handle %u con_handle %u", __func__, index, con_handle);
return BTM_WRONG_MODE;
}
@ -1254,7 +1255,7 @@ void btm_ble_adv_set_terminated_evt(tBTM_BLE_ADV_TERMINAT *params)
}
// adv terminated due to connection, save the adv handle and connection handle
if(params->completed_event == 0x00) {
if(params->status == 0x00) {
adv_record[params->adv_handle].ter_con_handle = params->conn_handle;
} else {
adv_record[params->adv_handle].ter_con_handle = INVALID_VALUE;

View File

@ -201,7 +201,12 @@ BOOLEAN btm_add_dev_to_controller (BOOLEAN to_add, BD_ADDR bd_addr, tBLE_ADDR_TY
/* Controller do not support resolvable address now, only support public address and static random address */
BOOLEAN started = FALSE;
if(wl_addr_type > BLE_ADDR_RANDOM) {
#if (BLE_50_FEATURE_SUPPORT == TRUE)
if (wl_addr_type > BLE_ADDR_RANDOM && wl_addr_type != BLE_ADDR_ANONYMOUS)
#else
if (wl_addr_type > BLE_ADDR_RANDOM)
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
{
BTM_TRACE_ERROR("wl_addr_type is error\n");
return started;
}
@ -278,7 +283,12 @@ void btm_enq_wl_dev_operation(BOOLEAN to_add, BD_ADDR bd_addr, tBLE_ADDR_TYPE ad
*******************************************************************************/
BOOLEAN btm_update_dev_to_white_list(BOOLEAN to_add, BD_ADDR bd_addr, tBLE_ADDR_TYPE addr_type, tBTM_UPDATE_WHITELIST_CBACK *update_wl_cb)
{
if(addr_type > BLE_ADDR_RANDOM) {
#if (BLE_50_FEATURE_SUPPORT == TRUE)
if (addr_type > BLE_ADDR_RANDOM && addr_type != BLE_ADDR_ANONYMOUS)
#else
if (addr_type > BLE_ADDR_RANDOM)
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
{
BTM_TRACE_ERROR("%s address type is error, unable to add device", __func__);
if (update_wl_cb){
update_wl_cb(HCI_ERR_ILLEGAL_PARAMETER_FMT,to_add);

View File

@ -72,7 +72,9 @@ static tBTM_BLE_CTRL_FEATURES_CBACK *p_ctrl_le_feature_rd_cmpl_cback = NULL;
tBTM_CallbackFunc conn_callback_func;
// BLE vendor HCI event callback
#if (BLE_VENDOR_HCI_EN == TRUE)
static tBTM_BLE_VENDOR_HCI_EVT_CBACK *ble_vs_evt_callback = NULL;
#endif // #if (BLE_VENDOR_HCI_EN == TRUE)
/*******************************************************************************
** Local functions
*******************************************************************************/
@ -353,10 +355,12 @@ void BTM_BleRegiseterPktLengthChangeCallback(tBTM_SET_PKT_DATA_LENGTH_CBACK *ptk
conn_callback_func.set_pkt_data_length_cb = ptk_len_chane_cb;
}
#if (BLE_VENDOR_HCI_EN == TRUE)
void BTM_BleRegisterVendorHciEventCallback(tBTM_BLE_VENDOR_HCI_EVT_CBACK *vendor_hci_evt_cb)
{
ble_vs_evt_callback = vendor_hci_evt_cb;
}
#endif // #if (BLE_VENDOR_HCI_EN == TRUE)
/*******************************************************************************
**
@ -4548,6 +4552,7 @@ BOOLEAN btm_ble_update_mode_operation(UINT8 link_role, BD_ADDR bd_addr, UINT8 st
return bg_con;
}
#if (BLE_VENDOR_HCI_EN == TRUE)
static void btm_ble_vs_evt_callback(UINT8 len, UINT8 *p)
{
UINT8 sub_event;
@ -4559,7 +4564,7 @@ static void btm_ble_vs_evt_callback(UINT8 len, UINT8 *p)
STREAM_TO_UINT8(sub_event, p);
len--;
if (sub_event < HCI_VSE_LE_LEGACY_SCAN_REQ_RECEIVED_EVT) {
if (sub_event < HCI_VSE_LE_SUBEVT_BASE) {
return;
}
@ -4567,6 +4572,7 @@ static void btm_ble_vs_evt_callback(UINT8 len, UINT8 *p)
ble_vs_evt_callback(sub_event, len, p);
}
}
#endif // #if (BLE_VENDOR_HCI_EN == TRUE)
/*******************************************************************************
**
@ -4626,8 +4632,9 @@ void btm_ble_init (void)
btm_ble_adv_filter_init();
#endif // #if BLE_ANDROID_CONTROLLER_SCAN_FILTER == TRUE
#endif
#if (BLE_VENDOR_HCI_EN == TRUE)
BTM_RegisterForVSEvents(btm_ble_vs_evt_callback, TRUE);
#endif // #if (BLE_VENDOR_HCI_EN == TRUE)
}
/*******************************************************************************
@ -4754,6 +4761,7 @@ BOOLEAN BTM_Ble_Authorization(BD_ADDR bd_addr, BOOLEAN authorize)
return FALSE;
}
#if (BLE_VENDOR_HCI_EN == TRUE)
/*******************************************************************************
**
** Function BTM_BleClearAdv
@ -4775,6 +4783,30 @@ BOOLEAN BTM_BleClearAdv(tBTM_CLEAR_ADV_CMPL_CBACK *p_clear_adv_cback)
p_cb->inq_var.p_clear_adv_cb = p_clear_adv_cback;
return TRUE;
}
BOOLEAN BTM_BleSetCsaSupport(UINT8 csa_select, tBTM_SET_CSA_SUPPORT_CMPL_CBACK *p_callback)
{
if (btsnd_hcic_ble_set_csa_support(csa_select) != TRUE) {
BTM_TRACE_ERROR("LE SetCsaSupport csa_select=%d: error", csa_select);
return FALSE;
}
btm_cb.ble_ctr_cb.set_csa_support_cmpl_cb = p_callback;
return TRUE;
}
BOOLEAN BTM_BleSetVendorEventMask(UINT32 evt_mask, tBTM_SET_VENDOR_EVT_MASK_CBACK *p_callback)
{
if (btsnd_hcic_ble_set_vendor_evt_mask(evt_mask) != TRUE) {
BTM_TRACE_ERROR("LE SetVendorEventMask evt_mask=%x: error", evt_mask);
return FALSE;
}
btm_cb.ble_ctr_cb.set_vendor_evt_mask_cmpl_cb = p_callback;
return TRUE;
}
#endif // #if (BLE_VENDOR_HCI_EN == TRUE)
BOOLEAN BTM_BleSetRpaTimeout(uint16_t rpa_timeout,tBTM_SET_RPA_TIMEOUT_CMPL_CBACK *p_set_rpa_timeout_cback)
{
if ((btsnd_hcic_ble_set_rand_priv_addr_timeout(rpa_timeout)) != TRUE) {
@ -4810,28 +4842,6 @@ BOOLEAN BTM_BleSetPrivacyMode(UINT8 addr_type, BD_ADDR bd_addr, UINT8 privacy_mo
return TRUE;
}
BOOLEAN BTM_BleSetCsaSupport(UINT8 csa_select, tBTM_SET_CSA_SUPPORT_CMPL_CBACK *p_callback)
{
if (btsnd_hcic_ble_set_csa_support(csa_select) != TRUE) {
BTM_TRACE_ERROR("LE SetCsaSupport csa_select=%d: error", csa_select);
return FALSE;
}
btm_cb.ble_ctr_cb.set_csa_support_cmpl_cb = p_callback;
return TRUE;
}
BOOLEAN BTM_BleSetVendorEventMask(UINT32 evt_mask, tBTM_SET_VENDOR_EVT_MASK_CBACK *p_callback)
{
if (btsnd_hcic_ble_set_vendor_evt_mask(evt_mask) != TRUE) {
BTM_TRACE_ERROR("LE SetVendorEventMask evt_mask=%x: error", evt_mask);
return FALSE;
}
btm_cb.ble_ctr_cb.set_vendor_evt_mask_cmpl_cb = p_callback;
return TRUE;
}
#if (BLE_42_SCAN_EN == TRUE)
bool btm_ble_adv_pkt_ready(void)
{

View File

@ -126,7 +126,8 @@ void btm_free(void)
#endif
}
uint8_t btm_acl_active_count(void)
#if (BLE_INCLUDED == TRUE)
uint8_t btm_ble_acl_active_count(void)
{
list_node_t *p_node = NULL;
tACL_CONN *p_acl_conn = NULL;
@ -134,14 +135,14 @@ uint8_t btm_acl_active_count(void)
for (p_node = list_begin(btm_cb.p_acl_db_list); p_node; p_node = list_next(p_node)) {
p_acl_conn = list_node(p_node);
if (p_acl_conn && p_acl_conn->in_use) {
if (p_acl_conn && p_acl_conn->in_use && p_acl_conn->transport == BT_TRANSPORT_LE) {
count++;
}
}
return count;
}
#if (BLE_INCLUDED == TRUE)
// Address resolution status
uint8_t btm_get_ble_addr_resolve_disable_status(void)
{

View File

@ -1244,7 +1244,8 @@ uint8_t gatt_tcb_active_count(void)
for(p_node = list_begin(gatt_cb.p_tcb_list); p_node; p_node = list_next(p_node)) {
p_tcb = list_node(p_node);
if (p_tcb && p_tcb->in_use && (p_tcb->ch_state != GATT_CH_CLOSE)) {
if (p_tcb && p_tcb->in_use && (p_tcb->transport == BT_TRANSPORT_LE) &&
(p_tcb->ch_state != GATT_CH_CLOSE)) {
count++;
}
}

View File

@ -1088,27 +1088,6 @@ BOOLEAN btsnd_hcic_ble_set_channels (BLE_CHANNELS channels)
return (TRUE);
}
BOOLEAN btsnd_hcic_ble_clear_adv (void)
{
BT_HDR *p;
UINT8 *pp;
if ((p = HCI_GET_CMD_BUF (HCIC_PARAM_SIZE_BLE_CLEAR_ADV)) == NULL) {
return (FALSE);
}
pp = (UINT8 *)(p + 1);
p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_CLEAR_ADV;
p->offset = 0;
UINT16_TO_STREAM (pp, HCI_VENDOR_BLE_CLEAR_ADV);
UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_BLE_CLEAR_ADV);
btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
return TRUE;
}
#define HCIC_BLE_CMD_CREATED(p, pp, size) do{\
if ((p = HCI_GET_CMD_BUF(size)) == NULL) { \
return FALSE; \
@ -1948,6 +1927,28 @@ BOOLEAN btsnd_hcic_ble_set_privacy_mode(UINT8 addr_type, BD_ADDR addr, UINT8 pri
return (TRUE);
}
#if (BLE_VENDOR_HCI_EN == TRUE)
BOOLEAN btsnd_hcic_ble_clear_adv (void)
{
BT_HDR *p;
UINT8 *pp;
if ((p = HCI_GET_CMD_BUF (HCIC_PARAM_SIZE_BLE_CLEAR_ADV)) == NULL) {
return (FALSE);
}
pp = (UINT8 *)(p + 1);
p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_CLEAR_ADV;
p->offset = 0;
UINT16_TO_STREAM (pp, HCI_VENDOR_BLE_CLEAR_ADV);
UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_BLE_CLEAR_ADV);
btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
return TRUE;
}
BOOLEAN btsnd_hcic_ble_set_csa_support (UINT8 csa_select)
{
BT_HDR *p;
@ -1991,6 +1992,7 @@ BOOLEAN btsnd_hcic_ble_set_vendor_evt_mask (UINT32 evt_mask)
btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
return TRUE;
}
#endif // #if (BLE_VENDOR_HCI_EN == TRUE)
#endif
#if (BLE_FEAT_ISO_EN == TRUE)

View File

@ -486,6 +486,7 @@ typedef struct {
#define BLE_ADDR_RANDOM_ID 0x03
#define BLE_ADDR_TYPE_MAX BLE_ADDR_RANDOM_ID
#define BLE_ADDR_UNKNOWN_TYPE 0XFF
#define BLE_ADDR_ANONYMOUS 0xFF
typedef UINT8 tBLE_ADDR_TYPE;
#define BLE_ADDR_TYPE_MASK (BLE_ADDR_RANDOM | BLE_ADDR_PUBLIC)

View File

@ -927,9 +927,9 @@
#define HCI_VENDOR_CH_CLASSIFICATION_EVT_SUBCODE 0x06
#define HCI_VENDOR_CH_CLASSIFICATION_REPORTING_MODE_EVT_SUBCODE 0x07
#define HCI_VSE_LE_LEGACY_SCAN_REQ_RECEIVED_EVT 0xC0
#define HCI_VSE_LE_CHAN_MAP_UPDATE_CMPL_EVT 0xC1
#define HCI_VSE_LE_EVT_MAX 0xFF
#define HCI_VENDOR_SPECIFIC_EVT 0xFF /* Vendor specific events */
#define HCI_VSE_LE_SUBEVT_BASE 0xC0 /* BLE vendor event code base */
#define HCI_VSE_LE_EVT_MAX 0xFF /* BLE vendor event code max */
#define HCI_NAP_TRACE_EVT 0xFF /* was define 0xFE, 0xFD, change to 0xFF
because conflict w/ TCI_EVT and per
specification compliant */

View File

@ -65,7 +65,7 @@
#define L2CAP_WAIT_UNPARK_TOUT 2 /* 2 seconds */
#define L2CAP_LINK_INFO_RESP_TOUT 2 /* 2 seconds */
#define L2CAP_UPDATE_CONN_PARAM_TOUT 6 /* 6 seconds */
#define L2CAP_BLE_LINK_CONNECT_TOUT BLE_ESTABLISH_LINK_CONNECTION_TIMEOUT // configed in menuconfig
#define L2CAP_BLE_LINK_CONNECT_TOUT BLE_ESTABLISH_LINK_CONNECTION_TIMEOUT // configured in menuconfig
#define L2CAP_BLE_CONN_PARAM_UPD_TOUT 30 /* 30 seconds */
/* quick timer uses millisecond unit */
@ -80,10 +80,10 @@
** the Bluetooth specification.
*/
typedef enum {
CST_CLOSED, /* Channel is in clodes state */
CST_CLOSED, /* Channel is in closed state */
CST_ORIG_W4_SEC_COMP, /* Originator waits security clearence */
CST_TERM_W4_SEC_COMP, /* Acceptor waits security clearence */
CST_W4_L2CAP_CONNECT_RSP, /* Waiting for peer conenct response */
CST_W4_L2CAP_CONNECT_RSP, /* Waiting for peer connect response */
CST_W4_L2CA_CONNECT_RSP, /* Waiting for upper layer connect rsp */
CST_CONFIG, /* Negotiating configuration */
CST_OPEN, /* Data transfer state */
@ -208,8 +208,8 @@ typedef struct {
UINT32 controller_idle; /* # of times less than 2 packets in controller */
/* when the xmit window was closed */
UINT32 pkts_retransmitted; /* # of packets that were retransmitted */
UINT32 retrans_touts; /* # of retransmission timouts */
UINT32 xmit_ack_touts; /* # of xmit ack timouts */
UINT32 retrans_touts; /* # of retransmission timeouts */
UINT32 xmit_ack_touts; /* # of xmit ack timeouts */
#define L2CAP_ERTM_STATS_NUM_AVG 10
#define L2CAP_ERTM_STATS_AVG_NUM_SAMPLES 100
@ -386,7 +386,7 @@ typedef struct t_l2c_linkcb {
tL2C_CCB *p_pending_ccb; /* ccb of waiting channel during link disconnect */
TIMER_LIST_ENT info_timer_entry; /* Timer entry for info resp timeout evt */
TIMER_LIST_ENT upda_con_timer; /* Timer entry for update connection parametr */
TIMER_LIST_ENT upda_con_timer; /* Timer entry for update connection parameter */
BD_ADDR remote_bd_addr; /* The BD address of the remote */
UINT8 link_role; /* Master or slave */
@ -599,7 +599,7 @@ extern BOOLEAN l2cu_start_post_bond_timer (UINT16 handle);
extern void l2cu_release_lcb (tL2C_LCB *p_lcb);
extern tL2C_LCB *l2cu_find_lcb_by_bd_addr (BD_ADDR p_bd_addr, tBT_TRANSPORT transport);
extern tL2C_LCB *l2cu_find_lcb_by_handle (UINT16 handle);
extern uint8_t l2cu_plcb_active_count(void);
extern uint8_t l2cu_ble_plcb_active_count(void);
extern void l2cu_update_lcb_4_bonding (BD_ADDR p_bd_addr, BOOLEAN is_bonding);
extern UINT8 l2cu_get_conn_role (tL2C_LCB *p_this_lcb);

View File

@ -242,7 +242,7 @@ BOOLEAN L2CA_EnableUpdateBleConnParams (BD_ADDR rem_bda, BOOLEAN enable)
return (FALSE);
}
bool is_disable = (p_lcb->conn_update_mask & L2C_BLE_CONN_UPDATE_DISABLE);
if(l2cu_plcb_active_count() >1 && !(enable && is_disable)) {
if(l2cu_ble_plcb_active_count() >1 && !(enable && is_disable)) {
return FALSE;
}

View File

@ -480,6 +480,8 @@ BOOLEAN l2c_link_hci_disc_comp (UINT16 handle, UINT8 reason)
if (l2cu_create_conn(p_lcb, BT_TRANSPORT_LE)) {
btm_acl_removed (p_lcb->remote_bd_addr, BT_TRANSPORT_LE);
lcb_is_free = FALSE; /* still using this lcb */
} else {
L2CAP_TRACE_ERROR("master retry connect failed");
}
}
#endif // (GATTC_CONNECT_RETRY_EN == TRUE)
@ -489,7 +491,10 @@ BOOLEAN l2c_link_hci_disc_comp (UINT16 handle, UINT8 reason)
if(btm_ble_inter_get() && p_lcb->link_role == HCI_ROLE_SLAVE) {
p_lcb->retry_create_con ++;
L2CAP_TRACE_DEBUG("slave restart extend adv, retry count %d reason 0x%x\n", p_lcb->retry_create_con, reason);
BTM_BleStartExtAdvRestart(handle);
tBTM_STATUS start_adv_status = BTM_BleStartExtAdvRestart(handle);
if (start_adv_status != BTM_SUCCESS) {
L2CAP_TRACE_ERROR("slave restart extend adv failed (err 0x%x)", start_adv_status);
}
}
#endif // #if (BLE_50_EXTEND_ADV_EN == TRUE)
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
@ -499,7 +504,10 @@ BOOLEAN l2c_link_hci_disc_comp (UINT16 handle, UINT8 reason)
if(!btm_ble_inter_get() && p_lcb->link_role == HCI_ROLE_SLAVE) {
p_lcb->retry_create_con ++;
L2CAP_TRACE_DEBUG("slave resatrt adv, retry count %d reason 0x%x\n", p_lcb->retry_create_con, reason);
btm_ble_start_adv();
tBTM_STATUS start_adv_status = btm_ble_start_adv();
if (start_adv_status != BTM_SUCCESS) {
L2CAP_TRACE_ERROR("slave resatrt adv failed (err 0x%x)", start_adv_status);
}
}
#endif // #if (BLE_42_ADV_EN == TRUE)
#endif // #if (BLE_42_FEATURE_SUPPORT == TRUE)

View File

@ -336,14 +336,14 @@ tL2C_LCB *l2cu_find_free_lcb (void)
return (NULL);
}
uint8_t l2cu_plcb_active_count(void)
uint8_t l2cu_ble_plcb_active_count(void)
{
list_node_t *p_node = NULL;
tL2C_LCB *p_lcb = NULL;
uint8_t active_count = 0;
for (p_node = list_begin(l2cb.p_lcb_pool); p_node; p_node = list_next(p_node)) {
p_lcb = list_node(p_node);
if (p_lcb && p_lcb->in_use) {
if (p_lcb && p_lcb->in_use && p_lcb->transport == BT_TRANSPORT_LE) {
active_count ++;
}
}
@ -615,7 +615,7 @@ void l2cu_send_peer_connect_rsp (tL2C_CCB *p_ccb, UINT16 result, UINT16 status)
**
** Description Build and send an L2CAP "connection response neg" message
** to the peer. This function is called when there is no peer
** CCB (non-existant PSM or no resources).
** CCB (non-existent PSM or no resources).
**
** Returns void
**
@ -1737,7 +1737,7 @@ void l2cu_release_ccb (tL2C_CCB *p_ccb)
) {
l2cu_dequeue_ccb (p_ccb);
/* Delink the CCB from the LCB */
/* Unlink the CCB from the LCB */
p_ccb->p_lcb = NULL;
}
@ -1960,7 +1960,7 @@ tL2C_RCB *l2cu_find_ble_rcb_by_psm (UINT16 psm)
**
** Returns UINT8 - L2CAP_PEER_CFG_OK if passed to upper layer,
** L2CAP_PEER_CFG_UNACCEPTABLE if automatically responded to
** because parameters are unnacceptable from a specification
** because parameters are unacceptable from a specification
** point of view.
** L2CAP_PEER_CFG_DISCONNECT if no compatible channel modes
** between the two devices, and shall be closed.
@ -2558,7 +2558,7 @@ BOOLEAN l2cu_set_acl_priority (BD_ADDR bd_addr, UINT8 priority, BOOLEAN reset_af
**
** Function l2cu_set_non_flushable_pbf
**
** Description set L2CAP_PKT_START_NON_FLUSHABLE if controller supoorts
** Description set L2CAP_PKT_START_NON_FLUSHABLE if controller supports
**
** Returns void
**
@ -3328,7 +3328,7 @@ static tL2C_CCB *l2cu_get_next_channel_in_rr(tL2C_LCB *p_lcb)
for ( i = 0; (i < L2CAP_NUM_CHNL_PRIORITY) && (!p_serve_ccb); i++ ) {
/* scan all channel within serving priority group until finding a channel to serve */
for ( j = 0; (j < p_lcb->rr_serv[p_lcb->rr_pri].num_ccb) && (!p_serve_ccb); j++) {
/* scaning from next serving channel */
/* scanning from next serving channel */
p_ccb = p_lcb->rr_serv[p_lcb->rr_pri].p_serve_ccb;
if (!p_ccb) {