"bluedroid/btc/profile/std/avrc/bta_avrc_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"
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;
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;
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 {
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;
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
*/
/**
* @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
/**
* @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
/**
* @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
* @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
*/
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
*
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 */
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
/* 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)
/* 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;
*******************************************************************************/
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)
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;
}
/* 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;
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);
}
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 )
- && (p_bta_dm_eir_cfg->bta_dm_eir_uuid16)) {
- if ( free_eir_length > LEN_UUID_16 + 2) {
- free_eir_length -= 2;
-
- if ( free_eir_length >= p_bta_dm_eir_cfg->bta_dm_eir_uuid16_len) {
- num_uuid = p_bta_dm_eir_cfg->bta_dm_eir_uuid16_len / LEN_UUID_16;
- data_type = BTM_EIR_COMPLETE_16BITS_UUID_TYPE;
- } else { /* not enough room for all UUIDs */
- APPL_TRACE_WARNING("BTA EIR: UUID 16-bit list is truncated");
- num_uuid = free_eir_length / LEN_UUID_16;
- data_type = BTM_EIR_MORE_16BITS_UUID_TYPE;
+ /* if UUID list is provided as static data in configuration */
+ if (( p_bta_dm_eir_cfg->bta_dm_eir_uuid16_len > 0 )
+ && (p_bta_dm_eir_cfg->bta_dm_eir_uuid16)) {
+ if ( free_eir_length > LEN_UUID_16 + 2) {
+ free_eir_length -= 2;
+
+ if ( free_eir_length >= p_bta_dm_eir_cfg->bta_dm_eir_uuid16_len) {
+ num_uuid = p_bta_dm_eir_cfg->bta_dm_eir_uuid16_len / LEN_UUID_16;
+ data_type = BTM_EIR_COMPLETE_16BITS_UUID_TYPE;
+ } else { /* not enough room for all UUIDs */
+ APPL_TRACE_WARNING("BTA EIR: UUID 16-bit list is truncated");
+ num_uuid = free_eir_length / LEN_UUID_16;
+ data_type = BTM_EIR_MORE_16BITS_UUID_TYPE;
+ }
+ 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;
}
- UINT8_TO_STREAM(p, num_uuid * LEN_UUID_16 + 1);
- UINT8_TO_STREAM(p, 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 /* (BTA_EIR_CANNED_UUID_LIST == TRUE) */
- /* if UUID list is dynamic */
- if ( free_eir_length >= 2) {
- p_length = p++;
- p_type = p++;
- num_uuid = 0;
+ /* if UUID list is dynamic */
+ if ( free_eir_length >= 2) {
+ p_length = p++;
+ p_type = p++;
+ num_uuid = 0;
- max_num_uuid = (free_eir_length - 2) / LEN_UUID_16;
- data_type = BTM_GetEirSupportedServices( bta_dm_cb.eir_uuid, &p, max_num_uuid, &num_uuid );
+ max_num_uuid = (free_eir_length - 2) / LEN_UUID_16;
+ data_type = BTM_GetEirSupportedServices( bta_dm_cb.eir_uuid, &p, max_num_uuid, &num_uuid );
- if ( data_type == BTM_EIR_MORE_16BITS_UUID_TYPE ) {
- APPL_TRACE_WARNING("BTA EIR: UUID 16-bit list is truncated");
- }
+ if ( data_type == BTM_EIR_MORE_16BITS_UUID_TYPE ) {
+ APPL_TRACE_WARNING("BTA EIR: UUID 16-bit list is truncated");
+ }
#if (BTA_EIR_SERVER_NUM_CUSTOM_UUID > 0)
- else {
- for (custom_uuid_idx = 0; custom_uuid_idx < BTA_EIR_SERVER_NUM_CUSTOM_UUID; custom_uuid_idx++) {
- if (bta_dm_cb.custom_uuid[custom_uuid_idx].len == LEN_UUID_16) {
- if ( num_uuid < max_num_uuid ) {
- UINT16_TO_STREAM(p, bta_dm_cb.custom_uuid[custom_uuid_idx].uu.uuid16);
- num_uuid++;
- } else {
- data_type = BTM_EIR_MORE_16BITS_UUID_TYPE;
- APPL_TRACE_WARNING("BTA EIR: UUID 16-bit list is truncated");
- break;
+ else {
+ for (custom_uuid_idx = 0; custom_uuid_idx < BTA_EIR_SERVER_NUM_CUSTOM_UUID; custom_uuid_idx++) {
+ if (bta_dm_cb.custom_uuid[custom_uuid_idx].len == LEN_UUID_16) {
+ if ( num_uuid < max_num_uuid ) {
+ UINT16_TO_STREAM(p, bta_dm_cb.custom_uuid[custom_uuid_idx].uu.uuid16);
+ num_uuid++;
+ } else {
+ data_type = BTM_EIR_MORE_16BITS_UUID_TYPE;
+ APPL_TRACE_WARNING("BTA EIR: UUID 16-bit list is truncated");
+ break;
+ }
}
}
}
- }
#endif /* (BTA_EIR_SERVER_NUM_CUSTOM_UUID > 0) */
- UINT8_TO_STREAM(p_length, num_uuid * LEN_UUID_16 + 1);
- UINT8_TO_STREAM(p_type, data_type);
- free_eir_length -= num_uuid * LEN_UUID_16 + 2;
- }
+ 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) */
#if ( BTA_EIR_CANNED_UUID_LIST != TRUE )&&(BTA_EIR_SERVER_NUM_CUSTOM_UUID > 0)
- /* Adding 32-bit UUID list */
- if ( free_eir_length >= 2) {
- p_length = p++;
- p_type = p++;
- num_uuid = 0;
- data_type = BTM_EIR_COMPLETE_32BITS_UUID_TYPE;
-
- max_num_uuid = (free_eir_length - 2) / LEN_UUID_32;
-
- for (custom_uuid_idx = 0; custom_uuid_idx < BTA_EIR_SERVER_NUM_CUSTOM_UUID; custom_uuid_idx++) {
- if (bta_dm_cb.custom_uuid[custom_uuid_idx].len == LEN_UUID_32) {
- if ( num_uuid < max_num_uuid ) {
- UINT32_TO_STREAM(p, bta_dm_cb.custom_uuid[custom_uuid_idx].uu.uuid32);
- num_uuid++;
- } else {
- data_type = BTM_EIR_MORE_32BITS_UUID_TYPE;
- APPL_TRACE_WARNING("BTA EIR: UUID 32-bit list is truncated");
- break;
+ /* Adding 32-bit UUID list */
+ if ( free_eir_length >= 2) {
+ p_length = p++;
+ p_type = p++;
+ num_uuid = 0;
+ data_type = BTM_EIR_COMPLETE_32BITS_UUID_TYPE;
+
+ max_num_uuid = (free_eir_length - 2) / LEN_UUID_32;
+
+ for (custom_uuid_idx = 0; custom_uuid_idx < BTA_EIR_SERVER_NUM_CUSTOM_UUID; custom_uuid_idx++) {
+ if (bta_dm_cb.custom_uuid[custom_uuid_idx].len == LEN_UUID_32) {
+ if ( num_uuid < max_num_uuid ) {
+ UINT32_TO_STREAM(p, bta_dm_cb.custom_uuid[custom_uuid_idx].uu.uuid32);
+ num_uuid++;
+ } else {
+ data_type = BTM_EIR_MORE_32BITS_UUID_TYPE;
+ APPL_TRACE_WARNING("BTA EIR: UUID 32-bit list is truncated");
+ break;
+ }
}
}
- }
- UINT8_TO_STREAM(p_length, num_uuid * LEN_UUID_32 + 1);
- UINT8_TO_STREAM(p_type, data_type);
- free_eir_length -= num_uuid * LEN_UUID_32 + 2;
- }
+ 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 */
- if ( free_eir_length >= 2) {
- p_length = p++;
- p_type = p++;
- num_uuid = 0;
- data_type = BTM_EIR_COMPLETE_128BITS_UUID_TYPE;
+ /* Adding 128-bit UUID list */
+ if ( free_eir_length >= 2) {
+ p_length = p++;
+ p_type = p++;
+ num_uuid = 0;
+ data_type = BTM_EIR_COMPLETE_128BITS_UUID_TYPE;
- max_num_uuid = (free_eir_length - 2) / LEN_UUID_128;
+ max_num_uuid = (free_eir_length - 2) / LEN_UUID_128;
- for (custom_uuid_idx = 0; custom_uuid_idx < BTA_EIR_SERVER_NUM_CUSTOM_UUID; custom_uuid_idx++) {
- if (bta_dm_cb.custom_uuid[custom_uuid_idx].len == LEN_UUID_128) {
- if ( num_uuid < max_num_uuid ) {
- ARRAY16_TO_STREAM(p, bta_dm_cb.custom_uuid[custom_uuid_idx].uu.uuid128);
- num_uuid++;
- } else {
- data_type = BTM_EIR_MORE_128BITS_UUID_TYPE;
- APPL_TRACE_WARNING("BTA EIR: UUID 128-bit list is truncated");
- break;
+ for (custom_uuid_idx = 0; custom_uuid_idx < BTA_EIR_SERVER_NUM_CUSTOM_UUID; custom_uuid_idx++) {
+ if (bta_dm_cb.custom_uuid[custom_uuid_idx].len == LEN_UUID_128) {
+ if ( num_uuid < max_num_uuid ) {
+ ARRAY16_TO_STREAM(p, bta_dm_cb.custom_uuid[custom_uuid_idx].uu.uuid128);
+ num_uuid++;
+ } else {
+ data_type = BTM_EIR_MORE_128BITS_UUID_TYPE;
+ APPL_TRACE_WARNING("BTA EIR: UUID 128-bit list is truncated");
+ break;
+ }
}
}
- }
- UINT8_TO_STREAM(p_length, num_uuid * LEN_UUID_128 + 1);
- UINT8_TO_STREAM(p_type, data_type);
- free_eir_length -= num_uuid * LEN_UUID_128 + 2;
- }
+ 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);
- 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;
+ 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);
+ 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_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);
- memcpy(p, p_bta_dm_eir_cfg->bta_dm_eir_manufac_spec,
+ && ( 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;
-
+ 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)) {
- 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));
- 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);
+ 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);
+ }
}
/*******************************************************************************
}
+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;
#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)
#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,
/* 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;
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 */
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,
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;
typedef struct {
BT_HDR hdr;
- BOOLEAN add;
+ BOOLEAN add;
UINT32 static_passkey;
} tBTA_DM_API_SET_DEFAULT_PASSKEY;
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;
#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 */
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);
#define BTA_BUSY 3
#define BTA_NO_RESOURCES 4
#define BTA_WRONG_MODE 5
+#define BTA_EIR_TOO_LARGE 6
typedef UINT8 tBTA_STATUS;
#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 */
+ 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
*******************************************************************************/
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);
** Returns None
**
*******************************************************************************/
-extern void BTA_DmUpdateDuplicateExceptionalList(UINT8 subcode, UINT32 type,
- BD_ADDR device_info,
+extern void BTA_DmUpdateDuplicateExceptionalList(UINT8 subcode, UINT32 type,
+ BD_ADDR device_info,
tBTA_UPDATE_DUPLICATE_EXCEPTIONAL_LIST_CMPL_CBACK p_update_duplicate_exceptional_list_cback);
/*******************************************************************************
--- /dev/null
+// 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
\ No newline at end of file
#endif ///BTA_AV_INCLUDED == TRUE
#include "common/bt_defs.h"
#include "stack/btm_api.h"
+#include "bta/bta_api.h"
/************************************************************************************
** Constants & Macros
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;
+}
\ No newline at end of file
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__ */
--- /dev/null
+// 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)
\ No newline at end of file
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) {
break;
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;
+ btc_gap_bt_args_t *dst = (btc_gap_bt_args_t *)p_dest;
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);
}
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;
case BTC_GAP_BT_ACT_CONFIRM_REPLY:
break;
case BTC_GAP_BT_ACT_SET_SECURITY_PARAM:
- osi_free(arg->set_security_param.value);
+ 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;
break;
}
#endif ///BT_SSP_INCLUDED == TRUE
-
+ case BTC_GAP_BT_ACT_CONFIG_EIR: {
+ btc_gap_bt_config_eir(arg);
+ break;
+ }
default:
break;
}
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)
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;
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 {
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 */
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);
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
#ifndef CONFIG_BTDM_BLE_ADV_REPORT_FLOW_CTRL_NUM
#define BLE_ADV_REPORT_FLOW_CONTROL_NUM 100
-#else
+#else
#define BLE_ADV_REPORT_FLOW_CONTROL_NUM CONFIG_BTDM_BLE_ADV_REPORT_FLOW_CTRL_NUM
#endif /* CONFIG_BTDM_BLE_ADV_REPORT_FLOW_CTRL_NUM */
#ifndef CONFIG_BTDM_BLE_ADV_REPORT_DISCARD_THRSHOLD
#define BLE_ADV_REPORT_DISCARD_THRSHOLD 20
-#else
+#else
#define BLE_ADV_REPORT_DISCARD_THRSHOLD CONFIG_BTDM_BLE_ADV_REPORT_DISCARD_THRSHOLD
#endif /* CONFIG_BTDM_BLE_ADV_REPORT_DISCARD_THRSHOLD */
#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
**
** 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);
#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
#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 */
**
** 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);
/*******************************************************************************
**
#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