mirror of
https://github.com/espressif/esp-idf
synced 2025-03-09 09:09:10 -04:00
feat(bt/bluedroid): Support BLE setting vendor event mask
This commit is contained in:
parent
7d751dcc8f
commit
fd4094e502
@ -1774,3 +1774,21 @@ esp_err_t esp_ble_gap_vendor_command_send(esp_ble_vendor_cmd_params_t *vendor_cm
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), btc_gap_ble_arg_deep_copy, btc_gap_ble_arg_deep_free)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_gap_set_vendor_event_mask(uint32_t event_mask)
|
||||
{
|
||||
btc_msg_t msg = {0};
|
||||
btc_ble_gap_args_t arg;
|
||||
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GAP_BLE;
|
||||
msg.act = BTC_GAP_BLE_ACT_SET_VENDOR_EVT_MASK;
|
||||
arg.set_vendor_evt_mask.evt_mask = event_mask;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), NULL, NULL)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
@ -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
|
||||
*/
|
||||
@ -230,6 +230,7 @@ typedef enum {
|
||||
ESP_GAP_BLE_VENDOR_CMD_COMPLETE_EVT, /*!< When vendor hci command complete, the event comes */
|
||||
ESP_GAP_BLE_SET_PRIVACY_MODE_COMPLETE_EVT, /*!< When set privacy mode complete, the event comes */
|
||||
ESP_GAP_BLE_SET_CSA_SUPPORT_COMPLETE_EVT, /*!< When set CSA support complete, the event comes */
|
||||
ESP_GAP_BLE_SET_VENDOR_EVT_MASK_COMPLETE_EVT, /*!< When set vendor event mask complete, the event comes */
|
||||
ESP_GAP_BLE_EVT_MAX, /*!< when maximum advertising event complete, the event comes */
|
||||
} esp_gap_ble_cb_event_t;
|
||||
|
||||
@ -1580,7 +1581,13 @@ typedef union {
|
||||
*/
|
||||
struct ble_set_csa_support_cmpl_evt_param {
|
||||
esp_bt_status_t status; /*!< Indicate CSA support set operation success status */
|
||||
} set_csa_support_cmpl; /*!< Event parameter of ESP_GAP_BLE_SET_CSA_SUPPORT_COMPLETE_EVT */
|
||||
} set_csa_support_cmpl; /*!< Event parameter of ESP_GAP_BLE_SET_CSA_SUPPORT_COMPLETE_EVT */
|
||||
/**
|
||||
* @brief ESP_GAP_BLE_SET_VENDOR_EVT_MASK_COMPLETE_EVT
|
||||
*/
|
||||
struct ble_set_vendor_evt_mask_cmpl_evt_param {
|
||||
esp_bt_status_t status; /*!< Indicate set vendor event mask operation success status */
|
||||
} set_vendor_evt_mask_cmpl; /*!< Event parameter of ESP_GAP_BLE_SET_VENDOR_EVT_MASK_COMPLETE_EVT */
|
||||
} esp_ble_gap_cb_param_t;
|
||||
|
||||
/**
|
||||
@ -2772,6 +2779,18 @@ esp_err_t esp_ble_gap_set_privacy_mode(esp_ble_addr_type_t addr_type, esp_bd_add
|
||||
*/
|
||||
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
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : success
|
||||
* - other : failed
|
||||
*/
|
||||
esp_err_t esp_ble_gap_set_vendor_event_mask(uint32_t event_mask);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -5859,6 +5859,11 @@ void bta_dm_ble_gap_set_csa_support(tBTA_DM_MSG *p_data)
|
||||
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);
|
||||
}
|
||||
|
||||
#if (BLE_50_DTM_TEST_EN == TRUE)
|
||||
void bta_dm_ble_gap_dtm_enhance_tx_start(tBTA_DM_MSG *p_data)
|
||||
|
@ -3013,6 +3013,19 @@ void BTA_DmBleGapSetCsaSupport(uint8_t csa_select, tBTA_SET_CSA_SUPPORT_CMPL_CBA
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_VendorInit
|
||||
|
@ -285,6 +285,7 @@ const tBTA_DM_ACTION bta_dm_action[BTA_DM_MAX_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 */
|
||||
#endif
|
||||
};
|
||||
|
||||
|
@ -276,6 +276,7 @@ enum {
|
||||
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,
|
||||
#endif
|
||||
BTA_DM_MAX_EVT
|
||||
};
|
||||
@ -1020,6 +1021,12 @@ typedef struct {
|
||||
tBTA_SET_CSA_SUPPORT_CMPL_CBACK *p_cback;
|
||||
} tBTA_DM_API_BLE_SET_CSA_SUPPORT;
|
||||
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
UINT32 evt_mask;
|
||||
tBTA_SET_VENDOR_EVT_MASK_CBACK *p_cback;
|
||||
} tBTA_DM_API_BLE_SET_VENDOR_EVT_MASK;
|
||||
|
||||
#endif /* BLE_INCLUDED */
|
||||
|
||||
#if (BLE_HOST_REMOVE_AN_ACL_EN == TRUE)
|
||||
@ -1463,6 +1470,7 @@ typedef union {
|
||||
tBTA_DM_API_CLEAR_ADV ble_clear_adv;
|
||||
tBTA_DM_API_SET_PRIVACY_MODE ble_set_privacy_mode;
|
||||
tBTA_DM_API_BLE_SET_CSA_SUPPORT ble_set_csa_support;
|
||||
tBTA_DM_API_BLE_SET_VENDOR_EVT_MASK ble_set_vendor_evt_mask;
|
||||
#endif
|
||||
#if (BLE_HOST_REMOVE_AN_ACL_EN == TRUE)
|
||||
tBTA_DM_API_REMOVE_ACL remove_acl;
|
||||
@ -1929,6 +1937,7 @@ extern void bta_dm_ble_gap_set_rpa_timeout(tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_ble_gap_add_dev_to_resolving_list(tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_ble_gap_set_privacy_mode(tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_ble_gap_set_csa_support(tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_ble_gap_set_vendor_evt_mask(tBTA_DM_MSG *p_data);
|
||||
#if (BLE_50_DTM_TEST_EN == TRUE)
|
||||
extern void bta_dm_ble_gap_dtm_enhance_tx_start(tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_ble_gap_dtm_enhance_rx_start(tBTA_DM_MSG *p_data);
|
||||
|
@ -441,6 +441,8 @@ typedef tBTM_SET_PRIVACY_MODE_CMPL_CBACK tBTA_SET_PRIVACY_MODE_CMPL_CBACK;
|
||||
|
||||
typedef tBTM_SET_CSA_SUPPORT_CMPL_CBACK tBTA_SET_CSA_SUPPORT_CMPL_CBACK;
|
||||
|
||||
typedef tBTM_SET_VENDOR_EVT_MASK_CBACK tBTA_SET_VENDOR_EVT_MASK_CBACK;
|
||||
|
||||
typedef tBTM_CMPL_CB tBTA_CMPL_CB;
|
||||
|
||||
typedef tBTM_VSC_CMPL tBTA_VSC_CMPL;
|
||||
@ -2921,6 +2923,8 @@ extern void BTA_DmBleSetPrivacyMode(uint8_t addr_type, BD_ADDR addr, uint8_t pri
|
||||
|
||||
extern void BTA_DmBleGapSetCsaSupport(uint8_t csa_select, tBTM_SET_CSA_SUPPORT_CMPL_CBACK *p_callback);
|
||||
|
||||
extern void BTA_DmBleGapSetVendorEventMask(uint32_t evt_mask, tBTA_SET_VENDOR_EVT_MASK_CBACK *p_callback);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_DmBleSetStorageParams
|
||||
|
@ -1381,6 +1381,25 @@ static void btc_ble_set_csa_support_callback(UINT8 status)
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_ble_set_vendor_evt_mask_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_VENDOR_EVT_MASK_COMPLETE_EVT;
|
||||
|
||||
param.set_csa_support_cmpl.status = btc_btm_status_to_esp_status(status);
|
||||
|
||||
ret = btc_transfer_context(&msg, ¶m, sizeof(esp_ble_gap_cb_param_t), NULL, NULL);
|
||||
|
||||
if (ret != BT_STATUS_SUCCESS) {
|
||||
BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
void btc_get_whitelist_size(uint16_t *length)
|
||||
{
|
||||
BTM_BleGetWhiteListSize(length);
|
||||
@ -2461,6 +2480,9 @@ void btc_gap_ble_call_handler(btc_msg_t *msg)
|
||||
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;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -121,6 +121,7 @@ typedef enum {
|
||||
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,
|
||||
} btc_gap_ble_act_t;
|
||||
|
||||
/* btc_ble_gap_args_t */
|
||||
@ -295,6 +296,10 @@ typedef union {
|
||||
struct set_csa_support_args {
|
||||
uint8_t csa_select;
|
||||
} set_csa_support;
|
||||
// BTC_GAP_BLE_ACT_SET_VENDOR_EVT_MASK
|
||||
struct set_vendor_evt_mask_args {
|
||||
uint32_t evt_mask;
|
||||
} set_vendor_evt_mask;
|
||||
} btc_ble_gap_args_t;
|
||||
|
||||
#if (BLE_50_FEATURE_SUPPORT == TRUE)
|
||||
|
@ -4793,6 +4793,17 @@ BOOLEAN BTM_BleSetCsaSupport(UINT8 csa_select, tBTM_SET_CSA_SUPPORT_CMPL_CBACK *
|
||||
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)
|
||||
{
|
||||
|
@ -786,6 +786,14 @@ void btm_vsc_complete (UINT8 *p, UINT16 opcode, UINT16 evt_len,
|
||||
}
|
||||
break;
|
||||
}
|
||||
case HCI_VENDOR_BLE_SET_EVT_MASK: {
|
||||
uint8_t status;
|
||||
STREAM_TO_UINT8(status, p);
|
||||
if (ble_cb && ble_cb->set_vendor_evt_mask_cmpl_cb) {
|
||||
ble_cb->set_vendor_evt_mask_cmpl_cb(status);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -381,6 +381,7 @@ typedef struct {
|
||||
UINT8 link_count[2]; /* total link count master and slave*/
|
||||
tBTM_UPDATE_DUPLICATE_EXCEPTIONAL_LIST_CMPL_CBACK *update_exceptional_list_cmp_cb;
|
||||
tBTM_SET_CSA_SUPPORT_CMPL_CBACK *set_csa_support_cmpl_cb;
|
||||
tBTM_SET_VENDOR_EVT_MASK_CBACK *set_vendor_evt_mask_cmpl_cb;
|
||||
} tBTM_BLE_CB;
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -1969,4 +1969,26 @@ BOOLEAN btsnd_hcic_ble_set_csa_support (UINT8 csa_select)
|
||||
btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_set_vendor_evt_mask (UINT32 evt_mask)
|
||||
{
|
||||
BT_HDR *p;
|
||||
UINT8 *pp;
|
||||
|
||||
if ((p = HCI_GET_CMD_BUF (HCIC_PARAM_SIZE_BLE_SET_VENDOR_EVT_MASK)) == NULL) {
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
pp = (UINT8 *)(p + 1);
|
||||
|
||||
p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_SET_VENDOR_EVT_MASK;
|
||||
p->offset = 0;
|
||||
|
||||
UINT16_TO_STREAM (pp, HCI_VENDOR_BLE_SET_EVT_MASK);
|
||||
UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_BLE_SET_VENDOR_EVT_MASK);
|
||||
UINT32_TO_STREAM (pp, evt_mask);
|
||||
|
||||
btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
|
@ -1013,6 +1013,7 @@ typedef void (tBTM_UPDATE_DUPLICATE_EXCEPTIONAL_LIST_CMPL_CBACK) (tBTM_STATUS st
|
||||
typedef void (tBTM_CLEAR_ADV_CMPL_CBACK) (UINT8 status);
|
||||
typedef void (tBTM_SET_PRIVACY_MODE_CMPL_CBACK) (tBTM_STATUS status);
|
||||
typedef void (tBTM_SET_CSA_SUPPORT_CMPL_CBACK) (tBTM_STATUS status);
|
||||
typedef void (tBTM_SET_VENDOR_EVT_MASK_CBACK) (tBTM_STATUS status);
|
||||
|
||||
#if (BLE_50_FEATURE_SUPPORT == TRUE)
|
||||
#define BTM_BLE_5_GAP_READ_PHY_COMPLETE_EVT 1
|
||||
@ -2751,6 +2752,19 @@ BOOLEAN BTM_BleSetPrivacyMode(UINT8 addr_type,
|
||||
*******************************************************************************/
|
||||
BOOLEAN BTM_BleSetCsaSupport (UINT8 csa_select, tBTM_SET_CSA_SUPPORT_CMPL_CBACK *p_callback);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTM_BleSetVendorEventMask
|
||||
**
|
||||
** Description This function is called to set the vendor HCI event mask
|
||||
**
|
||||
** Parameters evt_mask - vendor HCI event mask.
|
||||
** p_callback - Callback function to be called when the operation is completed.
|
||||
**
|
||||
** Returns TRUE if the operation was successful, otherwise FALSE.
|
||||
**
|
||||
*******************************************************************************/
|
||||
BOOLEAN BTM_BleSetVendorEventMask(UINT32 evt_mask, tBTM_SET_VENDOR_EVT_MASK_CBACK *p_callback);
|
||||
/*
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -427,6 +427,7 @@
|
||||
#define HCI_SUBCODE_BLE_RD_STATIC_ADDR 0x0B
|
||||
#define HCI_SUBCODE_BLE_CLEAR_ADV 0x0C
|
||||
#define HCI_SUBCODE_BLE_SET_CSA_SUPPORT 0x12
|
||||
#define HCI_SUBCODE_BLE_SET_VENDOR_EVT_MASK 0x16
|
||||
#define HCI_SUBCODE_BLE_MAX 0x7F
|
||||
|
||||
//ESP BT subcode define
|
||||
@ -473,6 +474,8 @@
|
||||
#define HCI_VENDOR_BLE_CLEAR_ADV HCI_ESP_VENDOR_OPCODE_BUILD(HCI_VENDOR_OGF, HCI_ESP_GROUP_BLE, HCI_SUBCODE_BLE_CLEAR_ADV)
|
||||
/* BLE set CSA support */
|
||||
#define HCI_VENDOR_BLE_SET_CSA_SUPPORT HCI_ESP_VENDOR_OPCODE_BUILD(HCI_VENDOR_OGF, HCI_ESP_GROUP_BLE, HCI_SUBCODE_BLE_SET_CSA_SUPPORT)
|
||||
/* BLE set vendor event mask */
|
||||
#define HCI_VENDOR_BLE_SET_EVT_MASK HCI_ESP_VENDOR_OPCODE_BUILD(HCI_VENDOR_OGF, HCI_ESP_GROUP_BLE, HCI_SUBCODE_BLE_SET_VENDOR_EVT_MASK)
|
||||
//ESP BT HCI CMD
|
||||
#define HCI_VENDOR_BT_SET_MIN_ENC_KEY_SIZE HCI_ESP_VENDOR_OPCODE_BUILD(HCI_VENDOR_OGF, HCI_ESP_GROUP_BT, HCI_SUBCODE_BT_SET_MIN_ENC_KEY_SIZE)
|
||||
|
||||
|
@ -760,6 +760,7 @@ void btsnd_hcic_vendor_spec_cmd (BT_HDR *buffer, UINT16 opcode,
|
||||
#define HCIC_PARAM_SIZE_BLE_CLEAR_ADV 0
|
||||
#define HCIC_PARAM_SIZE_SET_PRIVACY_MODE 8
|
||||
#define HCIC_PARAM_SIZE_BLE_SET_CSA_SUPPORT 1
|
||||
#define HCIC_PARAM_SIZE_BLE_SET_VENDOR_EVT_MASK 4
|
||||
#if (BLE_50_FEATURE_SUPPORT == TRUE)
|
||||
#define HCIC_PARAM_SIZE_BLE_READ_PHY 2
|
||||
#define HCIC_PARAM_SIZE_BLE_SET_DEF_PHY 3
|
||||
@ -923,6 +924,8 @@ BOOLEAN btsnd_hcic_ble_set_privacy_mode(UINT8 addr_type, BD_ADDR addr, UINT8 pri
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_set_csa_support (UINT8 csa_select);
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_set_vendor_evt_mask (UINT32 evt_mask);
|
||||
|
||||
#endif /* BLE_INCLUDED */
|
||||
|
||||
#if (BLE_50_FEATURE_SUPPORT == TRUE)
|
||||
|
Loading…
x
Reference in New Issue
Block a user