summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/device.c2
-rw-r--r--src/gatt-database.c2
-rw-r--r--src/hcid.h1
-rw-r--r--src/main.c16
-rw-r--r--src/main.conf5
5 files changed, 25 insertions, 1 deletions
diff --git a/src/device.c b/src/device.c
index 4f1af7012..49c55f02b 100644
--- a/src/device.c
+++ b/src/device.c
@@ -4986,7 +4986,7 @@ bool device_attach_att(struct btd_device *dev, GIOChannel *io)
}
}
- dev->att_mtu = MIN(mtu, BT_ATT_MAX_LE_MTU);
+ dev->att_mtu = MIN(mtu, main_opts.gatt_mtu);
attrib = g_attrib_new(io,
cid == ATT_CID ? BT_ATT_DEFAULT_LE_MTU : dev->att_mtu,
false);
diff --git a/src/gatt-database.c b/src/gatt-database.c
index b96f5daf4..abcf7b759 100644
--- a/src/gatt-database.c
+++ b/src/gatt-database.c
@@ -40,6 +40,7 @@
#include "src/shared/gatt-server.h"
#include "log.h"
#include "error.h"
+#include "hcid.h"
#include "adapter.h"
#include "device.h"
#include "gatt-database.h"
@@ -3274,6 +3275,7 @@ struct btd_gatt_database *btd_gatt_database_new(struct btd_adapter *adapter)
BT_IO_OPT_SOURCE_BDADDR, addr,
BT_IO_OPT_PSM, ATT_PSM,
BT_IO_OPT_SEC_LEVEL, BT_IO_SEC_LOW,
+ BT_IO_OPT_MTU, main_opts.gatt_mtu,
BT_IO_OPT_INVALID);
if (database->l2cap_io == NULL) {
error("Failed to start listening: %s", gerr->message);
diff --git a/src/hcid.h b/src/hcid.h
index 2c2b89d9c..8924e9b4c 100644
--- a/src/hcid.h
+++ b/src/hcid.h
@@ -54,6 +54,7 @@ struct main_opts {
bt_mode_t mode;
bt_gatt_cache_t gatt_cache;
+ uint16_t gatt_mtu;
uint8_t min_enc_key_size;
};
diff --git a/src/main.c b/src/main.c
index 7e6af42cd..e82508241 100644
--- a/src/main.c
+++ b/src/main.c
@@ -50,6 +50,7 @@
#include "log.h"
#include "backtrace.h"
+#include "shared/att-types.h"
#include "lib/uuid.h"
#include "hcid.h"
#include "sdpd.h"
@@ -104,6 +105,7 @@ static const char *policy_options[] = {
static const char *gatt_options[] = {
"Cache",
"MinEncKeySize",
+ "ExchangeMTU",
NULL
};
@@ -419,6 +421,18 @@ static void parse_config(GKeyFile *config)
if (val >=7 && val <= 16)
main_opts.min_enc_key_size = val;
}
+
+ val = g_key_file_get_integer(config, "GATT", "ExchangeMTU", &err);
+ if (err) {
+ DBG("%s", err->message);
+ g_clear_error(&err);
+ } else {
+ /* Ensure the mtu is within a valid range. */
+ val = MIN(val, BT_ATT_MAX_LE_MTU);
+ val = MAX(val, BT_ATT_DEFAULT_LE_MTU);
+ DBG("ExchangeMTU=%d", val);
+ main_opts.gatt_mtu = val;
+ }
}
static void init_defaults(void)
@@ -442,6 +456,8 @@ static void init_defaults(void)
main_opts.did_vendor = 0x1d6b; /* Linux Foundation */
main_opts.did_product = 0x0246; /* BlueZ */
main_opts.did_version = (major << 8 | minor);
+
+ main_opts.gatt_mtu = BT_ATT_MAX_LE_MTU;
}
static void log_handler(const gchar *log_domain, GLogLevelFlags log_level,
diff --git a/src/main.conf b/src/main.conf
index cbae32ec5..a70997669 100644
--- a/src/main.conf
+++ b/src/main.conf
@@ -82,6 +82,11 @@
# Defaults to 0
# MinEncKeySize = 0
+# Exchange MTU size.
+# Possible values: 23-517
+# Defaults to 517
+#ExchangeMTU = 517
+
[Policy]
#
# The ReconnectUUIDs defines the set of remote services that should try