[PATCH 12/16] android/gatt: Extract trigger le connection to new function

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

 



This will be needed in reconnect scenario
---
 android/gatt.c | 41 ++++++++++++++++-------------------------
 1 file changed, 16 insertions(+), 25 deletions(-)

diff --git a/android/gatt.c b/android/gatt.c
index 94a65cb..c614e6a 100644
--- a/android/gatt.c
+++ b/android/gatt.c
@@ -1825,15 +1825,19 @@ static int connect_bredr(struct gatt_device *dev)
 	return 0;
 }
 
-static bool auto_connect(struct gatt_device *dev)
+static bool auto_connect_le(struct gatt_device *dev)
 {
-	bool err;
-
-	err = bt_auto_connect_add(&dev->bdaddr);
-	if (!err)
-		return false;
+	/*  For LE devices use auto connect feature if possible */
+	if (bt_kernel_conn_control())
+		return  bt_auto_connect_add(&dev->bdaddr);
 
-	device_set_state(dev, DEVICE_CONNECT_INIT);
+	/* Trigger discovery if not already started */
+	if (!scanning) {
+		if (!bt_le_discovery_start()) {
+			error("gatt: Could not start scan");
+			return false;
+		}
+	}
 
 	return true;
 }
@@ -1852,24 +1856,11 @@ static bool trigger_connection(struct app_connection *connection)
 								BDADDR_BREDR)
 			return connect_bredr(connection->device) == 0;
 
-		/*
-		 * For LE devices use auto connect feature if possible
-		 * Note: Connection state is handled inside auto_connect() func
-		 */
-		if (bt_kernel_conn_control())
-			return auto_connect(connection->device);
-
-		/* Trigger discovery if not already started */
-		if (!scanning) {
-			if (!bt_le_discovery_start()) {
-				error("gatt: Could not start scan");
-				ret = false;
-				break;
-			}
-		}
-
-		ret = true;
-		device_set_state(connection->device, DEVICE_CONNECT_INIT);
+		/* For LE use auto connect feature */
+		ret = auto_connect_le(connection->device);
+		if (ret)
+			device_set_state(connection->device,
+							DEVICE_CONNECT_INIT);
 		break;
 	case DEVICE_CONNECTED:
 		send_app_connect_notify(connection, GATT_SUCCESS);
-- 
1.8.4

--
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