Skip to contentSkip to conversation

adapter: Fix initializing GATT server for BR/EDR only controllers

PATCH Superseded Luiz Augusto von Dentz 2 participants 2 messages Feb 14, 2018 Bluetooth drivers

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Luiz Augusto von Dentz

author maintainer
#0 lore raw

PATCH 1/1 adapter: Fix initializing GATT server for BR/EDR only controllers

From: Luiz Augusto von Dentz <[email protected]>

Controller that do not support LE bearer shall not use GATT server for anything.

---
 src/adapter.c | 14 ++++++++------
 src/main.conf |  2 +-
 2 files changed, 9 insertions(+), 7 deletions(-)
src/adapter.c +8 -6
index bd5c1e150..8b785dcfd 100644
@@ -7745,6 +7745,12 @@ static int adapter_register(struct btd_adapter *adapter)
 		agent_unref(agent);
 	}
 
+	/* Don't start GATT database and advertising managers on
+	 * non-LE controllers.
+	 */
+	if (!(adapter->supported_settings & MGMT_SETTING_LE))
+		goto load;
+
 	adapter->database = btd_gatt_database_new(adapter);
 	if (!adapter->database) {
 		btd_error(adapter->dev_id,
@@ -7753,18 +7759,14 @@ static int adapter_register(struct btd_adapter *adapter)
 		return -EINVAL;
 	}
 
-	/* Don't start advertising managers on non-LE controllers. */
-	if (adapter->supported_settings & MGMT_SETTING_LE)
-		adapter->adv_manager = btd_adv_manager_new(adapter);
-	else
-		btd_info(adapter->dev_id,
-			"LEAdvertisingManager skipped, LE unavailable");
+	adapter->adv_manager = btd_adv_manager_new(adapter);
 
 	db = btd_gatt_database_get_db(adapter->database);
 	adapter->db_id = gatt_db_register(db, services_modified,
 							services_modified,
 							adapter, NULL);
 
+load:
 	load_config(adapter);
 	fix_storage(adapter);
 	load_drivers(adapter);
src/main.conf +1 -1
index 21986b386..b3f8bb274 100644
@@ -42,7 +42,7 @@
 # Restricts all controllers to the specified transport. Default value
 # is "dual", i.e. both BR/EDR and LE enabled (when supported by the HW).
 # Possible values: "dual", "bredr", "le"
-#ControllerMode = dual
+ControllerMode = bredr
 
 # Enables Multi Profile Specification support. This allows to specify if
 # system supports only Multiple Profiles Single Device (MPSD) configuration
Signature · 1 line
2.14.3
#1 lore raw

Hi Luiz,

Quoted 52 lines · On Wednesday, 14 February 2018 12:41:33 CET Luiz Augusto von Dentz wrote:

From: Luiz Augusto von Dentz <[email protected]>

Controller that do not support LE bearer shall not use GATT server for anything.

---
 src/adapter.c | 14 ++++++++------
 src/main.conf |  2 +-
 2 files changed, 9 insertions(+), 7 deletions(-)
src/adapter.c +8 -6
index bd5c1e150..8b785dcfd 100644
@@ -7745,6 +7745,12 @@ static int adapter_register(struct btd_adapter
 *adapter) agent_unref(agent);
 	}
 
+	/* Don't start GATT database and advertising managers on
+	 * non-LE controllers.
+	 */
+	if (!(adapter->supported_settings & MGMT_SETTING_LE))
+		goto load;
+
 	adapter->database = btd_gatt_database_new(adapter);
 	if (!adapter->database) {
 		btd_error(adapter->dev_id,
@@ -7753,18 +7759,14 @@ static int adapter_register(struct btd_adapter
 *adapter) return -EINVAL;
 	}
 
-	/* Don't start advertising managers on non-LE controllers. */
-	if (adapter->supported_settings & MGMT_SETTING_LE)
-		adapter->adv_manager = btd_adv_manager_new(adapter);
-	else
-		btd_info(adapter->dev_id,
-			"LEAdvertisingManager skipped, LE unavailable");
+	adapter->adv_manager = btd_adv_manager_new(adapter);
 
 	db = btd_gatt_database_get_db(adapter->database);
 	adapter->db_id = gatt_db_register(db, services_modified,
 							services_modified,
 							adapter, NULL);
 
+load:
 	load_config(adapter);
 	fix_storage(adapter);
 	load_drivers(adapter);
src/main.conf +0 -0
index 21986b386..b3f8bb274 100644

src/main.conf line 45

Quoted 5 lines
src/main.conf +1 -1
@@ -42,7 +42,7 @@
 # Restricts all controllers to the specified transport. Default value
 # is "dual", i.e. both BR/EDR and LE enabled (when supported by the HW).
 # Possible values: "dual", "bredr", "le"
-#ControllerMode = dual
+ControllerMode = bredr

I don't think we want to default to that :)

Quoted 3 lines
src/main.conf +0 -0
 # Enables Multi Profile Specification support. This allows to specify if
 # system supports only Multiple Profiles Single Device (MPSD) configuration
Signature · 2 lines
pozdrawiam
Szymon Janc