From d41c2d2832fa603036e0715bf8fda2e5f58bd44e Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Fri, 20 Dec 2024 10:45:53 +0100 Subject: [PATCH] gatt-service/hids-client: fix in-place event for received HID reports --- src/ble/gatt-service/hids_client.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/ble/gatt-service/hids_client.c b/src/ble/gatt-service/hids_client.c index ac99e1724..4fd4a57a8 100644 --- a/src/ble/gatt-service/hids_client.c +++ b/src/ble/gatt-service/hids_client.c @@ -623,10 +623,19 @@ static void handle_notification_event(uint8_t packet_type, uint16_t channel, uin return; } - uint8_t * in_place_event = &packet[-2]; + // GATT_EVENT_NOTIFICATION has HID report data at offset 12 + // - see gatt_event_notification_get_value() + // + // GATTSERVICE_SUBEVENT_HID_REPORT has HID report data at offset 10 + // - see gattservice_subevent_hid_report_get_report() and add 1 for the inserted Report ID + // + // => use existing packet from offset 2 = 12 - 10 to setup event + const int16_t offset = 2; + + uint8_t * in_place_event = &packet[offset]; hids_client_setup_report_event_with_report_id(client, report_index, in_place_event, gatt_event_notification_get_value_length(packet)); - (*client->client_handler)(HCI_EVENT_GATTSERVICE_META, client->cid, in_place_event, size + 2); + (*client->client_handler)(HCI_EVENT_GATTSERVICE_META, client->cid, in_place_event, size - offset); } static void handle_report_event(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size) {