--- src/device.c | 2 +- src/hcid.h | 1 + src/main.c | 22 +++++++++++++++++++--- src/main.conf | 9 +++++++-- 4 files changed, 28 insertions(+), 6 deletions(-) diff --git a/src/device.c b/src/device.c index 4f1af7012..839223a35 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_default_le_mtu); attrib = g_attrib_new(io, cid == ATT_CID ? BT_ATT_DEFAULT_LE_MTU : dev->att_mtu, false); diff --git a/src/hcid.h b/src/hcid.h index 2c2b89d9c..780cec0b4 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_default_le_mtu; uint8_t min_enc_key_size; }; diff --git a/src/main.c b/src/main.c index 7e6af42cd..81a880da9 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" @@ -103,7 +104,8 @@ static const char *policy_options[] = { static const char *gatt_options[] = { "Cache", - "MinEncKeySize", + "MinEncryptionKeySize", + "DefaultLeMtu", NULL }; @@ -409,16 +411,28 @@ static void parse_config(GKeyFile *config) } val = g_key_file_get_integer(config, "GATT", - "MinEncKeySize", &err); + "MinEncryptionKeySize", &err); if (err) { DBG("%s", err->message); g_clear_error(&err); } else { - DBG("MinEncKeySize=%d", val); + DBG("MinEncryptionKeySize=%d", val); if (val >=7 && val <= 16) main_opts.min_enc_key_size = val; } + + val = g_key_file_get_integer(config, "GATT", + "DefaultLeMtu", &err); + if (err) { + 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("gatt_default_le_mtu=%d", val); + main_opts.gatt_default_le_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_default_le_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..4b0ae757b 100644 --- a/src/main.conf +++ b/src/main.conf @@ -63,7 +63,7 @@ # Possible values: "off", "device", "network" # "network" option not supported currently # Defaults to "off" -# Privacy = off +#Privacy = off [GATT] # GATT attribute cache. @@ -80,7 +80,12 @@ # Minimum required Encryption Key Size for accessing secured characteristics. # Possible values: 0 and 7-16. 0 means don't care. # Defaults to 0 -# MinEncKeySize = 0 +#MinEncryptionKeySize = 0 + +# Default LE MTU size. +# Possible values: 23-517 +# Defaults to 517 +#DefaultLeMtu = 517 [Policy] # -- 2.18.0 -- 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