summaryrefslogtreecommitdiff
path: root/src/gatt-client.c
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2020-03-16 15:16:12 -0700
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2020-03-30 15:23:12 -0700
commit7daf0d60fcd438e638c7663bb2585e9f0065d87b (patch)
tree460bec9faecf33f8521388343dd93f21caabe745 /src/gatt-client.c
parent781cdbe1acbb354e634b5832dd7539a8c467786a (diff)
downloadbluez-7daf0d60fcd438e638c7663bb2585e9f0065d87b.tar.gz
gatt: Enable connecting to EATT channel using Ext-Flowctl mode
This makes use of BT_IO_MODE_EXT_FLOWCTL to connect to EATT channels.
Diffstat (limited to 'src/gatt-client.c')
-rw-r--r--src/gatt-client.c34
1 files changed, 29 insertions, 5 deletions
diff --git a/src/gatt-client.c b/src/gatt-client.c
index 20efb7ae9..a9bfc2802 100644
--- a/src/gatt-client.c
+++ b/src/gatt-client.c
@@ -2182,9 +2182,13 @@ static void eatt_connect(struct btd_gatt_client *client)
ba2str(device_get_address(dev), addr);
- DBG("Connection attempt to: %s", addr);
-
for (i = bt_att_get_channels(att); i < main_opts.gatt_channels; i++) {
+ int defer_timeout = i + 1 < main_opts.gatt_channels ? 1 : 0;
+
+ DBG("Connection attempt to: %s defer %s", addr,
+ defer_timeout ? "true" : "false");
+
+ /* Attempt to connect using the Ext-Flowctl */
io = bt_io_connect(eatt_connect_cb, client, NULL, &gerr,
BT_IO_OPT_SOURCE_BDADDR,
btd_adapter_get_address(adapter),
@@ -2194,15 +2198,35 @@ static void eatt_connect(struct btd_gatt_client *client)
device_get_address(dev),
BT_IO_OPT_DEST_TYPE,
device_get_le_address_type(dev),
+ BT_IO_OPT_MODE, BT_IO_MODE_EXT_FLOWCTL,
BT_IO_OPT_PSM, BT_ATT_EATT_PSM,
BT_IO_OPT_SEC_LEVEL, BT_IO_SEC_LOW,
BT_IO_OPT_MTU, main_opts.gatt_mtu,
+ BT_IO_OPT_DEFER_TIMEOUT, defer_timeout,
BT_IO_OPT_INVALID);
if (!io) {
- error("EATT bt_io_connect(%s): %s", addr,
- gerr->message);
g_error_free(gerr);
- return;
+ gerr = NULL;
+ /* Fallback to legacy LE Mode */
+ io = bt_io_connect(eatt_connect_cb, client, NULL, &gerr,
+ BT_IO_OPT_SOURCE_BDADDR,
+ btd_adapter_get_address(adapter),
+ BT_IO_OPT_SOURCE_TYPE,
+ btd_adapter_get_address_type(adapter),
+ BT_IO_OPT_DEST_BDADDR,
+ device_get_address(dev),
+ BT_IO_OPT_DEST_TYPE,
+ device_get_le_address_type(dev),
+ BT_IO_OPT_PSM, BT_ATT_EATT_PSM,
+ BT_IO_OPT_SEC_LEVEL, BT_IO_SEC_LOW,
+ BT_IO_OPT_MTU, main_opts.gatt_mtu,
+ BT_IO_OPT_INVALID);
+ if (!io) {
+ error("EATT bt_io_connect(%s): %s", addr,
+ gerr->message);
+ g_error_free(gerr);
+ return;
+ }
}
g_io_channel_unref(io);