Bluetooth: GATT: Fix warning when attempting to use read callback
When using bt_gatt_discover with BT_GATT_DISCOVER_CHARACTERISTIC the read callback would be set to bt_gatt_attr_read_chrc which would attempt to access the next attribute which in this case would not be set since the value attribute is no fetched by the discovery, the spec actually omit the value handle saying it should always be the first attribute to appear after the characteristic thus we can assume it to be handle + 1. Fixes #12159 Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This commit is contained in:
parent
f06a20c25c
commit
80bc21e03c
|
@ -542,7 +542,6 @@ ssize_t bt_gatt_attr_read_chrc(struct bt_conn *conn,
|
|||
{
|
||||
struct bt_gatt_chrc *chrc = attr->user_data;
|
||||
struct gatt_chrc pdu;
|
||||
const struct bt_gatt_attr *next;
|
||||
u8_t value_len;
|
||||
|
||||
pdu.properties = chrc->properties;
|
||||
|
@ -553,13 +552,8 @@ ssize_t bt_gatt_attr_read_chrc(struct bt_conn *conn,
|
|||
* declaration. All characteristic definitions shall have a
|
||||
* Characteristic Value declaration.
|
||||
*/
|
||||
next = bt_gatt_attr_next(attr);
|
||||
if (!next) {
|
||||
BT_WARN("No value for characteristic at 0x%04x", attr->handle);
|
||||
pdu.value_handle = 0x0000;
|
||||
} else {
|
||||
pdu.value_handle = sys_cpu_to_le16(next->handle);
|
||||
}
|
||||
pdu.value_handle = sys_cpu_to_le16(attr->handle + 1);
|
||||
|
||||
value_len = sizeof(pdu.properties) + sizeof(pdu.value_handle);
|
||||
|
||||
if (chrc->uuid->type == BT_UUID_TYPE_16) {
|
||||
|
|
Loading…
Reference in New Issue