summaryrefslogtreecommitdiffstats
path: root/stack/btm
diff options
context:
space:
mode:
authorKausik Sinnaswamy <kausik@broadcom.com>2012-04-10 13:45:26 +0530
committerMatthew Xie <mattx@google.com>2012-07-14 11:19:15 -0700
commita5c380dbe1419e077bf6a3a8a30359ce74958350 (patch)
tree338b4965a9156d109c10fef4fb19340243bc24d8 /stack/btm
parent48253de5c3dffcc3884f9c2b349354f9a8acf174 (diff)
downloadexternal_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/btm')
-rw-r--r--stack/btm/btm_acl.c15
-rw-r--r--stack/btm/btm_inq.c24
-rw-r--r--stack/btm/btm_int.h1
3 files changed, 35 insertions, 5 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;