hids_client: fix read HID descriptor

This commit is contained in:
Milanka Ringwald 2021-03-25 10:05:56 +01:00
parent c756b1a545
commit 8cec2b74ed
3 changed files with 16 additions and 12 deletions

View File

@ -610,7 +610,7 @@ static void hids_run_for_client(hids_client_t * client){
printf("\n\nRead REPORT_MAP (Handle 0x%04X) HID Descriptor of service %d:\n", client->services[client->service_index].report_map_value_handle, client->service_index);
#endif
client->state = HIDS_CLIENT_STATE_W4_REPORT_MAP_HID_DESCRIPTOR;
att_status = gatt_client_read_value_of_characteristic_using_value_handle(&handle_gatt_client_event, client->con_handle, client->services[client->service_index].report_map_value_handle);
att_status = gatt_client_read_long_value_of_characteristic_using_value_handle(&handle_gatt_client_event, client->con_handle, client->services[client->service_index].report_map_value_handle);
UNUSED(att_status);
break;
@ -784,8 +784,8 @@ static void handle_gatt_client_event(uint8_t packet_type, uint16_t channel, uint
uint8_t i;
uint8_t report_index;
const uint8_t * descriptor;
uint16_t descriptor_len;
const uint8_t * descriptor_value;
uint16_t descriptor_value_len;
switch(hci_event_packet_get_type(packet)){
case GATT_EVENT_SERVICE_QUERY_RESULT:
@ -821,18 +821,20 @@ static void handle_gatt_client_event(uint8_t packet_type, uint16_t channel, uint
hids_client_parse_characteristic(client, characteristic);
break;
case GATT_EVENT_CHARACTERISTIC_VALUE_QUERY_RESULT:
case GATT_EVENT_LONG_CHARACTERISTIC_VALUE_QUERY_RESULT:
// Map Report characteristic value == HID Descriptor
client = hids_get_client_for_con_handle(gatt_event_characteristic_value_query_result_get_handle(packet));
client = hids_get_client_for_con_handle(gatt_event_long_characteristic_value_query_result_get_handle(packet));
btstack_assert(client != NULL);
descriptor_len = gatt_event_characteristic_value_query_result_get_value_length(packet);
descriptor = gatt_event_characteristic_value_query_result_get_value(packet);
descriptor_value = gatt_event_long_characteristic_value_query_result_get_value(packet);
descriptor_value_len = gatt_event_long_characteristic_value_query_result_get_value_length(packet);
#ifdef ENABLE_TESTING_SUPPORT
printf("Found HID Descriptor[%d] for service %d\n", descriptor_len, client->service_index);
// printf("Report Map HID Desc [%d] for service %d\n", descriptor_len, client->service_index);
printf_hexdump(descriptor_value, descriptor_value_len);
#endif
for (i = 0; i < descriptor_len; i++){
bool stored = hids_client_descriptor_storage_store(client, client->service_index, descriptor[i]);
for (i = 0; i < descriptor_value_len; i++){
bool stored = hids_client_descriptor_storage_store(client, client->service_index, descriptor_value[i]);
if (!stored){
client->services[client->service_index].hid_descriptor_status = ERROR_CODE_MEMORY_CAPACITY_EXCEEDED;
break;
@ -1030,7 +1032,6 @@ static void handle_gatt_client_event(uint8_t packet_type, uint16_t channel, uint
hids_finalize_client(client);
break;
}
printf("HIDS_CLIENT_STATE_W2_REPORT_MAP_DISCOVER_CHARACTERISTIC_DESCRIPTORS for service %d\n", client->service_index);
client->state = HIDS_CLIENT_STATE_W2_REPORT_MAP_DISCOVER_CHARACTERISTIC_DESCRIPTORS;
break;

View File

@ -16,4 +16,6 @@ HOGP/RH/HGDC/BV-07-I: h, search for 'HID Characteristic HID_CONTROL_POINT'
HOGP/RH/HGDC/BV-08-I: h, search for 'HID Characteristic PROTOCOL_MODE'
HOGP/RH/HGDC/BV-14-I: b, search for 'Battery Level Characteristic'
HOGP/RH/HGDC/BV-15-I: b, saerch for 'Battery Level Client Characteristic Configuration Descriptor'
HOGP/RH/HGDC/BV-16-I:
HOGP/RH/HGDC/BV-16-I: d
HOGP/RH/HGRF/BV-01-I: h

View File

@ -416,6 +416,7 @@ static void device_information_service_gatt_client_event_handler(uint8_t packet_
switch (status){
case ERROR_CODE_SUCCESS:
app_state = READY;
printf("Device Information service found\n");
break;
default:
printf("Device Information service client connection failed, err 0x%02x.\n", status);