From: Szymon Janc <szymon.janc@tieto.com>
To: Jakub Tyszkowski <jakub.tyszkowski@tieto.com>
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCHv5 1/4] android/gatt: Send Exchange MTU request on connect
Date: Thu, 22 May 2014 16:49:32 +0200 [thread overview]
Message-ID: <3514086.fNq38fX02p@uw000953> (raw)
In-Reply-To: <1400756073-16330-1-git-send-email-jakub.tyszkowski@tieto.com>
Hi Jakub,
On Thursday 22 of May 2014 12:54:30 Jakub Tyszkowski wrote:
> This adds sending exchange MTU request on connection.
>
> This is needed to pass TC_GAC_CL_BV_01_C.
> ---
> android/gatt.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 71 insertions(+)
>
> diff --git a/android/gatt.c b/android/gatt.c
> index 89da60d..82e8dc1 100644
> --- a/android/gatt.c
> +++ b/android/gatt.c
> @@ -979,6 +979,73 @@ static void send_app_connect_notifications(void *data, void *user_data)
>
> static void att_handler(const uint8_t *ipdu, uint16_t len, gpointer user_data);
>
> +static void exchange_mtu_cb(guint8 status, const guint8 *pdu, guint16 plen,
> + gpointer user_data)
> +{
> + struct gatt_device *device = user_data;
> + GIOChannel *io;
> + GError *gerr = NULL;
> + uint16_t rmtu, mtu, imtu;
> +
> + if (status) {
> + error("gatt: MTU exchange: %s", att_ecode2str(status));
> + goto failed;
> + }
> +
> + if (!dec_mtu_resp(pdu, plen, &rmtu)) {
> + error("gatt: MTU exchange: protocol error");
> + goto failed;
> + }
> +
> + if (rmtu < ATT_DEFAULT_LE_MTU) {
> + error("gatt: MTU exchange: mtu error");
> + goto failed;
> + }
> +
> + io = g_attrib_get_channel(device->attrib);
> +
> + bt_io_get(io, &gerr, BT_IO_OPT_IMTU, &imtu, BT_IO_OPT_INVALID);
> + if (gerr) {
> + error("gatt: Could not get imtu: %s", gerr->message);
> + g_error_free(gerr);
> +
> + return;
> + }
> +
> + mtu = MIN(rmtu, imtu);
> + if (mtu != imtu && !g_attrib_set_mtu(device->attrib, mtu)) {
> + error("gatt: MTU exchange failed");
> + goto failed;
> + }
> +
> + DBG("MTU exchange succeeded: rmtu:%d, old mtu:%d, new mtu:%d", rmtu,
> + imtu, mtu);
> +
> +failed:
> + device_unref(device);
> +}
> +
> +static void send_exchange_mtu_request(struct gatt_device *device)
> +{
> + GIOChannel *io;
> + GError *gerr = NULL;
> + uint16_t imtu;
> +
> + io = g_attrib_get_channel(device->attrib);
> +
> + bt_io_get(io, &gerr, BT_IO_OPT_IMTU, &imtu, BT_IO_OPT_INVALID);
> + if (gerr) {
> + error("gatt: Could not get imtu: %s", gerr->message);
> + g_error_free(gerr);
> +
> + return;
> + }
> +
> + if (!gatt_exchange_mtu(device->attrib, imtu, exchange_mtu_cb,
> + device_ref(device)))
> + device_unref(device);
> +}
> +
> static void connect_cb(GIOChannel *io, GError *gerr, gpointer user_data)
> {
> struct gatt_device *dev = user_data;
> @@ -1024,6 +1091,10 @@ static void connect_cb(GIOChannel *io, GError *gerr, gpointer user_data)
>
> device_set_state(dev, DEVICE_CONNECTED);
>
> + /* Send exchange mtu request as we assume being client and server */
> + /* TODO: Dont exchange mtu if no client apps */
> + send_exchange_mtu_request(dev);
> +
> status = GATT_SUCCESS;
>
> reply:
Patch 1/4 is now applied but rest need rebase. Thanks.
--
Best regards,
Szymon Janc
prev parent reply other threads:[~2014-05-22 14:49 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-22 10:54 [PATCHv5 1/4] android/gatt: Send Exchange MTU request on connect Jakub Tyszkowski
2014-05-22 10:54 ` [PATCHv5 2/4] android/gatt: Use g_attrib buffer where possible for att Jakub Tyszkowski
2014-05-22 10:54 ` [PATCHv5 3/4] android/gatt: Make att_handler use g_attrib buffer Jakub Tyszkowski
2014-05-22 10:54 ` [PATCHv5 4/4] android/gatt: Use default mtu on mtu exchange response Jakub Tyszkowski
2014-05-22 14:49 ` Szymon Janc [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3514086.fNq38fX02p@uw000953 \
--to=szymon.janc@tieto.com \
--cc=jakub.tyszkowski@tieto.com \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox