Bluez Maintainers,
Here is a fix for attribute writes not working in src/shared/gatt-db.c. The prep_write_complete_cb was not getting called. The attrib->write_func code block should not be called when len is 0
commit 5a9baa10d4fde7ca8ab88ecd68e17671c33cb587 (HEAD -> gat-db, master)
Author: Trey_Ramsay <trey_ramsay@xxxxxxxx>
Date: Fri May 31 15:39:27 2024 -0500
shared/gatt-db: Prepare Write req error BT_ATT_ERROR_UNLIKELY
Fixes Prepare Write req error: BT_ATT_ERROR_UNLIKELY
ATT: Error (0x01)
Error: Unlikely error (14)
Prepare Write req (0x16) on handle 0x0069
The prep_write_complete_cb was not getting called
The attrib->write_func code block does not need to be called when len is 0
diff --git a/src/shared/gatt-db.c b/src/shared/gatt-db.c
index 2c8e7d31e..678aef4cf 100644
--- a/src/shared/gatt-db.c
+++ b/src/shared/gatt-db.c
@@ -2127,6 +2127,10 @@ bool gatt_db_attribute_write(struct gatt_db_attribute *attrib, uint16_t offset,
if (!attrib || (!func && attrib->write_func))
return false;
+ /* Nothing to write just skip */
+ if (len == 0)
+ goto done;
+
if (attrib->write_func) {
struct pending_write *p;
@@ -2162,10 +2166,6 @@ bool gatt_db_attribute_write(struct gatt_db_attribute *attrib, uint16_t offset,
return true;
}
- /* Nothing to write just skip */
- if (len == 0)
- goto done;
-
/* For values stored in db allocate on demand */
if (!attrib->value || offset >= attrib->value_len ||
len > (unsigned) (attrib->value_len - offset)) {
-----Original Message-----
From: Ramsay, Trey <Trey.Ramsay@xxxxxxxx>
Sent: Thursday, June 20, 2024 1:58 PM
To: linux-bluetooth@xxxxxxxxxxxxxxx
Subject: [PATCH] ATT: Error (0x01) - Error: Unlikely error (14) Prepare Write req (0x16)
Bluez Maintainers
Here is a fix for attribute writes not working in src/shared/gatt-db.c
https://urldefense.com/v3/__https://github.com/tramsay/bluez-tramsay/commit/246bc960629dff34e744c728f048e9f50f1a005d__;!!LpKI!jkJYamzU8bOdd1qt-sWpj6gy1YwS30UyamHLUJj9Uy0UecrB6QxvCdSWFAUH7Dvq2wVJqu1C5jjoX5amywJH$ [github[.]com]
shared/gatt-db: Prepare Write req error BT_ATT_ERROR_UNLIKELY Fixes Prepare Write req error: BT_ATT_ERROR_UNLIKELY
ATT: Error (0x01)
Error: Unlikely error (14)
Prepare Write req (0x16) on handle 0x0069
The prep_write_complete_cb was not getting called The attrib->write_func code block should not be called when len is 0