From: Szymon Janc <szymon.janc@tieto.com>
To: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCH 1/5] android/gatt: Implement MTU exchange HAL API
Date: Thu, 12 Mar 2015 16:03:36 +0100 [thread overview]
Message-ID: <3668094.CB29rsQEEs@leonov> (raw)
In-Reply-To: <1426084883-10291-1-git-send-email-szymon.janc@tieto.com>
On Wednesday 11 of March 2015 15:41:19 Szymon Janc wrote:
> This allow application to query for current MTU. MTU is always
> exchanged on connection and notifications are sent to framework.
>
> When client requests MTU exchange we just report current value but
> don't trigger another exchange procedure (since this is against spec).
> ---
> android/gatt.c | 63
> +++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed,
> 60 insertions(+), 3 deletions(-)
>
> diff --git a/android/gatt.c b/android/gatt.c
> index 9c2a280..1a264ba 100644
> --- a/android/gatt.c
> +++ b/android/gatt.c
> @@ -941,6 +941,39 @@ static bool get_local_mtu(struct gatt_device *dev,
> uint16_t *mtu) return true;
> }
>
> +static void notify_client_mtu_change(struct app_connection *conn, bool
> success) +{
> + struct hal_ev_gatt_client_configure_mtu ev;
> + size_t mtu;
> +
> + g_attrib_get_buffer(conn->device->attrib, &mtu);
> +
> + ev.conn_id = conn->id;
> + ev.status = success ? GATT_SUCCESS : GATT_FAILURE;
> + ev.mtu = mtu;
> +
> + ipc_send_notif(hal_ipc, HAL_SERVICE_ID_GATT,
> + HAL_EV_GATT_CLIENT_CONFIGURE_MTU, sizeof(ev), &ev);
> +}
> +
> +static void notify_mtu_change(void *data, void *user_data)
> +{
> + struct gatt_device *device = user_data;
> + struct app_connection *conn = data;
> +
> + if (conn->device != device)
> + return;
> +
> + switch (conn->app->type) {
> + case GATT_CLIENT:
> + notify_client_mtu_change(conn, true);
> + break;
> + case GATT_SERVER:
> + default:
> + break;
> + }
> +}
> +
> static bool update_mtu(struct gatt_device *device, uint16_t rmtu)
> {
> uint16_t mtu, lmtu;
> @@ -965,6 +998,8 @@ static bool update_mtu(struct gatt_device *device,
> uint16_t rmtu) return false;
> }
>
> + queue_foreach(app_connections, notify_mtu_change, device);
> +
> return true;
> }
>
> @@ -1600,6 +1635,11 @@ reply:
> data.status = status;
> queue_foreach(app_connections, notify_app_connect_status_by_device,
> &data);
> +
> + /* For BR/EDR notify about MTU since it is not negotiable*/
> + if (cid != ATT_CID)
> + queue_foreach(app_connections, notify_mtu_change, dev);
> +
> device_unref(dev);
>
> /* Check if we should restart scan */
> @@ -5676,14 +5716,31 @@ static void handle_client_scan_filter_enable(const
> void *buf, uint16_t len) static void handle_client_configure_mtu(const void
> *buf, uint16_t len) {
> const struct hal_cmd_gatt_client_configure_mtu *cmd = buf;
> + static struct app_connection *conn;
> + uint8_t status;
>
> - DBG("conn_id %u", cmd->conn_id);
> + DBG("conn_id %u mtu %d", cmd->conn_id, cmd->mtu);
>
> - /* TODO */
> + conn = find_connection_by_id(cmd->conn_id);
> + if (!conn) {
> + status = HAL_STATUS_FAILED;
> + goto failed;
> + }
>
> + /*
> + * currently MTU is always exchanged on connection, just report current
> + * value
> + *
> + * TODO figure out when send failed status
> + * TODO should we fail for BR/EDR?
> + */
> + notify_client_mtu_change(conn, false);
> + status = HAL_STATUS_SUCCESS;
> +
> +failed:
> ipc_send_rsp(hal_ipc, HAL_SERVICE_ID_GATT,
> HAL_OP_GATT_CLIENT_CONFIGURE_MTU,
> - HAL_STATUS_UNSUPPORTED);
> + status);
> }
>
> static void handle_client_conn_param_update(const void *buf, uint16_t len)
Applied.
--
BR
Szymon Janc
prev parent reply other threads:[~2015-03-12 15:03 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-11 14:41 [PATCH 1/5] android/gatt: Implement MTU exchange HAL API Szymon Janc
2015-03-11 14:41 ` [PATCH 2/5] android: Update Android system headers to 5.1 API Szymon Janc
2015-03-11 14:41 ` [PATCH 3/5] android/hal-ipc-api: Add GATT Server MTU Changed notification Szymon Janc
2015-03-11 14:41 ` [PATCH 4/5] android/hal-gatt: Add support for server MTU changed callback Szymon Janc
2015-03-11 14:41 ` [PATCH 5/5] android/gatt: Add suport " Szymon Janc
2015-03-12 15:03 ` 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=3668094.CB29rsQEEs@leonov \
--to=szymon.janc@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.