diff options
author | Szymon Janc <szymon.janc@tieto.com> | 2015-02-07 16:18:14 +0100 |
---|---|---|
committer | Szymon Janc <szymon.janc@tieto.com> | 2015-02-09 13:32:10 +0100 |
commit | 06b2a8134fbdd30c827a770cc97588b772c87e0a (patch) | |
tree | 0017e3bd9f17e276c01b3352a8b289a8e4d19058 /android/gatt.c | |
parent | bf8faa2b4050551e076d085476fb2b99e305317a (diff) | |
download | bluez-06b2a8134fbdd30c827a770cc97588b772c87e0a.tar.gz |
android/gatt: Fix MTU exchange
This fix using invalid MTU on LE link. Previous attempt to fix this
"android/gatt: Fix initial setting of MTU" was not correct since
on LE default MTU is always 23 and we are not allowed to send bigger
requests before MTU exchange was performed.
This was affecting multiple PTS GATT test cases.
Diffstat (limited to 'android/gatt.c')
-rw-r--r-- | android/gatt.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/android/gatt.c b/android/gatt.c index 5f3050fc1..f754f3024 100644 --- a/android/gatt.c +++ b/android/gatt.c @@ -1490,7 +1490,7 @@ static void connect_cb(GIOChannel *io, GError *gerr, gpointer user_data) uint32_t status; GError *err = NULL; GAttrib *attrib; - uint16_t mtu; + uint16_t mtu, cid; if (dev->state != DEVICE_CONNECT_READY) { error("gatt: Device not in a connecting state!?"); @@ -1510,14 +1510,21 @@ static void connect_cb(GIOChannel *io, GError *gerr, gpointer user_data) goto reply; } - if (!bt_io_get(io, &err, BT_IO_OPT_IMTU, &mtu, BT_IO_OPT_INVALID)) { - error("gatt: Could not get imtu: %s", err->message); + if (!bt_io_get(io, &err, BT_IO_OPT_IMTU, &mtu, BT_IO_OPT_CID, &cid, + BT_IO_OPT_INVALID)) { + error("gatt: Could not get imtu or cid: %s", err->message); device_set_state(dev, DEVICE_DISCONNECTED); status = GATT_FAILURE; g_error_free(err); goto reply; } + DBG("mtu %u cid %u", mtu, cid); + + /* on LE we always start with default MTU */ + if (cid == ATT_CID) + mtu = ATT_DEFAULT_LE_MTU; + attrib = g_attrib_new(io, mtu); if (!attrib) { error("gatt: unable to create new GAttrib instance"); |