diff options
author | Kausik Sinnaswamy <kausik@broadcom.com> | 2012-06-13 16:26:47 +0530 |
---|---|---|
committer | Matthew Xie <mattx@google.com> | 2012-07-14 11:19:23 -0700 |
commit | 8e469244c3df905f69183098bac204c776936e6b (patch) | |
tree | 8c94067c913c47db0c304c94d9078b2e9c3c07c4 | |
parent | bc95df786e2192ef45500f0ef31a2d057a19f831 (diff) | |
download | external_bluetooth_bluedroid-8e469244c3df905f69183098bac204c776936e6b.zip external_bluetooth_bluedroid-8e469244c3df905f69183098bac204c776936e6b.tar.gz external_bluetooth_bluedroid-8e469244c3df905f69183098bac204c776936e6b.tar.bz2 |
Send PAN disconnecting event on local side disconnect initiation
When the local side initiates disconnection, bluedroid should send
diconnecting event, otherwise the instrumentation tests do not pass.
Change-Id: Ic21a905407814c2117c04044c2799ea17a16d33b
-rw-r--r-- | btif/include/btif_common.h | 6 | ||||
-rw-r--r-- | btif/src/btif_pan.c | 28 |
2 files changed, 33 insertions, 1 deletions
diff --git a/btif/include/btif_common.h b/btif/include/btif_common.h index 6e119c0..8ae52e9 100644 --- a/btif/include/btif_common.h +++ b/btif/include/btif_common.h @@ -84,6 +84,7 @@ #define BTIF_DM 1 #define BTIF_HFP 2 #define BTIF_AV 3 +#define BTIF_PAN 4 extern bt_callbacks_t *bt_hal_cbacks; @@ -138,7 +139,10 @@ enum BTIF_DM_CB_CREATE_BOND, /* Create bond */ BTIF_DM_CB_REMOVE_BOND, /*Remove bond */ BTIF_DM_CB_HID_REMOTE_NAME, /* Remote name callback for HID device */ - BTIF_DM_CB_BOND_STATE_BONDING + BTIF_DM_CB_BOND_STATE_BONDING, + + BTIF_PAN_CB_START = BTIF_SIG_CB_START(BTIF_PAN), + BTIF_PAN_CB_DISCONNECTING, /* PAN Disconnect has been sent to BTA successfully */ }; /* Macro definitions for BD ADDR persistence */ diff --git a/btif/src/btif_pan.c b/btif/src/btif_pan.c index 4a1f000..1aa882b 100644 --- a/btif/src/btif_pan.c +++ b/btif/src/btif_pan.c @@ -268,6 +268,31 @@ static bt_status_t btpan_connect(const bt_bdaddr_t *bd_addr, int local_role, int BTA_PanOpen((UINT8*)bd_addr->address, bta_local_role, bta_remote_role); return BT_STATUS_SUCCESS; } +static void btif_in_pan_generic_evt(UINT16 event, char *p_param) +{ + BTIF_TRACE_EVENT2("%s: event=%d", __FUNCTION__, event); + switch (event) { + case BTIF_PAN_CB_DISCONNECTING: + { + bt_bdaddr_t *bd_addr = (bt_bdaddr_t*)p_param; + btpan_conn_t* conn = btpan_find_conn_addr(bd_addr->address); + int btpan_conn_local_role; + int btpan_remote_role; + asrt(conn != NULL); + if (conn) { + btpan_conn_local_role = bta_role_to_btpan(conn->local_role); + btpan_remote_role = bta_role_to_btpan(conn->remote_role); + callback.connection_state_cb(BTPAN_STATE_DISCONNECTING, BT_STATUS_SUCCESS, + (const bt_bdaddr_t*)conn->peer, btpan_conn_local_role, btpan_remote_role); + } + } break; + default: + { + BTIF_TRACE_WARNING2("%s : Unknown event 0x%x", __FUNCTION__, event); + } + break; + } +} static bt_status_t btpan_disconnect(const bt_bdaddr_t *bd_addr) { debug("in"); @@ -275,6 +300,9 @@ static bt_status_t btpan_disconnect(const bt_bdaddr_t *bd_addr) if(conn && conn->handle >= 0) { BTA_PanClose(conn->handle); + /* Inform the application that the disconnect has been initiated successfully */ + btif_transfer_context(btif_in_pan_generic_evt, BTIF_PAN_CB_DISCONNECTING, + (char *)bd_addr, sizeof(bt_bdaddr_t), NULL); return BT_STATUS_SUCCESS; } return BT_STATUS_FAIL; |