[PATCH] Handle case where inquiry is active when bluetoothd starts up

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



If inquiry is active when bluetoothd starts up, it will get an error
from the HCI layer when it tries to execute the StartDiscovery dbus
call.  This error in turn will prevent the list of devices which have
been discovered and reported over dbus from being cleared, which will
make many devices undiscoverable.

This patch handles the case where the adapter is in standard inquiry
mode.  It checks for the HCI_INQUIRY status bit at startup, and if set,
issues an inquiry_cancel call.
---
 src/adapter.c  |    9 +++++----
 src/dbus-hci.c |    2 +-
 src/dbus-hci.h |    1 +
 3 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/src/adapter.c b/src/adapter.c
index d984445..614a430 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -2173,10 +2173,11 @@ setup:
 	hci_send_cmd(dd, OGF_LINK_POLICY, OCF_READ_DEFAULT_LINK_POLICY,
 								0, NULL);
 
-	if (hci_test_bit(HCI_INQUIRY, &di.flags))
-		adapter->state |= STD_INQUIRY;
-	else
-		adapter->state &= ~STD_INQUIRY;
+	if (hci_test_bit(HCI_INQUIRY, &di.flags)) {
+		debug("inquiry_cancel at adapter startup");
+		inquiry_cancel(dd, HCI_REQ_TIMEOUT);
+	}
+	adapter->state &= ~STD_INQUIRY;
 
 	adapter_setup(adapter, dd);
 	err = adapter_up(adapter, dd);
diff --git a/src/dbus-hci.c b/src/dbus-hci.c
index cf3e307..870b8f5 100644
--- a/src/dbus-hci.c
+++ b/src/dbus-hci.c
@@ -1314,7 +1314,7 @@ int hcid_dbus_set_io_cap(bdaddr_t *local, bdaddr_t *remote,
 	return 0;
 }
 
-static int inquiry_cancel(int dd, int to)
+int inquiry_cancel(int dd, int to)
 {
 	struct hci_request rq;
 	uint8_t status;
diff --git a/src/dbus-hci.h b/src/dbus-hci.h
index c7e0dca..034cf81 100644
--- a/src/dbus-hci.h
+++ b/src/dbus-hci.h
@@ -58,6 +58,7 @@ int cancel_periodic_discovery(struct btd_adapter *adapter);
 int set_service_classes(int dd, const uint8_t *cls, uint8_t value);
 int set_major_and_minor_class(int dd, const uint8_t *cls,
 						uint8_t major, uint8_t minor);
+int inquiry_cancel(int dd, int to);
 
 const char *class_to_icon(uint32_t class);
 
-- 
1.5.6.5

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux