gatt-service/hids-client: fix in-place event for received HID reports

This commit is contained in:
Matthias Ringwald 2024-12-20 10:45:53 +01:00
parent 77043c43b8
commit d41c2d2832

View File

@ -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) {