diff options
author | Andre Eisenbach <andre@broadcom.com> | 2013-05-15 04:55:08 -0700 |
---|---|---|
committer | Matthew Xie <mattx@google.com> | 2013-08-14 00:40:44 +0000 |
commit | e1202caae4920139ea0cfed5c51f5f76b2dc8bc4 (patch) | |
tree | 4cf11db521cf31dd8c01effc546329113fb4bf43 /stack | |
parent | f052217962d0c06392eb79687820c9469cd6a75a (diff) | |
download | bluedroid-e1202caae4920139ea0cfed5c51f5f76b2dc8bc4.tar.gz |
LE: Add GATT disable functions
This patch adds required disable functions to the GATT sub-system to
properly unregister with the stack. Without the disable functions in
place, turning Bluetooth off with a GATT device connected may lead to
unexpected behaviour and cause GATT to fail on sub-sequent stack
restarts.
Change-Id: I7cb80e96109e2c09882991298d0487b506f5ffdd
Diffstat (limited to 'stack')
-rw-r--r-- | stack/gatt/gatt_api.c | 5 | ||||
-rw-r--r-- | stack/gatt/gatt_utils.c | 28 |
2 files changed, 26 insertions, 7 deletions
diff --git a/stack/gatt/gatt_api.c b/stack/gatt/gatt_api.c index ef437e1..91eca96 100644 --- a/stack/gatt/gatt_api.c +++ b/stack/gatt/gatt_api.c @@ -1293,6 +1293,9 @@ void GATT_Deregister (tGATT_IF gatt_if) } gatt_deregister_bgdev_list(gatt_if); + /* update the listen mode */ + GATT_Listen(gatt_if, FALSE, NULL); + memset (p_reg, 0, sizeof(tGATT_REG)); } @@ -1564,7 +1567,7 @@ BOOLEAN GATT_GetConnIdIfConnected(tGATT_IF gatt_if, BD_ADDR bd_addr, UINT16 *p_c ** Parameters gatt_if: applicaiton interface ** p_bd_addr: listen for specific address connection, or NULL for ** listen to all device connection. -** start: is a direct conenection or a background auto connection +** start: start or stop listening. ** ** Returns TRUE if advertisement is started; FALSE if adv start failure. ** diff --git a/stack/gatt/gatt_utils.c b/stack/gatt/gatt_utils.c index 5470f4e..5b375b5 100644 --- a/stack/gatt/gatt_utils.c +++ b/stack/gatt/gatt_utils.c @@ -2322,6 +2322,8 @@ BOOLEAN gatt_add_bg_dev_list(tGATT_REG *p_reg, BD_ADDR bd_addr, BOOLEAN is_init p_dev->gatt_if[i] = gatt_if; if (i == 0) ret = BTM_BleUpdateBgConnDev(TRUE, bd_addr); + else + ret = TRUE; break; } } @@ -2342,6 +2344,8 @@ BOOLEAN gatt_add_bg_dev_list(tGATT_REG *p_reg, BD_ADDR bd_addr, BOOLEAN is_init if (i == 0) ret = BTM_BleUpdateAdvWhitelist(TRUE, bd_addr); + else + ret = TRUE; break; } } @@ -2515,26 +2519,38 @@ void gatt_deregister_bgdev_list(tGATT_IF gatt_if) { tGATT_BG_CONN_DEV *p_dev_list = &gatt_cb.bgconn_dev[0]; UINT8 i , j, k; + tGATT_REG *p_reg = gatt_get_regcb(gatt_if); + /* update the BG conn device list */ for (i = 0 ; i <GATT_MAX_BG_CONN_DEV; i ++, p_dev_list ++ ) { if (p_dev_list->in_use) { for (j = 0; j < GATT_MAX_APPS; j ++) { - if (p_dev_list->gatt_if[j] == 0) + if (p_dev_list->gatt_if[j] == 0 && p_dev_list->listen_gif[j] == 0) break; - else if (p_dev_list->gatt_if[j] == gatt_if) + + if (p_dev_list->gatt_if[j] == gatt_if) { for (k = j + 1; k < GATT_MAX_APPS; k ++) p_dev_list->gatt_if[k - 1] = p_dev_list->gatt_if[k]; if (p_dev_list->gatt_if[0] == 0) - { BTM_BleUpdateBgConnDev(FALSE, p_dev_list->remote_bda); - memset(p_dev_list, 0, sizeof(tGATT_BG_CONN_DEV)); - break; - } + } + + if (p_dev_list->listen_gif[j] == gatt_if) + { + p_dev_list->listen_gif[j] = 0; + p_reg->listening --; + + /* move all element behind one forward */ + for (k = j + 1; k < GATT_MAX_APPS; k ++) + p_dev_list->listen_gif[k - 1] = p_dev_list->listen_gif[k]; + + if (p_dev_list->listen_gif[0] == 0) + BTM_BleUpdateAdvWhitelist(FALSE, p_dev_list->remote_bda); } } } |