aboutsummaryrefslogtreecommitdiff
path: root/main/bte_main.cc
diff options
context:
space:
mode:
Diffstat (limited to 'main/bte_main.cc')
-rw-r--r--main/bte_main.cc129
1 files changed, 126 insertions, 3 deletions
diff --git a/main/bte_main.cc b/main/bte_main.cc
index ee484002d..16289769e 100644
--- a/main/bte_main.cc
+++ b/main/bte_main.cc
@@ -27,16 +27,30 @@
#define LOG_TAG "bt_main"
#include <base/logging.h>
+#include <base/threading/thread.h>
+#include <fcntl.h>
+#include <pthread.h>
+#include <signal.h>
+#include <stdlib.h>
+#include <time.h>
+
#include <hardware/bluetooth.h>
#include "bt_common.h"
+#include "bt_hci_bdroid.h"
+#include "bt_utils.h"
+#include "bta_api.h"
#include "btcore/include/module.h"
#include "bte.h"
-#include "btif/include/btif_config.h"
+#include "btif_common.h"
#include "btsnoop.h"
#include "btu.h"
#include "device/include/interop.h"
#include "hci_layer.h"
+#include "hcimsgs.h"
+#include "osi/include/alarm.h"
+#include "osi/include/fixed_queue.h"
+#include "osi/include/future.h"
#include "osi/include/log.h"
#include "osi/include/osi.h"
#include "shim/hci_layer.h"
@@ -44,6 +58,24 @@
#include "stack_config.h"
/*******************************************************************************
+ * Constants & Macros
+ ******************************************************************************/
+
+/* Run-time configuration file for BLE*/
+#ifndef BTE_BLE_STACK_CONF_FILE
+// TODO(armansito): Find a better way than searching by a hardcoded path.
+#if defined(OS_GENERIC)
+#define BTE_BLE_STACK_CONF_FILE "ble_stack.conf"
+#else // !defined(OS_GENERIC)
+#define BTE_BLE_STACK_CONF_FILE "/etc/bluetooth/ble_stack.conf"
+#endif // defined(OS_GENERIC)
+#endif // BT_BLE_STACK_CONF_FILE
+
+/******************************************************************************
+ * Variables
+ *****************************************************************************/
+
+/*******************************************************************************
* Static variables
******************************************************************************/
static const hci_t* hci;
@@ -74,14 +106,105 @@ void post_to_main_message_loop(const base::Location& from_here, BT_HDR* p_msg) {
}
}
-void bte_main_init(void) {
+/******************************************************************************
+ *
+ * Function bte_main_boot_entry
+ *
+ * Description BTE MAIN API - Entry point for BTE chip/stack initialization
+ *
+ * Returns None
+ *
+ *****************************************************************************/
+void bte_main_boot_entry(void) {
+ module_init(get_module(INTEROP_MODULE));
+
hci = hci_layer_get_interface();
if (!hci) {
- LOG_ERROR("%s could not get hci layer interface.", __func__);
+ LOG_ERROR(LOG_TAG, "%s could not get hci layer interface.", __func__);
return;
}
hci->set_data_cb(base::Bind(&post_to_main_message_loop));
+
+ module_init(get_module(STACK_CONFIG_MODULE));
+}
+
+/******************************************************************************
+ *
+ * Function bte_main_cleanup
+ *
+ * Description BTE MAIN API - Cleanup code for BTE chip/stack
+ *
+ * Returns None
+ *
+ *****************************************************************************/
+void bte_main_cleanup() {
+ module_clean_up(get_module(STACK_CONFIG_MODULE));
+
+ module_clean_up(get_module(INTEROP_MODULE));
+}
+
+/******************************************************************************
+ *
+ * Function bte_main_enable
+ *
+ * Description BTE MAIN API - Creates all the BTE tasks. Should be called
+ * part of the Bluetooth stack enable sequence
+ *
+ * Returns None
+ *
+ *****************************************************************************/
+void bte_main_enable() {
+ APPL_TRACE_DEBUG("%s", __func__);
+
+ if (bluetooth::shim::is_gd_shim_enabled()) {
+ LOG_INFO(LOG_TAG, "%s Gd shim module enabled", __func__);
+ module_start_up(get_module(GD_SHIM_MODULE));
+ module_start_up(get_module(GD_HCI_MODULE));
+ } else {
+ module_start_up(get_module(BTSNOOP_MODULE));
+ module_start_up(get_module(HCI_MODULE));
+ }
+
+ BTU_StartUp();
+}
+
+/******************************************************************************
+ *
+ * Function bte_main_disable
+ *
+ * Description BTE MAIN API - Destroys all the BTE tasks. Should be called
+ * part of the Bluetooth stack disable sequence
+ *
+ * Returns None
+ *
+ *****************************************************************************/
+void bte_main_disable(void) {
+ APPL_TRACE_DEBUG("%s", __func__);
+
+ if (bluetooth::shim::is_gd_shim_enabled()) {
+ LOG_INFO(LOG_TAG, "%s Gd shim module enabled", __func__);
+ module_shut_down(get_module(GD_HCI_MODULE));
+ module_shut_down(get_module(GD_SHIM_MODULE));
+ } else {
+ module_shut_down(get_module(HCI_MODULE));
+ module_shut_down(get_module(BTSNOOP_MODULE));
+ }
+
+ BTU_ShutDown();
+}
+
+/******************************************************************************
+ *
+ * Function bte_main_postload_cfg
+ *
+ * Description BTE MAIN API - Stack postload configuration
+ *
+ * Returns None
+ *
+ *****************************************************************************/
+void bte_main_postload_cfg(void) {
+ // TODO(eisenbach): [HIDL] DEPRECATE?
}
/******************************************************************************