From dc13fd8d8b463e8899955b6df3b1bd7d3fb9be43 Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Mon, 12 Apr 2021 11:47:30 +0200 Subject: [PATCH] gatt_client: fix read long characteristic descriptor --- CHANGELOG.md | 2 +- src/ble/gatt_client.c | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c94429f2d..aa74c8e0e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -69,7 +69,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Examples: use `btstack_event.h` getters instead of direct array access, use enum to compare status codes - HFP: provide acl_handle in events to identify connection - HCI Transport: extract convenience function declaration for h4, h5, em9304_spi, and usb into separate hci_transport_{type}.h -- GATT Client: Use ATT_READ_REQUEST for first blob of Read Long Characteristic +- GATT Client: Use ATT_READ_REQUEST for first blob of Read Long Characteristic and Read Long Characteristic Descriptor - HID: Move `src/classic/hid.h` into `src` and prefix with `btstack_` to use it with BLE and avoid name clashes ## Release v1.3.2 diff --git a/src/ble/gatt_client.c b/src/ble/gatt_client.c index c510a9b59..ddc79d7d5 100644 --- a/src/ble/gatt_client.c +++ b/src/ble/gatt_client.c @@ -1442,7 +1442,7 @@ static void gatt_client_att_packet_handler(uint8_t packet_type, uint16_t handle, break; case ATT_READ_RESPONSE: switch (gatt_client->gatt_client_state){ - case P_W4_INCLUDED_SERVICE_UUID_WITH_QUERY_RESULT: { + case P_W4_INCLUDED_SERVICE_UUID_WITH_QUERY_RESULT: if (size >= 17){ uint8_t uuid128[16]; reverse_128(&packet[1], uuid128); @@ -1451,25 +1451,33 @@ static void gatt_client_att_packet_handler(uint8_t packet_type, uint16_t handle, trigger_next_included_service_query(gatt_client, gatt_client->start_group_handle); // GATT_EVENT_QUERY_COMPLETE is emitted by trigger_next_xxx when done break; - } + case P_W4_READ_CHARACTERISTIC_VALUE_RESULT: gatt_client_handle_transaction_complete(gatt_client); report_gatt_characteristic_value(gatt_client, gatt_client->attribute_handle, &packet[1], size - 1u); emit_gatt_complete_event(gatt_client, ATT_ERROR_SUCCESS); break; - case P_W4_READ_CHARACTERISTIC_DESCRIPTOR_RESULT:{ + case P_W4_READ_CHARACTERISTIC_DESCRIPTOR_RESULT: gatt_client_handle_transaction_complete(gatt_client); report_gatt_characteristic_descriptor(gatt_client, gatt_client->attribute_handle, &packet[1], size - 1u, 0u); emit_gatt_complete_event(gatt_client, ATT_ERROR_SUCCESS); break; - } + // Use ATT_READ_REQUEST for first blob of Read Long Characteristic case P_W4_READ_BLOB_RESULT: report_gatt_long_characteristic_value_blob(gatt_client, gatt_client->attribute_handle, &packet[1], size - 1u, gatt_client->attribute_offset); trigger_next_blob_query(gatt_client, P_W2_SEND_READ_BLOB_QUERY, size - 1u); // GATT_EVENT_QUERY_COMPLETE is emitted by trigger_next_xxx when done break; + + // Use ATT_READ_REQUEST for first blob of Read Long Characteristic Descriptor + case P_W4_READ_BLOB_CHARACTERISTIC_DESCRIPTOR_RESULT: + report_gatt_long_characteristic_descriptor(gatt_client, gatt_client->attribute_handle, &packet[1], size-1u, gatt_client->attribute_offset); + trigger_next_blob_query(gatt_client, P_W2_SEND_READ_BLOB_CHARACTERISTIC_DESCRIPTOR_QUERY, size-1u); + // GATT_EVENT_QUERY_COMPLETE is emitted by trigger_next_xxx when done + break; + default: break; }