summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xbtif/src/btif_core.c10
-rw-r--r--hci/src/bt_hci_bdroid.c6
-rw-r--r--hci/src/bt_hw.c17
-rw-r--r--main/bte_main.c9
4 files changed, 31 insertions, 11 deletions
diff --git a/btif/src/btif_core.c b/btif/src/btif_core.c
index 62339a9..19ebae1 100755
--- a/btif/src/btif_core.c
+++ b/btif/src/btif_core.c
@@ -130,7 +130,7 @@ extern void bte_load_did_conf(const char *p_path);
/** TODO: Move these to _common.h */
void bte_main_boot_entry(void);
-void bte_main_enable(uint8_t *local_addr);
+bt_status_t bte_main_enable(uint8_t *local_addr);
void bte_main_disable(void);
void bte_main_shutdown(void);
#if (defined(HCILP_INCLUDED) && HCILP_INCLUDED == TRUE)
@@ -502,6 +502,8 @@ static bt_status_t btif_associate_evt(void)
bt_status_t btif_enable_bluetooth(void)
{
+ bt_status_t status;
+
BTIF_TRACE_DEBUG0("BTIF ENABLE BLUETOOTH");
if (btif_core_state != BTIF_CORE_STATE_DISABLED)
@@ -513,9 +515,11 @@ bt_status_t btif_enable_bluetooth(void)
btif_core_state = BTIF_CORE_STATE_ENABLING;
/* Create the GKI tasks and run them */
- bte_main_enable(btif_local_bd_addr.address);
+ status = bte_main_enable(btif_local_bd_addr.address);
+ if (status != BT_STATUS_SUCCESS)
+ btif_core_state = BTIF_CORE_STATE_DISABLED;
- return BT_STATUS_SUCCESS;
+ return status;
}
diff --git a/hci/src/bt_hci_bdroid.c b/hci/src/bt_hci_bdroid.c
index 46355de..9309198 100644
--- a/hci/src/bt_hci_bdroid.c
+++ b/hci/src/bt_hci_bdroid.c
@@ -59,7 +59,7 @@ void lpm_enable(uint8_t turn_on);
void lpm_wake_deassert(void);
void lpm_allow_bt_device_sleep(void);
void lpm_wake_assert(void);
-void init_vnd_if(unsigned char *local_bdaddr);
+int init_vnd_if(unsigned char *local_bdaddr);
void btsnoop_open(char *p_path);
void btsnoop_close(void);
@@ -129,7 +129,9 @@ static int init(const bt_hc_callbacks_t* p_cb, unsigned char *local_bdaddr)
/* store reference to user callbacks */
bt_hc_cbacks = (bt_hc_callbacks_t *) p_cb;
- init_vnd_if(local_bdaddr);
+ result = init_vnd_if(local_bdaddr);
+ if (result != BT_HC_STATUS_SUCCESS)
+ return result;
utils_init();
#ifdef HCI_USE_MCT
diff --git a/hci/src/bt_hw.c b/hci/src/bt_hw.c
index b2a099f..f2b7b71 100644
--- a/hci/src/bt_hw.c
+++ b/hci/src/bt_hw.c
@@ -184,24 +184,33 @@ static const bt_vendor_callbacks_t vnd_callbacks = {
** Returns None
**
******************************************************************************/
-void init_vnd_if(unsigned char *local_bdaddr)
+int init_vnd_if(unsigned char *local_bdaddr)
{
void *dlhandle;
+ int rc;
dlhandle = dlopen("libbt-vendor.so", RTLD_NOW);
if (!dlhandle)
{
ALOGE("!!! Failed to load libbt-vendor.so !!!");
- return;
+ return BT_HC_STATUS_FAIL;
}
bt_vnd_if = (bt_vendor_interface_t *) dlsym(dlhandle, "BLUETOOTH_VENDOR_LIB_INTERFACE");
if (!bt_vnd_if)
{
ALOGE("!!! Failed to get bt vendor interface !!!");
- return;
+ return BT_HC_STATUS_FAIL;
}
- bt_vnd_if->init(&vnd_callbacks, local_bdaddr);
+ rc = bt_vnd_if->init(&vnd_callbacks, local_bdaddr);
+ if (rc < 0) {
+ dlclose(dlhandle);
+ bt_vnd_if = NULL;
+
+ return BT_HC_STATUS_FAIL;
+ }
+
+ return BT_HC_STATUS_SUCCESS;
}
diff --git a/main/bte_main.c b/main/bte_main.c
index 4e7e37c..de73add 100644
--- a/main/bte_main.c
+++ b/main/bte_main.c
@@ -27,6 +27,8 @@
#include <stdlib.h>
#include <assert.h>
+#include <hardware/bluetooth.h>
+
#include "gki.h"
#include "bd.h"
#include "btu.h"
@@ -159,7 +161,7 @@ void bte_main_shutdown()
** Returns None
**
******************************************************************************/
-void bte_main_enable(uint8_t *local_addr)
+bt_status_t bte_main_enable(uint8_t *local_addr)
{
APPL_TRACE_DEBUG1("%s", __FUNCTION__);
@@ -173,7 +175,8 @@ void bte_main_enable(uint8_t *local_addr)
int result = bt_hc_if->init(&hc_callbacks, local_addr);
APPL_TRACE_EVENT1("libbt-hci init returns %d", result);
- assert(result == BT_HC_STATUS_SUCCESS);
+ if (result != BT_HC_STATUS_SUCCESS)
+ return BT_STATUS_FAIL;
if (hci_logging_enabled == TRUE)
bt_hc_if->logging(BT_HC_LOGGING_ON, hci_logfile);
@@ -206,6 +209,8 @@ void bte_main_enable(uint8_t *local_addr)
sizeof(bte_btu_stack));
GKI_run(0);
+
+ return BT_STATUS_SUCCESS;
}
/******************************************************************************