diff options
author | Michael Janssen <jamuraa@chromium.org> | 2014-10-31 11:14:52 -0700 |
---|---|---|
committer | Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | 2014-11-03 17:16:56 +0200 |
commit | 566488510e0e8216a26e93c3422a36f560c380e1 (patch) | |
tree | 2e986cdd39adc7aad275d5323d4570132b9748b1 /attrib/gatttool.c | |
parent | 49f13e083d1458582c983f768fbc9ff0fe2a14b0 (diff) | |
download | bluez-566488510e0e8216a26e93c3422a36f560c380e1.tar.gz |
attrib: Add mtu argument to g_attrib_new
Instead of using the default MTU, use one passed
in by the user, and detect it from the channel when
it is created.
Diffstat (limited to 'attrib/gatttool.c')
-rw-r--r-- | attrib/gatttool.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/attrib/gatttool.c b/attrib/gatttool.c index db5da6220..b8e0f680d 100644 --- a/attrib/gatttool.c +++ b/attrib/gatttool.c @@ -123,6 +123,9 @@ static gboolean listen_start(gpointer user_data) static void connect_cb(GIOChannel *io, GError *err, gpointer user_data) { GAttrib *attrib; + uint16_t mtu; + uint16_t cid; + GError *gerr = NULL; if (err) { g_printerr("%s\n", err->message); @@ -130,7 +133,20 @@ static void connect_cb(GIOChannel *io, GError *err, gpointer user_data) g_main_loop_quit(event_loop); } - attrib = g_attrib_new(io); + bt_io_get(io, &gerr, BT_IO_OPT_IMTU, &mtu, + BT_IO_OPT_CID, &cid, BT_IO_OPT_INVALID); + + if (gerr) { + g_printerr("Can't detect MTU, using default: %s", + gerr->message); + g_error_free(gerr); + mtu = ATT_DEFAULT_LE_MTU; + } + + if (cid == ATT_CID) + mtu = ATT_DEFAULT_LE_MTU; + + attrib = g_attrib_new(io, mtu); if (opt_listen) g_idle_add(listen_start, attrib); |