Merge branch 'feature/btdm_config_eir' into 'master'
components/bt: Add API to config EIR data See merge request idf/esp-idf!5038
This commit is contained in:
commit
4e09eaf8e2
22 changed files with 686 additions and 154 deletions
|
@ -137,6 +137,7 @@ if(CONFIG_BT_ENABLED)
|
|||
"bluedroid/btc/profile/std/hf_client/bta_hf_client_co.c"
|
||||
"bluedroid/btc/profile/std/gap/btc_gap_ble.c"
|
||||
"bluedroid/btc/profile/std/gap/btc_gap_bt.c"
|
||||
"bluedroid/btc/profile/std/gap/bta_gap_bt_co.c"
|
||||
"bluedroid/btc/profile/std/gatt/btc_gatt_common.c"
|
||||
"bluedroid/btc/profile/std/gatt/btc_gatt_util.c"
|
||||
"bluedroid/btc/profile/std/gatt/btc_gattc.c"
|
||||
|
|
|
@ -144,6 +144,38 @@ uint8_t *esp_bt_gap_resolve_eir_data(uint8_t *eir, esp_bt_eir_type_t type, uint8
|
|||
return BTM_CheckEirData(eir, type, length);
|
||||
}
|
||||
|
||||
esp_err_t esp_bt_gap_config_eir_data(esp_bt_eir_data_t *eir_data)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_gap_bt_args_t arg;
|
||||
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
if (eir_data == NULL) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
if (eir_data->manufacturer_len > ESP_BT_EIR_MAX_LEN
|
||||
|| eir_data->url_len > ESP_BT_EIR_MAX_LEN) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
if ((eir_data->manufacturer_len > 0 && eir_data->p_manufacturer_data == NULL)
|
||||
|| (eir_data->url_len > 0 && eir_data->p_url == NULL)) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GAP_BT;
|
||||
msg.act = BTC_GAP_BT_ACT_CONFIG_EIR;
|
||||
|
||||
memcpy(&arg.config_eir, eir_data, sizeof(esp_bt_eir_data_t));
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_gap_bt_args_t), btc_gap_bt_arg_deep_copy) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_bt_gap_set_cod(esp_bt_cod_t cod, esp_bt_cod_mode_t mode)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
|
|
|
@ -51,7 +51,8 @@ typedef enum {
|
|||
ESP_BT_STATUS_PEER_LE_DATA_LEN_UNSUPPORTED, /* relate to BTM_PEER_LE_DATA_LEN_UNSUPPORTED in stack/btm_api.h */
|
||||
ESP_BT_STATUS_CONTROL_LE_DATA_LEN_UNSUPPORTED,/* relate to BTM_CONTROL_LE_DATA_LEN_UNSUPPORTED in stack/btm_api.h */
|
||||
ESP_BT_STATUS_ERR_ILLEGAL_PARAMETER_FMT, /* relate to HCI_ERR_ILLEGAL_PARAMETER_FMT in stack/hcidefs.h */
|
||||
ESP_BT_STATUS_MEMORY_FULL, /* relate to BT_STATUS_MEMORY_FULL in bt_def.h */
|
||||
ESP_BT_STATUS_MEMORY_FULL = 20, /* relate to BT_STATUS_MEMORY_FULL in bt_def.h */
|
||||
ESP_BT_STATUS_EIR_TOO_LARGE, /* relate to BT_STATUS_EIR_TOO_LARGE in bt_def.h */
|
||||
} esp_bt_status_t;
|
||||
|
||||
|
||||
|
|
|
@ -90,8 +90,30 @@ typedef enum {
|
|||
ESP_BT_EIR_TYPE_SHORT_LOCAL_NAME = 0x08, /*!< Shortened Local Name */
|
||||
ESP_BT_EIR_TYPE_CMPL_LOCAL_NAME = 0x09, /*!< Complete Local Name */
|
||||
ESP_BT_EIR_TYPE_TX_POWER_LEVEL = 0x0a, /*!< Tx power level, value is 1 octet ranging from -127 to 127, unit is dBm*/
|
||||
ESP_BT_EIR_TYPE_URL = 0x24, /*!< Uniform resource identifier */
|
||||
ESP_BT_EIR_TYPE_MANU_SPECIFIC = 0xff, /*!< Manufacturer specific data */
|
||||
} esp_bt_eir_type_t;
|
||||
#define ESP_BT_EIR_TYPE_MAX_NUM 12 /*!< MAX number of EIR type */
|
||||
|
||||
/* ESP_BT_EIR_FLAG bit definition */
|
||||
#define ESP_BT_EIR_FLAG_LIMIT_DISC (0x01 << 0)
|
||||
#define ESP_BT_EIR_FLAG_GEN_DISC (0x01 << 1)
|
||||
#define ESP_BT_EIR_FLAG_BREDR_NOT_SPT (0x01 << 2)
|
||||
#define ESP_BT_EIR_FLAG_DMT_CONTROLLER_SPT (0x01 << 3)
|
||||
#define ESP_BT_EIR_FLAG_DMT_HOST_SPT (0x01 << 4)
|
||||
|
||||
#define ESP_BT_EIR_MAX_LEN 240
|
||||
/// EIR data content, according to "Supplement to the Bluetooth Core Specification"
|
||||
typedef struct {
|
||||
bool fec_required; /*!< FEC is required or not, true by default */
|
||||
bool include_txpower; /*!< EIR data include TX power, false by default */
|
||||
bool include_uuid; /*!< EIR data include UUID, false by default */
|
||||
uint8_t flag; /*!< EIR flags, see ESP_BT_EIR_FLAG for details, EIR will not include flag if it is 0, 0 by default */
|
||||
uint16_t manufacturer_len; /*!< Manufacturer data length, 0 by default */
|
||||
uint8_t *p_manufacturer_data; /*!< Manufacturer data point */
|
||||
uint16_t url_len; /*!< URL length, 0 by default */
|
||||
uint8_t *p_url; /*!< URL point */
|
||||
} esp_bt_eir_data_t;
|
||||
|
||||
/// Major service class field of Class of Device, mutiple bits can be set
|
||||
typedef enum {
|
||||
|
@ -179,6 +201,7 @@ typedef enum {
|
|||
ESP_BT_GAP_KEY_NOTIF_EVT, /*!< Simple Pairing Passkey Notification */
|
||||
ESP_BT_GAP_KEY_REQ_EVT, /*!< Simple Pairing Passkey request */
|
||||
ESP_BT_GAP_READ_RSSI_DELTA_EVT, /*!< read rssi event */
|
||||
ESP_BT_GAP_CONFIG_EIR_DATA_EVT, /*!< config EIR data event */
|
||||
ESP_BT_GAP_EVT_MAX,
|
||||
} esp_bt_gap_cb_event_t;
|
||||
|
||||
|
@ -237,6 +260,19 @@ typedef union {
|
|||
int8_t rssi_delta; /*!< rssi delta value range -128 ~127, The value zero indicates that the RSSI is inside the Golden Receive Power Range, the Golden Receive Power Range is from ESP_BT_GAP_RSSI_LOW_THRLD to ESP_BT_GAP_RSSI_HIGH_THRLD */
|
||||
} read_rssi_delta; /*!< read rssi parameter struct */
|
||||
|
||||
/**
|
||||
* @brief ESP_BT_GAP_CONFIG_EIR_DATA_EVT *
|
||||
*/
|
||||
struct config_eir_data_param {
|
||||
esp_bt_status_t stat; /*!< config EIR status:
|
||||
ESP_BT_STATUS_SUCCESS: config success
|
||||
ESP_BT_STATUS_EIR_TOO_LARGE: the EIR data is more than 240B. The EIR may not contain the whole data.
|
||||
others: failed
|
||||
*/
|
||||
uint8_t eir_type_num; /*!< the number of EIR types in EIR type */
|
||||
esp_bt_eir_type_t eir_type[ESP_BT_EIR_TYPE_MAX_NUM]; /*!< EIR types in EIR type */
|
||||
} config_eir_data; /*!< config EIR data */
|
||||
|
||||
/**
|
||||
* @brief ESP_BT_GAP_AUTH_CMPL_EVT
|
||||
*/
|
||||
|
@ -368,8 +404,8 @@ esp_err_t esp_bt_gap_set_scan_mode(esp_bt_connection_mode_t c_mode, esp_bt_disco
|
|||
|
||||
/**
|
||||
* @brief Start device discovery. This function should be called after esp_bluedroid_enable() completes successfully.
|
||||
* esp_bt_gap_cb_t will is called with ESP_BT_GAP_DISC_STATE_CHANGED_EVT if discovery is started or halted.
|
||||
* esp_bt_gap_cb_t will is called with ESP_BT_GAP_DISC_RES_EVT if discovery result is got.
|
||||
* esp_bt_gap_cb_t will be called with ESP_BT_GAP_DISC_STATE_CHANGED_EVT if discovery is started or halted.
|
||||
* esp_bt_gap_cb_t will be called with ESP_BT_GAP_DISC_RES_EVT if discovery result is got.
|
||||
*
|
||||
* @param[in] mode - inquiry mode
|
||||
* @param[in] inq_len - inquiry duration in 1.28 sec units, ranging from 0x01 to 0x30
|
||||
|
@ -385,7 +421,7 @@ esp_err_t esp_bt_gap_start_discovery(esp_bt_inq_mode_t mode, uint8_t inq_len, ui
|
|||
|
||||
/**
|
||||
* @brief Cancel device discovery. This function should be called after esp_bluedroid_enable() completes successfully
|
||||
* esp_bt_gap_cb_t will is called with ESP_BT_GAP_DISC_STATE_CHANGED_EVT if discovery is stopped.
|
||||
* esp_bt_gap_cb_t will be called with ESP_BT_GAP_DISC_STATE_CHANGED_EVT if discovery is stopped.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : Succeed
|
||||
|
@ -396,7 +432,7 @@ esp_err_t esp_bt_gap_cancel_discovery(void);
|
|||
|
||||
/**
|
||||
* @brief Start SDP to get remote services. This function should be called after esp_bluedroid_enable() completes successfully.
|
||||
* esp_bt_gap_cb_t will is called with ESP_BT_GAP_RMT_SRVCS_EVT after service discovery ends
|
||||
* esp_bt_gap_cb_t will be called with ESP_BT_GAP_RMT_SRVCS_EVT after service discovery ends
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : Succeed
|
||||
|
@ -409,7 +445,7 @@ esp_err_t esp_bt_gap_get_remote_services(esp_bd_addr_t remote_bda);
|
|||
* @brief Start SDP to look up the service matching uuid on the remote device. This function should be called after
|
||||
* esp_bluedroid_enable() completes successfully
|
||||
*
|
||||
* esp_bt_gap_cb_t will is called with ESP_BT_GAP_RMT_SRVC_REC_EVT after service discovery ends
|
||||
* esp_bt_gap_cb_t will be called with ESP_BT_GAP_RMT_SRVC_REC_EVT after service discovery ends
|
||||
* @return
|
||||
* - ESP_OK : Succeed
|
||||
* - ESP_ERR_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
|
@ -429,9 +465,23 @@ esp_err_t esp_bt_gap_get_remote_service_record(esp_bd_addr_t remote_bda, esp_bt_
|
|||
*/
|
||||
uint8_t *esp_bt_gap_resolve_eir_data(uint8_t *eir, esp_bt_eir_type_t type, uint8_t *length);
|
||||
|
||||
/**
|
||||
* @brief This function is called to config EIR data.
|
||||
*
|
||||
* esp_bt_gap_cb_t will be called with ESP_BT_GAP_CONFIG_EIR_DATA_EVT after config EIR ends.
|
||||
*
|
||||
* @param[in] eir_data - pointer of EIR data content
|
||||
* @return
|
||||
* - ESP_OK : Succeed
|
||||
* - ESP_ERR_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - ESP_ERR_INVALID_ARG: if param is invalid
|
||||
* - ESP_FAIL: others
|
||||
*/
|
||||
esp_err_t esp_bt_gap_config_eir_data(esp_bt_eir_data_t *eir_data);
|
||||
|
||||
/**
|
||||
* @brief This function is called to set class of device.
|
||||
* esp_bt_gap_cb_t will is called with ESP_BT_GAP_SET_COD_EVT after set COD ends
|
||||
* esp_bt_gap_cb_t will be called with ESP_BT_GAP_SET_COD_EVT after set COD ends
|
||||
* Some profile have special restrictions on class of device,
|
||||
* changes may cause these profile do not work
|
||||
*
|
||||
|
|
|
@ -131,7 +131,7 @@ static void bta_dm_observe_discard_cb (uint32_t num_dis);
|
|||
static void bta_dm_delay_role_switch_cback(TIMER_LIST_ENT *p_tle);
|
||||
extern void sdpu_uuid16_to_uuid128(UINT16 uuid16, UINT8 *p_uuid128);
|
||||
static void bta_dm_disable_timer_cback(TIMER_LIST_ENT *p_tle);
|
||||
|
||||
extern int bredr_txpwr_get(int *min_power_level, int *max_power_level);
|
||||
|
||||
const UINT16 bta_service_id_to_uuid_lkup_tbl [BTA_MAX_SERVICE_ID] = {
|
||||
UUID_SERVCLASS_PNP_INFORMATION, /* Reserved */
|
||||
|
@ -325,6 +325,58 @@ void bta_dm_deinit_cb(void)
|
|||
memset(&bta_dm_cb, 0, sizeof(bta_dm_cb));
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* Function bta_dm_eir_cfg_init
|
||||
*
|
||||
* Description Initializes the p_bta_dm_eir_cfg
|
||||
*
|
||||
*
|
||||
* Returns void
|
||||
*
|
||||
******************************************************************************/
|
||||
static void bta_dm_eir_cfg_init(void)
|
||||
{
|
||||
p_bta_dm_eir_cfg->bta_dm_eir_fec_required = BTM_EIR_DEFAULT_FEC_REQUIRED;
|
||||
p_bta_dm_eir_cfg->bta_dm_eir_min_name_len = 50;
|
||||
|
||||
p_bta_dm_eir_cfg->bta_dm_eir_included_uuid = TRUE;
|
||||
p_bta_dm_eir_cfg->bta_dm_eir_included_tx_power = FALSE;
|
||||
p_bta_dm_eir_cfg->bta_dm_eir_inq_tx_power = 3;
|
||||
p_bta_dm_eir_cfg->bta_dm_eir_flags = 0;
|
||||
|
||||
p_bta_dm_eir_cfg->bta_dm_eir_manufac_spec_len = 0;
|
||||
p_bta_dm_eir_cfg->bta_dm_eir_manufac_spec = NULL;
|
||||
|
||||
p_bta_dm_eir_cfg->bta_dm_eir_url_len = 0;
|
||||
p_bta_dm_eir_cfg->bta_dm_eir_url = NULL;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* Function bta_dm_eir_cfg_deinit
|
||||
*
|
||||
* Description De-initializes the p_bta_dm_eir_cfg
|
||||
*
|
||||
*
|
||||
* Returns void
|
||||
*
|
||||
******************************************************************************/
|
||||
static void bta_dm_eir_cfg_deinit(void)
|
||||
{
|
||||
p_bta_dm_eir_cfg->bta_dm_eir_manufac_spec_len = 0;
|
||||
if (p_bta_dm_eir_cfg->bta_dm_eir_manufac_spec) {
|
||||
osi_free(p_bta_dm_eir_cfg->bta_dm_eir_manufac_spec);
|
||||
p_bta_dm_eir_cfg->bta_dm_eir_manufac_spec = NULL;
|
||||
}
|
||||
|
||||
p_bta_dm_eir_cfg->bta_dm_eir_url_len = 0;
|
||||
if (p_bta_dm_eir_cfg->bta_dm_eir_url) {
|
||||
osi_free(p_bta_dm_eir_cfg->bta_dm_eir_url);
|
||||
p_bta_dm_eir_cfg->bta_dm_eir_url = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_sys_hw_cback
|
||||
|
@ -363,6 +415,9 @@ static void bta_dm_sys_hw_cback( tBTA_SYS_HW_EVT status )
|
|||
/* reinitialize the control block */
|
||||
bta_dm_deinit_cb();
|
||||
|
||||
/* reinitialize the Extended Inquiry Response */
|
||||
bta_dm_eir_cfg_deinit();
|
||||
|
||||
bta_sys_free_timer(&bta_dm_search_cb.search_timer);
|
||||
#if ((defined BLE_INCLUDED) && (BLE_INCLUDED == TRUE))
|
||||
#if ((defined BTA_GATT_INCLUDED) && (BTA_GATT_INCLUDED == TRUE) && SDP_INCLUDED == TRUE)
|
||||
|
@ -391,6 +446,9 @@ static void bta_dm_sys_hw_cback( tBTA_SYS_HW_EVT status )
|
|||
/* make sure the control block is properly initialized */
|
||||
bta_dm_init_cb();
|
||||
|
||||
/* make sure the Extended Inquiry Response is properly initialized */
|
||||
bta_dm_eir_cfg_init();
|
||||
|
||||
/* and retrieve the callback */
|
||||
bta_dm_cb.p_sec_cback = temp_cback;
|
||||
bta_dm_cb.is_bta_dm_active = TRUE;
|
||||
|
@ -588,9 +646,52 @@ static void bta_dm_disable_timer_cback (TIMER_LIST_ENT *p_tle)
|
|||
*******************************************************************************/
|
||||
void bta_dm_set_dev_name (tBTA_DM_MSG *p_data)
|
||||
{
|
||||
|
||||
BTM_SetLocalDeviceName((char *)p_data->set_name.name);
|
||||
#if CLASSIC_BT_INCLUDED
|
||||
bta_dm_set_eir ((char *)p_data->set_name.name);
|
||||
#endif /// CLASSIC_BT_INCLUDED
|
||||
}
|
||||
|
||||
void bta_dm_config_eir (tBTA_DM_MSG *p_data)
|
||||
{
|
||||
tBTA_DM_API_CONFIG_EIR *config_eir = &p_data->config_eir;
|
||||
|
||||
p_bta_dm_eir_cfg->bta_dm_eir_fec_required = config_eir->eir_fec_required;
|
||||
p_bta_dm_eir_cfg->bta_dm_eir_included_uuid = config_eir->eir_included_uuid;
|
||||
p_bta_dm_eir_cfg->bta_dm_eir_included_tx_power = config_eir->eir_included_tx_power;
|
||||
p_bta_dm_eir_cfg->bta_dm_eir_flags = config_eir->eir_flags;
|
||||
p_bta_dm_eir_cfg->bta_dm_eir_manufac_spec_len = config_eir->eir_manufac_spec_len;
|
||||
p_bta_dm_eir_cfg->bta_dm_eir_url_len = config_eir->eir_url_len;
|
||||
|
||||
if (p_bta_dm_eir_cfg->bta_dm_eir_manufac_spec) {
|
||||
osi_free(p_bta_dm_eir_cfg->bta_dm_eir_manufac_spec);
|
||||
p_bta_dm_eir_cfg->bta_dm_eir_manufac_spec = NULL;
|
||||
}
|
||||
if (config_eir->eir_manufac_spec) {
|
||||
p_bta_dm_eir_cfg->bta_dm_eir_manufac_spec = osi_malloc(config_eir->eir_manufac_spec_len);
|
||||
if (p_bta_dm_eir_cfg->bta_dm_eir_manufac_spec) {
|
||||
memcpy(p_bta_dm_eir_cfg->bta_dm_eir_manufac_spec, config_eir->eir_manufac_spec, config_eir->eir_manufac_spec_len);
|
||||
} else {
|
||||
APPL_TRACE_ERROR("%s, malloc failed.", __func__);
|
||||
p_bta_dm_eir_cfg->bta_dm_eir_manufac_spec_len = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (p_bta_dm_eir_cfg->bta_dm_eir_url) {
|
||||
osi_free(p_bta_dm_eir_cfg->bta_dm_eir_url);
|
||||
p_bta_dm_eir_cfg->bta_dm_eir_url = NULL;
|
||||
}
|
||||
if (config_eir->eir_url) {
|
||||
p_bta_dm_eir_cfg->bta_dm_eir_url = osi_malloc(config_eir->eir_url_len);
|
||||
if (p_bta_dm_eir_cfg->bta_dm_eir_url == NULL) {
|
||||
memcpy(p_bta_dm_eir_cfg->bta_dm_eir_url, config_eir->eir_url, config_eir->eir_url_len);
|
||||
} else {
|
||||
APPL_TRACE_ERROR("%s, malloc failed.", __func__);
|
||||
p_bta_dm_eir_cfg->bta_dm_eir_url_len = 0;
|
||||
}
|
||||
}
|
||||
|
||||
bta_dm_set_eir(NULL);
|
||||
}
|
||||
|
||||
void bta_dm_update_white_list(tBTA_DM_MSG *p_data)
|
||||
|
@ -3719,23 +3820,37 @@ static void bta_dm_set_eir (char *local_name)
|
|||
UINT8 custom_uuid_idx;
|
||||
#endif // BTA_EIR_SERVER_NUM_CUSTOM_UUID
|
||||
#endif // BTA_EIR_CANNED_UUID_LIST
|
||||
#if (BTM_EIR_DEFAULT_FEC_REQUIRED == FALSE)
|
||||
UINT8 free_eir_length = HCI_EXT_INQ_RESPONSE_LEN;
|
||||
#else // BTM_EIR_DEFAULT_FEC_REQUIRED
|
||||
UINT8 free_eir_length = HCI_DM5_PACKET_SIZE;
|
||||
#endif // BTM_EIR_DEFAULT_FEC_REQUIRED
|
||||
|
||||
UINT8 free_eir_length;
|
||||
if (p_bta_dm_eir_cfg->bta_dm_eir_fec_required) {
|
||||
free_eir_length = HCI_DM5_PACKET_SIZE;
|
||||
} else {
|
||||
free_eir_length = HCI_EXT_INQ_RESPONSE_LEN;
|
||||
}
|
||||
|
||||
UINT8 num_uuid;
|
||||
UINT8 data_type;
|
||||
UINT8 local_name_len;
|
||||
|
||||
UINT8 eir_type[BTM_EIR_TYPE_MAX_NUM];
|
||||
UINT8 eir_type_num = 0;
|
||||
|
||||
tBTA_STATUS status = BTA_SUCCESS;
|
||||
|
||||
/* wait until complete to disable */
|
||||
if (bta_dm_cb.disable_timer.in_use) {
|
||||
if (p_bta_dm_eir_cfg->config_eir_callback) {
|
||||
p_bta_dm_eir_cfg->config_eir_callback(BTA_WRONG_MODE, eir_type_num , eir_type);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
#if ( BTA_EIR_CANNED_UUID_LIST != TRUE )
|
||||
/* wait until App is ready */
|
||||
if (bta_dm_cb.app_ready_timer.in_use) {
|
||||
if (p_bta_dm_eir_cfg->config_eir_callback) {
|
||||
p_bta_dm_eir_cfg->config_eir_callback(BTA_WRONG_MODE, eir_type_num , eir_type);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -3750,6 +3865,9 @@ static void bta_dm_set_eir (char *local_name)
|
|||
/* Allocate a buffer to hold HCI command */
|
||||
if ((p_buf = (BT_HDR *)osi_malloc(BTM_CMD_BUF_SIZE)) == NULL) {
|
||||
APPL_TRACE_ERROR("bta_dm_set_eir couldn't allocate buffer");
|
||||
if (p_bta_dm_eir_cfg->config_eir_callback) {
|
||||
p_bta_dm_eir_cfg->config_eir_callback(BTA_NO_RESOURCES, eir_type_num , eir_type);
|
||||
}
|
||||
return;
|
||||
}
|
||||
p = (UINT8 *)p_buf + BTM_HCI_EIR_OFFSET;
|
||||
|
@ -3790,6 +3908,7 @@ static void bta_dm_set_eir (char *local_name)
|
|||
|
||||
UINT8_TO_STREAM(p, local_name_len + 1);
|
||||
UINT8_TO_STREAM(p, data_type);
|
||||
eir_type[eir_type_num++] = data_type;
|
||||
|
||||
if (local_name != NULL) {
|
||||
memcpy(p, local_name, local_name_len);
|
||||
|
@ -3797,6 +3916,8 @@ static void bta_dm_set_eir (char *local_name)
|
|||
}
|
||||
free_eir_length -= local_name_len + 2;
|
||||
|
||||
/* if UUIDs are provided in configuration */
|
||||
if (p_bta_dm_eir_cfg->bta_dm_eir_included_uuid) {
|
||||
#if (BTA_EIR_CANNED_UUID_LIST == TRUE)
|
||||
/* if UUID list is provided as static data in configuration */
|
||||
if (( p_bta_dm_eir_cfg->bta_dm_eir_uuid16_len > 0 )
|
||||
|
@ -3814,9 +3935,12 @@ static void bta_dm_set_eir (char *local_name)
|
|||
}
|
||||
UINT8_TO_STREAM(p, num_uuid * LEN_UUID_16 + 1);
|
||||
UINT8_TO_STREAM(p, data_type);
|
||||
eir_type[eir_type_num++] = data_type;
|
||||
memcpy(p, p_bta_dm_eir_cfg->bta_dm_eir_uuid16, num_uuid * LEN_UUID_16 );
|
||||
p += num_uuid * LEN_UUID_16;
|
||||
free_eir_length -= num_uuid * LEN_UUID_16;
|
||||
} else {
|
||||
status = BTA_EIR_TOO_LARGE;
|
||||
}
|
||||
}
|
||||
#else /* (BTA_EIR_CANNED_UUID_LIST == TRUE) */
|
||||
|
@ -3851,7 +3975,10 @@ static void bta_dm_set_eir (char *local_name)
|
|||
|
||||
UINT8_TO_STREAM(p_length, num_uuid * LEN_UUID_16 + 1);
|
||||
UINT8_TO_STREAM(p_type, data_type);
|
||||
eir_type[eir_type_num++] = data_type;
|
||||
free_eir_length -= num_uuid * LEN_UUID_16 + 2;
|
||||
} else {
|
||||
status = BTA_EIR_TOO_LARGE;
|
||||
}
|
||||
#endif /* (BTA_EIR_CANNED_UUID_LIST == TRUE) */
|
||||
|
||||
|
@ -3880,7 +4007,10 @@ static void bta_dm_set_eir (char *local_name)
|
|||
|
||||
UINT8_TO_STREAM(p_length, num_uuid * LEN_UUID_32 + 1);
|
||||
UINT8_TO_STREAM(p_type, data_type);
|
||||
eir_type[eir_type_num++] = data_type;
|
||||
free_eir_length -= num_uuid * LEN_UUID_32 + 2;
|
||||
} else {
|
||||
status = BTA_EIR_TOO_LARGE;
|
||||
}
|
||||
|
||||
/* Adding 128-bit UUID list */
|
||||
|
@ -3907,54 +4037,97 @@ static void bta_dm_set_eir (char *local_name)
|
|||
|
||||
UINT8_TO_STREAM(p_length, num_uuid * LEN_UUID_128 + 1);
|
||||
UINT8_TO_STREAM(p_type, data_type);
|
||||
eir_type[eir_type_num++] = data_type;
|
||||
free_eir_length -= num_uuid * LEN_UUID_128 + 2;
|
||||
}
|
||||
else {
|
||||
status = BTA_EIR_TOO_LARGE;
|
||||
}
|
||||
#endif /* ( BTA_EIR_CANNED_UUID_LIST != TRUE )&&(BTA_EIR_SERVER_NUM_CUSTOM_UUID > 0) */
|
||||
}
|
||||
|
||||
/* if Flags are provided in configuration */
|
||||
if (( p_bta_dm_eir_cfg->bta_dm_eir_flag_len > 0 )
|
||||
&& ( p_bta_dm_eir_cfg->bta_dm_eir_flags )
|
||||
&& ( free_eir_length >= p_bta_dm_eir_cfg->bta_dm_eir_flag_len + 2 )) {
|
||||
UINT8_TO_STREAM(p, p_bta_dm_eir_cfg->bta_dm_eir_flag_len + 1);
|
||||
if ( p_bta_dm_eir_cfg->bta_dm_eir_flags != 0 ) {
|
||||
if ( free_eir_length >= 3 ) {
|
||||
UINT8_TO_STREAM(p, 2);
|
||||
UINT8_TO_STREAM(p, BTM_EIR_FLAGS_TYPE);
|
||||
memcpy(p, p_bta_dm_eir_cfg->bta_dm_eir_flags,
|
||||
p_bta_dm_eir_cfg->bta_dm_eir_flag_len);
|
||||
p += p_bta_dm_eir_cfg->bta_dm_eir_flag_len;
|
||||
free_eir_length -= p_bta_dm_eir_cfg->bta_dm_eir_flag_len + 2;
|
||||
eir_type[eir_type_num++] = BTM_EIR_FLAGS_TYPE;
|
||||
UINT8_TO_STREAM(p, p_bta_dm_eir_cfg->bta_dm_eir_flags);
|
||||
free_eir_length -= 3;
|
||||
} else {
|
||||
status = BTA_EIR_TOO_LARGE;
|
||||
}
|
||||
}
|
||||
|
||||
/* if Manufacturer Specific are provided in configuration */
|
||||
if (( p_bta_dm_eir_cfg->bta_dm_eir_manufac_spec_len > 0 )
|
||||
&& ( p_bta_dm_eir_cfg->bta_dm_eir_manufac_spec )
|
||||
&& ( free_eir_length >= p_bta_dm_eir_cfg->bta_dm_eir_manufac_spec_len + 2 )) {
|
||||
&& ( p_bta_dm_eir_cfg->bta_dm_eir_manufac_spec )) {
|
||||
if ( free_eir_length >= p_bta_dm_eir_cfg->bta_dm_eir_manufac_spec_len + 2) {
|
||||
p_length = p;
|
||||
|
||||
UINT8_TO_STREAM(p, p_bta_dm_eir_cfg->bta_dm_eir_manufac_spec_len + 1);
|
||||
UINT8_TO_STREAM(p, BTM_EIR_MANUFACTURER_SPECIFIC_TYPE);
|
||||
eir_type[eir_type_num++] = BTM_EIR_MANUFACTURER_SPECIFIC_TYPE;
|
||||
memcpy(p, p_bta_dm_eir_cfg->bta_dm_eir_manufac_spec,
|
||||
p_bta_dm_eir_cfg->bta_dm_eir_manufac_spec_len);
|
||||
p += p_bta_dm_eir_cfg->bta_dm_eir_manufac_spec_len;
|
||||
free_eir_length -= p_bta_dm_eir_cfg->bta_dm_eir_manufac_spec_len + 2;
|
||||
|
||||
} else {
|
||||
status = BTA_EIR_TOO_LARGE;
|
||||
}
|
||||
} else {
|
||||
p_length = NULL;
|
||||
}
|
||||
|
||||
/* if Inquiry Tx Resp Power compiled */
|
||||
if ((p_bta_dm_eir_cfg->bta_dm_eir_inq_tx_power) &&
|
||||
(free_eir_length >= 3)) {
|
||||
if (p_bta_dm_eir_cfg->bta_dm_eir_included_tx_power) {
|
||||
if (free_eir_length >= 3) {
|
||||
int min_power_level, max_power_level;
|
||||
if (bredr_txpwr_get(&min_power_level, &max_power_level) == 0) {
|
||||
INT8 btm_tx_power[BTM_TX_POWER_LEVEL_MAX + 1] = BTM_TX_POWER;
|
||||
p_bta_dm_eir_cfg->bta_dm_eir_inq_tx_power = btm_tx_power[max_power_level];
|
||||
UINT8_TO_STREAM(p, 2); /* Length field */
|
||||
UINT8_TO_STREAM(p, BTM_EIR_TX_POWER_LEVEL_TYPE);
|
||||
UINT8_TO_STREAM(p, *(p_bta_dm_eir_cfg->bta_dm_eir_inq_tx_power));
|
||||
eir_type[eir_type_num++] = BTM_EIR_TX_POWER_LEVEL_TYPE;
|
||||
UINT8_TO_STREAM(p, p_bta_dm_eir_cfg->bta_dm_eir_inq_tx_power);
|
||||
free_eir_length -= 3;
|
||||
}
|
||||
} else {
|
||||
status = BTA_EIR_TOO_LARGE;
|
||||
}
|
||||
}
|
||||
|
||||
/* if URL are provided in configuration */
|
||||
if (( p_bta_dm_eir_cfg->bta_dm_eir_url_len > 0 )
|
||||
&& ( p_bta_dm_eir_cfg->bta_dm_eir_url )) {
|
||||
if ( free_eir_length >= p_bta_dm_eir_cfg->bta_dm_eir_url_len + 2 ) {
|
||||
UINT8_TO_STREAM(p, p_bta_dm_eir_cfg->bta_dm_eir_url_len + 1);
|
||||
UINT8_TO_STREAM(p, BTM_EIR_URL_TYPE);
|
||||
eir_type[eir_type_num++] = BTM_EIR_URL_TYPE;
|
||||
memcpy(p, p_bta_dm_eir_cfg->bta_dm_eir_url,
|
||||
p_bta_dm_eir_cfg->bta_dm_eir_url_len);
|
||||
p += p_bta_dm_eir_cfg->bta_dm_eir_url_len;
|
||||
free_eir_length -= p_bta_dm_eir_cfg->bta_dm_eir_url_len + 2;
|
||||
} else {
|
||||
status = BTA_EIR_TOO_LARGE;
|
||||
}
|
||||
}
|
||||
|
||||
if ( free_eir_length ) {
|
||||
UINT8_TO_STREAM(p, 0); /* terminator of significant part */
|
||||
}
|
||||
|
||||
BTM_WriteEIR( p_buf );
|
||||
tBTM_STATUS btm_status = BTM_WriteEIR( p_buf, p_bta_dm_eir_cfg->bta_dm_eir_fec_required );
|
||||
|
||||
if ( btm_status == BTM_MODE_UNSUPPORTED) {
|
||||
status = BTA_WRONG_MODE;
|
||||
} else if (btm_status != BTM_SUCCESS) {
|
||||
status = BTA_FAILURE;
|
||||
}
|
||||
|
||||
if (p_bta_dm_eir_cfg->config_eir_callback) {
|
||||
p_bta_dm_eir_cfg->config_eir_callback(status, eir_type_num, eir_type);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
|
|
|
@ -183,6 +183,48 @@ void BTA_DmSetDeviceName(const char *p_name)
|
|||
|
||||
}
|
||||
|
||||
void BTA_DmConfigEir(tBTA_DM_EIR_CONF *eir_config)
|
||||
{
|
||||
tBTA_DM_API_CONFIG_EIR *p_msg;
|
||||
|
||||
UINT8 eir_manufac_spec_len = eir_config->bta_dm_eir_manufac_spec_len;
|
||||
UINT8 eir_url_len = eir_config->bta_dm_eir_url_len;
|
||||
|
||||
if (eir_manufac_spec_len > HCI_EXT_INQ_RESPONSE_LEN) {
|
||||
APPL_TRACE_WARNING ("%s: Manufacturer data is too long(%d), cut it to %d\n",
|
||||
__func__, eir_manufac_spec_len, HCI_EXT_INQ_RESPONSE_LEN);
|
||||
eir_manufac_spec_len = HCI_EXT_INQ_RESPONSE_LEN;
|
||||
}
|
||||
if (eir_url_len > HCI_EXT_INQ_RESPONSE_LEN) {
|
||||
APPL_TRACE_WARNING ("%s: URL is too long(%d), cut it to %d\n",
|
||||
__func__, eir_url_len, HCI_EXT_INQ_RESPONSE_LEN);
|
||||
eir_url_len = HCI_EXT_INQ_RESPONSE_LEN;
|
||||
}
|
||||
|
||||
if ((p_msg = (tBTA_DM_API_CONFIG_EIR *) osi_malloc(sizeof(tBTA_DM_API_CONFIG_EIR) + eir_manufac_spec_len + eir_url_len)) != NULL) {
|
||||
p_msg->hdr.event = BTA_DM_API_CONFIG_EIR_EVT;
|
||||
|
||||
p_msg->eir_fec_required = eir_config->bta_dm_eir_fec_required;
|
||||
p_msg->eir_included_tx_power = eir_config->bta_dm_eir_included_tx_power;
|
||||
p_msg->eir_included_uuid = eir_config->bta_dm_eir_included_uuid;
|
||||
p_msg->eir_flags = eir_config->bta_dm_eir_flags;
|
||||
p_msg->eir_manufac_spec_len = eir_manufac_spec_len;
|
||||
p_msg->eir_manufac_spec = p_msg->data;
|
||||
p_msg->eir_url_len = eir_url_len;
|
||||
p_msg->eir_url = p_msg->data + eir_manufac_spec_len;
|
||||
|
||||
if (eir_manufac_spec_len > 0) {
|
||||
memcpy(p_msg->eir_manufac_spec, eir_config->bta_dm_eir_manufac_spec, eir_manufac_spec_len);
|
||||
}
|
||||
|
||||
if (eir_url_len > 0) {
|
||||
memcpy(p_msg->eir_url, eir_config->bta_dm_eir_url, eir_url_len);
|
||||
}
|
||||
|
||||
bta_sys_sendmsg(p_msg);
|
||||
}
|
||||
}
|
||||
|
||||
void BTA_DmUpdateWhiteList(BOOLEAN add_remove, BD_ADDR remote_addr, tBLE_ADDR_TYPE addr_type, tBTA_ADD_WHITELIST_CBACK *add_wl_cb)
|
||||
{
|
||||
tBTA_DM_API_UPDATE_WHITE_LIST *p_msg;
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "bta/bta_api.h"
|
||||
#include "bta_dm_int.h"
|
||||
#include "bta/bta_jv_api.h"
|
||||
#include "bta/bta_gap_bt_co.h"
|
||||
|
||||
#ifndef BTA_DM_LINK_POLICY_SETTINGS
|
||||
#define BTA_DM_LINK_POLICY_SETTINGS (HCI_ENABLE_MASTER_SLAVE_SWITCH | HCI_ENABLE_HOLD_MODE | HCI_ENABLE_SNIFF_MODE | HCI_ENABLE_PARK_MODE)
|
||||
|
@ -411,10 +412,12 @@ const UINT8 bta_dm_eir_uuid16_list[] = { 0x08, 0x11, /* Headset */
|
|||
#endif // BTA_EIR_CANNED_UUID_LIST
|
||||
|
||||
/* Extended Inquiry Response */
|
||||
const tBTA_DM_EIR_CONF bta_dm_eir_cfg = {
|
||||
tBTA_DM_EIR_CONF bta_dm_eir_cfg = {
|
||||
BTM_EIR_DEFAULT_FEC_REQUIRED, /* FEC required */
|
||||
50, /* minimum length of local name when it is shortened */
|
||||
/* if length of local name is longer than this and EIR has not enough */
|
||||
/* room for all UUID list then local name is shortened to this length */
|
||||
TRUE, /* Included UUIDs */
|
||||
#if (BTA_EIR_CANNED_UUID_LIST == TRUE)
|
||||
8,
|
||||
(UINT8 *)bta_dm_eir_uuid16_list,
|
||||
|
@ -425,12 +428,17 @@ const tBTA_DM_EIR_CONF bta_dm_eir_cfg = {
|
|||
/* BTM_EIR_UUID_LKUP_TBL can be overrided */
|
||||
},
|
||||
#endif // BTA_EIR_CANNED_UUID_LIST
|
||||
NULL, /* Inquiry TX power */
|
||||
0, /* length of flags in bytes */
|
||||
NULL, /* flags for EIR */
|
||||
FALSE, /* Not included TX power*/
|
||||
3, /* Inquiry TX power */
|
||||
0, /* flags for EIR */
|
||||
0, /* length of manufacturer specific in bytes */
|
||||
NULL, /* manufacturer specific */
|
||||
0, /* length of additional data in bytes */
|
||||
NULL /* additional data */
|
||||
0, /* length of URL in bytes */
|
||||
NULL, /* URL */
|
||||
#if (BTC_GAP_BT_INCLUDED == TRUE)
|
||||
(tBTA_DM_CONFIG_EIR_CBACK *)btc_gap_bt_config_eir_cmpl_callback /* callback */
|
||||
#else
|
||||
NULL
|
||||
#endif /* #if (BTC_GAP_BT_INCLUDED == TRUE) */
|
||||
};
|
||||
tBTA_DM_EIR_CONF *p_bta_dm_eir_cfg = (tBTA_DM_EIR_CONF *) &bta_dm_eir_cfg;
|
||||
|
|
|
@ -56,6 +56,7 @@ const tBTA_DM_ACTION bta_dm_action[BTA_DM_MAX_EVT] = {
|
|||
bta_dm_enable, /* BTA_DM_API_ENABLE_EVT */
|
||||
bta_dm_disable, /* BTA_DM_API_DISABLE_EVT */
|
||||
bta_dm_set_dev_name, /* BTA_DM_API_SET_NAME_EVT */
|
||||
bta_dm_config_eir, /* BTA_DM_API_CONFIG_EIR_EVT */
|
||||
bta_dm_set_visibility, /* BTA_DM_API_SET_VISIBILITY_EVT */
|
||||
bta_dm_acl_change, /* BTA_DM_ACL_CHANGE_EVT */
|
||||
bta_dm_add_device, /* BTA_DM_API_ADD_DEVICE_EVT */
|
||||
|
|
|
@ -52,6 +52,7 @@ enum {
|
|||
BTA_DM_API_ENABLE_EVT = BTA_SYS_EVT_START(BTA_ID_DM),
|
||||
BTA_DM_API_DISABLE_EVT,
|
||||
BTA_DM_API_SET_NAME_EVT,
|
||||
BTA_DM_API_CONFIG_EIR_EVT,
|
||||
BTA_DM_API_SET_VISIBILITY_EVT,
|
||||
|
||||
BTA_DM_ACL_CHANGE_EVT,
|
||||
|
@ -188,6 +189,20 @@ typedef struct {
|
|||
BD_NAME name; /* max 248 bytes name, plus must be Null terminated */
|
||||
} tBTA_DM_API_SET_NAME;
|
||||
|
||||
/* data type for BTA_DM_API_CONFIG_EIR_EVT */
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
BOOLEAN eir_fec_required;
|
||||
BOOLEAN eir_included_tx_power;
|
||||
BOOLEAN eir_included_uuid;
|
||||
UINT8 eir_flags;
|
||||
UINT8 eir_manufac_spec_len;
|
||||
UINT8 *eir_manufac_spec;
|
||||
UINT8 eir_url_len;
|
||||
UINT8 *eir_url;
|
||||
UINT8 data[];
|
||||
}tBTA_DM_API_CONFIG_EIR;
|
||||
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
BOOLEAN add_remove;
|
||||
|
@ -784,6 +799,7 @@ typedef union {
|
|||
tBTA_DM_API_ENABLE enable;
|
||||
|
||||
tBTA_DM_API_SET_NAME set_name;
|
||||
tBTA_DM_API_CONFIG_EIR config_eir;
|
||||
|
||||
tBTA_DM_API_UPDATE_WHITE_LIST white_list;
|
||||
tBTA_DM_API_READ_ADV_TX_POWER read_tx_power;
|
||||
|
@ -1185,7 +1201,7 @@ extern tBTA_DM_SSR_SPEC *p_bta_dm_ssr_spec;
|
|||
#endif /* #if (BTA_DM_PM_INCLUDED == TRUE) */
|
||||
|
||||
/* update dynamic BRCM Aware EIR data */
|
||||
extern const tBTA_DM_EIR_CONF bta_dm_eir_cfg;
|
||||
extern tBTA_DM_EIR_CONF bta_dm_eir_cfg;
|
||||
extern tBTA_DM_EIR_CONF *p_bta_dm_eir_cfg;
|
||||
|
||||
/* DM control block */
|
||||
|
@ -1222,6 +1238,7 @@ extern void bta_dm_search_sm_disable( void );
|
|||
extern void bta_dm_enable (tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_disable (tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_set_dev_name (tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_config_eir (tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_update_white_list(tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_ble_read_adv_tx_power(tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_ble_read_rssi(tBTA_DM_MSG *p_data);
|
||||
|
|
|
@ -46,6 +46,7 @@
|
|||
#define BTA_BUSY 3
|
||||
#define BTA_NO_RESOURCES 4
|
||||
#define BTA_WRONG_MODE 5
|
||||
#define BTA_EIR_TOO_LARGE 6
|
||||
|
||||
typedef UINT8 tBTA_STATUS;
|
||||
|
||||
|
@ -295,21 +296,31 @@ typedef struct {
|
|||
#endif
|
||||
} tBTA_DM_INQ;
|
||||
|
||||
/* Config EIR callback */
|
||||
typedef void (tBTA_DM_CONFIG_EIR_CBACK) (tBTA_STATUS status, UINT8 eir_type_num, UINT8 *eir_type);
|
||||
|
||||
typedef struct {
|
||||
BOOLEAN bta_dm_eir_fec_required; /* FEC required */
|
||||
UINT8 bta_dm_eir_min_name_len; /* minimum length of local name when it is shortened */
|
||||
|
||||
BOOLEAN bta_dm_eir_included_uuid; /* Included UUIDs or not */
|
||||
#if (BTA_EIR_CANNED_UUID_LIST == TRUE)
|
||||
UINT8 bta_dm_eir_uuid16_len; /* length of 16-bit UUIDs */
|
||||
UINT8 *bta_dm_eir_uuid16; /* 16-bit UUIDs */
|
||||
#else
|
||||
UINT32 uuid_mask[BTM_EIR_SERVICE_ARRAY_SIZE]; /* mask of UUID list in EIR */
|
||||
#endif
|
||||
INT8 *bta_dm_eir_inq_tx_power; /* Inquiry TX power */
|
||||
UINT8 bta_dm_eir_flag_len; /* length of flags in bytes */
|
||||
UINT8 *bta_dm_eir_flags; /* flags for EIR */
|
||||
|
||||
BOOLEAN bta_dm_eir_included_tx_power; /* Included inquiry TX power or not */
|
||||
INT8 bta_dm_eir_inq_tx_power; /* Inquiry TX power */
|
||||
|
||||
UINT8 bta_dm_eir_flags; /* flags for EIR */
|
||||
UINT8 bta_dm_eir_manufac_spec_len; /* length of manufacturer specific in bytes */
|
||||
UINT8 *bta_dm_eir_manufac_spec; /* manufacturer specific */
|
||||
UINT8 bta_dm_eir_additional_len; /* length of additional data in bytes */
|
||||
UINT8 *bta_dm_eir_additional; /* additional data */
|
||||
UINT8 bta_dm_eir_url_len; /* length of URL in bytes */
|
||||
UINT8 *bta_dm_eir_url; /* URL data */
|
||||
|
||||
tBTA_DM_CONFIG_EIR_CBACK *config_eir_callback; /* callback */
|
||||
} tBTA_DM_EIR_CONF;
|
||||
|
||||
#if BLE_INCLUDED == TRUE
|
||||
|
@ -1450,6 +1461,18 @@ extern void BTA_DisableTestMode(void);
|
|||
*******************************************************************************/
|
||||
extern void BTA_DmSetDeviceName(const char *p_name);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_DmConfigEir
|
||||
**
|
||||
** Description This function config EIR data of the local device.
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void BTA_DmConfigEir(tBTA_DM_EIR_CONF *eir_config);
|
||||
|
||||
extern void BTA_DmUpdateWhiteList(BOOLEAN add_remove, BD_ADDR remote_addr, tBLE_ADDR_TYPE addr_type, tBTA_ADD_WHITELIST_CBACK *add_wl_cb);
|
||||
|
||||
extern void BTA_DmBleReadAdvTxPower(tBTA_CMPL_CB *cmpl_cb);
|
||||
|
|
29
components/bt/bluedroid/bta/include/bta/bta_gap_bt_co.h
Normal file
29
components/bt/bluedroid/bta/include/bta/bta_gap_bt_co.h
Normal file
|
@ -0,0 +1,29 @@
|
|||
// Copyright 2018 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* This is the interface file for BT GAP call-out functions.
|
||||
*
|
||||
******************************************************************************/
|
||||
#ifndef BTA_GAP_BT_CO_H
|
||||
#define BTA_GAP_BT_CO_H
|
||||
|
||||
#if (BTC_GAP_BT_INCLUDED == TRUE)
|
||||
|
||||
extern void btc_gap_bt_config_eir_cmpl_callback (uint8_t status, uint8_t eir_type_num, uint8_t *eir_type);
|
||||
|
||||
#endif /// (BTC_GAP_BT_INCLUDED == TRUE)
|
||||
#endif /// BTA_GAP_BT_CO_H
|
|
@ -32,6 +32,7 @@
|
|||
#endif ///BTA_AV_INCLUDED == TRUE
|
||||
#include "common/bt_defs.h"
|
||||
#include "stack/btm_api.h"
|
||||
#include "bta/bta_api.h"
|
||||
|
||||
/************************************************************************************
|
||||
** Constants & Macros
|
||||
|
@ -246,3 +247,36 @@ esp_bt_status_t btc_btm_status_to_esp_status (uint8_t btm_status)
|
|||
|
||||
return esp_status;
|
||||
}
|
||||
|
||||
esp_bt_status_t btc_bta_status_to_esp_status (uint8_t bta_status)
|
||||
{
|
||||
esp_bt_status_t esp_status = ESP_BT_STATUS_FAIL;
|
||||
switch(bta_status){
|
||||
case BTA_SUCCESS:
|
||||
esp_status = ESP_BT_STATUS_SUCCESS;
|
||||
break;
|
||||
case BTA_FAILURE:
|
||||
esp_status = ESP_BT_STATUS_FAIL;
|
||||
break;
|
||||
case BTA_PENDING:
|
||||
esp_status = ESP_BT_STATUS_PENDING;
|
||||
break;
|
||||
case BTA_BUSY:
|
||||
esp_status = ESP_BT_STATUS_BUSY;
|
||||
break;
|
||||
case BTA_NO_RESOURCES:
|
||||
esp_status = ESP_BT_STATUS_NOMEM;
|
||||
break;
|
||||
case BTA_WRONG_MODE:
|
||||
esp_status = ESP_BT_STATUS_NOT_READY;
|
||||
break;
|
||||
case BTA_EIR_TOO_LARGE:
|
||||
esp_status = ESP_BT_STATUS_EIR_TOO_LARGE;
|
||||
break;
|
||||
default:
|
||||
esp_status = ESP_BT_STATUS_FAIL;
|
||||
break;
|
||||
}
|
||||
|
||||
return esp_status;
|
||||
}
|
|
@ -46,5 +46,6 @@ void uuid_to_string_legacy(bt_uuid_t *p_uuid, char *str);
|
|||
|
||||
esp_bt_status_t btc_hci_to_esp_status(uint8_t hci_status);
|
||||
esp_bt_status_t btc_btm_status_to_esp_status (uint8_t btm_status);
|
||||
esp_bt_status_t btc_bta_status_to_esp_status (uint8_t bta_status);
|
||||
|
||||
#endif /* __BTC_UTIL_H__ */
|
||||
|
|
40
components/bt/bluedroid/btc/profile/std/gap/bta_gap_bt_co.c
Normal file
40
components/bt/bluedroid/btc/profile/std/gap/bta_gap_bt_co.c
Normal file
|
@ -0,0 +1,40 @@
|
|||
// Copyright 2018 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include <string.h>
|
||||
#include "btc_gap_bt.h"
|
||||
#include "btc/btc_util.h"
|
||||
|
||||
#if (BTC_GAP_BT_INCLUDED == TRUE)
|
||||
void btc_gap_bt_config_eir_cmpl_callback (uint8_t status, uint8_t eir_type_num, uint8_t *eir_type)
|
||||
{
|
||||
esp_bt_gap_cb_param_t param;
|
||||
bt_status_t ret;
|
||||
btc_msg_t msg;
|
||||
msg.sig = BTC_SIG_API_CB;
|
||||
msg.pid = BTC_PID_GAP_BT;
|
||||
msg.act = BTC_GAP_BT_CONFIG_EIR_DATA_EVT;
|
||||
|
||||
param.config_eir_data.stat = btc_bta_status_to_esp_status(status);
|
||||
param.config_eir_data.eir_type_num = eir_type_num;
|
||||
memcpy(param.config_eir_data.eir_type, eir_type, eir_type_num);
|
||||
|
||||
ret = btc_transfer_context(&msg, ¶m,
|
||||
sizeof(esp_bt_gap_cb_param_t), NULL);
|
||||
|
||||
if (ret != BT_STATUS_SUCCESS) {
|
||||
BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__);
|
||||
}
|
||||
}
|
||||
#endif /// (BTC_GAP_BT_INCLUDED == TRUE)
|
|
@ -687,11 +687,27 @@ static void btc_gap_bt_ssp_passkey_reply(btc_gap_bt_args_t *arg)
|
|||
static void btc_gap_bt_ssp_confirm(btc_gap_bt_args_t *arg)
|
||||
{
|
||||
BTA_DmConfirm(arg->confirm_reply.bda.address, arg->confirm_reply.accept);
|
||||
|
||||
}
|
||||
|
||||
#endif ///BT_SSP_INCLUDED == TRUE
|
||||
|
||||
static void btc_gap_bt_config_eir(btc_gap_bt_args_t *arg)
|
||||
{
|
||||
tBTA_DM_EIR_CONF eir_config;
|
||||
esp_bt_eir_data_t *eir_data = &arg->config_eir.eir_data;
|
||||
|
||||
eir_config.bta_dm_eir_fec_required = eir_data->fec_required;
|
||||
eir_config.bta_dm_eir_included_tx_power = eir_data->include_txpower;
|
||||
eir_config.bta_dm_eir_included_uuid = eir_data->include_uuid;
|
||||
eir_config.bta_dm_eir_flags = eir_data->flag;
|
||||
eir_config.bta_dm_eir_manufac_spec_len = eir_data->manufacturer_len;
|
||||
eir_config.bta_dm_eir_manufac_spec = eir_data->p_manufacturer_data;
|
||||
eir_config.bta_dm_eir_url_len = eir_data->url_len;
|
||||
eir_config.bta_dm_eir_url = eir_data->p_url;
|
||||
|
||||
BTA_DmConfigEir(&eir_config);
|
||||
}
|
||||
|
||||
void btc_gap_bt_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||
{
|
||||
switch (msg->act) {
|
||||
|
@ -713,12 +729,10 @@ void btc_gap_bt_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
|
|||
case BTC_GAP_BT_ACT_SET_SECURITY_PARAM:{
|
||||
btc_gap_bt_args_t *src = (btc_gap_bt_args_t *)p_src;
|
||||
btc_gap_bt_args_t *dst = (btc_gap_bt_args_t *)p_dest;
|
||||
uint8_t length = 0;
|
||||
if (src->set_security_param.value) {
|
||||
length = dst->set_security_param.len;
|
||||
dst->set_security_param.value = osi_malloc(length);
|
||||
dst->set_security_param.value = osi_malloc(src->set_security_param.len);
|
||||
if (dst->set_security_param.value != NULL) {
|
||||
memcpy(dst->set_security_param.value, src->set_security_param.value, length);
|
||||
memcpy(dst->set_security_param.value, src->set_security_param.value, src->set_security_param.len);
|
||||
} else {
|
||||
BTC_TRACE_ERROR("%s %d no mem\n",__func__, msg->act);
|
||||
}
|
||||
|
@ -726,6 +740,30 @@ void btc_gap_bt_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
|
|||
break;
|
||||
}
|
||||
#endif ///BT_SSP_INCLUDED == TRUE
|
||||
|
||||
case BTC_GAP_BT_ACT_CONFIG_EIR:{
|
||||
btc_gap_bt_args_t *src = (btc_gap_bt_args_t *)p_src;
|
||||
btc_gap_bt_args_t *dst = (btc_gap_bt_args_t *)p_dest;
|
||||
if (src->config_eir.eir_data.p_manufacturer_data) {
|
||||
dst->config_eir.eir_data.p_manufacturer_data = osi_malloc(src->config_eir.eir_data.manufacturer_len);
|
||||
if (dst->config_eir.eir_data.p_manufacturer_data != NULL) {
|
||||
memcpy(dst->config_eir.eir_data.p_manufacturer_data, src->config_eir.eir_data.p_manufacturer_data, src->config_eir.eir_data.manufacturer_len);
|
||||
} else {
|
||||
dst->config_eir.eir_data.manufacturer_len = 0;
|
||||
BTC_TRACE_ERROR("%s %d no mem\n",__func__, msg->act);
|
||||
}
|
||||
}
|
||||
if (src->config_eir.eir_data.p_url) {
|
||||
dst->config_eir.eir_data.p_url = osi_malloc(src->config_eir.eir_data.url_len);
|
||||
if (dst->config_eir.eir_data.p_url != NULL) {
|
||||
memcpy(dst->config_eir.eir_data.p_url, src->config_eir.eir_data.p_url, src->config_eir.eir_data.url_len);
|
||||
} else {
|
||||
dst->config_eir.eir_data.url_len = 0;
|
||||
BTC_TRACE_ERROR("%s %d no mem\n",__func__, msg->act);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
BTC_TRACE_ERROR("Unhandled deep copy %d\n", msg->act);
|
||||
break;
|
||||
|
@ -752,9 +790,20 @@ void btc_gap_bt_arg_deep_free(btc_msg_t *msg)
|
|||
case BTC_GAP_BT_ACT_CONFIRM_REPLY:
|
||||
break;
|
||||
case BTC_GAP_BT_ACT_SET_SECURITY_PARAM:
|
||||
if (arg->set_security_param.value) {
|
||||
osi_free(arg->set_security_param.value);
|
||||
}
|
||||
break;
|
||||
#endif ///BT_SSP_INCLUDED == TRUE
|
||||
|
||||
case BTC_GAP_BT_ACT_CONFIG_EIR:
|
||||
if (arg->config_eir.eir_data.p_manufacturer_data) {
|
||||
osi_free(arg->config_eir.eir_data.p_manufacturer_data);
|
||||
}
|
||||
if (arg->config_eir.eir_data.p_url) {
|
||||
osi_free(arg->config_eir.eir_data.p_url);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
BTC_TRACE_ERROR("Unhandled deep copy %d, arg: %p\n", msg->act, arg);
|
||||
break;
|
||||
|
@ -820,7 +869,10 @@ void btc_gap_bt_call_handler(btc_msg_t *msg)
|
|||
break;
|
||||
}
|
||||
#endif ///BT_SSP_INCLUDED == TRUE
|
||||
|
||||
case BTC_GAP_BT_ACT_CONFIG_EIR: {
|
||||
btc_gap_bt_config_eir(arg);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -853,6 +905,7 @@ void btc_gap_bt_cb_deep_free(btc_msg_t *msg)
|
|||
osi_free(((tBTA_DM_SEARCH_PARAM *) (msg->arg)) ->p_data);
|
||||
break;
|
||||
case BTC_GAP_BT_READ_RSSI_DELTA_EVT:
|
||||
case BTC_GAP_BT_CONFIG_EIR_DATA_EVT:
|
||||
case BTC_GAP_BT_AUTH_CMPL_EVT:
|
||||
case BTC_GAP_BT_PIN_REQ_EVT:
|
||||
#if (BT_SSP_INCLUDED == TRUE)
|
||||
|
@ -886,6 +939,10 @@ void btc_gap_bt_cb_handler(btc_msg_t *msg)
|
|||
btc_gap_bt_cb_to_app(ESP_BT_GAP_READ_RSSI_DELTA_EVT, (esp_bt_gap_cb_param_t *)msg->arg);
|
||||
break;
|
||||
}
|
||||
case BTC_GAP_BT_CONFIG_EIR_DATA_EVT: {
|
||||
btc_gap_bt_cb_to_app(ESP_BT_GAP_CONFIG_EIR_DATA_EVT, (esp_bt_gap_cb_param_t *)msg->arg);
|
||||
break;
|
||||
}
|
||||
case BTC_GAP_BT_AUTH_CMPL_EVT:{
|
||||
btc_gap_bt_cb_to_app(ESP_BT_GAP_AUTH_CMPL_EVT, (esp_bt_gap_cb_param_t *)msg->arg);
|
||||
break;
|
||||
|
|
|
@ -32,6 +32,7 @@ typedef enum {
|
|||
BTC_GAP_BT_KEY_NOTIF_EVT,
|
||||
BTC_GAP_BT_KEY_REQ_EVT,
|
||||
BTC_GAP_BT_READ_RSSI_DELTA_EVT,
|
||||
BTC_GAP_BT_CONFIG_EIR_DATA_EVT,
|
||||
}btc_gap_bt_evt_t;
|
||||
|
||||
typedef enum {
|
||||
|
@ -48,6 +49,7 @@ typedef enum {
|
|||
BTC_GAP_BT_ACT_SET_SECURITY_PARAM,
|
||||
BTC_GAP_BT_ACT_PASSKEY_REPLY,
|
||||
BTC_GAP_BT_ACT_CONFIRM_REPLY,
|
||||
BTC_GAP_BT_ACT_CONFIG_EIR,
|
||||
} btc_gap_bt_act_t;
|
||||
|
||||
/* btc_bt_gap_args_t */
|
||||
|
@ -124,6 +126,11 @@ typedef union {
|
|||
bt_bdaddr_t bda;
|
||||
bool accept;
|
||||
} confirm_reply;
|
||||
|
||||
// BTC_GAP_BT_ACT_CONFIG_EIR
|
||||
struct config_eir_args {
|
||||
esp_bt_eir_data_t eir_data;
|
||||
} config_eir;
|
||||
} btc_gap_bt_args_t;
|
||||
|
||||
void btc_gap_bt_call_handler(btc_msg_t *msg);
|
||||
|
|
|
@ -88,6 +88,7 @@ typedef enum {
|
|||
BT_STATUS_PARAM_OUT_OF_RANGE,
|
||||
BT_STATUS_TIMEOUT,
|
||||
BT_STATUS_MEMORY_FULL,
|
||||
BT_STATUS_EIR_TOO_LARGE,
|
||||
} bt_status_t;
|
||||
|
||||
#ifndef CPU_LITTLE_ENDIAN
|
||||
|
|
|
@ -1073,6 +1073,14 @@
|
|||
#define BTM_BLE_ADV_TX_POWER {-12, -9, -6, -3, 0, 3, 6, 9}
|
||||
#endif
|
||||
|
||||
#ifndef BTM_TX_POWER
|
||||
#define BTM_TX_POWER {-12, -9, -6, -3, 0, 3, 6, 9}
|
||||
#endif
|
||||
|
||||
#ifndef BTM_TX_POWER_LEVEL_MAX
|
||||
#define BTM_TX_POWER_LEVEL_MAX 7
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef BLE_BATCH_SCAN_INCLUDED
|
||||
#define BLE_BATCH_SCAN_INCLUDED TRUE
|
||||
|
|
|
@ -2387,16 +2387,17 @@ void btm_read_linq_tx_power_complete(UINT8 *p)
|
|||
**
|
||||
** Parameters p_buff - allocated HCI command buffer including extended
|
||||
** inquriry response
|
||||
** fec_required - FEC is required or not
|
||||
**
|
||||
** Returns BTM_SUCCESS - if successful
|
||||
** BTM_MODE_UNSUPPORTED - if local device cannot support it
|
||||
**
|
||||
*******************************************************************************/
|
||||
tBTM_STATUS BTM_WriteEIR( BT_HDR *p_buff )
|
||||
tBTM_STATUS BTM_WriteEIR( BT_HDR *p_buff, BOOLEAN fec_required)
|
||||
{
|
||||
if (controller_get_interface()->supports_extended_inquiry_response()) {
|
||||
BTM_TRACE_API("Write Extended Inquiry Response to controller\n");
|
||||
btsnd_hcic_write_ext_inquiry_response (p_buff, BTM_EIR_DEFAULT_FEC_REQUIRED);
|
||||
btsnd_hcic_write_ext_inquiry_response (p_buff, fec_required);
|
||||
return BTM_SUCCESS;
|
||||
} else {
|
||||
osi_free(p_buff);
|
||||
|
|
|
@ -446,6 +446,7 @@ typedef struct {
|
|||
#define BT_EIR_OOB_COD_TYPE 0x0D
|
||||
#define BT_EIR_OOB_SSP_HASH_C_TYPE 0x0E
|
||||
#define BT_EIR_OOB_SSP_RAND_R_TYPE 0x0F
|
||||
#define BT_EIR_URL_TYPE 0x24
|
||||
#define BT_EIR_MANUFACTURER_SPECIFIC_TYPE 0xFF
|
||||
|
||||
#define BT_OOB_COD_SIZE 3
|
||||
|
|
|
@ -540,8 +540,11 @@ typedef UINT8 tBTM_EIR_SEARCH_RESULT;
|
|||
#define BTM_EIR_SHORTENED_LOCAL_NAME_TYPE HCI_EIR_SHORTENED_LOCAL_NAME_TYPE /* 0x08 */
|
||||
#define BTM_EIR_COMPLETE_LOCAL_NAME_TYPE HCI_EIR_COMPLETE_LOCAL_NAME_TYPE /* 0x09 */
|
||||
#define BTM_EIR_TX_POWER_LEVEL_TYPE HCI_EIR_TX_POWER_LEVEL_TYPE /* 0x0A */
|
||||
#define BTM_EIR_URL_TYPE HCI_EIR_URL_TYPE /* 0x24 */
|
||||
#define BTM_EIR_MANUFACTURER_SPECIFIC_TYPE HCI_EIR_MANUFACTURER_SPECIFIC_TYPE /* 0xFF */
|
||||
|
||||
#define BTM_EIR_TYPE_MAX_NUM 12 /* Max EIR types */
|
||||
|
||||
/* the following EIR tags are defined to OOB, not regular EIR data */
|
||||
#define BTM_EIR_OOB_BD_ADDR_TYPE HCI_EIR_OOB_BD_ADDR_TYPE /* 6 bytes */
|
||||
#define BTM_EIR_OOB_COD_TYPE HCI_EIR_OOB_COD_TYPE /* 3 bytes */
|
||||
|
@ -3867,13 +3870,14 @@ tBTM_STATUS BTM_DeleteStoredLinkKey(BD_ADDR bd_addr, tBTM_CMPL_CB *p_cb);
|
|||
**
|
||||
** Parameters p_buff - allocated HCI command buffer including extended
|
||||
** inquriry response
|
||||
** fec_required - FEC is required or not
|
||||
**
|
||||
** Returns BTM_SUCCESS - if successful
|
||||
** BTM_MODE_UNSUPPORTED - if local device cannot support it
|
||||
**
|
||||
*******************************************************************************/
|
||||
//extern
|
||||
tBTM_STATUS BTM_WriteEIR( BT_HDR *p_buff );
|
||||
tBTM_STATUS BTM_WriteEIR( BT_HDR *p_buff, BOOLEAN fec_required);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
|
|
|
@ -1139,6 +1139,7 @@
|
|||
#define HCI_EIR_SHORTENED_LOCAL_NAME_TYPE BT_EIR_SHORTENED_LOCAL_NAME_TYPE
|
||||
#define HCI_EIR_COMPLETE_LOCAL_NAME_TYPE BT_EIR_COMPLETE_LOCAL_NAME_TYPE
|
||||
#define HCI_EIR_TX_POWER_LEVEL_TYPE BT_EIR_TX_POWER_LEVEL_TYPE
|
||||
#define HCI_EIR_URL_TYPE BT_EIR_URL_TYPE
|
||||
#define HCI_EIR_MANUFACTURER_SPECIFIC_TYPE BT_EIR_MANUFACTURER_SPECIFIC_TYPE
|
||||
#define HCI_EIR_OOB_BD_ADDR_TYPE BT_EIR_OOB_BD_ADDR_TYPE
|
||||
#define HCI_EIR_OOB_COD_TYPE BT_EIR_OOB_COD_TYPE
|
||||
|
|
Loading…
Reference in a new issue