Skip to contentSkip to conversation

Adding start_discovery functionality to hciops plugin.

PATCH New [email protected] 1 participant 1 message May 21, 2009 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Adding start_discovery functionality to hciops plugin.

From: Alok Barsode <[email protected]>

Adding adapter_discovery_begin and adapter_discovery_result callback functions.

---
 plugins/hciops.c |   56 ++++++++++++++
 src/adapter.c    |  211 +++++++++++++++++++++++++++++-------------------------
 src/adapter.h    |    5 +-
 src/dbus-hci.c   |  161 -----------------------------------------
 src/security.c   |   60 ++++++++++++---
 5 files changed, 222 insertions(+), 271 deletions(-)
plugins/hciops.c +56 -0
index 8f9ee06..c4c084e 100644
@@ -561,6 +561,61 @@ done:
 	return err;
 }
 
+static int hciops_start_discovery(int index)
+{
+	struct btd_adapter *adapter;
+	inquiry_cp inq_cp;
+	periodic_inquiry_cp cp;
+	uint8_t lap[3] = { 0x33, 0x8b, 0x9e };
+	int dd, err = 0;
+
+	dd = hci_open_dev(index);
+	if (dd < 0)
+		return dd;
+
+	if (main_opts.discov_interval)
+		goto standard;
+
+	memset(&cp, 0, sizeof(cp));
+	memcpy(&cp.lap, lap, 3);
+	cp.max_period = htobs(24);
+	cp.min_period = htobs(16);
+	cp.length  = 0x08;
+	cp.num_rsp = 0x00;
+
+	err = hci_send_cmd(dd, OGF_LINK_CTL, OCF_PERIODIC_INQUIRY,
+					PERIODIC_INQUIRY_CP_SIZE, &cp);
+
+	goto done;
+
+standard:
+
+	adapter = manager_find_adapter_by_id(index);
+	if (!adapter) {
+		error("Unable to find matching adapter");
+		hci_close_dev(dd);
+		return -EINVAL;
+	}
+
+	pending_remote_name_cancel(adapter);
+
+	memset(&inq_cp, 0, sizeof(inq_cp));
+	memcpy(&inq_cp.lap, lap, 3);
+	inq_cp.length = 0x08;
+	inq_cp.num_rsp = 0x00;
+
+	err = hci_send_cmd(dd, OGF_LINK_CTL, OCF_INQUIRY,
+					INQUIRY_CP_SIZE, &inq_cp);
+
+done:
+	if (err < 0)
+		err = -errno;
+
+	hci_close_dev(dd);
+
+	return err;
+}
+
 static struct btd_adapter_ops hci_ops = {
 	.setup = hciops_setup,
 	.cleanup = hciops_cleanup,
@@ -570,6 +625,7 @@ static struct btd_adapter_ops hci_ops = {
 	.set_connectable = hciops_connectable,
 	.set_discoverable = hciops_discoverable,
 	.set_limited_discoverable = hciops_set_limited_discoverable,
+	.start_discovery = hciops_start_discovery,
 };
 
 static int hciops_init(void)
src/adapter.c +114 -97

258 lines not on this page · raw message

src/adapter.h +4 -1
index a94edc6..2fc4234 100644
@@ -123,7 +123,9 @@ void adapter_add_connection(struct btd_adapter *adapter,
 				struct btd_device *device, uint16_t handle);
 void adapter_remove_connection(struct btd_adapter *adapter,
 				struct btd_device *device, uint16_t handle);
-gboolean adapter_has_discov_sessions(struct btd_adapter *adapter);
+void adapter_discovery_begin(struct btd_adapter *adapter, gboolean periodic);
+void adapter_discovery_result(struct btd_adapter *adapter, bdaddr_t *peer,
+				uint32_t class, int8_t rssi, uint8_t *data);
 
 struct btd_adapter_driver {
 	const char *name;
@@ -157,6 +159,7 @@ struct btd_adapter_ops {
 	int (*set_discoverable) (int index);
 	int (*set_limited_discoverable) (int index, const uint8_t *cls,
 						gboolean limited);
+	int (*start_discovery) (int index);
 };
 
 int btd_register_adapter_ops(struct btd_adapter_ops *btd_adapter_ops);
src/dbus-hci.c +0 -161

179 lines not on this page · raw message

src/security.c +48 -12

141 lines not on this page · raw message

Signature · 1 line
1.5.6.3