summaryrefslogtreecommitdiffstats
path: root/btif
diff options
context:
space:
mode:
authorzzy <zhenye@broadcom.com>2012-05-21 11:08:53 -0700
committerMatthew Xie <mattx@google.com>2012-07-14 11:19:21 -0700
commit2672151d36df40cd06b4fbed26d1ee8c7e85c72f (patch)
treebea4cec1fed4e27569f6b29d3a8cf60fccc584aa /btif
parentc31ac09a04a4aa3319e0cff85b92f5b2a92b16c9 (diff)
downloadexternal_bluetooth_bluedroid-2672151d36df40cd06b4fbed26d1ee8c7e85c72f.zip
external_bluetooth_bluedroid-2672151d36df40cd06b4fbed26d1ee8c7e85c72f.tar.gz
external_bluetooth_bluedroid-2672151d36df40cd06b4fbed26d1ee8c7e85c72f.tar.bz2
disable pan nap for wingray and misc fixes
Diffstat (limited to 'btif')
-rw-r--r--btif/co/bta_pan_co.c7
-rw-r--r--btif/include/btif_pan_internal.h2
-rw-r--r--btif/src/btif_pan.c83
3 files changed, 53 insertions, 39 deletions
diff --git a/btif/co/bta_pan_co.c b/btif/co/bta_pan_co.c
index ec6d44e..1b6da4f 100644
--- a/btif/co/bta_pan_co.c
+++ b/btif/co/bta_pan_co.c
@@ -175,8 +175,11 @@ void bta_pan_co_close(UINT16 handle, UINT8 app_id)
if(btpan_cb.open_count == 0)
{
destroy_tap_read_thread();
- btpan_tap_close(btpan_cb.tap_fd);
- btpan_cb.tap_fd = -1;
+ if(btpan_cb.tap_fd != -1)
+ {
+ btpan_tap_close(btpan_cb.tap_fd);
+ btpan_cb.tap_fd = -1;
+ }
}
}
}
diff --git a/btif/include/btif_pan_internal.h b/btif/include/btif_pan_internal.h
index f4883bf..fdd9da3 100644
--- a/btif/include/btif_pan_internal.h
+++ b/btif/include/btif_pan_internal.h
@@ -65,7 +65,7 @@
#define TAP_IF_NAME "bt-pan"
#define ETH_ADDR_LEN 6
#ifndef PAN_SECURITY
-#define PAN_SECURITY BTM_SEC_NONE//(PAN_SEC_AUTHORIZE | PAN_SEC_AUTHENTICATE)// | PAN_SEC_ENCRYPT)
+#define PAN_SECURITY (BTM_SEC_IN_AUTHENTICATE | BTM_SEC_OUT_AUTHENTICATE | BTM_SEC_IN_ENCRYPT | BTM_SEC_OUT_ENCRYPT)
#endif
#define PAN_STATE_UNKNOWN 0
diff --git a/btif/src/btif_pan.c b/btif/src/btif_pan.c
index 76faf27..4a1f000 100644
--- a/btif/src/btif_pan.c
+++ b/btif/src/btif_pan.c
@@ -86,6 +86,18 @@
#include "btif_sock_util.h"
#include "btif_pan_internal.h"
+//#define PANU_DISABLED TRUE
+
+#if (PAN_NAP_DISABLED == TRUE) && (PANU_DISABLED == TRUE)
+#define BTPAN_LOCAL_ROLE BTPAN_ROLE_NONE
+#elif PAN_NAP_DISABLED == TRUE
+#define BTPAN_LOCAL_ROLE BTPAN_ROLE_PANU
+#elif PANU_DISABLED == TRUE
+#define BTPAN_LOCAL_ROLE BTPAN_ROLE_PANNAP
+#else
+#define BTPAN_LOCAL_ROLE (BTPAN_ROLE_PANU | BTPAN_ROLE_PANNAP)
+#endif
+
#include <cutils/log.h>
@@ -100,9 +112,9 @@
btpan_cb_t btpan_cb;
BD_ADDR local_addr;
-static int btpan_initialized;
-static bt_status_t btpan_init(const btpan_callbacks_t* callbacks);
-static void btpan_cleanup();
+static int jni_initialized, stack_initialized;
+static bt_status_t btpan_jni_init(const btpan_callbacks_t* callbacks);
+static void btpan_jni_cleanup();
static bt_status_t btpan_connect(const bt_bdaddr_t *bd_addr, int local_role, int remote_role);
static bt_status_t btpan_disconnect(const bt_bdaddr_t *bd_addr);
static bt_status_t btpan_enable(int local_role);
@@ -115,19 +127,19 @@ static void bta_pan_callback(tBTA_PAN_EVT event, tBTA_PAN *p_data);
**
** Function btpan_ini
**
- ** Description initializes the bt socket interface
+ ** Description initializes the pan interface
**
** Returns bt_status_t
**
*******************************************************************************/
static btpan_interface_t pan_if = {
sizeof(pan_if),
- btpan_init,
+ btpan_jni_init,
btpan_enable,
btpan_get_local_role,
btpan_connect,
btpan_disconnect,
- btpan_cleanup
+ btpan_jni_cleanup
};
btpan_interface_t *btif_pan_get_interface()
{
@@ -135,8 +147,9 @@ btpan_interface_t *btif_pan_get_interface()
}
void btif_pan_init()
{
- debug("btpan_initialized = %d, btpan_cb.enabled:%d", btpan_initialized, btpan_cb.enabled);
- if (btpan_initialized && !btpan_cb.enabled)
+ debug("jni_initialized = %d, btpan_cb.enabled:%d", jni_initialized, btpan_cb.enabled);
+ stack_initialized = TRUE;
+ if (jni_initialized && !btpan_cb.enabled)
{
debug("Enabling PAN....");
memset(&btpan_cb, 0, sizeof(btpan_cb));
@@ -146,56 +159,54 @@ void btif_pan_init()
btpan_cleanup_conn(&btpan_cb.conns[i]);
BTA_PanEnable(bta_pan_callback);
btpan_cb.enabled = 1;
- btpan_enable(BTPAN_ROLE_PANU | BTPAN_ROLE_PANNAP);
+ btpan_enable(BTPAN_LOCAL_ROLE);
}
debug("leaving");
}
-
+static void pan_disable()
+{
+ if(btpan_cb.enabled)
+ {
+ btpan_cb.enabled = 0;
+ BTA_PanDisable();
+ if(btpan_cb.tap_fd != -1)
+ {
+ destroy_tap_read_thread();
+ btpan_tap_close(btpan_cb.tap_fd);
+ btpan_cb.tap_fd = -1;
+ }
+ }
+}
void btif_pan_cleanup()
{
- debug("btpan_initialized = %d, btpan_cb.enabled:%d", btpan_initialized, btpan_cb.enabled);
- if (btpan_initialized)
+ if(stack_initialized)
{
//bt is shuting down, invalid all bta pan handles
int i;
for(i = 0; i < MAX_PAN_CONNS; i++)
- {
btpan_cleanup_conn(&btpan_cb.conns[i]);
- }
- btpan_cleanup();
+ pan_disable();
debug("leaving");
}
+ stack_initialized = FALSE;
}
static btpan_callbacks_t callback;
-static bt_status_t btpan_init(const btpan_callbacks_t* callbacks)
+static bt_status_t btpan_jni_init(const btpan_callbacks_t* callbacks)
{
- btpan_initialized=1;
- debug("btpan_initialized = %d, btpan_cb.enabled:%d", btpan_initialized, btpan_cb.enabled);
- static volatile int binit;
+ debug("stack_initialized = %d, btpan_cb.enabled:%d", stack_initialized, btpan_cb.enabled);
+ jni_initialized = TRUE;
+ if(stack_initialized && !btpan_cb.enabled)
+ btif_pan_init();
callback = *callbacks;
debug(" leaving");
return BT_STATUS_SUCCESS;
}
-static void btpan_cleanup()
+static void btpan_jni_cleanup()
{
- debug("btpan_initialized =%d, btpan_cb.enabled:%d", btpan_initialized, btpan_cb.enabled);
- if (btpan_cb.enabled)
- {
- btpan_cb.enabled = 0;
- BTA_PanDisable();
- if(btpan_cb.tap_fd != -1)
- {
- destroy_tap_read_thread();
- btpan_tap_close(btpan_cb.tap_fd);
- btpan_cb.tap_fd = -1;
- }
- }
- if (btpan_initialized)
- {
- btpan_initialized=0;
- }
+ pan_disable();
+ jni_initialized = FALSE;
debug("leaving");
}
static inline int bta_role_to_btpan(int bta_pan_role)