Skip to contentSkip to conversation

test-rap: Fix gatt_ccc_read_cb on big-endian

PATCH New Luiz Augusto von Dentz 1 participant 1 message May 14 Bluetooth drivers

lore
Share & tools
lore

Luiz Augusto von Dentz

author maintainer
#0 lore raw

PATCH v2 1/1 test-rap: Fix gatt_ccc_read_cb on big-endian

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

Reading CCC values shall return little-endian 16 bits, not native format.

---
 unit/test-rap.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
unit/test-rap.c +5 -6
index 4ca4a715edff..22bc2671bf46 100644
@@ -253,8 +253,7 @@ static void gatt_ccc_read_cb(struct gatt_db_attribute *attrib,
 	struct ccc_state *ccc;
 	uint16_t handle;
 	uint8_t ecode = 0;
-	const uint8_t *value = NULL;
-	size_t len = 0;
+	uint16_t value = 0;
 
 	handle = gatt_db_attribute_get_handle(attrib);
 
@@ -264,11 +263,11 @@ static void gatt_ccc_read_cb(struct gatt_db_attribute *attrib,
 		goto done;
 	}
 
-	len = sizeof(ccc->value);
-	value = (void *) &ccc->value;
+	value = cpu_to_le16(ccc->value);
 
 done:
-	gatt_db_attribute_read_result(attrib, id, ecode, value, len);
+	gatt_db_attribute_read_result(attrib, id, ecode, (void *)&value,
+							sizeof(value));
 }
 
 static void ras_attached(struct bt_rap *rap, void *user_data)
@@ -528,7 +527,7 @@ static void test_server(const void *user_data)
 	RAS_FIND_INFO
 
 /*
- * RAS/SR/RCO/BV-01-C � Characteristic Read: RAS Features
+ * RAS/SR/RCO/BV-01-C Characteristic Read: RAS Features
  *
  *  ATT: Read Request (0x0a) len 2
  *       Handle: 0x0003 (RAS Features value handle)
Signature · 1 line
2.53.0