mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-31 10:20:58 +00:00
hfp: use 'don't care' to accept SCO connections, fixes issue on ESP32
This commit is contained in:
parent
f823745acb
commit
c528139d1e
@ -10,6 +10,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
||||
|
||||
### Added
|
||||
### Fixed
|
||||
- HFP: use 'don't care' to accept SCO connections, fixes issue on ESP32
|
||||
|
||||
### Changed
|
||||
- btstack_crypto: allow MBEDTLS config via MBEDTLS_CONFIG_FILE
|
||||
|
||||
|
@ -122,20 +122,6 @@ static const struct {
|
||||
{0x000d, 0x02, SCO_PACKET_TYPES_2EV3, CODEC_MASK_OTHER} // HFP_LINK_SETTINGS_T2
|
||||
};
|
||||
|
||||
// table 5.8 'mandatory safe settings' for eSCO + similar entries for SCO
|
||||
static const struct hfp_mandatory_safe_setting {
|
||||
const uint8_t codec_mask;
|
||||
const bool secure_connection_in_use;
|
||||
hfp_link_settings_t link_setting;
|
||||
} hfp_mandatory_safe_settings[] = {
|
||||
{ CODEC_MASK_CVSD, false, HFP_LINK_SETTINGS_D1},
|
||||
{ CODEC_MASK_CVSD, true, HFP_LINK_SETTINGS_D1},
|
||||
{ CODEC_MASK_CVSD, false, HFP_LINK_SETTINGS_S1},
|
||||
{ CODEC_MASK_CVSD, true, HFP_LINK_SETTINGS_S4},
|
||||
{ CODEC_MASK_OTHER, false, HFP_LINK_SETTINGS_T1},
|
||||
{ CODEC_MASK_OTHER, true, HFP_LINK_SETTINGS_T2},
|
||||
};
|
||||
|
||||
static const char * hfp_hf_features[] = {
|
||||
"EC and/or NR function",
|
||||
"Three-way calling",
|
||||
@ -1939,34 +1925,11 @@ void hfp_setup_synchronous_connection(hfp_connection_t * hfp_connection){
|
||||
sco_voice_setting, hfp_link_settings[setting].retransmission_effort, packet_types_flipped);
|
||||
}
|
||||
|
||||
hfp_link_settings_t hfp_safe_settings_for_context(bool use_eSCO, uint8_t negotiated_codec, bool secure_connection_in_use){
|
||||
uint8_t i;
|
||||
hfp_link_settings_t link_setting = HFP_LINK_SETTINGS_NONE;
|
||||
for (i=0 ; i < (sizeof(hfp_mandatory_safe_settings) / sizeof(struct hfp_mandatory_safe_setting)) ; i++){
|
||||
uint16_t packet_types = hfp_link_settings[(uint8_t)(hfp_mandatory_safe_settings[i].link_setting)].packet_types;
|
||||
bool is_eSCO_setting = (packet_types & SCO_PACKET_TYPES_ESCO) != 0;
|
||||
if (is_eSCO_setting != use_eSCO) continue;
|
||||
if ((hfp_mandatory_safe_settings[i].codec_mask & (1 << negotiated_codec)) == 0) continue;
|
||||
if (hfp_mandatory_safe_settings[i].secure_connection_in_use != secure_connection_in_use) continue;
|
||||
link_setting = hfp_mandatory_safe_settings[i].link_setting;
|
||||
break;
|
||||
}
|
||||
return link_setting;
|
||||
}
|
||||
|
||||
void hfp_accept_synchronous_connection(hfp_connection_t * hfp_connection, bool use_eSCO){
|
||||
|
||||
bool secure_connection_in_use = gap_secure_connection(hfp_connection->acl_handle);
|
||||
|
||||
// lookup safe settings based on SCO type, SC use and Codec type
|
||||
hfp_link_settings_t link_setting = hfp_safe_settings_for_context(use_eSCO, hfp_connection->negotiated_codec, secure_connection_in_use);
|
||||
btstack_assert(link_setting != HFP_LINK_SETTINGS_NONE);
|
||||
|
||||
uint16_t max_latency = hfp_link_settings[(uint8_t) link_setting].max_latency;
|
||||
uint16_t retransmission_effort = hfp_link_settings[(uint8_t) link_setting].retransmission_effort;
|
||||
|
||||
// safer to allow more packet types:
|
||||
uint16_t packet_types = use_eSCO ? (SCO_PACKET_TYPES_EV3 | SCO_PACKET_TYPES_2EV3) : (SCO_PACKET_TYPES_HV1 | SCO_PACKET_TYPES_HV3);
|
||||
// use "don't care" where possible
|
||||
uint16_t max_latency = 0xffff;
|
||||
uint16_t retransmission_effort = 0xff;
|
||||
|
||||
// transparent data for non-CVSD connections or if codec provided by Controller
|
||||
uint16_t sco_voice_setting = hci_get_sco_voice_setting();
|
||||
@ -1979,8 +1942,7 @@ void hfp_accept_synchronous_connection(hfp_connection_t * hfp_connection, bool u
|
||||
}
|
||||
|
||||
// filter packet types
|
||||
packet_types &= hfp_get_sco_packet_types();
|
||||
|
||||
uint16_t packet_types = hfp_get_sco_packet_types();
|
||||
hfp_connection->packet_types = packet_types;
|
||||
|
||||
// bits 6-9 are 'don't allow'
|
||||
|
@ -874,7 +874,6 @@ void hfp_init_link_settings(hfp_connection_t * hfp_connection, uint8_t eSCO_S4_s
|
||||
hfp_link_settings_t hfp_next_link_setting(hfp_link_settings_t current_setting, uint16_t local_sco_packet_types,
|
||||
uint16_t remote_sco_packet_types, bool eSCO_s4_supported,
|
||||
uint8_t negotiated_codec);
|
||||
hfp_link_settings_t hfp_safe_settings_for_context(bool use_eSCO, uint8_t negotiated_codec, bool secure_connection_in_use);
|
||||
|
||||
const char * hfp_hf_feature(int index);
|
||||
const char * hfp_ag_feature(int index);
|
||||
|
Loading…
x
Reference in New Issue
Block a user