gap: support sniff subrating

This commit is contained in:
Matthias Ringwald 2021-04-07 12:04:13 +02:00
parent 580d6bb47e
commit 140c055723
4 changed files with 33 additions and 1 deletions

View File

@ -23,6 +23,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- GATT Client: Scan Parameters Service Client
- GATT Client: HID-over-GATT (HOG) Client, Report and Boot Host
- GAP: add `gap_set_page_scan_activity` and `gap_set_page_scan_type`
- GAP: support sniff subrating with `gap_sniff_subrating_configure`
- AVRCP: new field `button_pressed` in `AVRCP_SUBEVENT_OPERATION`
- AVRCP: `AVRCP_SUBEVENT_OPERATION` emitted for button release
- AVRCP Controller: avrcp_controller_start_press_and_hold_cmd helps to support device buttons

View File

@ -801,6 +801,15 @@ uint8_t gap_sniff_mode_enter(hci_con_handle_t con_handle, uint16_t sniff_min_int
*/
uint8_t gap_sniff_mode_exit(hci_con_handle_t con_handle);
/**
* @brief Configure Sniff Subrating
* @param con_handle
* @param max_latency range: 0x0002 to 0xFFFE; Time = N * 0.625 ms
* @param min_remote_timeout range: 0x0002 to 0xFFFE; Time = N * 0.625 ms
* @param min_local_timeout range: 0x0002 to 0xFFFE; Time = N * 0.625 ms
*/
uint8_t gap_sniff_subrating_configure(hci_con_handle_t con_handle, uint16_t max_latency, uint16_t min_remote_timeout, uint16_t min_local_timeout);
// LE
/**

View File

@ -212,6 +212,7 @@ static hci_connection_t * create_connection_for_bd_addr_and_type(const bd_addr_t
conn->requested_security_level = LEVEL_0;
#ifdef ENABLE_CLASSIC
conn->request_role = HCI_ROLE_INVALID;
conn->sniff_subrating_max_latency = 0xffff;
btstack_run_loop_set_timer_handler(&conn->timeout, hci_connection_timeout_handler);
btstack_run_loop_set_timer_context(&conn->timeout, conn);
hci_connection_timestamp(conn);
@ -4493,8 +4494,15 @@ static bool hci_run_general_pending_commands(void){
return true;
}
if (connection->sniff_subrating_max_latency != 0xffff){
uint16_t max_latency = connection->sniff_subrating_max_latency;
connection->sniff_subrating_max_latency = 0;
hci_send_cmd(&hci_sniff_subrating, connection->con_handle, max_latency, connection->sniff_subrating_min_remote_timeout, connection->sniff_subrating_min_local_timeout);
return true;
}
if (connection->request_role != HCI_ROLE_INVALID){
hci_role_t role = connection->request_role;
hci_role_t role = connection->request_role;
connection->request_role = HCI_ROLE_INVALID;
hci_send_cmd(&hci_switch_role_command, connection->address, role);
return true;
@ -6357,6 +6365,15 @@ uint8_t gap_sniff_mode_exit(hci_con_handle_t con_handle){
return 0;
}
uint8_t gap_sniff_subrating_configure(hci_con_handle_t con_handle, uint16_t max_latency, uint16_t min_remote_timeout, uint16_t min_local_timeout){
hci_connection_t * conn = hci_connection_for_handle(con_handle);
if (!conn) return GAP_CONNECTION_INVALID;
conn->sniff_subrating_max_latency = max_latency;
conn->sniff_subrating_min_remote_timeout = min_remote_timeout;
conn->sniff_subrating_min_local_timeout = min_local_timeout;
hci_run();
}
void gap_set_page_scan_activity(uint16_t page_scan_interval, uint16_t page_scan_window){
hci_stack->new_page_scan_interval = page_scan_interval;
hci_stack->new_page_scan_window = page_scan_window;

View File

@ -541,6 +541,11 @@ typedef struct {
uint16_t sniff_attempt;
uint16_t sniff_timeout;
// sniff subrating
uint16_t sniff_subrating_max_latency; // 0xffff = not set
uint16_t sniff_subrating_min_remote_timeout;
uint16_t sniff_subrating_min_local_timeout;
#ifdef ENABLE_SCO_OVER_HCI
// track SCO rx event
uint32_t sco_rx_ms;