Remove BTA layer components for LE advertising
Advertising is so simple, it doesn't need the BTA layer.
Values returned by BTM_VendorSpecificCommand shouldn't be handled as
success or failure, it's just to inform wether we sent the callback.
Bug: 30622771
Change-Id: I104c4fbf84d3818b76fe8c527fbde4e6c4336c3a
diff --git a/bta/dm/bta_dm_act.cc b/bta/dm/bta_dm_act.cc
index 12f0c3f..4b4fc44 100644
--- a/bta/dm/bta_dm_act.cc
+++ b/bta/dm/bta_dm_act.cc
@@ -4736,50 +4736,6 @@
/*******************************************************************************
**
-** Function bta_dm_ble_set_adv_config
-**
-** Description This function set the customized ADV data configuration
-**
-** Parameters:
-**
-*******************************************************************************/
-void bta_dm_ble_set_adv_config (tBTA_BLE_AD_MASK data_mask,
- tBTA_BLE_ADV_DATA *adv_cfg,
- tBTA_SET_ADV_DATA_CMPL_CBACK *p_adv_data_cback)
-{
- tBTA_STATUS status = BTA_FAILURE;
-
- if (BTM_BleWriteAdvData(data_mask, (tBTM_BLE_ADV_DATA *)adv_cfg) == BTM_SUCCESS)
- status = BTA_SUCCESS;
-
- if (p_adv_data_cback)
- (*p_adv_data_cback)(status);
-}
-
-/*******************************************************************************
-**
-** Function bta_dm_ble_set_scan_rsp
-**
-** Description This function set the customized ADV scan resp. configuration
-**
-** Parameters:
-**
-*******************************************************************************/
-void bta_dm_ble_set_scan_rsp (tBTA_BLE_AD_MASK data_mask,
- tBTA_BLE_ADV_DATA *adv_cfg,
- tBTA_SET_ADV_DATA_CMPL_CBACK *p_adv_data_cback)
-{
- tBTA_STATUS status = BTA_FAILURE;
-
- if(BTM_BleWriteScanRsp(data_mask, (tBTM_BLE_ADV_DATA *)adv_cfg) == BTM_SUCCESS)
- status = BTA_SUCCESS;
-
- if (p_adv_data_cback)
- (*p_adv_data_cback)(status);
-}
-
-/*******************************************************************************
-**
** Function bta_dm_ble_set_data_length
**
** Description This function set the maximum transmission packet size
@@ -4810,109 +4766,6 @@
BTM_BleBroadcast(p_data->ble_observe.start);
}
-
-void bta_dm_ble_multi_adv_register(tBTA_BLE_MULTI_ADV_CBACK *p_cback) {
- bta_dm_cb.p_multi_adv_cback = p_cback;
-
- BTM_BleAdvRegister((tBTM_BLE_MULTI_ADV_CBACK *)p_cback);
-}
-
-/*******************************************************************************
-**
-** Function bta_dm_ble_multi_adv_enb
-**
-** Description This function enables a single advertising instance
-**
-** Parameters:
-**
-*******************************************************************************/
-void bta_dm_ble_multi_adv_enb(uint8_t inst_id, tBTA_BLE_ADV_PARAMS *p_params)
-{
- tBTM_STATUS btm_status = 0;
-
- if (BTM_BleMaxMultiAdvInstanceCount() > 0) {
- btm_status = BTM_BleEnableAdvInstance(inst_id,
- (tBTM_BLE_ADV_PARAMS *)p_params);
- }
-
- if (BTM_CMD_STARTED != btm_status) {
- bta_dm_cb.p_multi_adv_cback(BTA_BLE_MULTI_ADV_ENB_EVT, inst_id,
- BTA_FAILURE);
- }
-}
-/*******************************************************************************
-**
-** Function bta_dm_ble_multi_adv_param_upd
-**
-** Description This function updates multiple advertising instance parameters
-**
-** Parameters:
-**
-*******************************************************************************/
-void bta_dm_ble_multi_adv_upd_param(uint8_t inst_id, tBTA_BLE_ADV_PARAMS *p_params)
-{
- tBTM_STATUS btm_status = 0;
-
- if (BTM_BleMaxMultiAdvInstanceCount() > 0 && inst_id > 0
- && inst_id < BTM_BleMaxMultiAdvInstanceCount()) {
- btm_status = BTM_BleUpdateAdvInstParam(inst_id,
- (tBTM_BLE_ADV_PARAMS*)p_params);
- }
-
- if (BTM_CMD_STARTED != btm_status) {
- bta_dm_cb.p_multi_adv_cback(BTA_BLE_MULTI_ADV_PARAM_EVT, inst_id, BTA_FAILURE);
- }
-}
-/*******************************************************************************
-**
-** Function bta_dm_ble_multi_adv_data
-**
-** Description This function write multiple advertising instance adv data
-** or scan response data
-**
-** Parameters:
-**
-*******************************************************************************/
-void bta_dm_ble_multi_adv_data(uint8_t inst_id, bool is_scan_rsp,
- tBTA_BLE_AD_MASK data_mask, tBTA_BLE_ADV_DATA data)
-{
- tBTM_STATUS btm_status = 0;
-
- if (BTM_BleMaxMultiAdvInstanceCount() > 0 && inst_id > 0
- && inst_id < BTM_BleMaxMultiAdvInstanceCount()) {
- btm_status = BTM_BleCfgAdvInstData(inst_id, is_scan_rsp, data_mask,
- (tBTM_BLE_ADV_DATA*)&data);
- }
-
- if (BTM_CMD_STARTED != btm_status) {
- bta_dm_cb.p_multi_adv_cback(BTA_BLE_MULTI_ADV_DATA_EVT,
- inst_id, BTA_FAILURE);
- }
-}
-/*******************************************************************************
-**
-** Function btm_dm_ble_multi_adv_disable
-**
-** Description This function disable a single adv instance
-**
-** Parameters:
-**
-*******************************************************************************/
-void btm_dm_ble_multi_adv_disable(uint8_t inst_id)
-{
- tBTM_STATUS btm_status = 0;
-
- if (BTM_BleMaxMultiAdvInstanceCount() > 0 && inst_id > 0
- && inst_id < BTM_BleMaxMultiAdvInstanceCount()) {
- btm_status = BTM_BleDisableAdvInstance(inst_id);
- }
-
- if (BTM_CMD_STARTED != btm_status) {
- bta_dm_cb.p_multi_adv_cback(BTA_BLE_MULTI_ADV_DISABLE_EVT,
- inst_id, BTA_FAILURE);
- }
-}
-
/*******************************************************************************
**
** Function bta_dm_ble_setup_storage
diff --git a/bta/dm/bta_dm_api.cc b/bta/dm/bta_dm_api.cc
index dcf9bb4..7862d0b 100644
--- a/bta/dm/bta_dm_api.cc
+++ b/bta/dm/bta_dm_api.cc
@@ -904,52 +904,6 @@
#if (BLE_INCLUDED == TRUE)
/*******************************************************************************
**
-** Function BTA_DmBleSetAdvConfig
-**
-** Description This function is called to override the BTA default ADV parameters.
-**
-** Parameters data_mask: adv data mask.
-** p_adv_cfg: Pointer to User defined ADV data structure. This
-** memory space can not be freed until p_adv_data_cback
-** is received.
-** p_adv_data_cback: set adv data complete callback.
-**
-** Returns None
-**
-*******************************************************************************/
-void BTA_DmBleSetAdvConfig (tBTA_BLE_AD_MASK data_mask, tBTA_BLE_ADV_DATA *p_adv_cfg,
- tBTA_SET_ADV_DATA_CMPL_CBACK *p_adv_data_cback)
-{
- tBTA_BLE_ADV_DATA *adv_cfg = new tBTA_BLE_ADV_DATA;
- memcpy(adv_cfg, p_adv_cfg, sizeof(tBTA_BLE_ADV_DATA));
-
- do_in_bta_thread(FROM_HERE,
- base::Bind(&bta_dm_ble_set_adv_config, data_mask, base::Owned(adv_cfg), p_adv_data_cback));
-}
-
-/*******************************************************************************
-**
-** Function BTA_DmBleSetScanRsp
-**
-** Description This function is called to override the BTA scan response.
-**
-** Parameters Pointer to User defined ADV data structure
-**
-** Returns None
-**
-*******************************************************************************/
-extern void BTA_DmBleSetScanRsp (tBTA_BLE_AD_MASK data_mask, tBTA_BLE_ADV_DATA *p_adv_cfg,
- tBTA_SET_ADV_DATA_CMPL_CBACK *p_adv_data_cback)
-{
- tBTA_BLE_ADV_DATA *adv_cfg = new tBTA_BLE_ADV_DATA;
- memcpy(adv_cfg, p_adv_cfg, sizeof(tBTA_BLE_ADV_DATA));
-
- do_in_bta_thread(FROM_HERE,
- base::Bind(&bta_dm_ble_set_scan_rsp, data_mask, base::Owned(adv_cfg), p_adv_data_cback));
-}
-
-/*******************************************************************************
-**
** Function BTA_DmBleSetStorageParams
**
** Description This function is called to override the BTA scan response.
@@ -1362,114 +1316,6 @@
}
#if (BLE_INCLUDED == TRUE)
-
-/*******************************************************************************
-**
-** Register an advertising instance, status will be returned in |p_cback|
-** callback, with assigned id, if operation succeeds. Instance is freed when
-** advertising is disabled by calling |BTA_BleDisableAdvInstance|, or when any
-** of the operations fails.
-*******************************************************************************/
-void BTA_BleAdvRegisterInstance(tBTA_BLE_MULTI_ADV_CBACK *p_cback) {
- do_in_bta_thread(FROM_HERE,
- base::Bind(&bta_dm_ble_multi_adv_register, p_cback));
-}
-
-/*******************************************************************************
-**
-** Function BTA_BleEnableAdvInstance
-**
-** Description This function enable a Multi-ADV instance with the specififed
-** 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 sucessfully; otherwise failure.
-**
-*******************************************************************************/
-void BTA_BleEnableAdvInstance (uint8_t inst_id, tBTA_BLE_ADV_PARAMS *p_params)
-{
- APPL_TRACE_API("%s", __func__);
-
- if (p_params != NULL) {
- tBTA_BLE_ADV_PARAMS *params = new tBTA_BLE_ADV_PARAMS;
- memcpy(params, p_params, sizeof(tBTA_BLE_ADV_PARAMS));
- do_in_bta_thread(FROM_HERE,
- base::Bind(&bta_dm_ble_multi_adv_enb, inst_id, base::Owned(params)));
- } else {
- do_in_bta_thread(FROM_HERE,
- base::Bind(&bta_dm_ble_multi_adv_enb, inst_id, nullptr));
- }
-}
-
-/*******************************************************************************
-**
-** Function BTA_BleUpdateAdvInstParam
-**
-** Description This function update a Multi-ADV instance with the specififed
-** 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 sucessfully; otherwise failure.
-**
-*******************************************************************************/
-void BTA_BleUpdateAdvInstParam (uint8_t inst_id, tBTA_BLE_ADV_PARAMS *p_params)
-{
- APPL_TRACE_API("%s", __func__);
-
- tBTA_BLE_ADV_PARAMS *params = new tBTA_BLE_ADV_PARAMS;
- memcpy(params, p_params, sizeof(tBTA_BLE_ADV_PARAMS));
- do_in_bta_thread(FROM_HERE,
- base::Bind(&bta_dm_ble_multi_adv_upd_param, inst_id, base::Owned(params)));
-}
-
-/*******************************************************************************
-**
-** Function BTA_BleCfgAdvInstData
-**
-** Description This function configure a Multi-ADV instance with the specififed
-** 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 sucessfully; otherwise failure.
-**
-*******************************************************************************/
-void BTA_BleCfgAdvInstData (uint8_t inst_id, bool is_scan_rsp,
- tBTA_BLE_AD_MASK data_mask,
- tBTA_BLE_ADV_DATA *p_data)
-{
- do_in_bta_thread(FROM_HERE,
- base::Bind(&bta_dm_ble_multi_adv_data, inst_id, is_scan_rsp, data_mask, *p_data));
-}
-
-/*******************************************************************************
-**
-** Function BTA_BleDisableAdvInstance
-**
-** Description This function disable a Multi-ADV instance.
-**
-** Parameter inst_id: instance ID to disable.
-**
-** Returns BTA_SUCCESS if command started sucessfully; otherwise failure.
-**
-*******************************************************************************/
-void BTA_BleDisableAdvInstance(uint8_t inst_id)
-{
- APPL_TRACE_API("%s: %d", __func__, inst_id);
-
- do_in_bta_thread(FROM_HERE,
- base::Bind(&btm_dm_ble_multi_adv_disable, inst_id));
-}
-
/*******************************************************************************
**
** Function BTA_DmBleCfgFilterCondition
diff --git a/bta/dm/bta_dm_int.h b/bta/dm/bta_dm_int.h
index 5c1b3ff..62f59dd 100644
--- a/bta/dm/bta_dm_int.h
+++ b/bta/dm/bta_dm_int.h
@@ -799,7 +799,6 @@
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;
- tBTA_BLE_MULTI_ADV_CBACK *p_multi_adv_cback;
tBTA_BLE_ENERGY_INFO_CBACK *p_energy_info_cback;
#endif
uint16_t state;
@@ -1040,12 +1039,6 @@
extern void bta_dm_ble_config_local_privacy (tBTA_DM_MSG *p_data);
extern void bta_dm_ble_set_adv_params(uint16_t adv_int_min, uint16_t adv_int_max,
tBLE_BD_ADDR *p_dir_bda);
-extern void bta_dm_ble_set_adv_config (tBTA_BLE_AD_MASK data_mask,
- tBTA_BLE_ADV_DATA *adv_cfg,
- tBTA_SET_ADV_DATA_CMPL_CBACK *p_adv_data_cback);
-extern void bta_dm_ble_set_scan_rsp (tBTA_BLE_AD_MASK data_mask,
- tBTA_BLE_ADV_DATA *adv_cfg,
- tBTA_SET_ADV_DATA_CMPL_CBACK *p_adv_data_cback);
extern void bta_dm_ble_broadcast (tBTA_DM_MSG *p_data);
extern void bta_dm_ble_set_data_length(tBTA_DM_MSG *p_data);
@@ -1055,15 +1048,6 @@
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 bta_dm_ble_multi_adv_register(tBTA_BLE_MULTI_ADV_CBACK *p_cback);
-extern void btm_dm_ble_multi_adv_disable(uint8_t inst_id);
-extern void bta_dm_ble_multi_adv_data(uint8_t inst_id, bool is_scan_rsp,
- tBTA_BLE_AD_MASK data_mask,
- tBTA_BLE_ADV_DATA data);
-extern void bta_dm_ble_multi_adv_upd_param(uint8_t inst_id,
- tBTA_BLE_ADV_PARAMS *p_params);
-extern void bta_dm_ble_multi_adv_enb(uint8_t inst_id,
- tBTA_BLE_ADV_PARAMS *p_params);
extern void bta_dm_ble_setup_storage(tBTA_DM_MSG *p_data);
extern void bta_dm_ble_enable_batch_scan(tBTA_DM_MSG * p_data);
diff --git a/bta/include/bta_api.h b/bta/include/bta_api.h
index 4b79174..a4e27d1 100644
--- a/bta/include/bta_api.h
+++ b/bta/include/bta_api.h
@@ -369,41 +369,9 @@
typedef void (tBTA_SET_ADV_DATA_CMPL_CBACK) (tBTA_STATUS status);
-/* advertising channel map */
-#define BTA_BLE_ADV_CHNL_37 BTM_BLE_ADV_CHNL_37
-#define BTA_BLE_ADV_CHNL_38 BTM_BLE_ADV_CHNL_38
-#define BTA_BLE_ADV_CHNL_39 BTM_BLE_ADV_CHNL_39
-typedef tBTM_BLE_ADV_CHNL_MAP tBTA_BLE_ADV_CHNL_MAP; /* use as a bit mask */
-
/* advertising filter policy */
typedef tBTM_BLE_AFP tBTA_BLE_AFP;
-/* adv event type */
-#define BTA_BLE_CONNECT_EVT BTM_BLE_CONNECT_EVT /* Connectable undirected advertising */
-#define BTA_BLE_CONNECT_DIR_EVT BTM_BLE_CONNECT_DIR_EVT /* Connectable directed advertising */
-#define BTA_BLE_DISCOVER_EVT BTM_BLE_DISCOVER_EVT /* Scannable undirected advertising */
-#define BTA_BLE_NON_CONNECT_EVT BTM_BLE_NON_CONNECT_EVT /* Non connectable undirected advertising */
-typedef uint8_t tBTA_BLE_ADV_EVT;
-
-/* adv tx power level */
-#define BTA_BLE_ADV_TX_POWER_MIN 0 /* minimum tx power */
-#define BTA_BLE_ADV_TX_POWER_LOW 1 /* low tx power */
-#define BTA_BLE_ADV_TX_POWER_MID 2 /* middle tx power */
-#define BTA_BLE_ADV_TX_POWER_UPPER 3 /* upper tx power */
-#define BTA_BLE_ADV_TX_POWER_MAX 4 /* maximum tx power */
-typedef uint8_t tBTA_BLE_ADV_TX_POWER;
-
-/* advertising instance parameters */
-typedef struct
-{
- uint16_t adv_int_min; /* minimum adv interval */
- uint16_t adv_int_max; /* maximum adv interval */
- tBTA_BLE_ADV_EVT adv_type; /* adv event type */
- tBTA_BLE_ADV_CHNL_MAP channel_map; /* adv channel map */
- tBTA_BLE_AFP adv_filter_policy; /* advertising filter policy */
- tBTA_BLE_ADV_TX_POWER tx_power; /* adv tx power */
-}tBTA_BLE_ADV_PARAMS;
-
/* These are the fields returned in each device adv packet. It
** is returned in the results callback if registered.
*/
@@ -902,20 +870,6 @@
/* Security callback */
typedef void (tBTA_DM_SEC_CBACK)(tBTA_DM_SEC_EVT event, tBTA_DM_SEC *p_data);
-#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
-#define BTA_BLE_MULTI_ADV_REG_EVT 5
-
-typedef uint8_t tBTA_BLE_MULTI_ADV_EVT;
-
-/* multi adv callback */
-typedef void (tBTA_BLE_MULTI_ADV_CBACK)(tBTA_BLE_MULTI_ADV_EVT event,
- uint8_t inst_id, tBTA_STATUS status);
typedef uint32_t tBTA_DM_BLE_REF_VALUE;
#define BTA_DM_BLE_PF_ENABLE_EVT BTM_BLE_PF_ENABLE
@@ -2005,36 +1959,6 @@
/*******************************************************************************
**
-** Function BTA_DmBleSetAdvConfig
-**
-** Description This function is called to override the BTA default ADV parameters.
-**
-** Parameters Pointer to User defined ADV data structure
-**
-** Returns None
-**
-*******************************************************************************/
-extern void BTA_DmBleSetAdvConfig (tBTA_BLE_AD_MASK data_mask,
- tBTA_BLE_ADV_DATA *p_adv_cfg,
- tBTA_SET_ADV_DATA_CMPL_CBACK *p_adv_data_cback);
-
-/*******************************************************************************
-**
-** Function BTA_DmBleSetScanRsp
-**
-** Description This function is called to override the BTA scan response.
-**
-** Parameters Pointer to User defined ADV data structure
-**
-** Returns None
-**
-*******************************************************************************/
-extern void BTA_DmBleSetScanRsp (tBTA_BLE_AD_MASK data_mask,
- tBTA_BLE_ADV_DATA *p_adv_cfg,
- tBTA_SET_ADV_DATA_CMPL_CBACK *p_adv_data_cback);
-
-/*******************************************************************************
-**
** Function BTA_DmBleBroadcast
**
** Description This function starts or stops LE broadcasting.
@@ -2048,72 +1972,6 @@
/*******************************************************************************
**
-** Register an advertising instance, status will be returned in |p_cback|
-** callback, with assigned id, if operation succeeds. Instance is freed when
-** advertising is disabled by calling |BTA_BleDisableAdvInstance|, or when any
-** of the operations fails.
-*******************************************************************************/
-extern void BTA_BleAdvRegisterInstance(tBTA_BLE_MULTI_ADV_CBACK *p_cback);
-
-/*******************************************************************************
-**
-** Function BTA_BleEnableAdvInstance
-**
-** Description This function enables the Multi ADV instance feature
-**
-** Parameters inst_id Instance ID
-** p_params Pointer to ADV param user defined structure
-**
-** Returns None
-**
-*******************************************************************************/
-extern void BTA_BleEnableAdvInstance(uint8_t inst_id, tBTA_BLE_ADV_PARAMS *p_params);
-
-/*******************************************************************************
-**
-** 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_t 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_t inst_id, bool 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_t inst_id);
-
-/*******************************************************************************
-**
** Function BTA_DmBleUpdateConnectionParams
**
** Description Update connection parameters, can only be used when connection is up.
diff --git a/btif/include/btif_gatt_multi_adv_util.h b/btif/include/btif_gatt_multi_adv_util.h
index a93a67d..aec85ed 100644
--- a/btif/include/btif_gatt_multi_adv_util.h
+++ b/btif/include/btif_gatt_multi_adv_util.h
@@ -56,7 +56,7 @@
uint8_t advertiser_id;
tBTA_BLE_AD_MASK mask;
tBTA_BLE_ADV_DATA data;
- tBTA_BLE_ADV_PARAMS param;
+ tBTM_BLE_ADV_PARAMS param;
alarm_t *multi_adv_timer;
int timeout_s;
} btgatt_multi_adv_inst_cb;
diff --git a/btif/src/btif_ble_advertiser.cc b/btif/src/btif_ble_advertiser.cc
index 67ad122..a4c37c0 100644
--- a/btif/src/btif_ble_advertiser.cc
+++ b/btif/src/btif_ble_advertiser.cc
@@ -23,6 +23,7 @@
#include <base/bind.h>
+#include "bta_closure_api.h"
#include "bta_api.h"
#include "bta_gatt_api.h"
#include "btif_common.h"
@@ -87,23 +88,23 @@
advertiser_id, ®istering_uuid);
}
-void bta_gattc_multi_adv_cback(tBTA_BLE_MULTI_ADV_EVT event, uint8_t advertiser_id,
+void bta_gattc_multi_adv_cback(tBTM_BLE_MULTI_ADV_EVT event, uint8_t advertiser_id,
tBTA_STATUS status) {
BTIF_TRACE_DEBUG("%s: advertiser_id: %d, Status:%x", __func__, advertiser_id, status);
- if (event == BTA_BLE_MULTI_ADV_ENB_EVT)
+ if (event == BTM_BLE_MULTI_ADV_ENB_EVT)
do_in_jni_thread(
Bind(multi_adv_enable_cb_impl, advertiser_id, status));
- else if (event == BTA_BLE_MULTI_ADV_DISABLE_EVT)
+ else if (event == BTM_BLE_MULTI_ADV_DISABLE_EVT)
do_in_jni_thread(
Bind(multi_adv_disable_cb_impl, advertiser_id, status));
- else if (event == BTA_BLE_MULTI_ADV_PARAM_EVT)
+ else if (event == BTM_BLE_MULTI_ADV_PARAM_EVT)
do_in_jni_thread(
Bind(multi_adv_update_cb_impl, advertiser_id, status));
- else if (event == BTA_BLE_MULTI_ADV_DATA_EVT)
+ else if (event == BTM_BLE_MULTI_ADV_DATA_EVT)
do_in_jni_thread(Bind(multi_adv_data_cb_impl, advertiser_id, status));
- else if (event == BTA_BLE_MULTI_ADV_REG_EVT)
+ else if (event == BTM_BLE_MULTI_ADV_REG_EVT)
do_in_jni_thread(Bind(multi_adv_reg_cb_impl, advertiser_id, status));
}
@@ -116,14 +117,23 @@
if (cbindex >= 0 && btif_gattc_copy_datacb(cbindex, p_adv_data, false)) {
btgatt_multi_adv_common_data *p_multi_adv_data_cb =
btif_obtain_multi_adv_data_cb();
+
+ tBTM_BLE_ADV_DATA *adv_cfg = new tBTM_BLE_ADV_DATA;
+ memcpy(adv_cfg, &p_multi_adv_data_cb->inst_cb[cbindex].data,
+ sizeof(tBTM_BLE_ADV_DATA));
+
if (!p_adv_data->set_scan_rsp) {
- BTA_DmBleSetAdvConfig(p_multi_adv_data_cb->inst_cb[cbindex].mask,
- &p_multi_adv_data_cb->inst_cb[cbindex].data,
- bta_adv_set_data_cback);
+ do_in_bta_thread(FROM_HERE,
+ base::Bind(&BTM_BleWriteAdvData,
+ p_multi_adv_data_cb->inst_cb[cbindex].mask,
+ base::Owned(adv_cfg),
+ bta_adv_set_data_cback));
} else {
- BTA_DmBleSetScanRsp(p_multi_adv_data_cb->inst_cb[cbindex].mask,
- &p_multi_adv_data_cb->inst_cb[cbindex].data,
- bta_adv_set_data_cback);
+ do_in_bta_thread(FROM_HERE,
+ base::Bind(&BTM_BleWriteScanRsp,
+ p_multi_adv_data_cb->inst_cb[cbindex].mask,
+ base::Owned(adv_cfg),
+ bta_adv_set_data_cback));
}
} else {
BTIF_TRACE_ERROR("%s: failed to get instance data cbindex: %d", __func__,
@@ -157,7 +167,7 @@
int timeout_s) {
BTIF_TRACE_DEBUG("%s: advertiser_id: %d", __func__, advertiser_id);
- tBTA_BLE_ADV_PARAMS param;
+ tBTM_BLE_ADV_PARAMS param;
param.adv_int_min = min_interval;
param.adv_int_max = max_interval;
param.adv_type = adv_type;
@@ -168,10 +178,14 @@
btgatt_multi_adv_common_data *p_multi_adv_data_cb =
btif_obtain_multi_adv_data_cb();
memcpy(&p_multi_adv_data_cb->inst_cb[advertiser_id].param, ¶m,
- sizeof(tBTA_BLE_ADV_PARAMS));
+ sizeof(tBTM_BLE_ADV_PARAMS));
p_multi_adv_data_cb->inst_cb[advertiser_id].timeout_s = timeout_s;
- BTA_BleEnableAdvInstance(advertiser_id,
- &(p_multi_adv_data_cb->inst_cb[advertiser_id].param));
+
+ tBTM_BLE_ADV_PARAMS *params = new tBTM_BLE_ADV_PARAMS;
+ memcpy(params, &(p_multi_adv_data_cb->inst_cb[advertiser_id].param), sizeof(tBTM_BLE_ADV_PARAMS));
+ do_in_bta_thread(FROM_HERE,
+ base::Bind(&BTM_BleEnableAdvInstance, advertiser_id, base::Owned(params)));
+
}
bt_status_t btif_multiadv_enable(int advertiser_id, int min_interval,
@@ -187,7 +201,7 @@
void btif_multiadv_update_impl(int advertiser_id, int min_interval,
int max_interval, int adv_type,
int chnl_map, int tx_power) {
- tBTA_BLE_ADV_PARAMS param;
+ tBTM_BLE_ADV_PARAMS param;
param.adv_int_min = min_interval;
param.adv_int_max = max_interval;
param.adv_type = adv_type;
@@ -198,9 +212,12 @@
btgatt_multi_adv_common_data *p_multi_adv_data_cb =
btif_obtain_multi_adv_data_cb();
memcpy(&p_multi_adv_data_cb->inst_cb[advertiser_id].param, ¶m,
- sizeof(tBTA_BLE_ADV_PARAMS));
- BTA_BleUpdateAdvInstParam((uint8_t)advertiser_id,
- &(p_multi_adv_data_cb->inst_cb[advertiser_id].param));
+ sizeof(tBTM_BLE_ADV_PARAMS));
+
+ tBTM_BLE_ADV_PARAMS *params = new tBTM_BLE_ADV_PARAMS;
+ memcpy(params, &(p_multi_adv_data_cb->inst_cb[advertiser_id].param), sizeof(tBTM_BLE_ADV_PARAMS));
+ do_in_bta_thread(FROM_HERE,
+ base::Bind(&BTM_BleUpdateAdvInstParam, advertiser_id, base::Owned(params)));
}
bt_status_t btif_multiadv_update(int advertiser_id, int min_interval,
@@ -223,9 +240,11 @@
btgatt_multi_adv_common_data *p_multi_adv_data_cb =
btif_obtain_multi_adv_data_cb();
- BTA_BleCfgAdvInstData(advertiser_id, p_adv_data->set_scan_rsp,
- p_multi_adv_data_cb->inst_cb[advertiser_id].mask,
- &p_multi_adv_data_cb->inst_cb[advertiser_id].data);
+
+ do_in_bta_thread(FROM_HERE,
+ base::Bind(&BTM_BleCfgAdvInstData, advertiser_id, p_adv_data->set_scan_rsp,
+ p_multi_adv_data_cb->inst_cb[advertiser_id].mask,
+ (tBTM_BLE_ADV_DATA*)&p_multi_adv_data_cb->inst_cb[advertiser_id].data));
}
bt_status_t btif_multiadv_set_data(int advertiser_id, bool set_scan_rsp,
@@ -250,20 +269,19 @@
base::Owned(multi_adv_data_inst)));
}
-void btif_multiadv_disable_impl(int advertiser_id) {
- BTA_BleDisableAdvInstance((uint8_t)advertiser_id);
-}
-
bt_status_t btif_multiadv_disable(int advertiser_id) {
CHECK_BTGATT_INIT();
- return do_in_jni_thread(Bind(btif_multiadv_disable_impl, advertiser_id));
+ do_in_bta_thread(FROM_HERE, Bind(BTM_BleDisableAdvInstance, advertiser_id));
+ return (bt_status_t)BTA_GATT_OK;
}
bt_status_t btif_multiadv_register(bt_uuid_t *uuid) {
btif_gattc_incr_app_count();
registering_uuid = *uuid;
- BTA_BleAdvRegisterInstance(bta_gattc_multi_adv_cback);
+
+ do_in_bta_thread(FROM_HERE,
+ base::Bind(&BTM_BleAdvRegister, bta_gattc_multi_adv_cback));
return (bt_status_t)BTA_GATT_OK;
}
diff --git a/btif/src/btif_gatt_multi_adv_util.cc b/btif/src/btif_gatt_multi_adv_util.cc
index 6987957..9059443 100644
--- a/btif/src/btif_gatt_multi_adv_util.cc
+++ b/btif/src/btif_gatt_multi_adv_util.cc
@@ -157,7 +157,7 @@
p_multi_adv_data_cb->inst_cb[cbindex].data.flag = ADV_FLAGS_GENERAL;
if (p_multi_adv_data_cb->inst_cb[cbindex].timeout_s)
p_multi_adv_data_cb->inst_cb[cbindex].data.flag = ADV_FLAGS_LIMITED;
- if (p_multi_adv_data_cb->inst_cb[cbindex].param.adv_type == BTA_BLE_NON_CONNECT_EVT)
+ if (p_multi_adv_data_cb->inst_cb[cbindex].param.adv_type == BTM_BLE_NON_CONNECT_EVT)
p_multi_adv_data_cb->inst_cb[cbindex].data.flag &=
~(BTA_DM_LIMITED_DISC | BTA_DM_GENERAL_DISC);
if (p_multi_adv_data_cb->inst_cb[cbindex].data.flag == 0)
diff --git a/stack/btm/btm_ble_gap.c b/stack/btm/btm_ble_gap.c
index 120d8a9..b8b4a84 100644
--- a/stack/btm/btm_ble_gap.c
+++ b/stack/btm/btm_ble_gap.c
@@ -1197,15 +1197,18 @@
** Returns void
**
*******************************************************************************/
-tBTM_STATUS BTM_BleWriteScanRsp(tBTM_BLE_AD_MASK data_mask, tBTM_BLE_ADV_DATA *p_data)
+void BTM_BleWriteScanRsp(tBTM_BLE_AD_MASK data_mask, tBTM_BLE_ADV_DATA *p_data,
+ tBTM_BLE_ADV_DATA_CMPL_CBACK *p_adv_data_cback)
{
tBTM_STATUS status = BTM_NO_RESOURCES;
uint8_t rsp_data[BTM_BLE_AD_DATA_LEN],
*p = rsp_data;
BTM_TRACE_EVENT ("%s: data_mask:%08x", __func__, data_mask);
- if (!controller_get_interface()->supports_ble())
- return BTM_ILLEGAL_VALUE;
+ if (!controller_get_interface()->supports_ble()) {
+ p_adv_data_cback(BTM_ILLEGAL_VALUE);
+ return;
+ }
memset(rsp_data, 0, BTM_BLE_AD_DATA_LEN);
btm_ble_build_adv_data(&data_mask, &p, p_data);
@@ -1222,7 +1225,7 @@
else
status = BTM_ILLEGAL_VALUE;
- return status;
+ p_adv_data_cback(status);
}
/*******************************************************************************
@@ -1236,7 +1239,8 @@
** Returns void
**
*******************************************************************************/
-tBTM_STATUS BTM_BleWriteAdvData(tBTM_BLE_AD_MASK data_mask, tBTM_BLE_ADV_DATA *p_data)
+void BTM_BleWriteAdvData(tBTM_BLE_AD_MASK data_mask, tBTM_BLE_ADV_DATA *p_data,
+ tBTM_BLE_ADV_DATA_CMPL_CBACK *p_adv_data_cback)
{
tBTM_BLE_LOCAL_ADV_DATA *p_cb_data = &btm_cb.ble_ctr_cb.inq_var.adv_data;
uint8_t *p;
@@ -1244,8 +1248,10 @@
BTM_TRACE_EVENT ("BTM_BleWriteAdvData ");
- if (!controller_get_interface()->supports_ble())
- return BTM_ILLEGAL_VALUE;
+ if (!controller_get_interface()->supports_ble()) {
+ p_adv_data_cback(BTM_ILLEGAL_VALUE);
+ return;
+ }
memset(p_cb_data, 0, sizeof(tBTM_BLE_LOCAL_ADV_DATA));
p = p_cb_data->ad_data;
@@ -1264,9 +1270,9 @@
if (btsnd_hcic_ble_set_adv_data((uint8_t)(p_cb_data->p_pad - p_cb_data->ad_data),
p_cb_data->ad_data))
- return BTM_SUCCESS;
+ p_adv_data_cback(BTM_SUCCESS);
else
- return BTM_NO_RESOURCES;
+ p_adv_data_cback(BTM_NO_RESOURCES);
}
diff --git a/stack/btm/btm_ble_multi_adv.c b/stack/btm/btm_ble_multi_adv.c
index 057e631..6210738 100644
--- a/stack/btm/btm_ble_multi_adv.c
+++ b/stack/btm/btm_ble_multi_adv.c
@@ -193,14 +193,13 @@
** Parameters enable: enable or disable
** inst_id: adv instance ID, can not be 0
**
-** Returns status
+** Returns void
**
*******************************************************************************/
-tBTM_STATUS btm_ble_enable_multi_adv (bool enable, uint8_t inst_id, uint8_t cb_evt)
+void btm_ble_enable_multi_adv(bool enable, uint8_t inst_id, uint8_t cb_evt)
{
uint8_t param[BTM_BLE_MULTI_ADV_ENB_LEN], *pp;
uint8_t enb = enable ? 1: 0;
- tBTM_STATUS rt;
pp = param;
memset(param, 0, BTM_BLE_MULTI_ADV_ENB_LEN);
@@ -211,15 +210,11 @@
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;
+ BTM_VendorSpecificCommand(HCI_BLE_MULTI_ADV_OCF,
+ BTM_BLE_MULTI_ADV_ENB_LEN,
+ param,
+ btm_ble_multi_adv_vsc_cmpl_cback);
+ btm_ble_multi_adv_enq_op_q(BTM_BLE_MULTI_ADV_ENB, inst_id, cb_evt);
}
/*******************************************************************************
**
@@ -247,15 +242,14 @@
**
** Parameters advertise parameters used for this instance.
**
-** Returns status
+** Returns void
**
*******************************************************************************/
-tBTM_STATUS btm_ble_multi_adv_set_params (tBTM_BLE_MULTI_ADV_INST *p_inst,
+void btm_ble_multi_adv_set_params (tBTM_BLE_MULTI_ADV_INST *p_inst,
tBTM_BLE_ADV_PARAMS *p_params,
uint8_t cb_evt)
{
uint8_t param[BTM_BLE_MULTI_ADV_SET_PARAM_LEN], *pp;
- tBTM_STATUS rt;
BD_ADDR dummy ={0,0,0,0,0,0};
pp = param;
@@ -303,25 +297,22 @@
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;
+ BTM_VendorSpecificCommand(HCI_BLE_MULTI_ADV_OCF,
+ BTM_BLE_MULTI_ADV_SET_PARAM_LEN,
+ param,
+ btm_ble_multi_adv_vsc_cmpl_cback);
+
+ p_inst->adv_evt = p_params->adv_type;
#if (BLE_PRIVACY_SPT == TRUE)
- if (btm_cb.ble_ctr_cb.privacy_mode != BTM_PRIVACY_NONE) {
- alarm_set_on_queue(p_inst->adv_raddr_timer,
- BTM_BLE_PRIVATE_ADDR_INT_MS,
- btm_ble_adv_raddr_timer_timeout, p_inst,
- btu_general_alarm_queue);
- }
-#endif
- btm_ble_multi_adv_enq_op_q(BTM_BLE_MULTI_ADV_SET_PARAM, p_inst->inst_id, cb_evt);
+ if (btm_cb.ble_ctr_cb.privacy_mode != BTM_PRIVACY_NONE) {
+ alarm_set_on_queue(p_inst->adv_raddr_timer,
+ BTM_BLE_PRIVATE_ADDR_INT_MS,
+ btm_ble_adv_raddr_timer_timeout, p_inst,
+ btu_general_alarm_queue);
}
- return rt;
+#endif
+ btm_ble_multi_adv_enq_op_q(BTM_BLE_MULTI_ADV_SET_PARAM, p_inst->inst_id, cb_evt);
}
/*******************************************************************************
@@ -333,13 +324,12 @@
**
** Parameters
**
-** Returns status
+** Returns void
**
*******************************************************************************/
-tBTM_STATUS btm_ble_multi_adv_write_rpa (tBTM_BLE_MULTI_ADV_INST *p_inst, BD_ADDR random_addr)
+void btm_ble_multi_adv_write_rpa(tBTM_BLE_MULTI_ADV_INST *p_inst, BD_ADDR random_addr)
{
uint8_t 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",
__func__, random_addr[5], random_addr[4], random_addr[3], random_addr[2],
@@ -351,21 +341,19 @@
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 */
- /* TODO: is the above comment correct - is the timer periodical? */
- alarm_set_on_queue(p_inst->adv_raddr_timer,
- BTM_BLE_PRIVATE_ADDR_INT_MS,
- btm_ble_adv_raddr_timer_timeout, p_inst,
- btu_general_alarm_queue);
- btm_ble_multi_adv_enq_op_q(BTM_BLE_MULTI_ADV_SET_RANDOM_ADDR,
- p_inst->inst_id, 0);
- }
- return rt;
+ BTM_VendorSpecificCommand(HCI_BLE_MULTI_ADV_OCF,
+ BTM_BLE_MULTI_ADV_SET_RANDOM_ADDR_LEN,
+ param,
+ btm_ble_multi_adv_vsc_cmpl_cback);
+
+ /* start a periodical timer to refresh random addr */
+ /* TODO: is the above comment correct - is the timer periodical? */
+ alarm_set_on_queue(p_inst->adv_raddr_timer,
+ BTM_BLE_PRIVATE_ADDR_INT_MS,
+ btm_ble_adv_raddr_timer_timeout, p_inst,
+ btu_general_alarm_queue);
+ btm_ble_multi_adv_enq_op_q(BTM_BLE_MULTI_ADV_SET_RANDOM_ADDR,
+ p_inst->inst_id, 0);
}
/*******************************************************************************
@@ -567,43 +555,31 @@
** Returns status
**
*******************************************************************************/
-tBTM_STATUS BTM_BleEnableAdvInstance (uint8_t inst_id, tBTM_BLE_ADV_PARAMS *p_params)
+void BTM_BleEnableAdvInstance(uint8_t inst_id, tBTM_BLE_ADV_PARAMS *p_params)
{
- tBTM_STATUS rt = BTM_NO_RESOURCES;
-
BTM_TRACE_EVENT("%s:", __func__);
if (0 == btm_cb.cmn_ble_vsc_cb.adv_inst_max) {
- BTM_TRACE_ERROR("%s: Controller does not support Multi ADV", __func__);
- return BTM_ERR_PROCESSING;
+ BTM_TRACE_ERROR("%s: multi adv not supported", __func__);
+ return;
}
tBTM_BLE_MULTI_ADV_INST *p_inst = &btm_multi_adv_cb.p_adv_inst[inst_id - 1];
if (!p_inst || !p_inst->in_use) {
BTM_TRACE_ERROR("%s: Invalid or not active instance", __func__);
- return BTM_ERR_PROCESSING;
+ (p_inst->p_cback)(BTM_BLE_MULTI_ADV_ENB_EVT, inst_id, BTM_BLE_MULTI_ADV_FAILURE);
+ return;
}
/* configure adv parameter */
if (p_params)
- rt = btm_ble_multi_adv_set_params(p_inst, p_params, 0);
- else
- rt = BTM_CMD_STARTED;
+ btm_ble_multi_adv_set_params(p_inst, p_params, 0);
/* enable adv */
BTM_TRACE_EVENT("%s: being called with inst_id:%d", __func__, p_inst->inst_id);
- if (BTM_CMD_STARTED == rt) {
- rt = btm_ble_enable_multi_adv(true, p_inst->inst_id,
- BTM_BLE_MULTI_ADV_ENB_EVT);
- }
-
- if (BTM_CMD_STARTED != rt) {
- p_inst->in_use = false;
- BTM_TRACE_ERROR("%s: failed", __func__);
- }
-
- return rt;
+ btm_ble_enable_multi_adv(true, p_inst->inst_id,
+ BTM_BLE_MULTI_ADV_ENB_EVT);
}
/*******************************************************************************
@@ -619,35 +595,32 @@
** Returns status
**
*******************************************************************************/
-tBTM_STATUS BTM_BleUpdateAdvInstParam (uint8_t inst_id, tBTM_BLE_ADV_PARAMS *p_params)
+void BTM_BleUpdateAdvInstParam(uint8_t 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 (0 == btm_cb.cmn_ble_vsc_cb.adv_inst_max) {
+ BTM_TRACE_ERROR("%s: multi adv not supported", __func__);
+ return;
}
- 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);
+ if (inst_id > BTM_BleMaxMultiAdvInstanceCount() || inst_id < 0 ||
+ inst_id == BTM_BLE_MULTI_ADV_DEFAULT_STD) {
+ BTM_TRACE_ERROR("%s: bad instance id %d", __func__, inst_id);
+ return;
}
- return rt;
+
+ if (!p_inst->in_use) {
+ BTM_TRACE_ERROR("adv instance %d is not active", inst_id);
+ (p_inst->p_cback)(BTM_BLE_MULTI_ADV_PARAM_EVT, inst_id, BTM_BLE_MULTI_ADV_FAILURE);
+ return;
+ }
+
+ btm_ble_enable_multi_adv(false, inst_id, 0);
+ btm_ble_multi_adv_set_params(p_inst, p_params, 0);
+ btm_ble_enable_multi_adv(true, inst_id, BTM_BLE_MULTI_ADV_PARAM_EVT);
}
/*******************************************************************************
@@ -665,31 +638,31 @@
** Returns status
**
*******************************************************************************/
-tBTM_STATUS BTM_BleCfgAdvInstData (uint8_t inst_id, bool is_scan_rsp,
- tBTM_BLE_AD_MASK data_mask,
- tBTM_BLE_ADV_DATA *p_data)
+void BTM_BleCfgAdvInstData(uint8_t inst_id, bool is_scan_rsp,
+ tBTM_BLE_AD_MASK data_mask,
+ tBTM_BLE_ADV_DATA *p_data)
{
uint8_t param[BTM_BLE_MULTI_ADV_WRITE_DATA_LEN], *pp = param;
uint8_t sub_code = (is_scan_rsp) ?
BTM_BLE_MULTI_ADV_WRITE_SCAN_RSP_DATA : BTM_BLE_MULTI_ADV_WRITE_ADV_DATA;
uint8_t *p_len;
- tBTM_STATUS rt;
uint8_t *pp_temp = (uint8_t*)(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;
+ if (0 == cmn_ble_vsc_cb.adv_inst_max) {
+ BTM_TRACE_ERROR("%s: multi adv not supported", __func__);
+ return;
}
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;
+ if (inst_id > BTM_BleMaxMultiAdvInstanceCount() || inst_id < 0 ||
+ inst_id == BTM_BLE_MULTI_ADV_DEFAULT_STD) {
+ BTM_TRACE_ERROR("%s: bad instance id %d", __func__, inst_id);
+ return;
+ }
memset(param, 0, BTM_BLE_MULTI_ADV_WRITE_DATA_LEN);
@@ -699,15 +672,12 @@
*p_len = (uint8_t)(pp - param - 2);
UINT8_TO_STREAM(pp_temp, inst_id);
- if ((rt = BTM_VendorSpecificCommand (HCI_BLE_MULTI_ADV_OCF,
- (uint8_t)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;
+ BTM_VendorSpecificCommand(HCI_BLE_MULTI_ADV_OCF,
+ (uint8_t)BTM_BLE_MULTI_ADV_WRITE_DATA_LEN,
+ param,
+ btm_ble_multi_adv_vsc_cmpl_cback);
+
+ btm_ble_multi_adv_enq_op_q(sub_code, inst_id, BTM_BLE_MULTI_ADV_DATA_EVT);
}
/*******************************************************************************
@@ -721,34 +691,33 @@
** Returns status
**
*******************************************************************************/
-tBTM_STATUS BTM_BleDisableAdvInstance (uint8_t inst_id)
+void BTM_BleDisableAdvInstance(uint8_t inst_id)
{
- tBTM_STATUS rt = BTM_ILLEGAL_VALUE;
- tBTM_BLE_VSC_CB cmn_ble_vsc_cb;
+ tBTM_BLE_MULTI_ADV_INST *p_inst = &btm_multi_adv_cb.p_adv_inst[inst_id - 1];
+ tBTM_BLE_VSC_CB cmn_ble_vsc_cb;
- BTM_TRACE_EVENT("BTM_BleDisableAdvInstance with inst_id:%d", inst_id);
+ BTM_TRACE_EVENT("%s: with inst_id:%d", __func__, inst_id);
- BTM_BleGetVendorCapabilities(&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;
- }
+ if (0 == cmn_ble_vsc_cb.adv_inst_max) {
+ BTM_TRACE_ERROR("%s: multi adv not supported", __func__);
+ return;
+ }
- 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]);
- alarm_cancel(btm_multi_adv_cb.p_adv_inst[inst_id - 1].adv_raddr_timer);
- btm_multi_adv_cb.p_adv_inst[inst_id - 1].in_use = false;
- }
- }
- return rt;
+ if (inst_id > BTM_BleMaxMultiAdvInstanceCount() || inst_id < 0 ||
+ inst_id == BTM_BLE_MULTI_ADV_DEFAULT_STD) {
+ BTM_TRACE_ERROR("%s: bad instance id %d", __func__, inst_id);
+ return;
+ }
+
+ btm_ble_enable_multi_adv(false, inst_id, BTM_BLE_MULTI_ADV_DISABLE_EVT);
+
+ btm_ble_multi_adv_configure_rpa(p_inst);
+ alarm_cancel(p_inst->adv_raddr_timer);
+ p_inst->in_use = false;
}
+
/*******************************************************************************
**
** Function btm_ble_multi_adv_vse_cback
diff --git a/stack/include/btm_ble_api.h b/stack/include/btm_ble_api.h
index 1474075..a2cab5e 100644
--- a/stack/include/btm_ble_api.h
+++ b/stack/include/btm_ble_api.h
@@ -469,6 +469,8 @@
uint8_t tx_power;
}tBTM_BLE_ADV_DATA;
+typedef void (tBTM_BLE_ADV_DATA_CMPL_CBACK) (tBTM_STATUS status);
+
#ifndef BTM_BLE_MULTI_ADV_MAX
#define BTM_BLE_MULTI_ADV_MAX 16 /* controller returned adv_inst_max should be less
than this number */
@@ -963,8 +965,8 @@
** Returns void
**
*******************************************************************************/
-extern tBTM_STATUS BTM_BleWriteAdvData(tBTM_BLE_AD_MASK data_mask,
- tBTM_BLE_ADV_DATA *p_data);
+extern void BTM_BleWriteAdvData(tBTM_BLE_AD_MASK data_mask, tBTM_BLE_ADV_DATA *p_data,
+ tBTM_BLE_ADV_DATA_CMPL_CBACK *p_adv_data_cback);
/*******************************************************************************
**
@@ -1126,8 +1128,8 @@
** Returns status
**
*******************************************************************************/
-extern tBTM_STATUS BTM_BleWriteScanRsp(tBTM_BLE_AD_MASK data_mask,
- tBTM_BLE_ADV_DATA *p_data);
+extern void BTM_BleWriteScanRsp(tBTM_BLE_AD_MASK data_mask, tBTM_BLE_ADV_DATA *p_data,
+ tBTM_BLE_ADV_DATA_CMPL_CBACK *p_adv_data_cback);
/*******************************************************************************
**
@@ -1755,11 +1757,11 @@
** p_params: pointer to the adv parameter structure, set as default
** adv parameter when the instance is enabled.
**
-** Returns status
+** Returns void
**
*******************************************************************************/
-extern tBTM_STATUS BTM_BleEnableAdvInstance (uint8_t inst_id,
- tBTM_BLE_ADV_PARAMS *p_params);
+extern void BTM_BleEnableAdvInstance(uint8_t inst_id,
+ tBTM_BLE_ADV_PARAMS *p_params);
/*******************************************************************************
**
@@ -1771,10 +1773,10 @@
** Parameters inst_id: adv instance ID
** p_params: pointer to the adv parameter structure.
**
-** Returns status
+** Returns void
**
*******************************************************************************/
-extern tBTM_STATUS BTM_BleUpdateAdvInstParam (uint8_t inst_id, tBTM_BLE_ADV_PARAMS *p_params);
+extern void BTM_BleUpdateAdvInstParam(uint8_t inst_id, tBTM_BLE_ADV_PARAMS *p_params);
/*******************************************************************************
**
@@ -1788,10 +1790,10 @@
** data_mask: adv data mask.
** p_data: pointer to the adv data structure.
**
-** Returns status
+** Returns void
**
*******************************************************************************/
-extern tBTM_STATUS BTM_BleCfgAdvInstData (uint8_t inst_id, bool is_scan_rsp,
+extern void BTM_BleCfgAdvInstData(uint8_t inst_id, bool is_scan_rsp,
tBTM_BLE_AD_MASK data_mask,
tBTM_BLE_ADV_DATA *p_data);
@@ -1803,10 +1805,10 @@
**
** Parameters inst_id: adv instance ID
**
-** Returns status
+** Returns void
**
*******************************************************************************/
-extern tBTM_STATUS BTM_BleDisableAdvInstance (uint8_t inst_id);
+extern void BTM_BleDisableAdvInstance(uint8_t inst_id);
/*******************************************************************************
**