All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH BlueZ 1/2] core/gatt-database: Send offset if set to ReadValue
@ 2016-12-16 13:18 Luiz Augusto von Dentz
  2016-12-16 13:18 ` [PATCH BlueZ 2/2] core/gatt-database: Send offset if set to WriteValue Luiz Augusto von Dentz
  2016-12-20  9:58 ` [PATCH BlueZ 1/2] core/gatt-database: Send offset if set to ReadValue Luiz Augusto von Dentz
  0 siblings, 2 replies; 3+ messages in thread
From: Luiz Augusto von Dentz @ 2016-12-16 13:18 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

If there remote is using Read Blob command as part of a Read Long
procedure the offset needs to be set in order for the application to
detect from where it shall start.

Note that with this it is also possible to detect what the chunk sizes
needs to be as the first offset indicates the maximum payload.
---
 src/gatt-database.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/src/gatt-database.c b/src/gatt-database.c
index 7b3ec16..88627ac 100644
--- a/src/gatt-database.c
+++ b/src/gatt-database.c
@@ -138,6 +138,7 @@ struct external_desc {
 struct pending_op {
 	struct btd_device *device;
 	unsigned int id;
+	uint16_t offset;
 	struct gatt_db_attribute *attrib;
 	struct queue *owner_queue;
 	struct iovec data;
@@ -1605,7 +1606,7 @@ static void pending_op_free(void *data)
 static struct pending_op *pending_read_new(struct btd_device *device,
 					struct queue *owner_queue,
 					struct gatt_db_attribute *attrib,
-					unsigned int id)
+					unsigned int id, uint16_t offset)
 {
 	struct pending_op *op;
 
@@ -1615,6 +1616,7 @@ static struct pending_op *pending_read_new(struct btd_device *device,
 	op->device = device;
 	op->attrib = attrib;
 	op->id = id;
+	op->offset = offset;
 	queue_push_tail(owner_queue, op);
 
 	return op;
@@ -1626,6 +1628,9 @@ static void append_options(DBusMessageIter *iter, void *user_data)
 	const char *path = device_get_path(op->device);
 
 	dict_append_entry(iter, "device", DBUS_TYPE_OBJECT_PATH, &path);
+	if (op->offset)
+		dict_append_entry(iter, "offset", DBUS_TYPE_UINT16,
+							&op->offset);
 }
 
 static void read_setup_cb(DBusMessageIter *iter, void *user_data)
@@ -1649,11 +1654,12 @@ static struct pending_op *send_read(struct btd_device *device,
 					struct gatt_db_attribute *attrib,
 					GDBusProxy *proxy,
 					struct queue *owner_queue,
-					unsigned int id)
+					unsigned int id,
+					uint16_t offset)
 {
 	struct pending_op *op;
 
-	op = pending_read_new(device, owner_queue, attrib, id);
+	op = pending_read_new(device, owner_queue, attrib, id, offset);
 
 	if (g_dbus_proxy_method_call(proxy, "ReadValue", read_setup_cb,
 				read_reply_cb, op, pending_op_free) == TRUE)
@@ -1974,7 +1980,8 @@ static void desc_read_cb(struct gatt_db_attribute *attrib,
 		goto fail;
 	}
 
-	if (send_read(device, attrib, desc->proxy, desc->pending_reads, id))
+	if (send_read(device, attrib, desc->proxy, desc->pending_reads, id,
+								offset))
 		return;
 
 fail:
@@ -2054,7 +2061,8 @@ static void chrc_read_cb(struct gatt_db_attribute *attrib,
 		goto fail;
 	}
 
-	if (send_read(device, attrib, chrc->proxy, chrc->pending_reads, id))
+	if (send_read(device, attrib, chrc->proxy, chrc->pending_reads, id,
+								offset))
 		return;
 
 fail:
-- 
2.9.3


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH BlueZ 2/2] core/gatt-database: Send offset if set to WriteValue
  2016-12-16 13:18 [PATCH BlueZ 1/2] core/gatt-database: Send offset if set to ReadValue Luiz Augusto von Dentz
@ 2016-12-16 13:18 ` Luiz Augusto von Dentz
  2016-12-20  9:58 ` [PATCH BlueZ 1/2] core/gatt-database: Send offset if set to ReadValue Luiz Augusto von Dentz
  1 sibling, 0 replies; 3+ messages in thread
From: Luiz Augusto von Dentz @ 2016-12-16 13:18 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

If there remote is using Prepare + Execute Write commands as part of
a Write Long procedure the offset needs to be set in order for the
application to detect from where it shall write the data.
---
 src/gatt-database.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/src/gatt-database.c b/src/gatt-database.c
index 88627ac..5979e37 100644
--- a/src/gatt-database.c
+++ b/src/gatt-database.c
@@ -1738,7 +1738,8 @@ static struct pending_op *pending_write_new(struct btd_device *device,
 					struct gatt_db_attribute *attrib,
 					unsigned int id,
 					const uint8_t *value,
-					size_t len)
+					size_t len,
+					uint16_t offset)
 {
 	struct pending_op *op;
 
@@ -1751,6 +1752,7 @@ static struct pending_op *pending_write_new(struct btd_device *device,
 	op->owner_queue = owner_queue;
 	op->attrib = attrib;
 	op->id = id;
+	op->offset = offset;
 	queue_push_tail(owner_queue, op);
 
 	return op;
@@ -1761,11 +1763,13 @@ static struct pending_op *send_write(struct btd_device *device,
 					GDBusProxy *proxy,
 					struct queue *owner_queue,
 					unsigned int id,
-					const uint8_t *value, size_t len)
+					const uint8_t *value, size_t len,
+					uint16_t offset)
 {
 	struct pending_op *op;
 
-	op = pending_write_new(device, owner_queue, attrib, id, value, len);
+	op = pending_write_new(device, owner_queue, attrib, id, value, len,
+								offset);
 
 	if (g_dbus_proxy_method_call(proxy, "WriteValue", write_setup_cb,
 					owner_queue ? write_reply_cb : NULL,
@@ -2010,7 +2014,7 @@ static void desc_write_cb(struct gatt_db_attribute *attrib,
 	}
 
 	if (send_write(device, attrib, desc->proxy, desc->pending_writes, id,
-							value, len))
+							value, len, offset))
 		return;
 
 fail:
@@ -2096,7 +2100,8 @@ static void chrc_write_cb(struct gatt_db_attribute *attrib,
 	else
 		queue = NULL;
 
-	if (send_write(device, attrib, chrc->proxy, queue, id, value, len))
+	if (send_write(device, attrib, chrc->proxy, queue, id, value, len,
+								offset))
 		return;
 
 fail:
-- 
2.9.3


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH BlueZ 1/2] core/gatt-database: Send offset if set to ReadValue
  2016-12-16 13:18 [PATCH BlueZ 1/2] core/gatt-database: Send offset if set to ReadValue Luiz Augusto von Dentz
  2016-12-16 13:18 ` [PATCH BlueZ 2/2] core/gatt-database: Send offset if set to WriteValue Luiz Augusto von Dentz
@ 2016-12-20  9:58 ` Luiz Augusto von Dentz
  1 sibling, 0 replies; 3+ messages in thread
From: Luiz Augusto von Dentz @ 2016-12-20  9:58 UTC (permalink / raw)
  To: linux-bluetooth

Hi,

On Fri, Dec 16, 2016 at 3:18 PM, Luiz Augusto von Dentz
<luiz.dentz@gmail.com> wrote:
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
>
> If there remote is using Read Blob command as part of a Read Long
> procedure the offset needs to be set in order for the application to
> detect from where it shall start.
>
> Note that with this it is also possible to detect what the chunk sizes
> needs to be as the first offset indicates the maximum payload.
> ---
>  src/gatt-database.c | 18 +++++++++++++-----
>  1 file changed, 13 insertions(+), 5 deletions(-)
>
> diff --git a/src/gatt-database.c b/src/gatt-database.c
> index 7b3ec16..88627ac 100644
> --- a/src/gatt-database.c
> +++ b/src/gatt-database.c
> @@ -138,6 +138,7 @@ struct external_desc {
>  struct pending_op {
>         struct btd_device *device;
>         unsigned int id;
> +       uint16_t offset;
>         struct gatt_db_attribute *attrib;
>         struct queue *owner_queue;
>         struct iovec data;
> @@ -1605,7 +1606,7 @@ static void pending_op_free(void *data)
>  static struct pending_op *pending_read_new(struct btd_device *device,
>                                         struct queue *owner_queue,
>                                         struct gatt_db_attribute *attrib,
> -                                       unsigned int id)
> +                                       unsigned int id, uint16_t offset)
>  {
>         struct pending_op *op;
>
> @@ -1615,6 +1616,7 @@ static struct pending_op *pending_read_new(struct btd_device *device,
>         op->device = device;
>         op->attrib = attrib;
>         op->id = id;
> +       op->offset = offset;
>         queue_push_tail(owner_queue, op);
>
>         return op;
> @@ -1626,6 +1628,9 @@ static void append_options(DBusMessageIter *iter, void *user_data)
>         const char *path = device_get_path(op->device);
>
>         dict_append_entry(iter, "device", DBUS_TYPE_OBJECT_PATH, &path);
> +       if (op->offset)
> +               dict_append_entry(iter, "offset", DBUS_TYPE_UINT16,
> +                                                       &op->offset);
>  }
>
>  static void read_setup_cb(DBusMessageIter *iter, void *user_data)
> @@ -1649,11 +1654,12 @@ static struct pending_op *send_read(struct btd_device *device,
>                                         struct gatt_db_attribute *attrib,
>                                         GDBusProxy *proxy,
>                                         struct queue *owner_queue,
> -                                       unsigned int id)
> +                                       unsigned int id,
> +                                       uint16_t offset)
>  {
>         struct pending_op *op;
>
> -       op = pending_read_new(device, owner_queue, attrib, id);
> +       op = pending_read_new(device, owner_queue, attrib, id, offset);
>
>         if (g_dbus_proxy_method_call(proxy, "ReadValue", read_setup_cb,
>                                 read_reply_cb, op, pending_op_free) == TRUE)
> @@ -1974,7 +1980,8 @@ static void desc_read_cb(struct gatt_db_attribute *attrib,
>                 goto fail;
>         }
>
> -       if (send_read(device, attrib, desc->proxy, desc->pending_reads, id))
> +       if (send_read(device, attrib, desc->proxy, desc->pending_reads, id,
> +                                                               offset))
>                 return;
>
>  fail:
> @@ -2054,7 +2061,8 @@ static void chrc_read_cb(struct gatt_db_attribute *attrib,
>                 goto fail;
>         }
>
> -       if (send_read(device, attrib, chrc->proxy, chrc->pending_reads, id))
> +       if (send_read(device, attrib, chrc->proxy, chrc->pending_reads, id,
> +                                                               offset))
>                 return;
>
>  fail:
> --
> 2.9.3

Applied.


-- 
Luiz Augusto von Dentz

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-12-20  9:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-16 13:18 [PATCH BlueZ 1/2] core/gatt-database: Send offset if set to ReadValue Luiz Augusto von Dentz
2016-12-16 13:18 ` [PATCH BlueZ 2/2] core/gatt-database: Send offset if set to WriteValue Luiz Augusto von Dentz
2016-12-20  9:58 ` [PATCH BlueZ 1/2] core/gatt-database: Send offset if set to ReadValue Luiz Augusto von Dentz

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.