Refactor btm_devctl reset sequence
* Controller bring up on blockable thread now
* Removed some duplicate and commands during controller bring up
* The code to make commands for controller bring up is smaller and better
diff --git a/stack/Android.mk b/stack/Android.mk
index 616ee07..ad41b76 100644
--- a/stack/Android.mk
+++ b/stack/Android.mk
@@ -158,6 +158,7 @@
LOCAL_MODULE := libbt-brcm_stack
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_CLASS := STATIC_LIBRARIES
+LOCAL_STATIC_LIBRARIES := libbt-hci
LOCAL_SHARED_LIBRARIES := libcutils libc
LOCAL_MULTILIB := 32
diff --git a/stack/btm/btm_acl.c b/stack/btm/btm_acl.c
index e642f37..a7d4a52 100644
--- a/stack/btm/btm_acl.c
+++ b/stack/btm/btm_acl.c
@@ -30,6 +30,7 @@
#include "bt_types.h"
#include "bt_target.h"
+#include "controller.h"
#include "gki.h"
#include "hcimsgs.h"
#include "btu.h"
@@ -326,7 +327,7 @@
&p->active_remote_addr_type);
#endif
- if (HCI_LE_SLAVE_INIT_FEAT_EXC_SUPPORTED(btm_cb.devcb.local_le_features)
+ if (HCI_LE_SLAVE_INIT_FEAT_EXC_SUPPORTED(controller_get_interface()->get_features_ble()->as_array)
|| link_role == HCI_ROLE_MASTER)
{
btsnd_hcic_ble_read_remote_feat(p->hci_handle);
@@ -648,7 +649,7 @@
remote_bd_addr[3], remote_bd_addr[4], remote_bd_addr[5]);
/* Make sure the local device supports switching */
- if (!(HCI_SWITCH_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_0])))
+ if (!controller_get_interface()->supports_master_slave_role_switch())
return(BTM_MODE_UNSUPPORTED);
if (btm_cb.devcb.p_switch_role_cb && p_cb)
@@ -1487,7 +1488,7 @@
HCI_FEATURE_BYTES_PER_PAGE);
if ((HCI_LMP_EXTENDED_SUPPORTED(p_acl_cb->peer_lmp_features[HCI_EXT_FEATURES_PAGE_0])) &&
- (HCI_READ_REMOTE_EXT_FEATURES_SUPPORTED(btm_cb.devcb.supported_cmds)))
+ (controller_get_interface()->supports_reading_remote_extended_features()))
{
/* if the remote controller has extended features and local controller supports
** HCI_Read_Remote_Extended_Features command then start reading these feature starting
@@ -2561,7 +2562,7 @@
else
{
/* Special case for when info for the local device is requested */
- if (memcmp (btm_cb.devcb.local_addr, addr, BD_ADDR_LEN) == 0)
+ if (memcmp (controller_get_interface()->get_address(), addr, BD_ADDR_LEN) == 0)
{
pkt_types = btm_cb.btm_acl_pkt_types_supported;
}
diff --git a/stack/btm/btm_ble_adv_filter.c b/stack/btm/btm_ble_adv_filter.c
index 0784b02..e15d6d4 100644
--- a/stack/btm/btm_ble_adv_filter.c
+++ b/stack/btm/btm_ble_adv_filter.c
@@ -28,6 +28,7 @@
#include "hcidefs.h"
#include "btm_ble_api.h"
#include "vendor_ble.h"
+#include "controller.h"
#define BTM_BLE_ADV_FILT_META_HDR_LENGTH 3
#define BTM_BLE_ADV_FILT_FEAT_SELN_LEN 13
@@ -1302,7 +1303,7 @@
(tBTM_BLE_PF_COUNT*) GKI_getbuf( sizeof(tBTM_BLE_PF_COUNT) * cmn_ble_vsc_cb.max_filter);
}
- if (!HCI_LE_HOST_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_1]))
+ if (!controller_get_interface()->supports_ble())
return;
}
diff --git a/stack/btm/btm_ble_batchscan.c b/stack/btm/btm_ble_batchscan.c
index 7ae4b1e..91bc7f3 100644
--- a/stack/btm/btm_ble_batchscan.c
+++ b/stack/btm/btm_ble_batchscan.c
@@ -25,6 +25,7 @@
#include "bt_utils.h"
#include "btu.h"
#include "btm_int.h"
+#include "controller.h"
#include "hcimsgs.h"
#if (BLE_INCLUDED == TRUE)
@@ -613,7 +614,7 @@
ble_batchscan_cb.cur_state, ref_value, batch_scan_full_max, batch_scan_trunc_max,
batch_scan_notify_threshold);
- if (!HCI_LE_HOST_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_1]))
+ if (!controller_get_interface()->supports_ble())
return BTM_ILLEGAL_VALUE;
BTM_BleGetVendorCapabilities(&cmn_ble_vsc_cb);
@@ -686,7 +687,7 @@
BTM_TRACE_EVENT (" BTM_BleEnableBatchScan: %d, %d, %d, %d, %d, %d",
scan_mode, scan_interval, scan_window, addr_type, discard_rule, ref_value);
- if (!HCI_LE_HOST_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_1]))
+ if (!controller_get_interface()->supports_ble())
return BTM_ILLEGAL_VALUE;
BTM_BleGetVendorCapabilities(&cmn_ble_vsc_cb);
@@ -760,7 +761,7 @@
tBTM_BLE_VSC_CB cmn_ble_vsc_cb;
BTM_TRACE_EVENT (" BTM_BleDisableBatchScan");
- if (!HCI_LE_HOST_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_1]))
+ if (!controller_get_interface()->supports_ble())
return BTM_ILLEGAL_VALUE;
BTM_BleGetVendorCapabilities(&cmn_ble_vsc_cb);
@@ -806,7 +807,7 @@
BTM_TRACE_EVENT (" BTM_BleReadScanReports; %d, %d", scan_mode, ref_value);
- if (!HCI_LE_HOST_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_1]))
+ if (!controller_get_interface()->supports_ble())
return BTM_ILLEGAL_VALUE;
BTM_BleGetVendorCapabilities(&cmn_ble_vsc_cb);
@@ -864,7 +865,7 @@
{
tBTM_BLE_VSC_CB cmn_ble_vsc_cb;
BTM_TRACE_EVENT (" BTM_BleTrackAdvertiser");
- if (!HCI_LE_HOST_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_1]))
+ if (!controller_get_interface()->supports_ble())
return BTM_ILLEGAL_VALUE;
BTM_BleGetVendorCapabilities(&cmn_ble_vsc_cb);
diff --git a/stack/btm/btm_ble_gap.c b/stack/btm/btm_ble_gap.c
index e641573..e934120 100644
--- a/stack/btm/btm_ble_gap.c
+++ b/stack/btm/btm_ble_gap.c
@@ -31,6 +31,7 @@
#include "btm_int.h"
#include "btm_ble_api.h"
#include "btu.h"
+#include "controller.h"
#include "hcimsgs.h"
#if (GAP_INCLUDED == TRUE)
#include "gap_api.h"
@@ -254,7 +255,7 @@
BTM_TRACE_EVENT ("BTM_BleUpdateAdvFilterPolicy");
- if (!HCI_LE_HOST_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_1]))
+ if (!controller_get_interface()->supports_ble())
return;
if (p_cb->afp != adv_policy)
@@ -305,7 +306,7 @@
BTM_TRACE_EVENT ("BTM_BleObserve : scan_type:%d",btm_cb.btm_inq_vars.scan_type);
- if (!HCI_LE_HOST_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_1]))
+ if (!controller_get_interface()->supports_ble())
return BTM_ILLEGAL_VALUE;
if (start)
@@ -379,7 +380,7 @@
tBTM_BLE_INQ_CB *p_cb = &btm_cb.ble_ctr_cb.inq_var;
UINT8 evt_type = p_cb->scan_rsp ? BTM_BLE_DISCOVER_EVT: BTM_BLE_NON_CONNECT_EVT;
- if (!HCI_LE_HOST_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_1]))
+ if (!controller_get_interface()->supports_ble())
return BTM_ILLEGAL_VALUE;
#ifdef BTM_BLE_PC_ADV_TEST_MODE
@@ -695,7 +696,7 @@
BOOLEAN started = TRUE;
BTM_TRACE_EVENT ("BTM_BleSetBgConnType ");
- if (!HCI_LE_HOST_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_1]))
+ if (!controller_get_interface()->supports_ble())
return FALSE;
if (btm_cb.ble_ctr_cb.bg_conn_type != bg_conn_type)
@@ -804,7 +805,7 @@
tBTM_BLE_INQ_CB *p_cb = &btm_cb.ble_ctr_cb.inq_var;
BTM_TRACE_EVENT ("BTM_BleSetConnMode is_directed = %d ", is_directed);
- if (!HCI_LE_HOST_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_1]))
+ if (!controller_get_interface()->supports_ble())
return BTM_ILLEGAL_VALUE;
p_cb->directed_conn = is_directed;
@@ -884,7 +885,7 @@
BTM_TRACE_EVENT ("BTM_BleSetAdvParams");
- if (!HCI_LE_HOST_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_1]))
+ if (!controller_get_interface()->supports_ble())
return BTM_ILLEGAL_VALUE;
if (!BTM_BLE_VALID_PRAM(adv_int_min, BTM_BLE_ADV_INT_MIN, BTM_BLE_ADV_INT_MAX) ||
@@ -945,7 +946,7 @@
tBTM_BLE_INQ_CB *p_cb = &btm_cb.ble_ctr_cb.inq_var;
BTM_TRACE_EVENT ("BTM_BleReadAdvParams ");
- if (!HCI_LE_HOST_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_1]))
+ if (!controller_get_interface()->supports_ble())
return ;
*adv_int_min = p_cb->adv_interval_min;
@@ -978,7 +979,7 @@
tBTM_BLE_INQ_CB *p_cb = &btm_cb.ble_ctr_cb.inq_var;
BTM_TRACE_EVENT (" BTM_BleSetScanParams");
- if (!HCI_LE_HOST_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_1]))
+ if (!controller_get_interface()->supports_ble())
return ;
if (BTM_BLE_VALID_PRAM(scan_interval, BTM_BLE_SCAN_INT_MIN, BTM_BLE_SCAN_INT_MAX) &&
@@ -1020,7 +1021,7 @@
BTM_TRACE_EVENT (" BTM_BleWriteScanRsp");
- if (!HCI_LE_HOST_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_1]))
+ if (!controller_get_interface()->supports_ble())
return BTM_ILLEGAL_VALUE;
memset(rsp_data, 0, BTM_BLE_AD_DATA_LEN);
@@ -1060,7 +1061,7 @@
BTM_TRACE_EVENT ("BTM_BleWriteAdvData ");
- if (!HCI_LE_HOST_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_1]))
+ if (!controller_get_interface()->supports_ble())
return BTM_ILLEGAL_VALUE;
memset(p_cb_data, 0, sizeof(tBTM_BLE_LOCAL_ADV_DATA));
@@ -1470,7 +1471,7 @@
flag &= ~BTM_BLE_BREDR_NOT_SPT;
/* if local controller support, mark both controller and host support in flag */
- if (HCI_SIMUL_LE_BREDR_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_0]))
+ if (controller_get_interface()->supports_simultaneous_le_bredr())
flag |= (BTM_BLE_DMT_CONTROLLER_SPT|BTM_BLE_DMT_HOST_SPT);
else
flag &= ~(BTM_BLE_DMT_CONTROLLER_SPT|BTM_BLE_DMT_HOST_SPT);
@@ -1785,7 +1786,7 @@
{
tBTM_INQUIRY_VAR_ST *p_inq = &btm_cb.btm_inq_vars;
- if (!HCI_LE_HOST_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_1]))
+ if (!controller_get_interface()->supports_ble())
return BTM_ERR_PROCESSING;
if (p_cur &&
diff --git a/stack/btm/btm_ble_multi_adv.c b/stack/btm/btm_ble_multi_adv.c
index 6876726..ae3aa0b 100644
--- a/stack/btm/btm_ble_multi_adv.c
+++ b/stack/btm/btm_ble_multi_adv.c
@@ -17,7 +17,9 @@
******************************************************************************/
#include <string.h>
+
#include "bt_target.h"
+#include "controller.h"
#if (BLE_INCLUDED == TRUE)
#include "bt_types.h"
@@ -260,7 +262,7 @@
#endif
{
UINT8_TO_STREAM (pp, BLE_ADDR_PUBLIC);
- BDADDR_TO_STREAM (pp, btm_cb.devcb.local_addr);
+ 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",
diff --git a/stack/btm/btm_dev.c b/stack/btm/btm_dev.c
index a692b7e..2bb22a7 100644
--- a/stack/btm/btm_dev.c
+++ b/stack/btm/btm_dev.c
@@ -28,6 +28,7 @@
#include <stddef.h>
#include "bt_types.h"
+#include "controller.h"
#include "gki.h"
#include "hcimsgs.h"
#include "btu.h"
@@ -362,7 +363,7 @@
return(FALSE);
#endif
p_dev_rec = btm_find_dev (bd_addr);
- if (p_dev_rec && HCI_SWITCH_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_0]))
+ if (p_dev_rec && controller_get_interface()->supports_master_slave_role_switch())
{
if (HCI_SWITCH_SUPPORTED(p_dev_rec->features[HCI_EXT_FEATURES_PAGE_0]))
{
diff --git a/stack/btm/btm_devctl.c b/stack/btm/btm_devctl.c
index 24ae15a..963a2af 100644
--- a/stack/btm/btm_devctl.c
+++ b/stack/btm/btm_devctl.c
@@ -23,30 +23,29 @@
*
******************************************************************************/
+#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <stddef.h>
+#include <utils/Log.h>
#include "bt_types.h"
#include "bt_utils.h"
-#include "hcimsgs.h"
-#include "btu.h"
#include "btm_int.h"
+#include "btu.h"
+#include "controller.h"
+#include "hci_layer.h"
+#include "hcimsgs.h"
#include "l2c_int.h"
+#include "module.h"
+#include "thread.h"
#if BLE_INCLUDED == TRUE
#include "gatt_int.h"
-
#endif /* BLE_INCLUDED */
-#ifdef BTA_PRM_CHECK_FW_VER
-extern BOOLEAN BTA_PRM_CHECK_FW_VER(UINT8 *p);
-#endif
-
-#ifndef TT_DEV_RESET_MASK
-#define TT_DEV_RESET_MASK 0xff
-#endif
+extern thread_t *bt_workqueue_thread;
/********************************************************************************/
/* L O C A L D A T A D E F I N I T I O N S */
@@ -61,32 +60,11 @@
#define BTM_INFO_TIMEOUT 5 /* 5 seconds for info response */
-#ifndef BTM_SET_DEV_NAME_UPON_RESET
-#define BTM_SET_DEV_NAME_UPON_RESET TRUE
-#endif
-
-/* host SCO buffer size */
-#ifndef BTM_SCO_HOST_BUF_SIZE
-#define BTM_SCO_HOST_BUF_SIZE 0xff
-#endif
-
/********************************************************************************/
/* L O C A L F U N C T I O N P R O T O T Y P E S */
/********************************************************************************/
-static void btm_dev_reset (void);
-static void btm_continue_reset (void);
-static void btm_get_local_ext_features (UINT8 page_number);
static void btm_decode_ext_features_page (UINT8 page_number, const BD_FEATURES p_features);
-static void btm_read_all_lmp_features_complete (UINT8 max_page_number);
-static void btm_set_lmp_features_host_may_support (UINT8 max_page_number);
-static void btm_get_local_features (void);
-static void btm_issue_host_support_for_lmp_features (void);
-static void btm_read_local_supported_cmds (UINT8 local_controller_id);
-
-#if BLE_INCLUDED == TRUE
-static void btm_read_ble_local_supported_features (void);
-#endif
/*******************************************************************************
**
@@ -174,71 +152,73 @@
}
}
-/*******************************************************************************
-**
-** Function btm_dev_absent
-**
-** Description This function is called by when it is detected that the
-** device is not connected any more.
-**
-** Returns void
-**
-*******************************************************************************/
-void btm_dev_absent (void)
-{
- btm_cb.devcb.state = BTM_DEV_STATE_WAIT_RESET_CMPLT;
+static void reset_complete(void *result) {
+ assert(result == FUTURE_SUCCESS);
+ const controller_t *controller = controller_get_interface();
- btm_db_reset ();
- btm_inq_db_reset();
+ /* Tell L2CAP that all connections are gone */
+ l2cu_device_reset ();
- /* If anyone wants device status notifications, give him one */
- btm_report_device_status (BTM_DEV_STATUS_DOWN);
+ /* Clear current security state */
+ for (int devinx = 0; devinx < BTM_SEC_MAX_DEVICE_RECORDS; devinx++) {
+ btm_cb.sec_dev_rec[devinx].sec_state = BTM_SEC_STATE_IDLE;
+ }
- btu_stop_timer (&btm_cb.devcb.reset_timer);
+ /* After the reset controller should restore all parameters to defaults. */
+ btm_cb.btm_inq_vars.inq_counter = 1;
+ btm_cb.btm_inq_vars.inq_scan_window = HCI_DEF_INQUIRYSCAN_WINDOW;
+ btm_cb.btm_inq_vars.inq_scan_period = HCI_DEF_INQUIRYSCAN_INTERVAL;
+ btm_cb.btm_inq_vars.inq_scan_type = HCI_DEF_SCAN_TYPE;
+
+ btm_cb.btm_inq_vars.page_scan_window = HCI_DEF_PAGESCAN_WINDOW;
+ btm_cb.btm_inq_vars.page_scan_period = HCI_DEF_PAGESCAN_INTERVAL;
+ btm_cb.btm_inq_vars.page_scan_type = HCI_DEF_SCAN_TYPE;
+
+#if (BLE_INCLUDED == TRUE)
+ btm_cb.ble_ctr_cb.conn_state = BLE_CONN_IDLE;
+ btm_cb.ble_ctr_cb.bg_dev_num = 0;
+ btm_cb.ble_ctr_cb.bg_conn_type = BTM_BLE_CONN_NONE;
+ btm_cb.ble_ctr_cb.p_select_cback = NULL;
+ memset(&btm_cb.ble_ctr_cb.bg_dev_list, 0, (sizeof(tBTM_LE_BG_CONN_DEV)*BTM_BLE_MAX_BG_CONN_DEV_NUM));
+ gatt_reset_bgdev_list();
+ btm_ble_multi_adv_init();
+#endif
+
+#if BTM_PWR_MGR_INCLUDED == TRUE
+ btm_pm_reset();
+#endif
+
+ l2c_link_processs_num_bufs(controller->get_acl_buffer_count_classic());
+#if (BLE_INCLUDED == TRUE)
+ if (controller->supports_ble()) {
+ l2c_link_processs_ble_num_bufs(controller->get_acl_buffer_count_ble());
+ }
+#endif
+
+ BTM_SetPinType (btm_cb.cfg.pin_type, btm_cb.cfg.pin_code, btm_cb.cfg.pin_code_len);
+
+ for (int i = 0; i <= controller->get_last_features_classic_index(); i++) {
+ btm_decode_ext_features_page(i, controller->get_features_classic(i)->as_array);
+ }
+
+ btm_report_device_status(BTM_DEV_STATUS_UP);
}
+// TODO(zachoverflow): remove this function
+void BTM_DeviceReset (UNUSED_ATTR tBTM_CMPL_CB *p_cb) {
+ /* Flush all ACL connections */
+ btm_acl_device_down();
-/*******************************************************************************
-**
-** Function BTM_DeviceReset
-**
-** Description This function is called to reset the HCI. Callback function
-** if provided is called when startup of the device is
-** completed.
-**
-** Returns void
-**
-*******************************************************************************/
-void BTM_DeviceReset (tBTM_CMPL_CB *p_cb)
-{
- tBTM_STATUS status;
+ /* Clear the callback, so application would not hang on reset */
+ btm_db_reset();
- /* If device is already resetting, do not allow another */
- if ((!btm_cb.devcb.p_reset_cmpl_cb) || (btm_cb.devcb.p_reset_cmpl_cb == p_cb))
- {
- /* Flush all ACL connections */
- btm_acl_device_down();
-
- /* Clear the callback, so application would not hang on reset */
- btm_db_reset();
-
- /* Save address of the completion routine, if provided */
- btm_cb.devcb.p_reset_cmpl_cb = p_cb;
-
- btm_dev_reset ();
- }
- else
- {
- /* pass an error to the bad callback, another one was already provided */
- if (p_cb)
- {
- status = BTM_ILLEGAL_VALUE;
- p_cb (&status);
- }
- }
+ module_start_up_callbacked_wrapper(
+ get_module(CONTROLLER_MODULE),
+ bt_workqueue_thread,
+ reset_complete
+ );
}
-
/*******************************************************************************
**
** Function BTM_IsDeviceUp
@@ -250,7 +230,7 @@
*******************************************************************************/
BOOLEAN BTM_IsDeviceUp (void)
{
- return ((BOOLEAN) (btm_cb.devcb.state == BTM_DEV_STATE_READY));
+ return controller_get_interface()->get_is_ready();
}
/*******************************************************************************
@@ -268,10 +248,11 @@
first, btm_cb.first_disabled_channel, last,
btm_cb.last_disabled_channel);
+ const controller_t *controller = controller_get_interface();
/* Make sure the local device supports the feature before sending */
- if ((!HCI_LMP_AFH_CAP_MASTR_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_0])) &&
- (!HCI_LMP_AFH_CLASS_SLAVE_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_0])) &&
- (!HCI_LMP_AFH_CLASS_MASTR_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_0])))
+ if (!HCI_LMP_AFH_CAP_MASTR_SUPPORTED(controller->get_features_classic(0)->as_array) &&
+ !HCI_LMP_AFH_CLASS_SLAVE_SUPPORTED(controller->get_features_classic(0)->as_array) &&
+ !HCI_LMP_AFH_CLASS_MASTR_SUPPORTED(controller->get_features_classic(0)->as_array))
return (BTM_MODE_UNSUPPORTED);
if (!BTM_IsDeviceUp())
@@ -302,8 +283,9 @@
*******************************************************************************/
tBTM_STATUS BTM_SetAfhChannelAssessment (BOOLEAN enable_or_disable)
{
+ const controller_t *controller = controller_get_interface();
/* whatever app wants if device is not 1.2 scan type should be STANDARD */
- if (!HCI_LMP_AFH_CAP_SLAVE_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_0]))
+ if (!HCI_LMP_AFH_CAP_SLAVE_SUPPORTED(controller->get_features_classic(0)->as_array))
return (BTM_MODE_UNSUPPORTED);
if (!btsnd_hcic_write_afh_channel_assessment_mode (enable_or_disable))
@@ -314,204 +296,6 @@
/*******************************************************************************
**
-** Function btm_dev_reset
-**
-** Description Local function called to send a reset command
-**
-** Returns void
-**
-*******************************************************************************/
-static void btm_dev_reset (void)
-{
- btm_cb.devcb.state = BTM_DEV_STATE_WAIT_RESET_CMPLT;
-
- /* Start reset timer. When timer expires we will send first command */
- /* from the setup sequence */
-
- btu_start_timer (&btm_cb.devcb.reset_timer, BTU_TTYPE_BTM_DEV_CTL,
- BTM_DEV_RESET_TIMEOUT);
- btsnd_hcic_reset (LOCAL_BR_EDR_CONTROLLER_ID);
-}
-
-
-/*******************************************************************************
-**
-** Function btm_get_hci_buf_size
-**
-** Description Local function called to send a read buffer size command
-**
-** Returns void
-**
-*******************************************************************************/
-void btm_get_hci_buf_size (void)
-{
-
- btu_start_timer (&btm_cb.devcb.reset_timer, BTU_TTYPE_BTM_DEV_CTL, BTM_DEV_REPLY_TIMEOUT);
-
- /* Send a Read Buffer Size message to the Host Controller. */
- btsnd_hcic_read_buffer_size ();
-
-}
-#if BLE_INCLUDED == TRUE
-/*******************************************************************************
-**
-** Function btm_read_ble_wl_size
-**
-** Description Local function called to send a read BLE buffer size command
-**
-** Returns void
-**
-*******************************************************************************/
-void btm_read_ble_wl_size(void)
-{
- BTM_TRACE_DEBUG("btm_read_ble_wl_size ");
- btu_start_timer (&btm_cb.devcb.reset_timer, BTU_TTYPE_BTM_DEV_CTL, BTM_DEV_REPLY_TIMEOUT);
-
- /* Send a Read Buffer Size message to the Host Controller. */
- btsnd_hcic_ble_read_white_list_size();
-}
-/*******************************************************************************
-**
-** Function btm_get_ble_buffer_size
-**
-** Description Local function called to send a read BLE buffer size command
-**
-** Returns void
-**
-*******************************************************************************/
-void btm_get_ble_buffer_size(void)
-{
- BTM_TRACE_DEBUG("btm_get_ble_buffer_size ");
- btu_start_timer (&btm_cb.devcb.reset_timer, BTU_TTYPE_BTM_DEV_CTL, BTM_DEV_REPLY_TIMEOUT);
-
- /* Send a Read Buffer Size message to the Host Controller. */
- btsnd_hcic_ble_read_buffer_size ();
-}
-
-/*******************************************************************************
-**
-** Function btm_read_ble_local_supported_features
-**
-** Description Local function called to send a read BLE local supported
-** features command
-**
-** Returns void
-**
-*******************************************************************************/
-static void btm_read_ble_local_supported_features(void)
-{
- BTM_TRACE_DEBUG("btm_read_ble_local_supported_features ");
- btu_start_timer (&btm_cb.devcb.reset_timer, BTU_TTYPE_BTM_DEV_CTL, BTM_DEV_REPLY_TIMEOUT);
-
- /* Send a Read Local Supported Features message to the Host Controller. */
- btsnd_hcic_ble_read_local_spt_feat ();
-}
-
-/*******************************************************************************
-**
-** Function btm_read_ble_local_supported_states
-**
-** Description Local function called to send a read BLE local supported
-** features command
-**
-** Returns void
-**
-*******************************************************************************/
-static void btm_read_ble_local_supported_states(void)
-{
- BTM_TRACE_DEBUG("btm_read_ble_local_supported_states ");
- btu_start_timer (&btm_cb.devcb.reset_timer, BTU_TTYPE_BTM_DEV_CTL, BTM_DEV_REPLY_TIMEOUT);
-
- /* Send a Read Local Supported states message to the Host Controller. */
- btsnd_hcic_ble_read_supported_states ();
-}
-#endif
-/*******************************************************************************
-**
-** Function btm_get_local_version
-**
-** Description Local function called to send a read local version to controller
-**
-** Returns void
-**
-*******************************************************************************/
-void btm_get_local_version (void)
-{
-
- btu_start_timer (&btm_cb.devcb.reset_timer, BTU_TTYPE_BTM_DEV_CTL, BTM_DEV_REPLY_TIMEOUT);
-
- /* Send a Read Local Version message to the Host Controller. */
- btsnd_hcic_read_local_ver (LOCAL_BR_EDR_CONTROLLER_ID);
- btsnd_hcic_read_bd_addr ();
-
-#if BTM_PWR_MGR_INCLUDED == TRUE
- btm_pm_reset();
-#endif
-
-}
-
-/*******************************************************************************
-**
-** Function btm_read_local_supported_cmds
-**
-** Description Local function called to send a read local supported commands
-**
-** Returns void
-**
-*******************************************************************************/
-static void btm_read_local_supported_cmds (UINT8 local_controller_id)
-{
- BTM_TRACE_DEBUG("Start reading local supported commands");
-
- btu_start_timer (&btm_cb.devcb.reset_timer, BTU_TTYPE_BTM_DEV_CTL, BTM_DEV_REPLY_TIMEOUT);
-
- btsnd_hcic_read_local_supported_cmds(local_controller_id);
-}
-
-/*******************************************************************************
-**
-** Function btm_get_local_features
-**
-** Description Local function called to send a read local features
-**
-** Returns void
-**
-*******************************************************************************/
-static void btm_get_local_features (void)
-{
- /* If this BT controller supports Read Extended Feature */
- if (btm_cb.devcb.local_version.hci_version >= HCI_PROTO_VERSION_2_0)
- {
- btm_get_local_ext_features(HCI_EXT_FEATURES_PAGE_0);
- }
- /* else, if this is a very old BT controller */
- else
-{
- btu_start_timer (&btm_cb.devcb.reset_timer, BTU_TTYPE_BTM_DEV_CTL, BTM_DEV_REPLY_TIMEOUT);
-
- /* Just read the basic features (legacy HCI command) */
- btsnd_hcic_read_local_features ();
-}
-}
-
-/*******************************************************************************
-**
-** Function btm_get_local_ext_features
-**
-** Description Local function called to send a read local extended features
-**
-** Returns void
-**
-*******************************************************************************/
-static void btm_get_local_ext_features (UINT8 page_number)
-{
- btu_start_timer (&btm_cb.devcb.reset_timer, BTU_TTYPE_BTM_DEV_CTL, BTM_DEV_REPLY_TIMEOUT);
-
- btsnd_hcic_read_local_ext_features(page_number);
-}
-
-/*******************************************************************************
-**
** Function btm_dev_timeout
**
** Description This function is called when a timer list entry expires.
@@ -523,12 +307,7 @@
{
TIMER_PARAM_TYPE timer_type = (TIMER_PARAM_TYPE)p_tle->param;
- if ((timer_type & TT_DEV_RESET_MASK) == TT_DEV_RESET)
- {
- /* Call device reset as long as there is timeout*/
- btm_dev_reset();
- }
- else if (timer_type == (TIMER_PARAM_TYPE)TT_DEV_RLN)
+ if (timer_type == (TIMER_PARAM_TYPE)TT_DEV_RLN)
{
tBTM_CMPL_CB *p_cb = btm_cb.devcb.p_rln_cmpl_cb;
@@ -541,297 +320,6 @@
/*******************************************************************************
**
-** Function btm_reset_complete
-**
-** Description This function is called when command complete for HCI_Reset
-** is received. It does not make sense to send next command
-** because device is resetting after command complete is
-** received. Just start timer and set required state.
-**
-** Returns void
-**
-*******************************************************************************/
-void btm_reset_complete (void)
-{
- int devinx;
-
- BTM_TRACE_EVENT ("btm_reset_complete");
-
- /* Handle if btm initiated the reset */
- if (btm_cb.devcb.state == BTM_DEV_STATE_WAIT_RESET_CMPLT)
- {
- /* Tell L2CAP that all connections are gone */
- l2cu_device_reset ();
-
- /* Clear current security state */
- for (devinx = 0; devinx < BTM_SEC_MAX_DEVICE_RECORDS; devinx++)
- {
- btm_cb.sec_dev_rec[devinx].sec_state = BTM_SEC_STATE_IDLE;
- }
-
- /* After the reset controller should restore all parameters to defaults. */
- btm_cb.btm_inq_vars.inq_counter = 1;
- btm_cb.btm_inq_vars.inq_scan_window = HCI_DEF_INQUIRYSCAN_WINDOW;
- btm_cb.btm_inq_vars.inq_scan_period = HCI_DEF_INQUIRYSCAN_INTERVAL;
- btm_cb.btm_inq_vars.inq_scan_type = HCI_DEF_SCAN_TYPE;
-
- btm_cb.btm_inq_vars.page_scan_window = HCI_DEF_PAGESCAN_WINDOW;
- btm_cb.btm_inq_vars.page_scan_period = HCI_DEF_PAGESCAN_INTERVAL;
- btm_cb.btm_inq_vars.page_scan_type = HCI_DEF_SCAN_TYPE;
-
- btm_cb.devcb.state = BTM_DEV_STATE_WAIT_AFTER_RESET;
- btu_stop_timer(&btm_cb.devcb.reset_timer);
- btm_continue_reset();
-
-#if (BLE_INCLUDED == TRUE)
- btm_cb.ble_ctr_cb.conn_state = BLE_CONN_IDLE;
- btm_cb.ble_ctr_cb.bg_dev_num = 0;
- btm_cb.ble_ctr_cb.bg_conn_type = BTM_BLE_CONN_NONE;
- btm_cb.ble_ctr_cb.p_select_cback = NULL;
- memset(&btm_cb.ble_ctr_cb.bg_dev_list, 0, (sizeof(tBTM_LE_BG_CONN_DEV)*BTM_BLE_MAX_BG_CONN_DEV_NUM));
- gatt_reset_bgdev_list();
-#endif
- }
-}
-
-/*******************************************************************************
-**
-** Function btm_continue_reset
-**
-** Description This function is called when wait period expired after
-** device reset or called by the application to continue
-** initialization after the application has completed its
-** vendor specific sequence.
-**
-** Returns void
-**
-*******************************************************************************/
-void btm_continue_reset (void)
-{
- btm_get_hci_buf_size ();
-
-#if (BTM_MAX_LOC_BD_NAME_LEN > 0) && (BTM_SET_DEV_NAME_UPON_RESET == TRUE)
- BTM_SetLocalDeviceName(btm_cb.cfg.bd_name);
-#endif
-
- BTM_SetPinType (btm_cb.cfg.pin_type, btm_cb.cfg.pin_code, btm_cb.cfg.pin_code_len);
-}
-
-/*******************************************************************************
-**
-** Function btm_read_hci_buf_size_complete
-**
-** Description This function is called when command complete for
-** get HCI buffer size is received. Start timer and send
-** read local features request
-**
-** Returns void
-**
-*******************************************************************************/
-void btm_read_hci_buf_size_complete (UINT8 *p, UINT16 evt_len)
-{
- UINT8 status;
- UINT8 lm_sco_buf_size;
- UINT16 lm_num_acl_bufs;
- UINT16 lm_num_sco_bufs;
- UINT16 acl_buf_size;
- UNUSED(evt_len);
-
- STREAM_TO_UINT8 (status, p);
- if (status == HCI_SUCCESS)
- {
- STREAM_TO_UINT16 (btu_cb.hcit_acl_data_size, p);
- STREAM_TO_UINT8 (lm_sco_buf_size, p);
- STREAM_TO_UINT16 (lm_num_acl_bufs, p);
- STREAM_TO_UINT16 (lm_num_sco_bufs, p);
-
- btu_cb.hcit_acl_pkt_size = btu_cb.hcit_acl_data_size + HCI_DATA_PREAMBLE_SIZE;
-
- l2c_link_processs_num_bufs (lm_num_acl_bufs);
-
-#if BTM_ACL_BUF_SIZE > 0
- acl_buf_size = (BTM_ACL_BUF_SIZE < L2CAP_MTU_SIZE) ? BTM_ACL_BUF_SIZE : L2CAP_MTU_SIZE;
-#else
- acl_buf_size = L2CAP_MTU_SIZE;
-#endif
- /* Tell the controller what our buffer sizes are. ?? Need SCO info */
- btsnd_hcic_set_host_buf_size (acl_buf_size, BTM_SCO_HOST_BUF_SIZE, L2CAP_HOST_FC_ACL_BUFS, 10);
- }
-
- btm_get_local_version ();
-}
-
-#if (BLE_INCLUDED == TRUE)
-/*******************************************************************************
-**
-** Function btm_read_ble_buf_size_complete
-**
-** Description This function is called when command complete for
-** get HCI buffer size is received. Start timer and send
-** read local supported features request
-**
-** Returns void
-**
-*******************************************************************************/
-void btm_read_ble_buf_size_complete (UINT8 *p, UINT16 evt_len)
-{
- UINT8 status;
- UINT16 lm_num_le_bufs;
- UNUSED(evt_len);
-
- BTM_TRACE_DEBUG("btm_read_ble_buf_size_complete ");
- STREAM_TO_UINT8 (status, p);
- if (status == HCI_SUCCESS)
- {
- STREAM_TO_UINT16 (btu_cb.hcit_ble_acl_data_size, p);
- STREAM_TO_UINT8 (lm_num_le_bufs, p);
-
- if (btu_cb.hcit_ble_acl_data_size == 0)
- btu_cb.hcit_ble_acl_data_size = btu_cb.hcit_acl_data_size;
-
- btu_cb.hcit_ble_acl_pkt_size = btu_cb.hcit_ble_acl_data_size + HCI_DATA_PREAMBLE_SIZE;
-
- l2c_link_processs_ble_num_bufs (lm_num_le_bufs);
- }
- btm_read_ble_local_supported_states();
-}
-/*******************************************************************************
-**
-** Function btm_read_ble_local_supported_states_complete
-**
-** Description This function is called when command complete for
-** Read LE Local Supported states complete is received.
-**
-** Returns void
-**
-*******************************************************************************/
-void btm_read_ble_local_supported_states_complete (UINT8 *p, UINT16 evt_len)
-{
- UINT8 status;
-
- UNUSED(evt_len);
- BTM_TRACE_DEBUG("btm_read_ble_local_supported_states_complete ");
-
- btu_stop_timer (&btm_cb.devcb.reset_timer);
-
- STREAM_TO_UINT8 (status, p);
- if (status == HCI_SUCCESS)
- {
- STREAM_TO_ARRAY(&btm_cb.devcb.le_supported_states, p, BTM_LE_SUPPORT_STATE_SIZE);
- }
- else
- {
- BTM_TRACE_WARNING ("btm_read_ble_local_supported_features_complete status = %d", status);
- }
-
- btm_read_ble_local_supported_features();
-}
-
-/*******************************************************************************
-**
-** Function btm_read_ble_local_supported_features_complete
-**
-** Description This function is called when command complete for
-** Read LE Local Supported Features is received. Start timer and send
-** read LMP local features request
-**
-** Returns void
-**
-*******************************************************************************/
-void btm_read_ble_local_supported_features_complete (UINT8 *p, UINT16 evt_len)
-{
- UINT8 status;
- UNUSED(evt_len);
-
- BTM_TRACE_DEBUG("btm_read_ble_local_supported_features_complete ");
-
- btu_stop_timer (&btm_cb.devcb.reset_timer);
-
- STREAM_TO_UINT8 (status, p);
- if (status == HCI_SUCCESS)
- {
- STREAM_TO_ARRAY(&btm_cb.devcb.local_le_features, p, HCI_FEATURE_BYTES_PER_PAGE);
- }
- else
- {
- BTM_TRACE_WARNING ("btm_read_ble_local_supported_features_complete status = %d", status);
- }
-
- btsnd_hcic_ble_set_evt_mask((UINT8 *)HCI_BLE_EVENT_MASK_DEF);
-
- btm_reset_ctrlr_complete();
-}
-
-/*******************************************************************************
-**
-** Function btm_read_white_list_size_complete
-**
-** Description This function read the current white list size.
-*******************************************************************************/
-void btm_read_white_list_size_complete(UINT8 *p, UINT16 evt_len)
-{
- UINT8 status;
- UNUSED(evt_len);
-
- BTM_TRACE_DEBUG("btm_read_white_list_size_complete ");
- STREAM_TO_UINT8 (status, p);
-
- if (status == HCI_SUCCESS)
- {
- STREAM_TO_UINT8(btm_cb.ble_ctr_cb.max_filter_entries, p);
- btm_cb.ble_ctr_cb.num_empty_filter = btm_cb.ble_ctr_cb.max_filter_entries;
- }
- /* write LE host support and simultatunous LE supported */
- btsnd_hcic_ble_write_host_supported(BTM_BLE_HOST_SUPPORT, BTM_BLE_SIMULTANEOUS_HOST);
-
- btm_get_ble_buffer_size();
-}
-
-#endif
-/*******************************************************************************
-**
-** Function btm_read_local_version_complete
-**
-** Description This function is called when local BD Addr read complete
-** message is received from the HCI.
-**
-** Returns void
-**
-*******************************************************************************/
-void btm_read_local_version_complete (UINT8 *p, UINT16 evt_len)
-{
- tBTM_VERSION_INFO *p_vi = &btm_cb.devcb.local_version;
- UINT8 status;
- UNUSED(evt_len);
-
-#ifdef BTA_PRM_CHECK_FW_VER
- if(BTA_PRM_CHECK_FW_VER(p))
- return;
-#endif
-
- STREAM_TO_UINT8 (status, p);
- if (status == HCI_SUCCESS)
- {
-
- STREAM_TO_UINT8 (p_vi->hci_version, p);
- STREAM_TO_UINT16 (p_vi->hci_revision, p);
- STREAM_TO_UINT8 (p_vi->lmp_version, p);
- STREAM_TO_UINT16 (p_vi->manufacturer, p);
- STREAM_TO_UINT16 (p_vi->lmp_subversion, p);
- }
-
- if (p_vi->hci_version >= HCI_PROTO_VERSION_1_2)
- {
- btm_read_local_supported_cmds(LOCAL_BR_EDR_CONTROLLER_ID);
- }
- else
- {
- btm_get_local_features ();
- }
-}
-
-/*******************************************************************************
-**
** Function btm_decode_ext_features_page
**
** Description This function is decodes a features page.
@@ -862,37 +350,32 @@
btm_cb.btm_acl_pkt_types_supported |= (BTM_ACL_PKT_TYPES_MASK_DH5 +
BTM_ACL_PKT_TYPES_MASK_DM5);
- /* _NO_X_DXX masks are reserved before ver 2.0.
- Set them only for later versions of controller */
- if (btm_cb.devcb.local_version.hci_version >= HCI_PROTO_VERSION_2_0)
+ /* Add in EDR related ACL types */
+ if (!HCI_EDR_ACL_2MPS_SUPPORTED(p_features))
{
- /* Add in EDR related ACL types */
- if (!HCI_EDR_ACL_2MPS_SUPPORTED(p_features))
- {
- btm_cb.btm_acl_pkt_types_supported |= (BTM_ACL_PKT_TYPES_MASK_NO_2_DH1 +
- BTM_ACL_PKT_TYPES_MASK_NO_2_DH3 +
- BTM_ACL_PKT_TYPES_MASK_NO_2_DH5);
- }
+ btm_cb.btm_acl_pkt_types_supported |= (BTM_ACL_PKT_TYPES_MASK_NO_2_DH1 +
+ BTM_ACL_PKT_TYPES_MASK_NO_2_DH3 +
+ BTM_ACL_PKT_TYPES_MASK_NO_2_DH5);
+ }
- if (!HCI_EDR_ACL_3MPS_SUPPORTED(p_features))
- {
- btm_cb.btm_acl_pkt_types_supported |= (BTM_ACL_PKT_TYPES_MASK_NO_3_DH1 +
- BTM_ACL_PKT_TYPES_MASK_NO_3_DH3 +
+ if (!HCI_EDR_ACL_3MPS_SUPPORTED(p_features))
+ {
+ btm_cb.btm_acl_pkt_types_supported |= (BTM_ACL_PKT_TYPES_MASK_NO_3_DH1 +
+ BTM_ACL_PKT_TYPES_MASK_NO_3_DH3 +
+ BTM_ACL_PKT_TYPES_MASK_NO_3_DH5);
+ }
+
+ /* Check to see if 3 and 5 slot packets are available */
+ if (HCI_EDR_ACL_2MPS_SUPPORTED(p_features) ||
+ HCI_EDR_ACL_3MPS_SUPPORTED(p_features))
+ {
+ if (!HCI_3_SLOT_EDR_ACL_SUPPORTED(p_features))
+ btm_cb.btm_acl_pkt_types_supported |= (BTM_ACL_PKT_TYPES_MASK_NO_2_DH3 +
+ BTM_ACL_PKT_TYPES_MASK_NO_3_DH3);
+
+ if (!HCI_5_SLOT_EDR_ACL_SUPPORTED(p_features))
+ btm_cb.btm_acl_pkt_types_supported |= (BTM_ACL_PKT_TYPES_MASK_NO_2_DH5 +
BTM_ACL_PKT_TYPES_MASK_NO_3_DH5);
- }
-
- /* Check to see if 3 and 5 slot packets are available */
- if (HCI_EDR_ACL_2MPS_SUPPORTED(p_features) ||
- HCI_EDR_ACL_3MPS_SUPPORTED(p_features))
- {
- if (!HCI_3_SLOT_EDR_ACL_SUPPORTED(p_features))
- btm_cb.btm_acl_pkt_types_supported |= (BTM_ACL_PKT_TYPES_MASK_NO_2_DH3 +
- BTM_ACL_PKT_TYPES_MASK_NO_3_DH3);
-
- if (!HCI_5_SLOT_EDR_ACL_SUPPORTED(p_features))
- btm_cb.btm_acl_pkt_types_supported |= (BTM_ACL_PKT_TYPES_MASK_NO_2_DH5 +
- BTM_ACL_PKT_TYPES_MASK_NO_3_DH5);
- }
}
BTM_TRACE_DEBUG("Local supported ACL packet types: 0x%04x",
@@ -1018,441 +501,6 @@
/*******************************************************************************
**
-** Function btm_reset_ctrlr_complete
-**
-** Description This is the last step of BR/EDR controller startup sequence.
-**
-** Returns void
-**
-*******************************************************************************/
-void btm_reset_ctrlr_complete ()
-{
- tBTM_DEVCB *p_devcb = &btm_cb.devcb;
- tBTM_CMPL_CB *p_cb = p_devcb->p_reset_cmpl_cb;
- BOOLEAN found = FALSE;
- UINT8 i, j, max_page_number;
-
- btu_stop_timer (&btm_cb.devcb.reset_timer);
-
- /* find the highest feature page number which contains non-zero bits */
- for (i = HCI_EXT_FEATURES_PAGE_MAX; ; i--)
- {
- for (j = 0; j < HCI_FEATURE_BYTES_PER_PAGE; j++)
- {
- if (p_devcb->local_lmp_features[i][j] != 0)
- {
- found = TRUE;
- break;
- }
- }
- if (found || !i)
- {
- break;
- }
- }
-
- if (!found)
- BTM_TRACE_WARNING ("btm_reset_ctrlr_complete: NONE of local controller features is set");
-
- max_page_number = i;
-
- BTM_TRACE_DEBUG ("btm_reset_ctrlr_complete: max_page_number: %d", max_page_number);
-
- /*
- * Set State to Ready (needs to be done before btm_decode_ext_features_page
- * to allow it to send some HCI configuration commands)
- */
- p_devcb->state = BTM_DEV_STATE_READY;
-
- /* For every received/saved feature page */
- for (i = 0; i <= max_page_number; i++)
- {
- /* Decode the saved Feature Page */
- btm_decode_ext_features_page(i, p_devcb->local_lmp_features[i]);
- }
-
- /* If there was a callback address for reset complete, reset it */
- p_devcb->p_reset_cmpl_cb = NULL;
-
- /* If anyone wants device status notifications, give him one */
- btm_report_device_status(BTM_DEV_STATUS_UP);
-
- /* Reset sequence is complete. If this was an application originated */
- /* reset, tell him its done. */
- if (p_cb)
- (*p_cb)((void *) NULL);
-}
-
-/*******************************************************************************
-**
-** Function btm_issue_host_support_for_lmp_features
-**
-** Description This function:
-** - issues commands to set host supported LMP features (one at
-** a time);
-** - after this is done it issues command to re-read LMP features
-** page 1;
-** - after this is done it calls the last step of BR/EDR
-** controller startup sequence.
-**
-** Returns void
-**
-*******************************************************************************/
-static void btm_issue_host_support_for_lmp_features (void)
-{
- BTM_TRACE_DEBUG("btm_issue_host_support_for_lmp_features lmp_features_host_may_support: 0x%02x", btm_cb.devcb.lmp_features_host_may_support);
-
- if (btm_cb.devcb.lmp_features_host_may_support & BTM_HOST_MAY_SUPP_SSP)
- {
- btsnd_hcic_write_simple_pairing_mode(HCI_SP_MODE_ENABLED);
- return;
- }
-
-#if (BLE_INCLUDED == TRUE)
- if (btm_cb.devcb.lmp_features_host_may_support & BTM_HOST_MAY_SUPP_LE)
- {
- if (btm_cb.devcb.lmp_features_host_may_support & BTM_HOST_MAY_SUPP_SIMULT_BR_LE)
- {
- btsnd_hcic_ble_write_host_supported(BTM_BLE_HOST_SUPPORT, BTM_BLE_SIMULTANEOUS_HOST);
- }
- else
- {
- btsnd_hcic_ble_write_host_supported(BTM_BLE_HOST_SUPPORT, 0);
- }
- return;
- }
-#endif
-
- if (btm_cb.devcb.lmp_features_host_may_support & BTM_RE_READ_1ST_PAGE)
- {
- btm_get_local_ext_features(HCI_EXT_FEATURES_PAGE_1);
- return;
- }
-
- if (!btm_cb.devcb.lmp_features_host_may_support)
- {
-#if BLE_INCLUDED == TRUE
- if (HCI_LE_HOST_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_1]))
- {
- btm_read_ble_wl_size();
- }
- else
-#endif
- {
- btm_reset_ctrlr_complete();
- }
- return;
- }
-
- BTM_TRACE_ERROR("%s lmp_features_host_may_support: 0x%02x. This is unexpected.",__FUNCTION__,
- btm_cb.devcb.lmp_features_host_may_support);
-}
-
-/*******************************************************************************
-**
-** Function btm_set_lmp_features_host_may_support
-**
-** Description This function is called after all LMP features provided by
-** controller are read. It sets the mask that indicates LMP
-** features the host may support based on LMP features supported
-** by controller.
-** Example:
-** Host may set SSP (host support) bit only if SSP (controller
-** support) bit is set by controller.
-**
-** Returns void
-**
-*******************************************************************************/
-static void btm_set_lmp_features_host_may_support (UINT8 max_page_number)
-{
- btm_cb.devcb.lmp_features_host_may_support = 0;
-
- /* LMP page 0 is always read */
- if (HCI_SIMPLE_PAIRING_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_0]))
- {
- /* host may support SSP */
- btm_cb.devcb.lmp_features_host_may_support |= BTM_HOST_MAY_SUPP_SSP;
- }
-
-#if (BLE_INCLUDED == TRUE)
- if (HCI_LE_SPT_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_0]))
- {
- /* host may support LE */
- btm_cb.devcb.lmp_features_host_may_support |= BTM_HOST_MAY_SUPP_LE;
-
- if (HCI_SIMUL_LE_BREDR_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_0]))
- {
- /* host may support BR/EDR and LE simultaneously */
- btm_cb.devcb.lmp_features_host_may_support |= BTM_HOST_MAY_SUPP_SIMULT_BR_LE;
- }
- }
-#endif
-
- if (max_page_number >= HCI_EXT_FEATURES_PAGE_1)
- {
- /* nothing yet for HCI_EXT_FEATURES_PAGE_1 */
- }
-
- if (max_page_number >= HCI_EXT_FEATURES_PAGE_1)
- {
- /* nothing yet for HCI_EXT_FEATURES_PAGE_2 */
- }
-
- if (btm_cb.devcb.lmp_features_host_may_support)
- btm_cb.devcb.lmp_features_host_may_support |= BTM_RE_READ_1ST_PAGE;
-}
-
-/*******************************************************************************
-**
-** Function btm_read_all_lmp_features_complete
-**
-** Description This function is called after all LMP features provided by
-** controller are read.
-** It works with controller supported LMP features which host
-** may support too.
-**
-** Returns void
-**
-*******************************************************************************/
-static void btm_read_all_lmp_features_complete (UINT8 max_page_number)
-{
- btm_set_lmp_features_host_may_support(max_page_number);
-
- btm_issue_host_support_for_lmp_features();
-}
-
-/*******************************************************************************
-**
-** Function btm_read_local_features_complete
-**
-** Description This function is called when local supported features read
-** is complete.
-**
-** Returns void
-**
-*******************************************************************************/
-void btm_read_local_features_complete (UINT8 *p, UINT16 evt_len)
-{
- tBTM_DEVCB *p_devcb = &btm_cb.devcb;
- UINT8 status;
- UNUSED(evt_len);
-
- btu_stop_timer (&p_devcb->reset_timer);
-
- STREAM_TO_UINT8 (status, p);
- if (status == HCI_SUCCESS)
- {
- /* Save the Feature Page 0 */
- STREAM_TO_ARRAY(p_devcb->local_lmp_features[0],
- p, HCI_FEATURE_BYTES_PER_PAGE);
-
- if ((HCI_LMP_EXTENDED_SUPPORTED(p_devcb->local_lmp_features[HCI_EXT_FEATURES_PAGE_0])) &&
- (HCI_READ_LOCAL_EXT_FEATURES_SUPPORTED(p_devcb->supported_cmds)))
- {
- /* if local controller has extended features and supports
- **HCI_Read_Local_Extended_Features command,
- ** then start reading these feature starting with extended features page 1 */
- BTM_TRACE_DEBUG ("Start reading local extended features");
- btm_get_local_ext_features(HCI_EXT_FEATURES_PAGE_1);
- }
- else
- {
- btm_read_all_lmp_features_complete (HCI_EXT_FEATURES_PAGE_0);
- }
- }
-}
-
-/*******************************************************************************
-**
-** Function btm_read_local_ext_features_complete
-**
-** Description This function is called when read local extended features
-** command complete message is received from the HCI.
-**
-** Returns void
-**
-*******************************************************************************/
-void btm_read_local_ext_features_complete (UINT8 *p, UINT16 evt_len)
-{
- tBTM_DEVCB *p_devcb = &btm_cb.devcb;
- tBTM_CMPL_CB *p_cb = p_devcb->p_reset_cmpl_cb;
- UINT8 status;
- UINT8 page_number;
- UINT8 page_number_max;
- UNUSED(evt_len);
-
- btu_stop_timer (&btm_cb.devcb.reset_timer);
-
- STREAM_TO_UINT8 (status, p);
-
- if (status != HCI_SUCCESS)
- {
- BTM_TRACE_WARNING("btm_read_local_ext_features_complete status = 0x%02X", status);
- btm_read_all_lmp_features_complete (HCI_EXT_FEATURES_PAGE_0);
- return;
- }
-
- /* Extract Page number */
- STREAM_TO_UINT8 (page_number, p);
-
- /* Extract Page number Max */
- STREAM_TO_UINT8 (page_number_max, p);
-
- if (page_number > HCI_EXT_FEATURES_PAGE_MAX)
- {
- BTM_TRACE_ERROR("btm_read_local_ext_features_complete page=%d unknown",
- page_number);
- return;
- }
-
- /* Save the extended features Page received */
- STREAM_TO_ARRAY(btm_cb.devcb.local_lmp_features[page_number],
- p, HCI_FEATURE_BYTES_PER_PAGE);
-
- /* If this is re-read of the 1-st extended page after host supported LMP features are set */
- if ((page_number == HCI_EXT_FEATURES_PAGE_1) &&
- (btm_cb.devcb.lmp_features_host_may_support == BTM_RE_READ_1ST_PAGE))
- {
- btm_cb.devcb.lmp_features_host_may_support &= ~BTM_RE_READ_1ST_PAGE;
- btm_issue_host_support_for_lmp_features();
- return;
- }
-
- /* If this is the last page supported by the local BT controller OR */
- /* if this is the last page supported by the Host */
- if ((page_number == page_number_max) ||
- (page_number == HCI_EXT_FEATURES_PAGE_MAX))
- {
- BTM_TRACE_DEBUG("BTM reached last extended features page (%d)", page_number);
- btm_read_all_lmp_features_complete(page_number);
- }
- /* Else (another page must be read) */
- else
- {
- /* Read the next features page */
- page_number++;
- BTM_TRACE_DEBUG("BTM reads next extended features page (%d)", page_number);
- btm_get_local_ext_features(page_number);
- }
-}
-
-/*******************************************************************************
-**
-** Function btm_read_local_supported_cmds_complete
-**
-** Description This function is called when local supported commands read
-** is complete.
-**
-** Returns void
-**
-*******************************************************************************/
-void btm_read_local_supported_cmds_complete (UINT8 *p)
-{
- tBTM_DEVCB *p_devcb = &btm_cb.devcb;
- UINT8 status;
-
- btu_stop_timer (&(p_devcb->reset_timer));
-
- STREAM_TO_UINT8 (status, p);
- BTM_TRACE_DEBUG("btm_read_local_supported_cmds_complete status (0x%02x)", status);
-
- if (status == HCI_SUCCESS)
- {
- /* Save the supported commands bit mask */
- STREAM_TO_ARRAY(p_devcb->supported_cmds, p, HCI_NUM_SUPP_COMMANDS_BYTES);
- }
-
- btm_get_local_features();
-}
-
-/*******************************************************************************
-**
-** Function btm_write_simple_paring_mode_complete
-**
-** Description This function is called when the command complete message
-** is received from the HCI for the write simple pairing mode
-** command.
-**
-** Returns void
-**
-*******************************************************************************/
-void btm_write_simple_paring_mode_complete (UINT8 *p)
-{
- UINT8 status;
-
- STREAM_TO_UINT8 (status, p);
-
- if (status != HCI_SUCCESS)
- {
- BTM_TRACE_WARNING("btm_write_simple_paring_mode_complete status: 0x%02x", status);
- }
-
- if (btm_cb.devcb.lmp_features_host_may_support & BTM_HOST_MAY_SUPP_SSP)
- {
- btm_cb.devcb.lmp_features_host_may_support &= ~BTM_HOST_MAY_SUPP_SSP;
- btm_issue_host_support_for_lmp_features();
- }
-}
-
-/*******************************************************************************
-**
-** Function btm_write_le_host_supported_complete
-**
-** Description This function is called when the command complete message
-** is received from the HCI for the write LE host supported
-** command.
-**
-** Returns void
-**
-*******************************************************************************/
-void btm_write_le_host_supported_complete (UINT8 *p)
-{
- UINT8 status;
-
- STREAM_TO_UINT8 (status, p);
-
- if (status != HCI_SUCCESS)
- {
- BTM_TRACE_WARNING("btm_write_le_host_supported_complete status: 0x%02x", status);
- }
-
- if (btm_cb.devcb.lmp_features_host_may_support & BTM_HOST_MAY_SUPP_LE)
- {
- btm_cb.devcb.lmp_features_host_may_support &= ~BTM_HOST_MAY_SUPP_LE;
- if (btm_cb.devcb.lmp_features_host_may_support & BTM_HOST_MAY_SUPP_SIMULT_BR_LE)
- {
- btm_cb.devcb.lmp_features_host_may_support &= ~BTM_HOST_MAY_SUPP_SIMULT_BR_LE;
- }
- btm_issue_host_support_for_lmp_features();
- }
-}
-
-/*******************************************************************************
-**
-** Function btm_get_voice_coding_support
-**
-** Description This function is provides a way to get the voice coding schemes
-** supported the device.
-**
-** Returns A bit mask - Bit 0 if set indicates CVSD support
-** Bit 1 if set indicates PCM A-law support
-** Bit 2 if set indicates PCM Mu-law support
-**
-*******************************************************************************/
-
-UINT8 btm_get_voice_coding_support( void )
-{
- UINT8 code = 0;
-
- if( HCI_LMP_CVSD_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_0]) ) code |= 0x01 ;
- if( HCI_LMP_A_LAW_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_0]) ) code |= 0x02 ;
- if( HCI_LMP_U_LAW_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_0]) ) code |= 0x04 ;
-
- return code ;
-}
-
-/*******************************************************************************
-**
** Function BTM_SetLocalDeviceName
**
** Description This function is called to set the local device name.
@@ -1467,8 +515,7 @@
if (!p_name || !p_name[0] || (strlen ((char *)p_name) > BD_NAME_LEN))
return (BTM_ILLEGAL_VALUE);
- if (btm_cb.devcb.state == BTM_DEV_STATE_WAIT_RESET_CMPLT ||
- btm_cb.devcb.state == BTM_DEV_STATE_WAIT_AFTER_RESET)
+ if (!controller_get_interface()->get_is_ready())
return (BTM_DEV_RESET);
#if BTM_MAX_LOC_BD_NAME_LEN > 0
@@ -1573,7 +620,8 @@
}
}
-
+// TODO(zachoverflow):
+// These two functions do pretty much the same thing...just what is this I can't even whyyy
/*******************************************************************************
**
** Function BTM_GetLocalDeviceAddr
@@ -1586,7 +634,7 @@
*******************************************************************************/
void BTM_GetLocalDeviceAddr (BD_ADDR bd_addr)
{
- memcpy (bd_addr, btm_cb.devcb.local_addr, BD_ADDR_LEN);
+ memcpy (bd_addr, controller_get_interface()->get_address(), BD_ADDR_LEN);
}
/*******************************************************************************
@@ -1601,35 +649,11 @@
tBTM_STATUS BTM_ReadLocalDeviceAddr (tBTM_CMPL_CB *p_cb)
{
if(p_cb)
- (*p_cb)(btm_cb.devcb.local_addr);
+ (*p_cb)((void *)controller_get_interface()->get_address());
return (BTM_SUCCESS);
}
-
-/*******************************************************************************
-**
-** Function btm_read_local_addr_complete
-**
-** Description This function is called when local BD Addr read complete
-** message is received from the HCI.
-**
-** Returns void
-**
-*******************************************************************************/
-void btm_read_local_addr_complete (UINT8 *p, UINT16 evt_len)
-{
- UINT8 status;
- UNUSED(evt_len);
-
- STREAM_TO_UINT8 (status, p);
-
- if (status == HCI_SUCCESS)
- {
- STREAM_TO_BDADDR (btm_cb.devcb.local_addr, p);
- }
-}
-
/*******************************************************************************
**
** Function BTM_SetDeviceClass
@@ -1646,8 +670,7 @@
memcpy (btm_cb.devcb.dev_class, dev_class, DEV_CLASS_LEN);
- if (btm_cb.devcb.state == BTM_DEV_STATE_WAIT_RESET_CMPLT ||
- btm_cb.devcb.state == BTM_DEV_STATE_WAIT_AFTER_RESET)
+ if (!controller_get_interface()->get_is_ready())
return (BTM_DEV_RESET);
if (!btsnd_hcic_write_dev_class (dev_class))
@@ -1681,29 +704,11 @@
** Returns pointer to the local features string
**
*******************************************************************************/
+// TODO(zachoverflow): get rid of this function
UINT8 *BTM_ReadLocalFeatures (void)
{
- return (btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_0]);
-}
-
-/*******************************************************************************
-**
-** Function BTM_ReadLocalExtendedFeatures
-**
-** Description This function is called to read the local extended features
-**
-** Returns pointer to the local extended features mask or NULL if bad
-** page
-**
-*******************************************************************************/
-UINT8 *BTM_ReadLocalExtendedFeatures (UINT8 page_number)
-{
- if (page_number <= HCI_EXT_FEATURES_PAGE_MAX)
- return (btm_cb.devcb.local_lmp_features[page_number]);
-
- BTM_TRACE_ERROR("Warning: BTM_ReadLocalExtendedFeatures page %d unknown",
- page_number);
- return NULL;
+ // Discarding const modifier for now, until this function dies
+ return (UINT8 *)controller_get_interface()->get_features_classic(0)->as_array;
}
/*******************************************************************************
@@ -1975,11 +980,11 @@
}
/* mask off all of event from controller */
- if (!btsnd_hcic_set_event_mask(LOCAL_BR_EDR_CONTROLLER_ID,
- (UINT8 *)"\x00\x00\x00\x00\x00\x00\x00\x00"))
- {
- return BTM_NO_RESOURCES;
- }
+ 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 ())
diff --git a/stack/btm/btm_inq.c b/stack/btm/btm_inq.c
index 8dac72c..f425eb8 100644
--- a/stack/btm/btm_inq.c
+++ b/stack/btm/btm_inq.c
@@ -31,6 +31,7 @@
#include <stddef.h>
#include "bt_types.h"
+#include "controller.h"
#include "gki.h"
#include "hcimsgs.h"
#include "btu.h"
@@ -185,7 +186,7 @@
BTM_TRACE_API ("BTM_SetDiscoverability");
#if (BLE_INCLUDED == TRUE && BLE_INCLUDED == TRUE)
- if (HCI_LE_HOST_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_1]))
+ if (controller_get_interface()->supports_ble())
{
if (btm_ble_set_discoverability((UINT16)(inq_mode))
== BTM_SUCCESS)
@@ -202,7 +203,7 @@
return (BTM_ILLEGAL_VALUE);
/* Make sure the controller is active */
- if (btm_cb.devcb.state < BTM_DEV_STATE_READY)
+ if (!controller_get_interface()->get_is_ready())
return (BTM_DEV_RESET);
/* If the window and/or interval is '0', set to default values */
@@ -316,7 +317,7 @@
return (BTM_ILLEGAL_VALUE);
/* whatever app wants if device is not 1.2 scan type should be STANDARD */
- if (!HCI_LMP_INTERLACED_INQ_SCAN_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_0]))
+ if (!controller_get_interface()->supports_interlaced_inquiry_scan())
return (BTM_MODE_UNSUPPORTED);
/* Check for scan type if configuration has been changed */
@@ -353,7 +354,7 @@
return (BTM_ILLEGAL_VALUE);
/* whatever app wants if device is not 1.2 scan type should be STANDARD */
- if (!HCI_LMP_INTERLACED_PAGE_SCAN_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_0]))
+ if (!controller_get_interface()->supports_interlaced_inquiry_scan())
return (BTM_MODE_UNSUPPORTED);
/* Check for scan type if configuration has been changed */
@@ -389,6 +390,7 @@
*******************************************************************************/
tBTM_STATUS BTM_SetInquiryMode (UINT8 mode)
{
+ const controller_t *controller = controller_get_interface();
BTM_TRACE_API ("BTM_SetInquiryMode");
if (mode == BTM_INQ_RESULT_STANDARD)
{
@@ -396,13 +398,13 @@
}
else if (mode == BTM_INQ_RESULT_WITH_RSSI)
{
- if (!HCI_LMP_INQ_RSSI_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_0]))
- return (BTM_MODE_UNSUPPORTED);
+ if (!controller->supports_rssi_with_inquiry_results())
+ return (BTM_MODE_UNSUPPORTED);
}
#if (( BTM_EIR_CLIENT_INCLUDED == TRUE )||( BTM_EIR_SERVER_INCLUDED == TRUE ))
else if (mode == BTM_INQ_RESULT_EXTENDED)
{
- if (!HCI_EXT_INQ_RSP_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_0]))
+ if (!controller->supports_extended_inquiry_response())
return (BTM_MODE_UNSUPPORTED);
}
#endif
@@ -622,7 +624,7 @@
BTM_TRACE_API ("BTM_SetConnectability");
#if (BLE_INCLUDED == TRUE && BLE_INCLUDED == TRUE)
- if (HCI_LE_HOST_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_1]))
+ if (controller_get_interface()->supports_ble())
{
if (btm_ble_set_connectability(page_mode) != BTM_SUCCESS)
{
@@ -639,7 +641,7 @@
return (BTM_ILLEGAL_VALUE);
/* Make sure the controller is active */
- if (btm_cb.devcb.state < BTM_DEV_STATE_READY)
+ if (!controller_get_interface()->get_is_ready())
return (BTM_DEV_RESET);
/* If the window and/or interval is '0', set to default values */
@@ -946,7 +948,7 @@
BTM_TRACE_API("BTM:Starting LE Scan with duration %d and activeMode:0x%02x",
p_inqparms->duration, (p_inqparms->mode & BTM_BLE_INQUIRY_MASK));
#endif
- if (!HCI_LE_HOST_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_1]))
+ if (!controller_get_interface()->supports_ble())
{
p_inq->inqparms.mode &= ~ BTM_BLE_INQUIRY_MASK;
status = BTM_ILLEGAL_VALUE;
@@ -2335,7 +2337,7 @@
btm_clr_inq_result_flt();
if((p_inq->inq_cmpl_info.status == BTM_SUCCESS) &&
- HCI_LMP_INQ_RSSI_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_0]))
+ controller_get_interface()->supports_rssi_with_inquiry_results())
{
btm_sort_inq_result();
}
@@ -2648,7 +2650,7 @@
tBTM_STATUS BTM_WriteEIR( BT_HDR *p_buff )
{
#if (BTM_EIR_SERVER_INCLUDED == TRUE)
- if (HCI_EXT_INQ_RSP_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_0]))
+ if (controller_get_interface()->supports_extended_inquiry_response())
{
BTM_TRACE_API("Write Extended Inquiry Response to controller");
btsnd_hcic_write_ext_inquiry_response (p_buff, BTM_EIR_DEFAULT_FEC_REQUIRED);
diff --git a/stack/btm/btm_int.h b/stack/btm/btm_int.h
index 57fdf51..808b443 100644
--- a/stack/btm/btm_int.h
+++ b/stack/btm/btm_int.h
@@ -69,10 +69,10 @@
HCI_PKT_TYPES_MASK_NO_3_DH5)
#define BTM_EPR_AVAILABLE(p) ((HCI_ATOMIC_ENCRYPT_SUPPORTED((p)->peer_lmp_features[HCI_EXT_FEATURES_PAGE_0]) && \
- HCI_ATOMIC_ENCRYPT_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_0])) \
+ HCI_ATOMIC_ENCRYPT_SUPPORTED(controller_get_interface()->get_features_classic(0)->as_array)) \
? TRUE : FALSE)
-#define BTM_IS_BRCM_CONTROLLER() (btm_cb.devcb.local_version.manufacturer == LMP_COMPID_BROADCOM)
+#define BTM_IS_BRCM_CONTROLLER() (controller_get_interface()->get_bt_version()->manufacturer == LMP_COMPID_BROADCOM)
/* Define the ACL Management control structure
*/
@@ -145,8 +145,7 @@
tBTM_CMPL_CB *p_stored_link_key_cmpl_cb; /* Read/Write/Delete stored link key */
TIMER_LIST_ENT reset_timer;
- tBTM_CMPL_CB *p_reset_cmpl_cb; /* Callback function to be called */
- /* when startup of the device is done */
+
TIMER_LIST_ENT rln_timer;
tBTM_CMPL_CB *p_rln_cmpl_cb; /* Callback function to be called when */
/* read local name function complete */
@@ -178,20 +177,14 @@
TIMER_LIST_ENT tx_power_timer;
tBTM_CMPL_CB *p_tx_power_cmpl_cb;/* Callback function to be called */
- BD_ADDR local_addr; /* BD_ADDR of the local device */
- tBTM_VERSION_INFO local_version; /* Local Version Information */
DEV_CLASS dev_class; /* Local device class */
- /* Local LMP Extended features mask table for the device */
- BD_FEATURES local_lmp_features[HCI_EXT_FEATURES_PAGE_MAX + 1];
-
#if BLE_INCLUDED == TRUE
tBTM_CMPL_CB *p_le_test_cmd_cmpl_cb; /* Callback function to be called when
LE test mode command has been sent successfully */
BD_ADDR read_tx_pwr_addr; /* read TX power target address */
- BD_FEATURES local_le_features; /* Local LE Supported features mask for the device */
tBTM_BLE_LOCAL_ID_KEYS id_keys; /* local BLE ID keys */
BT_OCTET16 er; /* BLE encryption key */
@@ -212,22 +205,8 @@
#endif /* BLE_INCLUDED */
-#define BTM_DEV_STATE_WAIT_RESET_CMPLT 0
-#define BTM_DEV_STATE_WAIT_AFTER_RESET 1
-#define BTM_DEV_STATE_READY 2
-
- UINT8 state;
tBTM_IO_CAP loc_io_caps; /* IO capability of the local device */
tBTM_AUTH_REQ loc_auth_req; /* the auth_req flag */
-#define BTM_RELOAD_LE_HOST_FEATURE 0x10
-
-#define BTM_RE_READ_1ST_PAGE 0x01 /* Set it if you set at least one of "..._HOST_MAY_SUPP_..." bits */
-#define BTM_HOST_MAY_SUPP_SSP 0x02
-#define BTM_HOST_MAY_SUPP_LE 0x04
-#define BTM_HOST_MAY_SUPP_SIMULT_BR_LE 0x08
- UINT8 lmp_features_host_may_support; /* The flags of LMP features host may support via BR/EDR ctrlr + BTM_RE_READ_1ST_PAGE */
- UINT8 supported_cmds[HCI_NUM_SUPP_COMMANDS_BYTES]; /* Supported Commands bit field */
-
} tBTM_DEVCB;
@@ -1066,24 +1045,10 @@
**********************************************
*/
extern void btm_dev_init (void);
-extern void btm_dev_absent (void);
extern void btm_dev_timeout (TIMER_LIST_ENT *p_tle);
-extern void btm_reset_complete (void);
-extern void btm_read_local_version_complete (UINT8 *p, UINT16 evt_len);
-extern void btm_read_hci_buf_size_complete (UINT8 *p, UINT16 evt_len);
-extern void btm_read_local_supported_cmds_complete (UINT8 *p);
-extern void btm_read_local_features_complete (UINT8 *p, UINT16 evt_len);
-extern void btm_read_local_ext_features_complete (UINT8 *p, UINT16 evt_len);
extern void btm_read_local_name_complete (UINT8 *p, UINT16 evt_len);
-extern void btm_read_local_addr_complete (UINT8 *p, UINT16 evt_len);
-extern void btm_reset_ctrlr_complete (void);
-extern void btm_write_simple_paring_mode_complete (UINT8 *p);
-extern void btm_write_le_host_supported_complete (UINT8 *p);
#if (BLE_INCLUDED == TRUE)
-extern void btm_read_ble_buf_size_complete (UINT8 *p, UINT16 evt_len);
-extern void btm_read_ble_local_supported_features_complete (UINT8 *p, UINT16 evt_len);
-extern void btm_read_white_list_size_complete(UINT8 *p, UINT16 evt_len);
extern void btm_ble_add_2_white_list_complete(UINT8 status);
extern void btm_ble_remove_from_white_list_complete(UINT8 *p, UINT16 evt_len);
extern void btm_ble_clear_white_list_complete(UINT8 *p, UINT16 evt_len);
@@ -1105,7 +1070,6 @@
**********************************************
*/
extern BOOLEAN btm_dev_support_switch (BD_ADDR bd_addr);
-extern UINT8 btm_get_voice_coding_support (void);
extern tBTM_SEC_DEV_REC *btm_sec_alloc_dev (BD_ADDR bd_addr);
extern void btm_sec_free_dev (tBTM_SEC_DEV_REC *p_dev_rec);
diff --git a/stack/btm/btm_sec.c b/stack/btm/btm_sec.c
index 611c9dd..2aeda95 100644
--- a/stack/btm/btm_sec.c
+++ b/stack/btm/btm_sec.c
@@ -23,7 +23,9 @@
******************************************************************************/
#include <string.h>
+
#include "bt_types.h"
+#include "controller.h"
#include "hcimsgs.h"
#include "btu.h"
#include "btm_int.h"
@@ -381,7 +383,7 @@
/* If device is not up security mode will be set as a part of startup */
if ( (btm_cb.cfg.pin_type != pin_type)
- && (btm_cb.devcb.state > BTM_DEV_STATE_WAIT_AFTER_RESET) )
+ && controller_get_interface()->get_is_ready() )
{
btsnd_hcic_write_pin_type (pin_type);
}
@@ -1154,7 +1156,7 @@
BTM_TRACE_DEBUG ("after update sec_flags=0x%x", p_dev_rec->sec_flags);
- if (!HCI_SIMPLE_PAIRING_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_0]))
+ if (!controller_get_interface()->supports_simple_pairing())
{
/* The special case when we authenticate keyboard. Set pin type to fixed */
/* It would be probably better to do it from the application, but it is */
@@ -1197,7 +1199,7 @@
}
BTM_TRACE_DEBUG ("sec mode: %d sm4:x%x", btm_cb.security_mode, p_dev_rec->sm4);
- if (!HCI_SIMPLE_PAIRING_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_0])
+ if (!controller_get_interface()->supports_simple_pairing()
|| (p_dev_rec->sm4 == BTM_SM4_KNOWN))
{
if ( btm_sec_check_prefetch_pin (p_dev_rec) )
@@ -1848,7 +1850,7 @@
{
/* add mandatory part */
UINT16_TO_STREAM(p, len);
- BDADDR_TO_STREAM(p, btm_cb.devcb.local_addr);
+ BDADDR_TO_STREAM(p, controller_get_interface()->get_address()->address);
len = BTM_OOB_MANDATORY_SIZE;
max_len -= len;
@@ -2590,7 +2592,7 @@
tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev (bda);
/* Some device may request a connection before we are done with the HCI_Reset sequence */
- if (btm_cb.devcb.state != BTM_DEV_STATE_READY)
+ if (!controller_get_interface()->get_is_ready())
{
BTM_TRACE_EVENT ("Security Manager: connect request when device not ready");
btsnd_hcic_reject_conn (bda, HCI_ERR_HOST_REJECT_DEVICE);
@@ -2826,17 +2828,8 @@
*******************************************************************************/
void btm_sec_dev_reset (void)
{
- /* btm_sec_dev_reset() is only called from btm_decode_ext_features_page(...)
- * right now. */
- if (HCI_SIMPLE_PAIRING_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_0]))
+ if (controller_get_interface()->supports_simple_pairing())
{
-#if BLE_INCLUDED == TRUE
- btsnd_hcic_set_event_mask(LOCAL_BR_EDR_CONTROLLER_ID,
- (UINT8 *)HCI_DUMO_EVENT_MASK_EXT);
-#else
- btsnd_hcic_set_event_mask(LOCAL_BR_EDR_CONTROLLER_ID,
- (UINT8 *)HCI_LISBON_EVENT_MASK_EXT);
-#endif
/* set the default IO capabilities */
btm_cb.devcb.loc_io_caps = BTM_LOCAL_IO_CAPS;
/* add mx service to use no security */
diff --git a/stack/btu/btu_hcif.c b/stack/btu/btu_hcif.c
index 8964115..e63a6ec 100644
--- a/stack/btu/btu_hcif.c
+++ b/stack/btu/btu_hcif.c
@@ -25,6 +25,7 @@
*
******************************************************************************/
+#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
@@ -899,10 +900,6 @@
{
switch (opcode)
{
- case HCI_RESET:
- btm_reset_complete (); /* BR/EDR */
- break;
-
case HCI_INQUIRY_CANCEL:
/* Tell inquiry processing that we are done */
btm_process_cancel_complete(HCI_SUCCESS, BTM_BR_INQUIRY_MASK);
@@ -923,38 +920,14 @@
btm_delete_stored_link_key_complete (p);
break;
- case HCI_READ_LOCAL_VERSION_INFO:
- btm_read_local_version_complete (p, evt_len);
- break;
-
case HCI_READ_POLICY_SETTINGS:
btm_read_link_policy_complete (p);
break;
- case HCI_READ_BUFFER_SIZE:
- btm_read_hci_buf_size_complete (p, evt_len);
- break;
-
- case HCI_READ_LOCAL_SUPPORTED_CMDS:
- btm_read_local_supported_cmds_complete (p);
- break;
-
- case HCI_READ_LOCAL_FEATURES:
- btm_read_local_features_complete (p, evt_len);
- break;
-
- case HCI_READ_LOCAL_EXT_FEATURES:
- btm_read_local_ext_features_complete (p, evt_len);
- break;
-
case HCI_READ_LOCAL_NAME:
btm_read_local_name_complete (p, evt_len);
break;
- case HCI_READ_BD_ADDR:
- btm_read_local_addr_complete (p, evt_len);
- break;
-
case HCI_GET_LINK_QUALITY:
btm_read_link_quality_complete (p);
break;
@@ -982,20 +955,8 @@
btm_read_linq_tx_power_complete (p);
break;
- case HCI_WRITE_SIMPLE_PAIRING_MODE:
- btm_write_simple_paring_mode_complete (p);
- break;
-
- case HCI_WRITE_LE_HOST_SUPPORTED:
- btm_write_le_host_supported_complete (p);
- break;
-
#if (BLE_INCLUDED == TRUE)
/* BLE Commands sComplete*/
- case HCI_BLE_READ_WHITE_LIST_SIZE :
- btm_read_white_list_size_complete(p, evt_len);
- break;
-
case HCI_BLE_ADD_WHITE_LIST:
btm_ble_add_2_white_list_complete(*p);
break;
@@ -1013,14 +974,6 @@
btm_ble_rand_enc_complete (p, opcode, (tBTM_RAND_ENC_CB *)p_cplt_cback);
break;
- case HCI_BLE_READ_BUFFER_SIZE:
- btm_read_ble_buf_size_complete(p, evt_len);
- break;
-
- case HCI_BLE_READ_LOCAL_SPT_FEAT:
- btm_read_ble_local_supported_features_complete(p, evt_len);
- break;
-
case HCI_BLE_READ_ADV_CHNL_TX_POWER:
btm_read_tx_power_complete(p, TRUE);
break;
@@ -1029,10 +982,6 @@
btm_ble_write_adv_enable_complete(p);
break;
- case HCI_BLE_READ_SUPPORTED_STATES:
- btm_read_ble_local_supported_states_complete(p, evt_len);
- break;
-
case HCI_BLE_CREATE_LL_CONN:
btm_ble_create_ll_conn_complete(*p);
break;
diff --git a/stack/btu/btu_init.c b/stack/btu/btu_init.c
index 8611de6..162b4bc 100644
--- a/stack/btu/btu_init.c
+++ b/stack/btu/btu_init.c
@@ -26,6 +26,7 @@
#include "dyn_mem.h"
#include "alarm.h"
+#include "controller.h"
#include "fixed_queue.h"
#include "hash_functions.h"
#include "hash_map.h"
@@ -143,10 +144,6 @@
void BTU_StartUp(void)
{
memset (&btu_cb, 0, sizeof (tBTU_CB));
- btu_cb.hcit_acl_pkt_size = BTU_DEFAULT_DATA_SIZE + HCI_DATA_PREAMBLE_SIZE;
-#if (BLE_INCLUDED == TRUE)
- btu_cb.hcit_ble_acl_pkt_size = BTU_DEFAULT_BLE_DATA_SIZE + HCI_DATA_PREAMBLE_SIZE;
-#endif
btu_cb.trace_level = HCI_INITIAL_TRACE_LEVEL;
btu_bta_msg_queue = fixed_queue_new(SIZE_MAX);
@@ -246,7 +243,7 @@
******************************************************************************/
UINT16 BTU_AclPktSize(void)
{
- return btu_cb.hcit_acl_pkt_size;
+ return controller_get_interface()->get_acl_packet_size_classic();
}
/*****************************************************************************
**
@@ -260,7 +257,7 @@
UINT16 BTU_BleAclPktSize(void)
{
#if BLE_INCLUDED == TRUE
- return btu_cb.hcit_ble_acl_pkt_size;
+ return controller_get_interface()->get_acl_packet_size_ble();
#else
return 0;
#endif
diff --git a/stack/hcic/hciblecmds.c b/stack/hcic/hciblecmds.c
index 860fb7a..fa46dec 100644
--- a/stack/hcic/hciblecmds.c
+++ b/stack/hcic/hciblecmds.c
@@ -35,68 +35,6 @@
#if (defined BLE_INCLUDED) && (BLE_INCLUDED == TRUE)
-BOOLEAN btsnd_hcic_ble_set_evt_mask (BT_EVENT_MASK event_mask)
-{
- BT_HDR *p;
- UINT8 *pp;
-
- if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_SET_EVENT_MASK)) == NULL)
- return (FALSE);
-
- pp = (UINT8 *)(p + 1);
-
- p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_SET_EVENT_MASK;
- p->offset = 0;
-
- UINT16_TO_STREAM (pp, HCI_BLE_SET_EVENT_MASK);
- UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_SET_EVENT_MASK);
- ARRAY8_TO_STREAM (pp, event_mask);
-
- btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
- return (TRUE);
-}
-
-
-BOOLEAN btsnd_hcic_ble_read_buffer_size (void)
-{
- BT_HDR *p;
- UINT8 *pp;
-
- if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL)
- return (FALSE);
-
- pp = (UINT8 *)(p + 1);
-
- p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD;
- p->offset = 0;
-
- UINT16_TO_STREAM (pp, HCI_BLE_READ_BUFFER_SIZE);
- UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD);
-
- btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
- return (TRUE);
-}
-
-BOOLEAN btsnd_hcic_ble_read_local_spt_feat (void)
-{
- BT_HDR *p;
- UINT8 *pp;
-
- if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL)
- return (FALSE);
-
- pp = (UINT8 *)(p + 1);
-
- p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD;
- p->offset = 0;
-
- UINT16_TO_STREAM (pp, HCI_BLE_READ_LOCAL_SPT_FEAT);
- UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD);
-
- btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
- return (TRUE);
-}
-
BOOLEAN btsnd_hcic_ble_set_local_used_feat (UINT8 feat_set[8])
{
BT_HDR *p;
@@ -391,26 +329,6 @@
return (TRUE);
}
-BOOLEAN btsnd_hcic_ble_read_white_list_size (void)
-{
- BT_HDR *p;
- UINT8 *pp;
-
- if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL)
- return (FALSE);
-
- pp = (UINT8 *)(p + 1);
-
- p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD;
- p->offset = 0;
-
- UINT16_TO_STREAM (pp, HCI_BLE_READ_WHITE_LIST_SIZE);
- UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD);
-
- btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
- return (TRUE);
-}
-
BOOLEAN btsnd_hcic_ble_clear_white_list (void)
{
BT_HDR *p;
@@ -707,26 +625,6 @@
return (TRUE);
}
-BOOLEAN btsnd_hcic_ble_read_supported_states (void)
-{
- BT_HDR *p;
- UINT8 *pp;
-
- if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL)
- return (FALSE);
-
- pp = (UINT8 *)(p + 1);
-
- p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD;
- p->offset = 0;
-
- UINT16_TO_STREAM (pp, HCI_BLE_READ_SUPPORTED_STATES);
- UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD);
-
- btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
- return (TRUE);
-}
-
BOOLEAN btsnd_hcic_ble_receiver_test(UINT8 rx_freq)
{
BT_HDR *p;
@@ -806,35 +704,13 @@
p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD;
p->offset = 0;
- UINT16_TO_STREAM (pp, HCI_READ_LE_HOST_SUPPORTED);
+ UINT16_TO_STREAM (pp, HCI_READ_LE_HOST_SUPPORT);
UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD);
btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
return (TRUE);
}
-BOOLEAN btsnd_hcic_ble_write_host_supported (UINT8 le_host_spt, UINT8 simul_le_host_spt)
-{
- BT_HDR *p;
- UINT8 *pp;
-
- if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_WRITE_LE_HOST_SUPPORTED)) == NULL)
- return (FALSE);
-
- pp = (UINT8 *)(p + 1);
-
- p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_LE_HOST_SUPPORTED;
- p->offset = 0;
-
- UINT16_TO_STREAM (pp, HCI_WRITE_LE_HOST_SUPPORTED);
- UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_WRITE_LE_HOST_SUPPORTED);
- UINT8_TO_STREAM (pp, le_host_spt);
- UINT8_TO_STREAM (pp, simul_le_host_spt);
-
- btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
- return (TRUE);
-}
-
#if (defined BLE_LLT_INCLUDED) && (BLE_LLT_INCLUDED == TRUE)
BOOLEAN btsnd_hcic_ble_rc_param_req_reply( UINT16 handle,
diff --git a/stack/hcic/hcicmds.c b/stack/hcic/hcicmds.c
index 3b2e1f5..6130c38 100644
--- a/stack/hcic/hcicmds.c
+++ b/stack/hcic/hcicmds.c
@@ -1065,27 +1065,6 @@
return (TRUE);
}
-BOOLEAN btsnd_hcic_set_event_mask(UINT8 local_controller_id, BT_EVENT_MASK event_mask)
-{
- BT_HDR *p;
- UINT8 *pp;
-
- if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_SET_EVENT_MASK)) == NULL)
- return (FALSE);
-
- pp = (UINT8 *)(p + 1);
-
- p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_SET_EVENT_MASK;
- p->offset = 0;
-
- UINT16_TO_STREAM (pp, HCI_SET_EVENT_MASK);
- UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_SET_EVENT_MASK);
- ARRAY8_TO_STREAM (pp, event_mask);
-
- btu_hcif_send_cmd (local_controller_id, p);
- return (TRUE);
-}
-
BOOLEAN btsnd_hcic_set_event_mask_page_2 (UINT8 local_controller_id, BT_EVENT_MASK event_mask)
{
BT_HDR *p;
@@ -1107,34 +1086,6 @@
return (TRUE);
}
-BOOLEAN btsnd_hcic_reset (UINT8 local_controller_id)
-{
- BT_HDR *p;
- UINT8 *pp;
-
- if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_RESET)) == NULL)
- return (FALSE);
-
- pp = (UINT8 *)(p + 1);
-
- p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_RESET;
- p->offset = 0;
-
- UINT16_TO_STREAM (pp, HCI_RESET);
- UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_RESET);
-
- btu_hcif_send_cmd (local_controller_id, p);
-/* If calling from LMP_TEST or ScriptEngine, then send HCI command immediately */
-#if (!defined (LMP_TEST) && !defined(BTISE))
- if (local_controller_id == LOCAL_BR_EDR_CONTROLLER_ID)
- {
- btm_acl_reset_paging ();
- btm_acl_set_discing (FALSE);
- }
-#endif
- return (TRUE);
-}
-
BOOLEAN btsnd_hcic_set_event_filter (UINT8 filt_type, UINT8 filt_cond_type,
UINT8 *filt_cond, UINT8 filt_cond_len)
{
@@ -1997,32 +1948,6 @@
return (TRUE);
}
-BOOLEAN btsnd_hcic_set_host_buf_size (UINT16 acl_len, UINT8 sco_len,
- UINT16 acl_num, UINT16 sco_num)
-{
- BT_HDR *p;
- UINT8 *pp;
-
- if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_SET_HOST_BUF_SIZE)) == NULL)
- return (FALSE);
-
- pp = (UINT8 *)(p + 1);
-
- p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_SET_HOST_BUF_SIZE;
- p->offset = 0;
-
- UINT16_TO_STREAM (pp, HCI_HOST_BUFFER_SIZE);
- UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_SET_HOST_BUF_SIZE);
-
- UINT16_TO_STREAM (pp, acl_len);
- UINT8_TO_STREAM (pp, sco_len);
- UINT16_TO_STREAM (pp, acl_num);
- UINT16_TO_STREAM (pp, sco_num);
-
- btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
- return (TRUE);
-}
-
BOOLEAN btsnd_hcic_host_num_xmitted_pkts (UINT8 num_handles, UINT16 *handle,
UINT16 *num_pkts)
{
@@ -2319,29 +2244,6 @@
}
#endif /* BTM_EIR_SERVER_INCLUDED == TRUE */
-/**** Simple Pairing Commands ****/
-BOOLEAN btsnd_hcic_write_simple_pairing_mode (UINT8 mode)
-{
- BT_HDR *p;
- UINT8 *pp;
-
- if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_W_SIMP_PAIR)) == NULL)
- return (FALSE);
-
- pp = (UINT8 *)(p + 1);
-
- p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_W_SIMP_PAIR;
- p->offset = 0;
-
- UINT16_TO_STREAM (pp, HCI_WRITE_SIMPLE_PAIRING_MODE);
- UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_W_SIMP_PAIR);
-
- UINT8_TO_STREAM (pp, mode);
-
- btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
- return (TRUE);
-}
-
BOOLEAN btsnd_hcic_read_simple_pairing_mode (void)
{
BT_HDR *p;
@@ -2737,108 +2639,6 @@
** End of Lisbon Commands
**************************/
-BOOLEAN btsnd_hcic_read_local_ver (UINT8 local_controller_id)
-{
- BT_HDR *p;
- UINT8 *pp;
-
- if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL)
- return (FALSE);
-
- pp = (UINT8 *)(p + 1);
-
- p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD;
- p->offset = 0;
-
- UINT16_TO_STREAM (pp, HCI_READ_LOCAL_VERSION_INFO);
- UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD);
-
- btu_hcif_send_cmd (local_controller_id, p);
- return (TRUE);
-}
-
-BOOLEAN btsnd_hcic_read_local_supported_cmds (UINT8 local_controller_id)
-{
- BT_HDR *p;
- UINT8 *pp;
-
- if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL)
- return (FALSE);
-
- pp = (UINT8 *)(p + 1);
-
- p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD;
- p->offset = 0;
-
- UINT16_TO_STREAM (pp, HCI_READ_LOCAL_SUPPORTED_CMDS);
- UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD);
-
- btu_hcif_send_cmd (local_controller_id, p);
- return (TRUE);
-}
-
-BOOLEAN btsnd_hcic_read_local_features (void)
-{
- BT_HDR *p;
- UINT8 *pp;
-
- if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL)
- return (FALSE);
-
- pp = (UINT8 *)(p + 1);
-
- p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD;
- p->offset = 0;
-
- UINT16_TO_STREAM (pp, HCI_READ_LOCAL_FEATURES);
- UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD);
-
- btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
- return (TRUE);
-}
-
-BOOLEAN btsnd_hcic_read_local_ext_features (UINT8 page_num)
-{
- BT_HDR *p;
- UINT8 *pp;
-
- if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_LOCAL_EXT_FEATURES)) == NULL)
- return (FALSE);
-
- pp = (UINT8 *)(p + 1);
-
- p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_LOCAL_EXT_FEATURES;
- p->offset = 0;
-
- UINT16_TO_STREAM (pp, HCI_READ_LOCAL_EXT_FEATURES);
- UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_LOCAL_EXT_FEATURES);
-
- UINT8_TO_STREAM (pp, page_num);
-
- btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
- return (TRUE);
-}
-
-BOOLEAN btsnd_hcic_read_buffer_size (void)
-{
- BT_HDR *p;
- UINT8 *pp;
-
- if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL)
- return (FALSE);
-
- pp = (UINT8 *)(p + 1);
-
- p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD;
- p->offset = 0;
-
- UINT16_TO_STREAM (pp, HCI_READ_BUFFER_SIZE);
- UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD);
-
- btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
- return (TRUE);
-}
-
BOOLEAN btsnd_hcic_read_country_code (void)
{
BT_HDR *p;
@@ -2859,26 +2659,6 @@
return (TRUE);
}
-BOOLEAN btsnd_hcic_read_bd_addr (void)
-{
- BT_HDR *p;
- UINT8 *pp;
-
- if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL)
- return (FALSE);
-
- pp = (UINT8 *)(p + 1);
-
- p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD;
- p->offset = 0;
-
- UINT16_TO_STREAM (pp, HCI_READ_BD_ADDR);
- UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD);
-
- btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
- return (TRUE);
-}
-
BOOLEAN btsnd_hcic_read_fail_contact_count (UINT8 local_controller_id, UINT16 handle)
{
BT_HDR *p;
diff --git a/stack/include/btm_api.h b/stack/include/btm_api.h
index 85217e1..b4c5305 100644
--- a/stack/include/btm_api.h
+++ b/stack/include/btm_api.h
@@ -2113,18 +2113,6 @@
/*******************************************************************************
**
-** Function BTM_ReadLocalExtendedFeatures
-**
-** Description This function is called to read the local extended features
-**
-** Returns pointer to the local extended features mask or NULL if bad
-** page
-**
-*******************************************************************************/
-extern UINT8 *BTM_ReadLocalExtendedFeatures (UINT8 page_number);
-
-/*******************************************************************************
-**
** Function BTM_RegisterForDeviceStatusNotif
**
** Description This function is called to register for device status
diff --git a/stack/include/btu.h b/stack/include/btu.h
index 9a9efef..71d0e6d 100644
--- a/stack/include/btu.h
+++ b/stack/include/btu.h
@@ -236,16 +236,6 @@
TIMER_LIST_ENT cmd_cmpl_timer; /* Command complete timer */
- UINT16 hcit_acl_data_size; /* Max ACL data size across HCI transport */
- UINT16 hcit_acl_pkt_size; /* Max ACL packet size across HCI transport */
- /* (this is data size plus 4 bytes overhead) */
-
-#if BLE_INCLUDED == TRUE
- UINT16 hcit_ble_acl_data_size; /* Max BLE ACL data size across HCI transport */
- UINT16 hcit_ble_acl_pkt_size; /* Max BLE ACL packet size across HCI transport */
- /* (this is data size plus 4 bytes overhead) */
-#endif
-
BOOLEAN reset_complete; /* TRUE after first ack from device received */
UINT8 trace_level; /* Trace level for HCI layer */
} tBTU_CB;
diff --git a/stack/include/hcidefs.h b/stack/include/hcidefs.h
index a950695..941ca57 100644
--- a/stack/include/hcidefs.h
+++ b/stack/include/hcidefs.h
@@ -218,8 +218,8 @@
#define HCI_READ_BE_FLUSH_TOUT (0x0069 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
#define HCI_WRITE_BE_FLUSH_TOUT (0x006A | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
#define HCI_SHORT_RANGE_MODE (0x006B | HCI_GRP_HOST_CONT_BASEBAND_CMDS) /* 802.11 only */
-#define HCI_READ_LE_HOST_SUPPORTED (0x006C | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
-#define HCI_WRITE_LE_HOST_SUPPORTED (0x006D | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_READ_LE_HOST_SUPPORT (0x006C | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_WRITE_LE_HOST_SUPPORT (0x006D | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
/* MWS coexistence */
diff --git a/stack/include/hcimsgs.h b/stack/include/hcimsgs.h
index 068b7ee..786fc10 100644
--- a/stack/include/hcimsgs.h
+++ b/stack/include/hcimsgs.h
@@ -611,13 +611,6 @@
/**** end of Simple Pairing Commands ****/
-
-extern BOOLEAN btsnd_hcic_set_event_mask(UINT8 local_controller_id, BT_EVENT_MASK evt_mask);
-
-#define HCIC_PARAM_SIZE_SET_EVENT_MASK 8
-#define HCI_EVENT_MASK_MASK_OFF 0
- /* Set Event Mask */
-
/* Reset */
extern BOOLEAN btsnd_hcic_set_event_mask_page_2 (UINT8 local_controller_id,
BT_EVENT_MASK event_mask);
@@ -626,12 +619,6 @@
#define HCI_EVENT_MASK_MASK_OFF 0
/* Set Event Mask Page 2 */
- /* Reset */
-extern BOOLEAN btsnd_hcic_reset(UINT8 local_controller_id);
-
-#define HCIC_PARAM_SIZE_RESET 0
- /* Reset */
-
/* Store Current Settings */
#define MAX_FILT_COND (sizeof (BD_ADDR) + 1)
@@ -877,7 +864,6 @@
extern BOOLEAN btsnd_hcic_read_local_ver (UINT8 local_controller_id); /* Read Local Version Info */
extern BOOLEAN btsnd_hcic_read_local_supported_cmds (UINT8 local_controller_id); /* Read Local Supported Commands */
extern BOOLEAN btsnd_hcic_read_local_features (void); /* Read Local Supported Features */
-extern BOOLEAN btsnd_hcic_read_buffer_size (void); /* Read Local buffer sizes */
extern BOOLEAN btsnd_hcic_read_country_code (void); /* Read Country Code */
extern BOOLEAN btsnd_hcic_read_bd_addr (void); /* Read Local BD_ADDR */
extern BOOLEAN btsnd_hcic_read_fail_contact_count (UINT8 local_controller_id, UINT16 handle); /* Read Failed Contact Counter */
diff --git a/stack/l2cap/l2c_ble.c b/stack/l2cap/l2c_ble.c
index 1d4655c..87b1521 100644
--- a/stack/l2cap/l2c_ble.c
+++ b/stack/l2cap/l2c_ble.c
@@ -30,6 +30,7 @@
#include "btu.h"
#include "btm_int.h"
#include "hcimsgs.h"
+#include "controller.h"
#if (BLE_INCLUDED == TRUE)
static void l2cble_start_conn_update (tL2C_LCB *p_lcb);
@@ -416,7 +417,7 @@
p_lcb->peer_chnl_mask[0] = L2CAP_FIXED_CHNL_ATT_BIT | L2CAP_FIXED_CHNL_BLE_SIG_BIT | L2CAP_FIXED_CHNL_SMP_BIT;
- if (!HCI_LE_SLAVE_INIT_FEAT_EXC_SUPPORTED(btm_cb.devcb.local_le_features))
+ if (!HCI_LE_SLAVE_INIT_FEAT_EXC_SUPPORTED(controller_get_interface()->get_features_ble()->as_array))
{
p_lcb->link_state = LST_CONNECTED;
l2cu_process_fixed_chnl_resp (p_lcb);
@@ -488,7 +489,7 @@
/* if both side 4.1, or we are master device, send HCI command */
if (p_lcb->link_role == HCI_ROLE_MASTER
#if (defined BLE_LLT_INCLUDED) && (BLE_LLT_INCLUDED == TRUE)
- || (HCI_LE_CONN_PARAM_REQ_SUPPORTED(btm_cb.devcb.local_le_features) &&
+ || (HCI_LE_CONN_PARAM_REQ_SUPPORTED(controller_get_interface()->get_features_ble()->as_array) &&
HCI_LE_CONN_PARAM_REQ_SUPPORTED(p_acl_cb->peer_le_features))
#endif
)
@@ -513,7 +514,7 @@
/* if both side 4.1, or we are master device, send HCI command */
if (p_lcb->link_role == HCI_ROLE_MASTER
#if (defined BLE_LLT_INCLUDED) && (BLE_LLT_INCLUDED == TRUE)
- || (HCI_LE_CONN_PARAM_REQ_SUPPORTED(btm_cb.devcb.local_le_features) &&
+ || (HCI_LE_CONN_PARAM_REQ_SUPPORTED(controller_get_interface()->get_features_ble()->as_array) &&
HCI_LE_CONN_PARAM_REQ_SUPPORTED(p_acl_cb->peer_le_features))
#endif
)
diff --git a/stack/l2cap/l2c_link.c b/stack/l2cap/l2c_link.c
index 70f9b16..ad47921 100644
--- a/stack/l2cap/l2c_link.c
+++ b/stack/l2cap/l2c_link.c
@@ -28,6 +28,7 @@
#include <string.h>
#include <stdio.h>
+#include "controller.h"
#include "gki.h"
#include "bt_types.h"
#include "bt_utils.h"
@@ -1257,11 +1258,12 @@
{
UINT16 num_segs;
UINT16 xmit_window, acl_data_size;
+ const controller_t *controller = controller_get_interface();
- if ((p_buf->len <= btu_cb.hcit_acl_pkt_size
+ if ((p_buf->len <= controller->get_acl_packet_size_classic()
#if (BLE_INCLUDED == TRUE)
&& (p_lcb->transport == BT_TRANSPORT_BR_EDR)) ||
- ((p_lcb->transport == BT_TRANSPORT_LE) && (p_buf->len <= btu_cb.hcit_ble_acl_pkt_size))
+ ((p_lcb->transport == BT_TRANSPORT_LE) && (p_buf->len <= controller->get_acl_packet_size_ble()))
#else
)
#endif
@@ -1297,14 +1299,14 @@
#if BLE_INCLUDED == TRUE
if (p_lcb->transport == BT_TRANSPORT_LE)
{
- acl_data_size = btu_cb.hcit_ble_acl_data_size;
+ acl_data_size = controller->get_acl_data_size_ble();
xmit_window = l2cb.controller_le_xmit_window;
}
else
#endif
{
- acl_data_size = btu_cb.hcit_acl_data_size;
+ acl_data_size = controller->get_acl_data_size_classic();
xmit_window = l2cb.controller_xmit_window;
}
num_segs = (p_buf->len - HCI_DATA_PREAMBLE_SIZE + acl_data_size - 1) / acl_data_size;
diff --git a/stack/l2cap/l2c_main.c b/stack/l2cap/l2c_main.c
index 6324c11..4ca28eb 100755
--- a/stack/l2cap/l2c_main.c
+++ b/stack/l2cap/l2c_main.c
@@ -27,6 +27,7 @@
#include <string.h>
#include <stdio.h>
+#include "controller.h"
#include "gki.h"
#include "hcimsgs.h"
#include "l2cdefs.h"
@@ -82,10 +83,11 @@
/* First, the HCI transport header */
UINT16_TO_STREAM (p, 0x0050 | (L2CAP_PKT_START << 12) | (2 << 14));
+ uint16_t acl_data_size = controller_get_interface()->get_acl_data_size_classic();
/* The HCI transport will segment the buffers. */
- if (p_buf->len > btu_cb.hcit_acl_data_size)
+ if (p_buf->len > acl_data_size)
{
- UINT16_TO_STREAM (p, btu_cb.hcit_acl_data_size);
+ UINT16_TO_STREAM (p, acl_data_size);
}
else
{
@@ -99,7 +101,7 @@
p_buf->len += HCI_DATA_PREAMBLE_SIZE;
- if (p_buf->len <= btu_cb.hcit_acl_pkt_size)
+ if (p_buf->len <= controller_get_interface()->get_acl_packet_size_classic())
{
bte_main_hci_send(p_buf, BT_EVT_TO_LM_HCI_ACL);
}
diff --git a/stack/l2cap/l2c_utils.c b/stack/l2cap/l2c_utils.c
index 0429efa..0dc2f8b 100644
--- a/stack/l2cap/l2c_utils.c
+++ b/stack/l2cap/l2c_utils.c
@@ -26,6 +26,7 @@
#include <string.h>
#include <stdio.h>
+#include "controller.h"
#include "gki.h"
#include "bt_types.h"
#include "hcimsgs.h"
@@ -1054,9 +1055,11 @@
return;
}
+ uint16_t acl_data_size = controller_get_interface()->get_acl_data_size_classic();
+ uint16_t acl_packet_size = controller_get_interface()->get_acl_packet_size_classic();
/* Don't return data if it does not fit in ACL and L2CAP MTU */
- maxlen = (GKI_get_pool_bufsize(L2CAP_CMD_POOL_ID) > btu_cb.hcit_acl_pkt_size) ?
- btu_cb.hcit_acl_data_size : (UINT16)GKI_get_pool_bufsize(L2CAP_CMD_POOL_ID);
+ maxlen = (GKI_get_pool_bufsize(L2CAP_CMD_POOL_ID) > acl_packet_size) ?
+ acl_data_size : (UINT16)GKI_get_pool_bufsize(L2CAP_CMD_POOL_ID);
maxlen -= (UINT16)(BT_HDR_SIZE + HCI_DATA_PREAMBLE_SIZE + L2CAP_PKT_OVERHEAD +
L2CAP_CMD_OVERHEAD + L2CAP_ECHO_RSP_LEN);
@@ -2233,7 +2236,7 @@
if (transport == BT_TRANSPORT_LE)
{
- if (!HCI_LE_HOST_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_1]))
+ if (!controller_get_interface()->supports_ble())
return FALSE;
p_lcb->ble_addr_type = addr_type;
@@ -3362,10 +3365,11 @@
{
UINT16_TO_STREAM (p, p_ccb->p_lcb->handle | (L2CAP_PKT_START_NON_FLUSHABLE << L2CAP_PKT_TYPE_SHIFT));
+ uint16_t acl_data_size = controller_get_interface()->get_acl_data_size_ble();
/* The HCI transport will segment the buffers. */
- if (p_buf->len > btu_cb.hcit_ble_acl_data_size)
+ if (p_buf->len > acl_data_size)
{
- UINT16_TO_STREAM (p, btu_cb.hcit_ble_acl_data_size);
+ UINT16_TO_STREAM (p, acl_data_size);
}
else
{
@@ -3389,10 +3393,11 @@
UINT16_TO_STREAM (p, p_ccb->p_lcb->handle | (L2CAP_PKT_START << L2CAP_PKT_TYPE_SHIFT));
#endif
+ uint16_t acl_data_size = controller_get_interface()->get_acl_data_size_classic();
/* The HCI transport will segment the buffers. */
- if (p_buf->len > btu_cb.hcit_acl_data_size)
+ if (p_buf->len > acl_data_size)
{
- UINT16_TO_STREAM (p, btu_cb.hcit_acl_data_size);
+ UINT16_TO_STREAM (p, acl_data_size);
}
else
{