Skip to contentSkip to conversation

shared/gatt-client: Make bt_gatt_client_read use bt_gatt_client_read_long

PATCH Applied Luiz Augusto von Dentz 3 participants 3 messages Jun 13, 2025 – Jun 16, 2025 Bluetooth drivers

lore
Share & tools
lore

Luiz Augusto von Dentz

author maintainer
#0 lore raw

PATCH 1/1 shared/gatt-client: Make bt_gatt_client_read use bt_gatt_client_read_long

From: Luiz Augusto von Dentz <[email protected]>

This makes bt_gatt_client_read use bt_gatt_client_read_long since the later does use BT_ATT_OP_READ_REQ for reading the first chunk, so they are actually equivalent in this respect, but bt_gatt_client_read_long detects when the data returned maybe truncated due to MTU and then proceed to use BT_ATT_OP_READ_BLOB_REQ to read the remaining chunks which is a disarable behavior since there is no property indicating when an attribute would require long read procedure.

---
 src/shared/gatt-client.c | 68 ++--------------------------------------
 1 file changed, 2 insertions(+), 66 deletions(-)
src/shared/gatt-client.c +2 -66
index 41a5c6f9c399..ec23415086c3 100644
@@ -2686,78 +2686,14 @@ static void destroy_read_op(void *data)
 	free(op);
 }
 
-static void read_cb(uint8_t opcode, const void *pdu, uint16_t length,
-								void *user_data)
-{
-	struct request *req = user_data;
-	struct read_op *op = req->data;
-	bool success;
-	uint8_t att_ecode = 0;
-	const uint8_t *value = NULL;
-	uint16_t value_len = 0;
-
-	if (opcode == BT_ATT_OP_ERROR_RSP) {
-		success = false;
-		att_ecode = process_error(pdu, length);
-		goto done;
-	}
-
-	if (opcode != BT_ATT_OP_READ_RSP || (!pdu && length)) {
-		success = false;
-		goto done;
-	}
-
-	success = true;
-	value_len = length;
-	if (value_len)
-		value = pdu;
-
-done:
-	if (op->callback)
-		op->callback(success, att_ecode, value, length, op->user_data);
-}
-
 unsigned int bt_gatt_client_read_value(struct bt_gatt_client *client,
 					uint16_t value_handle,
 					bt_gatt_client_read_callback_t callback,
 					void *user_data,
 					bt_gatt_client_destroy_func_t destroy)
 {
-	struct request *req;
-	struct read_op *op;
-	uint8_t pdu[2];
-
-	if (!client)
-		return 0;
-
-	op = new0(struct read_op, 1);
-
-	req = request_create(client);
-	if (!req) {
-		free(op);
-		return 0;
-	}
-
-	op->callback = callback;
-	op->user_data = user_data;
-	op->destroy = destroy;
-
-	req->data = op;
-	req->destroy = destroy_read_op;
-
-	put_le16(value_handle, pdu);
-
-	req->att_id = bt_att_send(client->att, BT_ATT_OP_READ_REQ,
-							pdu, sizeof(pdu),
-							read_cb, req,
-							request_unref);
-	if (!req->att_id) {
-		op->destroy = NULL;
-		request_unref(req);
-		return 0;
-	}
-
-	return req->id;
+	return bt_gatt_client_read_long_value(client, value_handle, 0, callback,
+						user_data, destroy);
 }
 
 static void read_multiple_cb(uint8_t opcode, const void *pdu, uint16_t length,
Signature · 1 line
2.49.0
#1 lore raw

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=971855

---Test result---

Test Summary:

CheckPatch                    PENDING   0.41 seconds
GitLint                       PENDING   0.31 seconds
BuildEll                      PASS      20.22 seconds
BluezMake                     PASS      2720.52 seconds
MakeCheck                     PASS      20.52 seconds
MakeDistcheck                 PASS      202.22 seconds
CheckValgrind                 PASS      279.65 seconds
CheckSmatch                   PASS      310.39 seconds
bluezmakeextell               PASS      129.80 seconds
IncrementalBuild              PENDING   0.38 seconds
ScanBuild                     PASS      930.49 seconds

Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script
Output:

##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:

##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series Output:

---
Regards,
Linux Bluetooth

#2 lore raw
In reply to Luiz Augusto von Dentz
This patch was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:

Hello:

This patch was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:

Quoted 11 lines · On Fri, 13 Jun 2025 10:04:45 -0400 you wrote:

From: Luiz Augusto von Dentz <[email protected]>

This makes bt_gatt_client_read use bt_gatt_client_read_long since the later does use BT_ATT_OP_READ_REQ for reading the first chunk, so they are actually equivalent in this respect, but bt_gatt_client_read_long detects when the data returned maybe truncated due to MTU and then proceed to use BT_ATT_OP_READ_BLOB_REQ to read the remaining chunks which is a disarable behavior since there is no property indicating when an attribute would require long read procedure.

[...]

Here is the summary with links:
- [BlueZ,v1] shared/gatt-client: Make bt_gatt_client_read use bt_gatt_client_read_long

    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=be36a9c9d3af

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html