Re: [PATCH bluez v2] shared/gatt-db: Add read offset to record the progress of att read blob request

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

On Tue, May 27, 2025 at 4:13 AM Ye He via B4 Relay
<devnull+ye.he.amlogic.com@xxxxxxxxxx> wrote:
>
> From: Ye He <ye.he@xxxxxxxxxxx>
>
> When processing the att read blob request packet sent
> by the mobile phone, Bluez ignores the offset and the
> payload of each att read blob response is the same.
>
> This patch add read offset to record the progress of
> att read blob request.
>
> Fixes: https://github.com/bluez/bluez/issues/1294
>
> Signed-off-by: Ye He <ye.he@xxxxxxxxxxx>
> ---
> Changes in v2:
> - Fix build error.
> - Link to v1: https://patch.msgid.link/20250527-att-read-blob-rsp-err-v1-1-75d3bc498862@xxxxxxxxxxx
> ---
>  src/shared/gatt-db.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/src/shared/gatt-db.c b/src/shared/gatt-db.c
> index 8951079beef1a8af7e46e87043f320640d4109f7..06af4f65bacaac39cdf9641e40fac902653c4b9c 100644
> --- a/src/shared/gatt-db.c
> +++ b/src/shared/gatt-db.c
> @@ -109,6 +109,7 @@ struct gatt_db_attribute {
>         uint32_t permissions;
>         uint16_t value_len;
>         uint8_t *value;
> +       uint16_t read_offset;
>
>         gatt_db_read_t read_func;
>         gatt_db_write_t write_func;
> @@ -151,7 +152,8 @@ static void pending_read_result(struct pending_read *p, int err,
>         if (p->timeout_id > 0)
>                 timeout_remove(p->timeout_id);
>
> -       p->func(p->attrib, err, data, length, p->user_data);
> +       p->func(p->attrib, err, data + p->attrib->read_offset,
> +                       length - p->attrib->read_offset, p->user_data);
>
>         free(p);
>  }
> @@ -2126,6 +2128,8 @@ bool gatt_db_attribute_read(struct gatt_db_attribute *attrib, uint16_t offset,
>         if (!attrib || !func)
>                 return false;
>
> +       attrib->read_offset = offset;
> +
>         /* Check boundaries if value_len is set */
>         if (attrib->value_len && offset > attrib->value_len) {
>                 func(attrib, BT_ATT_ERROR_INVALID_OFFSET, NULL, 0, user_data);

This is not quite right, first there is the problem that you are
storing it in the gatt_db_attribute itself, so it will affect
subsequent requests, rather than storing the offset at pending_read,
but even then this would be wrong since the intention is that the
offset is handled by the read_func otherwise we wouldn't bother
passing the offset to the it.

> ---
> base-commit: c888c682fbd4e02dce6bf4c1f9a47328ceb02716
> change-id: 20250527-att-read-blob-rsp-err-c30db15efd30
>
> Best regards,
> --
> Ye He <ye.he@xxxxxxxxxxx>
>
>
>


-- 
Luiz Augusto von Dentz





[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux