diff --git a/src/hci.c b/src/hci.c index 1870ba678..7d2d9def9 100644 --- a/src/hci.c +++ b/src/hci.c @@ -1403,9 +1403,12 @@ static void event_handler(uint8_t *packet, int size){ if (features[6] & (1 << 3)){ conn->bonding_flags |= BONDING_REMOTE_SUPPORTS_SSP; } + if (features[3] & (1<<7)){ + conn->remote_supported_feature_eSCO = 1; + } } conn->bonding_flags |= BONDING_RECEIVED_REMOTE_FEATURES; - log_info("HCI_EVENT_READ_REMOTE_SUPPORTED_FEATURES_COMPLETE, bonding flags %x", conn->bonding_flags); + log_info("HCI_EVENT_READ_REMOTE_SUPPORTED_FEATURES_COMPLETE, bonding flags %x, eSCO %u", conn->bonding_flags, conn->remote_supported_feature_eSCO); if (conn->bonding_flags & BONDING_DEDICATED){ conn->bonding_flags |= BONDING_SEND_AUTHENTICATE_REQUEST; } @@ -2325,7 +2328,13 @@ void hci_run(void){ if (connection->address_type == BD_ADDR_TYPE_CLASSIC){ hci_send_cmd(&hci_accept_connection_request, connection->address, 1); } else { - hci_send_cmd(&hci_accept_synchronous_connection, connection->address, 8000, 8000, 0xFFFF, hci_stack->sco_voice_setting, 0xFF, 0x003F); + if (connection->remote_supported_feature_eSCO){ + // S4 - max latency == transmission interval = 0x000c == 12 ms + hci_send_cmd(&hci_accept_synchronous_connection, connection->address, 8000, 8000, 0x000c, hci_stack->sco_voice_setting, 0x02, 0x003f); + } else { + // max latency, retransmission interval: N/A. any packet type + hci_send_cmd(&hci_accept_synchronous_connection, connection->address, 8000, 8000, 0x000c, hci_stack->sco_voice_setting, 0xff, 0x003f); + } } return; @@ -2889,6 +2898,13 @@ void hci_emit_dedicated_bonding_result(bd_addr_t address, uint8_t status){ hci_stack->packet_handler(HCI_EVENT_PACKET, event, sizeof(event)); } +// query if remote side supports eSCO +int hci_remote_eSCO_supported(hci_con_handle_t con_handle){ + hci_connection_t * connection = hci_connection_for_handle(con_handle); + if (!connection) return 0; + return connection->remote_supported_feature_eSCO; +} + // query if remote side supports SSP int hci_remote_ssp_supported(hci_con_handle_t con_handle){ hci_connection_t * connection = hci_connection_for_handle(con_handle); diff --git a/src/hci.h b/src/hci.h index 69b1a1276..1cd24df9a 100644 --- a/src/hci.h +++ b/src/hci.h @@ -513,6 +513,9 @@ typedef struct { // link_key_type_t link_key_type; + // remote supported features + uint8_t remote_supported_feature_eSCO; + // errands uint32_t authentication_flags; @@ -850,6 +853,8 @@ void hci_disconnect_security_block(hci_con_handle_t con_handle); // send complete CMD packet int hci_send_cmd_packet(uint8_t *packet, int size); +// query if remote side supports eSCO +int hci_remote_eSCO_supported(hci_con_handle_t con_handle); /* API_START */