Merge branch 'feat/reduce_bluedroid_host_bin_v5.4' into 'release/v5.4'

feat/reduce bluedroid host bin size (v5.4)

See merge request espressif/esp-idf!44867
This commit is contained in:
Island
2026-01-08 14:20:59 +08:00
56 changed files with 784 additions and 7731 deletions
@@ -524,6 +524,29 @@ esp_err_t esp_ble_gap_config_adv_data_raw(uint8_t *raw_data, uint32_t raw_data_l
btc_gap_ble_arg_deep_free) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_gap_config_scan_rsp_data_raw(uint8_t *raw_data, uint32_t raw_data_len)
{
btc_msg_t msg = {0};
btc_ble_gap_args_t arg;
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
if ((raw_data_len != 0 && raw_data == NULL) || raw_data_len > ESP_BLE_ADV_DATA_LEN_MAX) {
return ESP_ERR_INVALID_ARG;
}
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_GAP_BLE;
msg.act = BTC_GAP_BLE_ACT_CFG_SCAN_RSP_DATA_RAW;
arg.cfg_scan_rsp_data_raw.raw_scan_rsp = raw_data;
arg.cfg_scan_rsp_data_raw.raw_scan_rsp_len = raw_data_len;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), btc_gap_ble_arg_deep_copy,
btc_gap_ble_arg_deep_free) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
#endif // #if (BLE_42_ADV_EN == TRUE)
#endif // #if (BLE_42_FEATURE_SUPPORT == TRUE)
esp_err_t esp_ble_gap_read_rssi(esp_bd_addr_t remote_addr)
@@ -547,28 +570,7 @@ esp_err_t esp_ble_gap_read_rssi(esp_bd_addr_t remote_addr)
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), NULL, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
#if (BLE_42_FEATURE_SUPPORT == TRUE)
esp_err_t esp_ble_gap_config_scan_rsp_data_raw(uint8_t *raw_data, uint32_t raw_data_len)
{
btc_msg_t msg = {0};
btc_ble_gap_args_t arg;
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
if ((raw_data_len != 0 && raw_data == NULL) || raw_data_len > ESP_BLE_ADV_DATA_LEN_MAX) {
return ESP_ERR_INVALID_ARG;
}
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_GAP_BLE;
msg.act = BTC_GAP_BLE_ACT_CFG_SCAN_RSP_DATA_RAW;
arg.cfg_scan_rsp_data_raw.raw_scan_rsp = raw_data;
arg.cfg_scan_rsp_data_raw.raw_scan_rsp_len = raw_data_len;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), btc_gap_ble_arg_deep_copy,
btc_gap_ble_arg_deep_free) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
#if ((BLE_42_SCAN_EN == TRUE) || (BLE_50_EXTEND_SCAN_EN == TRUE))
esp_err_t esp_ble_gap_add_duplicate_scan_exceptional_device(esp_ble_duplicate_exceptional_info_type_t type, esp_duplicate_info_t device_info)
{
@@ -636,7 +638,8 @@ esp_err_t esp_ble_gap_clean_duplicate_scan_exceptional_list(esp_duplicate_scan_e
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), NULL, NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
#endif // #if (BLE_42_FEATURE_SUPPORT == TRUE)
#endif // ((BLE_42_SCAN_EN == TRUE) || (BLE_50_EXTEND_SCAN_EN == TRUE))
#if (SMP_INCLUDED == TRUE)
esp_err_t esp_ble_gap_set_security_param(esp_ble_sm_param_t param_type,
void *value, uint8_t len)
@@ -823,9 +823,10 @@ typedef enum {
ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_ALL_LIST = 0xFFFF, /*!< duplicate scan exceptional all list */
} esp_duplicate_scan_exceptional_list_type_t;
#endif //#if (BLE_42_FEATURE_SUPPORT == TRUE)
typedef uint8_t esp_duplicate_info_t[ESP_BD_ADDR_LEN];
#endif //#if (BLE_42_FEATURE_SUPPORT == TRUE)
#if (BLE_50_FEATURE_SUPPORT == TRUE)
#define ESP_BLE_GAP_SET_EXT_ADV_PROP_NONCONN_NONSCANNABLE_UNDIRECTED (0 << 0) /*!< Non-Connectable and Non-Scannable Undirected advertising */
@@ -1894,7 +1895,6 @@ typedef union {
esp_bt_status_t status; /*!< Indicate the add or remove whitelist operation success status */
esp_ble_wl_operation_t wl_operation; /*!< The value is ESP_BLE_WHITELIST_ADD if add address to whitelist operation success, ESP_BLE_WHITELIST_REMOVE if remove address from the whitelist operation success */
} update_whitelist_cmpl; /*!< Event parameter of ESP_GAP_BLE_UPDATE_WHITELIST_COMPLETE_EVT */
#if (BLE_42_FEATURE_SUPPORT == TRUE)
/**
* @brief ESP_GAP_BLE_UPDATE_DUPLICATE_EXCEPTIONAL_LIST_COMPLETE_EVT
*/
@@ -1904,7 +1904,6 @@ typedef union {
uint16_t length; /*!< The length of device_info */
esp_duplicate_info_t device_info; /*!< device information, when subcode is ESP_BLE_DUPLICATE_EXCEPTIONAL_LIST_CLEAN, the value is invalid */
} update_duplicate_exceptional_list_cmpl; /*!< Event parameter of ESP_GAP_BLE_UPDATE_DUPLICATE_EXCEPTIONAL_LIST_COMPLETE_EVT */
#endif // #if (BLE_42_FEATURE_SUPPORT == TRUE)
/**
* @brief ESP_GAP_BLE_SET_CHANNELS_EVT
*/
@@ -3068,6 +3067,7 @@ esp_err_t esp_ble_gap_clear_whitelist(void);
/**
* @brief Get the whitelist size in the controller
* Note: This API returns a constant value indicating the maximum number of whitelists supported by the controller
*
* @param[out] length: the white list length.
* @return
File diff suppressed because it is too large Load Diff
+12 -830
View File
@@ -73,8 +73,10 @@ tBTA_STATUS BTA_EnableBluetooth(tBTA_DM_SEC_CBACK *p_cback)
bta_sys_register (BTA_ID_DM, &bta_dm_reg );
bta_sys_register (BTA_ID_DM_SEARCH, &bta_dm_search_reg );
#if (CLASSIC_BT_INCLUDED == TRUE)
/* if UUID list is not provided as static data */
bta_sys_eir_register(bta_dm_eir_update_uuid);
#endif // (CLASSIC_BT_INCLUDED == TRUE)
if ((p_msg = (tBTA_DM_API_ENABLE *) osi_malloc(sizeof(tBTA_DM_API_ENABLE))) != NULL) {
p_msg->hdr.event = BTA_DM_API_ENABLE_EVT;
@@ -110,53 +112,6 @@ tBTA_STATUS BTA_DisableBluetooth(void)
return BTA_SUCCESS;
}
#if (BLE_HOST_ENABLE_TEST_MODE_EN == TRUE)
/*******************************************************************************
**
** Function BTA_EnableTestMode
**
** Description Enables bluetooth device under test mode
**
**
** Returns tBTA_STATUS
**
*******************************************************************************/
tBTA_STATUS BTA_EnableTestMode(void)
{
BT_HDR *p_msg;
APPL_TRACE_API("BTA_EnableTestMode");
if ((p_msg = (BT_HDR *) osi_malloc(sizeof(BT_HDR))) != NULL) {
p_msg->event = BTA_DM_API_ENABLE_TEST_MODE_EVT;
bta_sys_sendmsg(p_msg);
return BTA_SUCCESS;
}
return BTA_FAILURE;
}
/*******************************************************************************
**
** Function BTA_DisableTestMode
**
** Description Disable bluetooth device under test mode
**
**
** Returns None
**
*******************************************************************************/
void BTA_DisableTestMode(void)
{
BT_HDR *p_msg;
APPL_TRACE_API("BTA_DisableTestMode");
if ((p_msg = (BT_HDR *) osi_malloc(sizeof(BT_HDR))) != NULL) {
p_msg->event = BTA_DM_API_DISABLE_TEST_MODE_EVT;
bta_sys_sendmsg(p_msg);
}
}
#endif // #if (BLE_HOST_ENABLE_TEST_MODE_EN == TRUE)
/*******************************************************************************
**
@@ -540,18 +495,6 @@ void BTA_DmClearWhiteList(tBTA_UPDATE_WHITELIST_CBACK *update_wl_cb)
}
}
#if (BLE_HOST_READ_TX_POWER_EN == TRUE)
void BTA_DmBleReadAdvTxPower(tBTA_CMPL_CB *cmpl_cb)
{
tBTA_DM_API_READ_ADV_TX_POWER *p_msg;
if ((p_msg = (tBTA_DM_API_READ_ADV_TX_POWER *)osi_malloc(sizeof(tBTA_DM_API_READ_ADV_TX_POWER))) != NULL) {
p_msg->hdr.event = BTA_DM_API_BLE_READ_ADV_TX_POWER_EVT;
p_msg->read_tx_power_cb = cmpl_cb;
bta_sys_sendmsg(p_msg);
}
}
#endif // BLE_HOST_READ_TX_POWER_EN
void BTA_DmBleReadChannelMap(BD_ADDR remote_device, tBTA_CMPL_CB *p_callback)
{
if (!remote_device || !p_callback) {
@@ -1222,31 +1165,6 @@ tBTA_STATUS BTA_DmRemoveLocalDiRecord(UINT32 handle)
}
#endif ///SDP_INCLUDED == TRUE
#if (BLE_HOST_EXECUTE_CBACK_EN == TRUE)
/*******************************************************************************
**
** Function bta_dmexecutecallback
**
** Description This function will request BTA to execute a call back in the context of BTU task
** This API was named in lower case because it is only intended
** for the internal customers(like BTIF).
**
** Returns void
**
*******************************************************************************/
void bta_dmexecutecallback (tBTA_DM_EXEC_CBACK *p_callback, void *p_param)
{
tBTA_DM_API_EXECUTE_CBACK *p_msg;
if ((p_msg = (tBTA_DM_API_EXECUTE_CBACK *) osi_malloc(sizeof(tBTA_DM_API_EXECUTE_CBACK))) != NULL) {
p_msg->hdr.event = BTA_DM_API_EXECUTE_CBACK_EVT;
p_msg->p_param = p_param;
p_msg->p_exec_cback = p_callback;
bta_sys_sendmsg(p_msg);
}
}
#endif // #if (BLE_HOST_EXECUTE_CBACK_EN == TRUE)
/*******************************************************************************
**
** Function BTA_DmAddBleKey
@@ -1456,69 +1374,6 @@ void BTA_DmSetBlePrefConnParams(BD_ADDR bd_addr,
#endif
}
#if (BLE_HOST_CONN_SCAN_PARAM_EN == TRUE)
/*******************************************************************************
**
** Function BTA_DmSetBleConnScanParams
**
** Description This function is called to set scan parameters used in
** BLE connection request
**
** Parameters: scan_interval - scan interval
** scan_window - scan window
**
** Returns void
**
*******************************************************************************/
void BTA_DmSetBleConnScanParams(UINT32 scan_interval, UINT32 scan_window)
{
tBTA_DM_API_BLE_SCAN_PARAMS *p_msg;
if ((p_msg = (tBTA_DM_API_BLE_SCAN_PARAMS *)osi_malloc(sizeof(tBTA_DM_API_BLE_SCAN_PARAMS))) != NULL) {
memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_SCAN_PARAMS));
p_msg->hdr.event = BTA_DM_API_BLE_CONN_SCAN_PARAM_EVT;
p_msg->scan_int = scan_interval;
p_msg->scan_window = scan_window;
bta_sys_sendmsg(p_msg);
}
}
#endif // #if (BLE_HOST_CONN_SCAN_PARAM_EN == TRUE)
#if (BLE_HOST_BLE_SCAN_PARAM_UNUSED == TRUE)
/*******************************************************************************
**
** Function BTA_DmSetBleScanParams
**
** Description This function is called to set scan parameters
**
** Parameters: client_if - Client IF
** scan_interval - scan interval
** scan_window - scan window
** scan_mode - scan mode
** scan_param_setup_status_cback - Set scan param status callback
**
** Returns void
**
*******************************************************************************/
void BTA_DmSetBleScanParams(tGATT_IF client_if, UINT32 scan_interval,
UINT32 scan_window, tBLE_SCAN_MODE scan_mode,
tBLE_SCAN_PARAM_SETUP_CBACK scan_param_setup_cback)
{
tBTA_DM_API_BLE_SCAN_PARAMS *p_msg;
if ((p_msg = (tBTA_DM_API_BLE_SCAN_PARAMS *)osi_malloc(sizeof(tBTA_DM_API_BLE_SCAN_PARAMS))) != NULL) {
memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_SCAN_PARAMS));
p_msg->hdr.event = BTA_DM_API_BLE_SCAN_PARAM_EVT;
p_msg->client_if = client_if;
p_msg->scan_int = scan_interval;
p_msg->scan_window = scan_window;
p_msg->scan_mode = scan_mode;
p_msg->scan_param_setup_cback = scan_param_setup_cback;
bta_sys_sendmsg(p_msg);
}
}
#endif // #if (BLE_HOST_BLE_SCAN_PARAM_UNUSED == TRUE)
#if (BLE_42_SCAN_EN == TRUE)
/*******************************************************************************
**
@@ -1725,6 +1580,7 @@ void BTA_DmBleSetScanRspRaw (UINT8 *p_raw_scan_rsp, UINT32 raw_scan_rsp_len,
}
#endif // #if (BLE_42_ADV_EN == TRUE)
#if ((BLE_42_SCAN_EN == TRUE) || (BLE_50_EXTEND_SCAN_EN == TRUE))
/*******************************************************************************
**
** Function BTA_DmUpdateDuplicateExceptionalList
@@ -1752,165 +1608,7 @@ void BTA_DmUpdateDuplicateExceptionalList(UINT8 subcode, UINT32 type, BD_ADDR de
bta_sys_sendmsg(p_msg);
}
}
#if (BLE_HOST_SETUP_STORAGE_EN == TRUE)
/*******************************************************************************
**
** Function BTA_DmBleSetStorageParams
**
** Description This function is called to override the BTA scan response.
**
** Parameters batch_scan_full_max -Max storage space (in %) allocated to full scanning
** batch_scan_trunc_max -Max storage space (in %) allocated to truncated scanning
** batch_scan_notify_threshold -Setup notification level based on total space
** p_setup_cback - Setup callback pointer
** p_thres_cback - Threshold callback pointer
** p_rep_cback - Reports callback pointer
** ref_value - Ref value
**
** Returns None
**
*******************************************************************************/
extern void BTA_DmBleSetStorageParams(UINT8 batch_scan_full_max,
UINT8 batch_scan_trunc_max,
UINT8 batch_scan_notify_threshold,
tBTA_BLE_SCAN_SETUP_CBACK *p_setup_cback,
tBTA_BLE_SCAN_THRESHOLD_CBACK *p_thres_cback,
tBTA_BLE_SCAN_REP_CBACK *p_rep_cback,
tBTA_DM_BLE_REF_VALUE ref_value)
{
tBTA_DM_API_SET_STORAGE_CONFIG *p_msg;
bta_dm_cb.p_setup_cback = p_setup_cback;
if ((p_msg = (tBTA_DM_API_SET_STORAGE_CONFIG *)
osi_malloc(sizeof(tBTA_DM_API_SET_STORAGE_CONFIG))) != NULL) {
p_msg->hdr.event = BTA_DM_API_BLE_SETUP_STORAGE_EVT;
p_msg->p_setup_cback = bta_ble_scan_setup_cb;
p_msg->p_thres_cback = p_thres_cback;
p_msg->p_read_rep_cback = p_rep_cback;
p_msg->ref_value = ref_value;
p_msg->batch_scan_full_max = batch_scan_full_max;
p_msg->batch_scan_trunc_max = batch_scan_trunc_max;
p_msg->batch_scan_notify_threshold = batch_scan_notify_threshold;
bta_sys_sendmsg(p_msg);
}
}
#endif // #if (BLE_HOST_SETUP_STORAGE_EN == TRUE)
#if (BLE_HOST_BATCH_SCAN_EN == TRUE)
/*******************************************************************************
**
** Function BTA_DmBleEnableBatchScan
**
** Description This function is called to enable the batch scan
**
** Parameters scan_mode -Batch scan mode
** scan_interval - Scan interval
** scan_window - Scan window
** discard_rule -Discard rules
** addr_type - Address type
** ref_value - Reference value
**
** Returns None
**
*******************************************************************************/
extern void BTA_DmBleEnableBatchScan(tBTA_BLE_BATCH_SCAN_MODE scan_mode,
UINT32 scan_interval, UINT32 scan_window,
tBTA_BLE_DISCARD_RULE discard_rule,
tBLE_ADDR_TYPE addr_type,
tBTA_DM_BLE_REF_VALUE ref_value)
{
tBTA_DM_API_ENABLE_SCAN *p_msg;
if ((p_msg = (tBTA_DM_API_ENABLE_SCAN *) osi_malloc(sizeof(tBTA_DM_API_ENABLE_SCAN))) != NULL) {
p_msg->hdr.event = BTA_DM_API_BLE_ENABLE_BATCH_SCAN_EVT;
p_msg->scan_mode = scan_mode;
p_msg->scan_int = scan_interval;
p_msg->scan_window = scan_window;
p_msg->discard_rule = discard_rule;
p_msg->addr_type = addr_type;
p_msg->ref_value = ref_value;
bta_sys_sendmsg(p_msg);
}
}
/*******************************************************************************
**
** Function BTA_DmBleDisableBatchScan
**
** Description This function is called to disable the batch scan
**
** Parameters ref_value - Reference value
**
** Returns None
**
*******************************************************************************/
extern void BTA_DmBleDisableBatchScan(tBTA_DM_BLE_REF_VALUE ref_value)
{
tBTA_DM_API_DISABLE_SCAN *p_msg;
if ((p_msg = (tBTA_DM_API_DISABLE_SCAN *)
osi_malloc(sizeof(tBTA_DM_API_DISABLE_SCAN))) != NULL) {
p_msg->hdr.event = BTA_DM_API_BLE_DISABLE_BATCH_SCAN_EVT;
p_msg->ref_value = ref_value;
bta_sys_sendmsg(p_msg);
}
}
#endif // #if (BLE_HOST_BATCH_SCAN_EN == TRUE)
#if (BLE_HOST_READ_SCAN_REPORTS_EN == TRUE)
/*******************************************************************************
**
** Function BTA_DmBleReadScanReports
**
** Description This function is called to read scan reports
**
** Parameters scan_type -Batch scan mode
** ref_value - Reference value
**
** Returns None
**
*******************************************************************************/
extern void BTA_DmBleReadScanReports(tBTA_BLE_BATCH_SCAN_MODE scan_type,
tBTA_DM_BLE_REF_VALUE ref_value)
{
tBTA_DM_API_READ_SCAN_REPORTS *p_msg;
if ((p_msg = (tBTA_DM_API_READ_SCAN_REPORTS *)
osi_malloc(sizeof(tBTA_DM_API_READ_SCAN_REPORTS))) != NULL) {
p_msg->hdr.event = BTA_DM_API_BLE_READ_SCAN_REPORTS_EVT;
p_msg->scan_type = scan_type;
p_msg->ref_value = ref_value;
bta_sys_sendmsg(p_msg);
}
}
#endif // #if (BLE_HOST_READ_SCAN_REPORTS_EN == TRUE)
#if (BLE_HOST_TRACK_ADVERTISER_EN == TRUE)
/*******************************************************************************
**
** Function BTA_DmBleTrackAdvertiser
**
** Description This function is called to track advertiser
**
** Parameters ref_value - Reference value
** p_track_adv_cback - Track ADV callback
**
** Returns None
**
*******************************************************************************/
extern void BTA_DmBleTrackAdvertiser(tBTA_DM_BLE_REF_VALUE ref_value,
tBTA_BLE_TRACK_ADV_CBACK *p_track_adv_cback)
{
tBTA_DM_API_TRACK_ADVERTISER *p_msg;
if ((p_msg = (tBTA_DM_API_TRACK_ADVERTISER *)
osi_malloc(sizeof(tBTA_DM_API_TRACK_ADVERTISER))) != NULL) {
p_msg->hdr.event = BTA_DM_API_BLE_TRACK_ADVERTISER_EVT;
p_msg->p_track_adv_cback = p_track_adv_cback;
p_msg->ref_value = ref_value;
bta_sys_sendmsg(p_msg);
}
}
#endif // #if (BLE_HOST_TRACK_ADVERTISER_EN == TRUE)
#endif // ((BLE_42_SCAN_EN == TRUE) || (BLE_50_EXTEND_SCAN_EN == TRUE))
#endif
@@ -1921,25 +1619,25 @@ extern void BTA_DmBleTrackAdvertiser(tBTA_DM_BLE_REF_VALUE ref_value,
#if (BLE_42_ADV_EN == TRUE)
/*******************************************************************************
**
** Function BTA_DmBleBroadcast
** Function BTA_DmBleAdvStop
**
** Description This function starts or stops LE broadcasting.
**
** Parameters start: start or stop broadcast.
** Parameters start: always be false.
**
** Returns None
**
*******************************************************************************/
extern void BTA_DmBleBroadcast (BOOLEAN start, tBTA_START_STOP_ADV_CMPL_CBACK *p_start_stop_adv_cb)
extern void BTA_DmBleAdvStop (BOOLEAN start, tBTA_START_STOP_ADV_CMPL_CBACK *p_start_stop_adv_cb)
{
tBTA_DM_API_BLE_OBSERVE *p_msg;
APPL_TRACE_API("BTA_DmBleBroadcast: start = %d \n", start);
APPL_TRACE_API("BTA_DmBleAdvStop: start = %d \n", start);
if ((p_msg = (tBTA_DM_API_BLE_OBSERVE *) osi_malloc(sizeof(tBTA_DM_API_BLE_OBSERVE))) != NULL) {
memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_OBSERVE));
p_msg->hdr.event = BTA_DM_API_BLE_BROADCAST_EVT;
p_msg->hdr.event = BTA_DM_API_BLE_ADVSTOP_EVT;
p_msg->start = start;
if (start == FALSE){
p_msg->p_stop_adv_cback= p_start_stop_adv_cb;
@@ -1951,6 +1649,8 @@ extern void BTA_DmBleBroadcast (BOOLEAN start, tBTA_START_STOP_ADV_CMPL_CBACK *p
#endif // #if (BLE_42_ADV_EN == TRUE)
#endif
#if (BLE_GATT_BGCONN == TRUE)
/*******************************************************************************
**
** Function BTA_DmBleSetBgConnType
@@ -1981,6 +1681,7 @@ void BTA_DmBleSetBgConnType(tBTA_DM_BLE_CONN_TYPE bg_conn_type, tBTA_DM_BLE_SEL_
}
#endif
}
#endif// (BLE_GATT_BGCONN == TRUE)
/*******************************************************************************
**
@@ -2258,390 +1959,6 @@ void BTA_DmBleSetKeyMaterial(const uint8_t *session_key, const uint8_t *iv)
}
#endif
#if (BLE_HOST_BLE_MULTI_ADV_EN == TRUE)
/*******************************************************************************
**
** Function BTA_BleEnableAdvInstance
**
** Description This function enable a Multi-ADV instance with the specified
** adv parameters
**
** Parameters p_params: pointer to the adv parameter structure.
** p_cback: callback function associated to this adv instance.
** p_ref: reference data pointer to this adv instance.
**
** Returns BTA_SUCCESS if command started successfully; otherwise failure.
**
*******************************************************************************/
void BTA_BleEnableAdvInstance (tBTA_BLE_ADV_PARAMS *p_params,
tBTA_BLE_MULTI_ADV_CBACK *p_cback,
void *p_ref)
{
///This function just used for vendor debug
tBTA_DM_API_BLE_MULTI_ADV_ENB *p_msg;
UINT16 len = sizeof(tBTA_BLE_ADV_PARAMS) + sizeof(tBTA_DM_API_BLE_MULTI_ADV_ENB);
APPL_TRACE_API ("BTA_BleEnableAdvInstance");
if ((p_msg = (tBTA_DM_API_BLE_MULTI_ADV_ENB *) osi_malloc(len)) != NULL) {
memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_MULTI_ADV_ENB));
p_msg->hdr.event = BTA_DM_API_BLE_MULTI_ADV_ENB_EVT;
p_msg->p_cback = (void *)p_cback;
if (p_params != NULL) {
p_msg->p_params = (void *)(p_msg + 1);
memcpy(p_msg->p_params, p_params, sizeof(tBTA_BLE_ADV_PARAMS));
}
p_msg->p_ref = p_ref;
bta_sys_sendmsg(p_msg);
}
}
/*******************************************************************************
**
** Function BTA_BleUpdateAdvInstParam
**
** Description This function update a Multi-ADV instance with the specified
** adv parameters.
**
** Parameters inst_id: Adv instance to update the parameter.
** p_params: pointer to the adv parameter structure.
**
** Returns BTA_SUCCESS if command started successfully; otherwise failure.
**
*******************************************************************************/
void BTA_BleUpdateAdvInstParam (UINT8 inst_id, tBTA_BLE_ADV_PARAMS *p_params)
{
///This function just used for vendor debug
tBTA_DM_API_BLE_MULTI_ADV_PARAM *p_msg;
UINT16 len = sizeof(tBTA_BLE_ADV_PARAMS) + sizeof(tBTA_DM_API_BLE_MULTI_ADV_PARAM);
APPL_TRACE_API ("BTA_BleUpdateAdvInstParam");
if ((p_msg = (tBTA_DM_API_BLE_MULTI_ADV_PARAM *) osi_malloc(len)) != NULL) {
memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_MULTI_ADV_PARAM));
p_msg->hdr.event = BTA_DM_API_BLE_MULTI_ADV_PARAM_UPD_EVT;
p_msg->inst_id = inst_id;
p_msg->p_params = (void *)(p_msg + 1);
memcpy(p_msg->p_params, p_params, sizeof(tBTA_BLE_ADV_PARAMS));
bta_sys_sendmsg(p_msg);
}
}
/*******************************************************************************
**
** Function BTA_BleCfgAdvInstData
**
** Description This function configure a Multi-ADV instance with the specified
** adv data or scan response data.
**
** Parameter inst_id: Adv instance to configure the adv data or scan response.
** is_scan_rsp: is the data scan response or adv data.
** data_mask: adv data type as bit mask.
** p_data: pointer to the ADV data structure tBTA_BLE_ADV_DATA. This
** memory space can not be freed until BTA_BLE_MULTI_ADV_DATA_EVT
** is sent to application.
**
** Returns BTA_SUCCESS if command started successfully; otherwise failure.
**
*******************************************************************************/
void BTA_BleCfgAdvInstData (UINT8 inst_id, BOOLEAN is_scan_rsp,
tBTA_BLE_AD_MASK data_mask,
tBTA_BLE_ADV_DATA *p_data)
{
///This function just used for vendor debug
tBTA_DM_API_BLE_MULTI_ADV_DATA *p_msg;
UINT16 len = sizeof(tBTA_DM_API_BLE_MULTI_ADV_DATA) ;
APPL_TRACE_API ("BTA_BleCfgAdvInstData");
if ((p_msg = (tBTA_DM_API_BLE_MULTI_ADV_DATA *) osi_malloc(len)) != NULL) {
memset(p_msg, 0, len);
p_msg->hdr.event = BTA_DM_API_BLE_MULTI_ADV_DATA_EVT;
p_msg->inst_id = inst_id;
p_msg->is_scan_rsp = is_scan_rsp;
p_msg->data_mask = data_mask;
p_msg->p_data = p_data;
bta_sys_sendmsg(p_msg);
}
}
/*******************************************************************************
**
** Function BTA_BleDisableAdvInstance
**
** Description This function disable a Multi-ADV instance.
**
** Parameter inst_id: instance ID to disable.
**
** Returns BTA_SUCCESS if command started successfully; otherwise failure.
**
*******************************************************************************/
void BTA_BleDisableAdvInstance (UINT8 inst_id) //this function just used for vendor debug
{
tBTA_DM_API_BLE_MULTI_ADV_DISABLE *p_msg;
APPL_TRACE_API ("BTA_BleDisableAdvInstance: %d", inst_id);
if ((p_msg = (tBTA_DM_API_BLE_MULTI_ADV_DISABLE *)
osi_malloc(sizeof(tBTA_DM_API_BLE_MULTI_ADV_DISABLE))) != NULL) {
memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_MULTI_ADV_DISABLE));
p_msg->hdr.event = BTA_DM_API_BLE_MULTI_ADV_DISABLE_EVT;
p_msg->inst_id = inst_id;
bta_sys_sendmsg(p_msg);
}
}
#endif // #if (BLE_HOST_BLE_MULTI_ADV_EN == TRUE)
/*******************************************************************************
**
** Function BTA_DmBleCfgFilterCondition
**
** Description This function is called to configure the adv data payload filter
** condition.
**
** Parameters action: to read/write/clear
** cond_type: filter condition type
** filt_index - Filter index
** p_cond: filter condition parameter
** p_cmpl_back - Command completed callback
** ref_value - Reference value
**
** Returns void
**
*******************************************************************************/
void BTA_DmBleCfgFilterCondition(tBTA_DM_BLE_SCAN_COND_OP action,
tBTA_DM_BLE_PF_COND_TYPE cond_type,
tBTA_DM_BLE_PF_FILT_INDEX filt_index,
tBTA_DM_BLE_PF_COND_PARAM *p_cond,
tBTA_DM_BLE_PF_CFG_CBACK *p_cmpl_cback,
tBTA_DM_BLE_REF_VALUE ref_value)
{
#if BLE_ANDROID_CONTROLLER_SCAN_FILTER == TRUE
tBTA_DM_API_CFG_FILTER_COND *p_msg;
APPL_TRACE_API ("BTA_DmBleCfgFilterCondition: %d, %d", action, cond_type);
UINT16 len = sizeof(tBTA_DM_API_CFG_FILTER_COND) +
sizeof(tBTA_DM_BLE_PF_COND_PARAM);
UINT8 *p;
if (NULL != p_cond) {
switch (cond_type) {
case BTA_DM_BLE_PF_SRVC_DATA_PATTERN:
case BTA_DM_BLE_PF_MANU_DATA:
/* Length of pattern and pattern mask and other elements in */
/* tBTA_DM_BLE_PF_MANU_COND */
len += ((p_cond->manu_data.data_len) * 2) +
sizeof(UINT16) + sizeof(UINT16) + sizeof(UINT8);
break;
case BTA_DM_BLE_PF_LOCAL_NAME:
len += ((p_cond->local_name.data_len) + sizeof(UINT8));
break;
case BTM_BLE_PF_SRVC_UUID:
case BTM_BLE_PF_SRVC_SOL_UUID:
len += sizeof(tBLE_BD_ADDR) + sizeof(tBTA_DM_BLE_PF_COND_MASK);
break;
default:
break;
}
}
if ((p_msg = (tBTA_DM_API_CFG_FILTER_COND *) osi_malloc(len)) != NULL) {
memset (p_msg, 0, len);
p_msg->hdr.event = BTA_DM_API_CFG_FILTER_COND_EVT;
p_msg->action = action;
p_msg->cond_type = cond_type;
p_msg->filt_index = filt_index;
p_msg->p_filt_cfg_cback = p_cmpl_cback;
p_msg->ref_value = ref_value;
if (p_cond) {
p_msg->p_cond_param = (tBTA_DM_BLE_PF_COND_PARAM *)(p_msg + 1);
memcpy(p_msg->p_cond_param, p_cond, sizeof(tBTA_DM_BLE_PF_COND_PARAM));
p = (UINT8 *)(p_msg->p_cond_param + 1);
if (cond_type == BTA_DM_BLE_PF_SRVC_DATA_PATTERN ||
cond_type == BTA_DM_BLE_PF_MANU_DATA) {
p_msg->p_cond_param->manu_data.p_pattern = p;
p_msg->p_cond_param->manu_data.data_len = p_cond->manu_data.data_len;
memcpy(p_msg->p_cond_param->manu_data.p_pattern, p_cond->manu_data.p_pattern,
p_cond->manu_data.data_len);
p += p_cond->manu_data.data_len;
if (cond_type == BTA_DM_BLE_PF_MANU_DATA) {
p_msg->p_cond_param->manu_data.company_id_mask =
p_cond->manu_data.company_id_mask;
if ( p_cond->manu_data.p_pattern_mask != NULL) {
p_msg->p_cond_param->manu_data.p_pattern_mask = p;
memcpy(p_msg->p_cond_param->manu_data.p_pattern_mask,
p_cond->manu_data.p_pattern_mask, p_cond->manu_data.data_len);
}
}
} else if (cond_type == BTA_DM_BLE_PF_LOCAL_NAME) {
p_msg->p_cond_param->local_name.p_data = p;
p_msg->p_cond_param->local_name.data_len =
p_cond->local_name.data_len;
memcpy(p_msg->p_cond_param->local_name.p_data,
p_cond->local_name.p_data, p_cond->local_name.data_len);
} else if ((cond_type == BTM_BLE_PF_SRVC_UUID
|| cond_type == BTM_BLE_PF_SRVC_SOL_UUID)) {
if (p_cond->srvc_uuid.p_target_addr != NULL) {
p_msg->p_cond_param->srvc_uuid.p_target_addr = (tBLE_BD_ADDR *)(p);
p_msg->p_cond_param->srvc_uuid.p_target_addr->type =
p_cond->srvc_uuid.p_target_addr->type;
memcpy(p_msg->p_cond_param->srvc_uuid.p_target_addr->bda,
p_cond->srvc_uuid.p_target_addr->bda, BD_ADDR_LEN);
p = (UINT8 *)( p_msg->p_cond_param->srvc_uuid.p_target_addr + 1);
}
if (p_cond->srvc_uuid.p_uuid_mask) {
p_msg->p_cond_param->srvc_uuid.p_uuid_mask = (tBTA_DM_BLE_PF_COND_MASK *)p;
memcpy(p_msg->p_cond_param->srvc_uuid.p_uuid_mask,
p_cond->srvc_uuid.p_uuid_mask, sizeof(tBTA_DM_BLE_PF_COND_MASK));
}
}
}
bta_sys_sendmsg(p_msg);
}
#else
UNUSED(action);
UNUSED(cond_type);
UNUSED(filt_index);
UNUSED(p_cond);
UNUSED(p_cmpl_cback);
UNUSED(ref_value);
#endif
}
/*******************************************************************************
**
** Function BTA_DmBleScanFilterSetup
**
** Description This function is called to setup the adv data payload filter param
**
** Parameters p_target: enable the filter condition on a target device; if NULL
** filt_index - Filter index
** p_filt_params -Filter parameters
** ref_value - Reference value
** action - Add, delete or clear
** p_cmpl_back - Command completed callback
**
** Returns void
**
*******************************************************************************/
void BTA_DmBleScanFilterSetup(UINT8 action, tBTA_DM_BLE_PF_FILT_INDEX filt_index,
tBTA_DM_BLE_PF_FILT_PARAMS *p_filt_params,
tBLE_BD_ADDR *p_target,
tBTA_DM_BLE_PF_PARAM_CBACK *p_cmpl_cback,
tBTA_DM_BLE_REF_VALUE ref_value)
{
#if BLE_ANDROID_CONTROLLER_SCAN_FILTER == TRUE
tBTA_DM_API_SCAN_FILTER_PARAM_SETUP *p_msg;
APPL_TRACE_API ("BTA_DmBleScanFilterSetup: %d", action);
UINT16 len = sizeof(tBTA_DM_API_SCAN_FILTER_PARAM_SETUP) + sizeof(tBLE_BD_ADDR);
if ((p_msg = (tBTA_DM_API_SCAN_FILTER_PARAM_SETUP *) osi_malloc(len)) != NULL) {
memset (p_msg, 0, len);
p_msg->hdr.event = BTA_DM_API_SCAN_FILTER_SETUP_EVT;
p_msg->action = action;
p_msg->filt_index = filt_index;
if (p_filt_params) {
memcpy(&p_msg->filt_params, p_filt_params, sizeof(tBTA_DM_BLE_PF_FILT_PARAMS));
}
p_msg->p_filt_param_cback = p_cmpl_cback;
p_msg->ref_value = ref_value;
if (p_target) {
p_msg->p_target = (tBLE_BD_ADDR *)(p_msg + 1);
memcpy(p_msg->p_target, p_target, sizeof(tBLE_BD_ADDR));
}
bta_sys_sendmsg(p_msg);
}
#else
UNUSED(action);
UNUSED(filt_index);
UNUSED(p_filt_params);
UNUSED(p_target);
UNUSED(p_cmpl_cback);
UNUSED(ref_value);
#endif
}
#if (BLE_HOST_ENERGY_INFO_EN == TRUE)
/*******************************************************************************
**
** Function BTA_DmBleGetEnergyInfo
**
** Description This function is called to obtain the energy info
**
** Parameters p_cmpl_cback - Command complete callback
**
** Returns void
**
*******************************************************************************/
void BTA_DmBleGetEnergyInfo(tBTA_BLE_ENERGY_INFO_CBACK *p_cmpl_cback)
{
tBTA_DM_API_ENERGY_INFO *p_msg;
APPL_TRACE_API ("BTA_DmBleGetEnergyInfo");
UINT16 len = sizeof(tBTA_DM_API_ENERGY_INFO) + sizeof(tBLE_BD_ADDR);
if ((p_msg = (tBTA_DM_API_ENERGY_INFO *) osi_malloc(len)) != NULL) {
memset (p_msg, 0, len);
p_msg->hdr.event = BTA_DM_API_BLE_ENERGY_INFO_EVT;
p_msg->p_energy_info_cback = p_cmpl_cback;
bta_sys_sendmsg(p_msg);
}
}
#endif // #if (BLE_HOST_ENERGY_INFO_EN == TRUE)
/*******************************************************************************
**
** Function BTA_DmEnableScanFilter
**
** Description This function is called to enable the adv data payload filter
**
** Parameters action - enable or disable the APCF feature
** p_cmpl_cback - Command completed callback
** ref_value - Reference value
**
** Returns void
**
*******************************************************************************/
void BTA_DmEnableScanFilter(UINT8 action, tBTA_DM_BLE_PF_STATUS_CBACK *p_cmpl_cback,
tBTA_DM_BLE_REF_VALUE ref_value)
{
#if BLE_ANDROID_CONTROLLER_SCAN_FILTER == TRUE
tBTA_DM_API_ENABLE_SCAN_FILTER *p_msg;
APPL_TRACE_API ("BTA_DmEnableScanFilter: %d\n", action);
UINT16 len = sizeof(tBTA_DM_API_ENABLE_SCAN_FILTER) + sizeof(tBLE_BD_ADDR);
if ((p_msg = (tBTA_DM_API_ENABLE_SCAN_FILTER *) osi_malloc(len)) != NULL) {
memset (p_msg, 0, len);
p_msg->hdr.event = BTA_DM_API_SCAN_FILTER_ENABLE_EVT;
p_msg->action = action;
p_msg->ref_value = ref_value;
p_msg->p_filt_status_cback = p_cmpl_cback;
bta_sys_sendmsg(p_msg);
}
#else
UNUSED(action);
UNUSED(p_cmpl_cback);
UNUSED(ref_value);
#endif
}
/*******************************************************************************
**
** Function BTA_DmBleUpdateConnectionParams
@@ -2831,83 +2148,7 @@ void BTA_DmSetEncryption(BD_ADDR bd_addr, tBTA_TRANSPORT transport, tBTA_DM_ENCR
}
#endif ///SMP_INCLUDED == TRUE
#if (BLE_HOST_REMOVE_AN_ACL_EN == TRUE)
/*******************************************************************************
**
** Function BTA_DmCloseACL
**
** Description This function force to close an ACL connection and remove the
** device from the security database list of known devices.
**
** Parameters: bd_addr - Address of the peer device
** remove_dev - remove device or not after link down
**
** Returns void
**
*******************************************************************************/
void BTA_DmCloseACL(BD_ADDR bd_addr, BOOLEAN remove_dev, tBTA_TRANSPORT transport)
{
tBTA_DM_API_REMOVE_ACL *p_msg;
APPL_TRACE_API("BTA_DmCloseACL");
if ((p_msg = (tBTA_DM_API_REMOVE_ACL *) osi_malloc(sizeof(tBTA_DM_API_REMOVE_ACL))) != NULL) {
memset(p_msg, 0, sizeof(tBTA_DM_API_REMOVE_ACL));
p_msg->hdr.event = BTA_DM_API_REMOVE_ACL_EVT;
memcpy(p_msg->bd_addr, bd_addr, BD_ADDR_LEN);
p_msg->remove_dev = remove_dev;
p_msg->transport = transport;
bta_sys_sendmsg(p_msg);
}
}
#endif // #if (BLE_HOST_REMOVE_AN_ACL_EN == TRUE)
#if BLE_INCLUDED == TRUE
#if (BLE_HOST_BLE_OBSERVE_EN == TRUE)
/*******************************************************************************
**
** Function BTA_DmBleObserve
**
** Description This procedure keep the device listening for advertising
** events from a broadcast device.
**
** Parameters start: start or stop observe.
**
** Returns void
**
** Returns void.
**
*******************************************************************************/
extern void BTA_DmBleObserve(BOOLEAN start, UINT32 duration,
tBTA_DM_SEARCH_CBACK *p_results_cb,
tBTA_START_STOP_SCAN_CMPL_CBACK *p_start_stop_scan_cb)
{
tBTA_DM_API_BLE_OBSERVE *p_msg;
APPL_TRACE_API("BTA_DmBleObserve:start = %d ", start);
if ((p_msg = (tBTA_DM_API_BLE_OBSERVE *) osi_malloc(sizeof(tBTA_DM_API_BLE_OBSERVE))) != NULL) {
memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_OBSERVE));
p_msg->hdr.event = BTA_DM_API_BLE_OBSERVE_EVT;
p_msg->start = start;
p_msg->duration = duration;
p_msg->p_cback = p_results_cb;
if (start){
p_msg->p_start_scan_cback = p_start_stop_scan_cb;
}
else {
p_msg->p_stop_scan_cback = p_start_stop_scan_cb;
}
bta_sys_sendmsg(p_msg);
}
}
#endif // #if (BLE_HOST_BLE_OBSERVE_EN == TRUE)
#if (BLE_42_SCAN_EN == TRUE)
/*******************************************************************************
@@ -2952,33 +2193,6 @@ extern void BTA_DmBleScan(BOOLEAN start, UINT32 duration,
}
#endif // #if (BLE_42_SCAN_EN == TRUE)
#if (BLE_HOST_STOP_ADV_UNUSED == TRUE)
/*******************************************************************************
**
** Function BTA_DmBleStopAdvertising
**
** Description This function set the random address for the APP
**
** Parameters void
**
** Returns void
**
**
*******************************************************************************/
extern void BTA_DmBleStopAdvertising(void)
{
BT_HDR *p_msg;
APPL_TRACE_API("BTA_DmBleStopAdvertising\n");
if ((p_msg = (BT_HDR *) osi_malloc(sizeof(BT_HDR))) != NULL) {
memset(p_msg, 0, sizeof(BT_HDR));
p_msg->event = BTA_DM_API_BLE_STOP_ADV_EVT;
bta_sys_sendmsg(p_msg);
}
}
#endif // #if (BLE_HOST_STOP_ADV_UNUSED == TRUE)
/*******************************************************************************
**
** Function BTA_DmSetRandAddress
@@ -3429,38 +2643,6 @@ void BTA_VendorInit (void)
APPL_TRACE_API("BTA_VendorInit");
}
/*******************************************************************************
**
** Function BTA_VendorCleanup
**
** Description This function frees up Broadcom specific VS specific dynamic memory
**
** Returns void
**
*******************************************************************************/
void BTA_VendorCleanup (void)
{
tBTM_BLE_VSC_CB cmn_ble_vsc_cb;
BTM_BleGetVendorCapabilities(&cmn_ble_vsc_cb);
#if (BLE_INCLUDED == TRUE && BLE_ANDROID_CONTROLLER_SCAN_FILTER == TRUE)
btm_ble_adv_filter_cleanup(); // when BLE_VND_INCLUDED is false, this function will be ignore, so move it out of "if"
#if 0 //by TH, comment out temporarily
if (cmn_ble_vsc_cb.max_filter > 0) {
btm_ble_adv_filter_cleanup();
#if BLE_PRIVACY_SPT == TRUE
btm_ble_resolving_list_cleanup ();
#endif
}
#endif
if (cmn_ble_vsc_cb.tot_scan_results_strg > 0) {
btm_ble_batchscan_cleanup();
}
#endif
}
#if (BLE_50_FEATURE_SUPPORT == TRUE)
void BTA_DmBleGapReadPHY(BD_ADDR addr)
{
@@ -42,11 +42,15 @@
#if BTA_DYNAMIC_MEMORY == FALSE
tBTA_DM_CB bta_dm_cb;
tBTA_DM_SEARCH_CB bta_dm_search_cb;
#if (CLASSIC_BT_INCLUDED == TRUE)
tBTA_DM_DI_CB bta_dm_di_cb;
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
#else
tBTA_DM_CB *bta_dm_cb_ptr;
tBTA_DM_SEARCH_CB *bta_dm_search_cb_ptr;
tBTA_DM_DI_CB *bta_dm_di_cb_ptr;
#if (CLASSIC_BT_INCLUDED == TRUE)
tBTA_DM_DI_CB *bta_dm_di_cb_ptr;
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
SemaphoreHandle_t deinit_semaphore;
#endif
@@ -90,9 +94,6 @@ const tBTA_DM_ACTION bta_dm_action[BTA_DM_MAX_EVT] = {
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
bta_dm_acl_change, /* BTA_DM_ACL_CHANGE_EVT */
bta_dm_add_device, /* BTA_DM_API_ADD_DEVICE_EVT */
#if (BLE_HOST_REMOVE_AN_ACL_EN == TRUE)
bta_dm_close_acl, /* BTA_DM_API_REMOVE_ACL_EVT */
#endif // #if (BLE_HOST_REMOVE_AN_ACL_EN == TRUE)
#if (SMP_INCLUDED == TRUE)
/* security API events */
bta_dm_bond, /* BTA_DM_API_BOND_EVT */
@@ -134,38 +135,21 @@ const tBTA_DM_ACTION bta_dm_action[BTA_DM_MAX_EVT] = {
bta_dm_ble_passkey_reply, /* BTA_DM_API_BLE_PASSKEY_REPLY_EVT */
bta_dm_ble_set_static_passkey, /* BTA_DM_API_BLE_SET_STATIC_PASSKEY_EVT */
bta_dm_ble_confirm_reply, /* BTA_DM_API_BLE_CONFIRM_REPLY_EVT */
bta_dm_security_grant,
bta_dm_security_grant, /* BTA_DM_API_BLE_SEC_GRANT_EVT */
#endif ///SMP_INCLUDED == TRUE
bta_dm_ble_set_bg_conn_type,
#if (BLE_GATT_BGCONN == TRUE)
bta_dm_ble_set_bg_conn_type, /* BTA_DM_API_BLE_SET_BG_CONN_TYPE */
#endif // (BLE_GATT_BGCONN == TRUE)
bta_dm_ble_set_conn_params, /* BTA_DM_API_BLE_CONN_PARAM_EVT */
#if (BLE_HOST_CONN_SCAN_PARAM_EN == TRUE)
bta_dm_ble_set_conn_scan_params, /* BTA_DM_API_BLE_CONN_SCAN_PARAM_EVT */
#endif // #if (BLE_HOST_CONN_SCAN_PARAM_EN == TRUE)
#if (BLE_HOST_BLE_SCAN_PARAM_UNUSED == TRUE)
bta_dm_ble_set_scan_params, /* BTA_DM_API_BLE_SCAN_PARAM_EVT */
#endif // #if (BLE_HOST_BLE_SCAN_PARAM_UNUSED == TRUE)
#if (BLE_42_SCAN_EN == TRUE)
bta_dm_ble_set_scan_fil_params, /* BTA_DM_API_BLE_SCAN_FIL_PARAM_EVT */
#endif // #if (BLE_42_SCAN_EN == TRUE)
#if (BLE_HOST_BLE_OBSERVE_EN == TRUE)
bta_dm_ble_observe, /* BTA_DM_API_BLE_OBSERVE_EVT */
#endif // #if (BLE_HOST_BLE_OBSERVE_EN == TRUE)
#if (BLE_42_SCAN_EN == TRUE)
bta_dm_ble_scan, /* BTA_DM_API_BLE_SCAN_EVT */
#endif // #if (BLE_42_SCAN_EN == TRUE)
bta_dm_ble_update_conn_params, /* BTA_DM_API_UPDATE_CONN_PARAM_EVT */
/* This handler function added by
Yulong at 2016/9/9 to support the
random address setting for the APP */
bta_dm_ble_set_rand_address, /* BTA_DM_API_SET_RAND_ADDR_EVT*/
bta_dm_ble_clear_rand_address, /* BTA_DM_API_CLEAR_RAND_ADDR_EVT */
/* This handler function added by
Yulong at 2016/10/19 to support
stop the ble advertising setting
by the APP */
#if (BLE_HOST_STOP_ADV_UNUSED == TRUE)
bta_dm_ble_stop_advertising, /* BTA_DM_API_BLE_STOP_ADV_EVT */
#endif // #if (BLE_HOST_STOP_ADV_UNUSED == TRUE)
#if BLE_PRIVACY_SPT == TRUE
bta_dm_ble_config_local_privacy, /* BTA_DM_API_LOCAL_PRIVACY_EVT */
#endif
@@ -183,58 +167,20 @@ const tBTA_DM_ACTION bta_dm_action[BTA_DM_MAX_EVT] = {
/* New function to allow set raw scan
response data to HCI */
bta_dm_ble_set_scan_rsp_raw, /* BTA_DM_API_BLE_SET_SCAN_RSP_RAW_EVT */
bta_dm_ble_broadcast, /* BTA_DM_API_BLE_BROADCAST_EVT */
bta_dm_ble_advstop, /* BTA_DM_API_BLE_ADVSTOP_EVT */
#endif // #if (BLE_42_ADV_EN == TRUE)
bta_dm_ble_set_data_length, /* BTA_DM_API_SET_DATA_LENGTH_EVT */
#if BLE_ANDROID_CONTROLLER_SCAN_FILTER == TRUE
bta_dm_cfg_filter_cond, /* BTA_DM_API_CFG_FILTER_COND_EVT */
bta_dm_scan_filter_param_setup, /* BTA_DM_API_SCAN_FILTER_SETUP_EVT */
bta_dm_enable_scan_filter, /* BTA_DM_API_SCAN_FILTER_ENABLE_EVT */
#endif
#if (BLE_HOST_BLE_MULTI_ADV_EN == TRUE)
bta_dm_ble_multi_adv_enb, /* BTA_DM_API_BLE_MULTI_ADV_ENB_EVT */
bta_dm_ble_multi_adv_upd_param, /* BTA_DM_API_BLE_MULTI_ADV_PARAM_UPD_EVT */
bta_dm_ble_multi_adv_data, /* BTA_DM_API_BLE_MULTI_ADV_DATA_EVT */
btm_dm_ble_multi_adv_disable, /* BTA_DM_API_BLE_MULTI_ADV_DISABLE_EVT */
#endif // BLE_HOST_BLE_MULTI_ADV_EN
#if (BLE_HOST_SETUP_STORAGE_EN == TRUE)
bta_dm_ble_setup_storage, /* BTA_DM_API_BLE_SETUP_STORAGE_EVT */
#endif // #if (BLE_HOST_SETUP_STORAGE_EN == TRUE)
#if (BLE_HOST_BATCH_SCAN_EN == TRUE)
bta_dm_ble_enable_batch_scan, /* BTA_DM_API_BLE_ENABLE_BATCH_SCAN_EVT */
bta_dm_ble_disable_batch_scan, /* BTA_DM_API_BLE_DISABLE_BATCH_SCAN_EVT */
#endif // #if (BLE_HOST_BATCH_SCAN_EN == TRUE)
#if (BLE_HOST_READ_SCAN_REPORTS_EN == TRUE)
bta_dm_ble_read_scan_reports, /* BTA_DM_API_BLE_READ_SCAN_REPORTS_EVT */
#endif // #if (BLE_HOST_READ_SCAN_REPORTS_EN == TRUE)
#if (BLE_HOST_TRACK_ADVERTISER_EN == TRUE)
bta_dm_ble_track_advertiser, /* BTA_DM_API_BLE_TRACK_ADVERTISER_EVT */
#endif // #if (BLE_HOST_TRACK_ADVERTISER_EN == TRUE)
#if (BLE_HOST_ENERGY_INFO_EN == TRUE)
bta_dm_ble_get_energy_info, /* BTA_DM_API_BLE_ENERGY_INFO_EVT */
#endif // #if (BLE_HOST_ENERGY_INFO_EN == TRUE)
bta_dm_ble_disconnect, /* BTA_DM_API_BLE_DISCONNECT_EVT */
#endif
#if (BLE_HOST_ENABLE_TEST_MODE_EN == TRUE)
bta_dm_enable_test_mode, /* BTA_DM_API_ENABLE_TEST_MODE_EVT */
bta_dm_disable_test_mode, /* BTA_DM_API_DISABLE_TEST_MODE_EVT */
#endif // #if (BLE_HOST_ENABLE_TEST_MODE_EN == TRUE)
#if (BLE_HOST_EXECUTE_CBACK_EN == TRUE)
bta_dm_execute_callback, /* BTA_DM_API_EXECUTE_CBACK_EVT */
#endif // #if (BLE_HOST_EXECUTE_CBACK_EN == TRUE)
#if (BLE_HOST_REMOVE_ALL_ACL_EN == TRUE)
bta_dm_remove_all_acl, /* BTA_DM_API_REMOVE_ALL_ACL_EVT */
#endif // #if (BLE_HOST_REMOVE_ALL_ACL_EN == TRUE)
bta_dm_remove_device, /* BTA_DM_API_REMOVE_DEVICE_EVT */
bta_dm_ble_set_channels, /* BTA_DM_API_BLE_SET_CHANNELS_EVT */
bta_dm_update_white_list, /* BTA_DM_API_UPDATE_WHITE_LIST_EVT */
bta_dm_clear_white_list, /* BTA_DM_API_CLEAR_WHITE_LIST_EVT */
#if (BLE_HOST_READ_TX_POWER_EN == TRUE)
bta_dm_ble_read_adv_tx_power, /* BTA_DM_API_BLE_READ_ADV_TX_POWER_EVT */
#endif // #if (BLE_HOST_READ_TX_POWER_EN == TRUE)
bta_dm_read_rssi, /* BTA_DM_API_READ_RSSI_EVT */
#if BLE_INCLUDED == TRUE
#if ((BLE_42_SCAN_EN == TRUE) || (BLE_50_EXTEND_SCAN_EN == TRUE))
bta_dm_ble_update_duplicate_exceptional_list,/* BTA_DM_API_UPDATE_DUPLICATE_EXCEPTIONAL_LIST_EVT */
#endif // ((BLE_42_SCAN_EN == TRUE) || (BLE_50_EXTEND_SCAN_EN == TRUE))
#endif
#if (BLE_50_FEATURE_SUPPORT == TRUE)
bta_dm_ble_gap_read_phy, /* BTA_DM_API_READ_PHY_EVT */
@@ -572,11 +518,15 @@ void bta_dm_sm_deinit(void)
{
memset(&bta_dm_cb, 0, sizeof(tBTA_DM_CB));
memset(&bta_dm_search_cb, 0, sizeof(tBTA_DM_SEARCH_CB));
#if (CLASSIC_BT_INCLUDED == TRUE)
memset(&bta_dm_di_cb, 0, sizeof(tBTA_DM_DI_CB));
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
#if BTA_DYNAMIC_MEMORY
FREE_AND_RESET(bta_dm_cb_ptr);
FREE_AND_RESET(bta_dm_search_cb_ptr);
#if (CLASSIC_BT_INCLUDED == TRUE)
FREE_AND_RESET(bta_dm_di_cb_ptr);
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
#endif /* #if BTA_DYNAMIC_MEMORY */
}
@@ -32,6 +32,8 @@
#include "stack/btm_api.h"
#include "osi/allocator.h"
#if (CLASSIC_BT_INCLUDED == TRUE)
#if BTA_DYNAMIC_MEMORY == FALSE
tBTA_DM_CONNECTED_SRVCS bta_dm_conn_srvcs;
#else
@@ -1171,3 +1173,5 @@ tBTA_DM_CONTRL_STATE bta_dm_pm_obtain_controller_state(void)
}
#endif
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
@@ -80,9 +80,6 @@ enum {
BTA_DM_ACL_CHANGE_EVT,
BTA_DM_API_ADD_DEVICE_EVT,
#if (BLE_HOST_REMOVE_AN_ACL_EN == TRUE)
BTA_DM_API_REMOVE_ACL_EVT,
#endif // #if (BLE_HOST_REMOVE_AN_ACL_EN == TRUE)
#if (SMP_INCLUDED == TRUE)
/* security API events */
BTA_DM_API_BOND_EVT,
@@ -126,22 +123,15 @@ enum {
BTA_DM_API_BLE_CONFIRM_REPLY_EVT,
BTA_DM_API_BLE_SEC_GRANT_EVT,
#endif ///SMP_INCLUDED == TRUE
#if (BLE_GATT_BGCONN == TRUE)
BTA_DM_API_BLE_SET_BG_CONN_TYPE,
#endif // (BLE_GATT_BGCONN == TRUE)
BTA_DM_API_BLE_CONN_PARAM_EVT,
#if (BLE_HOST_CONN_SCAN_PARAM_EN == TRUE)
BTA_DM_API_BLE_CONN_SCAN_PARAM_EVT,
#endif // #if (BLE_HOST_CONN_SCAN_PARAM_EN == TRUE)
#if (BLE_HOST_BLE_SCAN_PARAM_UNUSED == TRUE)
BTA_DM_API_BLE_SCAN_PARAM_EVT,
#endif // #if (BLE_HOST_BLE_SCAN_PARAM_UNUSED == TRUE)
/*******This event added by Yulong at 2016/10/25 to
support the scan filter setting for the APP******/
#if (BLE_42_SCAN_EN == TRUE)
BTA_DM_API_BLE_SCAN_FIL_PARAM_EVT,
#endif // #if (BLE_42_SCAN_EN == TRUE)
#if (BLE_HOST_BLE_OBSERVE_EN == TRUE)
BTA_DM_API_BLE_OBSERVE_EVT,
#endif // #if (BLE_HOST_BLE_OBSERVE_EN == TRUE)
#if (BLE_42_SCAN_EN == TRUE)
BTA_DM_API_BLE_SCAN_EVT,
#endif // #if (BLE_42_SCAN_EN == TRUE)
@@ -150,11 +140,6 @@ enum {
support the random address setting for the APP******/
BTA_DM_API_SET_RAND_ADDR_EVT,
BTA_DM_API_CLEAR_RAND_ADDR_EVT,
/*******This event added by Yulong at 2016/10/19 to
support stop the ble advertising setting by the APP******/
#if (BLE_HOST_STOP_ADV_UNUSED == TRUE)
BTA_DM_API_BLE_STOP_ADV_EVT,
#endif // #if (BLE_HOST_STOP_ADV_UNUSED == TRUE)
#if BLE_PRIVACY_SPT == TRUE
BTA_DM_API_LOCAL_PRIVACY_EVT,
#endif
@@ -173,59 +158,22 @@ enum {
BTA_DM_API_BLE_SET_SCAN_RSP_EVT,
/* Add for set raw scan response data */
BTA_DM_API_BLE_SET_SCAN_RSP_RAW_EVT,
BTA_DM_API_BLE_BROADCAST_EVT,
BTA_DM_API_BLE_ADVSTOP_EVT,
#endif // #if (BLE_42_ADV_EN == TRUE)
BTA_DM_API_SET_DATA_LENGTH_EVT,
#if BLE_ANDROID_CONTROLLER_SCAN_FILTER == TRUE
BTA_DM_API_CFG_FILTER_COND_EVT,
BTA_DM_API_SCAN_FILTER_SETUP_EVT,
BTA_DM_API_SCAN_FILTER_ENABLE_EVT,
#endif
#if (BLE_HOST_BLE_MULTI_ADV_EN == TRUE)
BTA_DM_API_BLE_MULTI_ADV_ENB_EVT,
BTA_DM_API_BLE_MULTI_ADV_PARAM_UPD_EVT,
BTA_DM_API_BLE_MULTI_ADV_DATA_EVT,
BTA_DM_API_BLE_MULTI_ADV_DISABLE_EVT,
#endif // #if (BLE_HOST_BLE_MULTI_ADV_EN == TRUE)
#if (BLE_HOST_SETUP_STORAGE_EN == TRUE)
BTA_DM_API_BLE_SETUP_STORAGE_EVT,
#endif // #if (BLE_HOST_SETUP_STORAGE_EN == TRUE)
#if (BLE_HOST_BATCH_SCAN_EN == TRUE)
BTA_DM_API_BLE_ENABLE_BATCH_SCAN_EVT,
BTA_DM_API_BLE_DISABLE_BATCH_SCAN_EVT,
#endif // #if (BLE_HOST_BATCH_SCAN_EN == TRUE)
#if (BLE_HOST_READ_SCAN_REPORTS_EN == TRUE)
BTA_DM_API_BLE_READ_SCAN_REPORTS_EVT,
#endif // #if (BLE_HOST_READ_SCAN_REPORTS_EN == TRUE)
#if (BLE_HOST_TRACK_ADVERTISER_EN == TRUE)
BTA_DM_API_BLE_TRACK_ADVERTISER_EVT,
#endif // #if (BLE_HOST_TRACK_ADVERTISER_EN == TRUE)
#if (BLE_HOST_ENERGY_INFO_EN == TRUE)
BTA_DM_API_BLE_ENERGY_INFO_EVT,
#endif // #if (BLE_HOST_ENERGY_INFO_EN == TRUE)
BTA_DM_API_BLE_DISCONNECT_EVT,
#endif
#if (BLE_HOST_ENABLE_TEST_MODE_EN == TRUE)
BTA_DM_API_ENABLE_TEST_MODE_EVT,
BTA_DM_API_DISABLE_TEST_MODE_EVT,
#endif // #if (BLE_HOST_ENABLE_TEST_MODE_EN == TRUE)
#if (BLE_HOST_EXECUTE_CBACK_EN == TRUE)
BTA_DM_API_EXECUTE_CBACK_EVT,
#endif // #if (BLE_HOST_EXECUTE_CBACK_EN == TRUE)
#if (BLE_HOST_REMOVE_ALL_ACL_EN == TRUE)
BTA_DM_API_REMOVE_ALL_ACL_EVT,
#endif // #if (BLE_HOST_REMOVE_ALL_ACL_EN == TRUE)
BTA_DM_API_REMOVE_DEVICE_EVT,
BTA_DM_API_BLE_SET_CHANNELS_EVT,
BTA_DM_API_UPDATE_WHITE_LIST_EVT,
BTA_DM_API_CLEAR_WHITE_LIST_EVT,
#if (BLE_HOST_READ_TX_POWER_EN == TRUE)
BTA_DM_API_BLE_READ_ADV_TX_POWER_EVT,
#endif // #if (BLE_HOST_READ_TX_POWER_EN == TRUE)
BTA_DM_API_READ_RSSI_EVT,
#if BLE_INCLUDED == TRUE
#if ((BLE_42_SCAN_EN == TRUE) || (BLE_50_EXTEND_SCAN_EN == TRUE))
BTA_DM_API_UPDATE_DUPLICATE_EXCEPTIONAL_LIST_EVT,
#endif // ((BLE_42_SCAN_EN == TRUE) || (BLE_50_EXTEND_SCAN_EN == TRUE))
#endif
#if (BLE_50_FEATURE_SUPPORT == TRUE)
BTA_DM_API_READ_PHY_EVT,
@@ -489,6 +437,7 @@ typedef struct {
tBTA_UPDATE_WHITELIST_CBACK *update_wl_cb;
}tBTA_DM_API_UPDATE_WHITE_LIST;
#if ((BLE_42_SCAN_EN == TRUE) || (BLE_50_EXTEND_SCAN_EN == TRUE))
typedef struct {
BT_HDR hdr;
UINT8 subcode;
@@ -496,13 +445,7 @@ typedef struct {
BD_ADDR device_info;
tBTA_UPDATE_DUPLICATE_EXCEPTIONAL_LIST_CMPL_CBACK *exceptional_list_cb;
}tBTA_DM_API_UPDATE_DUPLICATE_EXCEPTIONAL_LIST;
#if (BLE_HOST_READ_TX_POWER_EN == TRUE)
typedef struct {
BT_HDR hdr;
tBTA_CMPL_CB *read_tx_power_cb;
}tBTA_DM_API_READ_ADV_TX_POWER;
#endif // #if (BLE_HOST_READ_TX_POWER_EN == TRUE)
#endif // ((BLE_42_SCAN_EN == TRUE) || (BLE_50_EXTEND_SCAN_EN == TRUE))
#endif ///BLE_INCLUDED == TRUE
@@ -765,15 +708,6 @@ typedef struct {
UINT8 transport;
} tBTA_DM_API_REMOVE_DEVICE;
#if (BLE_HOST_EXECUTE_CBACK_EN == TRUE)
/* data type for BTA_DM_API_EXECUTE_CBACK_EVT */
typedef struct {
BT_HDR hdr;
void *p_param;
tBTA_DM_EXEC_CBACK *p_exec_cback;
} tBTA_DM_API_EXECUTE_CBACK;
#endif // #if (BLE_HOST_EXECUTE_CBACK_EN == TRUE)
/* data type for tBTA_DM_API_SET_ENCRYPTION */
typedef struct {
BT_HDR hdr;
@@ -886,15 +820,6 @@ typedef struct {
tBLE_SCAN_PARAM_SETUP_CBACK scan_param_setup_cback;
} tBTA_DM_API_BLE_SCAN_FILTER_PARAMS;
#if (BLE_HOST_CONN_SCAN_PARAM_EN == TRUE)
/* set scan parameter for BLE connections */
typedef struct {
BT_HDR hdr;
UINT16 scan_int;
UINT16 scan_window;
} tBTA_DM_API_BLE_CONN_SCAN_PARAMS;
#endif // #if (BLE_HOST_CONN_SCAN_PARAM_EN == TRUE)
/* Data type for start/stop observe */
typedef struct {
BT_HDR hdr;
@@ -971,35 +896,6 @@ typedef struct {
} tBTA_DM_API_BLE_FEATURE;
#if (BLE_HOST_BLE_MULTI_ADV_EN == TRUE)
/* multi adv data structure */
typedef struct {
BT_HDR hdr;
tBTA_BLE_MULTI_ADV_CBACK *p_cback;
void *p_ref;
tBTA_BLE_ADV_PARAMS *p_params;
} tBTA_DM_API_BLE_MULTI_ADV_ENB;
typedef struct {
BT_HDR hdr;
UINT8 inst_id;
tBTA_BLE_ADV_PARAMS *p_params;
} tBTA_DM_API_BLE_MULTI_ADV_PARAM;
typedef struct {
BT_HDR hdr;
UINT8 inst_id;
BOOLEAN is_scan_rsp;
tBTA_BLE_AD_MASK data_mask;
tBTA_BLE_ADV_DATA *p_data;
} tBTA_DM_API_BLE_MULTI_ADV_DATA;
typedef struct {
BT_HDR hdr;
UINT8 inst_id;
} tBTA_DM_API_BLE_MULTI_ADV_DISABLE;
#endif // #if (BLE_HOST_BLE_MULTI_ADV_EN == TRUE)
typedef struct {
BT_HDR hdr;
UINT32 data_mask;
@@ -1016,59 +912,6 @@ typedef struct {
tBTA_SET_ADV_DATA_CMPL_CBACK *p_adv_data_cback;
} tBTA_DM_API_SET_ADV_CONFIG_RAW;
#if (BLE_HOST_SETUP_STORAGE_EN == TRUE)
typedef struct {
BT_HDR hdr;
UINT8 batch_scan_full_max;
UINT8 batch_scan_trunc_max;
UINT8 batch_scan_notify_threshold;
tBTA_BLE_SCAN_SETUP_CBACK *p_setup_cback;
tBTA_BLE_SCAN_THRESHOLD_CBACK *p_thres_cback;
tBTA_BLE_SCAN_REP_CBACK *p_read_rep_cback;
tBTA_DM_BLE_REF_VALUE ref_value;
} tBTA_DM_API_SET_STORAGE_CONFIG;
#endif // #if (BLE_HOST_SETUP_STORAGE_EN == TRUE)
#if (BLE_HOST_BATCH_SCAN_EN == TRUE)
typedef struct {
BT_HDR hdr;
tBTA_BLE_BATCH_SCAN_MODE scan_mode;
UINT32 scan_int;
UINT32 scan_window;
tBTA_BLE_DISCARD_RULE discard_rule;
tBLE_ADDR_TYPE addr_type;
tBTA_DM_BLE_REF_VALUE ref_value;
} tBTA_DM_API_ENABLE_SCAN;
typedef struct {
BT_HDR hdr;
tBTA_DM_BLE_REF_VALUE ref_value;
} tBTA_DM_API_DISABLE_SCAN;
#endif // #if (BLE_HOST_BATCH_SCAN_EN == TRUE)
#if (BLE_HOST_READ_SCAN_REPORTS_EN == TRUE)
typedef struct {
BT_HDR hdr;
tBTA_BLE_BATCH_SCAN_MODE scan_type;
tBTA_DM_BLE_REF_VALUE ref_value;
} tBTA_DM_API_READ_SCAN_REPORTS;
#endif // #if (BLE_HOST_READ_SCAN_REPORTS_EN == TRUE)
#if (BLE_HOST_TRACK_ADVERTISER_EN == TRUE)
typedef struct {
BT_HDR hdr;
tBTA_DM_BLE_REF_VALUE ref_value;
tBTA_BLE_TRACK_ADV_CBACK *p_track_adv_cback;
} tBTA_DM_API_TRACK_ADVERTISER;
#endif // #if (BLE_HOST_TRACK_ADVERTISER_EN == TRUE)
#if (BLE_HOST_ENERGY_INFO_EN == TRUE)
typedef struct {
BT_HDR hdr;
tBTA_BLE_ENERGY_INFO_CBACK *p_energy_info_cback;
} tBTA_DM_API_ENERGY_INFO;
#endif // #if (BLE_HOST_ENERGY_INFO_EN == TRUE)
typedef struct {
BT_HDR hdr;
BD_ADDR remote_bda;
@@ -1349,26 +1192,6 @@ typedef struct {
#endif /* BLE_INCLUDED */
#if (BLE_HOST_REMOVE_AN_ACL_EN == TRUE)
/* data type for BTA_DM_API_REMOVE_ACL_EVT */
typedef struct {
BT_HDR hdr;
BD_ADDR bd_addr;
BOOLEAN remove_dev;
tBTA_TRANSPORT transport;
} tBTA_DM_API_REMOVE_ACL;
#endif // #if (BLE_HOST_REMOVE_AN_ACL_EN == TRUE)
#if (BLE_HOST_REMOVE_ALL_ACL_EN == TRUE)
/* data type for BTA_DM_API_REMOVE_ALL_ACL_EVT */
typedef struct {
BT_HDR hdr;
tBTA_DM_LINK_TYPE link_type;
} tBTA_DM_API_REMOVE_ALL_ACL;
#endif // #if (BLE_HOST_REMOVE_ALL_ACL_EN == TRUE)
typedef struct {
BT_HDR hdr;
BD_ADDR bd_addr;
@@ -1378,35 +1201,6 @@ typedef struct {
UINT16 timeout;
} tBTA_DM_API_UPDATE_CONN_PARAM;
#if BLE_ANDROID_CONTROLLER_SCAN_FILTER == TRUE
typedef struct {
BT_HDR hdr;
tBTA_DM_BLE_SCAN_COND_OP action;
tBTA_DM_BLE_PF_COND_TYPE cond_type;
tBTA_DM_BLE_PF_FILT_INDEX filt_index;
tBTA_DM_BLE_PF_COND_PARAM *p_cond_param;
tBTA_DM_BLE_PF_CFG_CBACK *p_filt_cfg_cback;
tBTA_DM_BLE_REF_VALUE ref_value;
} tBTA_DM_API_CFG_FILTER_COND;
typedef struct {
BT_HDR hdr;
UINT8 action;
tBTA_DM_BLE_PF_STATUS_CBACK *p_filt_status_cback;
tBTA_DM_BLE_REF_VALUE ref_value;
} tBTA_DM_API_ENABLE_SCAN_FILTER;
typedef struct {
BT_HDR hdr;
UINT8 action;
tBTA_DM_BLE_PF_FILT_INDEX filt_index;
tBTA_DM_BLE_PF_FILT_PARAMS filt_params;
tBLE_BD_ADDR *p_target;
tBTA_DM_BLE_PF_PARAM_CBACK *p_filt_param_cback;
tBTA_DM_BLE_REF_VALUE ref_value;
} tBTA_DM_API_SCAN_FILTER_PARAM_SETUP;
#endif
#if (BLE_50_DTM_TEST_EN == TRUE)
typedef struct {
BT_HDR hdr;
@@ -1815,12 +1609,14 @@ typedef union {
tBTA_DM_API_CFG_COEX_STATUS cfg_coex_status;
#endif
tBTA_DM_API_SEND_VENDOR_HCI_CMD vendor_hci_cmd;
#if CLASSIC_BT_INCLUDED
tBTA_DM_API_CONFIG_EIR config_eir;
tBTA_DM_API_SET_AFH_CHANNELS set_afh_channels;
tBTA_DM_API_PAGE_TO_SET set_page_timeout;
tBTA_DM_API_PAGE_TO_GET get_page_timeout;
tBTA_DM_API_SET_ACL_PKT_TYPES set_acl_pkt_types;
#endif /* CLASSIC_BT_INCLUDED */
#if (ENC_KEY_SIZE_CTRL_MODE != ENC_KEY_SIZE_CTRL_MODE_NONE)
tBTA_DM_API_SET_MIN_ENC_KEY_SIZE set_min_enc_key_size;
#endif
@@ -1831,9 +1627,6 @@ typedef union {
#if (BLE_INCLUDED == TRUE)
tBTA_DM_API_BLE_SET_CHANNELS ble_set_channels;
tBTA_DM_API_UPDATE_WHITE_LIST white_list;
#if (BLE_HOST_READ_TX_POWER_EN == TRUE)
tBTA_DM_API_READ_ADV_TX_POWER read_tx_power;
#endif // #if (BLE_HOST_READ_TX_POWER_EN == TRUE)
#endif ///BLE_INCLUDED == TRUE
tBTA_DM_API_READ_RSSI rssi;
@@ -1886,9 +1679,6 @@ typedef union {
#endif /* #if (BTA_DM_QOS_INCLUDED == TRUE) */
tBTA_DM_API_DI_DISC di_disc;
#if (BLE_HOST_EXECUTE_CBACK_EN == TRUE)
tBTA_DM_API_EXECUTE_CBACK exec_cback;
#endif // #if (BLE_HOST_EXECUTE_CBACK_EN == TRUE)
tBTA_DM_API_SET_ENCRYPTION set_encryption;
#if BLE_INCLUDED == TRUE
@@ -1899,12 +1689,6 @@ typedef union {
tBTA_DM_API_BLE_SEC_GRANT ble_sec_grant;
tBTA_DM_API_BLE_SET_BG_CONN_TYPE ble_set_bd_conn_type;
tBTA_DM_API_BLE_CONN_PARAMS ble_set_conn_params;
#if (BLE_HOST_CONN_SCAN_PARAM_EN == TRUE)
tBTA_DM_API_BLE_CONN_SCAN_PARAMS ble_set_conn_scan_params;
#endif // #if (BLE_HOST_CONN_SCAN_PARAM_EN == TRUE)
#if (BLE_HOST_BLE_SCAN_PARAM_UNUSED == TRUE)
tBTA_DM_API_BLE_SCAN_PARAMS ble_set_scan_params;
#endif // #if (BLE_HOST_BLE_SCAN_PARAM_UNUSED == TRUE)
tBTA_DM_API_BLE_SCAN_FILTER_PARAMS ble_set_scan_fil_params;
tBTA_DM_API_BLE_OBSERVE ble_observe;
tBTA_DM_API_BLE_SCAN ble_scan;
@@ -1917,44 +1701,16 @@ typedef union {
tBTA_DM_API_BLE_ADV_PARAMS_ALL ble_set_adv_params_all;
tBTA_DM_API_SET_ADV_CONFIG ble_set_adv_data;
tBTA_DM_API_SET_ADV_CONFIG_RAW ble_set_adv_data_raw;
#if BLE_ANDROID_CONTROLLER_SCAN_FILTER == TRUE
tBTA_DM_API_SCAN_FILTER_PARAM_SETUP ble_scan_filt_param_setup;
tBTA_DM_API_CFG_FILTER_COND ble_cfg_filter_cond;
tBTA_DM_API_ENABLE_SCAN_FILTER ble_enable_scan_filt;
#endif
tBTA_DM_API_UPDATE_CONN_PARAM ble_update_conn_params;
tBTA_DM_API_BLE_SET_DATA_LENGTH ble_set_data_length;
tBTA_DM_APT_SET_DEV_ADDR set_addr;
tBTA_DM_APT_CLEAR_ADDR clear_addr;
tBTA_DM_API_SET_RPA_TIMEOUT set_rpa_timeout;
tBTA_DM_API_ADD_DEV_TO_RESOLVING_LIST add_dev_to_resolving_list;
#if (BLE_HOST_BLE_MULTI_ADV_EN == TRUE)
tBTA_DM_API_BLE_MULTI_ADV_ENB ble_multi_adv_enb;
tBTA_DM_API_BLE_MULTI_ADV_PARAM ble_multi_adv_param;
tBTA_DM_API_BLE_MULTI_ADV_DATA ble_multi_adv_data;
tBTA_DM_API_BLE_MULTI_ADV_DISABLE ble_multi_adv_disable;
#endif // #if (BLE_HOST_BLE_MULTI_ADV_EN == TRUE)
#if (BLE_HOST_SETUP_STORAGE_EN == TRUE)
tBTA_DM_API_SET_STORAGE_CONFIG ble_set_storage;
#endif // #if (BLE_HOST_SETUP_STORAGE_EN == TRUE)
#if (BLE_HOST_BATCH_SCAN_EN == TRUE)
tBTA_DM_API_ENABLE_SCAN ble_enable_scan;
#endif // #if (BLE_HOST_BATCH_SCAN_EN == TRUE)
#if (BLE_HOST_READ_SCAN_REPORTS_EN == TRUE)
tBTA_DM_API_READ_SCAN_REPORTS ble_read_reports;
#endif // #if (BLE_HOST_READ_SCAN_REPORTS_EN == TRUE)
#if (BLE_HOST_BATCH_SCAN_EN == TRUE)
tBTA_DM_API_DISABLE_SCAN ble_disable_scan;
#endif // #if (BLE_HOST_BATCH_SCAN_EN == TRUE)
#if (BLE_HOST_TRACK_ADVERTISER_EN == TRUE)
tBTA_DM_API_TRACK_ADVERTISER ble_track_advert;
#endif // #if (BLE_HOST_TRACK_ADVERTISER_EN == TRUE)
#if (BLE_HOST_ENERGY_INFO_EN == TRUE)
tBTA_DM_API_ENERGY_INFO ble_energy_info;
#endif // #if (BLE_HOST_ENERGY_INFO_EN == TRUE)
tBTA_DM_API_BLE_DISCONNECT ble_disconnect;
#if ((BLE_42_SCAN_EN == TRUE) || (BLE_50_EXTEND_SCAN_EN == TRUE))
tBTA_DM_API_UPDATE_DUPLICATE_EXCEPTIONAL_LIST ble_duplicate_exceptional_list;
#endif // ((BLE_42_SCAN_EN == TRUE) || (BLE_50_EXTEND_SCAN_EN == TRUE))
#if (BLE_50_FEATURE_SUPPORT == TRUE)
tBTA_DM_API_READ_PHY ble_read_phy;
tBTA_DM_API_SET_PER_DEF_PHY ble_set_per_def_phy;
@@ -2006,13 +1762,6 @@ typedef union {
tBTA_DM_API_BLE_SET_CSA_SUPPORT ble_set_csa_support;
tBTA_DM_API_BLE_SET_VENDOR_EVT_MASK ble_set_vendor_evt_mask;
#endif
#if (BLE_HOST_REMOVE_AN_ACL_EN == TRUE)
tBTA_DM_API_REMOVE_ACL remove_acl;
#endif // #if (BLE_HOST_REMOVE_AN_ACL_EN == TRUE)
#if (BLE_HOST_REMOVE_ALL_ACL_EN == TRUE)
tBTA_DM_API_REMOVE_ALL_ACL remove_all_acl;
#endif // #if (BLE_HOST_REMOVE_ALL_ACL_EN == TRUE)
#if (BLE_FEAT_ISO_EN == TRUE)
#if (BLE_FEAT_ISO_BIG_BROCASTER_EN == TRUE)
tBTA_DM_API_BIG_CREATE big_creat;
@@ -2197,24 +1946,9 @@ typedef struct {
BOOLEAN is_bta_dm_active;
tBTA_DM_ACTIVE_LINK device_list;
tBTA_DM_SEC_CBACK *p_sec_cback;
#if ((defined BLE_INCLUDED) && (BLE_INCLUDED == TRUE))
tBTA_BLE_SCAN_SETUP_CBACK *p_setup_cback;
tBTA_DM_BLE_PF_CFG_CBACK *p_scan_filt_cfg_cback;
tBTA_DM_BLE_PF_STATUS_CBACK *p_scan_filt_status_cback;
tBTA_DM_BLE_PF_PARAM_CBACK *p_scan_filt_param_cback;
#if (BLE_HOST_BLE_MULTI_ADV_EN == TRUE)
tBTA_BLE_MULTI_ADV_CBACK *p_multi_adv_cback;
#endif // #if (BLE_HOST_BLE_MULTI_ADV_EN == TRUE)
#if (BLE_HOST_ENERGY_INFO_EN == TRUE)
tBTA_BLE_ENERGY_INFO_CBACK *p_energy_info_cback;
#endif // #if (BLE_HOST_ENERGY_INFO_EN == TRUE)
#endif
UINT16 state;
BOOLEAN disabling;
TIMER_LIST_ENT disable_timer;
UINT32 wbt_sdp_handle; /* WIDCOMM Extensions SDP record handle */
UINT8 wbt_scn; /* WIDCOMM Extensions SCN */
UINT8 num_master_only;
#if (BTA_DM_PM_INCLUDED == TRUE)
UINT8 pm_id;
tBTA_PM_TIMER pm_timer[BTA_DM_NUM_PM_TIMER];
@@ -2222,7 +1956,9 @@ typedef struct {
UINT32 role_policy_mask; /* the bits set indicates the modules that wants to remove role switch from the default link policy */
UINT16 cur_policy; /* current default link policy */
UINT16 rs_event; /* the event waiting for role switch */
#if (CLASSIC_BT_INCLUDED == TRUE)
UINT8 cur_av_count; /* current AV connections */
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
BOOLEAN disable_pair_mode; /* disable pair mode or not */
BOOLEAN conn_paired_only; /* allow connectable to paired device only or not */
tBTA_DM_API_SEARCH search_msg;
@@ -2253,7 +1989,9 @@ typedef struct {
tBTA_DM_ENCRYPT_CBACK *p_encrypt_cback;
#if (CLASSIC_BT_INCLUDED == TRUE)
TIMER_LIST_ENT switch_delay_timer[BTA_DM_NUM_PEER_DEVICE];
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
} tBTA_DM_CB;
@@ -2423,8 +2161,10 @@ extern tBTA_DM_SEARCH_CB *bta_dm_search_cb_ptr;
#if BTA_DYNAMIC_MEMORY == FALSE
extern tBTA_DM_DI_CB bta_dm_di_cb;
#else
#if (CLASSIC_BT_INCLUDED == TRUE)
extern tBTA_DM_DI_CB *bta_dm_di_cb_ptr;
#define bta_dm_di_cb (*bta_dm_di_cb_ptr)
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
extern SemaphoreHandle_t deinit_semaphore;
#endif
@@ -2501,9 +2241,6 @@ extern void bta_dm_ble_set_bg_conn_type (tBTA_DM_MSG *p_data);
extern void bta_dm_ble_set_conn_params (tBTA_DM_MSG *p_data);
extern void bta_dm_ble_set_scan_params(tBTA_DM_MSG *p_data);
extern void bta_dm_ble_set_scan_fil_params(tBTA_DM_MSG *p_data);
#if (BLE_HOST_CONN_SCAN_PARAM_EN == TRUE)
extern void bta_dm_ble_set_conn_scan_params (tBTA_DM_MSG *p_data);
#endif // #if (BLE_HOST_CONN_SCAN_PARAM_EN == TRUE)
#if ((defined BTA_GATT_INCLUDED) && (BTA_GATT_INCLUDED == TRUE) && SDP_INCLUDED == TRUE) && (GATTC_INCLUDED == TRUE)
extern void bta_dm_close_gatt_conn(tBTA_DM_MSG *p_data);
#endif /* ((defined BTA_GATT_INCLUDED) && (BTA_GATT_INCLUDED == TRUE) && SDP_INCLUDED == TRUE) && (GATTC_INCLUDED == TRUE) */
@@ -2513,9 +2250,6 @@ extern void bta_dm_ble_update_conn_params (tBTA_DM_MSG *p_data);
extern void bta_dm_ble_disconnect (tBTA_DM_MSG *p_data);
extern void bta_dm_ble_set_rand_address(tBTA_DM_MSG *p_data);
extern void bta_dm_ble_clear_rand_address(tBTA_DM_MSG *p_data);
#if (BLE_HOST_STOP_ADV_UNUSED == TRUE)
extern void bta_dm_ble_stop_advertising(tBTA_DM_MSG *p_data);
#endif // #if (BLE_HOST_STOP_ADV_UNUSED == TRUE)
extern void bta_dm_ble_config_local_privacy (tBTA_DM_MSG *p_data);
extern void bta_dm_ble_config_local_icon (tBTA_DM_MSG *p_data);
#if (BT_GATTS_KEY_MATERIAL_CHAR == TRUE)
@@ -2526,17 +2260,12 @@ extern void bta_dm_ble_set_adv_config (tBTA_DM_MSG *p_data);
extern void bta_dm_ble_set_adv_config_raw (tBTA_DM_MSG *p_data);
extern void bta_dm_ble_set_scan_rsp (tBTA_DM_MSG *p_data);
extern void bta_dm_ble_set_scan_rsp_raw (tBTA_DM_MSG *p_data);
extern void bta_dm_ble_broadcast (tBTA_DM_MSG *p_data);
extern void bta_dm_ble_advstop (tBTA_DM_MSG *p_data);
extern void bta_dm_ble_set_data_length(tBTA_DM_MSG *p_data);
extern void bta_dm_ble_update_duplicate_exceptional_list(tBTA_DM_MSG *p_data);
#if SMP_INCLUDED == TRUE
extern void bta_dm_co_security_param_init(void);
#endif
#if BLE_ANDROID_CONTROLLER_SCAN_FILTER == TRUE
extern void bta_dm_cfg_filter_cond (tBTA_DM_MSG *p_data);
extern void bta_dm_scan_filter_param_setup (tBTA_DM_MSG *p_data);
extern void bta_dm_enable_scan_filter(tBTA_DM_MSG *p_data);
#endif
extern void btm_dm_ble_multi_adv_disable(tBTA_DM_MSG *p_data);
extern void bta_dm_ble_multi_adv_data(tBTA_DM_MSG *p_data);
extern void bta_dm_ble_multi_adv_upd_param(tBTA_DM_MSG *p_data);
@@ -2567,21 +2296,8 @@ extern void bta_dm_ble_gap_set_ext_scan_params(tBTA_DM_MSG *p_data);
extern void bta_dm_ble_gap_ext_scan(tBTA_DM_MSG *p_data);
extern void bta_dm_ble_gap_set_prefer_ext_conn_params(tBTA_DM_MSG *p_data);
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
#if (BLE_HOST_SETUP_STORAGE_EN == TRUE)
extern void bta_dm_ble_setup_storage(tBTA_DM_MSG *p_data);
#endif // #if (BLE_HOST_SETUP_STORAGE_EN == TRUE)
extern void bta_dm_ble_enable_batch_scan(tBTA_DM_MSG *p_data);
extern void bta_dm_ble_disable_batch_scan(tBTA_DM_MSG *p_data);
extern void bta_dm_ble_read_scan_reports(tBTA_DM_MSG *p_data);
#if (BLE_HOST_TRACK_ADVERTISER_EN == TRUE)
extern void bta_dm_ble_track_advertiser(tBTA_DM_MSG *p_data);
#endif // #if (BLE_HOST_TRACK_ADVERTISER_EN == TRUE)
#if (BLE_HOST_ENERGY_INFO_EN == TRUE)
extern void bta_dm_ble_get_energy_info(tBTA_DM_MSG *p_data);
#endif // #if (BLE_HOST_ENERGY_INFO_EN == TRUE)
#endif
extern void bta_dm_set_encryption(tBTA_DM_MSG *p_data);
extern void bta_dm_confirm(tBTA_DM_MSG *p_data);
@@ -2644,7 +2360,6 @@ extern void bta_dm_disable_test_mode(tBTA_DM_MSG *p_data);
extern void bta_dm_execute_callback(tBTA_DM_MSG *p_data);
extern void bta_dm_remove_all_acl(tBTA_DM_MSG *p_data);
#if (BLE_50_FEATURE_SUPPORT == TRUE)
extern void bta_dm_ble_gap_read_phy(tBTA_DM_MSG *p_data);
@@ -764,10 +764,12 @@ void bta_gattc_conn(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
}
if (p_clcb->p_rcb) {
#if (CLASSIC_BT_INCLUDED == TRUE)
/* there is no RM for GATT */
if (p_clcb->transport == BTA_TRANSPORT_BR_EDR) {
bta_sys_conn_open(BTA_ID_GATTC, BTA_ALL_APP_ID, p_clcb->bda);
}
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
tBTA_GATT_STATUS status = BTA_GATT_OK;
if (p_data && p_data->int_conn.already_connect) {
//clear already_connect
@@ -870,11 +872,11 @@ void bta_gattc_close(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
cb_data.close.reason = p_clcb->reason;
cb_data.close.status = p_clcb->status;
bdcpy(cb_data.close.remote_bda, p_clcb->bda);
#if (CLASSIC_BT_INCLUDED == TRUE)
if (p_clcb->transport == BTA_TRANSPORT_BR_EDR) {
bta_sys_conn_close( BTA_ID_GATTC , BTA_ALL_APP_ID, p_clcb->bda);
}
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
if (p_data->hdr.event == BTA_GATTC_API_CLOSE_EVT) {
cb_data.close.status = GATT_Disconnect(p_data->hdr.layer_specific);
} else if (p_data->hdr.event == BTA_GATTC_INT_DISCONN_EVT) {
@@ -1338,11 +1340,13 @@ void bta_gattc_confirm(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
!= GATT_SUCCESS) {
APPL_TRACE_ERROR("bta_gattc_confirm to handle [0x%04x] failed", handle);
} else {
#if (CLASSIC_BT_INCLUDED == TRUE)
/* if over BR_EDR, inform PM for mode change */
if (p_clcb->transport == BTA_TRANSPORT_BR_EDR) {
bta_sys_busy(BTA_ID_GATTC, BTA_ALL_APP_ID, p_clcb->bda);
bta_sys_idle(BTA_ID_GATTC, BTA_ALL_APP_ID, p_clcb->bda);
}
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
}
}
/*******************************************************************************
@@ -2202,13 +2206,13 @@ static void bta_gattc_cmpl_cback(UINT16 conn_id, tGATTC_OPTYPE op, tGATT_STATUS
APPL_TRACE_ERROR("bta_gattc_cmpl_cback unknown conn_id = %d, ignore data", conn_id);
return;
}
#if (CLASSIC_BT_INCLUDED == TRUE)
/* if over BR_EDR, inform PM for mode change */
if (p_clcb->transport == BTA_TRANSPORT_BR_EDR) {
bta_sys_busy(BTA_ID_GATTC, BTA_ALL_APP_ID, p_clcb->bda);
bta_sys_idle(BTA_ID_GATTC, BTA_ALL_APP_ID, p_clcb->bda);
}
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
bta_gattc_cmpl_sendmsg(conn_id, op, status, p_data);
}
@@ -695,12 +695,13 @@ void bta_gatts_indicate_handle (tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA *p_msg)
p_msg->api_indicate.len,
p_msg->api_indicate.value);
}
#if (CLASSIC_BT_INCLUDED == TRUE)
/* if over BR_EDR, inform PM for mode change */
if (transport == BTA_TRANSPORT_BR_EDR) {
bta_sys_busy(BTA_ID_GATTS, BTA_ALL_APP_ID, remote_bda);
bta_sys_idle(BTA_ID_GATTS, BTA_ALL_APP_ID, remote_bda);
}
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
} else {
APPL_TRACE_ERROR("Unknown connection ID: %d fail sending notification",
p_msg->api_indicate.hdr.layer_specific);
@@ -839,10 +840,11 @@ void bta_gatts_close (tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA *p_msg)
p_rcb = bta_gatts_find_app_rcb_by_app_if(gatt_if);
if (p_rcb && p_rcb->p_cback) {
#if (CLASSIC_BT_INCLUDED == TRUE)
if (transport == BTA_TRANSPORT_BR_EDR) {
bta_sys_conn_close( BTA_ID_GATTS , BTA_ALL_APP_ID, remote_bda);
}
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
close.status = status;
close.conn_id = p_msg->hdr.layer_specific;
(*p_rcb->p_cback)(BTA_GATTS_CLOSE_EVT, (tBTA_GATTS *)&close);
@@ -925,12 +927,13 @@ static void bta_gatts_send_request_cback (UINT16 conn_id,
conn_id, trans_id, req_type);
if (p_rcb && p_rcb->p_cback) {
#if (CLASSIC_BT_INCLUDED == TRUE)
/* if over BR_EDR, inform PM for mode change */
if (transport == BTA_TRANSPORT_BR_EDR) {
bta_sys_busy(BTA_ID_GATTS, BTA_ALL_APP_ID, cb_data.req_data.remote_bda);
bta_sys_idle(BTA_ID_GATTS, BTA_ALL_APP_ID, cb_data.req_data.remote_bda);
}
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
cb_data.req_data.conn_id = conn_id;
cb_data.req_data.trans_id = trans_id;
cb_data.req_data.p_data = (tBTA_GATTS_REQ_DATA *)p_data;
@@ -980,6 +983,7 @@ static void bta_gatts_conn_cback (tGATT_IF gatt_if, BD_ADDR bda, UINT16 conn_id,
p_reg = bta_gatts_find_app_rcb_by_app_if(gatt_if);
if (p_reg && p_reg->p_cback) {
#if (CLASSIC_BT_INCLUDED == TRUE)
/* there is no RM for GATT */
if (transport == BTA_TRANSPORT_BR_EDR) {
if (connected) {
@@ -988,6 +992,7 @@ static void bta_gatts_conn_cback (tGATT_IF gatt_if, BD_ADDR bda, UINT16 conn_id,
bta_sys_conn_close( BTA_ID_GATTS , BTA_ALL_APP_ID, bda);
}
}
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
if(evt == BTA_GATTS_CONNECT_EVT) {
tL2C_LCB *p_lcb = l2cu_find_lcb_by_bd_addr(bda, BT_TRANSPORT_LE);
if(p_lcb != NULL) {
@@ -2605,8 +2605,9 @@ static void bta_hh_le_add_dev_bg_conn(tBTA_HH_DEV_CB *p_cb, BOOLEAN check_bond)
BTA_GATTC_Enh_Open(bta_hh_cb.gatt_if, p_cb->addr, BLE_ADDR_UNKNOWN_TYPE, FALSE,
BTA_GATT_TRANSPORT_LE, FALSE, BLE_ADDR_UNKNOWN_TYPE, false, 0xFF, 0xFF, 0, NULL, NULL);
p_cb->in_bg_conn = TRUE;
#if (BLE_GATT_BGCONN == TRUE)
BTA_DmBleSetBgConnType(BTA_DM_BLE_CONN_AUTO, NULL);
#endif // (BLE_GATT_BGCONN == TRUE)
}
return;
}
@@ -293,9 +293,6 @@ typedef struct {
BOOLEAN report_dup; /* report duplicated inquiry response with higher RSSI value */
tBTA_DM_INQ_FILT filter_type; /* Filter condition type. */
tBTA_DM_INQ_COND filter_cond; /* Filter condition data. */
#if (defined(BTA_HOST_INTERLEAVE_SEARCH) && BTA_HOST_INTERLEAVE_SEARCH == TRUE)
UINT8 intl_duration[4];/*duration array storing the interleave scan's time portions*/
#endif
} tBTA_DM_INQ;
/* Config EIR callback */
@@ -514,13 +511,6 @@ typedef struct {
tBTA_BLE_SERVICE service;
} tBTA_BLE_INQ_DATA;
enum {
BTA_BLE_BATCH_SCAN_MODE_PASS = 1,
BTA_BLE_BATCH_SCAN_MODE_ACTI = 2,
BTA_BLE_BATCH_SCAN_MODE_PASS_ACTI = 3
};
typedef UINT8 tBTA_BLE_BATCH_SCAN_MODE;
enum {
BTA_BLE_DISCARD_OLD_ITEMS = 0,
BTA_BLE_DISCARD_LOWER_RSSI_ITEMS = 1
@@ -533,19 +523,6 @@ enum {
};
typedef UINT8 tBTA_BLE_ADV_CHANGE_REASON;
enum {
BTA_BLE_BATCH_SCAN_ENB_EVT = 1,
BTA_BLE_BATCH_SCAN_CFG_STRG_EVT = 2,
BTA_BLE_BATCH_SCAN_DATA_EVT = 3,
BTA_BLE_BATCH_SCAN_THRES_EVT = 4,
BTA_BLE_BATCH_SCAN_PARAM_EVT = 5,
BTA_BLE_BATCH_SCAN_DIS_EVT = 6
};
typedef tBTM_BLE_BATCH_SCAN_EVT tBTA_BLE_BATCH_SCAN_EVT;
#if (BLE_HOST_TRACK_ADVERTISER_EN == TRUE)
typedef tBTM_BLE_TRACK_ADV_ACTION tBTA_BLE_TRACK_ADV_ACTION;
#endif // #if (BLE_HOST_TRACK_ADVERTISER_EN == TRUE)
// #endif
/* BLE customer specific feature function type definitions */
@@ -579,7 +556,6 @@ enum {
BTA_DM_BLE_SCAN_COND_DELETE,
BTA_DM_BLE_SCAN_COND_CLEAR = 2
};
typedef UINT8 tBTA_DM_BLE_SCAN_COND_OP;
/* ADV payload filtering vendor specific call event */
enum {
@@ -587,18 +563,6 @@ enum {
BTA_BLE_SCAN_PF_COND_EVT
};
/* filter selection bit index */
#define BTA_DM_BLE_PF_ADDR_FILTER BTM_BLE_PF_ADDR_FILTER
#define BTA_DM_BLE_PF_SRVC_DATA BTM_BLE_PF_SRVC_DATA
#define BTA_DM_BLE_PF_SRVC_UUID BTM_BLE_PF_SRVC_UUID
#define BTA_DM_BLE_PF_SRVC_SOL_UUID BTM_BLE_PF_SRVC_SOL_UUID
#define BTA_DM_BLE_PF_LOCAL_NAME BTM_BLE_PF_LOCAL_NAME
#define BTA_DM_BLE_PF_MANU_DATA BTM_BLE_PF_MANU_DATA
#define BTA_DM_BLE_PF_SRVC_DATA_PATTERN BTM_BLE_PF_SRVC_DATA_PATTERN
#define BTA_DM_BLE_PF_TYPE_ALL BTM_BLE_PF_TYPE_ALL
#define BTA_DM_BLE_PF_TYPE_MAX BTM_BLE_PF_TYPE_MAX
typedef UINT8 tBTA_DM_BLE_PF_COND_TYPE;
typedef union {
UINT16 uuid16_mask;
UINT32 uuid32_mask;
@@ -634,18 +598,6 @@ typedef struct {
as data pattern, set to all 0xff, match exact data */
} tBTA_DM_BLE_PF_SRVC_PATTERN_COND;
typedef union {
tBLE_BD_ADDR target_addr;
tBTA_DM_BLE_PF_LOCAL_NAME_COND local_name; /* local name filtering */
tBTA_DM_BLE_PF_MANU_COND manu_data; /* manufacturer data filtering */
tBTA_DM_BLE_PF_UUID_COND srvc_uuid; /* service UUID filtering */
tBTA_DM_BLE_PF_UUID_COND solicitate_uuid; /* solicited service UUID filtering */
tBTA_DM_BLE_PF_SRVC_PATTERN_COND srvc_data; /* service data pattern */
} tBTA_DM_BLE_PF_COND_PARAM;
typedef UINT8 tBTA_DM_BLE_PF_FILT_INDEX;
typedef UINT8 tBTA_DM_BLE_PF_AVBL_SPACE;
typedef INT8 tBTA_DM_RSSI_VALUE;
typedef UINT8 tBTA_DM_LINK_QUALITY_VALUE;
@@ -1053,82 +1005,8 @@ typedef union {
/* Security callback */
typedef void (tBTA_DM_SEC_CBACK)(tBTA_DM_SEC_EVT event, tBTA_DM_SEC *p_data);
#if (BLE_HOST_BLE_MULTI_ADV_EN == TRUE)
#define BTA_BLE_MULTI_ADV_ILLEGAL 0
/* multi adv callback event */
#define BTA_BLE_MULTI_ADV_ENB_EVT 1
#define BTA_BLE_MULTI_ADV_DISABLE_EVT 2
#define BTA_BLE_MULTI_ADV_PARAM_EVT 3
#define BTA_BLE_MULTI_ADV_DATA_EVT 4
typedef UINT8 tBTA_BLE_MULTI_ADV_EVT;
/* multi adv callback */
typedef void (tBTA_BLE_MULTI_ADV_CBACK)(tBTA_BLE_MULTI_ADV_EVT event,
UINT8 inst_id, void *p_ref, tBTA_STATUS status);
#endif // #if (BLE_HOST_BLE_MULTI_ADV_EN == TRUE)
typedef UINT32 tBTA_DM_BLE_REF_VALUE;
#define BTA_DM_BLE_PF_ENABLE_EVT BTM_BLE_PF_ENABLE
#define BTA_DM_BLE_PF_CONFIG_EVT BTM_BLE_PF_CONFIG
typedef UINT8 tBTA_DM_BLE_PF_EVT;
#define BTA_DM_BLE_PF_ENABLE 1
#define BTA_DM_BLE_PF_CONFIG 2
typedef UINT8 tBTA_DM_BLE_PF_ACTION;
/* Config callback */
typedef void (tBTA_DM_BLE_PF_CFG_CBACK) (tBTA_DM_BLE_PF_ACTION action,
tBTA_DM_BLE_PF_COND_TYPE cfg_cond,
tBTA_DM_BLE_PF_AVBL_SPACE avbl_space, tBTA_STATUS status,
tBTA_DM_BLE_REF_VALUE ref_value);
/* Param callback */
typedef void (tBTA_DM_BLE_PF_PARAM_CBACK) (UINT8 action_type, tBTA_DM_BLE_PF_AVBL_SPACE avbl_space,
tBTA_DM_BLE_REF_VALUE ref_value, tBTA_STATUS status);
/* Status callback */
typedef void (tBTA_DM_BLE_PF_STATUS_CBACK) (UINT8 action, tBTA_STATUS status,
tBTA_DM_BLE_REF_VALUE ref_value);
#define BTA_DM_BLE_PF_BRDCAST_ADDR_FILT 1
#define BTA_DM_BLE_PF_SERV_DATA_CHG_FILT 2
#define BTA_DM_BLE_PF_SERV_UUID 4
#define BTA_DM_BLE_PF_SERV_SOLC_UUID 8
#define BTA_DM_BLE_PF_LOC_NAME_CHECK 16
#define BTA_DM_BLE_PF_MANUF_NAME_CHECK 32
#define BTA_DM_BLE_PF_SERV_DATA_CHECK 64
typedef UINT16 tBTA_DM_BLE_PF_FEAT_SEL;
#define BTA_DM_BLE_PF_LIST_LOGIC_OR 1
#define BTA_DM_BLE_PF_LIST_LOGIC_AND 2
typedef UINT16 tBTA_DM_BLE_PF_LIST_LOGIC_TYPE;
#define BTA_DM_BLE_PF_FILT_LOGIC_OR 0
#define BTA_DM_BLE_PF_FILT_LOGIC_AND 1
typedef UINT16 tBTA_DM_BLE_PF_FILT_LOGIC_TYPE;
typedef UINT8 tBTA_DM_BLE_PF_RSSI_THRESHOLD;
typedef UINT8 tBTA_DM_BLE_PF_DELIVERY_MODE;
typedef UINT16 tBTA_DM_BLE_PF_TIMEOUT;
typedef UINT8 tBTA_DM_BLE_PF_TIMEOUT_CNT;
typedef UINT16 tBTA_DM_BLE_PF_ADV_TRACK_ENTRIES;
typedef struct {
tBTA_DM_BLE_PF_FEAT_SEL feat_seln;
tBTA_DM_BLE_PF_LIST_LOGIC_TYPE list_logic_type;
tBTA_DM_BLE_PF_FILT_LOGIC_TYPE filt_logic_type;
tBTA_DM_BLE_PF_RSSI_THRESHOLD rssi_high_thres;
tBTA_DM_BLE_PF_RSSI_THRESHOLD rssi_low_thres;
tBTA_DM_BLE_PF_DELIVERY_MODE dely_mode;
tBTA_DM_BLE_PF_TIMEOUT found_timeout;
tBTA_DM_BLE_PF_TIMEOUT lost_timeout;
tBTA_DM_BLE_PF_TIMEOUT_CNT found_timeout_cnt;
tBTA_DM_BLE_PF_ADV_TRACK_ENTRIES num_of_tracking_entries;
} tBTA_DM_BLE_PF_FILT_PARAMS;
/* Search callback events */
#define BTA_DM_INQ_RES_EVT 0 /* Inquiry result for a peer device. */
#define BTA_DM_INQ_CMPL_EVT 1 /* Inquiry complete. */
@@ -1310,11 +1188,6 @@ typedef void (tBTA_DM_ENCRYPT_CBACK) (BD_ADDR bd_addr, tBTA_TRANSPORT transport,
#define BTA_DM_BLE_SEC_MITM BTM_BLE_SEC_ENCRYPT_MITM
typedef tBTM_BLE_SEC_ACT tBTA_DM_BLE_SEC_ACT;
typedef tBTM_BLE_TX_TIME_MS tBTA_DM_BLE_TX_TIME_MS;
typedef tBTM_BLE_RX_TIME_MS tBTA_DM_BLE_RX_TIME_MS;
typedef tBTM_BLE_IDLE_TIME_MS tBTA_DM_BLE_IDLE_TIME_MS;
typedef tBTM_BLE_ENERGY_USED tBTA_DM_BLE_ENERGY_USED;
#define BTA_DM_CONTRL_UNKNOWN 0 /* Unknown state */
#define BTA_DM_CONTRL_ACTIVE 1 /* ACL link on, SCO link ongoing, sniff mode */
#define BTA_DM_CONTRL_SCAN 2 /* Scan state - paging/inquiry/trying to connect*/
@@ -1326,9 +1199,6 @@ typedef UINT8 tBTA_DM_BLE_ADV_STATE;
typedef UINT8 tBTA_DM_BLE_ADV_INFO_PRESENT;
typedef UINT8 tBTA_DM_BLE_RSSI_VALUE;
typedef UINT16 tBTA_DM_BLE_ADV_INFO_TIMESTAMP;
#if (BLE_HOST_TRACK_ADVERTISER_EN == TRUE)
typedef tBTM_BLE_TRACK_ADV_DATA tBTA_DM_BLE_TRACK_ADV_DATA;
#endif // #if (BLE_HOST_TRACK_ADVERTISER_EN == TRUE)
typedef void (tBTA_BLE_SCAN_THRESHOLD_CBACK)(tBTA_DM_BLE_REF_VALUE ref_value);
@@ -1336,33 +1206,12 @@ typedef void (tBTA_BLE_SCAN_REP_CBACK) (tBTA_DM_BLE_REF_VALUE ref_value, UINT8 r
UINT8 num_records, UINT16 data_len,
UINT8 *p_rep_data, tBTA_STATUS status);
typedef void (tBTA_BLE_SCAN_SETUP_CBACK) (tBTA_BLE_BATCH_SCAN_EVT evt,
tBTA_DM_BLE_REF_VALUE ref_value,
tBTA_STATUS status);
typedef void (tBTA_START_STOP_SCAN_CMPL_CBACK) (tBTA_STATUS status);
typedef void (tBTA_START_STOP_ADV_CMPL_CBACK) (tBTA_STATUS status);
typedef void (tBTA_CLEAR_ADV_CMPL_CBACK) (tBTA_STATUS status);
#if (BLE_HOST_TRACK_ADVERTISER_EN == TRUE)
typedef void (tBTA_BLE_TRACK_ADV_CMPL_CBACK)(int action, tBTA_STATUS status,
tBTA_DM_BLE_PF_AVBL_SPACE avbl_space,
tBTA_DM_BLE_REF_VALUE ref_value);
typedef void (tBTA_BLE_TRACK_ADV_CBACK)(tBTA_DM_BLE_TRACK_ADV_DATA *p_adv_data);
#endif // #if (BLE_HOST_TRACK_ADVERTISER_EN == TRUE)
#if (BLE_HOST_ENERGY_INFO_EN == TRUE)
typedef void (tBTA_BLE_ENERGY_INFO_CBACK)(tBTA_DM_BLE_TX_TIME_MS tx_time,
tBTA_DM_BLE_RX_TIME_MS rx_time,
tBTA_DM_BLE_IDLE_TIME_MS idle_time,
tBTA_DM_BLE_ENERGY_USED energy_used,
tBTA_DM_CONTRL_STATE ctrl_state,
tBTA_STATUS status);
#endif // #if (BLE_HOST_ENERGY_INFO_EN == TRUE)
#else
typedef UINT8 tBTA_DM_BLE_SEC_ACT;
#endif
@@ -2898,9 +2747,6 @@ extern void BTA_DmBleScan(BOOLEAN start, UINT32 duration,
tBTA_DM_SEARCH_CBACK *p_results_cb,
tBTA_START_STOP_SCAN_CMPL_CBACK *p_start_stop_scan_cb);
#if (BLE_HOST_STOP_ADV_UNUSED == TRUE)
extern void BTA_DmBleStopAdvertising(void);
#endif // #if (BLE_HOST_STOP_ADV_UNUSED == TRUE)
extern void BTA_DmSetRandAddress(BD_ADDR rand_addr, tBTA_SET_RAND_ADDR_CBACK *p_set_rand_addr_cback);
extern void BTA_DmClearRandAddress(void);
@@ -3066,7 +2912,7 @@ extern void BTA_DmUpdateDuplicateExceptionalList(UINT8 subcode, UINT32 type,
/*******************************************************************************
**
** Function BTA_DmBleBroadcast
** Function BTA_DmBleAdvStop
**
** Description This function starts or stops LE broadcasting.
**
@@ -3076,68 +2922,7 @@ extern void BTA_DmUpdateDuplicateExceptionalList(UINT8 subcode, UINT32 type,
** Returns None
**
*******************************************************************************/
extern void BTA_DmBleBroadcast (BOOLEAN start, tBTA_START_STOP_ADV_CMPL_CBACK *p_start_stop_adv_cb);
#if (BLE_HOST_BLE_MULTI_ADV_EN == TRUE)
/*******************************************************************************
**
** Function BTA_BleEnableAdvInstance
**
** Description This function enables the Multi ADV instance feature
**
** Parameters p_params Pointer to ADV param user defined structure
** p_cback Pointer to Multi ADV callback structure
** p_ref - Reference pointer
**
** Returns None
**
*******************************************************************************/
extern void BTA_BleEnableAdvInstance (tBTA_BLE_ADV_PARAMS *p_params,
tBTA_BLE_MULTI_ADV_CBACK *p_cback, void *p_ref);
/*******************************************************************************
**
** Function BTA_BleUpdateAdvInstParam
**
** Description This function updates the Multi ADV instance params
**
** Parameters inst_id Instance ID
** p_params Pointer to ADV param user defined structure
**
** Returns None
**
*******************************************************************************/
extern void BTA_BleUpdateAdvInstParam (UINT8 inst_id,
tBTA_BLE_ADV_PARAMS *p_params);
/*******************************************************************************
**
** Function BTA_BleCfgAdvInstData
**
** Description This function is called to configure the ADV instance data
**
** Parameters inst_id - Instance ID
** is_scan_rsp - Boolean value Scan response
** Pointer to User defined ADV data structure
** Returns None
**
*******************************************************************************/
extern void BTA_BleCfgAdvInstData (UINT8 inst_id, BOOLEAN is_scan_rsp,
tBTA_BLE_AD_MASK data_mask, tBTA_BLE_ADV_DATA *p_data);
/*******************************************************************************
**
** Function BTA_BleDisableAdvInstance
**
** Description This function is called to disable the ADV instance
**
** Parameters inst_id - Instance ID to be disabled
**
** Returns None
**
*******************************************************************************/
extern void BTA_BleDisableAdvInstance(UINT8 inst_id);
#endif // #if (BLE_HOST_BLE_MULTI_ADV_EN == TRUE)
extern void BTA_DmBleAdvStop (BOOLEAN start, tBTA_START_STOP_ADV_CMPL_CBACK *p_start_stop_adv_cb);
/*******************************************************************************
**
@@ -3232,178 +3017,6 @@ void BTA_DmBleGapCsSetProcPatams(tBTA_DM_CS_SET_PROC_PARAMS *set_proc_params);
void BTA_DmBleGapCsProcEnable(uint16_t conn_handle, uint8_t config_id, uint8_t enable);
#endif // (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE)
/*******************************************************************************
**
** Function BTA_DmBleSetStorageParams
**
** Description This function is called to set the storage parameters
**
** Parameters batch_scan_full_max -Max storage space (in %) allocated to full scanning
** batch_scan_trunc_max -Max storage space (in %) allocated to truncated scanning
** batch_scan_notify_threshold - Setup notification level based on total space
** consumed by both pools. Setting it to 0 will disable threshold notification
** p_setup_cback - Setup callback
** p_thres_cback - Threshold callback
** p_rep_cback - Reports callback
** ref_value - Reference value
**
** Returns None
**
*******************************************************************************/
extern void BTA_DmBleSetStorageParams(UINT8 batch_scan_full_max,
UINT8 batch_scan_trunc_max,
UINT8 batch_scan_notify_threshold,
tBTA_BLE_SCAN_SETUP_CBACK *p_setup_cback,
tBTA_BLE_SCAN_THRESHOLD_CBACK *p_thres_cback,
tBTA_BLE_SCAN_REP_CBACK *p_rep_cback,
tBTA_DM_BLE_REF_VALUE ref_value);
/*******************************************************************************
**
** Function BTA_DmBleEnableBatchScan
**
** Description This function is called to enable the batch scan
**
** Parameters scan_mode -Batch scan mode
** scan_interval - Scan interval
** scan_window - Scan window
** discard_rule -Discard rules
** addr_type - Address type
** ref_value - Reference value
**
** Returns None
**
*******************************************************************************/
extern void BTA_DmBleEnableBatchScan(tBTA_BLE_BATCH_SCAN_MODE scan_mode,
UINT32 scan_interval, UINT32 scan_window,
tBTA_BLE_DISCARD_RULE discard_rule,
tBLE_ADDR_TYPE addr_type,
tBTA_DM_BLE_REF_VALUE ref_value);
/*******************************************************************************
**
** Function BTA_DmBleReadScanReports
**
** Description This function is called to read the batch scan reports
**
** Parameters scan_mode -Batch scan mode
** ref_value - Reference value
**
** Returns None
**
*******************************************************************************/
extern void BTA_DmBleReadScanReports(tBTA_BLE_BATCH_SCAN_MODE scan_type,
tBTA_DM_BLE_REF_VALUE ref_value);
/*******************************************************************************
**
** Function BTA_DmBleDisableBatchScan
**
** Description This function is called to disable the batch scanning
**
** Parameters ref_value - Reference value
**
** Returns None
**
*******************************************************************************/
extern void BTA_DmBleDisableBatchScan(tBTA_DM_BLE_REF_VALUE ref_value);
/*******************************************************************************
**
** Function BTA_DmEnableScanFilter
**
** Description This function is called to enable the adv data payload filter
**
** Parameters action - enable or disable the APCF feature
** p_cmpl_cback - Command completed callback
** ref_value - Reference value
**
** Returns void
**
*******************************************************************************/
extern void BTA_DmEnableScanFilter(UINT8 action,
tBTA_DM_BLE_PF_STATUS_CBACK *p_cmpl_cback,
tBTA_DM_BLE_REF_VALUE ref_value);
/*******************************************************************************
**
** Function BTA_DmBleScanFilterSetup
**
** Description This function is called to setup the filter params
**
** Parameters p_target: enable the filter condition on a target device; if NULL
** filt_index - Filter index
** p_filt_params -Filter parameters
** ref_value - Reference value
** action - Add, delete or clear
** p_cmpl_back - Command completed callback
**
** Returns void
**
*******************************************************************************/
extern void BTA_DmBleScanFilterSetup(UINT8 action,
tBTA_DM_BLE_PF_FILT_INDEX filt_index,
tBTA_DM_BLE_PF_FILT_PARAMS *p_filt_params,
tBLE_BD_ADDR *p_target,
tBTA_DM_BLE_PF_PARAM_CBACK *p_cmpl_cback,
tBTA_DM_BLE_REF_VALUE ref_value);
/*******************************************************************************
**
** Function BTA_DmBleCfgFilterCondition
**
** Description This function is called to configure the adv data payload filter
** condition.
**
** Parameters action: to read/write/clear
** cond_type: filter condition type
** filt_index - Filter index
** p_cond: filter condition parameter
** p_cmpl_back - Command completed callback
** ref_value - Reference value
**
** Returns void
**
*******************************************************************************/
extern void BTA_DmBleCfgFilterCondition(tBTA_DM_BLE_SCAN_COND_OP action,
tBTA_DM_BLE_PF_COND_TYPE cond_type,
tBTA_DM_BLE_PF_FILT_INDEX filt_index,
tBTA_DM_BLE_PF_COND_PARAM *p_cond,
tBTA_DM_BLE_PF_CFG_CBACK *p_cmpl_cback,
tBTA_DM_BLE_REF_VALUE ref_value);
#if (BLE_HOST_TRACK_ADVERTISER_EN == TRUE)
/*******************************************************************************
**
** Function BTA_DmBleTrackAdvertiser
**
** Description This function is called to track the advertiser
**
** Parameters ref_value - Reference value
** p_track_adv_cback - ADV callback
**
** Returns None
**
*******************************************************************************/
extern void BTA_DmBleTrackAdvertiser(tBTA_DM_BLE_REF_VALUE ref_value,
tBTA_BLE_TRACK_ADV_CBACK *p_track_adv_cback);
#endif // #if (BLE_HOST_TRACK_ADVERTISER_EN == TRUE)
#if (BLE_HOST_ENERGY_INFO_EN == TRUE)
/*******************************************************************************
**
** Function BTA_DmBleGetEnergyInfo
**
** Description This function is called to obtain the energy info
**
** Parameters p_cmpl_cback - Command complete callback
**
** Returns void
**
*******************************************************************************/
extern void BTA_DmBleGetEnergyInfo(tBTA_BLE_ENERGY_INFO_CBACK *p_cmpl_cback);
#endif // #if (BLE_HOST_ENERGY_INFO_EN == TRUE)
/*******************************************************************************
**
** Function BTA_BrcmInit
@@ -3415,17 +3028,6 @@ extern void BTA_DmBleGetEnergyInfo(tBTA_BLE_ENERGY_INFO_CBACK *p_cmpl_cback);
*******************************************************************************/
extern void BTA_VendorInit (void);
/*******************************************************************************
**
** Function BTA_BrcmCleanup
**
** Description This function frees up Broadcom specific VS specific dynamic memory
**
** Returns void
**
*******************************************************************************/
extern void BTA_VendorCleanup (void);
#if (BLE_50_FEATURE_SUPPORT == TRUE)
extern void BTA_DmBleGapReadPHY(BD_ADDR addr);
@@ -44,7 +44,7 @@ typedef void (tBTA_SYS_DISABLE)(void);
/* HW modules */
enum {
BTA_SYS_HW_BLUETOOTH,
BTA_SYS_HW_RT,
// BTA_SYS_HW_RT,
BTA_SYS_MAX_HW_MODULES
};
@@ -28,6 +28,8 @@
#include "bta_sys_int.h"
#include "bta/utl.h"
#if (CLASSIC_BT_INCLUDED == TRUE)
/*******************************************************************************
**
** Function bta_sys_rm_register
@@ -661,3 +663,5 @@ BOOLEAN bta_sys_vs_hdl(UINT16 evt, void *p)
return FALSE;
}
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
@@ -543,7 +543,7 @@ void bta_sys_deregister(UINT8 id)
**
** Function bta_sys_is_register
**
** Description Called by other BTA subsystems to get registeration
** Description Called by other BTA subsystems to get registration
** status.
**
**
@@ -724,7 +724,7 @@ void bta_sys_disable(tBTA_SYS_HW_MODULE module)
bta_id_max = BTA_ID_BLUETOOTH_MAX;
break;
default:
APPL_TRACE_WARNING("bta_sys_disable: unkown module");
APPL_TRACE_WARNING("bta_sys_disable: unknown module");
return;
}
@@ -750,7 +750,7 @@ void bta_sys_set_trace_level(UINT8 level)
{
appl_trace_level = level;
}
#if (CLASSIC_BT_INCLUDED == TRUE)
/*******************************************************************************
**
** Function bta_sys_get_sys_features
@@ -764,3 +764,4 @@ UINT16 bta_sys_get_sys_features (void)
{
return bta_sys_cb.sys_features;
}
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
@@ -56,8 +56,8 @@ typedef struct {
tBTA_SYS_HW_STATE state;
tBTA_SYS_HW_CBACK *sys_hw_cback[BTA_SYS_MAX_HW_MODULES]; /* enable callback for each HW modules */
UINT32 sys_hw_module_active; /* bitmask of all active modules */
#if (CLASSIC_BT_INCLUDED == TRUE)
UINT16 sys_features; /* Bitmask of sys features */
tBTA_SYS_CONN_CBACK *prm_cb; /* role management callback registered by DM */
tBTA_SYS_CONN_CBACK *ppm_cb; /* low power management callback registered by DM */
tBTA_SYS_CONN_CBACK *p_policy_cb; /* link policy change callback registered by DM */
@@ -72,6 +72,7 @@ typedef struct {
#endif
/* VS event handler */
tBTA_SYS_VS_EVT_HDLR *p_vs_evt_hdlr;
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
} tBTA_SYS_CB;
@@ -79,9 +79,9 @@ static void btc_deinit_bluetooth(void)
#if (GATTC_INCLUDED)
bta_gattc_deinit();
#endif /* #if (GATTC_INCLUDED) */
#if (GATTS_INCLUDED)
#if (GATTS_INCLUDED == TRUE)
bta_gatts_deinit();
#endif /* #if (GATTS_INCLUDED) */
#endif /* #if (GATTS_INCLUDED == TRUE) */
bte_main_shutdown();
#if (SMP_INCLUDED)
btc_config_clean_up();
@@ -168,6 +168,7 @@ uint32_t btc_get_ble_status(void)
status |= BIT(BTC_BLE_STATUS_CONN);
}
#if ((SMP_INCLUDED == TRUE) || (BLE_PRIVACY_SPT == TRUE))
// Address resolve status
extern uint8_t btm_get_ble_addr_resolve_disable_status(void);
uint8_t addr_resolve_disable = btm_get_ble_addr_resolve_disable_status();
@@ -175,6 +176,7 @@ uint32_t btc_get_ble_status(void)
BTC_TRACE_WARNING("%s address resolve disabled", __func__);
status |= BIT(BTC_BLE_STATUS_ADDR_RESOLVE_DISABLE);
}
#endif // #if ((SMP_INCLUDED == TRUE) || (BLE_PRIVACY_SPT == TRUE))
#if (SMP_INCLUDED == TRUE)
// Number of recorded devices
@@ -470,35 +470,6 @@ static void btc_stop_adv_callback(uint8_t status)
}
#endif // #if (BLE_42_ADV_EN == TRUE)
void btc_update_duplicate_exceptional_list_callback(tBTA_STATUS status, uint8_t subcode, uint32_t length, uint8_t *device_info)
{
esp_ble_gap_cb_param_t param;
bt_status_t ret;
btc_msg_t msg = {0};
msg.sig = BTC_SIG_API_CB;
msg.pid = BTC_PID_GAP_BLE;
msg.act = ESP_GAP_BLE_UPDATE_DUPLICATE_EXCEPTIONAL_LIST_COMPLETE_EVT;
param.update_duplicate_exceptional_list_cmpl.status = status;
param.update_duplicate_exceptional_list_cmpl.subcode = subcode;
if(length > sizeof(param.update_duplicate_exceptional_list_cmpl.device_info)) {
length = sizeof(param.update_duplicate_exceptional_list_cmpl.device_info);
}
param.update_duplicate_exceptional_list_cmpl.length = length;
memcpy(param.update_duplicate_exceptional_list_cmpl.device_info, device_info, length);
ret = btc_transfer_context(&msg, &param, sizeof(esp_ble_gap_cb_param_t), NULL, NULL);
if (ret != BT_STATUS_SUCCESS) {
BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__);
}
}
static void btc_ble_update_duplicate_exceptional_list(uint8_t subcode, uint32_t info_type, BD_ADDR device_info,
tBTA_UPDATE_DUPLICATE_EXCEPTIONAL_LIST_CMPL_CBACK p_update_duplicate_ignore_list_cback)
{
BTA_DmUpdateDuplicateExceptionalList(subcode, info_type, device_info, p_update_duplicate_ignore_list_cback);
}
#if (BLE_42_ADV_EN == TRUE)
static void btc_ble_start_advertising (esp_ble_adv_params_t *ble_adv_params, tBTA_START_ADV_CMPL_CBACK start_adv_cback)
{
@@ -735,6 +706,38 @@ static void btc_stop_scan_callback(tBTA_STATUS status)
}
#endif // #if (BLE_42_SCAN_EN == TRUE)
#endif // #if (BLE_42_FEATURE_SUPPORT == TRUE)
#if ((BLE_42_SCAN_EN == TRUE) || (BLE_50_EXTEND_SCAN_EN == TRUE))
void btc_update_duplicate_exceptional_list_callback(tBTA_STATUS status, uint8_t subcode, uint32_t length, uint8_t *device_info)
{
esp_ble_gap_cb_param_t param;
bt_status_t ret;
btc_msg_t msg = {0};
msg.sig = BTC_SIG_API_CB;
msg.pid = BTC_PID_GAP_BLE;
msg.act = ESP_GAP_BLE_UPDATE_DUPLICATE_EXCEPTIONAL_LIST_COMPLETE_EVT;
param.update_duplicate_exceptional_list_cmpl.status = status;
param.update_duplicate_exceptional_list_cmpl.subcode = subcode;
if(length > sizeof(param.update_duplicate_exceptional_list_cmpl.device_info)) {
length = sizeof(param.update_duplicate_exceptional_list_cmpl.device_info);
}
param.update_duplicate_exceptional_list_cmpl.length = length;
memcpy(param.update_duplicate_exceptional_list_cmpl.device_info, device_info, length);
ret = btc_transfer_context(&msg, &param, sizeof(esp_ble_gap_cb_param_t), NULL, NULL);
if (ret != BT_STATUS_SUCCESS) {
BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__);
}
}
static void btc_ble_update_duplicate_exceptional_list(uint8_t subcode, uint32_t info_type, BD_ADDR device_info,
tBTA_UPDATE_DUPLICATE_EXCEPTIONAL_LIST_CMPL_CBACK p_update_duplicate_ignore_list_cback)
{
BTA_DmUpdateDuplicateExceptionalList(subcode, info_type, device_info, p_update_duplicate_ignore_list_cback);
}
#endif // ((BLE_42_SCAN_EN == TRUE) || (BLE_50_EXTEND_SCAN_EN == TRUE))
void btc_update_conn_param_callback (UINT8 status, BD_ADDR bd_addr, tBTM_LE_UPDATE_CONN_PRAMS *update_conn_params)
{
esp_ble_gap_cb_param_t param;
@@ -1801,7 +1804,7 @@ static void btc_ble_stop_advertising(tBTA_START_STOP_ADV_CMPL_CBACK *stop_adv_cb
{
bool stop_adv = false;
BTA_DmBleBroadcast(stop_adv, stop_adv_cb);
BTA_DmBleAdvStop(stop_adv, stop_adv_cb);
}
#endif // #if (BLE_42_ADV_EN == TRUE)
@@ -2695,13 +2698,17 @@ void btc_gap_ble_call_handler(btc_msg_t *msg)
btc_scan_rsp_data_raw_callback);
break;
#endif // #if (BLE_42_ADV_EN == TRUE)
#endif // #if (BLE_42_FEATURE_SUPPORT == TRUE)
#if ((BLE_42_SCAN_EN == TRUE) || (BLE_50_EXTEND_SCAN_EN == TRUE))
case BTC_GAP_BLE_UPDATE_DUPLICATE_SCAN_EXCEPTIONAL_LIST:
btc_ble_update_duplicate_exceptional_list(arg->update_duplicate_exceptional_list.subcode,
arg->update_duplicate_exceptional_list.info_type,
arg->update_duplicate_exceptional_list.device_info,
btc_update_duplicate_exceptional_list_callback);
break;
#endif // #if (BLE_42_FEATURE_SUPPORT == TRUE)
#endif // ((BLE_42_SCAN_EN == TRUE) || (BLE_50_EXTEND_SCAN_EN == TRUE))
#if (SMP_INCLUDED == TRUE)
case BTC_GAP_BLE_SET_ENCRYPTION_EVT: {
BD_ADDR bd_addr;
@@ -231,13 +231,15 @@ typedef union {
esp_bd_addr_t remote_bda;
esp_ble_wl_addr_type_t wl_addr_type;
} update_white_list;
#if (BLE_42_FEATURE_SUPPORT == TRUE)
#if ((BLE_42_SCAN_EN == TRUE) || (BLE_50_EXTEND_SCAN_EN == TRUE))
//BTC_GAP_BLE_UPDATE_DUPLICATE_SCAN_EXCEPTIONAL_LIST
struct update_duplicate_exceptional_list_args {
uint8_t subcode;
uint32_t info_type;
esp_duplicate_info_t device_info;
} update_duplicate_exceptional_list;
#endif // ((BLE_42_SCAN_EN == TRUE) || (BLE_50_EXTEND_SCAN_EN == TRUE))
#if (BLE_42_FEATURE_SUPPORT == TRUE)
//BTC_GAP_BLE_ACT_SET_CONN_PARAMS
struct set_conn_params_args {
esp_bd_addr_t bd_addr;
@@ -428,13 +428,13 @@
#define CONTROLLER_RPA_LIST_ENABLE FALSE
#endif
#if (UC_BT_GATTS_ENABLE)
#if (UC_BT_GATTS_ENABLE == TRUE)
#define GATTS_INCLUDED TRUE
#else
#define GATTS_INCLUDED FALSE
#endif /* UC_BT_GATTS_ENABLE */
#if (UC_BT_GATTC_ENABLE)
#if (UC_BT_GATTC_ENABLE == TRUE)
#define GATTC_INCLUDED TRUE
#else
#define GATTC_INCLUDED FALSE
@@ -809,11 +809,6 @@
#define BT_CLASSIC_BQB_INCLUDED FALSE
#endif
/* This feature is used to enable interleaved scan*/
#ifndef BTA_HOST_INTERLEAVE_SEARCH
#define BTA_HOST_INTERLEAVE_SEARCH FALSE
#endif
#ifndef BT_USE_TRACES
#define BT_USE_TRACES FALSE
#endif
@@ -1570,71 +1565,6 @@
#define BLE_INCLUDED FALSE
#endif
#ifndef BLE_ANDROID_CONTROLLER_SCAN_FILTER
#define BLE_ANDROID_CONTROLLER_SCAN_FILTER FALSE
#endif
#ifndef BLE_HOST_BLE_MULTI_ADV_EN
#define BLE_HOST_BLE_MULTI_ADV_EN FALSE
#endif
#ifndef BLE_HOST_TRACK_ADVERTISER_EN
#define BLE_HOST_TRACK_ADVERTISER_EN FALSE
#endif
#ifndef BLE_HOST_ENERGY_INFO_EN
#define BLE_HOST_ENERGY_INFO_EN FALSE
#endif
#ifndef BLE_HOST_ENABLE_TEST_MODE_EN
#define BLE_HOST_ENABLE_TEST_MODE_EN FALSE
#endif
#ifndef BLE_HOST_EXECUTE_CBACK_EN
#define BLE_HOST_EXECUTE_CBACK_EN FALSE
#endif
#ifndef BLE_HOST_REMOVE_ALL_ACL_EN
#define BLE_HOST_REMOVE_ALL_ACL_EN FALSE
#endif
#ifndef BLE_HOST_REMOVE_AN_ACL_EN
#define BLE_HOST_REMOVE_AN_ACL_EN FALSE
#endif
#ifndef BLE_HOST_READ_TX_POWER_EN
#define BLE_HOST_READ_TX_POWER_EN FALSE
#endif
#ifndef BLE_HOST_STOP_ADV_UNUSED
#define BLE_HOST_STOP_ADV_UNUSED FALSE
#endif
#ifndef BLE_HOST_BLE_OBSERVE_EN
#define BLE_HOST_BLE_OBSERVE_EN FALSE
#endif
#ifndef BLE_HOST_BLE_SCAN_PARAM_UNUSED
#define BLE_HOST_BLE_SCAN_PARAM_UNUSED FALSE
#endif
#ifndef BLE_HOST_CONN_SCAN_PARAM_EN
#define BLE_HOST_CONN_SCAN_PARAM_EN FALSE
#endif
#ifndef BLE_HOST_SETUP_STORAGE_EN
#define BLE_HOST_SETUP_STORAGE_EN FALSE
#endif
#ifndef BLE_HOST_READ_SCAN_REPORTS_EN
#define BLE_HOST_READ_SCAN_REPORTS_EN FALSE
#endif
#ifndef BLE_HOST_BATCH_SCAN_EN
#define BLE_HOST_BATCH_SCAN_EN FALSE
#endif
#ifndef BLE_HOST_BG_CONNECT_EN
#define BLE_HOST_BG_CONNECT_EN FALSE
#endif
@@ -1658,14 +1588,6 @@
#define BLE_LOCAL_PRIVACY_ENABLED TRUE
#endif
/*
* Toggles support for vendor specific extensions such as RPA offloading,
* feature discovery, multi-adv etc.
*/
#ifndef BLE_VND_INCLUDED
#define BLE_VND_INCLUDED FALSE
#endif
#ifndef BTM_BLE_ADV_TX_POWER
#ifdef CONFIG_IDF_TARGET_ESP32
#define BTM_BLE_ADV_TX_POWER {-12, -9, -6, -3, 0, 3, 6, 9}
@@ -1690,11 +1612,6 @@
#endif
#endif
#ifndef BLE_BATCH_SCAN_INCLUDED
#define BLE_BATCH_SCAN_INCLUDED TRUE
#endif
/******************************************************************************
**
** ATT/GATT Protocol/Profile Settings
@@ -254,14 +254,18 @@ void BTE_DeinitStack(void)
bta_ag_cb_ptr = NULL;
}
#endif
#if (CLASSIC_BT_INCLUDED == TRUE)
if (bta_dm_conn_srvcs_ptr){
osi_free(bta_dm_conn_srvcs_ptr);
bta_dm_conn_srvcs_ptr = NULL;
}
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
#if (CLASSIC_BT_INCLUDED == TRUE)
if (bta_dm_di_cb_ptr){
osi_free(bta_dm_di_cb_ptr);
bta_dm_di_cb_ptr = NULL;
}
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
if (bta_dm_search_cb_ptr){
osi_free(bta_dm_search_cb_ptr);
bta_dm_search_cb_ptr = NULL;
@@ -428,17 +432,25 @@ bt_status_t BTE_InitStack(void)
if ((bta_dm_search_cb_ptr = (tBTA_DM_SEARCH_CB *)osi_malloc(sizeof(tBTA_DM_SEARCH_CB))) == NULL) {
goto error_exit;
}
#if (CLASSIC_BT_INCLUDED == TRUE)
if ((bta_dm_di_cb_ptr = (tBTA_DM_DI_CB *)osi_malloc(sizeof(tBTA_DM_DI_CB))) == NULL) {
goto error_exit;
}
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
#if (CLASSIC_BT_INCLUDED == TRUE)
if ((bta_dm_conn_srvcs_ptr = (tBTA_DM_CONNECTED_SRVCS *)osi_malloc(sizeof(tBTA_DM_CONNECTED_SRVCS))) == NULL) {
goto error_exit;
}
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
memset((void *)bta_sys_cb_ptr, 0, sizeof(tBTA_SYS_CB));
memset((void *)bta_dm_cb_ptr, 0, sizeof(tBTA_DM_CB));
memset((void *)bta_dm_search_cb_ptr, 0, sizeof(tBTA_DM_SEARCH_CB));
#if (CLASSIC_BT_INCLUDED == TRUE)
memset((void *)bta_dm_di_cb_ptr, 0, sizeof(tBTA_DM_DI_CB));
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
#if (CLASSIC_BT_INCLUDED == TRUE)
memset((void *)bta_dm_conn_srvcs_ptr, 0, sizeof(tBTA_DM_CONNECTED_SRVCS));
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
//memset((void *)bta_prm_cb_ptr, 0, sizeof(tBTA_PRM_CB));
#if (defined BTA_HF_INCLUDED && BTA_HF_INCLUDED == TRUE)
@@ -105,9 +105,6 @@ int bte_main_boot_entry(bluedroid_init_done_cb_t cb)
******************************************************************************/
void bte_main_shutdown(void)
{
#if (BLE_INCLUDED == TRUE)
BTA_VendorCleanup();
#endif
#if (BT_BLE_DYNAMIC_ENV_MEMORY == TRUE)
free_controller_param();
+50 -170
View File
@@ -75,7 +75,9 @@ void btm_acl_init (void)
btm_cb.p_bl_changed_cb = NULL;
#endif
btm_cb.p_acl_db_list = list_new(osi_free_func);
#if (CLASSIC_BT_INCLUDED == TRUE)
btm_cb.p_pm_mode_db_list = list_new(osi_free_func);
#endif// #if (CLASSIC_BT_INCLUDED == TRUE)
/* Initialize nonzero defaults */
btm_cb.btm_def_link_super_tout = HCI_DEFAULT_INACT_TOUT;
@@ -257,7 +259,9 @@ void btm_acl_created (BD_ADDR bda, DEV_CLASS dc, UINT8 bdn[BTM_MAX_REM_BD_NAME_L
#endif
BTM_TRACE_DEBUG ("Duplicate btm_acl_created: RemBdAddr: %02x%02x%02x%02x%02x%02x\n",
bda[0], bda[1], bda[2], bda[3], bda[4], bda[5]);
#if (CLASSIC_BT_INCLUDED == TRUE)
BTM_SetLinkPolicy(p->remote_addr, &btm_cb.btm_def_link_policy);
#endif // (CLASSIC_BT_INCLUDED == TRUE)
return;
}
@@ -292,12 +296,16 @@ void btm_acl_created (BD_ADDR bda, DEV_CLASS dc, UINT8 bdn[BTM_MAX_REM_BD_NAME_L
p->conn_addr[0], p->conn_addr[1], p->conn_addr[2], p->conn_addr[3], p->conn_addr[4], p->conn_addr[5]);
#endif
#endif
#if (CLASSIC_BT_INCLUDED == TRUE)
p->switch_role_state = BTM_ACL_SWKEY_STATE_IDLE;
p->p_pm_mode_db = btm_pm_sm_alloc();
#if BTM_PM_DEBUG == TRUE
BTM_TRACE_DEBUG( "btm_pm_sm_alloc handle:%d st:%d", hci_handle, p->p_pm_mode_db->state);
#endif // BTM_PM_DEBUG
#endif // (CLASSIC_BT_INCLUDED == TRUE)
#if (CLASSIC_BT_INCLUDED == TRUE)
btm_sec_update_legacy_auth_state(p, BTM_ACL_LEGACY_AUTH_NONE);
@@ -384,7 +392,7 @@ void btm_acl_created (BD_ADDR bda, DEV_CLASS dc, UINT8 bdn[BTM_MAX_REM_BD_NAME_L
}
}
#if (CLASSIC_BT_INCLUDED == TRUE)
/*******************************************************************************
**
** Function btm_acl_report_role_change
@@ -408,6 +416,7 @@ void btm_acl_report_role_change (UINT8 hci_status, BD_ADDR bda)
btm_cb.devcb.p_switch_role_cb = NULL;
}
}
#endif // (CLASSIC_BT_INCLUDED == TRUE)
/*******************************************************************************
**
@@ -432,8 +441,10 @@ void btm_acl_removed (BD_ADDR bda, tBT_TRANSPORT transport)
if (p != (tACL_CONN *)NULL) {
p->in_use = FALSE;
#if (CLASSIC_BT_INCLUDED == TRUE)
/* if the disconnected channel has a pending role switch, clear it now */
btm_acl_report_role_change(HCI_ERR_NO_CONNECTION, bda);
#endif // (CLASSIC_BT_INCLUDED == TRUE)
/* Only notify if link up has had a chance to be issued */
if (p->link_up_issued) {
@@ -484,8 +495,9 @@ void btm_acl_removed (BD_ADDR bda, tBT_TRANSPORT transport)
}
#endif
#if (CLASSIC_BT_INCLUDED == TRUE)
list_remove(btm_cb.p_pm_mode_db_list, p->p_pm_mode_db);
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
/* Clear the ACL connection data */
memset(p, 0, sizeof(tACL_CONN));
if (list_remove(btm_cb.p_acl_db_list, p)) {
@@ -532,7 +544,9 @@ void btm_acl_device_down (void)
void btm_acl_update_busy_level (tBTM_BLI_EVENT event)
{
UINT8 busy_level_flags = 0;
#if (CLASSIC_BT_INCLUDED == TRUE)
BOOLEAN old_inquiry_state = btm_cb.is_inquiry;
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
BTM_TRACE_DEBUG ("btm_acl_update_busy_level\n");
@@ -543,6 +557,7 @@ void btm_acl_update_busy_level (tBTM_BLI_EVENT event)
case BTM_BLI_ACL_DOWN_EVT:
BTM_TRACE_DEBUG ("BTM_BLI_ACL_DOWN_EVT\n");
break;
#if (CLASSIC_BT_INCLUDED == TRUE)
case BTM_BLI_PAGE_EVT:
BTM_TRACE_DEBUG ("BTM_BLI_PAGE_EVT\n");
btm_cb.is_paging = TRUE;
@@ -568,16 +583,24 @@ void btm_acl_update_busy_level (tBTM_BLI_EVENT event)
btm_cb.is_inquiry = FALSE;
busy_level_flags = BTM_BL_INQUIRY_COMPLETE;
break;
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
}
UINT8 busy_level;
#if (CLASSIC_BT_INCLUDED == TRUE)
if (btm_cb.is_paging || btm_cb.is_inquiry) {
busy_level = 10;
} else {
} else
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
{
busy_level = BTM_GetNumAclLinks();
}
if ((busy_level != btm_cb.busy_level) || (old_inquiry_state != btm_cb.is_inquiry)) {
if ((busy_level != btm_cb.busy_level)
#if (CLASSIC_BT_INCLUDED == TRUE)
|| (old_inquiry_state != btm_cb.is_inquiry)
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
) {
tBTM_BL_UPDATE_DATA evt = {
.event = BTM_BL_UPDATE_EVT,
.busy_level = busy_level,
@@ -635,7 +658,7 @@ tBTM_STATUS BTM_GetRole (BD_ADDR remote_bd_addr, UINT8 *p_role)
return (BTM_SUCCESS);
}
#if (CLASSIC_BT_INCLUDED == TRUE)
/*******************************************************************************
**
** Function BTM_SwitchRole
@@ -854,6 +877,8 @@ void btm_acl_encrypt_change (UINT16 handle, UINT8 status, UINT8 encr_enable)
#endif
}
}
#endif // (CLASSIC_BT_INCLUDED == TRUE)
#if (CLASSIC_BT_INCLUDED == TRUE)
/*******************************************************************************
**
** Function BTM_SetLinkPolicy
@@ -937,7 +962,7 @@ void BTM_SetDefaultLinkPolicy (UINT16 settings)
/* Set the default Link Policy of the controller */
btsnd_hcic_write_def_policy_set(settings);
}
#endif // (CLASSIC_BT_INCLUDED == TRUE)
/*******************************************************************************
**
** Function btm_read_remote_version_complete
@@ -1243,6 +1268,7 @@ void btm_establish_continue (tACL_CONN *p_acl_cb)
tBTM_BL_EVENT_DATA evt_data;
BTM_TRACE_DEBUG ("btm_establish_continue\n");
#if (!defined(BTM_BYPASS_EXTRA_ACL_SETUP) || BTM_BYPASS_EXTRA_ACL_SETUP == FALSE)
#if (CLASSIC_BT_INCLUDED == TRUE)
#if (defined BLE_INCLUDED && BLE_INCLUDED == TRUE)
if (p_acl_cb->transport == BT_TRANSPORT_BR_EDR)
#endif
@@ -1256,6 +1282,7 @@ void btm_establish_continue (tACL_CONN *p_acl_cb)
BTM_SetLinkPolicy (p_acl_cb->remote_addr, &btm_cb.btm_def_link_policy);
}
}
#endif // (CLASSIC_BT_INCLUDED == TRUE)
#endif
p_acl_cb->link_up_issued = TRUE;
@@ -1461,6 +1488,7 @@ void btm_process_clk_off_comp_evt (UINT16 hci_handle, UINT16 clock_offset)
}
#if (CLASSIC_BT_INCLUDED == TRUE)
/*******************************************************************************
**
** Function btm_acl_role_changed
@@ -1560,6 +1588,7 @@ void btm_acl_role_changed (UINT8 hci_status, BD_ADDR bd_addr, UINT8 new_role)
#endif
}
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
/*******************************************************************************
**
@@ -1880,6 +1909,7 @@ tBTM_STATUS BTM_RegAclLinkStatNotif(tBTM_ACL_LINK_STAT_CB *p_cb)
return BTM_SUCCESS;
}
#if (CLASSIC_BT_INCLUDED == TRUE)
/*******************************************************************************
**
** Function BTM_SetQoS
@@ -1961,7 +1991,7 @@ void btm_qos_setup_complete (UINT8 status, UINT16 handle, FLOW_SPEC *p_flow)
(*p_cb)(&qossu);
}
}
#endif // (CLASSIC_BT_INCLUDED == TRUE)
/*******************************************************************************
**
** Function btm_qos_setup_timeout
@@ -1976,7 +2006,9 @@ void btm_qos_setup_timeout (void *p_tle)
{
BTM_TRACE_DEBUG ("%s\n", __func__);
#if (CLASSIC_BT_INCLUDED == TRUE)
btm_qos_setup_complete (HCI_ERR_HOST_TIMEOUT, 0, NULL);
#endif // (CLASSIC_BT_INCLUDED == TRUE)
}
/*******************************************************************************
@@ -2027,6 +2059,7 @@ tBTM_STATUS BTM_ReadRSSI (BD_ADDR remote_bda, tBT_TRANSPORT transport, tBTM_CMPL
return (BTM_UNKNOWN_ADDR);
}
#if (CLASSIC_BT_INCLUDED == TRUE)
/*******************************************************************************
**
** Function BTM_ReadLinkQuality
@@ -2070,65 +2103,6 @@ tBTM_STATUS BTM_ReadLinkQuality (BD_ADDR remote_bda, tBTM_CMPL_CB *p_cb)
return (BTM_UNKNOWN_ADDR);
}
#if (BLE_HOST_READ_TX_POWER_EN == TRUE)
/*******************************************************************************
**
** Function BTM_ReadTxPower
**
** Description This function is called to read the current
** TX power of the connection. The tx power level results
** are returned in the callback.
** (tBTM_RSSI_RESULTS)
**
** Returns BTM_CMD_STARTED if successfully initiated or error code
**
*******************************************************************************/
tBTM_STATUS BTM_ReadTxPower (BD_ADDR remote_bda, tBT_TRANSPORT transport, tBTM_CMPL_CB *p_cb)
{
tACL_CONN *p;
BOOLEAN ret;
#define BTM_READ_RSSI_TYPE_CUR 0x00
#define BTM_READ_RSSI_TYPE_MAX 0X01
BTM_TRACE_API ("BTM_ReadTxPower: RemBdAddr: %02x%02x%02x%02x%02x%02x\n",
remote_bda[0], remote_bda[1], remote_bda[2],
remote_bda[3], remote_bda[4], remote_bda[5]);
/* If someone already waiting on the version, do not allow another */
if (btm_cb.devcb.p_tx_power_cmpl_cb) {
return (BTM_BUSY);
}
p = btm_bda_to_acl(remote_bda, transport);
if (p != (tACL_CONN *)NULL) {
btu_start_timer (&btm_cb.devcb.tx_power_timer, BTU_TTYPE_BTM_ACL,
BTM_DEV_REPLY_TIMEOUT);
btm_cb.devcb.p_tx_power_cmpl_cb = p_cb;
#if BLE_INCLUDED == TRUE
if (p->transport == BT_TRANSPORT_LE) {
memcpy(btm_cb.devcb.read_tx_pwr_addr, remote_bda, BD_ADDR_LEN);
ret = btsnd_hcic_ble_read_adv_chnl_tx_power();
} else
#endif
{
ret = btsnd_hcic_read_tx_power (p->hci_handle, BTM_READ_RSSI_TYPE_CUR);
}
if (!ret) {
btm_cb.devcb.p_tx_power_cmpl_cb = NULL;
btu_stop_timer (&btm_cb.devcb.tx_power_timer);
return (BTM_NO_RESOURCES);
} else {
return (BTM_CMD_STARTED);
}
}
/* If here, no BD Addr found */
return (BTM_UNKNOWN_ADDR);
}
#endif // #if (BLE_HOST_READ_TX_POWER_EN == TRUE)
tBTM_STATUS BTM_SetAclPktTypes(BD_ADDR remote_bda, UINT16 pkt_types, tBTM_CMPL_CB *p_cb)
{
#if CLASSIC_BT_INCLUDED == TRUE
@@ -2169,7 +2143,6 @@ tBTM_STATUS BTM_SetAclPktTypes(BD_ADDR remote_bda, UINT16 pkt_types, tBTM_CMPL_C
void btm_acl_pkt_types_changed(UINT8 status, UINT16 handle, UINT16 pkt_types)
{
#if CLASSIC_BT_INCLUDED == TRUE
BTM_TRACE_DEBUG ("btm_acl_pkt_types_changed\n");
tACL_CONN *conn = NULL;
tBTM_SET_ACL_PKT_TYPES_RESULTS results;
@@ -2190,8 +2163,8 @@ void btm_acl_pkt_types_changed(UINT8 status, UINT16 handle, UINT16 pkt_types)
}
btm_cb.devcb.p_set_acl_pkt_types_cmpl_cb = NULL;
}
#endif
}
#endif // (CLASSIC_BT_INCLUDED == TRUE)
#if (BLE_INCLUDED == TRUE)
@@ -2242,35 +2215,6 @@ tBTM_STATUS BTM_ReadChannelMap(BD_ADDR remote_bda, tBTM_CMPL_CB *p_cb)
return BTM_UNKNOWN_ADDR;
}
#if (BLE_HOST_READ_TX_POWER_EN == TRUE)
tBTM_STATUS BTM_BleReadAdvTxPower(tBTM_CMPL_CB *p_cb)
{
BOOLEAN ret;
tBTM_TX_POWER_RESULTS result;
/* If someone already waiting on the version, do not allow another */
if (btm_cb.devcb.p_tx_power_cmpl_cb) {
result.status = BTM_BUSY;
(*p_cb)(&result);
return (BTM_BUSY);
}
btm_cb.devcb.p_tx_power_cmpl_cb = p_cb;
btu_start_timer (&btm_cb.devcb.tx_power_timer, BTU_TTYPE_BTM_ACL,
BTM_DEV_REPLY_TIMEOUT);
ret = btsnd_hcic_ble_read_adv_chnl_tx_power();
if(!ret) {
btm_cb.devcb.p_tx_power_cmpl_cb = NULL;
btu_stop_timer (&btm_cb.devcb.tx_power_timer);
result.status = BTM_NO_RESOURCES;
(*p_cb)(&result);
return (BTM_NO_RESOURCES);
} else {
return BTM_CMD_STARTED;
}
}
#endif // #if (BLE_HOST_READ_TX_POWER_EN == TRUE)
void BTM_BleGetWhiteListSize(uint16_t *length)
{
tBTM_BLE_CB *p_cb = &btm_cb.ble_ctr_cb;
@@ -2294,79 +2238,7 @@ void BTM_BleGetPeriodicAdvListSize(uint8_t *size)
#endif ///BLE_INCLUDED == TRUE
#if (BLE_HOST_READ_TX_POWER_EN == TRUE)
/*******************************************************************************
**
** Function btm_read_tx_power_complete
**
** Description This function is called when the command complete message
** is received from the HCI for the read tx power request.
**
** Returns void
**
*******************************************************************************/
void btm_read_tx_power_complete (UINT8 *p, UINT16 evt_len, BOOLEAN is_ble)
{
tBTM_CMPL_CB *p_cb = btm_cb.devcb.p_tx_power_cmpl_cb;
tBTM_TX_POWER_RESULTS results;
UINT16 handle;
tACL_CONN *p_acl_cb = NULL;
BTM_TRACE_DEBUG ("btm_read_tx_power_complete\n");
btu_stop_timer (&btm_cb.devcb.tx_power_timer);
/* If there was a callback registered for read rssi, call it */
btm_cb.devcb.p_tx_power_cmpl_cb = NULL;
if (p_cb) {
if (evt_len < 1) {
BTM_TRACE_ERROR("Bogus event packet, too short\n");
results.status = BTM_ERR_PROCESSING;
goto err_out;
}
STREAM_TO_UINT8 (results.hci_status, p);
if (results.hci_status == HCI_SUCCESS) {
results.status = BTM_SUCCESS;
if (!is_ble) {
if (evt_len < 1 + 3) {
BTM_TRACE_ERROR("Bogus event packet, too short\n");
results.status = BTM_ERR_PROCESSING;
goto err_out;
}
STREAM_TO_UINT16 (handle, p);
STREAM_TO_UINT8 (results.tx_power, p);
/* Search through the list of active channels for the correct BD Addr */
p_acl_cb = btm_handle_to_acl(handle);
if (p_acl_cb) {
memcpy (results.rem_bda, p_acl_cb->remote_addr, BD_ADDR_LEN);
}
}
#if BLE_INCLUDED == TRUE
else {
if (evt_len < 1 + 1) {
BTM_TRACE_ERROR("Bogus event packet, too short\n");
results.status = BTM_ERR_PROCESSING;
goto err_out;
}
STREAM_TO_UINT8 (results.tx_power, p);
memcpy(results.rem_bda, btm_cb.devcb.read_tx_pwr_addr, BD_ADDR_LEN);
}
#endif
BTM_TRACE_DEBUG ("BTM TX power Complete: tx_power %d, hci status 0x%02x\n",
results.tx_power, results.hci_status);
} else {
results.status = BTM_ERR_PROCESSING;
}
err_out:
(*p_cb)(&results);
}
}
#endif // #if (BLE_HOST_READ_TX_POWER_EN == TRUE)
/*******************************************************************************
**
** Function btm_read_channel_map_complete
@@ -2421,7 +2293,7 @@ void btm_read_channel_map_complete(UINT8 *p)
(*p_cb)(&results);
}
}
#endif // #if BLE_INCLUDED == TRUE
/*******************************************************************************
**
@@ -2481,6 +2353,7 @@ err_out:
}
}
#if (CLASSIC_BT_INCLUDED == TRUE)
/*******************************************************************************
**
** Function btm_read_link_quality_complete
@@ -2527,6 +2400,7 @@ void btm_read_link_quality_complete (UINT8 *p)
(*p_cb)(&results);
}
}
#endif // (CLASSIC_BT_INCLUDED == TRUE)
/*******************************************************************************
**
@@ -2585,6 +2459,7 @@ UINT8 BTM_SetTraceLevel (UINT8 new_level)
return (btm_cb.trace_level);
}
#if (CLASSIC_BT_INCLUDED == TRUE)
/*******************************************************************************
**
** Function btm_cont_rswitch
@@ -2639,7 +2514,9 @@ void btm_cont_rswitch (tACL_CONN *p, tBTM_SEC_DEV_REC *p_dev_rec,
}
}
}
#endif // (CLASSIC_BT_INCLUDED == TRUE)
#if (CLASSIC_BT_INCLUDED == TRUE)
/*******************************************************************************
**
** Function btm_acl_resubmit_page
@@ -2693,6 +2570,7 @@ void btm_acl_reset_paging (void)
btm_cb.paging = FALSE;
}
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
/*******************************************************************************
**
@@ -2830,7 +2708,9 @@ void btm_acl_chk_peer_pkt_type_support (tACL_CONN *p, UINT16 *p_pkt_type)
void btm_acl_free(void)
{
list_free(btm_cb.p_acl_db_list);
#if (CLASSIC_BT_INCLUDED == TRUE)
list_free(btm_cb.p_pm_mode_db_list);
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
}
/*******************************************************************************
@@ -549,48 +549,6 @@ void BTM_BleSecureConnectionCreateOobData(void)
#endif
}
#if (BLE_HOST_CONN_SCAN_PARAM_EN == TRUE)
/******************************************************************************
**
** Function BTM_BleSetConnScanParams
**
** Description Set scan parameter used in BLE connection request
**
** Parameters: scan_interval: scan interval
** scan_window: scan window
**
** Returns void
**
*******************************************************************************/
void BTM_BleSetConnScanParams (UINT32 scan_interval, UINT32 scan_window)
{
#if SMP_INCLUDED == TRUE
tBTM_BLE_CB *p_ble_cb = &btm_cb.ble_ctr_cb;
BOOLEAN new_param = FALSE;
if (BTM_BLE_ISVALID_PARAM(scan_interval, BTM_BLE_SCAN_INT_MIN, BTM_BLE_SCAN_INT_MAX) &&
BTM_BLE_ISVALID_PARAM(scan_window, BTM_BLE_SCAN_WIN_MIN, BTM_BLE_SCAN_WIN_MAX)) {
if (p_ble_cb->scan_int != scan_interval) {
p_ble_cb->scan_int = scan_interval;
new_param = TRUE;
}
if (p_ble_cb->scan_win != scan_window) {
p_ble_cb->scan_win = scan_window;
new_param = TRUE;
}
#if (tGATT_BG_CONN_DEV == TRUE)
if (new_param && p_ble_cb->conn_state == BLE_BG_CONN) {
btm_ble_suspend_bg_conn();
}
#endif // #if (tGATT_BG_CONN_DEV == TRUE)
} else {
BTM_TRACE_ERROR("Illegal Connection Scan Parameters");
}
#endif
}
#endif // #if (BLE_HOST_CONN_SCAN_PARAM_EN == TRUE)
/********************************************************
**
** Function BTM_BleSetPrefConnParams
File diff suppressed because it is too large Load Diff
@@ -29,949 +29,6 @@
#include "stack/hcimsgs.h"
#if (BLE_INCLUDED == TRUE)
#if (BLE_HOST_BATCH_SCAN_EN == TRUE)
#if BTM_DYNAMIC_MEMORY == FALSE
tBTM_BLE_BATCH_SCAN_CB ble_batchscan_cb;
#if (BLE_HOST_TRACK_ADVERTISER_EN == TRUE)
tBTM_BLE_ADV_TRACK_CB ble_advtrack_cb;
#endif // #if (BLE_HOST_TRACK_ADVERTISER_EN == TRUE)
#else
tBTM_BLE_BATCH_SCAN_CB *ble_batchscan_cb_ptr;
#if (BLE_HOST_TRACK_ADVERTISER_EN == TRUE)
tBTM_BLE_ADV_TRACK_CB *ble_advtrack_cb_ptr;
#endif // #if (BLE_HOST_TRACK_ADVERTISER_EN == TRUE)
#define ble_batchscan_cb (*ble_batchscan_cb_ptr)
#if (BLE_HOST_TRACK_ADVERTISER_EN == TRUE)
#define ble_advtrack_cb (*ble_advtrack_cb_ptr)
#endif // #if (BLE_HOST_TRACK_ADVERTISER_EN == TRUE)
#endif
/* length of each batch scan command */
#define BTM_BLE_BATCH_SCAN_STORAGE_CFG_LEN 4
#define BTM_BLE_BATCH_SCAN_PARAM_CONFIG_LEN 12
#define BTM_BLE_BATCH_SCAN_ENB_DISB_LEN 2
#define BTM_BLE_BATCH_SCAN_READ_RESULTS_LEN 2
#define BTM_BLE_BATCH_SCAN_CB_EVT_MASK 0xF0
#define BTM_BLE_BATCH_SCAN_SUBCODE_MASK 0x0F
/*******************************************************************************
** Local functions
*******************************************************************************/
void btm_ble_batchscan_vsc_cmpl_cback (tBTM_VSC_CMPL *p_params);
void btm_ble_batchscan_cleanup(void);
/*******************************************************************************
**
** Function btm_ble_batchscan_filter_track_adv_vse_cback
**
** Description VSE callback for batch scan, filter, and tracking events.
**
** Returns None
**
*******************************************************************************/
void btm_ble_batchscan_filter_track_adv_vse_cback(UINT8 len, UINT8 *p)
{
#if (BLE_HOST_TRACK_ADVERTISER_EN == TRUE)
tBTM_BLE_TRACK_ADV_DATA adv_data;
tBTM_BLE_VSC_CB cmn_ble_vsc_cb;
#endif // #if (BLE_HOST_TRACK_ADVERTISER_EN == TRUE)
UINT8 sub_event = 0;
STREAM_TO_UINT8(sub_event, p);
BTM_TRACE_EVENT("btm_ble_batchscan_filter_track_adv_vse_cback called with event:%x", sub_event);
if (HCI_VSE_SUBCODE_BLE_THRESHOLD_SUB_EVT == sub_event &&
NULL != ble_batchscan_cb.p_thres_cback) {
ble_batchscan_cb.p_thres_cback(ble_batchscan_cb.ref_value);
return;
}
#if (BLE_HOST_TRACK_ADVERTISER_EN == TRUE)
if (HCI_VSE_SUBCODE_BLE_TRACKING_SUB_EVT == sub_event && NULL != ble_advtrack_cb.p_track_cback) {
if (len < 10) {
return;
}
memset(&adv_data, 0 , sizeof(tBTM_BLE_TRACK_ADV_DATA));
BTM_BleGetVendorCapabilities(&cmn_ble_vsc_cb);
adv_data.client_if = (UINT8)ble_advtrack_cb.ref_value;
if (cmn_ble_vsc_cb.version_supported > BTM_VSC_CHIP_CAPABILITY_L_VERSION) {
STREAM_TO_UINT8(adv_data.filt_index, p);
STREAM_TO_UINT8(adv_data.advertiser_state, p);
STREAM_TO_UINT8(adv_data.advertiser_info_present, p);
STREAM_TO_BDADDR(adv_data.bd_addr.address, p);
STREAM_TO_UINT8(adv_data.addr_type, p);
/* Extract the adv info details */
if (ADV_INFO_PRESENT == adv_data.advertiser_info_present) {
STREAM_TO_UINT8(adv_data.tx_power, p);
STREAM_TO_UINT8(adv_data.rssi_value, p);
STREAM_TO_UINT16(adv_data.time_stamp, p);
STREAM_TO_UINT8(adv_data.adv_pkt_len, p);
if (adv_data.adv_pkt_len > 0) {
adv_data.p_adv_pkt_data = osi_malloc(adv_data.adv_pkt_len);
memcpy(adv_data.p_adv_pkt_data, p, adv_data.adv_pkt_len);
}
STREAM_TO_UINT8(adv_data.scan_rsp_len, p);
if (adv_data.scan_rsp_len > 0) {
adv_data.p_scan_rsp_data = osi_malloc(adv_data.scan_rsp_len);
memcpy(adv_data.p_scan_rsp_data, p, adv_data.scan_rsp_len);
}
}
} else {
/* Based on L-release version */
STREAM_TO_UINT8(adv_data.filt_index, p);
STREAM_TO_UINT8(adv_data.addr_type, p);
STREAM_TO_BDADDR(adv_data.bd_addr.address, p);
STREAM_TO_UINT8(adv_data.advertiser_state, p);
}
BTM_TRACE_EVENT("track_adv_vse_cback called: %d, %d, %d", adv_data.filt_index,
adv_data.addr_type, adv_data.advertiser_state);
ble_advtrack_cb.p_track_cback(&adv_data);
return;
}
#endif // #if (BLE_HOST_TRACK_ADVERTISER_EN == TRUE)
}
/*******************************************************************************
**
** Function btm_ble_batchscan_enq_op_q
**
** Description enqueue a batchscan operation in q to check command complete
** status
**
** Returns void
**
*******************************************************************************/
void btm_ble_batchscan_enq_op_q(UINT8 opcode, tBTM_BLE_BATCH_SCAN_STATE cur_state,
UINT8 cb_evt, tBTM_BLE_REF_VALUE ref_value)
{
ble_batchscan_cb.op_q.sub_code[ble_batchscan_cb.op_q.next_idx] = (opcode | (cb_evt << 4));
ble_batchscan_cb.op_q.cur_state[ble_batchscan_cb.op_q.next_idx] = cur_state;
ble_batchscan_cb.op_q.ref_value[ble_batchscan_cb.op_q.next_idx] = ref_value;
BTM_TRACE_DEBUG("btm_ble_batchscan_enq_op_q: subcode:%d, Cur_state:%d, ref_value:%d",
ble_batchscan_cb.op_q.sub_code[ble_batchscan_cb.op_q.next_idx],
ble_batchscan_cb.op_q.cur_state[ble_batchscan_cb.op_q.next_idx],
ble_batchscan_cb.op_q.ref_value[ble_batchscan_cb.op_q.next_idx]);
ble_batchscan_cb.op_q.next_idx = (ble_batchscan_cb.op_q.next_idx + 1)
% BTM_BLE_BATCH_SCAN_MAX;
}
/*******************************************************************************
**
** Function btm_ble_batchscan_enq_rep_q
**
** Description enqueue a batchscan report operation in q to check command complete
** status
**
** Returns void
**
*******************************************************************************/
tBTM_STATUS btm_ble_batchscan_enq_rep_q(UINT8 report_format, tBTM_BLE_REF_VALUE ref_value)
{
int i = 0;
for (i = 0; i < BTM_BLE_BATCH_REP_MAIN_Q_SIZE; i++) {
if (report_format == ble_batchscan_cb.main_rep_q.rep_mode[i]) {
return BTM_ILLEGAL_VALUE;
}
}
ble_batchscan_cb.main_rep_q.rep_mode[ble_batchscan_cb.main_rep_q.next_idx] = report_format;
ble_batchscan_cb.main_rep_q.ref_value[ble_batchscan_cb.main_rep_q.next_idx] = ref_value;
ble_batchscan_cb.main_rep_q.num_records[ble_batchscan_cb.main_rep_q.next_idx] = 0;
ble_batchscan_cb.main_rep_q.data_len[ble_batchscan_cb.main_rep_q.next_idx] = 0;
ble_batchscan_cb.main_rep_q.p_data[ble_batchscan_cb.main_rep_q.next_idx] = NULL;
BTM_TRACE_DEBUG("btm_ble_batchscan_enq_rep_q: index:%d, rep %d, ref %d",
ble_batchscan_cb.main_rep_q.next_idx, report_format, ref_value);
ble_batchscan_cb.main_rep_q.next_idx = (ble_batchscan_cb.main_rep_q.next_idx + 1)
% BTM_BLE_BATCH_REP_MAIN_Q_SIZE;
return BTM_SUCCESS;
}
/*******************************************************************************
**
** Function btm_ble_batchscan_enq_rep_data
**
** Description setup the data in the main report queue
**
** Returns void
**
*******************************************************************************/
void btm_ble_batchscan_enq_rep_data(UINT8 report_format, UINT8 num_records, UINT8 *p_data,
UINT8 data_len)
{
int index = 0, len = 0;
UINT8 *p_orig_data = NULL, *p_app_data = NULL;
for (index = 0; index < BTM_BLE_BATCH_REP_MAIN_Q_SIZE; index++) {
if (report_format == ble_batchscan_cb.main_rep_q.rep_mode[index]) {
break;
}
}
BTM_TRACE_DEBUG("btm_ble_batchscan_enq_rep_data: index:%d, rep %d, num %d len : %d",
index, report_format, num_records, data_len);
if (index < BTM_BLE_BATCH_REP_MAIN_Q_SIZE && data_len > 0 && num_records > 0) {
len = ble_batchscan_cb.main_rep_q.data_len[index];
p_orig_data = ble_batchscan_cb.main_rep_q.p_data[index];
if (NULL != p_orig_data) {
p_app_data = osi_malloc(len + data_len);
memcpy(p_app_data, p_orig_data, len);
memcpy(p_app_data + len, p_data, data_len);
osi_free(p_orig_data);
ble_batchscan_cb.main_rep_q.p_data[index] = p_app_data;
ble_batchscan_cb.main_rep_q.num_records[index] += num_records;
ble_batchscan_cb.main_rep_q.data_len[index] += data_len;
} else {
p_app_data = osi_malloc(data_len);
memcpy(p_app_data, p_data, data_len);
ble_batchscan_cb.main_rep_q.p_data[index] = p_app_data;
ble_batchscan_cb.main_rep_q.num_records[index] = num_records;
ble_batchscan_cb.main_rep_q.data_len[index] = data_len;
}
}
}
/*******************************************************************************
**
** Function btm_ble_batchscan_deq_rep_q
**
** Description dequeue a batchscan report in q when command complete
** is received
**
** Returns void
**
*******************************************************************************/
void btm_ble_batchscan_deq_rep_data(UINT8 report_format, tBTM_BLE_REF_VALUE *p_ref_value,
UINT8 *p_num_records, UINT8 **p_data, UINT16 *p_data_len)
{
int index = 0;
for (index = 0; index < BTM_BLE_BATCH_REP_MAIN_Q_SIZE; index++) {
if (report_format == ble_batchscan_cb.main_rep_q.rep_mode[index]) {
break;
}
}
if (BTM_BLE_BATCH_REP_MAIN_Q_SIZE == index) {
BTM_TRACE_ERROR("btm_ble_batchscan_deq_rep_data: rep_format:%d not found", report_format);
return;
}
*p_num_records = ble_batchscan_cb.main_rep_q.num_records[index];
*p_ref_value = ble_batchscan_cb.main_rep_q.ref_value[index];
*p_data = ble_batchscan_cb.main_rep_q.p_data[index];
*p_data_len = ble_batchscan_cb.main_rep_q.data_len[index];
ble_batchscan_cb.main_rep_q.p_data[index] = NULL;
ble_batchscan_cb.main_rep_q.data_len[index] = 0;
ble_batchscan_cb.main_rep_q.rep_mode[index] = 0;
ble_batchscan_cb.main_rep_q.ref_value[index] = 0;
ble_batchscan_cb.main_rep_q.num_records[index] = 0;
BTM_TRACE_DEBUG("btm_ble_batchscan_deq_rep_data: index:%d, rep %d, num %d, data_len %d",
index, report_format, *p_num_records, *p_data_len);
ble_batchscan_cb.main_rep_q.pending_idx = (ble_batchscan_cb.main_rep_q.pending_idx + 1)
% BTM_BLE_BATCH_SCAN_MAX;
}
/*******************************************************************************
**
** Function btm_ble_batchscan_deq_op_q
**
** Description dequeue a batch scan operation from q when command complete
** is received
**
** Returns void
**
*******************************************************************************/
void btm_ble_batchscan_deq_op_q(UINT8 *p_opcode, tBTM_BLE_BATCH_SCAN_STATE *cur_state,
UINT8 *p_cb_evt, tBTM_BLE_REF_VALUE *p_ref)
{
*p_cb_evt = (ble_batchscan_cb.op_q.sub_code[ble_batchscan_cb.op_q.pending_idx] >> 4);
*p_opcode = (ble_batchscan_cb.op_q.sub_code[ble_batchscan_cb.op_q.pending_idx]
& BTM_BLE_BATCH_SCAN_SUBCODE_MASK);
*p_ref = ble_batchscan_cb.op_q.ref_value[ble_batchscan_cb.op_q.pending_idx];
*cur_state = (ble_batchscan_cb.op_q.cur_state[ble_batchscan_cb.op_q.pending_idx]);
ble_batchscan_cb.op_q.pending_idx = (ble_batchscan_cb.op_q.pending_idx + 1)
% BTM_BLE_BATCH_SCAN_MAX;
}
/*******************************************************************************
**
** Function btm_ble_read_batchscan_reports
**
** Description This function reads the reports from controller
**
** Parameters scan_mode - The mode for which the reports are to be read out from the controller
** ref_value - Reference value
**
** Returns status
**
*******************************************************************************/
tBTM_STATUS btm_ble_read_batchscan_reports(tBTM_BLE_BATCH_SCAN_MODE scan_mode,
tBTM_BLE_REF_VALUE ref_value)
{
tBTM_STATUS status = BTM_NO_RESOURCES;
UINT8 param[BTM_BLE_BATCH_SCAN_READ_RESULTS_LEN], *pp;
pp = param;
memset(param, 0, BTM_BLE_BATCH_SCAN_READ_RESULTS_LEN);
UINT8_TO_STREAM (pp, BTM_BLE_BATCH_SCAN_READ_RESULTS);
UINT8_TO_STREAM (pp, scan_mode);
if ((status = BTM_VendorSpecificCommand (HCI_BLE_BATCH_SCAN_OCF,
BTM_BLE_BATCH_SCAN_READ_RESULTS_LEN, param, btm_ble_batchscan_vsc_cmpl_cback))
!= BTM_CMD_STARTED) {
BTM_TRACE_ERROR("btm_ble_read_batchscan_reports %d", status);
return BTM_ILLEGAL_VALUE;
}
if (BTM_CMD_STARTED == status) {
/* The user needs to be provided scan read reports event */
btm_ble_batchscan_enq_op_q(BTM_BLE_BATCH_SCAN_READ_RESULTS, ble_batchscan_cb.cur_state,
BTM_BLE_BATCH_SCAN_READ_REPTS_EVT, ref_value);
}
return status;
}
/*******************************************************************************
**
** Function btm_ble_batchscan_vsc_cmpl_cback
**
** Description Batch scan VSC complete callback
**
** Parameters p_params - VSC completed callback parameters
**
** Returns void
**
*******************************************************************************/
void btm_ble_batchscan_vsc_cmpl_cback (tBTM_VSC_CMPL *p_params)
{
UINT8 *p = p_params->p_param_buf;
UINT16 len = p_params->param_len;
tBTM_BLE_REF_VALUE ref_value = 0;
UINT8 status = 0, subcode = 0, opcode = 0;
UINT8 report_format = 0, num_records = 0, cb_evt = 0;
UINT16 data_len = 0;
tBTM_BLE_BATCH_SCAN_STATE cur_state = 0;
tBTM_STATUS btm_status = 0;
UINT8 *p_data = NULL;
if (len < 2) {
BTM_TRACE_ERROR("wrong length for btm_ble_batch_scan_vsc_cmpl_cback");
btm_ble_batchscan_deq_op_q(&opcode, &cur_state, &cb_evt, &ref_value);
return;
}
STREAM_TO_UINT8(status, p);
STREAM_TO_UINT8(subcode, p);
btm_ble_batchscan_deq_op_q(&opcode, &cur_state, &cb_evt, &ref_value);
BTM_TRACE_DEBUG("btm_ble_batchscan op_code = %02x state = %02x cb_evt = %02x,ref_value=%d",
opcode, cur_state, cb_evt, ref_value);
if (opcode != subcode) {
BTM_TRACE_ERROR("Got unexpected VSC cmpl, expected: %d got: %d", subcode, opcode);
return;
}
switch (subcode) {
case BTM_BLE_BATCH_SCAN_ENB_DISAB_CUST_FEATURE: {
if (BTM_SUCCESS == status && BTM_BLE_SCAN_ENABLE_CALLED == cur_state) {
ble_batchscan_cb.cur_state = BTM_BLE_SCAN_ENABLED_STATE;
} else if (BTM_BLE_SCAN_ENABLE_CALLED == cur_state) {
BTM_TRACE_ERROR("SCAN_ENB_DISAB_CUST_FEATURE - Invalid state after enb");
ble_batchscan_cb.cur_state = BTM_BLE_SCAN_INVALID_STATE;
}
BTM_TRACE_DEBUG("BTM_BLE_BATCH_SCAN_ENB_DISAB_CUST_FEAT status = %d, state: %d,evt=%d",
status, ble_batchscan_cb.cur_state, cb_evt);
if (cb_evt != 0 && NULL != ble_batchscan_cb.p_setup_cback) {
ble_batchscan_cb.p_setup_cback(cb_evt, ref_value, status);
}
break;
}
case BTM_BLE_BATCH_SCAN_SET_STORAGE_PARAM: {
BTM_TRACE_DEBUG("BTM_BLE_BATCH_SCAN_SET_STORAGE_PARAM status = %d, evt=%d",
status, cb_evt);
if (cb_evt != 0 && NULL != ble_batchscan_cb.p_setup_cback) {
ble_batchscan_cb.p_setup_cback(cb_evt, ref_value, status);
}
break;
}
case BTM_BLE_BATCH_SCAN_SET_PARAMS: {
BTM_TRACE_DEBUG("BTM_BLE_BATCH_SCAN_SET_PARAMS status = %d,evt=%d", status, cb_evt);
if (BTM_BLE_SCAN_DISABLE_CALLED == cur_state) {
if (BTM_SUCCESS == status) {
ble_batchscan_cb.cur_state = BTM_BLE_SCAN_DISABLED_STATE;
} else {
BTM_TRACE_ERROR("BTM_BLE_BATCH_SCAN_SET_PARAMS - Invalid state after disabled");
ble_batchscan_cb.cur_state = BTM_BLE_SCAN_INVALID_STATE;
}
}
if (cb_evt != 0 && NULL != ble_batchscan_cb.p_setup_cback) {
ble_batchscan_cb.p_setup_cback(cb_evt, ref_value, status);
}
break;
}
case BTM_BLE_BATCH_SCAN_READ_RESULTS: {
if (cb_evt != 0 && NULL != ble_batchscan_cb.p_scan_rep_cback) {
STREAM_TO_UINT8(report_format, p);
STREAM_TO_UINT8(num_records, p);
p = (uint8_t *)(p_params->p_param_buf + 4);
BTM_TRACE_DEBUG("BTM_BLE_BATCH_SCAN_READ_RESULTS status=%d,len=%d,rec=%d",
status, len - 4, num_records);
if (0 == num_records) {
btm_ble_batchscan_deq_rep_data(report_format, &ref_value, &num_records,
&p_data, &data_len);
if (NULL != ble_batchscan_cb.p_scan_rep_cback) {
ble_batchscan_cb.p_scan_rep_cback(ref_value, report_format, num_records,
data_len, p_data, status);
}
} else {
if ((len - 4) > 0) {
btm_ble_batchscan_enq_rep_data(report_format, num_records, p, len - 4);
/* More records could be in the buffer and needs to be pulled out */
btm_status = btm_ble_read_batchscan_reports(report_format, ref_value);
if (BTM_CMD_STARTED != btm_status) {
btm_ble_batchscan_deq_rep_data(report_format, &ref_value, &num_records,
&p_data, &data_len);
/* Send whatever is available, in case of a command failure */
if (NULL != ble_batchscan_cb.p_scan_rep_cback && NULL != p_data) {
ble_batchscan_cb.p_scan_rep_cback(ref_value, report_format,
num_records, data_len, p_data, status);
}
}
}
}
}
break;
}
default:
break;
}
return;
}
/*******************************************************************************
**
** Function btm_ble_set_storage_config
**
** Description This function writes the storage configuration in controller
**
** Parameters batch_scan_full_max -Max storage space (in %) allocated to full scanning
** batch_scan_trunc_max -Max storage space (in %) allocated to truncated scanning
** batch_scan_notify_threshold - Setup notification level based on total space
**
** Returns status
**
*******************************************************************************/
tBTM_STATUS btm_ble_set_storage_config(UINT8 batch_scan_full_max, UINT8 batch_scan_trunc_max,
UINT8 batch_scan_notify_threshold)
{
tBTM_STATUS status = BTM_NO_RESOURCES;
UINT8 param[BTM_BLE_BATCH_SCAN_STORAGE_CFG_LEN], *pp;
pp = param;
memset(param, 0, BTM_BLE_BATCH_SCAN_STORAGE_CFG_LEN);
UINT8_TO_STREAM (pp, BTM_BLE_BATCH_SCAN_SET_STORAGE_PARAM);
UINT8_TO_STREAM (pp, batch_scan_full_max);
UINT8_TO_STREAM (pp, batch_scan_trunc_max);
UINT8_TO_STREAM (pp, batch_scan_notify_threshold);
if ((status = BTM_VendorSpecificCommand (HCI_BLE_BATCH_SCAN_OCF,
BTM_BLE_BATCH_SCAN_STORAGE_CFG_LEN, param,
btm_ble_batchscan_vsc_cmpl_cback)) != BTM_CMD_STARTED) {
BTM_TRACE_ERROR("btm_ble_set_storage_config %d", status);
return BTM_ILLEGAL_VALUE;
}
return status;
}
/*******************************************************************************
**
** Function btm_ble_set_batchscan_param
**
** Description This function writes the batch scan params in controller
**
** Parameters scan_mode -Batch scan mode
** scan_interval - Scan interval
** scan_window - Scan window
** discard_rule -Discard rules
** addr_type - Address type
**
** Returns status
**
*******************************************************************************/
tBTM_STATUS btm_ble_set_batchscan_param(tBTM_BLE_BATCH_SCAN_MODE scan_mode,
UINT32 scan_interval, UINT32 scan_window, tBLE_ADDR_TYPE addr_type,
tBTM_BLE_DISCARD_RULE discard_rule)
{
tBTM_STATUS status = BTM_NO_RESOURCES;
UINT8 scan_param[BTM_BLE_BATCH_SCAN_PARAM_CONFIG_LEN], *pp_scan;
pp_scan = scan_param;
memset(scan_param, 0, BTM_BLE_BATCH_SCAN_PARAM_CONFIG_LEN);
// Override param and decide addr_type based on own addr type
// TODO: Remove upper layer parameter?
addr_type = btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type;
UINT8_TO_STREAM (pp_scan, BTM_BLE_BATCH_SCAN_SET_PARAMS);
UINT8_TO_STREAM (pp_scan, scan_mode);
UINT32_TO_STREAM (pp_scan, scan_window);
UINT32_TO_STREAM (pp_scan, scan_interval);
UINT8_TO_STREAM (pp_scan, addr_type);
UINT8_TO_STREAM (pp_scan, discard_rule);
if ((status = BTM_VendorSpecificCommand (HCI_BLE_BATCH_SCAN_OCF,
BTM_BLE_BATCH_SCAN_PARAM_CONFIG_LEN,
scan_param, btm_ble_batchscan_vsc_cmpl_cback)) != BTM_CMD_STARTED) {
BTM_TRACE_ERROR("btm_ble_set_batchscan_param %d", status);
return BTM_ILLEGAL_VALUE;
}
return status;
}
/*******************************************************************************
**
** Function btm_ble_enable_disable_batchscan
**
** Description This function enables the customer specific feature in controller
**
** Parameters enable_disable: true - enable, false - disable
**
** Returns status
**
*******************************************************************************/
tBTM_STATUS btm_ble_enable_disable_batchscan(BOOLEAN should_enable)
{
tBTM_STATUS status = BTM_NO_RESOURCES;
UINT8 shld_enable = 0x01;
UINT8 enable_param[BTM_BLE_BATCH_SCAN_ENB_DISB_LEN], *pp_enable;
if (!should_enable) {
shld_enable = 0x00;
}
if (should_enable) {
pp_enable = enable_param;
memset(enable_param, 0, BTM_BLE_BATCH_SCAN_ENB_DISB_LEN);
UINT8_TO_STREAM (pp_enable, BTM_BLE_BATCH_SCAN_ENB_DISAB_CUST_FEATURE);
UINT8_TO_STREAM (pp_enable, shld_enable);
if ((status = BTM_VendorSpecificCommand(HCI_BLE_BATCH_SCAN_OCF,
BTM_BLE_BATCH_SCAN_ENB_DISB_LEN, enable_param,
btm_ble_batchscan_vsc_cmpl_cback)) != BTM_CMD_STARTED) {
status = BTM_MODE_UNSUPPORTED;
BTM_TRACE_ERROR("btm_ble_enable_disable_batchscan %d", status);
return BTM_ILLEGAL_VALUE;
}
} else if ((status = btm_ble_set_batchscan_param(BTM_BLE_BATCH_SCAN_MODE_DISABLE,
ble_batchscan_cb.scan_interval, ble_batchscan_cb.scan_window,
ble_batchscan_cb.addr_type, ble_batchscan_cb.discard_rule)) != BTM_CMD_STARTED) {
status = BTM_MODE_UNSUPPORTED;
BTM_TRACE_ERROR("btm_ble_enable_disable_batchscan %d", status);
return BTM_ILLEGAL_VALUE;
}
if (should_enable) {
ble_batchscan_cb.cur_state = BTM_BLE_SCAN_ENABLE_CALLED;
} else {
ble_batchscan_cb.cur_state = BTM_BLE_SCAN_DISABLE_CALLED;
}
return status;
}
#if (BLE_HOST_SETUP_STORAGE_EN == TRUE)
/*******************************************************************************
**
** Function BTM_BleSetStorageConfig
**
** Description This function is called to write storage config params.
**
** Parameters: batch_scan_full_max - Max storage space (in %) allocated to full style
** batch_scan_trunc_max - Max storage space (in %) allocated to trunc style
** batch_scan_notify_threshold - Setup notification level based on total space
** p_setup_cback - Setup callback pointer
** p_thres_cback - Threshold callback pointer
** p_rep_cback - Reports callback pointer
** ref_value - Reference value
**
** Returns tBTM_STATUS
**
*******************************************************************************/
tBTM_STATUS BTM_BleSetStorageConfig(UINT8 batch_scan_full_max, UINT8 batch_scan_trunc_max,
UINT8 batch_scan_notify_threshold,
tBTM_BLE_SCAN_SETUP_CBACK *p_setup_cback,
tBTM_BLE_SCAN_THRESHOLD_CBACK *p_thres_cback,
tBTM_BLE_SCAN_REP_CBACK *p_rep_cback,
tBTM_BLE_REF_VALUE ref_value)
{
tBTM_STATUS status = BTM_NO_RESOURCES;
tBTM_BLE_VSC_CB cmn_ble_vsc_cb;
BTM_TRACE_EVENT (" BTM_BleSetStorageConfig: %d, %d, %d, %d, %d",
ble_batchscan_cb.cur_state, ref_value, batch_scan_full_max, batch_scan_trunc_max,
batch_scan_notify_threshold);
if (!controller_get_interface()->supports_ble()) {
return BTM_ILLEGAL_VALUE;
}
BTM_BleGetVendorCapabilities(&cmn_ble_vsc_cb);
if (0 == cmn_ble_vsc_cb.tot_scan_results_strg) {
BTM_TRACE_ERROR("Controller does not support batch scan");
return BTM_ERR_PROCESSING;
}
ble_batchscan_cb.p_setup_cback = p_setup_cback;
ble_batchscan_cb.p_thres_cback = p_thres_cback;
ble_batchscan_cb.p_scan_rep_cback = p_rep_cback;
ble_batchscan_cb.ref_value = ref_value;
if (batch_scan_full_max > BTM_BLE_ADV_SCAN_FULL_MAX ||
batch_scan_trunc_max > BTM_BLE_ADV_SCAN_TRUNC_MAX ||
batch_scan_notify_threshold > BTM_BLE_ADV_SCAN_THR_MAX) {
BTM_TRACE_ERROR("Illegal set storage config params");
return BTM_ILLEGAL_VALUE;
}
if (BTM_BLE_SCAN_INVALID_STATE == ble_batchscan_cb.cur_state ||
BTM_BLE_SCAN_DISABLED_STATE == ble_batchscan_cb.cur_state ||
BTM_BLE_SCAN_DISABLE_CALLED == ble_batchscan_cb.cur_state) {
status = btm_ble_enable_disable_batchscan(TRUE);
if (BTM_CMD_STARTED != status) {
return status;
}
ble_batchscan_cb.cur_state = BTM_BLE_SCAN_ENABLE_CALLED;
btm_ble_batchscan_enq_op_q(BTM_BLE_BATCH_SCAN_ENB_DISAB_CUST_FEATURE,
BTM_BLE_SCAN_ENABLE_CALLED, 0, ref_value);
}
status = btm_ble_set_storage_config(batch_scan_full_max, batch_scan_trunc_max,
batch_scan_notify_threshold);
if (BTM_CMD_STARTED != status) {
return status;
}
/* The user needs to be provided scan config storage event */
btm_ble_batchscan_enq_op_q(BTM_BLE_BATCH_SCAN_SET_STORAGE_PARAM, ble_batchscan_cb.cur_state,
BTM_BLE_BATCH_SCAN_CFG_STRG_EVT, ref_value);
return status;
}
#endif // #if (BLE_HOST_SETUP_STORAGE_EN == TRUE)
/*******************************************************************************
**
** Function BTM_BleEnableBatchScan
**
** Description This function is called to configure and enable batch scanning
**
** Parameters: scan_mode -Batch scan mode
** scan_interval - Scan interval value
** scan_window - Scan window value
** discard_rule - Data discard rule
** ref_value - Reference value
**
** Returns tBTM_STATUS
**
*******************************************************************************/
tBTM_STATUS BTM_BleEnableBatchScan(tBTM_BLE_BATCH_SCAN_MODE scan_mode,
UINT32 scan_interval, UINT32 scan_window, tBLE_ADDR_TYPE addr_type,
tBTM_BLE_DISCARD_RULE discard_rule, tBTM_BLE_REF_VALUE ref_value)
{
tBTM_STATUS status = BTM_NO_RESOURCES;
tBTM_BLE_VSC_CB cmn_ble_vsc_cb;
BTM_TRACE_EVENT (" BTM_BleEnableBatchScan: %d, %d, %d, %d, %d, %d",
scan_mode, scan_interval, scan_window, addr_type, discard_rule, ref_value);
if (!controller_get_interface()->supports_ble()) {
return BTM_ILLEGAL_VALUE;
}
BTM_BleGetVendorCapabilities(&cmn_ble_vsc_cb);
if (0 == cmn_ble_vsc_cb.tot_scan_results_strg) {
BTM_TRACE_ERROR("Controller does not support batch scan");
return BTM_ERR_PROCESSING;
}
BTM_TRACE_DEBUG("BTM_BleEnableBatchScan: %d, %x, %x, %d, %d", scan_mode, scan_interval,
scan_window, discard_rule, ble_batchscan_cb.cur_state);
/* Only 16 bits will be used for scan interval and scan window as per agreement with Google */
/* So the standard LE range would suffice for scan interval and scan window */
if ((BTM_BLE_ISVALID_PARAM(scan_interval, BTM_BLE_SCAN_INT_MIN, BTM_BLE_SCAN_INT_MAX) ||
BTM_BLE_ISVALID_PARAM(scan_window, BTM_BLE_SCAN_WIN_MIN, BTM_BLE_SCAN_WIN_MAX))
&& (BTM_BLE_BATCH_SCAN_MODE_PASS == scan_mode || BTM_BLE_BATCH_SCAN_MODE_ACTI == scan_mode
|| BTM_BLE_BATCH_SCAN_MODE_PASS_ACTI == scan_mode)
&& (BTM_BLE_DISCARD_OLD_ITEMS == discard_rule ||
BTM_BLE_DISCARD_LOWER_RSSI_ITEMS == discard_rule)) {
if (BTM_BLE_SCAN_INVALID_STATE == ble_batchscan_cb.cur_state ||
BTM_BLE_SCAN_DISABLED_STATE == ble_batchscan_cb.cur_state ||
BTM_BLE_SCAN_DISABLE_CALLED == ble_batchscan_cb.cur_state) {
status = btm_ble_enable_disable_batchscan(TRUE);
if (BTM_CMD_STARTED != status) {
return status;
}
btm_ble_batchscan_enq_op_q(BTM_BLE_BATCH_SCAN_ENB_DISAB_CUST_FEATURE,
BTM_BLE_SCAN_ENABLE_CALLED, 0, ref_value);
}
ble_batchscan_cb.scan_mode = scan_mode;
ble_batchscan_cb.scan_interval = scan_interval;
ble_batchscan_cb.scan_window = scan_window;
ble_batchscan_cb.addr_type = addr_type;
ble_batchscan_cb.discard_rule = discard_rule;
/* This command starts batch scanning, if enabled */
status = btm_ble_set_batchscan_param(scan_mode, scan_interval, scan_window, addr_type,
discard_rule);
if (BTM_CMD_STARTED != status) {
return status;
}
/* The user needs to be provided scan enable event */
btm_ble_batchscan_enq_op_q(BTM_BLE_BATCH_SCAN_SET_PARAMS, ble_batchscan_cb.cur_state,
BTM_BLE_BATCH_SCAN_ENABLE_EVT, ref_value);
} else {
BTM_TRACE_ERROR("Illegal enable scan params");
return BTM_ILLEGAL_VALUE;
}
return status;
}
/*******************************************************************************
**
** Function BTM_BleDisableBatchScan
**
** Description This function is called to disable batch scanning
**
** Parameters: ref_value - Reference value
**
** Returns tBTM_STATUS
**
*******************************************************************************/
tBTM_STATUS BTM_BleDisableBatchScan(tBTM_BLE_REF_VALUE ref_value)
{
tBTM_STATUS status = BTM_NO_RESOURCES;
tBTM_BLE_VSC_CB cmn_ble_vsc_cb;
BTM_TRACE_EVENT (" BTM_BleDisableBatchScan");
if (!controller_get_interface()->supports_ble()) {
return BTM_ILLEGAL_VALUE;
}
BTM_BleGetVendorCapabilities(&cmn_ble_vsc_cb);
if (0 == cmn_ble_vsc_cb.tot_scan_results_strg) {
BTM_TRACE_ERROR("Controller does not support batch scan");
return BTM_ERR_PROCESSING;
}
status = btm_ble_enable_disable_batchscan(FALSE);
if (BTM_CMD_STARTED == status) {
/* The user needs to be provided scan disable event */
btm_ble_batchscan_enq_op_q(BTM_BLE_BATCH_SCAN_SET_PARAMS,
BTM_BLE_SCAN_DISABLE_CALLED, BTM_BLE_BATCH_SCAN_DISABLE_EVT,
ref_value);
}
return status;
}
#if (BLE_HOST_READ_SCAN_REPORTS_EN == TRUE)
/*******************************************************************************
**
** Function BTM_BleReadScanReports
**
** Description This function is called to start reading batch scan reports
**
** Parameters: scan_mode - Batch scan mode
** ref_value - Reference value
**
** Returns tBTM_STATUS
**
*******************************************************************************/
tBTM_STATUS BTM_BleReadScanReports(tBTM_BLE_BATCH_SCAN_MODE scan_mode,
tBTM_BLE_REF_VALUE ref_value)
{
tBTM_STATUS status = BTM_NO_RESOURCES;
tBTM_BLE_VSC_CB cmn_ble_vsc_cb;
UINT8 read_scan_mode = 0;
UINT8 *p_data = NULL, num_records = 0;
UINT16 data_len = 0;
BTM_TRACE_EVENT (" BTM_BleReadScanReports; %d, %d", scan_mode, ref_value);
if (!controller_get_interface()->supports_ble()) {
return BTM_ILLEGAL_VALUE;
}
BTM_BleGetVendorCapabilities(&cmn_ble_vsc_cb);
if (0 == cmn_ble_vsc_cb.tot_scan_results_strg) {
BTM_TRACE_ERROR("Controller does not support batch scan");
return BTM_ERR_PROCESSING;
}
/* Check if the requested scan mode has already been setup by the user */
read_scan_mode = ble_batchscan_cb.scan_mode & BTM_BLE_BATCH_SCAN_MODE_ACTI;
if (0 == read_scan_mode) {
read_scan_mode = ble_batchscan_cb.scan_mode & BTM_BLE_BATCH_SCAN_MODE_PASS;
}
/* Check only for modes, as scan reports can be called after disabling batch scan */
if (read_scan_mode > 0 && (BTM_BLE_BATCH_SCAN_MODE_PASS == scan_mode ||
BTM_BLE_BATCH_SCAN_MODE_ACTI == scan_mode)) {
status = btm_ble_batchscan_enq_rep_q(scan_mode, ref_value);
if (BTM_SUCCESS == status) {
status = btm_ble_read_batchscan_reports(scan_mode, ref_value);
if (BTM_CMD_STARTED != status) {
btm_ble_batchscan_deq_rep_data(scan_mode, &ref_value,
&num_records, &p_data, &data_len);
}
}
} else {
BTM_TRACE_ERROR("Illegal read scan params: %d, %d, %d", read_scan_mode, scan_mode,
ble_batchscan_cb.cur_state);
return BTM_ILLEGAL_VALUE;
}
return status;
}
#endif // #if (BLE_HOST_READ_SCAN_REPORTS_EN == TRUE)
#if (BLE_HOST_TRACK_ADVERTISER_EN == TRUE)
/*******************************************************************************
**
** Function BTM_BleTrackAdvertiser
**
** Description This function is called to setup the callback for tracking advertisers
**
** Parameters: p_track_cback - Tracking callback pointer
** ref_value - Reference value
**
** Returns tBTM_STATUS
**
*******************************************************************************/
tBTM_STATUS BTM_BleTrackAdvertiser(tBTM_BLE_TRACK_ADV_CBACK *p_track_cback,
tBTM_BLE_REF_VALUE ref_value)
{
tBTM_BLE_VSC_CB cmn_ble_vsc_cb;
BTM_TRACE_EVENT (" BTM_BleTrackAdvertiser");
if (!controller_get_interface()->supports_ble()) {
return BTM_ILLEGAL_VALUE;
}
BTM_BleGetVendorCapabilities(&cmn_ble_vsc_cb);
if (0 == cmn_ble_vsc_cb.tot_scan_results_strg) {
BTM_TRACE_ERROR("Controller does not support scan storage");
return BTM_ERR_PROCESSING;
}
ble_advtrack_cb.p_track_cback = p_track_cback;
ble_advtrack_cb.ref_value = ref_value;
return BTM_CMD_STARTED;
}
#endif // #if (BLE_HOST_TRACK_ADVERTISER_EN == TRUE)
/*******************************************************************************
**
** Function btm_ble_batchscan_init
**
** Description This function initialize the batch scan control block.
**
** Parameters None
**
** Returns status
**
*******************************************************************************/
void btm_ble_batchscan_init(void)
{
#if BTM_DYNAMIC_MEMORY == TRUE
ble_batchscan_cb_ptr = (tBTM_BLE_BATCH_SCAN_CB *)osi_malloc(sizeof(tBTM_BLE_BATCH_SCAN_CB));
#if (BLE_HOST_TRACK_ADVERTISER_EN == TRUE)
ble_advtrack_cb_ptr = (tBTM_BLE_ADV_TRACK_CB *)osi_malloc(sizeof(tBTM_BLE_ADV_TRACK_CB));
#endif // #if (BLE_HOST_TRACK_ADVERTISER_EN == TRUE)
if (ble_batchscan_cb_ptr == NULL || ble_advtrack_cb_ptr == NULL) {
BTM_TRACE_ERROR("%s malloc failed", __func__);
return;
}
#endif
BTM_TRACE_EVENT (" btm_ble_batchscan_init");
memset(&ble_batchscan_cb, 0, sizeof(tBTM_BLE_BATCH_SCAN_CB));
#if (BLE_HOST_TRACK_ADVERTISER_EN == TRUE)
memset(&ble_advtrack_cb, 0, sizeof(tBTM_BLE_ADV_TRACK_CB));
#endif // #if (BLE_HOST_TRACK_ADVERTISER_EN == TRUE)
BTM_RegisterForVSEvents(btm_ble_batchscan_filter_track_adv_vse_cback, TRUE);
}
/*******************************************************************************
**
** Function btm_ble_batchscan_cleanup
**
** Description This function cleans the batch scan control block.
**
** Parameters None
**
** Returns void
**
*******************************************************************************/
void btm_ble_batchscan_cleanup(void)
{
int index = 0;
BTM_TRACE_EVENT (" btm_ble_batchscan_cleanup");
for (index = 0; index < BTM_BLE_BATCH_REP_MAIN_Q_SIZE; index++) {
if (NULL != ble_batchscan_cb.main_rep_q.p_data[index]) {
osi_free(ble_batchscan_cb.main_rep_q.p_data[index]);
ble_batchscan_cb.main_rep_q.p_data[index] = NULL;
}
}
memset(&ble_batchscan_cb, 0, sizeof(tBTM_BLE_BATCH_SCAN_CB));
#if (BLE_HOST_TRACK_ADVERTISER_EN == TRUE)
memset(&ble_advtrack_cb, 0, sizeof(tBTM_BLE_ADV_TRACK_CB));
#endif // #if (BLE_HOST_TRACK_ADVERTISER_EN == TRUE)
#if BTM_DYNAMIC_MEMORY == TRUE
osi_free(ble_batchscan_cb_ptr);
ble_batchscan_cb_ptr = NULL;
#if (BLE_HOST_TRACK_ADVERTISER_EN == TRUE)
osi_free(ble_advtrack_cb_ptr);
ble_advtrack_cb_ptr = NULL;
#endif // #if (BLE_HOST_TRACK_ADVERTISER_EN == TRUE)
#endif
}
#endif // #if (BLE_HOST_BATCH_SCAN_EN == TRUE)
#endif
@@ -39,10 +39,11 @@
#endif
#if (BLE_INCLUDED == TRUE)
static void btm_suspend_wl_activity(tBTM_BLE_WL_STATE wl_state);
static void btm_wl_update_to_controller(void);
#if (BLE_GATT_BGCONN == TRUE)
// Unfortunately (for now?) we have to maintain a copy of the device whitelist
// on the host to determine if a device is pending to be connected or not. This
// controls whether the host should keep trying to scan for whitelisted
@@ -118,6 +119,7 @@ static bool background_connections_pending(void)
}
return pending_connections;
}
#endif // (BLE_GATT_BGCONN == TRUE)
/*******************************************************************************
**
@@ -137,16 +139,11 @@ void btm_update_scanner_filter_policy(tBTM_BLE_SFP scan_policy)
p_inq->sfp = scan_policy;
p_inq->scan_type = p_inq->scan_type == BTM_BLE_SCAN_MODE_NONE ? BTM_BLE_SCAN_MODE_ACTI : p_inq->scan_type;
if (btm_cb.cmn_ble_vsc_cb.extended_scan_support == 0) {
btsnd_hcic_ble_set_scan_params(p_inq->scan_type, (UINT16)scan_interval,
(UINT16)scan_window,
btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type,
scan_policy);
} else {
btm_ble_send_extended_scan_params(p_inq->scan_type, scan_interval, scan_window,
btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type,
scan_policy);
}
btsnd_hcic_ble_set_scan_params(p_inq->scan_type, (UINT16)scan_interval,
(UINT16)scan_window,
btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type,
scan_policy);
}
/*******************************************************************************
**
@@ -340,6 +337,7 @@ BOOLEAN btm_update_dev_to_white_list(BOOLEAN to_add, BD_ADDR bd_addr, tBLE_ADDR_
return FALSE;
}
#if (BLE_GATT_BGCONN == TRUE)
if (to_add) {
/* added the bd_addr to the connection hash map queue */
if(!background_connection_add((bt_bdaddr_t *)bd_addr)) {
@@ -359,6 +357,7 @@ BOOLEAN btm_update_dev_to_white_list(BOOLEAN to_add, BD_ADDR bd_addr, tBLE_ADDR_
return TRUE;
}
}
#endif // (BLE_GATT_BGCONN == TRUE)
if (update_wl_cb){
//save add whitelist complete callback
@@ -386,7 +385,10 @@ void btm_ble_clear_white_list (tBTM_UPDATE_WHITELIST_CBACK *update_wl_cb)
BTM_TRACE_EVENT ("btm_ble_clear_white_list");
btsnd_hcic_ble_clear_white_list();
#if (BLE_GATT_BGCONN == TRUE)
background_connections_clear();
#endif // (BLE_GATT_BGCONN == TRUE)
if (update_wl_cb) {
p_cb->update_wl_cb = update_wl_cb;
@@ -462,7 +464,15 @@ void btm_ble_add_2_white_list_complete(UINT8 status)
BTM_TRACE_EVENT("%s status=%d", __func__, status);
tBTM_BLE_CB *p_cb = &btm_cb.ble_ctr_cb;
if (status == HCI_SUCCESS) {
--btm_cb.ble_ctr_cb.white_list_avail_size;
// --btm_cb.ble_ctr_cb.white_list_avail_size;
/*
According to the latest Bluetooth spec:
If the device is already in the Filter Accept List, the Controller should not add the device
to the Filter Accept List again and should return success.
The host cannot obtain the controller as the actual remaining white list size unless the host
also maintains a white list
Keep consistent behavior with the NimBLE host stack
*/
}
// add whitelist complete callback
if (p_cb->update_wl_cb)
@@ -485,7 +495,7 @@ void btm_ble_remove_from_white_list_complete(UINT8 *p, UINT16 evt_len)
UNUSED(evt_len);
BTM_TRACE_EVENT ("%s status=%d", __func__, *p);
if (*p == HCI_SUCCESS) {
++btm_cb.ble_ctr_cb.white_list_avail_size;
// ++btm_cb.ble_ctr_cb.white_list_avail_size;
}
if (p_cb->update_wl_cb)
{
@@ -493,6 +503,7 @@ void btm_ble_remove_from_white_list_complete(UINT8 *p, UINT16 evt_len)
}
}
#if (BLE_GATT_BGCONN == TRUE)
/*******************************************************************************
**
** Function btm_ble_start_auto_conn
@@ -516,7 +527,10 @@ BOOLEAN btm_ble_start_auto_conn(BOOLEAN start)
if (start) {
if (p_cb->conn_state == BLE_CONN_IDLE && background_connections_pending()
&& btm_ble_topology_check(BTM_BLE_STATE_INIT)) {
#if (BLE_TOPOLOGY_CHECK == TRUE)
&& btm_ble_topology_check(BTM_BLE_STATE_INIT)
#endif // (BLE_TOPOLOGY_CHECK == TRUE)
) {
p_cb->wl_state |= BTM_BLE_WL_INIT;
btm_execute_wl_dev_operation();
@@ -604,29 +618,21 @@ BOOLEAN btm_ble_start_select_conn(BOOLEAN start, tBTM_BLE_SEL_CBACK *p_select_cb
btm_cb.ble_ctr_cb.inq_var.scan_type = BTM_BLE_SCAN_MODE_PASS;
/* Process advertising packets only from devices in the white list */
if (btm_cb.cmn_ble_vsc_cb.extended_scan_support == 0) {
/* use passive scan by default */
if (!btsnd_hcic_ble_set_scan_params(BTM_BLE_SCAN_MODE_PASS,
scan_int,
scan_win,
p_cb->addr_mgnt_cb.own_addr_type,
SP_ADV_WL)) {
return FALSE;
}
} else {
if (!btm_ble_send_extended_scan_params(BTM_BLE_SCAN_MODE_PASS,
scan_int,
scan_win,
p_cb->addr_mgnt_cb.own_addr_type,
SP_ADV_WL)) {
return FALSE;
}
/* use passive scan by default */
if (!btsnd_hcic_ble_set_scan_params(BTM_BLE_SCAN_MODE_PASS,
scan_int,
scan_win,
p_cb->addr_mgnt_cb.own_addr_type,
SP_ADV_WL)) {
return FALSE;
}
#if (BLE_TOPOLOGY_CHECK == TRUE)
if (!btm_ble_topology_check(BTM_BLE_STATE_PASSIVE_SCAN)) {
BTM_TRACE_ERROR("peripheral device cannot initiate passive scan for a selective connection");
return FALSE;
} else if (background_connections_pending()) {
}
#endif // (BLE_TOPOLOGY_CHECK == TRUE)
if (background_connections_pending()) {
#if BLE_PRIVACY_SPT == TRUE
btm_ble_enable_resolving_list_for_platform(BTM_BLE_RL_SCAN);
#endif
@@ -675,7 +681,9 @@ void btm_ble_initiate_select_conn(BD_ADDR bda)
BTM_TRACE_ERROR("btm_ble_initiate_select_conn failed");
}
}
#if (tGATT_BG_CONN_DEV == TRUE)
#endif // (BLE_GATT_BGCONN == TRUE)
#if (GATT_BG_CONN_DEV == TRUE)
/*******************************************************************************
**
** Function btm_ble_suspend_bg_conn
@@ -700,7 +708,7 @@ BOOLEAN btm_ble_suspend_bg_conn(void)
return FALSE;
}
#endif // #if (tGATT_BG_CONN_DEV == TRUE)
#endif // #if (GATT_BG_CONN_DEV == TRUE)
/*******************************************************************************
**
@@ -713,12 +721,15 @@ BOOLEAN btm_ble_suspend_bg_conn(void)
*******************************************************************************/
static void btm_suspend_wl_activity(tBTM_BLE_WL_STATE wl_state)
{
#if (BLE_GATT_BGCONN == TRUE)
if (wl_state & BTM_BLE_WL_INIT) {
btm_ble_start_auto_conn(FALSE);
}
if (wl_state & BTM_BLE_WL_SCAN) {
btm_ble_start_select_conn(FALSE, NULL);
}
#endif // (BLE_GATT_BGCONN == TRUE)
#if (BLE_42_ADV_EN == TRUE)
if (wl_state & BTM_BLE_WL_ADV) {
btm_ble_stop_adv();
@@ -736,9 +747,9 @@ static void btm_suspend_wl_activity(tBTM_BLE_WL_STATE wl_state)
*******************************************************************************/
void btm_resume_wl_activity(tBTM_BLE_WL_STATE wl_state)
{
#if (tGATT_BG_CONN_DEV == TRUE)
#if (GATT_BG_CONN_DEV == TRUE)
btm_ble_resume_bg_conn();
#endif // #if (tGATT_BG_CONN_DEV == TRUE)
#endif // #if (GATT_BG_CONN_DEV == TRUE)
if (wl_state & BTM_BLE_WL_ADV) {
#if (BLE_42_ADV_EN == TRUE)
btm_ble_start_adv();
@@ -765,7 +776,7 @@ static void btm_wl_update_to_controller(void)
btm_execute_wl_dev_operation();
}
#if (tGATT_BG_CONN_DEV == TRUE)
#if (GATT_BG_CONN_DEV == TRUE)
/*******************************************************************************
**
** Function btm_ble_resume_bg_conn
@@ -795,7 +806,7 @@ BOOLEAN btm_ble_resume_bg_conn(void)
return ret;
}
#endif // #if (tGATT_BG_CONN_DEV == TRUE)
#endif // #if (GATT_BG_CONN_DEV == TRUE)
/*******************************************************************************
**
@@ -824,11 +835,13 @@ void btm_ble_set_conn_st(tBTM_BLE_CONN_ST new_st)
BTM_TRACE_DEBUG("%s old=%u new=%u", __func__, btm_cb.ble_ctr_cb.conn_state, new_st);
btm_cb.ble_ctr_cb.conn_state = new_st;
#if (BLE_TOPOLOGY_CHECK == TRUE)
if (new_st == BLE_BG_CONN || new_st == BLE_DIR_CONN) {
btm_ble_set_topology_mask(BTM_BLE_STATE_INIT_BIT);
} else {
btm_ble_clear_topology_mask(BTM_BLE_STATE_INIT_BIT);
}
#endif // (BLE_TOPOLOGY_CHECK == TRUE)
}
/*******************************************************************************
@@ -20,91 +20,5 @@
#include "common/bt_target.h"
#if (BLE_INCLUDED == TRUE)
#if (BLE_HOST_ENERGY_INFO_EN == TRUE)
#include "stack/bt_types.h"
#include "stack/hcimsgs.h"
#include "stack/btu.h"
#include "btm_int.h"
//#include "bt_utils.h"
#include "stack/hcidefs.h"
#include "stack/btm_ble_api.h"
tBTM_BLE_ENERGY_INFO_CB ble_energy_info_cb;
/*******************************************************************************
**
** Function btm_ble_cont_energy_cmpl_cback
**
** Description Controller VSC complete callback
**
** Parameters
**
** Returns void
**
*******************************************************************************/
void btm_ble_cont_energy_cmpl_cback (tBTM_VSC_CMPL *p_params)
{
UINT8 *p = p_params->p_param_buf;
UINT16 len = p_params->param_len;
UINT8 status = 0;
UINT32 total_tx_time = 0, total_rx_time = 0, total_idle_time = 0, total_energy_used = 0;
if (len < 17) {
BTM_TRACE_ERROR("wrong length for btm_ble_cont_energy_cmpl_cback");
return;
}
STREAM_TO_UINT8(status, p);
STREAM_TO_UINT32(total_tx_time, p);
STREAM_TO_UINT32(total_rx_time, p);
STREAM_TO_UINT32(total_idle_time, p);
STREAM_TO_UINT32(total_energy_used, p);
BTM_TRACE_DEBUG("energy_info status=%d,tx_t=%u, rx_t=%u, ener_used=%u, idle_t=%u",
status, total_tx_time, total_rx_time, total_energy_used, total_idle_time);
if (NULL != ble_energy_info_cb.p_ener_cback) {
ble_energy_info_cb.p_ener_cback(total_tx_time, total_rx_time, total_idle_time,
total_energy_used, status);
}
return;
}
/*******************************************************************************
**
** Function BTM_BleGetEnergyInfo
**
** Description This function obtains the energy info
**
** Parameters p_ener_cback - Callback pointer
**
** Returns status
**
*******************************************************************************/
tBTM_STATUS BTM_BleGetEnergyInfo(tBTM_BLE_ENERGY_INFO_CBACK *p_ener_cback)
{
tBTM_STATUS status = BTM_ILLEGAL_VALUE;
tBTM_BLE_VSC_CB cmn_ble_vsc_cb;
BTM_BleGetVendorCapabilities(&cmn_ble_vsc_cb);
BTM_TRACE_EVENT("BTM_BleGetEnergyInfo\n");
if (0 == cmn_ble_vsc_cb.energy_support) {
BTM_TRACE_ERROR("Controller does not support get energy info\n");
return BTM_ERR_PROCESSING;
}
ble_energy_info_cb.p_ener_cback = p_ener_cback;
if ((status = BTM_VendorSpecificCommand (HCI_BLE_ENERGY_INFO_OCF, 0, NULL,
btm_ble_cont_energy_cmpl_cback)) != BTM_CMD_STARTED) {
BTM_TRACE_ERROR("BTM_BleGetEnergyInfo status: %d", status);
return BTM_ILLEGAL_VALUE;
}
return status;
}
#endif // #if (BLE_HOST_ENERGY_INFO_EN == TRUE)
#endif
File diff suppressed because it is too large Load Diff
@@ -23,848 +23,5 @@
#if (BLE_INCLUDED == TRUE)
#if (BLE_HOST_BLE_MULTI_ADV_EN == TRUE)
#include "stack/bt_types.h"
#include "stack/hcimsgs.h"
#include "stack/btu.h"
#include "btm_int.h"
//#include "bt_utils.h"
#include "stack/hcidefs.h"
#include "stack/btm_ble_api.h"
/************************************************************************************
** Constants & Macros
************************************************************************************/
/* length of each multi adv sub command */
#define BTM_BLE_MULTI_ADV_ENB_LEN 3
#define BTM_BLE_MULTI_ADV_SET_PARAM_LEN 24
#define BTM_BLE_MULTI_ADV_WRITE_DATA_LEN (BTM_BLE_AD_DATA_LEN + 3)
#define BTM_BLE_MULTI_ADV_SET_RANDOM_ADDR_LEN 8
#define BTM_BLE_MULTI_ADV_CB_EVT_MASK 0xF0
#define BTM_BLE_MULTI_ADV_SUBCODE_MASK 0x0F
/************************************************************************************
** Static variables
************************************************************************************/
#if BTM_DYNAMIC_MEMORY == FALSE
tBTM_BLE_MULTI_ADV_CB btm_multi_adv_cb;
tBTM_BLE_MULTI_ADV_INST_IDX_Q btm_multi_adv_idx_q;
#else
tBTM_BLE_MULTI_ADV_CB *btm_multi_adv_cb_ptr;
tBTM_BLE_MULTI_ADV_INST_IDX_Q *btm_multi_adv_idx_q_ptr;
#define btm_multi_adv_cb (*btm_multi_adv_cb_ptr)
#define btm_multi_adv_idx_q (*btm_multi_adv_idx_q_ptr)
#endif
/************************************************************************************
** Externs
************************************************************************************/
extern void btm_ble_update_dmt_flag_bits(UINT8 *flag_value,
const UINT16 connect_mode, const UINT16 disc_mode);
/*******************************************************************************
**
** Function btm_ble_multi_adv_enq_op_q
**
** Description enqueue a multi adv operation in q to check command complete
** status.
**
** Returns void
**
*******************************************************************************/
void btm_ble_multi_adv_enq_op_q(UINT8 opcode, UINT8 inst_id, UINT8 cb_evt)
{
tBTM_BLE_MULTI_ADV_OPQ *p_op_q = &btm_multi_adv_cb.op_q;
p_op_q->p_inst_id[p_op_q->next_idx] = inst_id;
p_op_q->p_sub_code[p_op_q->next_idx] = (opcode | (cb_evt << 4));
p_op_q->next_idx = (p_op_q->next_idx + 1) % BTM_BleMaxMultiAdvInstanceCount();
}
/*******************************************************************************
**
** Function btm_ble_multi_adv_deq_op_q
**
** Description dequeue a multi adv operation from q when command complete
** is received.
**
** Returns void
**
*******************************************************************************/
void btm_ble_multi_adv_deq_op_q(UINT8 *p_opcode, UINT8 *p_inst_id, UINT8 *p_cb_evt)
{
tBTM_BLE_MULTI_ADV_OPQ *p_op_q = &btm_multi_adv_cb.op_q;
*p_inst_id = p_op_q->p_inst_id[p_op_q->pending_idx] & 0x7F;
*p_cb_evt = (p_op_q->p_sub_code[p_op_q->pending_idx] >> 4);
*p_opcode = (p_op_q->p_sub_code[p_op_q->pending_idx] & BTM_BLE_MULTI_ADV_SUBCODE_MASK);
p_op_q->pending_idx = (p_op_q->pending_idx + 1) % BTM_BleMaxMultiAdvInstanceCount();
}
/*******************************************************************************
**
** Function btm_ble_multi_adv_vsc_cmpl_cback
**
** Description Multi adv VSC complete callback
**
** Parameters
**
** Returns void
**
*******************************************************************************/
void btm_ble_multi_adv_vsc_cmpl_cback (tBTM_VSC_CMPL *p_params)
{
UINT8 status, subcode;
UINT8 *p = p_params->p_param_buf, inst_id;
UINT16 len = p_params->param_len;
tBTM_BLE_MULTI_ADV_INST *p_inst ;
UINT8 cb_evt = 0, opcode;
if (len < 2) {
BTM_TRACE_ERROR("wrong length for btm_ble_multi_adv_vsc_cmpl_cback");
return;
}
STREAM_TO_UINT8(status, p);
STREAM_TO_UINT8(subcode, p);
btm_ble_multi_adv_deq_op_q(&opcode, &inst_id, &cb_evt);
BTM_TRACE_DEBUG("op_code = %02x inst_id = %d cb_evt = %02x", opcode, inst_id, cb_evt);
if (opcode != subcode || inst_id == 0) {
BTM_TRACE_ERROR("get unexpected VSC cmpl, expect: %d get: %d", subcode, opcode);
return;
}
p_inst = &btm_multi_adv_cb.p_adv_inst[inst_id - 1];
switch (subcode) {
case BTM_BLE_MULTI_ADV_ENB: {
BTM_TRACE_DEBUG("BTM_BLE_MULTI_ADV_ENB status = %d", status);
/* Mark as not in use here, if instance cannot be enabled */
if (HCI_SUCCESS != status && BTM_BLE_MULTI_ADV_ENB_EVT == cb_evt) {
btm_multi_adv_cb.p_adv_inst[inst_id - 1].in_use = FALSE;
}
break;
}
case BTM_BLE_MULTI_ADV_SET_PARAM: {
BTM_TRACE_DEBUG("BTM_BLE_MULTI_ADV_SET_PARAM status = %d", status);
break;
}
case BTM_BLE_MULTI_ADV_WRITE_ADV_DATA: {
BTM_TRACE_DEBUG("BTM_BLE_MULTI_ADV_WRITE_ADV_DATA status = %d", status);
break;
}
case BTM_BLE_MULTI_ADV_WRITE_SCAN_RSP_DATA: {
BTM_TRACE_DEBUG("BTM_BLE_MULTI_ADV_WRITE_SCAN_RSP_DATA status = %d", status);
break;
}
case BTM_BLE_MULTI_ADV_SET_RANDOM_ADDR: {
BTM_TRACE_DEBUG("BTM_BLE_MULTI_ADV_SET_RANDOM_ADDR status = %d", status);
break;
}
default:
break;
}
if (cb_evt != 0 && p_inst->p_cback != NULL) {
(p_inst->p_cback)(cb_evt, inst_id, p_inst->p_ref, status);
}
return;
}
/*******************************************************************************
**
** Function btm_ble_enable_multi_adv
**
** Description This function enable the customer specific feature in controller
**
** Parameters enable: enable or disable
** inst_id: adv instance ID, can not be 0
**
** Returns status
**
*******************************************************************************/
tBTM_STATUS btm_ble_enable_multi_adv (BOOLEAN enable, UINT8 inst_id, UINT8 cb_evt)
{
UINT8 param[BTM_BLE_MULTI_ADV_ENB_LEN], *pp;
UINT8 enb = enable ? 1 : 0;
tBTM_STATUS rt;
pp = param;
memset(param, 0, BTM_BLE_MULTI_ADV_ENB_LEN);
UINT8_TO_STREAM (pp, BTM_BLE_MULTI_ADV_ENB);
UINT8_TO_STREAM (pp, enb);
UINT8_TO_STREAM (pp, inst_id);
BTM_TRACE_EVENT (" btm_ble_enable_multi_adv: enb %d, Inst ID %d", enb, inst_id);
if ((rt = BTM_VendorSpecificCommand (HCI_BLE_MULTI_ADV_OCF,
BTM_BLE_MULTI_ADV_ENB_LEN,
param,
btm_ble_multi_adv_vsc_cmpl_cback))
== BTM_CMD_STARTED) {
btm_ble_multi_adv_enq_op_q(BTM_BLE_MULTI_ADV_ENB, inst_id, cb_evt);
}
return rt;
}
/*******************************************************************************
**
** Function btm_ble_multi_adv_set_params
**
** Description This function enable the customer specific feature in controller
**
** Parameters advertise parameters used for this instance.
**
** Returns status
**
*******************************************************************************/
tBTM_STATUS btm_ble_multi_adv_set_params (tBTM_BLE_MULTI_ADV_INST *p_inst,
tBTM_BLE_ADV_PARAMS *p_params,
UINT8 cb_evt)
{
UINT8 param[BTM_BLE_MULTI_ADV_SET_PARAM_LEN], *pp;
tBTM_STATUS rt;
BD_ADDR dummy = {0, 0, 0, 0, 0, 0};
pp = param;
memset(param, 0, BTM_BLE_MULTI_ADV_SET_PARAM_LEN);
UINT8_TO_STREAM(pp, BTM_BLE_MULTI_ADV_SET_PARAM);
UINT16_TO_STREAM (pp, p_params->adv_int_min);
UINT16_TO_STREAM (pp, p_params->adv_int_max);
UINT8_TO_STREAM (pp, p_params->adv_type);
#if (defined BLE_PRIVACY_SPT && BLE_PRIVACY_SPT == TRUE)
if (btm_cb.ble_ctr_cb.privacy_mode != BTM_PRIVACY_NONE) {
UINT8_TO_STREAM (pp, BLE_ADDR_RANDOM);
BDADDR_TO_STREAM (pp, p_inst->rpa);
} else
#endif
{
UINT8_TO_STREAM (pp, BLE_ADDR_PUBLIC);
BDADDR_TO_STREAM (pp, controller_get_interface()->get_address()->address);
}
BTM_TRACE_EVENT (" btm_ble_multi_adv_set_params,Min %d, Max %d,adv_type %d",
p_params->adv_int_min, p_params->adv_int_max, p_params->adv_type);
UINT8_TO_STREAM (pp, 0);
BDADDR_TO_STREAM (pp, dummy);
if (p_params->channel_map == 0 || p_params->channel_map > BTM_BLE_DEFAULT_ADV_CHNL_MAP) {
p_params->channel_map = BTM_BLE_DEFAULT_ADV_CHNL_MAP;
}
UINT8_TO_STREAM (pp, p_params->channel_map);
if (p_params->adv_filter_policy >= AP_SCAN_CONN_POLICY_MAX) {
p_params->adv_filter_policy = AP_SCAN_CONN_ALL;
}
UINT8_TO_STREAM (pp, p_params->adv_filter_policy);
UINT8_TO_STREAM (pp, p_inst->inst_id);
if (p_params->tx_power > BTM_BLE_ADV_TX_POWER_MAX) {
p_params->tx_power = BTM_BLE_ADV_TX_POWER_MAX;
}
UINT8_TO_STREAM (pp, btm_ble_map_adv_tx_power(p_params->tx_power));
BTM_TRACE_EVENT("set_params:Chnl Map %d,adv_fltr policy %d,ID:%d, TX Power%d",
p_params->channel_map, p_params->adv_filter_policy, p_inst->inst_id, p_params->tx_power);
if ((rt = BTM_VendorSpecificCommand (HCI_BLE_MULTI_ADV_OCF,
BTM_BLE_MULTI_ADV_SET_PARAM_LEN,
param,
btm_ble_multi_adv_vsc_cmpl_cback))
== BTM_CMD_STARTED) {
p_inst->adv_evt = p_params->adv_type;
#if (defined BLE_PRIVACY_SPT && BLE_PRIVACY_SPT == TRUE)
if (btm_cb.ble_ctr_cb.privacy_mode != BTM_PRIVACY_NONE) {
/* start timer */
p_inst->raddr_timer_ent.param = (TIMER_PARAM_TYPE) p_inst;
btu_start_timer_oneshot(&p_inst->raddr_timer_ent, BTU_TTYPE_BLE_RANDOM_ADDR,
BTM_BLE_PRIVATE_ADDR_INT);
}
#endif
btm_ble_multi_adv_enq_op_q(BTM_BLE_MULTI_ADV_SET_PARAM, p_inst->inst_id, cb_evt);
}
return rt;
}
/*******************************************************************************
**
** Function btm_ble_multi_adv_write_rpa
**
** Description This function write the random address for the adv instance into
** controller
**
** Parameters
**
** Returns status
**
*******************************************************************************/
tBTM_STATUS btm_ble_multi_adv_write_rpa (tBTM_BLE_MULTI_ADV_INST *p_inst, BD_ADDR random_addr)
{
UINT8 param[BTM_BLE_MULTI_ADV_SET_RANDOM_ADDR_LEN], *pp = param;
tBTM_STATUS rt;
BTM_TRACE_EVENT ("%s-BD_ADDR:%02x-%02x-%02x-%02x-%02x-%02x,inst_id:%d",
__FUNCTION__, random_addr[5], random_addr[4], random_addr[3], random_addr[2],
random_addr[1], random_addr[0], p_inst->inst_id);
memset(param, 0, BTM_BLE_MULTI_ADV_SET_RANDOM_ADDR_LEN);
UINT8_TO_STREAM (pp, BTM_BLE_MULTI_ADV_SET_RANDOM_ADDR);
BDADDR_TO_STREAM(pp, random_addr);
UINT8_TO_STREAM(pp, p_inst->inst_id);
if ((rt = BTM_VendorSpecificCommand (HCI_BLE_MULTI_ADV_OCF,
BTM_BLE_MULTI_ADV_SET_RANDOM_ADDR_LEN,
param,
btm_ble_multi_adv_vsc_cmpl_cback)) == BTM_CMD_STARTED) {
/* start a periodical timer to refresh random addr */
btu_stop_timer_oneshot(&p_inst->raddr_timer_ent);
p_inst->raddr_timer_ent.param = (TIMER_PARAM_TYPE) p_inst;
btu_start_timer_oneshot(&p_inst->raddr_timer_ent, BTU_TTYPE_BLE_RANDOM_ADDR,
BTM_BLE_PRIVATE_ADDR_INT);
btm_ble_multi_adv_enq_op_q(BTM_BLE_MULTI_ADV_SET_RANDOM_ADDR, p_inst->inst_id, 0);
}
return rt;
}
/*******************************************************************************
**
** Function btm_ble_multi_adv_gen_rpa_cmpl
**
** Description RPA generation completion callback for each adv instance. Will
** continue write the new RPA into controller.
**
** Returns none.
**
*******************************************************************************/
void btm_ble_multi_adv_gen_rpa_cmpl(tBTM_RAND_ENC *p)
{
#if (SMP_INCLUDED == TRUE)
tSMP_ENC output;
UINT8 index = 0;
tBTM_BLE_MULTI_ADV_INST *p_inst = NULL;
/* Retrieve the index of adv instance from stored Q */
if (btm_multi_adv_idx_q.front == -1) {
BTM_TRACE_ERROR(" %s can't locate advertise instance", __FUNCTION__);
return;
} else {
index = btm_multi_adv_idx_q.inst_index_queue[btm_multi_adv_idx_q.front];
if (btm_multi_adv_idx_q.front == btm_multi_adv_idx_q.rear) {
btm_multi_adv_idx_q.front = -1;
btm_multi_adv_idx_q.rear = -1;
} else {
btm_multi_adv_idx_q.front = (btm_multi_adv_idx_q.front + 1) % BTM_BLE_MULTI_ADV_MAX;
}
}
p_inst = &(btm_multi_adv_cb.p_adv_inst[index]);
BTM_TRACE_EVENT ("btm_ble_multi_adv_gen_rpa_cmpl inst_id = %d", p_inst->inst_id);
if (p) {
p->param_buf[2] &= (~BLE_RESOLVE_ADDR_MASK);
p->param_buf[2] |= BLE_RESOLVE_ADDR_MSB;
p_inst->rpa[2] = p->param_buf[0];
p_inst->rpa[1] = p->param_buf[1];
p_inst->rpa[0] = p->param_buf[2];
if (!SMP_Encrypt(btm_cb.devcb.id_keys.irk, BT_OCTET16_LEN, p->param_buf, 3, &output)) {
BTM_TRACE_DEBUG("generate random address failed");
} else {
/* set hash to be LSB of rpAddress */
p_inst->rpa[5] = output.param_buf[0];
p_inst->rpa[4] = output.param_buf[1];
p_inst->rpa[3] = output.param_buf[2];
}
if (p_inst->inst_id != BTM_BLE_MULTI_ADV_DEFAULT_STD &&
p_inst->inst_id < BTM_BleMaxMultiAdvInstanceCount()) {
/* set it to controller */
btm_ble_multi_adv_write_rpa(p_inst, p_inst->rpa);
}
}
#endif
}
/*******************************************************************************
**
** Function btm_ble_multi_adv_configure_rpa
**
** Description This function set the random address for the adv instance
**
** Parameters advertise parameters used for this instance.
**
** Returns none
**
*******************************************************************************/
void btm_ble_multi_adv_configure_rpa (tBTM_BLE_MULTI_ADV_INST *p_inst)
{
if (btm_multi_adv_idx_q.front == (btm_multi_adv_idx_q.rear + 1) % BTM_BLE_MULTI_ADV_MAX) {
BTM_TRACE_ERROR("outstanding rand generation exceeded max allowed ");
return;
} else {
if (btm_multi_adv_idx_q.front == -1) {
btm_multi_adv_idx_q.front = 0;
btm_multi_adv_idx_q.rear = 0;
} else {
btm_multi_adv_idx_q.rear = (btm_multi_adv_idx_q.rear + 1) % BTM_BLE_MULTI_ADV_MAX;
}
btm_multi_adv_idx_q.inst_index_queue[btm_multi_adv_idx_q.rear] = p_inst->index;
}
btm_gen_resolvable_private_addr((void *)btm_ble_multi_adv_gen_rpa_cmpl);
}
/*******************************************************************************
**
** Function btm_ble_multi_adv_reenable
**
** Description This function re-enable adv instance upon a connection establishment.
**
** Parameters advertise parameters used for this instance.
**
** Returns none.
**
*******************************************************************************/
void btm_ble_multi_adv_reenable(UINT8 inst_id)
{
tBTM_BLE_MULTI_ADV_INST *p_inst = &btm_multi_adv_cb.p_adv_inst[inst_id - 1];
if (TRUE == p_inst->in_use) {
if (p_inst->adv_evt != BTM_BLE_CONNECT_DIR_EVT) {
btm_ble_enable_multi_adv (TRUE, p_inst->inst_id, 0);
} else
/* mark directed adv as disabled if adv has been stopped */
{
(p_inst->p_cback)(BTM_BLE_MULTI_ADV_DISABLE_EVT, p_inst->inst_id, p_inst->p_ref, 0);
p_inst->in_use = FALSE;
}
}
}
/*******************************************************************************
**
** Function btm_ble_multi_adv_enb_privacy
**
** Description This function enable/disable privacy setting in multi adv
**
** Parameters enable: enable or disable the adv instance.
**
** Returns none.
**
*******************************************************************************/
void btm_ble_multi_adv_enb_privacy(BOOLEAN enable)
{
UINT8 i;
tBTM_BLE_MULTI_ADV_INST *p_inst = &btm_multi_adv_cb.p_adv_inst[0];
for (i = 0; i < BTM_BleMaxMultiAdvInstanceCount() - 1; i ++, p_inst++) {
p_inst->in_use = FALSE;
if (enable) {
btm_ble_multi_adv_configure_rpa (p_inst);
} else {
btu_stop_timer_oneshot(&p_inst->raddr_timer_ent);
}
}
}
/*******************************************************************************
**
** Function BTM_BleEnableAdvInstance
**
** Description This function enable a Multi-ADV instance with the specified
** adv parameters
**
** Parameters p_params: pointer to the adv parameter structure, set as default
** adv parameter when the instance is enabled.
** p_cback: callback function for the adv instance.
** p_ref: reference data attach to the adv instance to be enabled.
**
** Returns status
**
*******************************************************************************/
tBTM_STATUS BTM_BleEnableAdvInstance (tBTM_BLE_ADV_PARAMS *p_params,
tBTM_BLE_MULTI_ADV_CBACK *p_cback, void *p_ref)
{
UINT8 i;
tBTM_STATUS rt = BTM_NO_RESOURCES;
tBTM_BLE_MULTI_ADV_INST *p_inst = &btm_multi_adv_cb.p_adv_inst[0];
BTM_TRACE_EVENT("BTM_BleEnableAdvInstance called");
if (0 == btm_cb.cmn_ble_vsc_cb.adv_inst_max) {
BTM_TRACE_ERROR("Controller does not support Multi ADV");
return BTM_ERR_PROCESSING;
}
if (NULL == p_inst) {
BTM_TRACE_ERROR("Invalid instance in BTM_BleEnableAdvInstance");
return BTM_ERR_PROCESSING;
}
for (i = 0; i < BTM_BleMaxMultiAdvInstanceCount() - 1; i ++, p_inst++) {
if (FALSE == p_inst->in_use) {
p_inst->in_use = TRUE;
/* configure adv parameter */
if (p_params) {
rt = btm_ble_multi_adv_set_params(p_inst, p_params, 0);
} else {
rt = BTM_CMD_STARTED;
}
/* enable adv */
BTM_TRACE_EVENT("btm_ble_enable_multi_adv being called with inst_id:%d",
p_inst->inst_id);
if (BTM_CMD_STARTED == rt) {
if ((rt = btm_ble_enable_multi_adv (TRUE, p_inst->inst_id,
BTM_BLE_MULTI_ADV_ENB_EVT)) == BTM_CMD_STARTED) {
p_inst->p_cback = p_cback;
p_inst->p_ref = p_ref;
}
}
if (BTM_CMD_STARTED != rt) {
p_inst->in_use = FALSE;
BTM_TRACE_ERROR("BTM_BleEnableAdvInstance failed");
}
break;
}
}
return rt;
}
/*******************************************************************************
**
** Function BTM_BleUpdateAdvInstParam
**
** Description This function update a Multi-ADV instance with the specified
** adv parameters.
**
** Parameters inst_id: adv instance ID
** p_params: pointer to the adv parameter structure.
**
** Returns status
**
*******************************************************************************/
tBTM_STATUS BTM_BleUpdateAdvInstParam (UINT8 inst_id, tBTM_BLE_ADV_PARAMS *p_params)
{
tBTM_STATUS rt = BTM_ILLEGAL_VALUE;
tBTM_BLE_MULTI_ADV_INST *p_inst = &btm_multi_adv_cb.p_adv_inst[inst_id - 1];
BTM_TRACE_EVENT("BTM_BleUpdateAdvInstParam called with inst_id:%d", inst_id);
if (0 == btm_cb.cmn_ble_vsc_cb.adv_inst_max) {
BTM_TRACE_ERROR("Controller does not support Multi ADV");
return BTM_ERR_PROCESSING;
}
if (inst_id < BTM_BleMaxMultiAdvInstanceCount() &&
inst_id != BTM_BLE_MULTI_ADV_DEFAULT_STD &&
p_params != NULL) {
if (FALSE == p_inst->in_use) {
BTM_TRACE_DEBUG("adv instance %d is not active", inst_id);
return BTM_WRONG_MODE;
} else {
btm_ble_enable_multi_adv(FALSE, inst_id, 0);
}
if (BTM_CMD_STARTED == btm_ble_multi_adv_set_params(p_inst, p_params, 0)) {
rt = btm_ble_enable_multi_adv(TRUE, inst_id, BTM_BLE_MULTI_ADV_PARAM_EVT);
}
}
return rt;
}
/*******************************************************************************
**
** Function BTM_BleCfgAdvInstData
**
** Description This function configure a Multi-ADV instance with the specified
** adv data or scan response data.
**
** Parameters inst_id: adv instance ID
** is_scan_rsp: is this scan response. if no, set as adv data.
** data_mask: adv data mask.
** p_data: pointer to the adv data structure.
**
** Returns status
**
*******************************************************************************/
tBTM_STATUS BTM_BleCfgAdvInstData (UINT8 inst_id, BOOLEAN is_scan_rsp,
tBTM_BLE_AD_MASK data_mask,
tBTM_BLE_ADV_DATA *p_data)
{
UINT8 param[BTM_BLE_MULTI_ADV_WRITE_DATA_LEN], *pp = param;
UINT8 sub_code = (is_scan_rsp) ?
BTM_BLE_MULTI_ADV_WRITE_SCAN_RSP_DATA : BTM_BLE_MULTI_ADV_WRITE_ADV_DATA;
UINT8 *p_len;
tBTM_STATUS rt;
UINT8 *pp_temp = (UINT8 *)(param + BTM_BLE_MULTI_ADV_WRITE_DATA_LEN - 1);
tBTM_BLE_VSC_CB cmn_ble_vsc_cb;
BTM_BleGetVendorCapabilities(&cmn_ble_vsc_cb);
if (0 == cmn_ble_vsc_cb.adv_inst_max) {
BTM_TRACE_ERROR("Controller does not support Multi ADV");
return BTM_ERR_PROCESSING;
}
btm_ble_update_dmt_flag_bits(&p_data->flag, btm_cb.btm_inq_vars.connectable_mode,
btm_cb.btm_inq_vars.discoverable_mode);
BTM_TRACE_EVENT("BTM_BleCfgAdvInstData called with inst_id:%d", inst_id);
if (inst_id > BTM_BLE_MULTI_ADV_MAX || inst_id == BTM_BLE_MULTI_ADV_DEFAULT_STD) {
return BTM_ILLEGAL_VALUE;
}
memset(param, 0, BTM_BLE_MULTI_ADV_WRITE_DATA_LEN);
UINT8_TO_STREAM(pp, sub_code);
p_len = pp ++;
btm_ble_build_adv_data(&data_mask, &pp, p_data);
*p_len = (UINT8)(pp - param - 2);
UINT8_TO_STREAM(pp_temp, inst_id);
if ((rt = BTM_VendorSpecificCommand (HCI_BLE_MULTI_ADV_OCF,
(UINT8)BTM_BLE_MULTI_ADV_WRITE_DATA_LEN,
param,
btm_ble_multi_adv_vsc_cmpl_cback))
== BTM_CMD_STARTED) {
btm_ble_multi_adv_enq_op_q(sub_code, inst_id, BTM_BLE_MULTI_ADV_DATA_EVT);
}
return rt;
}
/*******************************************************************************
**
** Function BTM_BleDisableAdvInstance
**
** Description This function disables a Multi-ADV instance.
**
** Parameters inst_id: adv instance ID
**
** Returns status
**
*******************************************************************************/
tBTM_STATUS BTM_BleDisableAdvInstance (UINT8 inst_id)
{
tBTM_STATUS rt = BTM_ILLEGAL_VALUE;
tBTM_BLE_VSC_CB cmn_ble_vsc_cb;
BTM_TRACE_EVENT("BTM_BleDisableAdvInstance with inst_id:%d", inst_id);
BTM_BleGetVendorCapabilities(&cmn_ble_vsc_cb);
if (0 == cmn_ble_vsc_cb.adv_inst_max) {
BTM_TRACE_ERROR("Controller does not support Multi ADV");
return BTM_ERR_PROCESSING;
}
if (inst_id < BTM_BleMaxMultiAdvInstanceCount() &&
inst_id != BTM_BLE_MULTI_ADV_DEFAULT_STD) {
if ((rt = btm_ble_enable_multi_adv(FALSE, inst_id, BTM_BLE_MULTI_ADV_DISABLE_EVT))
== BTM_CMD_STARTED) {
btm_ble_multi_adv_configure_rpa(&btm_multi_adv_cb.p_adv_inst[inst_id - 1]);
btu_stop_timer_oneshot(&btm_multi_adv_cb.p_adv_inst[inst_id - 1].raddr_timer_ent);
btm_multi_adv_cb.p_adv_inst[inst_id - 1].in_use = FALSE;
}
}
return rt;
}
/*******************************************************************************
**
** Function btm_ble_multi_adv_vse_cback
**
** Description VSE callback for multi adv events.
**
** Returns
**
*******************************************************************************/
void btm_ble_multi_adv_vse_cback(UINT8 len, UINT8 *p)
{
UINT8 sub_event;
UINT8 adv_inst;
UINT16 conn_handle;
tACL_CONN *p_acl_cb = NULL;
/* Check if this is a BLE RSSI vendor specific event */
STREAM_TO_UINT8(sub_event, p);
len--;
BTM_TRACE_EVENT("btm_ble_multi_adv_vse_cback called with event:%d", sub_event);
if ((sub_event == HCI_VSE_SUBCODE_BLE_MULTI_ADV_ST_CHG) && (len >= 4)) {
STREAM_TO_UINT8(adv_inst, p);
++p;
STREAM_TO_UINT16(conn_handle, p);
if ((p_acl_cb = btm_handle_to_acl(conn_handle)) != NULL) {
#if (defined BLE_PRIVACY_SPT && BLE_PRIVACY_SPT == TRUE)
if (btm_cb.ble_ctr_cb.privacy_mode != BTM_PRIVACY_NONE &&
adv_inst <= BTM_BLE_MULTI_ADV_MAX && adv_inst != BTM_BLE_MULTI_ADV_DEFAULT_STD) {
memcpy(p_acl_cb->conn_addr, btm_multi_adv_cb.p_adv_inst[adv_inst - 1].rpa,
BD_ADDR_LEN);
}
#endif
}
if (adv_inst < BTM_BleMaxMultiAdvInstanceCount() &&
adv_inst != BTM_BLE_MULTI_ADV_DEFAULT_STD) {
BTM_TRACE_EVENT("btm_ble_multi_adv_reenable called");
btm_ble_multi_adv_reenable(adv_inst);
}
/* re-enable connectibility */
else if (adv_inst == BTM_BLE_MULTI_ADV_DEFAULT_STD) {
if (btm_cb.ble_ctr_cb.inq_var.connectable_mode == BTM_BLE_CONNECTABLE) {
btm_ble_set_connectability ( btm_cb.ble_ctr_cb.inq_var.connectable_mode );
}
}
}
}
/*******************************************************************************
**
** Function btm_ble_multi_adv_init
**
** Description This function initialize the multi adv control block.
**
** Parameters None
**
** Returns void
**
*******************************************************************************/
void btm_ble_multi_adv_init(void)
{
#if BTM_DYNAMIC_MEMORY == TRUE
btm_multi_adv_cb_ptr = (tBTM_BLE_MULTI_ADV_CB *)osi_malloc(sizeof(tBTM_BLE_MULTI_ADV_CB));
btm_multi_adv_idx_q_ptr = (tBTM_BLE_MULTI_ADV_INST_IDX_Q *)osi_malloc(sizeof(tBTM_BLE_MULTI_ADV_INST_IDX_Q));
if (btm_multi_adv_cb_ptr == NULL || btm_multi_adv_idx_q_ptr == NULL) {
BTM_TRACE_ERROR("%s malloc failed", __func__);
return;
}
#endif
UINT8 i = 0;
memset(&btm_multi_adv_cb, 0, sizeof(tBTM_BLE_MULTI_ADV_CB));
memset (&btm_multi_adv_idx_q, 0, sizeof (tBTM_BLE_MULTI_ADV_INST_IDX_Q));
btm_multi_adv_idx_q.front = -1;
btm_multi_adv_idx_q.rear = -1;
if (btm_cb.cmn_ble_vsc_cb.adv_inst_max > 0) {
btm_multi_adv_cb.p_adv_inst = osi_malloc( sizeof(tBTM_BLE_MULTI_ADV_INST) *
(btm_cb.cmn_ble_vsc_cb.adv_inst_max));
memset(btm_multi_adv_cb.p_adv_inst, 0, sizeof(tBTM_BLE_MULTI_ADV_INST) *
(btm_cb.cmn_ble_vsc_cb.adv_inst_max));
btm_multi_adv_cb.op_q.p_sub_code = osi_malloc( sizeof(UINT8) *
(btm_cb.cmn_ble_vsc_cb.adv_inst_max));
memset(btm_multi_adv_cb.op_q.p_sub_code, 0,
sizeof(UINT8) * (btm_cb.cmn_ble_vsc_cb.adv_inst_max));
btm_multi_adv_cb.op_q.p_inst_id = osi_malloc( sizeof(UINT8) *
(btm_cb.cmn_ble_vsc_cb.adv_inst_max));
memset(btm_multi_adv_cb.op_q.p_inst_id, 0,
sizeof(UINT8) * (btm_cb.cmn_ble_vsc_cb.adv_inst_max));
}
/* Initialize adv instance indices and IDs. */
for (i = 0; i < btm_cb.cmn_ble_vsc_cb.adv_inst_max; i++) {
btm_multi_adv_cb.p_adv_inst[i].index = i;
btm_multi_adv_cb.p_adv_inst[i].inst_id = i + 1;
}
BTM_RegisterForVSEvents(btm_ble_multi_adv_vse_cback, TRUE);
}
/*******************************************************************************
**
** Function btm_ble_multi_adv_cleanup
**
** Description This function cleans up multi adv control block.
**
** Parameters
** Returns void
**
*******************************************************************************/
void btm_ble_multi_adv_cleanup(void)
{
#if BTM_DYNAMIC_MEMORY == TRUE
if (btm_multi_adv_cb_ptr == NULL)
{
BTM_TRACE_WARNING("%s memory has been freed", __func__);
return;
}
#endif
if (btm_multi_adv_cb.p_adv_inst) {
osi_free(btm_multi_adv_cb.p_adv_inst);
btm_multi_adv_cb.p_adv_inst = NULL;
}
if (btm_multi_adv_cb.op_q.p_sub_code) {
osi_free(btm_multi_adv_cb.op_q.p_sub_code);
btm_multi_adv_cb.op_q.p_sub_code = NULL;
}
if (btm_multi_adv_cb.op_q.p_inst_id) {
osi_free(btm_multi_adv_cb.op_q.p_inst_id);
btm_multi_adv_cb.op_q.p_inst_id = NULL;
}
#if BTM_DYNAMIC_MEMORY == TRUE
if(btm_multi_adv_cb_ptr) {
osi_free(btm_multi_adv_cb_ptr);
btm_multi_adv_cb_ptr = NULL;
}
if(btm_multi_adv_idx_q_ptr) {
osi_free(btm_multi_adv_idx_q_ptr);
btm_multi_adv_idx_q_ptr = NULL;
}
#endif
}
/*******************************************************************************
**
** Function btm_ble_multi_adv_get_ref
**
** Description This function obtains the reference pointer for the instance ID provided
**
** Parameters inst_id - Instance ID
**
** Returns void*
**
*******************************************************************************/
void *btm_ble_multi_adv_get_ref(UINT8 inst_id)
{
tBTM_BLE_MULTI_ADV_INST *p_inst = NULL;
if (inst_id < BTM_BleMaxMultiAdvInstanceCount()) {
p_inst = &btm_multi_adv_cb.p_adv_inst[inst_id - 1];
if (NULL != p_inst) {
return p_inst->p_ref;
}
}
return NULL;
}
#endif // #if (BLE_HOST_BLE_MULTI_ADV_EN == TRUE)
#endif
@@ -499,6 +499,7 @@ void btm_ble_set_privacy_mode_complete(UINT8 *p, UINT16 evt_len)
}
}
#if (0)
/*******************************************************************************
VSC that implement controller based privacy
********************************************************************************/
@@ -534,7 +535,7 @@ void btm_ble_resolving_list_vsc_op_cmpl (tBTM_VSC_CMPL *p_params)
/* RPA offloading enable/disabled */
}
}
#endif
/*******************************************************************************
**
** Function btm_ble_remove_resolving_list_entry
@@ -569,6 +570,7 @@ tBTM_STATUS btm_ble_remove_resolving_list_entry(tBTM_SEC_DEV_REC *p_dev_rec)
* send key to the controller, but to resolve the random address in host. */
#endif
} else {
#if (0)
UINT8 param[20] = {0};
UINT8 *p = param;
@@ -580,6 +582,7 @@ tBTM_STATUS btm_ble_remove_resolving_list_entry(tBTM_SEC_DEV_REC *p_dev_rec)
BTM_BLE_META_REMOVE_IRK_LEN,
param,
btm_ble_resolving_list_vsc_op_cmpl);
#endif
}
if (st == BTM_CMD_STARTED) {
@@ -609,6 +612,7 @@ tBTM_STATUS btm_ble_clear_resolving_list(void)
st = BTM_SUCCESS;
}
} else {
#if (0)
UINT8 param[20] = {0};
UINT8 *p = param;
@@ -617,6 +621,7 @@ tBTM_STATUS btm_ble_clear_resolving_list(void)
BTM_BLE_META_CLEAR_IRK_LEN,
param,
btm_ble_resolving_list_vsc_op_cmpl);
#endif
}
return st;
@@ -647,6 +652,7 @@ tBTM_STATUS btm_ble_read_resolving_list_entry(tBTM_SEC_DEV_REC *p_dev_rec)
st = BTM_CMD_STARTED;
}
} else {
#if (0)
UINT8 param[20] = {0};
UINT8 *p = param;
@@ -657,6 +663,7 @@ tBTM_STATUS btm_ble_read_resolving_list_entry(tBTM_SEC_DEV_REC *p_dev_rec)
BTM_BLE_META_READ_IRK_LEN,
param,
btm_ble_resolving_list_vsc_op_cmpl);
#endif
}
if (st == BTM_CMD_STARTED) {
@@ -711,11 +718,11 @@ BOOLEAN btm_ble_suspend_resolving_list_activity(void)
btm_ble_stop_scan();
p_ble_cb->suspended_rl_state |= BTM_BLE_RL_SCAN;
}
#if (tGATT_BG_CONN_DEV == TRUE)
#if (GATT_BG_CONN_DEV == TRUE)
if (btm_ble_suspend_bg_conn()) {
p_ble_cb->suspended_rl_state |= BTM_BLE_RL_INIT;
}
#endif // #if (tGATT_BG_CONN_DEV == TRUE)
#endif // #if (GATT_BG_CONN_DEV == TRUE)
return TRUE;
}
@@ -743,14 +750,15 @@ void btm_ble_resume_resolving_list_activity(void)
btm_ble_start_scan();
}
#endif // #if (BLE_42_SCAN_EN == TRUE)
#if (tGATT_BG_CONN_DEV == TRUE)
#if (GATT_BG_CONN_DEV == TRUE)
if (p_ble_cb->suspended_rl_state & BTM_BLE_RL_INIT) {
btm_ble_resume_bg_conn();
}
#endif // #if (tGATT_BG_CONN_DEV == TRUE)
#endif // #if (GATT_BG_CONN_DEV == TRUE)
p_ble_cb->suspended_rl_state = BTM_BLE_RL_IDLE;
}
#if (0)
/*******************************************************************************
**
** Function btm_ble_vendor_enable_irk_feature
@@ -780,6 +788,7 @@ tBTM_STATUS btm_ble_vendor_enable_irk_feature(BOOLEAN enable)
return st;
}
#endif
/*******************************************************************************
**
@@ -797,7 +806,9 @@ BOOLEAN btm_ble_exe_disable_resolving_list(void)
}
if (!controller_get_interface()->supports_ble_privacy()) {
#if (0)
btm_ble_vendor_enable_irk_feature(FALSE);
#endif
} else {
//btsnd_hcic_ble_set_addr_resolution_enable(FALSE);
}
@@ -821,7 +832,9 @@ void btm_ble_exe_enable_resolving_list(void)
}
if (!controller_get_interface()->supports_ble_privacy()) {
#if (0)
btm_ble_vendor_enable_irk_feature(TRUE);
#endif
} else {
//btsnd_hcic_ble_set_addr_resolution_enable(TRUE);
}
@@ -930,6 +943,7 @@ BOOLEAN btm_ble_resolving_list_load_dev(tBTM_SEC_DEV_REC *p_dev_rec)
#endif
} else {
#if (0)
UINT8 param[40] = {0};
UINT8 *p = param;
@@ -945,6 +959,7 @@ BOOLEAN btm_ble_resolving_list_load_dev(tBTM_SEC_DEV_REC *p_dev_rec)
== BTM_CMD_STARTED) {
rt = TRUE;
}
#endif
}
if (rt) {
@@ -88,18 +88,21 @@ void btm_dev_init (void)
#endif
btm_cb.devcb.reset_timer.param = (TIMER_PARAM_TYPE)TT_DEV_RESET;
#if (CLASSIC_BT_INCLUDED == TRUE)
btm_cb.devcb.rln_timer.param = (TIMER_PARAM_TYPE)TT_DEV_RLN;
#endif // (CLASSIC_BT_INCLUDED == TRUE)
btm_cb.btm_acl_pkt_types_supported = BTM_ACL_PKT_TYPES_MASK_DH1 + BTM_ACL_PKT_TYPES_MASK_DM1 +
BTM_ACL_PKT_TYPES_MASK_DH3 + BTM_ACL_PKT_TYPES_MASK_DM3 +
BTM_ACL_PKT_TYPES_MASK_DH5 + BTM_ACL_PKT_TYPES_MASK_DM5;
#if (CLASSIC_BT_INCLUDED == TRUE)
btm_cb.btm_sco_pkt_types_supported = BTM_SCO_PKT_TYPES_MASK_HV1 +
BTM_SCO_PKT_TYPES_MASK_HV2 +
BTM_SCO_PKT_TYPES_MASK_HV3 +
BTM_SCO_PKT_TYPES_MASK_EV3 +
BTM_SCO_PKT_TYPES_MASK_EV4 +
BTM_SCO_PKT_TYPES_MASK_EV5;
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
}
@@ -121,6 +124,7 @@ static void btm_db_reset (void)
btm_inq_db_reset();
#if (CLASSIC_BT_INCLUDED == TRUE)
if (btm_cb.devcb.p_rln_cmpl_cb) {
p_cb = btm_cb.devcb.p_rln_cmpl_cb;
btm_cb.devcb.p_rln_cmpl_cb = NULL;
@@ -129,6 +133,7 @@ static void btm_db_reset (void)
(*p_cb)((void *) NULL);
}
}
#endif // (CLASSIC_BT_INCLUDED == TRUE)
if (btm_cb.devcb.p_rssi_cmpl_cb) {
p_cb = btm_cb.devcb.p_rssi_cmpl_cb;
@@ -169,17 +174,18 @@ static void reset_complete(void)
#if (BLE_INCLUDED == TRUE)
btm_cb.ble_ctr_cb.conn_state = BLE_CONN_IDLE;
#if (BLE_GATT_BGCONN == TRUE)
btm_cb.ble_ctr_cb.bg_conn_type = BTM_BLE_CONN_NONE;
btm_cb.ble_ctr_cb.p_select_cback = NULL;
#if (tGATT_BG_CONN_DEV == TRUE)
#endif // (BLE_GATT_BGCONN == TRUE)
#if (GATT_BG_CONN_DEV == TRUE)
gatt_reset_bgdev_list();
#endif // #if (tGATT_BG_CONN_DEV == TRUE)
#if (BLE_HOST_BLE_MULTI_ADV_EN == TRUE)
btm_ble_multi_adv_init();
#endif // #if (BLE_HOST_BLE_MULTI_ADV_EN == TRUE)
#endif
#endif // #if (GATT_BG_CONN_DEV == TRUE)
#endif
#if (CLASSIC_BT_INCLUDED == TRUE)
btm_pm_reset();
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
l2c_link_processs_num_bufs(controller->get_acl_buffer_count_classic());
#if BTM_SCO_HCI_INCLUDED == TRUE
@@ -247,6 +253,7 @@ BOOLEAN BTM_IsDeviceUp (void)
return controller_get_interface()->get_is_ready();
}
#if (CLASSIC_BT_INCLUDED == TRUE)
/*******************************************************************************
**
** Function btm_dev_timeout
@@ -270,6 +277,7 @@ void btm_dev_timeout (TIMER_LIST_ENT *p_tle)
}
}
}
#endif // (CLASSIC_BT_INCLUDED == TRUE)
/*******************************************************************************
**
@@ -330,7 +338,7 @@ static void btm_decode_ext_features_page (UINT8 page_number, const BD_FEATURES p
BTM_TRACE_DEBUG("Local supported ACL packet types: 0x%04x",
btm_cb.btm_acl_pkt_types_supported);
#if (CLASSIC_BT_INCLUDED == TRUE)
/* Create (e)SCO supported packet types mask */
btm_cb.btm_sco_pkt_types_supported = 0;
#if BTM_SCO_INCLUDED == TRUE
@@ -411,9 +419,9 @@ static void btm_decode_ext_features_page (UINT8 page_number, const BD_FEATURES p
} else {
btm_cb.btm_def_link_policy &= ~HCI_ENABLE_PARK_MODE;
}
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
btm_sec_dev_reset ();
#if (CLASSIC_BT_INCLUDED == TRUE)
if (HCI_LMP_INQ_RSSI_SUPPORTED(p_features)) {
if (HCI_EXT_INQ_RSP_SUPPORTED(p_features)) {
BTM_SetInquiryMode (BTM_INQ_RESULT_EXTENDED);
@@ -421,7 +429,7 @@ static void btm_decode_ext_features_page (UINT8 page_number, const BD_FEATURES p
BTM_SetInquiryMode (BTM_INQ_RESULT_WITH_RSSI);
}
}
#endif // (CLASSIC_BT_INCLUDED == TRUE)
#if L2CAP_NON_FLUSHABLE_PB_INCLUDED == TRUE
if ( HCI_NON_FLUSHABLE_PB_SUPPORTED(p_features)) {
l2cu_set_non_flushable_pbf(TRUE);
@@ -552,7 +560,7 @@ tBTM_STATUS BTM_ReadLocalDeviceName (char **p_name, tBT_DEVICE_TYPE name_type)
#endif
}
#if (CLASSIC_BT_INCLUDED == TRUE)
/*******************************************************************************
**
** Function BTM_ReadLocalDeviceNameFromController
@@ -610,7 +618,7 @@ void btm_read_local_name_complete (UINT8 *p, UINT16 evt_len)
}
}
}
#endif // (CLASSIC_BT_INCLUDED == TRUE)
/*******************************************************************************
**
** Function BTM_SetDeviceClass
@@ -764,6 +772,7 @@ void btm_vsc_complete (UINT8 *p, UINT16 opcode, UINT16 evt_len,
tBTM_BLE_CB *ble_cb = &btm_cb.ble_ctr_cb;
switch(opcode) {
case HCI_VENDOR_BLE_UPDATE_DUPLICATE_EXCEPTIONAL_LIST: {
#if ((BLE_42_SCAN_EN == TRUE) || (BLE_50_EXTEND_SCAN_EN == TRUE))
uint8_t subcode, status; uint32_t length;
STREAM_TO_UINT8(status, p);
STREAM_TO_UINT8(subcode, p);
@@ -772,6 +781,7 @@ void btm_vsc_complete (UINT8 *p, UINT16 opcode, UINT16 evt_len,
(*ble_cb->update_exceptional_list_cmp_cb)(status, subcode, length, p);
}
break;
#endif // ((BLE_42_SCAN_EN == TRUE) || (BLE_50_EXTEND_SCAN_EN == TRUE))
}
case HCI_VENDOR_BLE_CLEAR_ADV: {
uint8_t status;
@@ -1090,65 +1100,6 @@ tBTM_STATUS BTM_WriteVoiceSettings(UINT16 settings)
return (BTM_NO_RESOURCES);
}
#if (BLE_HOST_ENABLE_TEST_MODE_EN == TRUE)
/*******************************************************************************
**
** Function BTM_EnableTestMode
**
** Description Send HCI the enable device under test command.
**
** Note: Controller can only be taken out of this mode by
** resetting the controller.
**
** Returns
** BTM_SUCCESS Command sent.
** BTM_NO_RESOURCES If out of resources to send the command.
**
**
*******************************************************************************/
tBTM_STATUS BTM_EnableTestMode(void)
{
UINT8 cond;
BTM_TRACE_EVENT ("BTM: BTM_EnableTestMode");
/* set auto accept connection as this is needed during test mode */
/* Allocate a buffer to hold HCI command */
cond = HCI_DO_AUTO_ACCEPT_CONNECT;
if (!btsnd_hcic_set_event_filter(HCI_FILTER_CONNECTION_SETUP,
HCI_FILTER_COND_NEW_DEVICE,
&cond, sizeof(cond))) {
return (BTM_NO_RESOURCES);
}
/* put device to connectable mode */
if (BTM_SetConnectability(BTM_CONNECTABLE, BTM_DEFAULT_CONN_WINDOW,
BTM_DEFAULT_CONN_INTERVAL) != BTM_SUCCESS) {
return BTM_NO_RESOURCES;
}
/* put device to discoverable mode */
if (BTM_SetDiscoverability(BTM_GENERAL_DISCOVERABLE, BTM_DEFAULT_DISC_WINDOW,
BTM_DEFAULT_DISC_INTERVAL) != BTM_SUCCESS) {
return BTM_NO_RESOURCES;
}
/* mask off all of event from controller */
hci_layer_get_interface()->transmit_command(
hci_packet_factory_get_interface()->make_set_event_mask((const bt_event_mask_t *)("\x00\x00\x00\x00\x00\x00\x00\x00")),
NULL,
NULL,
NULL);
/* Send the HCI command */
if (btsnd_hcic_enable_test_mode ()) {
return (BTM_SUCCESS);
} else {
return (BTM_NO_RESOURCES);
}
}
#endif // #if (BLE_HOST_ENABLE_TEST_MODE_EN == TRUE)
#if (CLASSIC_BT_INCLUDED == TRUE)
/*******************************************************************************
**
@@ -718,9 +718,6 @@ tBTM_STATUS BTM_CancelInquiry(void)
{
tBTM_STATUS status = BTM_SUCCESS;
tBTM_INQUIRY_VAR_ST *p_inq = &btm_cb.btm_inq_vars;
#if (defined(BTA_HOST_INTERLEAVE_SEARCH) && BTA_HOST_INTERLEAVE_SEARCH == TRUE)
UINT8 active_mode = p_inq->inq_active;
#endif
BTM_TRACE_API ("BTM_CancelInquiry called\n");
/*** Make sure the device is ready ***/
@@ -745,23 +742,11 @@ tBTM_STATUS BTM_CancelInquiry(void)
/* Initiate the cancel inquiry */
else {
if (((p_inq->inqparms.mode & BTM_BR_INQUIRY_MASK) != 0)
#if (defined(BTA_HOST_INTERLEAVE_SEARCH) && BTA_HOST_INTERLEAVE_SEARCH == TRUE)
&& (active_mode & BTM_BR_INQUIRY_MASK)
#endif
) {
if (!btsnd_hcic_inq_cancel()) {
status = BTM_NO_RESOURCES;
}
}
#if BLE_INCLUDED == TRUE
if (((p_inq->inqparms.mode & BTM_BLE_INQUIRY_MASK) != 0)
#if (defined(BTA_HOST_INTERLEAVE_SEARCH) && BTA_HOST_INTERLEAVE_SEARCH == TRUE)
&& (active_mode & BTM_BLE_INQ_ACTIVE_MASK)
#endif
) {
btm_ble_stop_inquiry();
}
#endif
}
/* Do not send the BUSY_LEVEL event yet. Wait for the cancel_complete event
@@ -819,16 +804,6 @@ tBTM_STATUS BTM_StartInquiry (tBTM_INQ_PARMS *p_inqparms, tBTM_INQ_RESULTS_CB *p
/* Only one active inquiry is allowed in this implementation.
Also do not allow an inquiry if the inquiry filter is being updated */
if (p_inq->inq_active || p_inq->inqfilt_active) {
#if (defined BLE_INCLUDED && BLE_INCLUDED == TRUE)
/*check if LE observe is already running*/
if (p_inq->scan_type == INQ_LE_OBSERVE && p_inq->p_inq_ble_results_cb != NULL) {
BTM_TRACE_API("BTM_StartInquiry: LE observe in progress");
p_inq->scan_type = INQ_GENERAL;
p_inq->inq_active = BTM_INQUIRY_INACTIVE;
btm_cb.ble_ctr_cb.inq_var.scan_type = BTM_BLE_SCAN_MODE_NONE;
btsnd_hcic_ble_set_scan_enable (BTM_BLE_SCAN_DISABLE, BTM_BLE_DUPLICATE_ENABLE);
} else
#endif
{
return (BTM_BUSY);
BTM_TRACE_API("BTM_StartInquiry: return BUSY\n");
@@ -852,13 +827,6 @@ tBTM_STATUS BTM_StartInquiry (tBTM_INQ_PARMS *p_inqparms, tBTM_INQ_RESULTS_CB *p
return (BTM_ILLEGAL_VALUE);
}
#if (defined(BTA_HOST_INTERLEAVE_SEARCH) && BTA_HOST_INTERLEAVE_SEARCH == TRUE)
if (p_inq->next_state == BTM_FINISH) {
return BTM_ILLEGAL_VALUE;
}
#endif
/* Save the inquiry parameters to be used upon the completion of setting/clearing the inquiry filter */
p_inq->inqparms = *p_inqparms;
@@ -870,85 +838,12 @@ tBTM_STATUS BTM_StartInquiry (tBTM_INQ_PARMS *p_inqparms, tBTM_INQ_RESULTS_CB *p
p_inq->inq_active = p_inqparms->mode;
BTM_TRACE_DEBUG("BTM_StartInquiry: p_inq->inq_active = 0x%02x\n", p_inq->inq_active);
/* interleave scan minimal conditions */
#if (BLE_INCLUDED==TRUE && (defined(BTA_HOST_INTERLEAVE_SEARCH) && BTA_HOST_INTERLEAVE_SEARCH == TRUE))
/* check if both modes are present */
if ((p_inqparms->mode & BTM_BLE_INQUIRY_MASK) && (p_inqparms->mode & BTM_BR_INQUIRY_MASK)) {
BTM_TRACE_API("BTM:Interleave Inquiry Mode Set\n");
p_inqparms->duration = p_inqparms->intl_duration[p_inq->next_state];
p_inq->inqparms.duration = p_inqparms->duration;
} else {
BTM_TRACE_API("BTM:Single Mode: No interleaving, Mode:0x%02x\n", p_inqparms->mode);
p_inq->next_state = BTM_NO_INTERLEAVING;
}
#endif
/* start LE inquiry here if requested */
#if BLE_INCLUDED == TRUE
if ((p_inqparms->mode & BTM_BLE_INQUIRY_MASK)
#if (defined(BTA_HOST_INTERLEAVE_SEARCH) && BTA_HOST_INTERLEAVE_SEARCH == TRUE)
&& (p_inq->next_state == BTM_BLE_ONE || p_inq->next_state == BTM_BLE_TWO ||
p_inq->next_state == BTM_NO_INTERLEAVING)
#endif
)
{
#if (defined(BTA_HOST_INTERLEAVE_SEARCH) && BTA_HOST_INTERLEAVE_SEARCH == TRUE)
p_inq->inq_active = (p_inqparms->mode & BTM_BLE_INQUIRY_MASK);
BTM_TRACE_API("BTM:Starting LE Scan with duration %d and activeMode:0x%02x\n",
p_inqparms->duration, (p_inqparms->mode & BTM_BLE_INQUIRY_MASK));
#endif
if (!controller_get_interface()->supports_ble()) {
p_inq->inqparms.mode &= ~ BTM_BLE_INQUIRY_MASK;
status = BTM_ILLEGAL_VALUE;
}
/* BLE for now does not support filter condition for inquiry */
else if ((status = btm_ble_start_inquiry((UINT8)(p_inqparms->mode & BTM_BLE_INQUIRY_MASK),
p_inqparms->duration)) != BTM_CMD_STARTED) {
BTM_TRACE_ERROR("Err Starting LE Inquiry.\n");
p_inq->inqparms.mode &= ~ BTM_BLE_INQUIRY_MASK;
}
#if (!defined(BTA_HOST_INTERLEAVE_SEARCH) || BTA_HOST_INTERLEAVE_SEARCH == FALSE)
p_inqparms->mode &= ~BTM_BLE_INQUIRY_MASK;
#endif
#if (defined(BTA_HOST_INTERLEAVE_SEARCH) && BTA_HOST_INTERLEAVE_SEARCH == TRUE)
if (p_inq->next_state == BTM_NO_INTERLEAVING) {
p_inq->next_state = BTM_FINISH;
} else {
BTM_TRACE_API("BTM:Interleaving: started LE scan, Advancing to next state: %d\n",
p_inq->next_state + 1);
p_inq->next_state += 1;
}
/* reset next_state if status <> BTM_Started */
if (status != BTM_CMD_STARTED) {
p_inq->next_state = BTM_BR_ONE;
}
/* if interleave scan..return here */
return status;
#endif
BTM_TRACE_DEBUG("BTM_StartInquiry: mode = %02x\n", p_inqparms->mode);
}
#endif /* end of BLE_INCLUDED */
/* we're done with this routine if BR/EDR inquiry is not desired. */
if ((p_inqparms->mode & BTM_BR_INQUIRY_MASK) == BTM_INQUIRY_NONE) {
return status;
}
/* BR/EDR inquiry portion */
#if (defined(BTA_HOST_INTERLEAVE_SEARCH) && BTA_HOST_INTERLEAVE_SEARCH == TRUE)
if ((p_inq->next_state == BTM_BR_ONE || p_inq->next_state == BTM_BR_TWO ||
p_inq->next_state == BTM_NO_INTERLEAVING )) {
p_inq->inq_active = (p_inqparms->mode & BTM_BR_INQUIRY_MASK);
#endif
/* If a filter is specified, then save it for later and clear the current filter.
The setting of the filter is done upon completion of clearing of the previous
filter.
@@ -977,25 +872,6 @@ tBTM_STATUS BTM_StartInquiry (tBTM_INQ_PARMS *p_inqparms, tBTM_INQ_RESULTS_CB *p
p_inq->state = BTM_INQ_INACTIVE_STATE;
}
#if (defined(BTA_HOST_INTERLEAVE_SEARCH) && BTA_HOST_INTERLEAVE_SEARCH == TRUE)
if (p_inq->next_state == BTM_NO_INTERLEAVING) {
p_inq->next_state = BTM_FINISH;
} else {
BTM_TRACE_API("BTM:Interleaving: Started BTM inq, Advancing to next state: %d\n",
p_inq->next_state + 1);
p_inq->next_state += 1;
}
}
if (status != BTM_CMD_STARTED) {
/* Some error beginning the scan process.
Reset the next_state parameter.. Do we need to reset the inq_active also?
*/
BTM_TRACE_API("BTM:Interleaving: Error in Starting inquiry, status: 0x%02x\n", status);
p_inq->next_state = BTM_BR_ONE;
}
#endif
return (status);
}
@@ -1210,6 +1086,7 @@ tBTM_STATUS BTM_ClearInqDb (BD_ADDR p_bda)
return (BTM_SUCCESS);
}
#if (CLASSIC_BT_INCLUDED == TRUE)
/*******************************************************************************
**
** Function BTM_ReadInquiryRspTxPower
@@ -1240,6 +1117,7 @@ tBTM_STATUS BTM_ReadInquiryRspTxPower (tBTM_CMPL_CB *p_cb)
return (BTM_CMD_STARTED);
}
}
#endif // (CLASSIC_BT_INCLUDED == TRUE)
/*********************************************************************************
**********************************************************************************
@@ -1968,11 +1846,6 @@ void btm_process_inq_results (UINT8 *p, UINT8 inq_res_mode)
/* BTM_TRACE_DEBUG("BTMINQ: Found devices, cancelling inquiry..."); */
btsnd_hcic_inq_cancel();
#if BLE_INCLUDED == TRUE
if ((p_inq->inqparms.mode & BTM_BLE_INQUIRY_MASK) != 0) {
btm_ble_stop_inquiry();
}
#endif
btm_acl_update_busy_level (BTM_BLI_INQ_DONE_EVT);
}
/* Initialize flag to FALSE. This flag is set/used by application */
@@ -2053,27 +1926,10 @@ void btm_process_inq_complete (UINT8 status, UINT8 mode)
tBTM_CMPL_CB *p_inq_cb = btm_cb.btm_inq_vars.p_inq_cmpl_cb;
tBTM_INQUIRY_VAR_ST *p_inq = &btm_cb.btm_inq_vars;
#if (defined(BTA_HOST_INTERLEAVE_SEARCH) && BTA_HOST_INTERLEAVE_SEARCH == TRUE)
/* inquiry inactive case happens when inquiry is cancelled.
Make mode 0 for no further inquiries from the current inquiry process
*/
if (status != HCI_SUCCESS || p_inq->next_state == BTM_FINISH || !p_inq->inq_active) {
/* re-initialize for next inquiry request */
p_inq->next_state = BTM_BR_ONE;
/* make the mode 0 here */
p_inq->inqparms.mode &= ~(p_inq->inqparms.mode);
}
#endif
#if (!defined(BTA_HOST_INTERLEAVE_SEARCH) || BTA_HOST_INTERLEAVE_SEARCH == FALSE)
p_inq->inqparms.mode &= ~(mode);
#endif
if (p_inq->scan_type == INQ_LE_OBSERVE && !p_inq->inq_active) {
/*end of LE observe*/
p_inq->p_inq_ble_results_cb = (tBTM_INQ_RESULTS_CB *) NULL;
p_inq->p_inq_ble_cmpl_cb = (tBTM_CMPL_CB *) NULL;
p_inq->scan_type = INQ_NONE;
}
@@ -2117,24 +1973,9 @@ void btm_process_inq_complete (UINT8 status, UINT8 mode)
(p_inq_cb)((tBTM_INQUIRY_CMPL *) &p_inq->inq_cmpl_info);
}
}
#if (defined(BTA_HOST_INTERLEAVE_SEARCH) && BTA_HOST_INTERLEAVE_SEARCH == TRUE)
if (p_inq->inqparms.mode != 0 && !(p_inq->inq_active & BTM_PERIODIC_INQUIRY_ACTIVE)) {
/* make inquiry inactive for next iteration */
p_inq->inq_active = BTM_INQUIRY_INACTIVE;
/* call the inquiry again */
BTM_StartInquiry(&p_inq->inqparms, p_inq->p_inq_results_cb, p_inq->p_inq_cmpl_cb);
}
#endif
}
if (p_inq->inqparms.mode == 0 && p_inq->scan_type == INQ_GENERAL) { //this inquiry is complete
p_inq->scan_type = INQ_NONE;
#if (defined BLE_INCLUDED && BLE_INCLUDED == TRUE)
/* check if the LE observe is pending */
if (p_inq->p_inq_ble_results_cb != NULL) {
BTM_TRACE_DEBUG("BTM Inq Compl: resuming a pending LE scan");
BTM_BleObserve(1, 0, p_inq->p_inq_ble_results_cb, p_inq->p_inq_ble_cmpl_cb);
}
#endif
}
#if (BTM_INQ_DEBUG == TRUE)
BTM_TRACE_DEBUG ("inq_active:0x%x state:%d inqfilt_active:%d\n",
@@ -2342,6 +2183,8 @@ void btm_inq_rmt_name_failed (void)
btm_sec_rmt_name_request_complete (NULL, NULL, HCI_ERR_UNSPECIFIED);
#endif ///SMP_INCLUDED == TRUE
}
#if (CLASSIC_BT_INCLUDED == TRUE)
/*******************************************************************************
**
** Function btm_read_linq_tx_power_complete
@@ -2377,6 +2220,7 @@ void btm_read_linq_tx_power_complete(UINT8 *p)
}
}
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
/*******************************************************************************
**
** Function BTM_WriteEIR
@@ -64,9 +64,12 @@ void btm_init (void)
#endif /* #if BTM_DYNAMIC_MEMORY */
/* All fields are cleared; nonzero fields are reinitialized in appropriate function */
memset(&btm_cb, 0, sizeof(tBTM_CB));
#if (CLASSIC_BT_INCLUDED == TRUE)
btm_cb.page_queue = fixed_queue_new(QUEUE_SIZE_MAX);
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
#if (SMP_INCLUDED == TRUE)
btm_cb.sec_pending_q = fixed_queue_new(QUEUE_SIZE_MAX);
#endif // (SMP_INCLUDED == TRUE)
#if defined(BTM_INITIAL_TRACE_LEVEL)
btm_cb.trace_level = BTM_INITIAL_TRACE_LEVEL;
#else
@@ -86,7 +89,9 @@ void btm_init (void)
#if BLE_INCLUDED == TRUE
btm_ble_lock_init();
btm_ble_sem_init();
#if ((SMP_INCLUDED == TRUE) || (BLE_PRIVACY_SPT == TRUE))
btm_cb.addr_res_en = TRUE;
#endif // ((SMP_INCLUDED == TRUE) || (BLE_PRIVACY_SPT == TRUE))
#endif
btm_sec_dev_init();
#if (BLE_50_FEATURE_SUPPORT == TRUE)
@@ -110,8 +115,12 @@ void btm_init (void)
*******************************************************************************/
void btm_free(void)
{
#if (CLASSIC_BT_INCLUDED == TRUE)
fixed_queue_free(btm_cb.page_queue, osi_free_func);
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
#if (SMP_INCLUDED == TRUE)
fixed_queue_free(btm_cb.sec_pending_q, osi_free_func);
#endif // (SMP_INCLUDED == TRUE)
btm_acl_free();
btm_sec_dev_free();
#if BTM_SCO_INCLUDED == TRUE
@@ -151,7 +160,7 @@ uint8_t btm_ble_acl_active_count(void)
return count;
}
#if ((SMP_INCLUDED == TRUE) || (BLE_PRIVACY_SPT == TRUE))
// Address resolution status
uint8_t btm_get_ble_addr_resolve_disable_status(void)
{
@@ -163,4 +172,5 @@ void btm_ble_addr_resolve_enable(bool enable)
{
btm_cb.addr_res_en = enable;
}
#endif // ((SMP_INCLUDED == TRUE) || (BLE_PRIVACY_SPT == TRUE))
#endif /*BLE_INCLUDED*/
@@ -45,6 +45,8 @@
//#include "bt_utils.h"
//#include "osi/include/log.h"
#include "osi/allocator.h"
#if (CLASSIC_BT_INCLUDED == TRUE)
/*****************************************************************************/
/* to handle different modes */
/*****************************************************************************/
@@ -820,9 +822,10 @@ void btm_pm_proc_mode_change (UINT8 hci_status, UINT16 hci_handle, UINT8 mode, U
(*btm_cb.pm_reg_db[yy].cback)( p->remote_addr, mode, interval, hci_status);
}
}
#if (CLASSIC_BT_INCLUDED == TRUE)
/* If mode change was because of an active role switch or change link key */
btm_cont_rswitch(p, btm_find_dev(p->remote_addr), hci_status);
#endif // (CLASSIC_BT_INCLUDED == TRUE)
}
/*******************************************************************************
@@ -901,7 +904,7 @@ BOOLEAN btm_pm_device_in_active_or_sniff_mode(void)
return FALSE;
}
#if (CLASSIC_BT_INCLUDED == TRUE)
/*******************************************************************************
**
** Function btm_pm_device_in_scan_state
@@ -930,7 +933,7 @@ BOOLEAN btm_pm_device_in_scan_state(void)
return FALSE;
}
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
/*******************************************************************************
**
** Function BTM_PM_ReadControllerState
@@ -944,9 +947,13 @@ tBTM_CONTRL_STATE BTM_PM_ReadControllerState(void)
{
if (TRUE == btm_pm_device_in_active_or_sniff_mode()) {
return BTM_CONTRL_ACTIVE;
} else if (TRUE == btm_pm_device_in_scan_state()) {
}
#if (CLASSIC_BT_INCLUDED == TRUE)
else if (TRUE == btm_pm_device_in_scan_state()) {
return BTM_CONTRL_SCAN;
} else {
}
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
else {
return BTM_CONTRL_IDLE;
}
}
@@ -963,3 +970,5 @@ static const char *mode_to_string(tBTM_PM_MODE mode)
}
}
#endif
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
@@ -211,7 +211,7 @@ static BOOLEAN btm_serv_trusted(tBTM_SEC_DEV_REC *p_dev_rec, tBTM_SEC_SERV_REC *
}
return (FALSE);
}
#endif ///SMP_INCLUDED == TRUE
/*******************************************************************************
**
** Function BTM_SecRegister
@@ -274,6 +274,7 @@ BOOLEAN BTM_SecRegisterLinkKeyNotificationCallback (tBTM_LINK_KEY_CALLBACK *p_ca
btm_cb.api.p_link_key_callback = p_callback;
return TRUE;
}
#endif ///SMP_INCLUDED == TRUE
/*******************************************************************************
**
@@ -410,6 +411,7 @@ void BTM_SetPinType (UINT8 pin_type, PIN_CODE pin_code, UINT8 pin_code_len)
}
#endif ///CLASSIC_BT_INCLUDED == TRUE
#if (CLASSIC_BT_INCLUDED == TRUE)
/*******************************************************************************
**
** Function BTM_SetPairableMode
@@ -455,6 +457,8 @@ void BTM_SetSecureConnectionsOnly (BOOLEAN secure_connections_only_mode)
btm_cb.devcb.secure_connections_only = secure_connections_only_mode;
btm_cb.security_mode = BTM_SEC_MODE_SC;
}
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
#define BTM_NO_AVAIL_SEC_SERVICES ((UINT16) 0xffff)
/*******************************************************************************
@@ -2641,6 +2645,7 @@ tBTM_STATUS btm_sec_mx_access_request (BD_ADDR bd_addr, UINT16 psm, BOOLEAN is_o
** Returns void
**
*******************************************************************************/
#if (CLASSIC_BT_INCLUDED == TRUE)
#if (SMP_INCLUDED == TRUE)
void btm_sec_conn_req (UINT8 *bda, UINT8 *dc)
{
@@ -2701,7 +2706,7 @@ void btm_sec_conn_req (UINT8 *bda, UINT8 *dc)
}
}
#endif ///SMP_INCLUDED == TRUE
#endif // (CLASSIC_BT_INCLUDED == TRUE)
/*******************************************************************************
**
** Function btm_sec_bond_cancel_complete
@@ -2778,10 +2783,12 @@ void btm_create_conn_cancel_complete (UINT8 *p, UINT16 evt_len)
case HCI_ERR_CONNECTION_EXISTS:
case HCI_ERR_NO_CONNECTION:
default:
#if (SMP_INCLUDED == TRUE)
/* Notify application of the error */
if (btm_cb.api.p_bond_cancel_cmpl_callback) {
btm_cb.api.p_bond_cancel_cmpl_callback(BTM_ERR_PROCESSING);
}
#endif // #if (SMP_INCLUDED == TRUE)
break;
}
}
@@ -3007,7 +3014,9 @@ void btm_sec_rmt_name_request_complete (UINT8 *p_bd_addr, UINT8 *p_bd_name, UINT
BTM_TRACE_EVENT ("btm_sec_rmt_name_request_complete\n");
if (((p_bd_addr == NULL) && !BTM_ACL_IS_CONNECTED(btm_cb.connecting_bda))
|| ((p_bd_addr != NULL) && !BTM_ACL_IS_CONNECTED(p_bd_addr))) {
#if (CLASSIC_BT_INCLUDED == TRUE)
btm_acl_resubmit_page();
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
}
/* If remote name request failed, p_bd_addr is null and we need to search */
@@ -4303,8 +4312,9 @@ void btm_sec_connected (UINT8 *bda, UINT16 handle, UINT8 status, UINT8 enc_mode)
BOOLEAN is_pairing_device = FALSE;
tACL_CONN *p_acl_cb;
UINT8 bit_shift = 0;
#if (CLASSIC_BT_INCLUDED == TRUE)
btm_acl_resubmit_page();
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev (bda);
@@ -4545,10 +4555,11 @@ void btm_sec_connected (UINT8 *bda, UINT16 handle, UINT8 status, UINT8 enc_mode)
/* commands events and data at the same time. */
/* Set the packet types to the default allowed by the device */
btm_set_packet_types (p_acl_cb, btm_cb.btm_acl_pkt_types_supported);
#if (CLASSIC_BT_INCLUDED == TRUE)
if (btm_cb.btm_def_link_policy) {
BTM_SetLinkPolicy (p_acl_cb->remote_addr, &btm_cb.btm_def_link_policy);
}
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
#endif
}
btm_acl_created (bda, p_dev_rec->dev_class, p_dev_rec->sec_bd_name, handle, HCI_ROLE_SLAVE, BT_TRANSPORT_BR_EDR);
@@ -4635,10 +4646,10 @@ BOOLEAN btm_sec_disconnected (UINT16 handle, UINT8 reason)
tBTM_SEC_CALLBACK *p_callback = NULL;
tBT_TRANSPORT transport = BT_TRANSPORT_BR_EDR;
#if (CLASSIC_BT_INCLUDED == TRUE)
/* If page was delayed for disc complete, can do it now */
btm_cb.discing = FALSE;
#if (CLASSIC_BT_INCLUDED == TRUE)
btm_acl_resubmit_page();
#endif
@@ -331,26 +331,27 @@ typedef struct {
** BLE Inquiry
*****************************************************/
tBTM_BLE_INQ_CB inq_var;
/* observer callback and timer */
tBTM_INQ_RESULTS_CB *p_obs_results_cb;
tBTM_CMPL_CB *p_obs_cmpl_cb;
#if (BLE_42_SCAN_EN == TRUE)
#if (BLE_ADV_REPORT_FLOW_CONTROL == TRUE)
// /* observer callback and timer */
tBTM_INQ_DIS_CB *p_obs_discard_cb;
TIMER_LIST_ENT obs_timer_ent;
#endif // (BLE_ADV_REPORT_FLOW_CONTROL == TRUE)
/* scan callback and timer */
tBTM_INQ_RESULTS_CB *p_scan_results_cb;
tBTM_CMPL_CB *p_scan_cmpl_cb;
TIMER_LIST_ENT scan_timer_ent;
#if (BLE_42_SCAN_EN == TRUE)
struct pkt_queue *adv_rpt_queue;
struct osi_event *adv_rpt_ready;
#endif // #if (BLE_42_SCAN_EN == TRUE)
#if (BLE_GATT_BGCONN == TRUE)
/* background connection procedure cb value */
tBTM_BLE_CONN_TYPE bg_conn_type;
#endif // (BLE_GATT_BGCONN == TRUE)
UINT32 scan_int;
UINT32 scan_win;
#if (BLE_GATT_BGCONN == TRUE)
tBTM_BLE_SEL_CBACK *p_select_cback;
#endif // (BLE_GATT_BGCONN == TRUE)
/* white list information */
UINT8 white_list_avail_size;
#if (BLE_50_EXTEND_SYNC_EN == TRUE)
@@ -380,12 +381,18 @@ typedef struct {
tBTM_BLE_WL_OP wl_op_q[BTM_BLE_MAX_BG_CONN_DEV_NUM];
#if (BLE_TOPOLOGY_CHECK == TRUE)
/* current BLE link state */
tBTM_BLE_STATE_MASK cur_states; /* bit mask of tBTM_BLE_STATE */
UINT8 link_count[2]; /* total link count master and slave*/
#endif // (BLE_TOPOLOGY_CHECK == TRUE)
#if ((BLE_42_SCAN_EN == TRUE) || (BLE_50_EXTEND_SCAN_EN == TRUE))
tBTM_UPDATE_DUPLICATE_EXCEPTIONAL_LIST_CMPL_CBACK *update_exceptional_list_cmp_cb;
#endif // ((BLE_42_SCAN_EN == TRUE) || (BLE_50_EXTEND_SCAN_EN == TRUE))
#if (BLE_VENDOR_HCI_EN == TRUE)
tBTM_SET_CSA_SUPPORT_CMPL_CBACK *set_csa_support_cmpl_cb;
tBTM_SET_VENDOR_EVT_MASK_CBACK *set_vendor_evt_mask_cmpl_cb;
#endif // (BLE_VENDOR_HCI_EN == TRUE)
} tBTM_BLE_CB;
#ifdef __cplusplus
@@ -406,12 +413,9 @@ BOOLEAN btm_ble_cancel_remote_name(BD_ADDR remote_bda);
tBTM_STATUS btm_ble_set_discoverability(UINT16 combined_mode);
tBTM_STATUS btm_ble_set_connectability(UINT16 combined_mode);
tBTM_STATUS btm_ble_start_inquiry (UINT8 mode, UINT8 duration);
void btm_ble_stop_scan(void);
void btm_clear_all_pending_le_entry(void);
BOOLEAN btm_ble_send_extended_scan_params(UINT8 scan_type, UINT32 scan_int, UINT32 scan_win, UINT8 addr_type_own, UINT8 scan_filter_policy);
void btm_ble_stop_inquiry(void);
void btm_ble_init (void);
void btm_ble_free (void);
void btm_ble_connected (UINT8 *bda, UINT16 handle, UINT8 enc_mode, UINT8 role, tBLE_ADDR_TYPE addr_type, BOOLEAN addr_matched);
@@ -470,11 +474,11 @@ void btm_ble_remove_from_white_list_complete(UINT8 *p, UINT16 evt_len);
void btm_ble_clear_white_list_complete(UINT8 *p, UINT16 evt_len);
void btm_ble_white_list_init(UINT8 white_list_size);
#if (tGATT_BG_CONN_DEV == TRUE)
#if (GATT_BG_CONN_DEV == TRUE)
/* background connection function */
BOOLEAN btm_ble_suspend_bg_conn(void);
BOOLEAN btm_ble_resume_bg_conn(void);
#endif // #if (tGATT_BG_CONN_DEV == TRUE)
#endif // #if (GATT_BG_CONN_DEV == TRUE)
void btm_ble_initiate_select_conn(BD_ADDR bda);
BOOLEAN btm_ble_start_auto_conn(BOOLEAN start);
@@ -518,23 +522,13 @@ void btm_ble_add_default_entry_to_resolving_list(void);
void btm_ble_set_privacy_mode_complete(UINT8 *p, UINT16 evt_len);
#endif
#if (BLE_HOST_BLE_MULTI_ADV_EN == TRUE)
void btm_ble_multi_adv_configure_rpa (tBTM_BLE_MULTI_ADV_INST *p_inst);
void btm_ble_multi_adv_init(void);
void *btm_ble_multi_adv_get_ref(UINT8 inst_id);
void btm_ble_multi_adv_cleanup(void);
void btm_ble_multi_adv_reenable(UINT8 inst_id);
void btm_ble_multi_adv_enb_privacy(BOOLEAN enable);
#endif // #if (BLE_HOST_BLE_MULTI_ADV_EN == TRUE)
char btm_ble_map_adv_tx_power(int tx_power_index);
void btm_ble_batchscan_init(void);
void btm_ble_batchscan_cleanup(void);
void btm_ble_adv_filter_init(void);
void btm_ble_adv_filter_cleanup(void);
#if (BLE_TOPOLOGY_CHECK == TRUE)
BOOLEAN btm_ble_topology_check(tBTM_BLE_STATE_MASK request);
BOOLEAN btm_ble_clear_topology_mask(tBTM_BLE_STATE_MASK request_state);
BOOLEAN btm_ble_set_topology_mask(tBTM_BLE_STATE_MASK request_state);
tBTM_BLE_STATE_MASK btm_ble_get_topology_mask(void);
#endif // (BLE_TOPOLOGY_CHECK == TRUE)
#if BTM_BLE_CONFORMANCE_TESTING == TRUE
void btm_ble_set_no_disc_if_pair_fail (BOOLEAN disble_disc);
@@ -140,7 +140,10 @@ UINT8 legacy_auth_state;
#define BTM_ACL_SWKEY_STATE_SWITCHING 3
#define BTM_ACL_SWKEY_STATE_ENCRYPTION_ON 4
#define BTM_ACL_SWKEY_STATE_IN_PROGRESS 5
#if (CLASSIC_BT_INCLUDED == TRUE)
UINT8 switch_role_state;
#endif // (CLASSIC_BT_INCLUDED == TRUE)
#define BTM_ACL_ENCRYPT_STATE_IDLE 0
#define BTM_ACL_ENCRYPT_STATE_ENCRYPT_OFF 1 /* encryption turning off */
@@ -180,40 +183,49 @@ typedef struct {
tBTM_DEV_STATUS_CB *p_dev_status_cb; /* Device status change callback */
tBTM_VS_EVT_CB *p_vend_spec_cb[BTM_MAX_VSE_CALLBACKS]; /* Register for vendor specific events */
#if (CLASSIC_BT_INCLUDED == TRUE)
tBTM_CMPL_CB *p_stored_link_key_cmpl_cb; /* Read/Write/Delete stored link key */
#endif // (CLASSIC_BT_INCLUDED == TRUE)
TIMER_LIST_ENT reset_timer;
tBTM_CMPL_CB *p_reset_cmpl_cb;
#if (CLASSIC_BT_INCLUDED == TRUE)
TIMER_LIST_ENT rln_timer;
tBTM_CMPL_CB *p_rln_cmpl_cb; /* Callback function to be called when */
#endif // (CLASSIC_BT_INCLUDED == TRUE)
/* read local name function complete */
TIMER_LIST_ENT rssi_timer;
tBTM_CMPL_CB *p_rssi_cmpl_cb; /* Callback function to be called when */
/* read rssi function completes */
#if BLE_INCLUDED == TRUE
tBTM_CMPL_CB *p_ble_ch_map_cmpl_cb; /* Callback function to be called when */
#endif // #if BLE_INCLUDED == TRUE
/* read channel map function completes */
#if (CLASSIC_BT_INCLUDED == TRUE)
TIMER_LIST_ENT lnk_quality_timer;
tBTM_CMPL_CB *p_lnk_qual_cmpl_cb;/* Callback function to be called when */
#endif // (CLASSIC_BT_INCLUDED == TRUE)
#if (CLASSIC_BT_INCLUDED == TRUE)
/* read link quality function completes */
TIMER_LIST_ENT txpwer_timer;
tBTM_CMPL_CB *p_txpwer_cmpl_cb; /* Callback function to be called when */
/* read inq tx power function completes */
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
/* read inq tx power function completes */
#if (CLASSIC_BT_INCLUDED == TRUE)
TIMER_LIST_ENT qossu_timer;
tBTM_CMPL_CB *p_qossu_cmpl_cb; /* Callback function to be called when */
/* qos setup function completes */
#endif // (CLASSIC_BT_INCLUDED == TRUE)
#if (CLASSIC_BT_INCLUDED == TRUE)
tBTM_ROLE_SWITCH_CMPL switch_role_ref_data;
tBTM_CMPL_CB *p_switch_role_cb; /* Callback function to be called when */
/* requested switch role is completed */
#if (BLE_HOST_READ_TX_POWER_EN == TRUE)
TIMER_LIST_ENT tx_power_timer;
tBTM_CMPL_CB *p_tx_power_cmpl_cb;/* Callback function to be called */
#endif // #if (BLE_HOST_READ_TX_POWER_EN == TRUE)
#endif // (CLASSIC_BT_INCLUDED == TRUE)
#if CLASSIC_BT_INCLUDED == TRUE
TIMER_LIST_ENT afh_channels_timer;
@@ -265,10 +277,11 @@ UINT32 test_local_sign_cntr;
#endif
#endif /* BLE_INCLUDED */
tBTM_IO_CAP loc_io_caps; /* IO capability of the local device */
#if (SMP_INCLUDED == TRUE)
tBTM_AUTH_REQ loc_auth_req; /* the auth_req flag */
BOOLEAN secure_connections_only; /* Rejects service level 0 connections if */
#endif // #if (SMP_INCLUDED == TRUE)
/* itself or peer device doesn't support */
/* secure connections */
} tBTM_DEVCB;
@@ -347,8 +360,6 @@ typedef struct {
tBTM_CMPL_CB *p_inq_cmpl_cb;
tBTM_INQ_RESULTS_CB *p_inq_results_cb;
tBTM_CMPL_CB *p_inq_ble_cmpl_cb; /*completion callback exclusively for LE Observe*/
tBTM_INQ_RESULTS_CB *p_inq_ble_results_cb;/*results callback exclusively for LE observe*/
tBTM_CMPL_CB *p_inqfilter_cmpl_cb; /* Called (if not NULL) after inquiry filter completed */
UINT32 inq_counter; /* Counter incremented each time an inquiry completes */
/* Used for determining whether or not duplicate devices */
@@ -378,9 +389,6 @@ typedef struct {
UINT8 state; /* Current state that the inquiry process is in */
UINT8 inq_active; /* Bit Mask indicating type of inquiry is active */
BOOLEAN no_inc_ssp; /* TRUE, to stop inquiry on incoming SSP */
#if (defined(BTA_HOST_INTERLEAVE_SEARCH) && BTA_HOST_INTERLEAVE_SEARCH == TRUE)
btm_inq_state next_state; /*interleaving state to determine next mode to be inquired*/
#endif
} tBTM_INQUIRY_VAR_ST;
/* The MSB of the clock offset field indicates that the offset is valid if TRUE */
@@ -863,8 +871,9 @@ typedef struct {
list_t *p_acl_db_list;
#if (CLASSIC_BT_INCLUDED == TRUE)
UINT8 btm_scn[BTM_MAX_SCN]; /* current SCNs: TRUE if SCN is in use */
#endif ///CLASSIC_BT_INCLUDED == TRUE
UINT16 btm_def_link_policy;
#endif ///CLASSIC_BT_INCLUDED == TRUE
UINT16 btm_def_link_super_tout;
tBTM_ACL_LINK_STAT_CB *p_acl_link_stat_cb; /* Callback for when ACL link related events came */
@@ -875,11 +884,12 @@ typedef struct {
/****************************************************
** Power Management
****************************************************/
#if (CLASSIC_BT_INCLUDED == TRUE)
list_t *p_pm_mode_db_list;
tBTM_PM_RCB pm_reg_db[BTM_MAX_PM_RECORDS + 1]; /* per application/module */
UINT16 pm_pend_link_hdl; /* the index of acl_db, which has a pending PM cmd */
UINT8 pm_pend_id; /* the id pf the module, which has a pending PM cmd */
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
/*****************************************************
** Device control
*****************************************************/
@@ -890,18 +900,22 @@ typedef struct {
*****************************************************/
#if (BLE_INCLUDED == TRUE)
tBTM_BLE_CB ble_ctr_cb;
#if (SMP_INCLUDED == TRUE)
UINT16 enc_handle;
BT_OCTET8 enc_rand; /* received rand value from LTK request*/
UINT16 ediv; /* received ediv value from LTK request */
UINT8 key_size;
tBTM_BLE_VSC_CB cmn_ble_vsc_cb;
#endif // (SMP_INCLUDED == TRUE)
#if ((SMP_INCLUDED == TRUE) || (BLE_PRIVACY_SPT == TRUE))
BOOLEAN addr_res_en; /* internal use for test: address resolution enable/disable */
#endif // ((SMP_INCLUDED == TRUE) || (BLE_PRIVACY_SPT == TRUE))
#endif
/* Packet types supported by the local device */
UINT16 btm_acl_pkt_types_supported;
#if (CLASSIC_BT_INCLUDED == TRUE)
UINT16 btm_sco_pkt_types_supported;
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
/*****************************************************
@@ -915,7 +929,7 @@ typedef struct {
#if BTM_SCO_INCLUDED == TRUE
tSCO_CB sco_cb;
#endif
#if (SMP_INCLUDED == TRUE)
/*****************************************************
** Security Management
*****************************************************/
@@ -924,18 +938,22 @@ typedef struct {
#define BTM_SEC_MAX_RMT_NAME_CALLBACKS 2
tBTM_RMT_NAME_CALLBACK *p_rmt_name_callback[BTM_SEC_MAX_RMT_NAME_CALLBACKS];
#endif // #if (SMP_INCLUDED == TRUE)
#if (SMP_INCLUDED == TRUE)
tBTM_SEC_DEV_REC *p_collided_dev_rec;
#endif ///SMP_INCLUDED == TRUE
UINT8 security_mode;
UINT32 dev_rec_count; /* Counter used for device record timestamp */
#if (SMP_INCLUDED == TRUE)
TIMER_LIST_ENT sec_collision_tle;
UINT32 collision_start_time;
UINT32 max_collision_delay;
UINT32 dev_rec_count; /* Counter used for device record timestamp */
UINT8 security_mode;
BOOLEAN pairing_disabled;
BOOLEAN connect_only_paired;
BOOLEAN security_mode_changed; /* mode changed during bonding */
BOOLEAN sec_req_pending; /* TRUE if a request is pending */
#endif // #if (SMP_INCLUDED == TRUE)
#if (CLASSIC_BT_INCLUDED == TRUE)
BOOLEAN pin_type_changed; /* pin type changed during bonding */
#endif ///CLASSIC_BT_INCLUDED == TRUE
@@ -952,10 +970,12 @@ typedef struct {
UINT8 disc_reason; /* for legacy devices */
UINT16 disc_handle; /* for legacy devices */
#endif ///CLASSIC_BT_INCLUDED == TRUE
#if (SMP_INCLUDED == TRUE)
tBTM_PAIRING_STATE pairing_state; /* The current pairing state */
UINT8 pairing_flags; /* The current pairing flags */
BD_ADDR pairing_bda; /* The device currently pairing */
TIMER_LIST_ENT pairing_tle; /* Timer for pairing process */
#endif // #if (SMP_INCLUDED == TRUE)
#endif ///SMP_INCLUDED == TRUE
#if SMP_INCLUDED == TRUE || CLASSIC_BT_INCLUDED == TRUE
@@ -971,12 +991,18 @@ typedef struct {
UINT8 acl_disc_reason;
UINT8 trace_level;
UINT8 busy_level; /* the current busy level */
#if (CLASSIC_BT_INCLUDED == TRUE)
BOOLEAN is_paging; /* TRUE, if paging is in progress */
BOOLEAN is_inquiry; /* TRUE, if inquiry is in progress */
fixed_queue_t *page_queue;
BOOLEAN paging;
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
#if (SMP_INCLUDED == TRUE && CLASSIC_BT_INCLUDED == TRUE)
BOOLEAN discing;
#endif // (SMP_INCLUDED == TRUE && CLASSIC_BT_INCLUDED == TRUE)
#if (SMP_INCLUDED == TRUE)
fixed_queue_t *sec_pending_q; /* pending sequrity requests in tBTM_SEC_QUEUE_ENTRY format */
#endif // (SMP_INCLUDED == TRUE)
#if (!defined(BT_TRACE_VERBOSE) || (BT_TRACE_VERBOSE == FALSE))
char state_temp_buffer[BTM_STATE_BUFFER_SIZE];
#endif
@@ -1025,8 +1025,9 @@ static void btu_hcif_encryption_change_evt (UINT8 *p)
STREAM_TO_UINT8 (status, p);
STREAM_TO_UINT16 (handle, p);
STREAM_TO_UINT8 (encr_enable, p);
#if (CLASSIC_BT_INCLUDED == TRUE)
btm_acl_encrypt_change (handle, status, encr_enable);
#endif // (CLASSIC_BT_INCLUDED == TRUE)
btm_sec_encrypt_change (handle, status, encr_enable);
}
#endif ///SMP_INCLUDED == TRUE
@@ -1211,22 +1212,25 @@ static void btu_hcif_hdl_command_complete (UINT16 opcode, UINT8 *p, UINT16 evt_l
break;
case HCI_GET_LINK_QUALITY:
#if (CLASSIC_BT_INCLUDED == TRUE)
btm_read_link_quality_complete (p);
#endif // (CLASSIC_BT_INCLUDED == TRUE)
break;
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
case HCI_READ_LOCAL_NAME:
#if (CLASSIC_BT_INCLUDED == TRUE)
btm_read_local_name_complete (p, evt_len);
#endif // (CLASSIC_BT_INCLUDED == TRUE)
break;
case HCI_READ_RSSI:
btm_read_rssi_complete (p, evt_len);
break;
case HCI_BLE_READ_CHNL_MAP:
#if BLE_INCLUDED == TRUE
btm_read_channel_map_complete (p);
#endif // #if BLE_INCLUDED == TRUE
break;
case HCI_READ_TRANSMIT_POWER_LEVEL:
#if (BLE_HOST_READ_TX_POWER_EN == TRUE)
btm_read_tx_power_complete(p, evt_len, FALSE);
#endif // #if (BLE_HOST_READ_TX_POWER_EN == TRUE)
break;
#if (CLASSIC_BT_INCLUDED == TRUE)
case HCI_CREATE_CONNECTION_CANCEL:
@@ -1306,9 +1310,6 @@ static void btu_hcif_hdl_command_complete (UINT16 opcode, UINT8 *p, UINT16 evt_l
break;
case HCI_BLE_READ_ADV_CHNL_TX_POWER:
#if (BLE_HOST_READ_TX_POWER_EN == TRUE)
btm_read_tx_power_complete(p, evt_len, TRUE);
#endif // #if (BLE_HOST_READ_TX_POWER_EN == TRUE)
break;
#if (BLE_42_ADV_EN == TRUE)
case HCI_BLE_WRITE_ADV_ENABLE:
@@ -1702,13 +1703,16 @@ static void btu_hcif_hdl_command_status (UINT16 opcode, UINT8 status, UINT8 *p_c
break;
case HCI_QOS_SETUP_COMP_EVT:
#if (CLASSIC_BT_INCLUDED == TRUE)
/* Tell qos setup that we are done */
btm_qos_setup_complete(status, 0, NULL);
#endif // (CLASSIC_BT_INCLUDED == TRUE)
break;
case HCI_SWITCH_ROLE:
/* Tell BTM that the command failed */
/* read bd addr out of stored command */
#if (CLASSIC_BT_INCLUDED == TRUE)
if (p_cmd != NULL) {
p_cmd++;
STREAM_TO_BDADDR (bd_addr, p_cmd);
@@ -1717,6 +1721,7 @@ static void btu_hcif_hdl_command_status (UINT16 opcode, UINT8 status, UINT8 *p_c
btm_acl_role_changed(status, NULL, BTM_ROLE_UNDEFINED);
}
l2c_link_role_changed (NULL, BTM_ROLE_UNDEFINED, HCI_ERR_COMMAND_DISALLOWED);
#endif // (CLASSIC_BT_INCLUDED == TRUE)
break;
case HCI_CREATE_CONNECTION:
@@ -315,7 +315,9 @@ static void btu_general_alarm_process(void *param)
switch (p_tle->event) {
case BTU_TTYPE_BTM_DEV_CTL:
#if (CLASSIC_BT_INCLUDED == TRUE)
btm_dev_timeout(p_tle);
#endif // (CLASSIC_BT_INCLUDED == TRUE)
break;
case BTU_TTYPE_L2CAP_LINK:
@@ -374,11 +376,15 @@ static void btu_general_alarm_process(void *param)
break;
case BTU_TTYPE_ATT_WAIT_FOR_RSP:
#if (GATTC_INCLUDED == TRUE)
gatt_rsp_timeout(p_tle);
#endif // (GATTC_INCLUDED == TRUE)
break;
case BTU_TTYPE_ATT_WAIT_FOR_IND_ACK:
#if (GATTC_INCLUDED == TRUE)
gatt_ind_ack_timeout(p_tle);
#endif // (GATTC_INCLUDED == TRUE)
break;
#if (defined(SMP_INCLUDED) && SMP_INCLUDED == TRUE)
@@ -128,8 +128,9 @@ typedef struct {
} tGAP_CLCB;
typedef struct {
#if (CLASSIC_BT_INCLUDED == TRUE)
tGAP_INFO blk[GAP_MAX_BLOCKS];
tBTM_CMPL_CB *btm_cback[GAP_MAX_BLOCKS];
#endif // (CLASSIC_BT_INCLUDED == TRUE)
UINT8 trace_level;
//tGAP_FINDADDR_CB findaddr_cb; /* Contains the control block for finding a device addr */
//tBTM_INQ_INFO *cur_inqptr;
@@ -1044,11 +1044,13 @@ tGATT_STATUS GATTC_Read (UINT16 conn_id, tGATT_READ_TYPE type, tGATT_READ_PARAM
default:
break;
}
#if (SMP_INCLUDED == TRUE)
/* start security check */
if (gatt_security_check_start(p_clcb) == FALSE) {
status = GATT_NO_RESOURCES;
gatt_clcb_dealloc(p_clcb);
}
#endif // (SMP_INCLUDED == TRUE)
} else {
status = GATT_NO_RESOURCES;
}
@@ -1108,10 +1110,11 @@ tGATT_STATUS GATTC_Write (UINT16 conn_id, tGATT_WRITE_TYPE type, tGATT_VALUE *p_
p_clcb->start_offset = p_write->offset;
p->offset = 0;
}
#if (SMP_INCLUDED == TRUE)
if (gatt_security_check_start(p_clcb) == FALSE) {
status = GATT_NO_RESOURCES;
}
#endif // (SMP_INCLUDED == TRUE)
} else {
status = GATT_NO_RESOURCES;
}
@@ -1388,13 +1391,9 @@ void GATT_Deregister (tGATT_IF gatt_if)
}
}
}
#if (tGATT_BG_CONN_DEV == TRUE)
#if (GATT_BG_CONN_DEV == TRUE)
gatt_deregister_bgdev_list(gatt_if);
#endif // #if (tGATT_BG_CONN_DEV == TRUE)
/* update the listen mode */
#if (defined(BLE_PERIPHERAL_MODE_SUPPORT) && (BLE_PERIPHERAL_MODE_SUPPORT == TRUE))
GATT_Listen(gatt_if, FALSE, NULL);
#endif
#endif // #if (GATT_BG_CONN_DEV == TRUE)
memset (p_reg, 0, sizeof(tGATT_REG));
}
@@ -1470,11 +1469,11 @@ BOOLEAN GATT_Connect (tGATT_IF gatt_if, BD_ADDR bd_addr, tBLE_ADDR_TYPE bd_addr_
if (is_direct) {
status = gatt_act_connect (p_reg, bd_addr, bd_addr_type, transport, is_aux, is_pawr_synced, adv_handle, subevent);
} else {
#if (tGATT_BG_CONN_DEV == TRUE)
#if (GATT_BG_CONN_DEV == TRUE)
if (transport == BT_TRANSPORT_LE) {
status = gatt_update_auto_connect_dev(gatt_if, TRUE, bd_addr, TRUE);
} else
#endif // #if (tGATT_BG_CONN_DEV == TRUE)
#endif // #if (GATT_BG_CONN_DEV == TRUE)
{
GATT_TRACE_ERROR("Unsupported transport for background connection");
}
@@ -1532,7 +1531,7 @@ BOOLEAN GATT_CancelConnect (tGATT_IF gatt_if, BD_ADDR bd_addr, BOOLEAN is_direct
status = gatt_cancel_open(gatt_if, bd_addr);
}
} else {
#if (tGATT_BG_CONN_DEV == TRUE)
#if (GATT_BG_CONN_DEV == TRUE)
if (!gatt_if) {
if (gatt_get_num_apps_for_bg_dev(bd_addr)) {
while (gatt_find_app_for_bg_dev(bd_addr, &temp_gatt_if)) {
@@ -1545,7 +1544,7 @@ BOOLEAN GATT_CancelConnect (tGATT_IF gatt_if, BD_ADDR bd_addr, BOOLEAN is_direct
} else {
status = gatt_remove_bg_dev_for_app(gatt_if, bd_addr);
}
#endif // #if (tGATT_BG_CONN_DEV == TRUE)
#endif // #if (GATT_BG_CONN_DEV == TRUE)
}
return status;
@@ -1584,6 +1583,7 @@ tGATT_STATUS GATT_Disconnect (UINT16 conn_id)
return ret;
}
#if (GATTS_INCLUDED == TRUE)
/*******************************************************************************
**
** Function GATT_SendServiceChangeIndication
@@ -1630,6 +1630,7 @@ tGATT_STATUS GATT_SendServiceChangeIndication (BD_ADDR bd_addr)
return status;
}
#endif // (GATTS_INCLUDED == TRUE)
/*******************************************************************************
**
@@ -1698,45 +1699,7 @@ BOOLEAN GATT_GetConnIdIfConnected(tGATT_IF gatt_if, BD_ADDR bd_addr, UINT16 *p_c
return status;
}
/*******************************************************************************
**
** Function GATT_Listen
**
** Description This function start or stop LE advertisement and listen for
** connection.
**
** Parameters gatt_if: application interface
** p_bd_addr: listen for specific address connection, or NULL for
** listen to all device connection.
** start: start or stop listening.
**
** Returns TRUE if advertisement is started; FALSE if adv start failure.
**
*******************************************************************************/
BOOLEAN GATT_Listen (tGATT_IF gatt_if, BOOLEAN start, BD_ADDR_PTR bd_addr)
{
tGATT_REG *p_reg;
GATT_TRACE_API ("GATT_Listen gatt_if=%d", gatt_if);
/* Make sure app is registered */
if ((p_reg = gatt_get_regcb(gatt_if)) == NULL) {
GATT_TRACE_ERROR("GATT_Listen - gatt_if =%d is not registered", gatt_if);
return (FALSE);
}
if (bd_addr != NULL) {
#if (tGATT_BG_CONN_DEV == TRUE)
gatt_update_auto_connect_dev(gatt_if, start, bd_addr, FALSE);
#endif // #if (tGATT_BG_CONN_DEV == TRUE)
} else {
p_reg->listening = start ? GATT_LISTEN_TO_ALL : GATT_LISTEN_TO_NONE;
}
return gatt_update_listen_mode();
}
#if (GATTS_INCLUDED == TRUE)
tGATT_STATUS GATTS_SetServiceChangeMode(UINT8 mode)
{
if (mode > GATTS_SEND_SERVICE_CHANGE_MANUAL) {
@@ -1748,6 +1711,8 @@ tGATT_STATUS GATTS_SetServiceChangeMode(UINT8 mode)
return GATT_SUCCESS;
}
#endif // (GATTS_INCLUDED == TRUE)
tGATT_STATUS GATTS_HandleMultiValueNotification (UINT16 conn_id, tGATT_HLV *tuples, UINT16 num_tuples)
{
tGATT_STATUS cmd_sent = GATT_ILLEGAL_PARAMETER;
@@ -129,6 +129,8 @@ void gatt_verify_signature(tGATT_TCB *p_tcb, BT_HDR *p_buf)
}
#endif ///SMP_INCLUDED == TRUE
#if (SMP_INCLUDED == TRUE)
/*******************************************************************************
**
** Function gatt_sec_check_complete
@@ -155,6 +157,7 @@ void gatt_sec_check_complete(BOOLEAN sec_check_ok, tGATT_CLCB *p_clcb, UINT8 s
#endif ///GATTC_INCLUDED == TRUE
}
}
/*******************************************************************************
**
** Function gatt_enc_cmpl_cback
@@ -253,6 +256,7 @@ void gatt_notify_enc_cmpl(BD_ADDR bd_addr)
}
return;
}
/*******************************************************************************
**
** Function gatt_set_sec_act
@@ -268,6 +272,7 @@ void gatt_set_sec_act(tGATT_TCB *p_tcb, tGATT_SEC_ACTION sec_act)
p_tcb->sec_act = sec_act;
}
}
/*******************************************************************************
**
** Function gatt_get_sec_act
@@ -285,6 +290,7 @@ tGATT_SEC_ACTION gatt_get_sec_act(tGATT_TCB *p_tcb)
}
return sec_act;
}
#endif // (SMP_INCLUDED == TRUE)
/*******************************************************************************
**
** Function gatt_determine_sec_act
@@ -420,7 +426,7 @@ tGATT_STATUS gatt_get_link_encrypt_status(tGATT_TCB *p_tcb)
return encrypt_status ;
}
#if (SMP_INCLUDED == TRUE)
/*******************************************************************************
**
** Function gatt_convert_sec_action
@@ -450,6 +456,7 @@ static BOOLEAN gatt_convert_sec_action(tGATT_SEC_ACTION gatt_sec_act, tBTM_BLE_S
return status;
}
/*******************************************************************************
**
** Function gatt_check_enc_req
@@ -517,6 +524,6 @@ BOOLEAN gatt_security_check_start(tGATT_CLCB *p_clcb)
return status;
}
#endif // (SMP_INCLUDED == TRUE)
#endif /* BLE_INCLUDED */
@@ -102,8 +102,9 @@ void gatt_init (void)
#endif /* #if GATT_DYNAMIC_MEMORY */
memset (&gatt_cb, 0, sizeof(tGATT_CB));
memset (&fixed_reg, 0, sizeof(tL2CAP_FIXED_CHNL_REG));
#if (GATTC_INCLUDED == TRUE)
gatt_cb.auto_disc = TRUE;
#endif // (GATTC_INCLUDED == TRUE)
gatt_cb.p_clcb_list = list_new(osi_free_func);
gatt_cb.p_tcb_list = list_new(osi_free_func);
#if defined(GATT_INITIAL_TRACE_LEVEL)
@@ -111,11 +112,11 @@ void gatt_init (void)
#else
gatt_cb.trace_level = BT_TRACE_LEVEL_NONE; /* No traces */
#endif
gatt_cb.def_mtu_size = GATT_DEF_BLE_MTU_SIZE;
gatt_cb.sign_op_queue = fixed_queue_new(QUEUE_SIZE_MAX);
#if (GATTS_INCLUDED == TRUE)
gatt_cb.srv_chg_clt_q = fixed_queue_new(QUEUE_SIZE_MAX);
gatt_cb.pending_new_srv_start_q = fixed_queue_new(QUEUE_SIZE_MAX);
gatt_cb.srv_chg_mode = GATTS_SEND_SERVICE_CHANGE_MODE;
#endif // (GATTS_INCLUDED == TRUE)
/* First, register fixed L2CAP channel for ATT over BLE */
fixed_reg.fixed_chnl_opts.mode = L2CAP_FCR_BASIC_MODE;
@@ -140,11 +141,10 @@ void gatt_init (void)
#endif ///CLASSIC_BT_GATT_INCLUDED == TRUE
BTM_SetSecurityLevel(TRUE, "", BTM_SEC_SERVICE_ATT, BTM_SEC_NONE, BT_PSM_ATT, 0, 0);
BTM_SetSecurityLevel(FALSE, "", BTM_SEC_SERVICE_ATT, BTM_SEC_NONE, BT_PSM_ATT, 0, 0);
#if (GATTS_INCLUDED == TRUE)
gatt_cb.hdl_cfg.gatt_start_hdl = GATT_GATT_START_HANDLE;
gatt_cb.hdl_cfg.gap_start_hdl = GATT_GAP_START_HANDLE;
gatt_cb.hdl_cfg.app_start_hdl = GATT_APP_START_HANDLE;
#if (GATTS_INCLUDED == TRUE)
gatt_profile_db_init();
#endif ///GATTS_INCLUDED == TRUE
//init local MTU size
@@ -165,28 +165,30 @@ void gatt_init (void)
void gatt_free(void)
{
GATT_TRACE_DEBUG("gatt_free()");
fixed_queue_free(gatt_cb.sign_op_queue, NULL);
gatt_cb.sign_op_queue = NULL;
#if (GATTS_INCLUDED == TRUE)
fixed_queue_free(gatt_cb.srv_chg_clt_q, NULL);
gatt_cb.srv_chg_clt_q = NULL;
fixed_queue_free(gatt_cb.pending_new_srv_start_q, osi_free_func);
gatt_cb.pending_new_srv_start_q = NULL;
#endif // (GATTS_INCLUDED == TRUE)
list_node_t *p_node = NULL;
tGATT_TCB *p_tcb = NULL;
for(p_node = list_begin(gatt_cb.p_tcb_list); p_node; p_node = list_next(p_node)) {
p_tcb = list_node(p_node);
#if (SMP_INCLUDED == TRUE)
fixed_queue_free(p_tcb->pending_enc_clcb, NULL);
p_tcb->pending_enc_clcb = NULL;
fixed_queue_free(p_tcb->pending_ind_q, NULL);
p_tcb->pending_ind_q = NULL;
#endif // (SMP_INCLUDED == TRUE)
#if (GATTS_INCLUDED == TRUE)
btu_free_timer(&p_tcb->conf_timer_ent);
memset(&p_tcb->conf_timer_ent, 0, sizeof(TIMER_LIST_ENT));
#endif // (GATTS_INCLUDED == TRUE)
#if (GATTC_INCLUDED == TRUE)
btu_free_timer(&p_tcb->ind_ack_timer_ent);
memset(&p_tcb->ind_ack_timer_ent, 0, sizeof(TIMER_LIST_ENT));
#endif // #if (GATTC_INCLUDED == TRUE)
#if (GATTS_INCLUDED == TRUE)
fixed_queue_free(p_tcb->sr_cmd.multi_rsp_q, NULL);
@@ -411,12 +413,11 @@ BOOLEAN gatt_act_connect (tGATT_REG *p_reg, BD_ADDR bd_addr,
// but here p_tcb is get from gatt_allocate_tcb_by_bdaddr(), is too old, so we get p_tcb again
p_tcb = gatt_find_tcb_by_addr(bd_addr, transport);
if(p_tcb != NULL) {
#if (SMP_INCLUDED == TRUE)
if(p_tcb->pending_enc_clcb != NULL) {
fixed_queue_free(p_tcb->pending_enc_clcb, NULL);
}
if(p_tcb->pending_ind_q != NULL) {
fixed_queue_free(p_tcb->pending_ind_q, NULL);
}
#endif // (SMP_INCLUDED == TRUE)
gatt_tcb_free(p_tcb);
}
@@ -450,8 +451,10 @@ static void gatt_le_connect_cback (UINT16 chan, BD_ADDR bd_addr, BOOLEAN connect
{
tGATT_TCB *p_tcb = gatt_find_tcb_by_addr(bd_addr, transport);
#if (GATTS_INCLUDED == TRUE)
BOOLEAN check_srv_chg = FALSE;
tGATTS_SRV_CHG *p_srv_chg_clt = NULL;
#endif // (GATTS_INCLUDED == TRUE)
/* ignore all fixed channel connect/disconnect on BR/EDR link for GATT */
if (transport == BT_TRANSPORT_BR_EDR) {
@@ -461,7 +464,7 @@ static void gatt_le_connect_cback (UINT16 chan, BD_ADDR bd_addr, BOOLEAN connect
GATT_TRACE_DEBUG ("GATT ATT protocol channel with BDA: %08x%04x is %s",
(bd_addr[0] << 24) + (bd_addr[1] << 16) + (bd_addr[2] << 8) + bd_addr[3],
(bd_addr[4] << 8) + bd_addr[5], (connected) ? "connected" : "disconnected");
#if (GATTS_INCLUDED == TRUE)
if ((p_srv_chg_clt = gatt_is_bda_in_the_srv_chg_clt_list(bd_addr)) != NULL) {
check_srv_chg = TRUE;
} else {
@@ -469,6 +472,7 @@ static void gatt_le_connect_cback (UINT16 chan, BD_ADDR bd_addr, BOOLEAN connect
gatt_add_a_bonded_dev_for_srv_chg(bd_addr);
}
}
#endif // #if (GATTS_INCLUDED == TRUE)
if (connected) {
/* do we have a channel initiating a connection? */
@@ -481,11 +485,11 @@ static void gatt_le_connect_cback (UINT16 chan, BD_ADDR bd_addr, BOOLEAN connect
gatt_send_conn_cback(p_tcb);
}
if (check_srv_chg) {
#if (GATTS_INCLUDED == TRUE)
if (check_srv_chg) {
gatt_chk_srv_chg (p_srv_chg_clt);
#endif ///GATTS_INCLUDED == TRUE
}
#endif ///GATTS_INCLUDED == TRUE
}
/* this is incoming connection or background connection callback */
@@ -498,11 +502,11 @@ static void gatt_le_connect_cback (UINT16 chan, BD_ADDR bd_addr, BOOLEAN connect
p_tcb->payload_size = GATT_DEF_BLE_MTU_SIZE;
gatt_send_conn_cback (p_tcb);
if (check_srv_chg) {
#if (GATTS_INCLUDED == TRUE)
if (check_srv_chg) {
gatt_chk_srv_chg (p_srv_chg_clt);
#endif ///GATTS_INCLUDED == TRUE
}
#endif ///GATTS_INCLUDED == TRUE
} else {
GATT_TRACE_ERROR("CCB max out, no resources");
}
@@ -931,23 +935,23 @@ static void gatt_send_conn_cback(tGATT_TCB *p_tcb)
{
UINT8 i;
tGATT_REG *p_reg;
#if (tGATT_BG_CONN_DEV == TRUE)
#if (GATT_BG_CONN_DEV == TRUE)
tGATT_BG_CONN_DEV *p_bg_dev = NULL;
#endif // #if (tGATT_BG_CONN_DEV == TRUE)
#endif // #if (GATT_BG_CONN_DEV == TRUE)
UINT16 conn_id;
#if (tGATT_BG_CONN_DEV == TRUE)
#if (GATT_BG_CONN_DEV == TRUE)
p_bg_dev = gatt_find_bg_dev(p_tcb->peer_bda);
#endif // #if (tGATT_BG_CONN_DEV == TRUE)
#endif // #if (GATT_BG_CONN_DEV == TRUE)
/* notifying all applications for the connection up event */
for (i = 0, p_reg = gatt_cb.cl_rcb ; i < GATT_MAX_APPS; i++, p_reg++) {
if (p_reg->in_use) {
#if (tGATT_BG_CONN_DEV == TRUE)
#if (GATT_BG_CONN_DEV == TRUE)
if (p_bg_dev && gatt_is_bg_dev_for_app(p_bg_dev, p_reg->gatt_if)) {
gatt_update_app_use_link_flag(p_reg->gatt_if, p_tcb, TRUE, TRUE);
}
#endif // #if (tGATT_BG_CONN_DEV == TRUE)
#endif // #if (GATT_BG_CONN_DEV == TRUE)
if (p_reg->app_cb.p_conn_cb) {
conn_id = GATT_CREATE_CONN_ID(p_tcb->tcb_idx, p_reg->gatt_if);
(*p_reg->app_cb.p_conn_cb)(p_reg->gatt_if, p_tcb->peer_bda, conn_id,
@@ -1633,33 +1633,6 @@ static void gatts_proc_srv_chg_ind_ack(tGATT_TCB *p_tcb )
}
}
/*******************************************************************************
**
** Function gatts_chk_pending_ind
**
** Description This function check any pending indication needs to be sent if
** there is a pending indication then sent the indication
**
** Returns void
**
*******************************************************************************/
static void gatts_chk_pending_ind(tGATT_TCB *p_tcb )
{
#if (GATTS_INCLUDED == TRUE)
tGATT_VALUE *p_buf = (tGATT_VALUE *)fixed_queue_try_peek_first(p_tcb->pending_ind_q);
GATT_TRACE_DEBUG("gatts_chk_pending_ind");
if (p_buf ) {
GATTS_HandleValueIndication (p_buf->conn_id,
p_buf->handle,
p_buf->len,
p_buf->value);
osi_free(fixed_queue_try_remove_from_queue(p_tcb->pending_ind_q,
p_buf));
}
#endif ///GATTS_INCLUDED == TRUE
}
/*******************************************************************************
**
** Function gatts_proc_ind_ack
@@ -1686,7 +1659,6 @@ static BOOLEAN gatts_proc_ind_ack(tGATT_TCB *p_tcb, UINT16 ack_handle)
#endif /* GATTS_ROBUST_CACHING_ENABLED */
}
gatts_chk_pending_ind(p_tcb);
return continue_processing;
}
@@ -80,30 +80,7 @@ static const UINT8 base_uuid[LEN_UUID_128] = {0xFB, 0x34, 0x9B, 0x5F, 0x80, 0x0
static UINT8 gatt_tcb_id[GATT_MAX_PHY_CHANNEL / 8 + 1];
/*******************************************************************************
**
** Function gatt_free_pending_ind
**
** Description Free all pending indications
**
** Returns None
**
*******************************************************************************/
void gatt_free_pending_ind(tGATT_TCB *p_tcb)
{
GATT_TRACE_DEBUG("gatt_free_pending_ind");
if (p_tcb->pending_ind_q == NULL) {
return;
}
/* release all queued indications */
while (!fixed_queue_is_empty(p_tcb->pending_ind_q)) {
osi_free(fixed_queue_dequeue(p_tcb->pending_ind_q, 0));
}
fixed_queue_free(p_tcb->pending_ind_q, NULL);
p_tcb->pending_ind_q = NULL;
}
#if (SMP_INCLUDED == TRUE)
/*******************************************************************************
**
** Function gatt_free_pending_enc_queue
@@ -127,7 +104,8 @@ void gatt_free_pending_enc_queue(tGATT_TCB *p_tcb)
fixed_queue_free(p_tcb->pending_enc_clcb, NULL);
p_tcb->pending_enc_clcb = NULL;
}
#endif // (SMP_INCLUDED == TRUE)
#if (GATTS_INCLUDED == TRUE)
/*******************************************************************************
**
** Function gatt_free_pending_prepare_write_queue
@@ -153,7 +131,9 @@ void gatt_free_pending_prepare_write_queue(tGATT_TCB *p_tcb)
p_tcb->prepare_write_record.total_num = 0;
p_tcb->prepare_write_record.error_code_app = GATT_SUCCESS;
}
#endif // (GATTS_INCLUDED == TRUE)
#if (GATTS_INCLUDED == TRUE)
/*******************************************************************************
**
** Function gatt_delete_dev_from_srv_chg_clt_list
@@ -248,30 +228,9 @@ tGATTS_PENDING_NEW_SRV_START *gatt_sr_is_new_srv_chg(tBT_UUID *p_app_uuid128, tB
return p_buf;
}
#endif // (GATTS_INCLUDED == TRUE)
/*******************************************************************************
**
** Function gatt_add_pending_ind
**
** Description Add a pending indication
**
** Returns Pointer to the current pending indication buffer, NULL no buffer available
**
*******************************************************************************/
tGATT_VALUE *gatt_add_pending_ind(tGATT_TCB *p_tcb, tGATT_VALUE *p_ind)
{
tGATT_VALUE *p_buf;
GATT_TRACE_DEBUG ("gatt_add_pending_ind");
if ((p_buf = (tGATT_VALUE *)osi_malloc((UINT16)sizeof(tGATT_VALUE))) != NULL) {
GATT_TRACE_DEBUG ("enqueue a pending indication");
memcpy(p_buf, p_ind, sizeof(tGATT_VALUE));
fixed_queue_enqueue(p_tcb->pending_ind_q, p_buf, FIXED_QUEUE_MAX_TIMEOUT);
}
return p_buf;
}
#if (GATTS_INCLUDED == TRUE)
/*******************************************************************************
**
** Function gatt_add_pending_new_srv_start
@@ -327,7 +286,7 @@ tGATTS_SRV_CHG *gatt_add_srv_chg_clt(tGATTS_SRV_CHG *p_srv_chg)
** Returns Pointer to the allocated buffer, NULL no buffer available
**
*******************************************************************************/
#if (GATTS_INCLUDED == TRUE)
tGATT_HDL_LIST_ELEM *gatt_alloc_hdl_buffer(void)
{
UINT8 i;
@@ -803,7 +762,7 @@ BOOLEAN gatt_find_the_connected_bda(UINT8 start_idx, BD_ADDR bda, UINT8 *p_found
return found;
}
#if (GATTS_INCLUDED == TRUE)
/*******************************************************************************
**
** Function gatt_is_srv_chg_ind_pending
@@ -818,23 +777,10 @@ BOOLEAN gatt_is_srv_chg_ind_pending (tGATT_TCB *p_tcb)
{
BOOLEAN srv_chg_ind_pending = FALSE;
GATT_TRACE_DEBUG("gatt_is_srv_chg_ind_pending is_queue_empty=%d",
fixed_queue_is_empty(p_tcb->pending_ind_q));
GATT_TRACE_DEBUG("gatt_is_srv_chg_ind_pending is_queue_empty=%d_%d", p_tcb->indicate_handle, gatt_cb.handle_of_h_r);
if (p_tcb->indicate_handle == gatt_cb.handle_of_h_r) {
srv_chg_ind_pending = TRUE;
} else if (! fixed_queue_is_empty(p_tcb->pending_ind_q)) {
list_t *list = fixed_queue_get_list(p_tcb->pending_ind_q);
for (const list_node_t *node = list_begin(list);
node != list_end(list);
node = list_next(node)) {
tGATT_VALUE *p_buf = (tGATT_VALUE *)list_node(node);
if (p_buf->handle == gatt_cb.handle_of_h_r)
{
srv_chg_ind_pending = TRUE;
break;
}
}
}
GATT_TRACE_DEBUG("srv_chg_ind_pending = %d", srv_chg_ind_pending);
@@ -874,7 +820,7 @@ tGATTS_SRV_CHG *gatt_is_bda_in_the_srv_chg_clt_list (BD_ADDR bda)
return p_buf;
}
#endif // (GATTS_INCLUDED == TRUE)
/*******************************************************************************
**
@@ -1083,8 +1029,9 @@ tGATT_TCB *gatt_allocate_tcb_by_bdaddr(BD_ADDR bda, tBT_TRANSPORT transport)
}
if (allocated) {
memset(p_tcb, 0, sizeof(tGATT_TCB));
#if (SMP_INCLUDED == TRUE)
p_tcb->pending_enc_clcb = fixed_queue_new(QUEUE_SIZE_MAX);
p_tcb->pending_ind_q = fixed_queue_new(QUEUE_SIZE_MAX);
#endif // (SMP_INCLUDED == TRUE)
p_tcb->in_use = TRUE;
p_tcb->tcb_idx = i;
p_tcb->transport = transport;
@@ -1300,6 +1247,8 @@ void gatt_start_rsp_timer(UINT16 clcb_idx)
btu_start_timer (&p_clcb->rsp_timer_ent, BTU_TTYPE_ATT_WAIT_FOR_RSP,
GATT_WAIT_FOR_RSP_TOUT);
}
#if (GATTS_INCLUDED == TRUE)
/*******************************************************************************
**
** Function gatt_start_conf_timer
@@ -1315,6 +1264,9 @@ void gatt_start_conf_timer(tGATT_TCB *p_tcb)
btu_start_timer (&p_tcb->conf_timer_ent, BTU_TTYPE_ATT_WAIT_FOR_RSP,
GATT_WAIT_FOR_RSP_TOUT);
}
#endif // (GATTS_INCLUDED == TRUE)
#if (GATTC_INCLUDED == TRUE)
/*******************************************************************************
**
** Function gatt_start_ind_ack_timer
@@ -1332,6 +1284,7 @@ void gatt_start_ind_ack_timer(tGATT_TCB *p_tcb)
GATT_WAIT_FOR_IND_ACK_TOUT);
}
/*******************************************************************************
**
** Function gatt_rsp_timeout
@@ -1390,6 +1343,9 @@ void gatt_ind_ack_timeout(TIMER_LIST_ENT *p_tle)
attp_send_cl_msg(((tGATT_TCB *)p_tle->param), 0, GATT_HANDLE_VALUE_CONF, NULL);
}
#endif // (GATTC_INCLUDED == TRUE)
#if (GATTS_INCLUDED == TRUE)
/*******************************************************************************
**
** Function gatt_sr_find_i_rcb_by_handle
@@ -1422,7 +1378,7 @@ UINT8 gatt_sr_find_i_rcb_by_handle(UINT16 handle)
** Returns GATT_MAX_SR_PROFILES if not found. Otherwise index of th eservice.
**
*******************************************************************************/
#if (GATTS_INCLUDED == TRUE)
UINT8 gatt_sr_find_i_rcb_by_app_id(tBT_UUID *p_app_uuid128, tBT_UUID *p_svc_uuid, UINT16 svc_inst)
{
UINT8 i_rcb = 0;
@@ -1446,7 +1402,7 @@ UINT8 gatt_sr_find_i_rcb_by_app_id(tBT_UUID *p_app_uuid128, tBT_UUID *p_svc_uuid
}
return i_rcb;
}
#endif ///GATTS_INCLUDED == TRUE
/*******************************************************************************
**
** Function gatt_sr_find_i_rcb_by_handle
@@ -1482,6 +1438,7 @@ UINT8 gatt_sr_alloc_rcb(tGATT_HDL_LIST_ELEM *p_list )
return ii;
}
#endif ///GATTS_INCLUDED == TRUE
/*******************************************************************************
**
** Function gatt_sr_get_sec_info
@@ -2145,6 +2102,7 @@ BOOLEAN gatt_find_specific_app_in_hold_link(tGATT_TCB *p_tcb, tGATT_IF p_gatt_if
return found;
}
#if (GATTC_INCLUDED == TRUE)
/*******************************************************************************
**
** Function gatt_cmd_enq
@@ -2198,6 +2156,7 @@ tGATT_CLCB *gatt_cmd_dequeue(tGATT_TCB *p_tcb, UINT8 *p_op_code)
return p_clcb;
}
#endif // (GATTC_INCLUDED == TRUE)
/*******************************************************************************
**
@@ -2366,16 +2325,22 @@ void gatt_cleanup_upon_disc(BD_ADDR bda, UINT16 reason, tBT_TRANSPORT transport)
gatt_clcb_dealloc(p_clcb);
}
}
#if (GATTC_INCLUDED == TRUE)
btu_free_timer (&p_tcb->ind_ack_timer_ent);
#endif // #if (GATTC_INCLUDED == TRUE)
#if (GATTS_INCLUDED == TRUE)
btu_free_timer (&p_tcb->conf_timer_ent);
gatt_free_pending_ind(p_tcb);
#endif // (GATTS_INCLUDED == TRUE)
#if (SMP_INCLUDED == TRUE)
gatt_free_pending_enc_queue(p_tcb);
#endif // (SMP_INCLUDED == TRUE)
#if (GATTS_INCLUDED == TRUE)
gatt_free_pending_prepare_write_queue(p_tcb);
#if (GATTS_INCLUDED)
#endif // (GATTS_INCLUDED == TRUE)
#if (GATTS_INCLUDED == TRUE)
fixed_queue_free(p_tcb->sr_cmd.multi_rsp_q, osi_free_func);
p_tcb->sr_cmd.multi_rsp_q = NULL;
#endif /* #if (GATTS_INCLUDED) */
#endif /* #if (GATTS_INCLUDED == TRUE) */
for (i = 0; i < GATT_MAX_APPS; i ++) {
p_reg = &gatt_cb.cl_rcb[i];
if (p_reg->in_use && p_reg->app_cb.p_conn_cb) {
@@ -2389,7 +2354,9 @@ void gatt_cleanup_upon_disc(BD_ADDR bda, UINT16 reason, tBT_TRANSPORT transport)
GATT_TRACE_DEBUG ("exit gatt_cleanup_upon_disc ");
BTM_Recovery_Pre_State();
}
#if (GATTS_INCLUDED == TRUE)
gatt_delete_dev_from_srv_chg_clt_list(bda);
#endif // (GATTS_INCLUDED == TRUE)
}
/*******************************************************************************
**
@@ -2457,7 +2424,7 @@ void gatt_dbg_display_uuid(tBT_UUID bt_uuid)
}
#if (tGATT_BG_CONN_DEV == TRUE)
#if (GATT_BG_CONN_DEV == TRUE)
/*******************************************************************************
**
** Function gatt_is_bg_dev_for_app
@@ -2838,9 +2805,9 @@ BOOLEAN gatt_update_auto_connect_dev (tGATT_IF gatt_if, BOOLEAN add, BD_ADDR bd_
}
return ret;
}
#endif // #if (tGATT_BG_CONN_DEV == TRUE)
#endif // #if (GATT_BG_CONN_DEV == TRUE)
#if (SMP_INCLUDED == TRUE)
/*******************************************************************************
**
** Function gatt_add_pending_new_srv_start
@@ -2858,57 +2825,11 @@ tGATT_PENDING_ENC_CLCB *gatt_add_pending_enc_channel_clcb(tGATT_TCB *p_tcb, tGAT
if ((p_buf = (tGATT_PENDING_ENC_CLCB *)osi_malloc((UINT16)sizeof(tGATT_PENDING_ENC_CLCB))) != NULL) {
GATT_TRACE_DEBUG ("enqueue a new pending encryption channel clcb");
p_buf->p_clcb = p_clcb;
fixed_queue_enqueue(p_tcb->pending_enc_clcb, p_buf, FIXED_QUEUE_MAX_TIMEOUT);
fixed_queue_enqueue(p_tcb->pending_enc_clcb, p_buf, FIXED_QUEUE_MAX_TIMEOUT);
}
return p_buf;
}
/*******************************************************************************
**
** Function gatt_update_listen_mode
**
** Description update peripheral role listening mode
**
** Returns Pointer to the new service start buffer, NULL no buffer available
**
*******************************************************************************/
BOOLEAN gatt_update_listen_mode(void)
{
UINT8 ii = 0;
tGATT_REG *p_reg = &gatt_cb.cl_rcb[0];
UINT8 listening = 0;
UINT16 connectability, window, interval;
BOOLEAN rt = TRUE;
for (; ii < GATT_MAX_APPS; ii ++, p_reg ++) {
if ( p_reg->in_use && p_reg->listening > listening) {
listening = p_reg->listening;
}
}
if (listening == GATT_LISTEN_TO_ALL ||
listening == GATT_LISTEN_TO_NONE) {
BTM_BleUpdateAdvFilterPolicy (AP_SCAN_CONN_ALL);
} else {
BTM_BleUpdateAdvFilterPolicy (AP_SCAN_CONN_WL);
}
if (rt) {
connectability = BTM_ReadConnectability (&window, &interval);
if (listening != GATT_LISTEN_TO_NONE) {
connectability |= BTM_BLE_CONNECTABLE;
} else {
if ((connectability & BTM_BLE_CONNECTABLE) == 0) {
connectability &= ~BTM_BLE_CONNECTABLE;
}
}
/* turning on the adv now */
btm_ble_set_connectability(connectability);
}
return rt;
}
#endif // (SMP_INCLUDED == TRUE)
char *gatt_uuid_to_str(const tBT_UUID *uuid)
{
@@ -376,8 +376,11 @@ typedef struct{
}tGATT_PREPARE_WRITE_RECORD;
typedef struct {
#if (SMP_INCLUDED == TRUE)
fixed_queue_t *pending_enc_clcb; /* pending encryption channel q */
tGATT_SEC_ACTION sec_act;
#endif // (SMP_INCLUDED == TRUE)
BD_ADDR peer_bda;
tBT_TRANSPORT transport;
UINT32 trans_id;
@@ -394,30 +397,33 @@ typedef struct {
/* server response data */
#if (GATTS_INCLUDED == TRUE)
tGATT_SR_CMD sr_cmd;
#endif ///GATTS_INCLUDED == TRUE
UINT16 indicate_handle;
fixed_queue_t *pending_ind_q;
TIMER_LIST_ENT conf_timer_ent; /* peer confirm to indication timer */
#endif ///GATTS_INCLUDED == TRUE
UINT8 prep_cnt[GATT_MAX_APPS];
#if (GATTC_INCLUDED == TRUE)
UINT8 ind_count;
tGATT_CMD_Q cl_cmd_q[GATT_CL_MAX_LCB];
TIMER_LIST_ENT ind_ack_timer_ent; /* local app confirm to indication timer */
#endif // (GATTC_INCLUDED == TRUE)
UINT8 pending_cl_req;
UINT8 next_slot_inq; /* index of next available slot in queue */
#if (GATTS_ROBUST_CACHING_ENABLED == TRUE)
/* client supported feature */
UINT8 cl_supp_feat;
/* server supported feature */
UINT8 sr_supp_feat;
/* if false, should handle database out of sync */
BOOLEAN is_robust_cache_change_aware;
#endif // (GATTS_ROBUST_CACHING_ENABLED == TRUE)
BOOLEAN in_use;
UINT8 tcb_idx;
#if (GATTS_INCLUDED == TRUE)
tGATT_PREPARE_WRITE_RECORD prepare_write_record; /* prepare write packets record */
#endif // (GATTS_INCLUDED == TRUE)
} tGATT_TCB;
@@ -483,14 +489,14 @@ typedef struct {
UINT32 service_change;
} tGATT_SVC_CHG;
#if (tGATT_BG_CONN_DEV == TRUE)
#if (GATT_BG_CONN_DEV == TRUE)
typedef struct {
tGATT_IF gatt_if[GATT_MAX_APPS];
tGATT_IF listen_gif[GATT_MAX_APPS];
BD_ADDR remote_bda;
BOOLEAN in_use;
} tGATT_BG_CONN_DEV;
#endif // #if (tGATT_BG_CONN_DEV == TRUE)
#endif // #if (GATT_BG_CONN_DEV == TRUE)
#define GATT_SVC_CHANGED_CONNECTING 1 /* wait for connection */
#define GATT_SVC_CHANGED_SERVICE 2 /* GATT service discovery */
@@ -514,11 +520,11 @@ typedef struct {
typedef struct {
list_t *p_tcb_list;
fixed_queue_t *sign_op_queue;
#if (GATTS_INCLUDED == TRUE)
tGATT_SR_REG sr_reg[GATT_MAX_SR_PROFILES];
UINT16 next_handle; /* next available handle */
tGATT_SVC_CHG gattp_attr; /* GATT profile attribute service change */
#endif // (GATTS_INCLUDED == TRUE)
tGATT_IF gatt_if;
#if (GATTS_INCLUDED == TRUE)
tGATT_HDL_LIST_INFO hdl_list_info;
@@ -526,13 +532,13 @@ typedef struct {
tGATT_SRV_LIST_INFO srv_list_info;
tGATT_SRV_LIST_ELEM srv_list[GATT_MAX_SR_PROFILES];
#endif ///GATTS_INCLUDED == TRUE
#if (GATTS_INCLUDED == TRUE)
fixed_queue_t *srv_chg_clt_q; /* service change clients queue */
fixed_queue_t *pending_new_srv_start_q; /* pending new service start queue */
#endif // (GATTS_INCLUDED == TRUE)
tGATT_REG cl_rcb[GATT_MAX_APPS];
list_t *p_clcb_list; /* connection link control block*/
tGATT_SCCB sccb[GATT_MAX_SCCB]; /* sign complete callback function GATT_MAX_SCCB <= GATT_CL_MAX_LCB */
UINT8 trace_level;
UINT16 def_mtu_size;
#if GATT_CONFORMANCE_TESTING == TRUE
BOOLEAN enable_err_rsp;
@@ -556,14 +562,19 @@ typedef struct {
tGATT_APPL_INFO cb_info;
#if (GATTS_INCLUDED == TRUE)
tGATT_HDL_CFG hdl_cfg;
#if (tGATT_BG_CONN_DEV == TRUE)
#endif // (GATTS_INCLUDED == TRUE)
#if (GATT_BG_CONN_DEV == TRUE)
tGATT_BG_CONN_DEV bgconn_dev[GATT_MAX_BG_CONN_DEV];
#endif // #if (tGATT_BG_CONN_DEV == TRUE)
#endif // #if (GATT_BG_CONN_DEV == TRUE)
#if (GATTC_INCLUDED == TRUE)
BOOLEAN auto_disc; /* internal use: true for auto discovering after connected */
#endif // (GATTC_INCLUDED == TRUE)
#if (GATTS_INCLUDED == TRUE)
UINT8 srv_chg_mode; /* internal use: service change mode */
tGATTS_RSP rsp; /* use to read internal service attribute */
#endif // (GATTS_INCLUDED == TRUE)
} tGATT_CB;
typedef struct{
@@ -652,10 +663,8 @@ extern tGATTS_SRV_CHG *gatt_is_bda_in_the_srv_chg_clt_list (BD_ADDR bda);
extern BOOLEAN gatt_find_the_connected_bda(UINT8 start_idx, BD_ADDR bda, UINT8 *p_found_idx, tBT_TRANSPORT *p_transport);
extern void gatt_set_srv_chg(void);
extern void gatt_delete_dev_from_srv_chg_clt_list(BD_ADDR bd_addr);
extern tGATT_VALUE *gatt_add_pending_ind(tGATT_TCB *p_tcb, tGATT_VALUE *p_ind);
extern tGATTS_PENDING_NEW_SRV_START *gatt_add_pending_new_srv_start( tGATTS_HNDL_RANGE *p_new_srv_start);
extern void gatt_free_srvc_db_buffer_app_id(tBT_UUID *p_app_id);
extern BOOLEAN gatt_update_listen_mode(void);
extern BOOLEAN gatt_cl_send_next_cmd_inq(tGATT_TCB *p_tcb);
/* reserved handle list */
@@ -673,7 +682,7 @@ extern BOOLEAN gatt_add_an_item_to_list(tGATT_HDL_LIST_INFO *p_list, tGATT_HDL_L
extern BOOLEAN gatt_remove_an_item_from_list(tGATT_HDL_LIST_INFO *p_list, tGATT_HDL_LIST_ELEM *p_remove);
extern tGATTS_SRV_CHG *gatt_add_srv_chg_clt(tGATTS_SRV_CHG *p_srv_chg);
#if (tGATT_BG_CONN_DEV == TRUE)
#if (GATT_BG_CONN_DEV == TRUE)
/* for background connection */
extern BOOLEAN gatt_update_auto_connect_dev (tGATT_IF gatt_if, BOOLEAN add, BD_ADDR bd_addr, BOOLEAN is_initiator);
extern BOOLEAN gatt_is_bg_dev_for_app(tGATT_BG_CONN_DEV *p_dev, tGATT_IF gatt_if);
@@ -683,7 +692,7 @@ extern BOOLEAN gatt_find_app_for_bg_dev(BD_ADDR bd_addr, tGATT_IF *p_gatt_if);
extern tGATT_BG_CONN_DEV *gatt_find_bg_dev(BD_ADDR remote_bda);
extern void gatt_deregister_bgdev_list(tGATT_IF gatt_if);
extern void gatt_reset_bgdev_list(void);
#endif // #if (tGATT_BG_CONN_DEV == TRUE)
#endif // #if (GATT_BG_CONN_DEV == TRUE)
/* server function */
extern UINT8 gatt_sr_find_i_rcb_by_handle(UINT16 handle);
@@ -80,19 +80,6 @@ enum {
typedef uint8_t tBTM_STATUS;
#if (defined(BTA_HOST_INTERLEAVE_SEARCH) && BTA_HOST_INTERLEAVE_SEARCH == TRUE)
typedef enum {
BTM_BR_ONE, /*0 First state or BR/EDR scan 1*/
BTM_BLE_ONE, /*1BLE scan 1*/
BTM_BR_TWO, /*2 BR/EDR scan 2*/
BTM_BLE_TWO, /*3 BLE scan 2*/
BTM_FINISH, /*4 End of Interleave Scan, or normal scan*/
BTM_NO_INTERLEAVING /*5 No Interleaving*/
} btm_inq_state;
#endif
/*************************
** Device Control Types
**************************/
@@ -647,9 +634,6 @@ typedef struct { /* contains the parameters passed to the inquiry fun
BOOLEAN report_dup; /* report duplicated inquiry response with higher RSSI value */
UINT8 filter_cond_type; /* new devices, BD ADDR, COD, or No filtering */
tBTM_INQ_FILT_COND filter_cond; /* filter value based on filter cond type */
#if (defined(BTA_HOST_INTERLEAVE_SEARCH) && BTA_HOST_INTERLEAVE_SEARCH == TRUE)
UINT8 intl_duration[4]; /*duration array storing the interleave scan's time portions*/
#endif
} tBTM_INQ_PARMS;
#define BTM_INQ_RESULT_BR 0x01
@@ -3046,28 +3030,6 @@ tBTM_STATUS BTM_ReadRSSI (BD_ADDR remote_bda, tBT_TRANSPORT transport, tBTM_CMPL
**
*******************************************************************************/
tBTM_STATUS BTM_ReadChannelMap(BD_ADDR remote_bda, tBTM_CMPL_CB *p_cb);
#if (BLE_HOST_READ_TX_POWER_EN == TRUE)
/*******************************************************************************
**
** Function BTM_ReadTxPower
**
** Description This function is called to read the current connection
** TX power of the connection. The TX power level results
** are returned in the callback.
** (tBTM_RSSI_RESULTS)
**
** Returns BTM_CMD_STARTED if command issued to controller.
** BTM_NO_RESOURCES if couldn't allocate memory to issue command
** BTM_UNKNOWN_ADDR if no active link with bd addr specified
** BTM_BUSY if command is already in progress
**
*******************************************************************************/
//extern
tBTM_STATUS BTM_ReadTxPower (BD_ADDR remote_bda,
tBT_TRANSPORT transport, tBTM_CMPL_CB *p_cb);
tBTM_STATUS BTM_BleReadAdvTxPower(tBTM_CMPL_CB *p_cb);
#endif // #if (BLE_HOST_READ_TX_POWER_EN == TRUE)
void BTM_BleGetWhiteListSize(uint16_t *length);
@@ -57,13 +57,6 @@ typedef UINT32 tBTM_BLE_REF_VALUE;
#define BTM_BLE_SCAN_MODE_NONE 0xff
typedef UINT8 tBLE_SCAN_MODE;
#define BTM_BLE_BATCH_SCAN_MODE_DISABLE 0
#define BTM_BLE_BATCH_SCAN_MODE_PASS 1
#define BTM_BLE_BATCH_SCAN_MODE_ACTI 2
#define BTM_BLE_BATCH_SCAN_MODE_PASS_ACTI 3
typedef UINT8 tBTM_BLE_BATCH_SCAN_MODE;
/* advertising channel map */
#define BTM_BLE_ADV_CHNL_37 (0x01 << 0)
#define BTM_BLE_ADV_CHNL_38 (0x01 << 1)
@@ -129,8 +122,6 @@ typedef UINT8 tBTM_BLE_SFP;
#define BTM_BLE_SCAN_INT_MAX 0x4000
#define BTM_BLE_SCAN_WIN_MIN 0x0004
#define BTM_BLE_SCAN_WIN_MAX 0x4000
#define BTM_BLE_EXT_SCAN_INT_MAX 0x00FFFFFF
#define BTM_BLE_EXT_SCAN_WIN_MAX 0xFFFF
#define BTM_BLE_CONN_INT_MIN 0x0006
#define BTM_BLE_CONN_INT_MAX 0x0C80
#define BTM_BLE_CONN_LATENCY_MAX 499
@@ -393,22 +384,7 @@ typedef UINT8 tBTM_BLE_AD_TYPE;
typedef UINT8 tBTM_BLE_ADV_TX_POWER;
/* adv tx power in dBm */
typedef struct {
#if (BLE_HOST_BLE_MULTI_ADV_EN == TRUE)
UINT8 adv_inst_max; /* max adv instance supported in controller */
#endif // #if (BLE_HOST_BLE_MULTI_ADV_EN == TRUE)
UINT8 rpa_offloading;
UINT16 tot_scan_results_strg;
UINT8 max_irk_list_sz;
UINT8 filter_support;
UINT8 max_filter;
UINT8 energy_support;
BOOLEAN values_read;
UINT16 version_supported;
UINT16 total_trackable_advertisers;
UINT8 extended_scan_support;
UINT8 debug_logging_supported;
} tBTM_BLE_VSC_CB;
/* slave preferred connection interval range */
typedef struct {
@@ -500,40 +476,6 @@ typedef struct {
tBTM_BLE_ADV_TX_POWER tx_power;
} tBTM_BLE_ADV_PARAMS;
#if (BLE_HOST_BLE_MULTI_ADV_EN == TRUE)
typedef struct {
UINT8 *p_sub_code; /* dynamic array to store sub code */
UINT8 *p_inst_id; /* dynamic array to store instance id */
UINT8 pending_idx;
UINT8 next_idx;
} tBTM_BLE_MULTI_ADV_OPQ;
typedef void (tBTM_BLE_MULTI_ADV_CBACK)(tBTM_BLE_MULTI_ADV_EVT evt, UINT8 inst_id,
void *p_ref, tBTM_STATUS status);
typedef struct {
UINT8 inst_id;
BOOLEAN in_use;
UINT8 adv_evt;
BD_ADDR rpa;
TIMER_LIST_ENT raddr_timer_ent;
tBTM_BLE_MULTI_ADV_CBACK *p_cback;
void *p_ref;
UINT8 index;
} tBTM_BLE_MULTI_ADV_INST;
typedef struct {
UINT8 inst_index_queue[BTM_BLE_MULTI_ADV_MAX];
int front;
int rear;
} tBTM_BLE_MULTI_ADV_INST_IDX_Q;
typedef struct {
tBTM_BLE_MULTI_ADV_INST *p_adv_inst; /* dynamic array to store adv instance */
tBTM_BLE_MULTI_ADV_OPQ op_q;
} tBTM_BLE_MULTI_ADV_CB;
#endif // #if (BLE_HOST_BLE_MULTI_ADV_EN == TRUE)
typedef UINT8 tGATT_IF;
typedef void (tBTM_BLE_SCAN_THRESHOLD_CBACK)(tBTM_BLE_REF_VALUE ref_value);
@@ -542,60 +484,17 @@ typedef void (tBTM_BLE_SCAN_REP_CBACK)(tBTM_BLE_REF_VALUE ref_value, UINT8 repor
UINT8 *p_rep_data, UINT8 status);
typedef void (tBTM_BLE_SCAN_SETUP_CBACK)(UINT8 evt, tBTM_BLE_REF_VALUE ref_value, UINT8 status);
#ifndef BTM_BLE_BATCH_SCAN_MAX
#define BTM_BLE_BATCH_SCAN_MAX 5
#endif
#ifndef BTM_BLE_BATCH_REP_MAIN_Q_SIZE
#define BTM_BLE_BATCH_REP_MAIN_Q_SIZE 2
#endif
typedef enum {
BTM_BLE_SCAN_INVALID_STATE = 0,
BTM_BLE_SCAN_ENABLE_CALLED = 1,
BTM_BLE_SCAN_ENABLED_STATE = 2,
BTM_BLE_SCAN_DISABLE_CALLED = 3,
BTM_BLE_SCAN_DISABLED_STATE = 4
} tBTM_BLE_BATCH_SCAN_STATE;
enum {
BTM_BLE_DISCARD_OLD_ITEMS,
BTM_BLE_DISCARD_LOWER_RSSI_ITEMS
};
typedef UINT8 tBTM_BLE_DISCARD_RULE;
typedef struct {
UINT8 sub_code[BTM_BLE_BATCH_SCAN_MAX];
tBTM_BLE_BATCH_SCAN_STATE cur_state[BTM_BLE_BATCH_SCAN_MAX];
tBTM_BLE_REF_VALUE ref_value[BTM_BLE_BATCH_SCAN_MAX];
UINT8 pending_idx;
UINT8 next_idx;
} tBTM_BLE_BATCH_SCAN_OPQ;
typedef struct {
UINT8 rep_mode[BTM_BLE_BATCH_REP_MAIN_Q_SIZE];
tBTM_BLE_REF_VALUE ref_value[BTM_BLE_BATCH_REP_MAIN_Q_SIZE];
UINT8 num_records[BTM_BLE_BATCH_REP_MAIN_Q_SIZE];
UINT16 data_len[BTM_BLE_BATCH_REP_MAIN_Q_SIZE];
UINT8 *p_data[BTM_BLE_BATCH_REP_MAIN_Q_SIZE];
UINT8 pending_idx;
UINT8 next_idx;
} tBTM_BLE_BATCH_SCAN_REP_Q;
typedef struct {
tBTM_BLE_BATCH_SCAN_STATE cur_state;
tBTM_BLE_BATCH_SCAN_MODE scan_mode;
UINT32 scan_interval;
UINT32 scan_window;
tBLE_ADDR_TYPE addr_type;
tBTM_BLE_DISCARD_RULE discard_rule;
tBTM_BLE_BATCH_SCAN_OPQ op_q;
tBTM_BLE_BATCH_SCAN_REP_Q main_rep_q;
tBTM_BLE_SCAN_SETUP_CBACK *p_setup_cback;
tBTM_BLE_SCAN_THRESHOLD_CBACK *p_thres_cback;
tBTM_BLE_SCAN_REP_CBACK *p_scan_rep_cback;
tBTM_BLE_REF_VALUE ref_value;
} tBTM_BLE_BATCH_SCAN_CB;
/// Ble scan duplicate type
enum {
@@ -959,53 +858,7 @@ typedef UINT8 tBTM_BLE_CONN_TYPE;
#define ADV_INFO_PRESENT 0x00
#define NO_ADV_INFO_PRESENT 0x01
#if (BLE_HOST_TRACK_ADVERTISER_EN == TRUE)
typedef btgatt_track_adv_info_t tBTM_BLE_TRACK_ADV_DATA;
typedef void (tBTM_BLE_TRACK_ADV_CBACK)(tBTM_BLE_TRACK_ADV_DATA *p_track_adv_data);
typedef UINT8 tBTM_BLE_TRACK_ADV_EVT;
typedef struct {
tBTM_BLE_REF_VALUE ref_value;
tBTM_BLE_TRACK_ADV_CBACK *p_track_cback;
} tBTM_BLE_ADV_TRACK_CB;
enum {
BTM_BLE_TRACK_ADV_ADD,
BTM_BLE_TRACK_ADV_REMOVE
};
typedef UINT8 tBTM_BLE_TRACK_ADV_ACTION;
#endif // #if (BLE_HOST_TRACK_ADVERTISER_EN == TRUE)
#define BTM_BLE_MULTI_ADV_INVALID 0
#define BTM_BLE_BATCH_SCAN_ENABLE_EVT 1
#define BTM_BLE_BATCH_SCAN_CFG_STRG_EVT 2
#define BTM_BLE_BATCH_SCAN_READ_REPTS_EVT 3
#define BTM_BLE_BATCH_SCAN_THR_EVT 4
#define BTM_BLE_BATCH_SCAN_PARAM_EVT 5
#define BTM_BLE_BATCH_SCAN_DISABLE_EVT 6
typedef UINT8 tBTM_BLE_BATCH_SCAN_EVT;
typedef UINT32 tBTM_BLE_TX_TIME_MS;
typedef UINT32 tBTM_BLE_RX_TIME_MS;
typedef UINT32 tBTM_BLE_IDLE_TIME_MS;
typedef UINT32 tBTM_BLE_ENERGY_USED;
typedef void (tBTM_BLE_ENERGY_INFO_CBACK)(tBTM_BLE_TX_TIME_MS tx_time, tBTM_BLE_RX_TIME_MS rx_time,
tBTM_BLE_IDLE_TIME_MS idle_time,
tBTM_BLE_ENERGY_USED energy_used,
tBTM_STATUS status);
typedef struct {
tBTM_BLE_ENERGY_INFO_CBACK *p_ener_cback;
} tBTM_BLE_ENERGY_INFO_CB;
typedef BOOLEAN (tBTM_BLE_SEL_CBACK)(BD_ADDR random_bda, UINT8 *p_remote_name);
typedef void (tBTM_BLE_CTRL_FEATURES_CBACK)(tBTM_STATUS status);
/* callback function for SMP signing algorithm, signed data in little endian order with tlen bits long */
typedef void (tBTM_BLE_SIGN_CBACK)(void *p_ref_data, UINT8 *p_signing_data);
@@ -1016,8 +869,6 @@ typedef void (tBTM_BLE_RANDOM_SET_CBACK) (BD_ADDR random_bda);
typedef void (tBTM_BLE_SCAN_REQ_CBACK)(BD_ADDR remote_bda, tBLE_ADDR_TYPE addr_type, UINT8 adv_evt);
typedef void (*tBLE_SCAN_PARAM_SETUP_CBACK)(tGATT_IF client_if, tBTM_STATUS status);
tBTM_BLE_SCAN_SETUP_CBACK bta_ble_scan_setup_cb;
typedef void (tBTM_START_ADV_CMPL_CBACK) (UINT8 status);
typedef void (tBTM_START_STOP_ADV_CMPL_CBACK) (UINT8 status);
@@ -2218,61 +2069,6 @@ tBTM_STATUS BTM_BleSetRandAddress(BD_ADDR rand_addr);
void BTM_BleClearRandAddress(void);
/*******************************************************************************
**
** Function BTM_BleSetAdvParams
**
** Description This function is called to set advertising parameters.
**
** Parameters adv_int_min: minimum advertising interval
** adv_int_max: maximum advertising interval
** p_dir_bda: connectable direct initiator's LE device address
** chnl_map: advertising channel map.
**
** Returns void
**
*******************************************************************************/
//extern
void BTM_BleReadAdvParams (UINT16 *adv_int_min, UINT16 *adv_int_max,
tBLE_BD_ADDR *p_dir_bda, tBTM_BLE_ADV_CHNL_MAP *p_chnl_map);
/*******************************************************************************
**
** Function BTM_BleObtainVendorCapabilities
**
** Description This function is called to obtain vendor capabilities
**
** Parameters p_cmn_vsc_cb - Returns the vendor capabilities
**
** Returns void
**
*******************************************************************************/
//extern
void BTM_BleObtainVendorCapabilities(tBTM_BLE_VSC_CB *p_cmn_vsc_cb);
#if (BLE_HOST_BLE_SCAN_PARAM_UNUSED == TRUE)
/*******************************************************************************
**
** Function BTM_BleSetScanParams
**
** Description This function is called to set Scan parameters.
**
** Parameters client_if - Client IF value
** scan_interval - Scan interval
** scan_window - Scan window
** scan_type - Scan type
** scan_setup_status_cback - Scan setup status callback
**
** Returns void
**
*******************************************************************************/
//extern
void BTM_BleSetScanParams(tGATT_IF client_if, UINT32 scan_interval,
UINT32 scan_window, tBLE_SCAN_MODE scan_type,
tBLE_SCAN_PARAM_SETUP_CBACK scan_setup_status_cback);
#endif // #if (BLE_HOST_BLE_SCAN_PARAM_UNUSED == TRUE)
/*******************************************************************************
**
** Function BTM_BleSetScanFilterParams
@@ -2296,116 +2092,6 @@ tBTM_STATUS BTM_BleSetScanFilterParams(tGATT_IF client_if, UINT32 scan_interval,
tBLE_SCAN_PARAM_SETUP_CBACK scan_setup_status_cback);
/*******************************************************************************
**
** Function BTM_BleGetVendorCapabilities
**
** Description This function reads local LE features
**
** Parameters p_cmn_vsc_cb : Locala LE capability structure
**
** Returns void
**
*******************************************************************************/
//extern
void BTM_BleGetVendorCapabilities(tBTM_BLE_VSC_CB *p_cmn_vsc_cb);
/*******************************************************************************
**
** Function BTM_BleSetStorageConfig
**
** Description This function is called to setup storage configuration and setup callbacks.
**
** Parameters UINT8 batch_scan_full_max -Batch scan full maximum
UINT8 batch_scan_trunc_max - Batch scan truncated value maximum
UINT8 batch_scan_notify_threshold - Threshold value
tBTM_BLE_SCAN_SETUP_CBACK *p_setup_cback - Setup callback
tBTM_BLE_SCAN_THRESHOLD_CBACK *p_thres_cback -Threshold callback
void *p_ref - Reference value
**
** Returns tBTM_STATUS
**
*******************************************************************************/
//extern
tBTM_STATUS BTM_BleSetStorageConfig(UINT8 batch_scan_full_max,
UINT8 batch_scan_trunc_max,
UINT8 batch_scan_notify_threshold,
tBTM_BLE_SCAN_SETUP_CBACK *p_setup_cback,
tBTM_BLE_SCAN_THRESHOLD_CBACK *p_thres_cback,
tBTM_BLE_SCAN_REP_CBACK *p_cback,
tBTM_BLE_REF_VALUE ref_value);
/*******************************************************************************
**
** Function BTM_BleEnableBatchScan
**
** Description This function is called to enable batch scan
**
** Parameters tBTM_BLE_BATCH_SCAN_MODE scan_mode - Batch scan mode
UINT32 scan_interval -Scan interval
UINT32 scan_window - Scan window value
tBLE_ADDR_TYPE addr_type - Address type
tBTM_BLE_DISCARD_RULE discard_rule - Data discard rules
**
** Returns tBTM_STATUS
**
*******************************************************************************/
//extern
tBTM_STATUS BTM_BleEnableBatchScan(tBTM_BLE_BATCH_SCAN_MODE scan_mode,
UINT32 scan_interval, UINT32 scan_window,
tBTM_BLE_DISCARD_RULE discard_rule,
tBLE_ADDR_TYPE addr_type,
tBTM_BLE_REF_VALUE ref_value);
/*******************************************************************************
**
** Function BTM_BleDisableBatchScan
**
** Description This function is called to disable batch scanning
**
** Parameters void
**
** Returns void
**
*******************************************************************************/
//extern
tBTM_STATUS BTM_BleDisableBatchScan(tBTM_BLE_REF_VALUE ref_value);
#if (BLE_HOST_READ_SCAN_REPORTS_EN == TRUE)
/*******************************************************************************
**
** Function BTM_BleReadScanReports
**
** Description This function is called to read batch scan reports
**
** Parameters tBLE_SCAN_MODE scan_mode - Scan mode report to be read out
tBTM_BLE_SCAN_REP_CBACK* p_cback - Reports callback
**
** Returns tBTM_STATUS
**
*******************************************************************************/
//extern
tBTM_STATUS BTM_BleReadScanReports(tBLE_SCAN_MODE scan_mode,
tBTM_BLE_REF_VALUE ref_value);
#endif // #if (BLE_HOST_READ_SCAN_REPORTS_EN == TRUE)
#if (BLE_HOST_TRACK_ADVERTISER_EN == TRUE)
/*******************************************************************************
**
** Function BTM_BleTrackAdvertiser
**
** Description This function is called to read batch scan reports
**
** Parameters p_track_cback - Tracking callback
** ref_value - Reference value
**
** Returns tBTM_STATUS
**
*******************************************************************************/
//extern
tBTM_STATUS BTM_BleTrackAdvertiser(tBTM_BLE_TRACK_ADV_CBACK *p_track_cback,
tBTM_BLE_REF_VALUE ref_value);
#endif // #if (BLE_HOST_TRACK_ADVERTISER_EN == TRUE)
/*******************************************************************************
**
** Function BTM_BleWriteScanRsp
@@ -2788,20 +2474,6 @@ void BTM_BleSetPrefConnParams (BD_ADDR bd_addr,
//extern
void BTM_BleSetConnScanParams (UINT32 scan_interval, UINT32 scan_window);
/******************************************************************************
**
** Function BTM_BleReadControllerFeatures
**
** Description Reads BLE specific controller features
**
** Parameters: tBTM_BLE_CTRL_FEATURES_CBACK : Callback to notify when features are read
**
** Returns void
**
*******************************************************************************/
//extern
void BTM_BleReadControllerFeatures(tBTM_BLE_CTRL_FEATURES_CBACK *p_vsc_cback);
/*******************************************************************************
**
** Function BTM_CheckAdvData
@@ -3005,20 +2677,6 @@ BOOLEAN BTM_BleLocalPrivacyEnabled(void);
//extern
void BTM_BleEnableMixedPrivacyMode(BOOLEAN mixed_on);
#if (BLE_HOST_BLE_MULTI_ADV_EN == TRUE)
/*******************************************************************************
**
** Function BTM_BleMaxMultiAdvInstanceCount
**
** Description Returns max number of multi adv instances supported by controller
**
** Returns Max multi adv instance count
**
*******************************************************************************/
//extern
UINT8 BTM_BleMaxMultiAdvInstanceCount(void);
#endif // #if (BLE_HOST_BLE_MULTI_ADV_EN == TRUE)
/*******************************************************************************
**
** Function BTM_BleSetConnectableMode
@@ -3077,19 +2735,6 @@ BOOLEAN BTM_BleUpdateAdvWhitelist(BOOLEAN add_remove, BD_ADDR emote_bda, tBLE_AD
*******************************************************************************/
void BTM_BleClearWhitelist(tBTM_UPDATE_WHITELIST_CBACK *update_wl_cb);
/*******************************************************************************
**
** Function BTM_BleUpdateAdvFilterPolicy
**
** Description This function update the filter policy of advertiser.
**
** Parameter adv_policy: advertising filter policy
**
** Return void
*******************************************************************************/
//extern
void BTM_BleUpdateAdvFilterPolicy(tBTM_BLE_AFP adv_policy);
/*******************************************************************************
**
** Function BTM_BleReceiverTest
@@ -3198,80 +2843,6 @@ BOOLEAN BTM_BleSecurityProcedureIsRunning (BD_ADDR bd_addr);
//extern
UINT8 BTM_BleGetSupportedKeySize (BD_ADDR bd_addr);
#if (BLE_HOST_BLE_MULTI_ADV_EN == TRUE)
/*******************************************************************************/
/* Multi ADV API */
/*******************************************************************************
**
** Function BTM_BleEnableAdvInstance
**
** Description This function enable a Multi-ADV instance with the specified
** adv parameters
**
** Parameters p_params: pointer to the adv parameter structure, set as default
** adv parameter when the instance is enabled.
** p_cback: callback function for the adv instance.
** p_ref: reference data attach to the adv instance to be enabled.
**
** Returns status
**
*******************************************************************************/
//extern
tBTM_STATUS BTM_BleEnableAdvInstance (tBTM_BLE_ADV_PARAMS *p_params,
tBTM_BLE_MULTI_ADV_CBACK *p_cback,
void *p_ref);
/*******************************************************************************
**
** Function BTM_BleUpdateAdvInstParam
**
** Description This function update a Multi-ADV instance with the specified
** adv parameters.
**
** Parameters inst_id: adv instance ID
** p_params: pointer to the adv parameter structure.
**
** Returns status
**
*******************************************************************************/
//extern
tBTM_STATUS BTM_BleUpdateAdvInstParam (UINT8 inst_id, tBTM_BLE_ADV_PARAMS *p_params);
/*******************************************************************************
**
** Function BTM_BleCfgAdvInstData
**
** Description This function configure a Multi-ADV instance with the specified
** adv data or scan response data.
**
** Parameters inst_id: adv instance ID
** is_scan_rsp: is this scacn response, if no set as adv data.
** data_mask: adv data mask.
** p_data: pointer to the adv data structure.
**
** Returns status
**
*******************************************************************************/
//extern
tBTM_STATUS BTM_BleCfgAdvInstData (UINT8 inst_id, BOOLEAN is_scan_rsp,
tBTM_BLE_AD_MASK data_mask,
tBTM_BLE_ADV_DATA *p_data);
/*******************************************************************************
**
** Function BTM_BleDisableAdvInstance
**
** Description This function disable a Multi-ADV instance.
**
** Parameters inst_id: adv instance ID
**
** Returns status
**
*******************************************************************************/
//extern
tBTM_STATUS BTM_BleDisableAdvInstance (UINT8 inst_id);
#endif // #if (BLE_HOST_BLE_MULTI_ADV_EN == TRUE)
/*******************************************************************************
**
@@ -3333,20 +2904,6 @@ tBTM_STATUS BTM_BleEnableDisableFilterFeature(UINT8 enable,
tBTM_BLE_PF_STATUS_CBACK *p_stat_cback,
tBTM_BLE_REF_VALUE ref_value);
/*******************************************************************************
**
** Function BTM_BleGetEnergyInfo
**
** Description This function obtains the energy info
**
** Parameters p_ener_cback - Callback pointer
**
** Returns status
**
*******************************************************************************/
//extern
tBTM_STATUS BTM_BleGetEnergyInfo(tBTM_BLE_ENERGY_INFO_CBACK *p_ener_cback);
/*******************************************************************************
**
** Function BTM_SetBleDataLength
@@ -1227,23 +1227,6 @@ extern BOOLEAN GATT_GetConnIdIfConnected(tGATT_IF gatt_if, BD_ADDR bd_addr,
UINT16 *p_conn_id, tBT_TRANSPORT transport);
/*******************************************************************************
**
** Function GATT_Listen
**
** Description This function start or stop LE advertisement and listen for
** connection.
**
** Parameters gatt_if: application interface
** p_bd_addr: listen for specific address connection, or NULL for
** listen to all device connection.
** start: is a direct connection or a background auto connection
**
** Returns TRUE if advertisement is started; FALSE if adv start failure.
**
*******************************************************************************/
extern BOOLEAN GATT_Listen (tGATT_IF gatt_if, BOOLEAN start, BD_ADDR_PTR bd_addr);
/*******************************************************************************
**
** Function GATT_ConfigServiceChangeCCC
@@ -488,10 +488,9 @@
//ESP BLE subcode define
#define HCI_SUBCODE_BLE_INIT 0x00
#define HCI_SUBCODE_BLE_MULTI_ADV 0x01
#define HCI_SUBCODE_BLE_BATCH_SCAN 0x02
#define HCI_SUBCODE_BLE_ADV_FILTER 0x03
#define HCI_SUBCODE_BLE_TRACK_ADV 0x04
#define HCI_SUBCODE_BLE_ENERGY_INFO 0x05
#define HCI_SUBCODE_BLE_EXTENDED_SCAN_PARAMS 0x06
#define HCI_SUBCODE_BLE_LONG_ADV 0x07
#define HCI_SUBCODE_BLE_DUPLICATE_EXCEPTIONAL_LIST 0x08
@@ -536,14 +535,11 @@
//ESP BLE HCI CMD
/* Multi adv OCF */
#define HCI_BLE_MULTI_ADV_OCF HCI_ESP_VENDOR_OPCODE_BUILD(HCI_VENDOR_OGF, HCI_ESP_GROUP_BLE, HCI_SUBCODE_BLE_MULTI_ADV)
/* Batch scan OCF */
#define HCI_BLE_BATCH_SCAN_OCF HCI_ESP_VENDOR_OPCODE_BUILD(HCI_VENDOR_OGF, HCI_ESP_GROUP_BLE, HCI_SUBCODE_BLE_BATCH_SCAN)
/* ADV filter OCF */
#define HCI_BLE_ADV_FILTER_OCF HCI_ESP_VENDOR_OPCODE_BUILD(HCI_VENDOR_OGF, HCI_ESP_GROUP_BLE, HCI_SUBCODE_BLE_ADV_FILTER)
/* Tracking OCF */
#define HCI_BLE_TRACK_ADV_OCF HCI_ESP_VENDOR_OPCODE_BUILD(HCI_VENDOR_OGF, HCI_ESP_GROUP_BLE, HCI_SUBCODE_BLE_TRACK_ADV)
/* Energy info OCF */
#define HCI_BLE_ENERGY_INFO_OCF HCI_ESP_VENDOR_OPCODE_BUILD(HCI_VENDOR_OGF, HCI_ESP_GROUP_BLE, HCI_SUBCODE_BLE_ENERGY_INFO)
/* Extended BLE Scan parameters OCF */
#define HCI_BLE_EXTENDED_SCAN_PARAMS_OCF HCI_ESP_VENDOR_OPCODE_BUILD(HCI_VENDOR_OGF, HCI_ESP_GROUP_BLE, HCI_SUBCODE_BLE_EXTENDED_SCAN_PARAMS)
/* BLE update duplicate scan exceptional list */
@@ -576,12 +572,6 @@
/* multi adv VSE subcode */
#define HCI_VSE_SUBCODE_BLE_MULTI_ADV_ST_CHG 0x55 /* multi adv instance state change */
/* subcode for batch scan feature */
#define BTM_BLE_BATCH_SCAN_ENB_DISAB_CUST_FEATURE 0x01
#define BTM_BLE_BATCH_SCAN_SET_STORAGE_PARAM 0x02
#define BTM_BLE_BATCH_SCAN_SET_PARAMS 0x03
#define BTM_BLE_BATCH_SCAN_READ_RESULTS 0x04
/* batch scan VSE subcode */
#define HCI_VSE_SUBCODE_BLE_THRESHOLD_SUB_EVT 0x54 /* Threshold event */
@@ -488,19 +488,24 @@ typedef struct {
list_t *p_lcb_pool; /* Link Control Block pool */
list_t *p_ccb_pool; /* Channel Control Block pool */
#if (CLASSIC_BT_INCLUDED == TRUE)
tL2C_RCB rcb_pool[MAX_L2CAP_CLIENTS]; /* Registration info pool */
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
#if (CLASSIC_BT_INCLUDED == TRUE)
UINT8 desire_role; /* desire to be master/slave when accepting a connection */
BOOLEAN disallow_switch; /* FALSE, to allow switch at create conn */
#endif // (CLASSIC_BT_INCLUDED == TRUE)
UINT16 num_lm_acl_bufs; /* # of ACL buffers on controller */
UINT16 idle_timeout; /* Idle timeout */
list_t *rcv_pending_q; /* Recv pending queue */
TIMER_LIST_ENT rcv_hold_tle; /* Timer list entry for rcv hold */
tL2C_LCB *p_cur_hcit_lcb; /* Current HCI Transport buffer */
// tL2C_LCB *p_cur_hcit_lcb; /* Current HCI Transport buffer */
#if (CLASSIC_BT_INCLUDED == TRUE)
UINT16 num_links_active; /* Number of links active */
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
#if (L2CAP_NON_FLUSHABLE_PB_INCLUDED == TRUE)
UINT16 non_flushable_pbf; /* L2CAP_PKT_START_NON_FLUSHABLE if controller supports */
@@ -529,13 +534,16 @@ typedef struct {
tL2C_RCB ble_rcb_pool[BLE_MAX_L2CAP_CLIENTS]; /* Registration info pool */
#endif
#if (CLASSIC_BT_INCLUDED == TRUE)
tL2CA_ECHO_DATA_CB *p_echo_data_cb; /* Echo data callback */
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
#if (defined(L2CAP_HIGH_PRI_CHAN_QUOTA_IS_CONFIGURABLE) && (L2CAP_HIGH_PRI_CHAN_QUOTA_IS_CONFIGURABLE == TRUE))
UINT16 high_pri_min_xmit_quota; /* Minimum number of ACL credit for high priority link */
#endif /* (L2CAP_HIGH_PRI_CHAN_QUOTA_IS_CONFIGURABLE == TRUE) */
#if (CLASSIC_BT_INCLUDED == TRUE)
UINT16 dyn_psm;
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
} tL2C_CB;
@@ -863,7 +863,7 @@ UINT8 L2CA_SetTraceLevel (UINT8 new_level)
return (l2cb.l2cap_trace_level);
}
#if (CLASSIC_BT_INCLUDED == TRUE)
/*******************************************************************************
**
** Function L2CA_SetDesireRole
@@ -901,6 +901,7 @@ UINT8 L2CA_SetDesireRole (UINT8 new_role)
return (l2cb.desire_role);
}
#endif // (CLASSIC_BT_INCLUDED == TRUE)
#if (CLASSIC_BT_INCLUDED == TRUE)
@@ -506,8 +506,13 @@ void l2cble_advertiser_conn_comp (UINT16 handle, BD_ADDR bda, tBLE_ADDR_TYPE typ
void l2cble_conn_comp(UINT16 handle, UINT8 role, BD_ADDR bda, tBLE_ADDR_TYPE type,
UINT16 conn_interval, UINT16 conn_latency, UINT16 conn_timeout)
{
#if (BLE_TOPOLOGY_CHECK == TRUE)
btm_ble_update_link_topology_mask(role, TRUE);
#else
btm_cb.ble_ctr_cb.inq_var.adv_mode = BTM_BLE_ADV_DISABLE;
/* make device fall back into undirected adv mode by default */
btm_cb.ble_ctr_cb.inq_var.directed_conn = BTM_BLE_CONNECT_EVT;
#endif // (BLE_TOPOLOGY_CHECK == TRUE)
if (role == HCI_ROLE_MASTER) {
l2cble_scanner_conn_comp(handle, bda, type, conn_interval, conn_latency, conn_timeout);
} else {
@@ -945,11 +950,14 @@ BOOLEAN l2cble_init_direct_conn (tL2C_LCB *p_lcb)
#endif // CONTROLLER_RPA_LIST_ENABLE
#endif // (defined BLE_PRIVACY_SPT) && (BLE_PRIVACY_SPT == TRUE)
#if (BLE_TOPOLOGY_CHECK == TRUE)
if (!btm_ble_topology_check(BTM_BLE_STATE_INIT)) {
l2cu_release_lcb (p_lcb);
L2CAP_TRACE_ERROR("initiate direct connection fail, topology limitation");
return FALSE;
}
#endif // (BLE_TOPOLOGY_CHECK == TRUE)
uint32_t link_timeout = L2CAP_BLE_LINK_CONNECT_TOUT;
if(GATTC_CONNECT_RETRY_COUNT) {
if(!p_lcb->retry_create_con) {
@@ -1079,11 +1087,11 @@ BOOLEAN l2cble_create_conn (tL2C_LCB *p_lcb)
L2CAP_TRACE_WARNING ("L2CAP - LE - cannot start new connection at conn st: %d", conn_st);
btm_ble_enqueue_direct_conn_req(p_lcb);
#if (tGATT_BG_CONN_DEV == TRUE)
#if (GATT_BG_CONN_DEV == TRUE)
if (conn_st == BLE_BG_CONN) {
btm_ble_suspend_bg_conn();
}
#endif // #if (tGATT_BG_CONN_DEV == TRUE)
#endif // #if (GATT_BG_CONN_DEV == TRUE)
rt = TRUE;
}
return rt;
@@ -1110,6 +1118,7 @@ void l2c_link_processs_ble_num_bufs (UINT16 num_lm_ble_bufs)
l2cb.num_lm_ble_bufs = l2cb.controller_le_xmit_window = num_lm_ble_bufs;
}
#if (BLE_INCLUDED == TRUE)
/*******************************************************************************
**
** Function l2c_ble_link_adjust_allocation
@@ -1229,6 +1238,7 @@ void l2c_ble_link_adjust_allocation (void)
}
}
}
#endif // #if (BLE_INCLUDED == TRUE)
#if (defined BLE_LLT_INCLUDED) && (BLE_LLT_INCLUDED == TRUE)
/*******************************************************************************
@@ -392,10 +392,12 @@ BOOLEAN l2c_link_hci_disc_comp (UINT16 handle, UINT8 reason)
p_lcb->link_state = LST_DISCONNECTING;
#if (BLE_INCLUDED == TRUE)
#if (BLE_TOPOLOGY_CHECK == TRUE)
/* Check for BLE and handle that differently */
if (p_lcb->transport == BT_TRANSPORT_LE) {
btm_ble_update_link_topology_mask(p_lcb->link_role, FALSE);
}
#endif // (BLE_TOPOLOGY_CHECK == TRUE)
#endif
#if (CLASSIC_BT_INCLUDED == TRUE)
/* Link is disconnected. For all channels, send the event through */
@@ -734,7 +736,7 @@ void l2c_info_timeout (tL2C_LCB *p_lcb)
#endif ///CLASSIC_BT_INCLUDED == TRUE
}
}
#if (CLASSIC_BT_INCLUDED == TRUE)
/*******************************************************************************
**
** Function l2c_link_adjust_allocation
@@ -855,7 +857,7 @@ void l2c_link_adjust_allocation (void)
}
}
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
/*******************************************************************************
**
** Function l2c_link_adjust_chnl_allocation
@@ -936,6 +938,7 @@ UINT8 l2c_link_pkts_rcvd (UINT16 *num_pkts, UINT16 *handles)
return (num_found);
}
#if (CLASSIC_BT_INCLUDED == TRUE)
/*******************************************************************************
**
** Function l2c_link_role_changed
@@ -973,6 +976,7 @@ void l2c_link_role_changed (BD_ADDR bd_addr, UINT8 new_role, UINT8 hci_status)
}
}
}
#endif // (CLASSIC_BT_INCLUDED == TRUE)
/*******************************************************************************
**
@@ -1009,7 +1013,9 @@ void l2c_pin_code_request (BD_ADDR bd_addr)
*******************************************************************************/
BOOLEAN l2c_link_check_power_mode (tL2C_LCB *p_lcb)
{
#if (CLASSIC_BT_INCLUDED == TRUE)
tBTM_PM_MODE mode;
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
tL2C_CCB *p_ccb;
BOOLEAN need_to_active = FALSE;
@@ -1029,6 +1035,7 @@ BOOLEAN l2c_link_check_power_mode (tL2C_LCB *p_lcb)
/* if we have packets to send */
if ( need_to_active ) {
#if (CLASSIC_BT_INCLUDED == TRUE)
/* check power mode */
if (BTM_ReadPowerMode(p_lcb->remote_bd_addr, &mode) == BTM_SUCCESS) {
if ( mode == BTM_PM_STS_PENDING ) {
@@ -1037,6 +1044,7 @@ BOOLEAN l2c_link_check_power_mode (tL2C_LCB *p_lcb)
return TRUE;
}
}
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
}
return FALSE;
}
@@ -859,8 +859,10 @@ void l2c_init (void)
l2c_cb_ptr = (tL2C_CB *)osi_malloc(sizeof(tL2C_CB));
#endif /* #if L2C_DYNAMIC_MEMORY */
memset (&l2cb, 0, sizeof (tL2C_CB));
#if (CLASSIC_BT_INCLUDED == TRUE)
/* the psm is increased by 2 before being used */
l2cb.dyn_psm = 0xFFF;
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
l2cb.p_ccb_pool = list_new(osi_free_func);
if (l2cb.p_ccb_pool == NULL) {
@@ -877,13 +879,13 @@ void l2c_init (void)
#endif
#if (CLASSIC_BT_INCLUDED == TRUE)
#ifdef L2CAP_DESIRED_LINK_ROLE
l2cb.desire_role = L2CAP_DESIRED_LINK_ROLE;
#else
l2cb.desire_role = HCI_ROLE_SLAVE;
#endif
#endif // (CLASSIC_BT_INCLUDED == TRUE)
/* Set the default idle timeout */
l2cb.idle_timeout = L2CAP_LINK_INACTIVITY_TOUT;
@@ -113,8 +113,10 @@ tL2C_LCB *l2cu_allocate_lcb (BD_ADDR p_bd_addr, BOOLEAN is_bonding, tBT_TRANSPOR
} else
#endif
{
#if (CLASSIC_BT_INCLUDED == TRUE)
l2cb.num_links_active++;
l2c_link_adjust_allocation();
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
}
p_lcb->link_xmit_data_q = list_new(NULL);
return (p_lcb);
@@ -261,11 +263,13 @@ void l2cu_release_lcb (tL2C_LCB *p_lcb)
} else
#endif
{
#if (CLASSIC_BT_INCLUDED == TRUE)
if (l2cb.num_links_active >= 1) {
l2cb.num_links_active--;
}
l2c_link_adjust_allocation();
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
}
/* Check for ping outstanding */
@@ -369,6 +373,7 @@ uint8_t l2cu_ble_plcb_active_count(void)
}
#if (CLASSIC_BT_INCLUDED == TRUE)
/*******************************************************************************
**
** Function l2cu_get_conn_role
@@ -385,6 +390,7 @@ UINT8 l2cu_get_conn_role (tL2C_LCB *p_this_lcb)
{
return l2cb.desire_role;
}
#endif // (CLASSIC_BT_INCLUDED == TRUE)
/*******************************************************************************
**
@@ -1797,6 +1803,7 @@ tL2C_CCB *l2cu_find_ccb_by_remote_cid (tL2C_LCB *p_lcb, UINT16 remote_cid)
return (NULL);
}
#if (CLASSIC_BT_INCLUDED == TRUE)
/*******************************************************************************
**
** Function l2cu_allocate_rcb
@@ -1826,6 +1833,7 @@ tL2C_RCB *l2cu_allocate_rcb (UINT16 psm)
/* If here, no free RCB found */
return (NULL);
}
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
#if (BLE_INCLUDED == TRUE)
/*******************************************************************************
@@ -1905,7 +1913,7 @@ void l2cu_disconnect_chnl (tL2C_CCB *p_ccb)
}
}
#if (CLASSIC_BT_INCLUDED == TRUE)
/*******************************************************************************
**
** Function l2cu_find_rcb_by_psm
@@ -1930,6 +1938,7 @@ tL2C_RCB *l2cu_find_rcb_by_psm (UINT16 psm)
/* If here, no match found */
return (NULL);
}
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
#if (BLE_INCLUDED == TRUE)
/*******************************************************************************
@@ -2274,8 +2283,11 @@ BOOLEAN l2cu_create_conn (tL2C_LCB *p_lcb, tBT_TRANSPORT transport)
#if BTM_SCO_INCLUDED == TRUE
BOOLEAN is_sco_active;
#endif
#if (CLASSIC_BT_INCLUDED == TRUE)
list_node_t *p_node = NULL;
tL2C_LCB *p_lcb_cur = NULL;
#endif // (CLASSIC_BT_INCLUDED == TRUE)
#if (BLE_INCLUDED == TRUE)
tBT_DEVICE_TYPE dev_type;
@@ -2298,6 +2310,7 @@ BOOLEAN l2cu_create_conn (tL2C_LCB *p_lcb, tBT_TRANSPORT transport)
}
#endif
#if (CLASSIC_BT_INCLUDED == TRUE)
/* If there is a connection where we perform as a slave, try to switch roles
for this connection */
for (p_node = list_begin(l2cb.p_lcb_pool); p_node; p_node = list_next(p_node)) {
@@ -2341,6 +2354,8 @@ BOOLEAN l2cu_create_conn (tL2C_LCB *p_lcb, tBT_TRANSPORT transport)
p_lcb->link_state = LST_CONNECTING;
return (l2cu_create_conn_after_switch (p_lcb));
#endif // (CLASSIC_BT_INCLUDED == TRUE)
return false;
}
/*******************************************************************************
@@ -2367,7 +2382,7 @@ UINT8 l2cu_get_num_hi_priority (void)
return no_hi;
}
#if (CLASSIC_BT_INCLUDED == TRUE)
/*******************************************************************************
**
** Function l2cu_create_conn_after_switch
@@ -2442,7 +2457,7 @@ BOOLEAN l2cu_create_conn_after_switch (tL2C_LCB *p_lcb)
return (TRUE);
}
#endif // (CLASSIC_BT_INCLUDED == TRUE)
/*******************************************************************************
**