diff options
author | Kausik Sinnaswamy <kausik@broadcom.com> | 2012-04-10 13:45:26 +0530 |
---|---|---|
committer | Matthew Xie <mattx@google.com> | 2012-07-14 11:19:15 -0700 |
commit | a5c380dbe1419e077bf6a3a8a30359ce74958350 (patch) | |
tree | 338b4965a9156d109c10fef4fb19340243bc24d8 /stack | |
parent | 48253de5c3dffcc3884f9c2b349354f9a8acf174 (diff) | |
download | external_bluetooth_bluedroid-a5c380dbe1419e077bf6a3a8a30359ce74958350.zip external_bluetooth_bluedroid-a5c380dbe1419e077bf6a3a8a30359ce74958350.tar.gz external_bluetooth_bluedroid-a5c380dbe1419e077bf6a3a8a30359ce74958350.tar.bz2 |
Added support to ensure that BT_DISCOVERY_STARTED and
BT_DISCOVERY_STOPPED signals are sent only after receiving the
status/complete event from HCI for the start_inquiry/cancel_inquiry APIs
Change-Id: I14da272b3e0596c2062ce617e9dccb788cc80425
Diffstat (limited to 'stack')
-rw-r--r-- | stack/btm/btm_acl.c | 15 | ||||
-rw-r--r-- | stack/btm/btm_inq.c | 24 | ||||
-rw-r--r-- | stack/btm/btm_int.h | 1 | ||||
-rw-r--r-- | stack/btu/btu_hcif.c | 2 | ||||
-rw-r--r-- | stack/include/btm_api.h | 10 |
5 files changed, 45 insertions, 7 deletions
diff --git a/stack/btm/btm_acl.c b/stack/btm/btm_acl.c index aebbfec..4dd229c 100644 --- a/stack/btm/btm_acl.c +++ b/stack/btm/btm_acl.c @@ -443,6 +443,7 @@ void btm_acl_update_busy_level (tBTM_BLI_EVENT event) case BTM_BLI_ACL_UP_EVT: BTM_TRACE_DEBUG0 ("BTM_BLI_ACL_UP_EVT"); btm_cb.num_acl++; + busy_level = (UINT8)btm_cb.num_acl; break; case BTM_BLI_ACL_DOWN_EVT: if (btm_cb.num_acl) @@ -454,28 +455,34 @@ void btm_acl_update_busy_level (tBTM_BLI_EVENT event) { BTM_TRACE_ERROR0 ("BTM_BLI_ACL_DOWN_EVT issued, but num_acl already zero !!!"); } + busy_level = (UINT8)btm_cb.num_acl; break; case BTM_BLI_PAGE_EVT: BTM_TRACE_DEBUG0 ("BTM_BLI_PAGE_EVT"); btm_cb.is_paging = TRUE; + busy_level = BTM_BL_PAGING_STARTED; break; case BTM_BLI_PAGE_DONE_EVT: BTM_TRACE_DEBUG0 ("BTM_BLI_PAGE_DONE_EVT"); btm_cb.is_paging = FALSE; + busy_level = BTM_BL_PAGING_COMPLETE; break; case BTM_BLI_INQ_EVT: BTM_TRACE_DEBUG0 ("BTM_BLI_INQ_EVT"); btm_cb.is_inquiry = TRUE; + busy_level = BTM_BL_INQUIRY_STARTED; + break; + case BTM_BLI_INQ_CANCEL_EVT: + BTM_TRACE_DEBUG0 ("BTM_BLI_INQ_CANCEL_EVT"); + btm_cb.is_inquiry = FALSE; + busy_level = BTM_BL_INQUIRY_CANCELLED; break; case BTM_BLI_INQ_DONE_EVT: BTM_TRACE_DEBUG0 ("BTM_BLI_INQ_DONE_EVT"); btm_cb.is_inquiry = FALSE; + busy_level = BTM_BL_INQUIRY_COMPLETE; break; } - if (btm_cb.is_paging || btm_cb.is_inquiry) - busy_level = 10; - else - busy_level = (UINT8)btm_cb.num_acl; if (busy_level != btm_cb.busy_level) { diff --git a/stack/btm/btm_inq.c b/stack/btm/btm_inq.c index f42cdc1..a67f723 100644 --- a/stack/btm/btm_inq.c +++ b/stack/btm/btm_inq.c @@ -774,7 +774,10 @@ tBTM_STATUS BTM_CancelInquiry(void) } #if (defined(BTM_BUSY_LEVEL_CHANGE_INCLUDED) && BTM_BUSY_LEVEL_CHANGE_INCLUDED == TRUE) - btm_acl_update_busy_level (BTM_BLI_INQ_DONE_EVT); + /* Do not send the BUSY_LEVEL event yet. Wait for the cancel_complete event + * and then send the BUSY_LEVEL event + * btm_acl_update_busy_level (BTM_BLI_INQ_DONE_EVT); + */ #endif p_inq->inq_counter++; @@ -2340,6 +2343,25 @@ void btm_process_inq_complete (UINT8 status, UINT8 mode) /******************************************************************************* ** +** Function btm_process_cancel_complete +** +** Description This function is called when inquiry cancel complete is received +** from the device.This function will also call the btm_process_inq_complete +** This function is needed to differentiate a cancel_cmpl_evt from the +** inq_cmpl_evt +** +** Returns void +** +*******************************************************************************/ +void btm_process_cancel_complete(UINT8 status, UINT8 mode) +{ +#if (defined(BTM_BUSY_LEVEL_CHANGE_INCLUDED) && BTM_BUSY_LEVEL_CHANGE_INCLUDED == TRUE) + btm_acl_update_busy_level (BTM_BLI_INQ_CANCEL_EVT); +#endif + btm_process_inq_complete(status, mode); +} +/******************************************************************************* +** ** Function btm_initiate_rem_name ** ** Description This function looks initiates a remote name request. It is called diff --git a/stack/btm/btm_int.h b/stack/btm/btm_int.h index 644359c..e8fb57b 100644 --- a/stack/btm/btm_int.h +++ b/stack/btm/btm_int.h @@ -634,6 +634,7 @@ enum BTM_BLI_PAGE_EVT, BTM_BLI_PAGE_DONE_EVT, BTM_BLI_INQ_EVT, + BTM_BLI_INQ_CANCEL_EVT, BTM_BLI_INQ_DONE_EVT }; typedef UINT8 tBTM_BLI_EVENT; diff --git a/stack/btu/btu_hcif.c b/stack/btu/btu_hcif.c index 26b0b8f..2b3c418 100644 --- a/stack/btu/btu_hcif.c +++ b/stack/btu/btu_hcif.c @@ -982,7 +982,7 @@ static void btu_hcif_hdl_command_complete (UINT16 opcode, UINT8 *p, UINT16 evt_l case HCI_INQUIRY_CANCEL: /* Tell inquiry processing that we are done */ - btm_process_inq_complete(HCI_SUCCESS, BTM_BR_INQUIRY_MASK); + btm_process_cancel_complete(HCI_SUCCESS, BTM_BR_INQUIRY_MASK); break; case HCI_SET_EVENT_FILTER: btm_event_filter_complete (p); diff --git a/stack/include/btm_api.h b/stack/include/btm_api.h index 20ae90c..e27fcb1 100644 --- a/stack/include/btm_api.h +++ b/stack/include/btm_api.h @@ -807,11 +807,19 @@ typedef struct BD_ADDR_PTR p_bda; /* The address of the disconnected device */ } tBTM_BL_DISCN_DATA; +/* Busy-Level shall have the inquiry_paging mask set when + * inquiry/paging is in progress, Else the number of ACL links */ +#define BTM_BL_INQUIRY_PAGING_MASK 0x10 +#define BTM_BL_INQUIRY_STARTED (BTM_BL_INQUIRY_PAGING_MASK | 0x1) +#define BTM_BL_INQUIRY_CANCELLED (BTM_BL_INQUIRY_PAGING_MASK | 0x2) +#define BTM_BL_INQUIRY_COMPLETE (BTM_BL_INQUIRY_PAGING_MASK | 0x3) +#define BTM_BL_PAGING_STARTED (BTM_BL_INQUIRY_PAGING_MASK | 0x4) +#define BTM_BL_PAGING_COMPLETE (BTM_BL_INQUIRY_PAGING_MASK | 0x5) /* the data type associated with BTM_BL_UPDATE_EVT */ typedef struct { tBTM_BL_EVENT event; /* The event reported. */ - UINT8 busy_level;/* when paging or inquiring, level is 10. + UINT8 busy_level;/* when paging or inquiring, level is as above. * Otherwise, the number of ACL links. */ } tBTM_BL_UPDATE_DATA; |