From: Lukasz Rymanowski <lukasz.rymanowski@tieto.com>
To: linux-bluetooth@vger.kernel.org
Cc: szymon.janc@tieto.com, Lukasz Rymanowski <lukasz.rymanowski@tieto.com>
Subject: [PATCH v2 4/5] android/gatt: Add support for write execute
Date: Thu, 17 Apr 2014 13:57:47 +0200 [thread overview]
Message-ID: <1397735868-19092-5-git-send-email-lukasz.rymanowski@tieto.com> (raw)
In-Reply-To: <1397735868-19092-1-git-send-email-lukasz.rymanowski@tieto.com>
This patch add support for write execute. There is possible to write or
cancel all prepared data
---
android/gatt.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 47 insertions(+), 1 deletion(-)
diff --git a/android/gatt.c b/android/gatt.c
index 281f520..3f37a44 100644
--- a/android/gatt.c
+++ b/android/gatt.c
@@ -2633,12 +2633,58 @@ failed:
HAL_OP_GATT_CLIENT_WRITE_DESCRIPTOR, status);
}
+static void send_client_write_execute_notify(int32_t id, int32_t status)
+{
+ struct hal_ev_gatt_client_exec_write ev;
+
+ ev.conn_id = id;
+ ev.status = status;
+
+ ipc_send_notif(hal_ipc, HAL_SERVICE_ID_GATT,
+ HAL_EV_GATT_CLIENT_EXEC_WRITE,
+ sizeof(ev), &ev);
+}
+
+static void write_execute_cb(guint8 status, const guint8 *pdu, guint16 len,
+ gpointer user_data)
+{
+ send_client_write_execute_notify(PTR_TO_INT(user_data), status);
+}
+
static void handle_client_execute_write(const void *buf, uint16_t len)
{
+ const struct hal_cmd_gatt_client_execute_write *cmd = buf;
+ struct gatt_device *dev;
+ uint8_t status;
+ uint8_t flags;
+
DBG("");
+ dev = queue_find(conn_list, match_dev_by_conn_id,
+ INT_TO_PTR(cmd->conn_id));
+ if (!dev) {
+ status = HAL_STATUS_FAILED;
+ goto reply;
+ }
+
+ flags = cmd->execute ? ATT_WRITE_ALL_PREP_WRITES :
+ ATT_CANCEL_ALL_PREP_WRITES;
+
+ if (!gatt_execute_write(dev->attrib, flags, write_execute_cb,
+ INT_TO_PTR(cmd->conn_id))) {
+ error("gatt: Could not send execute write");
+ status = HAL_STATUS_FAILED;
+ goto reply;
+ }
+
+ status = HAL_STATUS_SUCCESS;
+reply:
ipc_send_rsp(hal_ipc, HAL_SERVICE_ID_GATT,
- HAL_OP_GATT_CLIENT_EXECUTE_WRITE, HAL_STATUS_FAILED);
+ HAL_OP_GATT_CLIENT_EXECUTE_WRITE, status);
+
+ /* In case of early error send also notification.*/
+ if (status != HAL_STATUS_SUCCESS)
+ send_client_write_execute_notify(cmd->conn_id, GATT_FAILURE);
}
static void handle_notification(const uint8_t *pdu, uint16_t len,
--
1.8.4
next prev parent reply other threads:[~2014-04-17 11:57 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-17 11:57 [PATCH v2 0/5]android/gatt: GATT Client write types support Lukasz Rymanowski
2014-04-17 11:57 ` [PATCH v2 1/5] attrib: Add API for reliable write Lukasz Rymanowski
2014-04-17 11:57 ` [PATCH v2 2/5] attrib: Expose write execute Lukasz Rymanowski
2014-04-17 11:57 ` [PATCH v2 3/5] android/gatt: Add support for reliable write Lukasz Rymanowski
2014-04-17 11:57 ` Lukasz Rymanowski [this message]
2014-04-17 11:57 ` [PATCH v2 5/5] android/gatt: Add support for write without response Lukasz Rymanowski
2014-04-23 13:19 ` [PATCH v2 0/5]android/gatt: GATT Client write types support Szymon Janc
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=1397735868-19092-5-git-send-email-lukasz.rymanowski@tieto.com \
--to=lukasz.rymanowski@tieto.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=szymon.janc@tieto.com \
/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