mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'feature/btdm_raw_adv' into 'master'
Feature/btdm raw adv Add APIs to set raw advertising data and scan response data by user self. See merge request !451
This commit is contained in:
commit
aea18f6e74
@ -252,3 +252,50 @@ uint8_t *esp_ble_resolve_adv_data( uint8_t *adv_data, uint8_t type, uint8_t *len
|
||||
return (BTM_CheckAdvData( adv_data, type, length));
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_gap_config_adv_data_raw(uint8_t *raw_data, uint32_t raw_data_len)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_ble_gap_args_t arg;
|
||||
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
if (raw_data == NULL
|
||||
|| (raw_data_len <= 0 || raw_data_len > ESP_BLE_ADV_DATA_LEN_MAX)) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GAP_BLE;
|
||||
msg.act = BTC_GAP_BLE_ACT_CFG_ADV_DATA_RAW;
|
||||
arg.cfg_adv_data_raw.raw_adv = raw_data;
|
||||
arg.cfg_adv_data_raw.raw_adv_len = raw_data_len;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), btc_gap_ble_arg_deep_copy) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_gap_config_scan_rsp_data_raw(uint8_t *raw_data, uint32_t raw_data_len)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_ble_gap_args_t arg;
|
||||
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
if (raw_data == NULL
|
||||
|| (raw_data_len <= 0 || raw_data_len > ESP_BLE_SCAN_RSP_DATA_LEN_MAX)) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GAP_BLE;
|
||||
msg.act = BTC_GAP_BLE_ACT_CFG_SCAN_RSP_DATA_RAW;
|
||||
arg.cfg_scan_rsp_data_raw.raw_scan_rsp = raw_data;
|
||||
arg.cfg_scan_rsp_data_raw.raw_scan_rsp_len = raw_data_len;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), btc_gap_ble_arg_deep_copy) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
|
||||
}
|
||||
|
@ -44,6 +44,8 @@ typedef enum {
|
||||
ESP_GAP_BLE_SCAN_RSP_DATA_SET_COMPLETE_EVT, /*!< When scan response data set complete, the event comes */
|
||||
ESP_GAP_BLE_SCAN_PARAM_SET_COMPLETE_EVT, /*!< When scan parameters set complete, the event comes */
|
||||
ESP_GAP_BLE_SCAN_RESULT_EVT, /*!< When one scan result ready, the event comes each time */
|
||||
ESP_GAP_BLE_ADV_DATA_RAW_SET_COMPLETE_EVT, /*!< When raw advertising data set complete, the event comes */
|
||||
ESP_GAP_BLE_SCAN_RSP_DATA_RAW_SET_COMPLETE_EVT, /*!< When raw advertising data set complete, the event comes */
|
||||
} esp_gap_ble_cb_event_t;
|
||||
|
||||
/// Advertising data maximum length
|
||||
@ -270,6 +272,18 @@ typedef union {
|
||||
int flag; /*!< Advertising data flag bit */
|
||||
int num_resps; /*!< Scan result number */
|
||||
} scan_rst; /*!< Event parameter of ESP_GAP_BLE_SCAN_RESULT_EVT */
|
||||
/**
|
||||
* @brief ESP_GAP_BLE_ADV_DATA_RAW_SET_COMPLETE_EVT
|
||||
*/
|
||||
struct ble_adv_data_raw_cmpl_evt_param {
|
||||
esp_bt_status_t status; /*!< Indicate the set raw advertising data operation success status */
|
||||
} adv_data_raw_cmpl; /*!< Event parameter of ESP_GAP_BLE_ADV_DATA_RAW_SET_COMPLETE_EVT */
|
||||
/**
|
||||
* @brief ESP_GAP_BLE_SCAN_RSP_DATA_RAW_SET_COMPLETE_EVT
|
||||
*/
|
||||
struct ble_scan_rsp_data_raw_cmpl_evt_param {
|
||||
esp_bt_status_t status; /*!< Indicate the set raw advertising data operation success status */
|
||||
} scan_rsp_data_raw_cmpl; /*!< Event parameter of ESP_GAP_BLE_SCAN_RSP_DATA_RAW_SET_COMPLETE_EVT */
|
||||
} esp_ble_gap_cb_param_t;
|
||||
|
||||
/**
|
||||
@ -448,6 +462,33 @@ esp_err_t esp_ble_gap_set_device_name(const char *name);
|
||||
*/
|
||||
uint8_t *esp_ble_resolve_adv_data(uint8_t *adv_data, uint8_t type, uint8_t *length);
|
||||
|
||||
/**
|
||||
* @brief This function is called to set raw advertising data. User need to fill
|
||||
* ADV data by self.
|
||||
*
|
||||
* @param[in] raw_data : raw advertising data
|
||||
* @param[in] raw_data_len : raw advertising data length , less than 31 bytes
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : success
|
||||
* - other : failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_gap_config_adv_data_raw(uint8_t *raw_data, uint32_t raw_data_len);
|
||||
|
||||
/**
|
||||
* @brief This function is called to set raw scan response data. User need to fill
|
||||
* scan response data by self.
|
||||
*
|
||||
* @param[in] raw_data : raw scan response data
|
||||
* @param[in] raw_data_len : raw scan response data length , less than 31 bytes
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : success
|
||||
* - other : failed
|
||||
*/
|
||||
esp_err_t esp_ble_gap_config_scan_rsp_data_raw(uint8_t *raw_data, uint32_t raw_data_len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -4608,6 +4608,30 @@ void bta_dm_ble_set_adv_config (tBTA_DM_MSG *p_data)
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_ble_set_adv_config_raw
|
||||
**
|
||||
** Description This function set the customized ADV data configuration
|
||||
**
|
||||
** Parameters:
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_dm_ble_set_adv_config_raw (tBTA_DM_MSG *p_data)
|
||||
{
|
||||
tBTA_STATUS status = BTA_FAILURE;
|
||||
|
||||
if (BTM_BleWriteAdvDataRaw(p_data->ble_set_adv_data_raw.p_raw_adv,
|
||||
p_data->ble_set_adv_data_raw.raw_adv_len) == BTM_SUCCESS) {
|
||||
status = BTA_SUCCESS;
|
||||
}
|
||||
|
||||
if (p_data->ble_set_adv_data_raw.p_adv_data_cback) {
|
||||
(*p_data->ble_set_adv_data_raw.p_adv_data_cback)(status);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_ble_set_scan_rsp
|
||||
@ -4631,6 +4655,29 @@ void bta_dm_ble_set_scan_rsp (tBTA_DM_MSG *p_data)
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_ble_set_scan_rsp_raw
|
||||
**
|
||||
** Description This function set the raw scan response data
|
||||
**
|
||||
** Parameters:
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_dm_ble_set_scan_rsp_raw (tBTA_DM_MSG *p_data)
|
||||
{
|
||||
tBTA_STATUS status = BTA_FAILURE;
|
||||
|
||||
if (BTM_BleWriteScanRspRaw(p_data->ble_set_adv_data_raw.p_raw_adv,
|
||||
p_data->ble_set_adv_data_raw.raw_adv_len) == BTM_SUCCESS) {
|
||||
status = BTA_SUCCESS;
|
||||
}
|
||||
|
||||
if (p_data->ble_set_adv_data_raw.p_adv_data_cback) {
|
||||
(*p_data->ble_set_adv_data_raw.p_adv_data_cback)(status);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_ble_set_data_length
|
||||
|
@ -1077,6 +1077,35 @@ void BTA_DmBleSetAdvConfig (tBTA_BLE_AD_MASK data_mask, tBTA_BLE_ADV_DATA *p_adv
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_DmBleSetAdvConfigRaw
|
||||
**
|
||||
** Description This function is called to set raw Advertising data
|
||||
**
|
||||
** Parameters p_raw_adv : raw advertising data.
|
||||
** raw_adv_len : raw advertising data length.
|
||||
** p_adv_data_cback : set adv data complete callback.
|
||||
**
|
||||
** Returns None
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_DmBleSetAdvConfigRaw (UINT8 *p_raw_adv, UINT32 raw_adv_len,
|
||||
tBTA_SET_ADV_DATA_CMPL_CBACK *p_adv_data_cback)
|
||||
{
|
||||
tBTA_DM_API_SET_ADV_CONFIG_RAW *p_msg;
|
||||
|
||||
if ((p_msg = (tBTA_DM_API_SET_ADV_CONFIG_RAW *)
|
||||
GKI_getbuf(sizeof(tBTA_DM_API_SET_ADV_CONFIG_RAW))) != NULL) {
|
||||
p_msg->hdr.event = BTA_DM_API_BLE_SET_ADV_CONFIG_RAW_EVT;
|
||||
p_msg->p_adv_data_cback = p_adv_data_cback;
|
||||
p_msg->p_raw_adv = p_raw_adv;
|
||||
p_msg->raw_adv_len = raw_adv_len;
|
||||
|
||||
bta_sys_sendmsg(p_msg);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_DmBleSetScanRsp
|
||||
@ -1104,6 +1133,35 @@ extern void BTA_DmBleSetScanRsp (tBTA_BLE_AD_MASK data_mask, tBTA_BLE_ADV_DATA *
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_DmBleSetScanRspRaw
|
||||
**
|
||||
** Description This function is called to set raw scan response data
|
||||
**
|
||||
** Parameters p_raw_scan_rsp : raw scan_rspertising data.
|
||||
** raw_scan_rsp_len : raw scan_rspertising data length.
|
||||
** p_scan_rsp_data_cback : set scan_rsp data complete callback.
|
||||
**
|
||||
** Returns None
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_DmBleSetScanRspRaw (UINT8 *p_raw_scan_rsp, UINT32 raw_scan_rsp_len,
|
||||
tBTA_SET_ADV_DATA_CMPL_CBACK *p_scan_rsp_data_cback)
|
||||
{
|
||||
tBTA_DM_API_SET_ADV_CONFIG_RAW *p_msg;
|
||||
|
||||
if ((p_msg = (tBTA_DM_API_SET_ADV_CONFIG_RAW *)
|
||||
GKI_getbuf(sizeof(tBTA_DM_API_SET_ADV_CONFIG_RAW))) != NULL) {
|
||||
p_msg->hdr.event = BTA_DM_API_BLE_SET_SCAN_RSP_RAW_EVT;
|
||||
p_msg->p_adv_data_cback = p_scan_rsp_data_cback;
|
||||
p_msg->p_raw_adv = p_raw_scan_rsp;
|
||||
p_msg->raw_adv_len = raw_scan_rsp_len;
|
||||
|
||||
bta_sys_sendmsg(p_msg);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_DmBleSetStorageParams
|
||||
|
@ -109,7 +109,11 @@ enum {
|
||||
support setting the ble advertising param by the APP******/
|
||||
BTA_DM_API_BLE_ADV_PARAM_All_EVT,
|
||||
BTA_DM_API_BLE_SET_ADV_CONFIG_EVT,
|
||||
/* Add for set raw advertising data */
|
||||
BTA_DM_API_BLE_SET_ADV_CONFIG_RAW_EVT,
|
||||
BTA_DM_API_BLE_SET_SCAN_RSP_EVT,
|
||||
/* Add for set raw scan response data */
|
||||
BTA_DM_API_BLE_SET_SCAN_RSP_RAW_EVT,
|
||||
BTA_DM_API_BLE_BROADCAST_EVT,
|
||||
BTA_DM_API_SET_DATA_LENGTH_EVT,
|
||||
|
||||
@ -545,6 +549,15 @@ typedef struct {
|
||||
tBTA_SET_ADV_DATA_CMPL_CBACK *p_adv_data_cback;
|
||||
} tBTA_DM_API_SET_ADV_CONFIG;
|
||||
|
||||
/* raw scan response and raw advertising data use
|
||||
the same structure */
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
UINT8 *p_raw_adv;
|
||||
UINT32 raw_adv_len;
|
||||
tBTA_SET_ADV_DATA_CMPL_CBACK *p_adv_data_cback;
|
||||
} tBTA_DM_API_SET_ADV_CONFIG_RAW;
|
||||
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
UINT8 batch_scan_full_max;
|
||||
@ -708,6 +721,7 @@ typedef union {
|
||||
tBTA_DM_API_BLE_ADV_PARAMS ble_set_adv_params;
|
||||
tBTA_DM_API_BLE_ADV_PARAMS_ALL ble_set_adv_params_all;
|
||||
tBTA_DM_API_SET_ADV_CONFIG ble_set_adv_data;
|
||||
tBTA_DM_API_SET_ADV_CONFIG_RAW ble_set_adv_data_raw;
|
||||
#if BLE_ANDROID_CONTROLLER_SCAN_FILTER == TRUE
|
||||
tBTA_DM_API_SCAN_FILTER_PARAM_SETUP ble_scan_filt_param_setup;
|
||||
tBTA_DM_API_CFG_FILTER_COND ble_cfg_filter_cond;
|
||||
@ -1093,9 +1107,11 @@ extern void bta_dm_ble_set_rand_address(tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_ble_stop_advertising(tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_ble_config_local_privacy (tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_ble_set_adv_params (tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_ble_set_adv_params_all (tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_ble_set_adv_params_all(tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_ble_set_adv_config (tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_ble_set_adv_config_raw (tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_ble_set_scan_rsp (tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_ble_set_scan_rsp_raw (tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_ble_broadcast (tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_ble_set_data_length(tBTA_DM_MSG *p_data);
|
||||
|
||||
|
@ -47,86 +47,95 @@ typedef void (*tBTA_DM_ACTION)(tBTA_DM_MSG *p_data);
|
||||
const tBTA_DM_ACTION bta_dm_action[BTA_DM_MAX_EVT] = {
|
||||
|
||||
/* device manager local device API events */
|
||||
bta_dm_enable, /* 0 BTA_DM_API_ENABLE_EVT */
|
||||
bta_dm_disable, /* 1 BTA_DM_API_DISABLE_EVT */
|
||||
bta_dm_set_dev_name, /* 2 BTA_DM_API_SET_NAME_EVT */
|
||||
bta_dm_set_visibility, /* 3 BTA_DM_API_SET_VISIBILITY_EVT */
|
||||
bta_dm_acl_change, /* 8 BTA_DM_ACL_CHANGE_EVT */
|
||||
bta_dm_add_device, /* 9 BTA_DM_API_ADD_DEVICE_EVT */
|
||||
bta_dm_close_acl, /* 10 BTA_DM_API_ADD_DEVICE_EVT */
|
||||
bta_dm_enable, /* 0 BTA_DM_API_ENABLE_EVT */
|
||||
bta_dm_disable, /* 1 BTA_DM_API_DISABLE_EVT */
|
||||
bta_dm_set_dev_name, /* 2 BTA_DM_API_SET_NAME_EVT */
|
||||
bta_dm_set_visibility, /* 3 BTA_DM_API_SET_VISIBILITY_EVT */
|
||||
bta_dm_acl_change, /* 8 BTA_DM_ACL_CHANGE_EVT */
|
||||
bta_dm_add_device, /* 9 BTA_DM_API_ADD_DEVICE_EVT */
|
||||
bta_dm_close_acl, /* 10 BTA_DM_API_ADD_DEVICE_EVT */
|
||||
|
||||
/* security API events */
|
||||
bta_dm_bond, /* 11 BTA_DM_API_BOND_EVT */
|
||||
bta_dm_bond_cancel, /* 12 BTA_DM_API_BOND_CANCEL_EVT */
|
||||
bta_dm_pin_reply, /* 13 BTA_DM_API_PIN_REPLY_EVT */
|
||||
bta_dm_bond, /* 11 BTA_DM_API_BOND_EVT */
|
||||
bta_dm_bond_cancel, /* 12 BTA_DM_API_BOND_CANCEL_EVT */
|
||||
bta_dm_pin_reply, /* 13 BTA_DM_API_PIN_REPLY_EVT */
|
||||
|
||||
/* power manger events */
|
||||
bta_dm_pm_btm_status, /* 16 BTA_DM_PM_BTM_STATUS_EVT */
|
||||
bta_dm_pm_timer, /* 17 BTA_DM_PM_TIMER_EVT*/
|
||||
bta_dm_pm_btm_status, /* 16 BTA_DM_PM_BTM_STATUS_EVT */
|
||||
bta_dm_pm_timer, /* 17 BTA_DM_PM_TIMER_EVT*/
|
||||
|
||||
/* simple pairing events */
|
||||
bta_dm_confirm, /* 18 BTA_DM_API_CONFIRM_EVT */
|
||||
bta_dm_confirm, /* 18 BTA_DM_API_CONFIRM_EVT */
|
||||
|
||||
bta_dm_set_encryption, /* BTA_DM_API_SET_ENCRYPTION_EVT */
|
||||
bta_dm_set_encryption, /* BTA_DM_API_SET_ENCRYPTION_EVT */
|
||||
|
||||
#if (BTM_OOB_INCLUDED == TRUE)
|
||||
bta_dm_loc_oob, /* 20 BTA_DM_API_LOC_OOB_EVT */
|
||||
bta_dm_ci_io_req_act, /* 21 BTA_DM_CI_IO_REQ_EVT */
|
||||
bta_dm_ci_rmt_oob_act, /* 22 BTA_DM_CI_RMT_OOB_EVT */
|
||||
bta_dm_loc_oob, /* 20 BTA_DM_API_LOC_OOB_EVT */
|
||||
bta_dm_ci_io_req_act, /* 21 BTA_DM_CI_IO_REQ_EVT */
|
||||
bta_dm_ci_rmt_oob_act, /* 22 BTA_DM_CI_RMT_OOB_EVT */
|
||||
#endif /* BTM_OOB_INCLUDED */
|
||||
|
||||
|
||||
#if BLE_INCLUDED == TRUE
|
||||
bta_dm_add_blekey, /* BTA_DM_API_ADD_BLEKEY_EVT */
|
||||
bta_dm_add_ble_device, /* BTA_DM_API_ADD_BLEDEVICE_EVT */
|
||||
bta_dm_ble_passkey_reply, /* BTA_DM_API_BLE_PASSKEY_REPLY_EVT */
|
||||
bta_dm_ble_confirm_reply, /* BTA_DM_API_BLE_CONFIRM_REPLY_EVT */
|
||||
bta_dm_add_blekey, /* BTA_DM_API_ADD_BLEKEY_EVT */
|
||||
bta_dm_add_ble_device, /* BTA_DM_API_ADD_BLEDEVICE_EVT */
|
||||
bta_dm_ble_passkey_reply, /* BTA_DM_API_BLE_PASSKEY_REPLY_EVT */
|
||||
bta_dm_ble_confirm_reply, /* BTA_DM_API_BLE_CONFIRM_REPLY_EVT */
|
||||
bta_dm_security_grant,
|
||||
bta_dm_ble_set_bg_conn_type,
|
||||
bta_dm_ble_set_conn_params, /* BTA_DM_API_BLE_CONN_PARAM_EVT */
|
||||
bta_dm_ble_set_conn_scan_params, /* BTA_DM_API_BLE_CONN_SCAN_PARAM_EVT */
|
||||
bta_dm_ble_set_scan_params, /* BTA_DM_API_BLE_SCAN_PARAM_EVT */
|
||||
bta_dm_ble_set_scan_fil_params, /* BTA_DM_API_BLE_SCAN_FIL_PARAM_EVT */
|
||||
bta_dm_ble_observe, /* BTA_DM_API_BLE_OBSERVE_EVT*/
|
||||
bta_dm_ble_update_conn_params, /* BTA_DM_API_UPDATE_CONN_PARAM_EVT */
|
||||
/*******This handler function added by Yulong at 2016/9/9 to
|
||||
support the random address setting for the APP******/
|
||||
bta_dm_ble_set_rand_address, /*BTA_DM_API_SET_RAND_ADDR_EVT*/
|
||||
/*******This handler function added by Yulong at 2016/10/19 to
|
||||
support stop the ble advertising setting by the APP******/
|
||||
bta_dm_ble_stop_advertising, /*BTA_DM_API_BLE_STOP_ADV_EVT*/
|
||||
bta_dm_ble_set_conn_params, /* BTA_DM_API_BLE_CONN_PARAM_EVT */
|
||||
bta_dm_ble_set_conn_scan_params, /* BTA_DM_API_BLE_CONN_SCAN_PARAM_EVT */
|
||||
bta_dm_ble_set_scan_params, /* BTA_DM_API_BLE_SCAN_PARAM_EVT */
|
||||
bta_dm_ble_set_scan_fil_params, /* BTA_DM_API_BLE_SCAN_FIL_PARAM_EVT */
|
||||
bta_dm_ble_observe, /* BTA_DM_API_BLE_OBSERVE_EVT*/
|
||||
bta_dm_ble_update_conn_params, /* BTA_DM_API_UPDATE_CONN_PARAM_EVT */
|
||||
/* This handler function added by
|
||||
Yulong at 2016/9/9 to support the
|
||||
random address setting for the APP */
|
||||
bta_dm_ble_set_rand_address, /* BTA_DM_API_SET_RAND_ADDR_EVT*/
|
||||
/* This handler function added by
|
||||
Yulong at 2016/10/19 to support
|
||||
stop the ble advertising setting
|
||||
by the APP */
|
||||
bta_dm_ble_stop_advertising, /* BTA_DM_API_BLE_STOP_ADV_EVT*/
|
||||
#if BLE_PRIVACY_SPT == TRUE
|
||||
bta_dm_ble_config_local_privacy, /* BTA_DM_API_LOCAL_PRIVACY_EVT */
|
||||
bta_dm_ble_config_local_privacy, /* BTA_DM_API_LOCAL_PRIVACY_EVT */
|
||||
#endif
|
||||
bta_dm_ble_set_adv_params, /* BTA_DM_API_BLE_ADV_PARAM_EVT */
|
||||
bta_dm_ble_set_adv_params_all, /* BTA_DM_API_BLE_ADV_PARAM_All_EVT */
|
||||
bta_dm_ble_set_adv_config, /* BTA_DM_API_BLE_SET_ADV_CONFIG_EVT */
|
||||
bta_dm_ble_set_scan_rsp, /* BTA_DM_API_BLE_SET_SCAN_RSPT */
|
||||
bta_dm_ble_broadcast, /* BTA_DM_API_BLE_BROADCAST_EVT */
|
||||
bta_dm_ble_set_data_length, /* BTA_DM_API_SET_DATA_LENGTH_EVT */
|
||||
bta_dm_ble_set_adv_params, /* BTA_DM_API_BLE_ADV_PARAM_EVT */
|
||||
bta_dm_ble_set_adv_params_all, /* BTA_DM_API_BLE_ADV_PARAM_All_EVT */
|
||||
bta_dm_ble_set_adv_config, /* BTA_DM_API_BLE_SET_ADV_CONFIG_EVT */
|
||||
/* New function to allow set raw adv
|
||||
data to HCI */
|
||||
bta_dm_ble_set_adv_config_raw, /* BTA_DM_API_BLE_SET_ADV_CONFIG_RAW_EVT */
|
||||
bta_dm_ble_set_scan_rsp, /* BTA_DM_API_BLE_SET_SCAN_RSP_EVT */
|
||||
/* New function to allow set raw scan
|
||||
response data to HCI */
|
||||
bta_dm_ble_set_scan_rsp_raw, /* BTA_DM_API_BLE_SET_SCAN_RSP_RAW_EVT */
|
||||
bta_dm_ble_broadcast, /* BTA_DM_API_BLE_BROADCAST_EVT */
|
||||
bta_dm_ble_set_data_length, /* BTA_DM_API_SET_DATA_LENGTH_EVT */
|
||||
#if BLE_ANDROID_CONTROLLER_SCAN_FILTER == TRUE
|
||||
bta_dm_cfg_filter_cond, /* BTA_DM_API_CFG_FILTER_COND_EVT */
|
||||
bta_dm_scan_filter_param_setup, /* BTA_DM_API_SCAN_FILTER_SETUP_EVT */
|
||||
bta_dm_enable_scan_filter, /* BTA_DM_API_SCAN_FILTER_ENABLE_EVT */
|
||||
bta_dm_cfg_filter_cond, /* BTA_DM_API_CFG_FILTER_COND_EVT */
|
||||
bta_dm_scan_filter_param_setup, /* BTA_DM_API_SCAN_FILTER_SETUP_EVT */
|
||||
bta_dm_enable_scan_filter, /* BTA_DM_API_SCAN_FILTER_ENABLE_EVT */
|
||||
#endif
|
||||
bta_dm_ble_multi_adv_enb, /* BTA_DM_API_BLE_MULTI_ADV_ENB_EVT*/
|
||||
bta_dm_ble_multi_adv_upd_param, /* BTA_DM_API_BLE_MULTI_ADV_PARAM_UPD_EVT */
|
||||
bta_dm_ble_multi_adv_data, /* BTA_DM_API_BLE_MULTI_ADV_DATA_EVT */
|
||||
btm_dm_ble_multi_adv_disable, /* BTA_DM_API_BLE_MULTI_ADV_DISABLE_EVT */
|
||||
bta_dm_ble_setup_storage, /* BTA_DM_API_BLE_SETUP_STORAGE_EVT */
|
||||
bta_dm_ble_enable_batch_scan, /* BTA_DM_API_BLE_ENABLE_BATCH_SCAN_EVT */
|
||||
bta_dm_ble_disable_batch_scan, /* BTA_DM_API_BLE_DISABLE_BATCH_SCAN_EVT */
|
||||
bta_dm_ble_read_scan_reports, /* BTA_DM_API_BLE_READ_SCAN_REPORTS_EVT */
|
||||
bta_dm_ble_track_advertiser, /* BTA_DM_API_BLE_TRACK_ADVERTISER_EVT */
|
||||
bta_dm_ble_get_energy_info, /* BTA_DM_API_BLE_ENERGY_INFO_EVT */
|
||||
bta_dm_ble_multi_adv_enb, /* BTA_DM_API_BLE_MULTI_ADV_ENB_EVT*/
|
||||
bta_dm_ble_multi_adv_upd_param, /* BTA_DM_API_BLE_MULTI_ADV_PARAM_UPD_EVT */
|
||||
bta_dm_ble_multi_adv_data, /* BTA_DM_API_BLE_MULTI_ADV_DATA_EVT */
|
||||
btm_dm_ble_multi_adv_disable, /* BTA_DM_API_BLE_MULTI_ADV_DISABLE_EVT */
|
||||
bta_dm_ble_setup_storage, /* BTA_DM_API_BLE_SETUP_STORAGE_EVT */
|
||||
bta_dm_ble_enable_batch_scan, /* BTA_DM_API_BLE_ENABLE_BATCH_SCAN_EVT */
|
||||
bta_dm_ble_disable_batch_scan, /* BTA_DM_API_BLE_DISABLE_BATCH_SCAN_EVT */
|
||||
bta_dm_ble_read_scan_reports, /* BTA_DM_API_BLE_READ_SCAN_REPORTS_EVT */
|
||||
bta_dm_ble_track_advertiser, /* BTA_DM_API_BLE_TRACK_ADVERTISER_EVT */
|
||||
bta_dm_ble_get_energy_info, /* BTA_DM_API_BLE_ENERGY_INFO_EVT */
|
||||
#endif
|
||||
|
||||
bta_dm_enable_test_mode, /* BTA_DM_API_ENABLE_TEST_MODE_EVT */
|
||||
bta_dm_disable_test_mode, /* BTA_DM_API_DISABLE_TEST_MODE_EVT */
|
||||
bta_dm_execute_callback, /* BTA_DM_API_EXECUTE_CBACK_EVT */
|
||||
bta_dm_enable_test_mode, /* BTA_DM_API_ENABLE_TEST_MODE_EVT */
|
||||
bta_dm_disable_test_mode, /* BTA_DM_API_DISABLE_TEST_MODE_EVT */
|
||||
bta_dm_execute_callback, /* BTA_DM_API_EXECUTE_CBACK_EVT */
|
||||
|
||||
bta_dm_remove_all_acl, /* BTA_DM_API_REMOVE_ALL_ACL_EVT */
|
||||
bta_dm_remove_device, /* BTA_DM_API_REMOVE_DEVICE_EVT */
|
||||
bta_dm_remove_all_acl, /* BTA_DM_API_REMOVE_ALL_ACL_EVT */
|
||||
bta_dm_remove_device, /* BTA_DM_API_REMOVE_DEVICE_EVT */
|
||||
};
|
||||
|
||||
|
||||
@ -161,24 +170,24 @@ enum {
|
||||
/* action function list */
|
||||
const tBTA_DM_ACTION bta_dm_search_action[] = {
|
||||
|
||||
bta_dm_search_start, /* 0 BTA_DM_API_SEARCH */
|
||||
bta_dm_search_cancel, /* 1 BTA_DM_API_SEARCH_CANCEL */
|
||||
bta_dm_discover, /* 2 BTA_DM_API_DISCOVER */
|
||||
bta_dm_inq_cmpl, /* 3 BTA_DM_INQUIRY_CMPL */
|
||||
bta_dm_rmt_name, /* 4 BTA_DM_REMT_NAME */
|
||||
bta_dm_sdp_result, /* 5 BTA_DM_SDP_RESULT */
|
||||
bta_dm_search_cmpl, /* 6 BTA_DM_SEARCH_CMPL */
|
||||
bta_dm_free_sdp_db, /* 7 BTA_DM_FREE_SDP_DB */
|
||||
bta_dm_disc_result, /* 8 BTA_DM_DISC_RESULT */
|
||||
bta_dm_search_result, /* 9 BTA_DM_SEARCH_RESULT */
|
||||
bta_dm_queue_search, /* 10 BTA_DM_QUEUE_SEARCH */
|
||||
bta_dm_queue_disc, /* 11 BTA_DM_QUEUE_DISC */
|
||||
bta_dm_search_clear_queue, /* 12 BTA_DM_SEARCH_CLEAR_QUEUE */
|
||||
bta_dm_search_cancel_cmpl, /* 13 BTA_DM_SEARCH_CANCEL_CMPL */
|
||||
bta_dm_search_cancel_notify, /* 14 BTA_DM_SEARCH_CANCEL_NOTIFY */
|
||||
bta_dm_search_cancel_transac_cmpl, /* 15 BTA_DM_SEARCH_CANCEL_TRANSAC_CMPL */
|
||||
bta_dm_disc_rmt_name, /* 16 BTA_DM_DISC_RMT_NAME */
|
||||
bta_dm_di_disc /* 17 BTA_DM_API_DI_DISCOVER */
|
||||
bta_dm_search_start, /* 0 BTA_DM_API_SEARCH */
|
||||
bta_dm_search_cancel, /* 1 BTA_DM_API_SEARCH_CANCEL */
|
||||
bta_dm_discover, /* 2 BTA_DM_API_DISCOVER */
|
||||
bta_dm_inq_cmpl, /* 3 BTA_DM_INQUIRY_CMPL */
|
||||
bta_dm_rmt_name, /* 4 BTA_DM_REMT_NAME */
|
||||
bta_dm_sdp_result, /* 5 BTA_DM_SDP_RESULT */
|
||||
bta_dm_search_cmpl, /* 6 BTA_DM_SEARCH_CMPL */
|
||||
bta_dm_free_sdp_db, /* 7 BTA_DM_FREE_SDP_DB */
|
||||
bta_dm_disc_result, /* 8 BTA_DM_DISC_RESULT */
|
||||
bta_dm_search_result, /* 9 BTA_DM_SEARCH_RESULT */
|
||||
bta_dm_queue_search, /* 10 BTA_DM_QUEUE_SEARCH */
|
||||
bta_dm_queue_disc, /* 11 BTA_DM_QUEUE_DISC */
|
||||
bta_dm_search_clear_queue, /* 12 BTA_DM_SEARCH_CLEAR_QUEUE */
|
||||
bta_dm_search_cancel_cmpl, /* 13 BTA_DM_SEARCH_CANCEL_CMPL */
|
||||
bta_dm_search_cancel_notify, /* 14 BTA_DM_SEARCH_CANCEL_NOTIFY */
|
||||
bta_dm_search_cancel_transac_cmpl, /* 15 BTA_DM_SEARCH_CANCEL_TRANSAC_CMPL */
|
||||
bta_dm_disc_rmt_name, /* 16 BTA_DM_DISC_RMT_NAME */
|
||||
bta_dm_di_disc /* 17 BTA_DM_API_DI_DISCOVER */
|
||||
#if BLE_INCLUDED == TRUE
|
||||
, bta_dm_close_gatt_conn
|
||||
#endif
|
||||
|
@ -2050,6 +2050,22 @@ extern void BTA_DmBleSetAdvConfig (tBTA_BLE_AD_MASK data_mask,
|
||||
tBTA_BLE_ADV_DATA *p_adv_cfg,
|
||||
tBTA_SET_ADV_DATA_CMPL_CBACK *p_adv_data_cback);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_DmBleSetAdvConfigRaw
|
||||
**
|
||||
** Description This function is called to set raw Advertising data
|
||||
**
|
||||
** Parameters p_raw_adv : raw advertising data.
|
||||
** raw_adv_len : raw advertising data length.
|
||||
** p_adv_data_cback : set adv data complete callback.
|
||||
**
|
||||
** Returns None
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void BTA_DmBleSetAdvConfigRaw (UINT8 *p_raw_adv, UINT32 raw_adv_len,
|
||||
tBTA_SET_ADV_DATA_CMPL_CBACK *p_adv_data_cback);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_DmBleSetScanRsp
|
||||
@ -2065,6 +2081,22 @@ extern void BTA_DmBleSetScanRsp (tBTA_BLE_AD_MASK data_mask,
|
||||
tBTA_BLE_ADV_DATA *p_adv_cfg,
|
||||
tBTA_SET_ADV_DATA_CMPL_CBACK *p_adv_data_cback);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_DmBleSetScanRspRaw
|
||||
**
|
||||
** Description This function is called to set raw scan response data
|
||||
**
|
||||
** Parameters p_raw_scan_rsp : raw scan_rspertising data.
|
||||
** raw_scan_rsp_len : raw scan_rspertising data length.
|
||||
** p_scan_rsp_data_cback : set scan_rsp data complete callback.
|
||||
**
|
||||
** Returns None
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void BTA_DmBleSetScanRspRaw (UINT8 *p_raw_scan_rsp, UINT32 raw_scan_rsp_len,
|
||||
tBTA_SET_ADV_DATA_CMPL_CBACK *p_scan_rsp_data_cback);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_DmBleBroadcast
|
||||
|
@ -30,7 +30,7 @@ static inline void btc_gap_ble_cb_to_app(esp_gap_ble_cb_event_t event, esp_ble_g
|
||||
{
|
||||
esp_gap_ble_cb_t btc_gap_ble_cb = (esp_gap_ble_cb_t)btc_profile_cb_get(BTC_PID_GAP_BLE);
|
||||
if (btc_gap_ble_cb) {
|
||||
btc_gap_ble_cb(event, param);
|
||||
btc_gap_ble_cb(event, param);
|
||||
}
|
||||
}
|
||||
|
||||
@ -303,6 +303,44 @@ static void btc_scan_rsp_data_callback(tBTA_STATUS status)
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_adv_data_raw_callback(tBTA_STATUS status)
|
||||
{
|
||||
esp_ble_gap_cb_param_t param;
|
||||
bt_status_t ret;
|
||||
btc_msg_t msg;
|
||||
|
||||
msg.sig = BTC_SIG_API_CB;
|
||||
msg.pid = BTC_PID_GAP_BLE;
|
||||
msg.act = ESP_GAP_BLE_ADV_DATA_RAW_SET_COMPLETE_EVT;
|
||||
param.adv_data_raw_cmpl.status = status;
|
||||
|
||||
ret = btc_transfer_context(&msg, ¶m,
|
||||
sizeof(esp_ble_gap_cb_param_t), NULL);
|
||||
|
||||
if (ret != BT_STATUS_SUCCESS) {
|
||||
LOG_ERROR("%s btc_transfer_context failed\n", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_scan_rsp_data_raw_callback(tBTA_STATUS status)
|
||||
{
|
||||
esp_ble_gap_cb_param_t param;
|
||||
bt_status_t ret;
|
||||
btc_msg_t msg;
|
||||
|
||||
msg.sig = BTC_SIG_API_CB;
|
||||
msg.pid = BTC_PID_GAP_BLE;
|
||||
msg.act = ESP_GAP_BLE_SCAN_RSP_DATA_RAW_SET_COMPLETE_EVT;
|
||||
param.scan_rsp_data_raw_cmpl.status = status;
|
||||
|
||||
ret = btc_transfer_context(&msg, ¶m,
|
||||
sizeof(esp_ble_gap_cb_param_t), NULL);
|
||||
|
||||
if (ret != BT_STATUS_SUCCESS) {
|
||||
LOG_ERROR("%s btc_transfer_context failed\n", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_ble_set_adv_data(esp_ble_adv_data_t *adv_data,
|
||||
tBTA_SET_ADV_DATA_CMPL_CBACK p_adv_data_cback)
|
||||
{
|
||||
@ -317,6 +355,18 @@ static void btc_ble_set_adv_data(esp_ble_adv_data_t *adv_data,
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_ble_set_adv_data_raw(uint8_t *raw_adv, uint32_t raw_adv_len,
|
||||
tBTA_SET_ADV_DATA_CMPL_CBACK p_adv_data_cback)
|
||||
{
|
||||
BTA_DmBleSetAdvConfigRaw(raw_adv, raw_adv_len, p_adv_data_cback);
|
||||
}
|
||||
|
||||
static void btc_ble_set_scan_rsp_data_raw(uint8_t *raw_scan_rsp, uint32_t raw_scan_rsp_len,
|
||||
tBTA_SET_ADV_DATA_CMPL_CBACK p_scan_rsp_data_cback)
|
||||
{
|
||||
BTA_DmBleSetScanRspRaw(raw_scan_rsp, raw_scan_rsp_len, p_scan_rsp_data_cback);
|
||||
}
|
||||
|
||||
static void btc_ble_start_advertising (esp_ble_adv_params_t *ble_adv_params)
|
||||
{
|
||||
tBLE_BD_ADDR peer_addr;
|
||||
@ -520,6 +570,12 @@ void btc_gap_ble_cb_handler(btc_msg_t *msg)
|
||||
case ESP_GAP_BLE_SCAN_RESULT_EVT:
|
||||
btc_gap_ble_cb_to_app(ESP_GAP_BLE_SCAN_RESULT_EVT, param);
|
||||
break;
|
||||
case ESP_GAP_BLE_ADV_DATA_RAW_SET_COMPLETE_EVT:
|
||||
btc_gap_ble_cb_to_app(ESP_GAP_BLE_ADV_DATA_RAW_SET_COMPLETE_EVT, param);
|
||||
break;
|
||||
case ESP_GAP_BLE_SCAN_RSP_DATA_RAW_SET_COMPLETE_EVT:
|
||||
btc_gap_ble_cb_to_app(ESP_GAP_BLE_SCAN_RSP_DATA_RAW_SET_COMPLETE_EVT, param);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
@ -551,6 +607,30 @@ void btc_gap_ble_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||
}
|
||||
break;
|
||||
}
|
||||
case BTC_GAP_BLE_ACT_CFG_ADV_DATA_RAW: {
|
||||
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;
|
||||
|
||||
if (src && src->cfg_adv_data_raw.raw_adv && src->cfg_adv_data_raw.raw_adv_len > 0) {
|
||||
dst->cfg_adv_data_raw.raw_adv = GKI_getbuf(src->cfg_adv_data_raw.raw_adv_len);
|
||||
if (dst->cfg_adv_data_raw.raw_adv) {
|
||||
memcpy(dst->cfg_adv_data_raw.raw_adv, src->cfg_adv_data_raw.raw_adv, src->cfg_adv_data_raw.raw_adv_len);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case BTC_GAP_BLE_ACT_CFG_SCAN_RSP_DATA_RAW: {
|
||||
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;
|
||||
|
||||
if (src && src->cfg_scan_rsp_data_raw.raw_scan_rsp && src->cfg_scan_rsp_data_raw.raw_scan_rsp_len > 0) {
|
||||
dst->cfg_scan_rsp_data_raw.raw_scan_rsp = GKI_getbuf(src->cfg_scan_rsp_data_raw.raw_scan_rsp_len);
|
||||
if (dst->cfg_scan_rsp_data_raw.raw_scan_rsp) {
|
||||
memcpy(dst->cfg_scan_rsp_data_raw.raw_scan_rsp, src->cfg_scan_rsp_data_raw.raw_scan_rsp, src->cfg_scan_rsp_data_raw.raw_scan_rsp_len);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
LOG_ERROR("Unhandled deep copy %d\n", msg->act);
|
||||
break;
|
||||
@ -576,6 +656,20 @@ static void btc_gap_ble_arg_deep_free(btc_msg_t *msg)
|
||||
}
|
||||
break;
|
||||
}
|
||||
case BTC_GAP_BLE_ACT_CFG_ADV_DATA_RAW: {
|
||||
uint8_t *raw_adv = ((btc_ble_gap_args_t *)msg->arg)->cfg_adv_data_raw.raw_adv;
|
||||
if (raw_adv) {
|
||||
GKI_freebuf(raw_adv);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case BTC_GAP_BLE_ACT_CFG_SCAN_RSP_DATA_RAW: {
|
||||
uint8_t *raw_scan_rsp = ((btc_ble_gap_args_t *)msg->arg)->cfg_scan_rsp_data_raw.raw_scan_rsp;
|
||||
if (raw_scan_rsp) {
|
||||
GKI_freebuf(raw_scan_rsp);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
LOG_DEBUG("Unhandled deep free %d\n", msg->act);
|
||||
break;
|
||||
@ -631,6 +725,16 @@ void btc_gap_ble_call_handler(btc_msg_t *msg)
|
||||
case BTC_GAP_BLE_ACT_SET_DEV_NAME:
|
||||
BTA_DmSetDeviceName(arg->set_dev_name.device_name);
|
||||
break;
|
||||
case BTC_GAP_BLE_ACT_CFG_ADV_DATA_RAW:
|
||||
btc_ble_set_adv_data_raw(arg->cfg_adv_data_raw.raw_adv,
|
||||
arg->cfg_adv_data_raw.raw_adv_len,
|
||||
btc_adv_data_raw_callback);
|
||||
break;
|
||||
case BTC_GAP_BLE_ACT_CFG_SCAN_RSP_DATA_RAW:
|
||||
btc_ble_set_scan_rsp_data_raw(arg->cfg_scan_rsp_data_raw.raw_scan_rsp,
|
||||
arg->cfg_scan_rsp_data_raw.raw_scan_rsp_len,
|
||||
btc_scan_rsp_data_raw_callback);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -32,6 +32,8 @@ typedef enum {
|
||||
BTC_GAP_BLE_ACT_SET_RAND_ADDRESS,
|
||||
BTC_GAP_BLE_ACT_CONFIG_LOCAL_PRIVACY,
|
||||
BTC_GAP_BLE_ACT_SET_DEV_NAME,
|
||||
BTC_GAP_BLE_ACT_CFG_ADV_DATA_RAW,
|
||||
BTC_GAP_BLE_ACT_CFG_SCAN_RSP_DATA_RAW,
|
||||
} btc_gap_ble_act_t;
|
||||
|
||||
/* btc_ble_gap_args_t */
|
||||
@ -76,6 +78,16 @@ typedef union {
|
||||
#define ESP_GAP_DEVICE_NAME_MAX (32)
|
||||
char device_name[ESP_GAP_DEVICE_NAME_MAX + 1];
|
||||
} set_dev_name;
|
||||
//BTC_GAP_BLE_ACT_CFG_ADV_DATA_RAW,
|
||||
struct config_adv_data_raw_args {
|
||||
uint8_t *raw_adv;
|
||||
uint32_t raw_adv_len;
|
||||
} cfg_adv_data_raw;
|
||||
//BTC_GAP_BLE_ACT_CFG_SCAN_RSP_DATA_RAW,
|
||||
struct config_scan_rsp_data_raw_args {
|
||||
uint8_t *raw_scan_rsp;
|
||||
uint32_t raw_scan_rsp_len;
|
||||
} cfg_scan_rsp_data_raw;
|
||||
} btc_ble_gap_args_t;
|
||||
|
||||
void btc_gap_ble_call_handler(btc_msg_t *msg);
|
||||
|
@ -1298,6 +1298,26 @@ tBTM_STATUS BTM_BleWriteScanRsp(tBTM_BLE_AD_MASK data_mask, tBTM_BLE_ADV_DATA *p
|
||||
return status;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTM_BleWriteScanRspRaw
|
||||
**
|
||||
** Description This function is called to write raw scan response data
|
||||
**
|
||||
** Parameters: None.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
tBTM_STATUS BTM_BleWriteScanRspRaw(UINT8 *p_raw_scan_rsp, UINT32 raw_scan_rsp_len)
|
||||
{
|
||||
if (btsnd_hcic_ble_set_scan_rsp_data((UINT8)raw_scan_rsp_len, p_raw_scan_rsp)) {
|
||||
return BTM_SUCCESS;
|
||||
} else {
|
||||
return BTM_NO_RESOURCES;
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTM_BleWriteAdvData
|
||||
@ -1345,6 +1365,27 @@ tBTM_STATUS BTM_BleWriteAdvData(tBTM_BLE_AD_MASK data_mask, tBTM_BLE_ADV_DATA *p
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTM_BleWriteAdvDataRaw
|
||||
**
|
||||
** Description This function is called to write raw advertising data.
|
||||
**
|
||||
** Parameters: None.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
tBTM_STATUS BTM_BleWriteAdvDataRaw(UINT8 *p_raw_adv, UINT32 raw_adv_len)
|
||||
{
|
||||
if (btsnd_hcic_ble_set_adv_data((UINT8)raw_adv_len, p_raw_adv)) {
|
||||
return BTM_SUCCESS;
|
||||
} else {
|
||||
return BTM_NO_RESOURCES;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTM_BleSetRandAddress
|
||||
|
@ -936,6 +936,22 @@ tBTM_STATUS BTM_BleSetAdvParamsStartAdv(UINT16 adv_int_min, UINT16 adv_int_max,
|
||||
tBTM_STATUS BTM_BleWriteAdvData(tBTM_BLE_AD_MASK data_mask,
|
||||
tBTM_BLE_ADV_DATA *p_data);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTM_BleWriteAdvDataRaw
|
||||
**
|
||||
** Description This function is called to write raw advertising data.
|
||||
**
|
||||
** Parameters: p_raw_adv : point to raw advertising data
|
||||
** raw_adv_len : raw advertising data
|
||||
**
|
||||
** Returns BTM_SUCCESS means success.
|
||||
**
|
||||
*******************************************************************************/
|
||||
//extern
|
||||
tBTM_STATUS BTM_BleWriteAdvDataRaw(UINT8 *p_raw_adv, UINT32 raw_adv_len);
|
||||
|
||||
|
||||
BOOLEAN BTM_BleSetRandAddress(BD_ADDR rand_addr);
|
||||
|
||||
|
||||
@ -1136,6 +1152,20 @@ tBTM_STATUS BTM_BleTrackAdvertiser(tBTM_BLE_TRACK_ADV_CBACK *p_track_cback,
|
||||
tBTM_STATUS BTM_BleWriteScanRsp(tBTM_BLE_AD_MASK data_mask,
|
||||
tBTM_BLE_ADV_DATA *p_data);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTM_BleWriteScanRspRaw
|
||||
**
|
||||
** Description This function is called to write raw scan response data
|
||||
**
|
||||
** Parameters: None.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
//extern
|
||||
tBTM_STATUS BTM_BleWriteScanRspRaw(UINT8 *p_raw_scan_rsp, UINT32 raw_scan_rsp_len);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTM_BleObserve
|
||||
|
@ -36,6 +36,7 @@ Macros
|
||||
.. doxygendefine:: ESP_BLE_ADV_FLAG_DMT_HOST_SPT
|
||||
.. doxygendefine:: ESP_BLE_ADV_FLAG_NON_LIMIT_DISC
|
||||
.. doxygendefine:: ESP_BLE_ADV_DATA_LEN_MAX
|
||||
.. doxygendefine:: ESP_BLE_SCAN_RSP_DATA_LEN_MAX
|
||||
|
||||
Type Definitions
|
||||
^^^^^^^^^^^^^^^^
|
||||
@ -86,6 +87,12 @@ Structures
|
||||
.. doxygenstruct:: esp_ble_gap_cb_param_t::ble_scan_result_evt_param
|
||||
:members:
|
||||
|
||||
.. doxygenstruct:: esp_ble_gap_cb_param_t::ble_adv_data_raw_cmpl_evt_param
|
||||
:members:
|
||||
|
||||
.. doxygenstruct:: esp_ble_gap_cb_param_t::ble_scan_rsp_data_raw_cmpl_evt_param
|
||||
:members:
|
||||
|
||||
|
||||
Functions
|
||||
^^^^^^^^^
|
||||
@ -103,4 +110,6 @@ Functions
|
||||
.. doxygenfunction:: esp_ble_gap_config_local_privacy
|
||||
.. doxygenfunction:: esp_ble_gap_set_device_name
|
||||
.. doxygenfunction:: esp_ble_resolve_adv_data
|
||||
.. doxygenfunction:: esp_ble_gap_config_adv_data_raw
|
||||
.. doxygenfunction:: esp_ble_gap_config_scan_rsp_data_raw
|
||||
|
||||
|
@ -3,3 +3,18 @@ ESP-IDF GATT SERVER demo
|
||||
|
||||
This is the demo for user to use ESP_APIs to create a GATT Server.
|
||||
|
||||
Options choose step:
|
||||
1. make menuconfig.
|
||||
2. enter menuconfig "Component config".
|
||||
3. enter menuconfig "Example 'GATT SERVER' Config".
|
||||
4. choose your options.
|
||||
|
||||
UPDATE NOTE
|
||||
===========
|
||||
|
||||
2017-01-19:
|
||||
1. Use New APIs to set raw advertising data and raw scan response data.
|
||||
2. Could use macro CONFIG_SET_RAW_ADV_DATA (should use menuconfig) to config use raw advertising/scan_response
|
||||
or use structure do automatically config. The macro CONFIG_SET_RAW_ADV will effect both advertising data
|
||||
and scan_response data.
|
||||
|
||||
|
10
examples/bluetooth/gatt_server/main/Kconfig
Normal file
10
examples/bluetooth/gatt_server/main/Kconfig
Normal file
@ -0,0 +1,10 @@
|
||||
menu "Example 'GATT SERVER' Config"
|
||||
|
||||
config SET_RAW_ADV_DATA
|
||||
bool "adv data or scan_rsp data use raw data or structure"
|
||||
default "y"
|
||||
help
|
||||
Set raw advertising data/scan response data by self or use adv_data/scan_rsp_data structure to
|
||||
set advertising data/scan response data. If use structure, lower layer will encapsulate the packets.
|
||||
|
||||
endmenu
|
@ -30,6 +30,8 @@
|
||||
#include "esp_bt_main.h"
|
||||
#include "esp_bt_main.h"
|
||||
|
||||
#include "sdkconfig.h"
|
||||
|
||||
#define GATTS_TAG "GATTS_DEMO"
|
||||
|
||||
///Declare the static function
|
||||
@ -51,8 +53,7 @@ static void gatts_profile_b_event_handler(esp_gatts_cb_event_t event, esp_gatt_i
|
||||
|
||||
#define GATTS_DEMO_CHAR_VAL_LEN_MAX 0x40
|
||||
|
||||
uint8_t char1_str[] ={0x11,0x22,0x33};
|
||||
|
||||
uint8_t char1_str[] = {0x11,0x22,0x33};
|
||||
esp_attr_value_t gatts_demo_char1_val =
|
||||
{
|
||||
.attr_max_len = GATTS_DEMO_CHAR_VAL_LEN_MAX,
|
||||
@ -60,7 +61,12 @@ esp_attr_value_t gatts_demo_char1_val =
|
||||
.attr_value = char1_str,
|
||||
};
|
||||
|
||||
|
||||
#ifdef CONFIG_SET_RAW_ADV_DATA
|
||||
static uint8_t raw_adv_data[] = {0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf,
|
||||
0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe};
|
||||
static uint8_t raw_scan_rsp_data[] = {0x7, 0x7, 0x7, 0x7, 0x8, 0x8, 0x8, 0x8, 0x9, 0x9, 0x9, 0x9, 0xa, 0xa, 0xa, 0xa,
|
||||
0xb, 0xb, 0xb, 0xb, 0xc, 0xc, 0xc, 0xc, 0xd, 0xd, 0xd, 0xd, 0xe, 0xe, 0xe};
|
||||
#else
|
||||
static uint8_t test_service_uuid128[32] = {
|
||||
/* LSB <--------------------------------------------------------------------------------> MSB */
|
||||
//first uuid, 16bit, [12],[13] is the value
|
||||
@ -85,6 +91,7 @@ static esp_ble_adv_data_t test_adv_data = {
|
||||
.p_service_uuid = test_service_uuid128,
|
||||
.flag = (ESP_BLE_ADV_FLAG_GEN_DISC | ESP_BLE_ADV_FLAG_BREDR_NOT_SPT),
|
||||
};
|
||||
#endif /* CONFIG_SET_RAW_ADV_DATA */
|
||||
|
||||
static esp_ble_adv_params_t test_adv_params = {
|
||||
.adv_int_min = 0x20,
|
||||
@ -134,6 +141,12 @@ static void gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param
|
||||
case ESP_GAP_BLE_ADV_DATA_SET_COMPLETE_EVT:
|
||||
esp_ble_gap_start_advertising(&test_adv_params);
|
||||
break;
|
||||
case ESP_GAP_BLE_ADV_DATA_RAW_SET_COMPLETE_EVT:
|
||||
esp_ble_gap_start_advertising(&test_adv_params);
|
||||
break;
|
||||
case ESP_GAP_BLE_SCAN_RSP_DATA_RAW_SET_COMPLETE_EVT:
|
||||
esp_ble_gap_start_advertising(&test_adv_params);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -149,8 +162,12 @@ static void gatts_profile_a_event_handler(esp_gatts_cb_event_t event, esp_gatt_i
|
||||
gl_profile_tab[PROFILE_A_APP_ID].service_id.id.uuid.uuid.uuid16 = GATTS_SERVICE_UUID_TEST_A;
|
||||
|
||||
esp_ble_gap_set_device_name(TEST_DEVICE_NAME);
|
||||
#ifdef CONFIG_SET_RAW_ADV_DATA
|
||||
esp_ble_gap_config_adv_data_raw(raw_adv_data, sizeof(raw_adv_data));
|
||||
esp_ble_gap_config_scan_rsp_data_raw(raw_scan_rsp_data, sizeof(raw_scan_rsp_data));
|
||||
#else
|
||||
esp_ble_gap_config_adv_data(&test_adv_data);
|
||||
|
||||
#endif
|
||||
esp_ble_gatts_create_service(gatts_if, &gl_profile_tab[PROFILE_A_APP_ID].service_id, GATTS_NUM_HANDLE_TEST_A);
|
||||
break;
|
||||
case ESP_GATTS_READ_EVT: {
|
||||
@ -252,9 +269,6 @@ static void gatts_profile_b_event_handler(esp_gatts_cb_event_t event, esp_gatt_i
|
||||
gl_profile_tab[PROFILE_B_APP_ID].service_id.id.uuid.len = ESP_UUID_LEN_16;
|
||||
gl_profile_tab[PROFILE_B_APP_ID].service_id.id.uuid.uuid.uuid16 = GATTS_SERVICE_UUID_TEST_B;
|
||||
|
||||
esp_ble_gap_set_device_name(TEST_DEVICE_NAME);
|
||||
esp_ble_gap_config_adv_data(&test_adv_data);
|
||||
|
||||
esp_ble_gatts_create_service(gatts_if, &gl_profile_tab[PROFILE_B_APP_ID].service_id, GATTS_NUM_HANDLE_TEST_B);
|
||||
break;
|
||||
case ESP_GATTS_READ_EVT: {
|
||||
|
Loading…
x
Reference in New Issue
Block a user