Diff between e96a7fdd697bcba9046fd1afab75fd411c5cbf0d and 6c039398fee20165bce0e453a28d49800ff7522c

Changed Files

File Additions Deletions Status
src/btd.h +1 -0 modified
src/device.c +4 -0 modified
src/main.c +3 -0 modified
src/main.conf +6 -1 modified

Full Patch

diff --git a/src/btd.h b/src/btd.h
index 7166e21..8c80059 100644
--- a/src/btd.h
+++ b/src/btd.h
@@ -140,6 +140,7 @@ struct btd_opts {
 	bt_gatt_cache_t gatt_cache;
 	uint16_t	gatt_mtu;
 	uint8_t		gatt_channels;
+	bool		gatt_client;
 	enum mps_mode_t	mps;
 
 	struct btd_avdtp_opts avdtp;
diff --git a/src/device.c b/src/device.c
index b5b5742..5e74633 100644
--- a/src/device.c
+++ b/src/device.c
@@ -5513,6 +5513,10 @@ static void gatt_client_init(struct btd_device *device)
 		DBG("Reverse service discovery disabled: skipping GATT client");
 		return;
 	}
+	if (!device->connect && !btd_opts.gatt_client) {
+		DBG("GATT client disabled: skipping GATT client");
+		return;
+	}
 
 	device->client = bt_gatt_client_new(device->db, device->att,
 							device->att_mtu, 0);
diff --git a/src/main.c b/src/main.c
index b1339c2..f774670 100644
--- a/src/main.c
+++ b/src/main.c
@@ -145,6 +145,7 @@ static const char *gatt_options[] = {
 	"KeySize",
 	"ExchangeMTU",
 	"Channels",
+	"Client",
 	NULL
 };
 
@@ -1058,6 +1059,7 @@ static void parse_gatt(GKeyFile *config)
 				BT_ATT_DEFAULT_LE_MTU, BT_ATT_MAX_LE_MTU);
 	parse_config_u8(config, "GATT", "Channels", &btd_opts.gatt_channels,
 				1, 5);
+	parse_config_bool(config, "GATT", "Client", &btd_opts.gatt_client);
 }
 
 static void parse_csis_sirk(GKeyFile *config)
@@ -1190,6 +1192,7 @@ static void init_defaults(void)
 	btd_opts.gatt_cache = BT_GATT_CACHE_ALWAYS;
 	btd_opts.gatt_mtu = BT_ATT_MAX_LE_MTU;
 	btd_opts.gatt_channels = 1;
+	btd_opts.gatt_client = true;
 
 	btd_opts.avdtp.session_mode = BT_IO_MODE_BASIC;
 	btd_opts.avdtp.stream_mode = BT_IO_MODE_BASIC;
diff --git a/src/main.conf b/src/main.conf
index 085c81a..815f1c0 100644
--- a/src/main.conf
+++ b/src/main.conf
@@ -33,7 +33,7 @@
 # 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.
+# can only operate as peripheral (see also GATT Client option).
 # Defaults to 'true'.
 #ReverseServiceDiscovery = true
 
@@ -283,6 +283,11 @@
 # Defaults to 0
 #Rank = 0
 
+# This enables the GATT client functionally, so it can be disabled in system
+# which can only operate as a peripheral.
+# Defaults to 'true'.
+#Client = true
+
 [AVDTP]
 # AVDTP L2CAP Signalling Channel Mode.
 # Possible values: