Skip to contentSkip to conversation

main.conf: Make ReverseServiceDiscovery work with LE

PATCH Applied Luiz Augusto von Dentz 1 participant 2 messages May 29, 2019 – Jun 3, 2019 Bluetooth drivers

lore
Share & tools
lore

Luiz Augusto von Dentz

author maintainer
#0 lore raw

PATCH 1/1 main.conf: Make ReverseServiceDiscovery work with LE

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

This makes ReverseServiceDiscovery work properly with LE connection by disabling the GATT client functionality which makes one able to setup a system to operate in peripheral role only mode.

---
 src/device.c  | 9 +++++++--
 src/hcid.h    | 2 +-
 src/main.c    | 4 ++--
 src/main.conf | 8 +++++---
 4 files changed, 15 insertions(+), 8 deletions(-)
src/device.c +7 -2
index 8ddfa28ff..263f60aea 100644
@@ -4933,6 +4933,11 @@ static void gatt_client_init(struct btd_device *device)
 {
 	gatt_client_cleanup(device);
 
+	if (!device->connect && !main_opts.reverse_discovery) {
+		DBG("Reverse service discovery disabled: skipping GATT client");
+		return;
+	}
+
 	device->client = bt_gatt_client_new(device->db, device->att,
 							device->att_mtu);
 	if (!device->client) {
@@ -5814,7 +5819,7 @@ void device_bonding_complete(struct btd_device *device, uint8_t bdaddr_type,
 		bonding_request_free(bonding);
 	} else if (!state->svc_resolved) {
 		if (!device->browse && !device->discov_timer &&
-				main_opts.reverse_sdp) {
+				main_opts.reverse_discovery) {
 			/* If we are not initiators and there is no currently
 			 * active discovery or discovery timer, set discovery
 			 * timer */
@@ -5858,7 +5863,7 @@ unsigned int device_wait_for_svc_complete(struct btd_device *dev,
 
 	dev->svc_callbacks = g_slist_prepend(dev->svc_callbacks, cb);
 
-	if (state->svc_resolved || !main_opts.reverse_sdp)
+	if (state->svc_resolved || !main_opts.reverse_discovery)
 		cb->idle_id = g_idle_add(svc_idle_cb, cb);
 	else if (dev->discov_timer > 0) {
 		g_source_remove(dev->discov_timer);
src/hcid.h +1 -1
index 1eb3c5ac2..adea85ce2 100644
@@ -43,7 +43,7 @@ struct main_opts {
 	uint32_t	discovto;
 	uint8_t		privacy;
 
-	gboolean	reverse_sdp;
+	gboolean	reverse_discovery;
 	gboolean	name_resolv;
 	gboolean	debug_keys;
 	gboolean	fast_conn;
src/main.c +2 -2
index 696728320..1a6ab36a3 100644
@@ -367,7 +367,7 @@ static void parse_config(GKeyFile *config)
 		DBG("%s", err->message);
 		g_clear_error(&err);
 	} else
-		main_opts.reverse_sdp = boolean;
+		main_opts.reverse_discovery = boolean;
 
 	boolean = g_key_file_get_boolean(config, "General",
 						"NameResolving", &err);
@@ -456,7 +456,7 @@ static void init_defaults(void)
 	main_opts.class = 0x000000;
 	main_opts.pairto = DEFAULT_PAIRABLE_TIMEOUT;
 	main_opts.discovto = DEFAULT_DISCOVERABLE_TIMEOUT;
-	main_opts.reverse_sdp = TRUE;
+	main_opts.reverse_discovery = TRUE;
 	main_opts.name_resolv = TRUE;
 	main_opts.debug_keys = FALSE;
 
src/main.conf +5 -3
index b2f843c75..40687a755 100644
@@ -30,9 +30,11 @@
 #DeviceID = bluetooth:1234:5678:abcd
 
 # Do reverse service discovery for previously unknown devices that connect to
-# us. This option is really only needed for qualification since the BITE tester
-# doesn't like us doing reverse SDP for some test cases (though there could in
-# theory be other useful purposes for this too). Defaults to 'true'.
+# us. For BR/EDR this option is really only needed for qualification since the
+# BITE tester doesn't like us doing reverse SDP for some test cases, for LE
+# this disables the GATT client functionally so it can be used in system which
+# can only operate as peripheral.
+# Defaults to 'true'.
 #ReverseServiceDiscovery = true
 
 # Enable name resolving after inquiry. Set it to 'false' if you don't need
Signature · 1 line
2.21.0
author maintainer Applied
#1 lore raw

Hi,

Quoted 102 lines · Luiz Augusto von Dentz

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

This makes ReverseServiceDiscovery work properly with LE connection by disabling the GATT client functionality which makes one able to setup a system to operate in peripheral role only mode.

---
 src/device.c  | 9 +++++++--
 src/hcid.h    | 2 +-
 src/main.c    | 4 ++--
 src/main.conf | 8 +++++---
 4 files changed, 15 insertions(+), 8 deletions(-)
src/device.c +7 -2
index 8ddfa28ff..263f60aea 100644
@@ -4933,6 +4933,11 @@ static void gatt_client_init(struct btd_device *device)
 {
        gatt_client_cleanup(device);
 
+       if (!device->connect && !main_opts.reverse_discovery) {
+               DBG("Reverse service discovery disabled: skipping GATT client");
+               return;
+       }
+
        device->client = bt_gatt_client_new(device->db, device->att,
                                                        device->att_mtu);
        if (!device->client) {
@@ -5814,7 +5819,7 @@ void device_bonding_complete(struct btd_device *device, uint8_t bdaddr_type,
                bonding_request_free(bonding);
        } else if (!state->svc_resolved) {
                if (!device->browse && !device->discov_timer &&
-                               main_opts.reverse_sdp) {
+                               main_opts.reverse_discovery) {
                        /* If we are not initiators and there is no currently
                         * active discovery or discovery timer, set discovery
                         * timer */
@@ -5858,7 +5863,7 @@ unsigned int device_wait_for_svc_complete(struct btd_device *dev,
 
        dev->svc_callbacks = g_slist_prepend(dev->svc_callbacks, cb);
 
-       if (state->svc_resolved || !main_opts.reverse_sdp)
+       if (state->svc_resolved || !main_opts.reverse_discovery)
                cb->idle_id = g_idle_add(svc_idle_cb, cb);
        else if (dev->discov_timer > 0) {
                g_source_remove(dev->discov_timer);
src/hcid.h +1 -1
index 1eb3c5ac2..adea85ce2 100644
@@ -43,7 +43,7 @@ struct main_opts {
        uint32_t        discovto;
        uint8_t         privacy;
 
-       gboolean        reverse_sdp;
+       gboolean        reverse_discovery;
        gboolean        name_resolv;
        gboolean        debug_keys;
        gboolean        fast_conn;
src/main.c +2 -2
index 696728320..1a6ab36a3 100644
@@ -367,7 +367,7 @@ static void parse_config(GKeyFile *config)
                DBG("%s", err->message);
                g_clear_error(&err);
        } else
-               main_opts.reverse_sdp = boolean;
+               main_opts.reverse_discovery = boolean;
 
        boolean = g_key_file_get_boolean(config, "General",
                                                "NameResolving", &err);
@@ -456,7 +456,7 @@ static void init_defaults(void)
        main_opts.class = 0x000000;
        main_opts.pairto = DEFAULT_PAIRABLE_TIMEOUT;
        main_opts.discovto = DEFAULT_DISCOVERABLE_TIMEOUT;
-       main_opts.reverse_sdp = TRUE;
+       main_opts.reverse_discovery = TRUE;
        main_opts.name_resolv = TRUE;
        main_opts.debug_keys = FALSE;
 
src/main.conf +5 -4
index b2f843c75..40687a755 100644
@@ -30,9 +30,11 @@
 #DeviceID = bluetooth:1234:5678:abcd
 
 # Do reverse service discovery for previously unknown devices that connect to
-# us. This option is really only needed for qualification since the BITE tester
-# doesn't like us doing reverse SDP for some test cases (though there could in
-# theory be other useful purposes for this too). Defaults to 'true'.
+# us. For BR/EDR this option is really only needed for qualification since the
+# BITE tester doesn't like us doing reverse SDP for some test cases, for LE
+# this disables the GATT client functionally so it can be used in system which
+# can only operate as peripheral.
+# Defaults to 'true'.
 #ReverseServiceDiscovery = true
 
 # Enable name resolving after inquiry. Set it to 'false' if you don't need
--
Quoted 1 line

2.21.0

Applied.

Signature · 1 line
Luiz Augusto von Dentz