hid_host: emit HID_SUBEVENT_SNIFF_SUBRATING_PARAMS event

This commit is contained in:
Milanka Ringwald 2021-04-07 11:52:12 +02:00
parent fee1f3a79e
commit 580d6bb47e
4 changed files with 65 additions and 2 deletions

View File

@ -195,6 +195,23 @@ static void hid_emit_descriptor_available_event(hid_host_connection_t * connecti
hid_callback(HCI_EVENT_PACKET, connection->hid_cid, &event[0], pos); hid_callback(HCI_EVENT_PACKET, connection->hid_cid, &event[0], pos);
} }
static void hid_emit_sniff_params_event(hid_host_connection_t * connection){
uint8_t event[9];
uint16_t pos = 0;
event[pos++] = HCI_EVENT_HID_META;
pos++; // skip len
event[pos++] = HID_SUBEVENT_SNIFF_SUBRATING_PARAMS;
little_endian_store_16(event,pos,connection->hid_cid);
pos += 2;
little_endian_store_16(event,pos,connection->host_max_latency);
pos += 2;
little_endian_store_16(event,pos,connection->host_min_timeout);
pos += 2;
event[1] = pos - 2;
hid_callback(HCI_EVENT_PACKET, connection->hid_cid, &event[0], pos);
}
static void hid_emit_event(hid_host_connection_t * connection, uint8_t subevent_type){ static void hid_emit_event(hid_host_connection_t * connection, uint8_t subevent_type){
uint8_t event[5]; uint8_t event[5];
uint16_t pos = 0; uint16_t pos = 0;
@ -455,6 +472,29 @@ static void hid_host_handle_sdp_client_query_result(uint8_t packet_type, uint16_
} }
} }
break; break;
case BLUETOOTH_ATTRIBUTE_HIDSSR_HOST_MAX_LATENCY:
if (de_get_element_type(attribute_value) == DE_UINT) {
uint16_t host_max_latency;
if (de_element_get_uint16(attribute_value, &host_max_latency) == 1){
connection->host_max_latency = host_max_latency;
} else {
connection->host_max_latency = 0xFFFF;
}
}
break;
case BLUETOOTH_ATTRIBUTE_HIDSSR_HOST_MIN_TIMEOUT:
if (de_get_element_type(attribute_value) == DE_UINT) {
uint16_t host_min_timeout;
if (de_element_get_uint16(attribute_value, &host_min_timeout) == 1){
connection->host_min_timeout = host_min_timeout;
} else {
connection->host_min_timeout = 0xFFFF;
}
}
break;
default: default:
break; break;
} }
@ -502,6 +542,8 @@ static void hid_host_handle_sdp_client_query_result(uint8_t packet_type, uint16_
break; break;
} }
hid_emit_sniff_params_event(connection);
if (try_fallback_to_boot){ if (try_fallback_to_boot){
if (connection->incoming){ if (connection->incoming){
connection->set_protocol = true; connection->set_protocol = true;

View File

@ -97,6 +97,9 @@ typedef struct {
bool w4_set_protocol_response; bool w4_set_protocol_response;
hid_protocol_mode_t requested_protocol_mode; hid_protocol_mode_t requested_protocol_mode;
uint16_t host_max_latency;
uint16_t host_min_timeout;
uint16_t hid_descriptor_offset; uint16_t hid_descriptor_offset;
uint16_t hid_descriptor_len; uint16_t hid_descriptor_len;
uint16_t hid_descriptor_max_len; uint16_t hid_descriptor_max_len;

View File

@ -19,6 +19,9 @@ HID11/HOS/HCR/BV-02-I: c, c, (Confirmation), (Confirmation)
HID11/HOS/HCR/BV-03-I: c, U, c, "OK", u HID11/HOS/HCR/BV-03-I: c, U, c, "OK", u
HID11/HOS/HCR/BV-04-I: c, c, (ok) HID11/HOS/HCR/BV-04-I: c, c, (ok)
HID11/HOS/HGR/BV-02-C: rm /tmp/btstack*.tlv, c, y, w
HID11/HOS/HGR/BV-03-C: rm /tmp/btstack*.tlv, c, y
HID11/HOS/HCT/BV-01-C: c, 1, 2, 3 HID11/HOS/HCT/BV-01-C: c, 1, 2, 3
HID11/HOS/HCT/BV-02-C: c, 4 HID11/HOS/HCT/BV-02-C: c, 4
HID11/HOS/HCT/BV-03-C: c, 5 HID11/HOS/HCT/BV-03-C: c, 5

View File

@ -123,6 +123,8 @@ static uint8_t hid_descriptor[MAX_ATTRIBUTE_VALUE_SIZE];
static const char * remote_addr_string = "00:1B:DC:08:E2:5C"; static const char * remote_addr_string = "00:1B:DC:08:E2:5C";
static bd_addr_t remote_addr; static bd_addr_t remote_addr;
static uint16_t host_max_latency;
static uint16_t host_min_timeout;
static btstack_packet_callback_registration_t hci_event_callback_registration; static btstack_packet_callback_registration_t hci_event_callback_registration;
static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size); static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size);
@ -288,6 +290,11 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack
printf("HID Host connected...\n"); printf("HID Host connected...\n");
break; break;
case HID_SUBEVENT_SNIFF_SUBRATING_PARAMS:
host_max_latency = hid_subevent_sniff_subrating_params_get_host_max_latency(packet);
host_min_timeout = hid_subevent_sniff_subrating_params_get_host_min_timeout(packet);
break;
case HID_SUBEVENT_DESCRIPTOR_AVAILABLE: case HID_SUBEVENT_DESCRIPTOR_AVAILABLE:
status = hid_subevent_descriptor_available_get_status(packet); status = hid_subevent_descriptor_available_get_status(packet);
if (status == ERROR_CODE_SUCCESS){ if (status == ERROR_CODE_SUCCESS){
@ -410,7 +417,9 @@ static void show_usage(void){
printf("b - Set protocol in BOOT mode\n"); printf("b - Set protocol in BOOT mode\n");
printf("\n"); printf("\n");
printf("z - set link supervision timeout to 0\n"); printf("y - set link supervision timeout to 0\n");
printf("w - send sniff subrating cmd\n");
printf("Ctrl-c - exit\n"); printf("Ctrl-c - exit\n");
printf("---\n"); printf("---\n");
} }
@ -530,10 +539,16 @@ static void stdin_process(char cmd){
break; break;
} }
case 'z': case 'y':
printf("Set link supervision timeout to 0 \n"); printf("Set link supervision timeout to 0 \n");
hci_send_cmd(&hci_write_link_supervision_timeout, hid_host_con_handle, 0); hci_send_cmd(&hci_write_link_supervision_timeout, hid_host_con_handle, 0);
break; break;
case 'w':
printf("Send sniff subrating cmd \n");
hci_send_cmd(&hci_sniff_subrating, hid_host_con_handle, host_max_latency, host_min_timeout, 0);
break;
case '\n': case '\n':
case '\r': case '\r':
break; break;