From a1d703afb26dd04e800d70a93a46ed9c631b9227 Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Thu, 30 Jan 2025 12:29:05 +0100 Subject: [PATCH] hid_host: storage for HID Descriptors is now optional --- CHANGELOG.md | 1 + src/classic/hid_host.c | 8 ++++++-- src/classic/hid_host.h | 7 ++++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2db8fdceb..7ba850f4a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Added - GAP: simulate HCI_EVENT_REMOTE_NAME_REQUEST_COMPLETE if HCI Remote Name Request fails - AVRCP Controller: Added send generic PASS THROUGH command +- HID Host: storage for HID Descriptors is now optional ### Fixed - GAP: store link key for standard/non-SSP pairing ### Changed diff --git a/src/classic/hid_host.c b/src/classic/hid_host.c index c8e99169f..3b02eb5d2 100644 --- a/src/classic/hid_host.c +++ b/src/classic/hid_host.c @@ -559,8 +559,11 @@ static void hid_host_handle_sdp_client_query_result(uint8_t packet_type, uint16_ process_data = true; break; case BLUETOOTH_ATTRIBUTE_HID_DESCRIPTOR_LIST: - // directly process BLUETOOTH_ATTRIBUTE_HID_DESCRIPTOR_LIST with state machine - hid_host_handle_sdp_hid_descriptor_list(connection, attribute_offset, attribute_data); + // directly process BLUETOOTH_ATTRIBUTE_HID_DESCRIPTOR_LIST with state machine if hid_descriptor_storage is available + if (hid_host_descriptor_storage != NULL){ + hid_host_handle_sdp_hid_descriptor_list(connection, attribute_offset, attribute_data); + break; + } break; default: break; @@ -1162,6 +1165,7 @@ static void hid_host_packet_handler(uint8_t packet_type, uint16_t channel, uint8 void hid_host_init(uint8_t * hid_descriptor_storage, uint16_t hid_descriptor_storage_len){ + btstack_assert((hid_descriptor_storage_len == 0) || (hid_descriptor_storage != NULL)); hid_host_descriptor_storage = hid_descriptor_storage; hid_host_descriptor_storage_len = hid_descriptor_storage_len; diff --git a/src/classic/hid_host.h b/src/classic/hid_host.h index 3dccb984c..b4ad6cef2 100644 --- a/src/classic/hid_host.h +++ b/src/classic/hid_host.h @@ -132,7 +132,12 @@ typedef struct { /* API_START */ /** - * @brief Set up HID Host + * @brief Set up HID Host and provide storage for HID Descriptors + * If storage for HID Descriptors is provided, the HID Host will fetch and store the HID Descriptors + * for each connection and inform the application via HID_SUBEVENT_DESCRIPTOR_AVAILABLE event. + * The app can then access the HID descriptor for a particular connection with + * hid_descriptor_storage_get_descriptor_data and hid_descriptor_storage_get_descriptor_len. + * @note if hid_descriptor_storage is NULL, the HID Host will not store the HID Descriptor * @param hid_descriptor_storage * @param hid_descriptor_storage_len */