This commit is contained in:
Matthias Ringwald 2016-07-28 13:58:01 +02:00
commit ba3eebad97
5 changed files with 45 additions and 22 deletions

View File

@ -525,7 +525,7 @@ void hfp_handle_hci_event(uint8_t packet_type, uint16_t channel, uint8_t *packet
hfp_connection = provide_hfp_connection_context_for_bd_addr(event_addr);
if (!hfp_connection) break;
hfp_connection->ag_establish_eSCO = 1;
hfp_connection->ag_establish_SCO = 1;
break;
case RFCOMM_EVENT_INCOMING_CONNECTION:
@ -590,7 +590,7 @@ void hfp_handle_hci_event(uint8_t packet_type, uint16_t channel, uint8_t *packet
log_error("HFP: connection does not exist for remote with addr %s.", bd_addr_to_str(event_addr));
return;
}
hfp_connection->ag_establish_eSCO = 0;
hfp_connection->ag_establish_SCO = 0;
status = hci_event_synchronous_connection_complete_get_status(packet);
if (status != 0){

View File

@ -561,7 +561,7 @@ typedef struct hfp_connection {
uint8_t send_response_and_hold_status; // 0 - don't send. BRTH:0 == 1, ..
// AG only
uint8_t ag_establish_eSCO;
uint8_t ag_establish_SCO;
uint8_t change_in_band_ring_tone_setting;
uint8_t ag_ring;
uint8_t ag_send_clip;

View File

@ -1626,17 +1626,28 @@ static void hfp_run_for_context(hfp_connection_t *hfp_connection){
if (!hfp_connection->rfcomm_cid) return;
if (hfp_connection->ag_establish_eSCO && hci_can_send_command_packet_now()){
if (hfp_connection->ag_establish_SCO && hci_can_send_command_packet_now()){
// remote supported feature eSCO is set if link type is eSCO
// eSCO: S4 - max latency == transmission interval = 0x000c == 12 ms,
uint16_t max_latency = 0x000c;
uint8_t retransmission_effort = 0x02;
uint16_t packet_types = 0x388;
uint16_t sco_voice_setting = hci_get_sco_voice_setting();
uint16_t max_latency;
uint8_t retransmission_effort;
uint16_t packet_types;
if (hci_remote_esco_supported(hfp_connection->acl_handle)){
max_latency = 0x000c;
retransmission_effort = 0x02;
packet_types = 0x388;
} else {
max_latency = 0xffff;
retransmission_effort = 0xff;
packet_types = 0x003f;
}
uint16_t sco_voice_setting = hci_get_sco_voice_setting();
if (hfp_connection->negotiated_codec == HFP_CODEC_MSBC){
sco_voice_setting = 0x0003; // Transparent data
}
log_info("HFP: sending hci_accept_connection_request, sco_voice_setting %02x", sco_voice_setting);
hci_send_cmd(&hci_accept_synchronous_connection, hfp_connection->remote_addr, 8000, 8000, max_latency,
sco_voice_setting, retransmission_effort, packet_types);

View File

@ -92,7 +92,7 @@ static uint8_t ag_send_ok = 0;
static uint8_t ag_send_error = 0;
static uint8_t ag_num_button_press_received = 0;
static uint8_t ag_support_custom_commands = 0;
static uint8_t ag_establish_eSCO = 0;
static uint8_t ag_establish_SCO = 0;
static uint8_t hsp_disconnect_rfcomm = 0;
static uint8_t hsp_establish_audio_connection = 0;
static uint8_t hsp_release_audio_connection = 0;
@ -381,9 +381,29 @@ void hsp_ag_stop_ringing(void){
}
static void hsp_run(void){
if (ag_establish_eSCO && hci_can_send_command_packet_now()){
if (ag_establish_SCO && hci_can_send_command_packet_now()){
log_info("HSP: sending hci_accept_connection_request.");
hci_send_cmd(&hci_accept_synchronous_connection, sco_event_addr, 8000, 8000, 0xFFFF, hci_get_sco_voice_setting(), 0xFF, 0x003F);
// remote supported feature eSCO is set if link type is eSCO
// eSCO: S4 - max latency == transmission interval = 0x000c == 12 ms,
uint16_t max_latency;
uint8_t retransmission_effort;
uint16_t packet_types;
if (hci_remote_esco_supported(rfcomm_handle)){
max_latency = 0x000c;
retransmission_effort = 0x02;
packet_types = 0x388;
} else {
max_latency = 0xffff;
retransmission_effort = 0xff;
packet_types = 0x003f;
}
uint16_t sco_voice_setting = hci_get_sco_voice_setting();
log_info("HFP: sending hci_accept_connection_request, sco_voice_setting %02x", sco_voice_setting);
hci_send_cmd(&hci_accept_synchronous_connection, remote, 8000, 8000, max_latency,
sco_voice_setting, retransmission_effort, packet_types);
return;
}
@ -566,10 +586,10 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack
case HCI_EVENT_CONNECTION_REQUEST:
printf("hsp HCI_EVENT_CONNECTION_REQUEST\n");
hci_event_connection_request_get_bd_addr(packet, sco_event_addr);
ag_establish_eSCO = 1;
ag_establish_SCO = 1;
break;
case HCI_EVENT_SYNCHRONOUS_CONNECTION_COMPLETE:{
ag_establish_eSCO = 0;
ag_establish_SCO = 0;
uint8_t status = hci_event_synchronous_connection_complete_get_status(packet);
if (status != 0){
log_error("(e)SCO Connection failed, status %u", status);

View File

@ -2542,14 +2542,6 @@ static void hci_run(void){
connection->role = HCI_ROLE_SLAVE;
if (connection->address_type == BD_ADDR_TYPE_CLASSIC){
hci_send_cmd(&hci_accept_connection_request, connection->address, 1);
} else {
// remote supported feature eSCO is set if link type is eSCO
if (connection->remote_supported_feature_eSCO) return;
// SCO: max latency, retransmission interval: N/A. any packet type
uint16_t max_latency = 0xffff;
uint8_t retransmission_effort = 0xff;
uint16_t packet_types = 0x003f;
hci_send_cmd(&hci_accept_synchronous_connection, connection->address, 8000, 8000, max_latency, hci_stack->sco_voice_setting, retransmission_effort, packet_types);
}
return;