mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'feature/config_device_name_in_eir' into 'master'
Add option whether to include or exclude device name in extended inquiry response data Closes BTQABR2023-31 See merge request espressif/esp-idf!25341
This commit is contained in:
commit
3632aa5bd5
@ -106,6 +106,7 @@ 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 */
|
||||
bool include_name; /*!< EIR data include device name, true 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 */
|
||||
|
@ -788,6 +788,7 @@ 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_name = config_eir->eir_included_name;
|
||||
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;
|
||||
@ -4039,15 +4040,20 @@ static void bta_dm_set_eir (char *local_name)
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/* if local name is not provided, get it from controller */
|
||||
if ( local_name == NULL ) {
|
||||
if ( BTM_ReadLocalDeviceName( &local_name ) != BTM_SUCCESS ) {
|
||||
APPL_TRACE_ERROR("Fail to read local device name for EIR");
|
||||
}
|
||||
}
|
||||
#endif // BTA_EIR_CANNED_UUID_LIST
|
||||
|
||||
if (p_bta_dm_eir_cfg->bta_dm_eir_included_name) {
|
||||
/* if local name is not provided, get it from controller */
|
||||
if ( local_name == NULL ) {
|
||||
if ( BTM_ReadLocalDeviceName( &local_name ) != BTM_SUCCESS ) {
|
||||
APPL_TRACE_ERROR("Fail to read local device name for EIR");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
local_name = NULL;
|
||||
}
|
||||
|
||||
|
||||
/* 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");
|
||||
@ -4092,15 +4098,16 @@ 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) {
|
||||
UINT8_TO_STREAM(p, local_name_len + 1);
|
||||
UINT8_TO_STREAM(p, data_type);
|
||||
eir_type[eir_type_num++] = data_type;
|
||||
memcpy(p, local_name, local_name_len);
|
||||
p += local_name_len;
|
||||
free_eir_length -= local_name_len + 2;
|
||||
}
|
||||
free_eir_length -= local_name_len + 2;
|
||||
|
||||
/* if UUIDs are provided in configuration */
|
||||
if (p_bta_dm_eir_cfg->bta_dm_eir_included_uuid) {
|
||||
|
@ -226,6 +226,7 @@ void BTA_DmConfigEir(tBTA_DM_EIR_CONF *eir_config)
|
||||
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_name = eir_config->bta_dm_eir_included_name;
|
||||
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;
|
||||
|
@ -454,6 +454,7 @@ const UINT8 bta_dm_eir_uuid16_list[] = { 0x08, 0x11, /* Headset */
|
||||
/* Extended Inquiry Response */
|
||||
tBTA_DM_EIR_CONF bta_dm_eir_cfg = {
|
||||
BTM_EIR_DEFAULT_FEC_REQUIRED, /* FEC required */
|
||||
TRUE, /* Included local name */
|
||||
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 */
|
||||
|
@ -246,6 +246,7 @@ typedef struct {
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
BOOLEAN eir_fec_required;
|
||||
BOOLEAN eir_included_name;
|
||||
BOOLEAN eir_included_tx_power;
|
||||
BOOLEAN eir_included_uuid;
|
||||
UINT8 eir_flags;
|
||||
|
@ -303,6 +303,7 @@ typedef void (tBTA_DM_CONFIG_EIR_CBACK) (tBTA_STATUS status, UINT8 eir_type_num,
|
||||
|
||||
typedef struct {
|
||||
BOOLEAN bta_dm_eir_fec_required; /* FEC required */
|
||||
BOOLEAN bta_dm_eir_included_name; /* Included device name or not */
|
||||
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 */
|
||||
|
@ -689,6 +689,7 @@ static void btc_gap_bt_config_eir(btc_gap_bt_args_t *arg)
|
||||
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_name = eir_data->include_name;
|
||||
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;
|
||||
|
Loading…
Reference in New Issue
Block a user