hfp_ag: trigger codec exchange and disconnect after all other state machines

This commit is contained in:
Matthias Ringwald 2021-03-30 13:52:44 +02:00
parent fe62696f0f
commit d0a0eceeda
2 changed files with 18 additions and 26 deletions

View File

@ -35,7 +35,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- GAP: calculate IO Cap AuthReq Bondable Mode based on `gap_ssp_set_authentication_requirement` and `gap_set_bondable_mode`
- GAP: only store link key for ssp if remote side has set bondable in io cap auth requirements as well
- HFP HF: only emit single event for RING and AG Status updates
- HFP AG: fix audio connection setup for in-band ringtone on incoming connection
### Changed
- HCI: config I2S for BCM Controllers if `ENABLE_SCO_OVER_PCM`, reduce bit clock to 256/512 kHz
- btstack_uart_posix: supports SLIP frames and replaces `btstack_uart_block_posix`

View File

@ -1777,25 +1777,6 @@ static void hfp_ag_run_for_context(hfp_connection_t *hfp_connection){
int cmd_sent = hfp_ag_send_commands(hfp_connection);
// trigger codec exchange if requested by app
if (hfp_connection->trigger_codec_exchange){
log_info("trigger codec, command %u, codec state %u", hfp_connection->command, hfp_connection->codecs_state);
}
if (hfp_connection->trigger_codec_exchange && (hfp_connection->command == HFP_CMD_NONE)){
switch (hfp_connection->codecs_state){
case HFP_CODECS_IDLE:
case HFP_CODECS_RECEIVED_LIST:
case HFP_CODECS_AG_RESEND_COMMON_CODEC:
case HFP_CODECS_ERROR:
hfp_connection->trigger_codec_exchange = 0;
hfp_connection->command = HFP_CMD_AG_SEND_COMMON_CODEC;
break;
default:
break;
}
}
if (!cmd_sent){
cmd_sent = hfp_ag_run_for_context_service_level_connection(hfp_connection);
}
@ -1812,17 +1793,27 @@ static void hfp_ag_run_for_context(hfp_connection_t *hfp_connection){
cmd_sent = hfp_ag_run_for_audio_connection(hfp_connection);
}
if ((hfp_connection->command == HFP_CMD_NONE) && !cmd_sent){
// log_info("hfp_connection->command == HFP_CMD_NONE");
switch(hfp_connection->state){
case HFP_W2_DISCONNECT_RFCOMM:
hfp_connection->state = HFP_W4_RFCOMM_DISCONNECTED;
rfcomm_disconnect(hfp_connection->rfcomm_cid);
// trigger codec exchange
if (!cmd_sent && (hfp_connection->command == HFP_CMD_NONE) && hfp_connection->trigger_codec_exchange){
log_info("trigger codec, command %u, codec state %u", hfp_connection->command, hfp_connection->codecs_state);
switch (hfp_connection->codecs_state){
case HFP_CODECS_IDLE:
case HFP_CODECS_RECEIVED_LIST:
case HFP_CODECS_AG_RESEND_COMMON_CODEC:
case HFP_CODECS_ERROR:
hfp_connection->trigger_codec_exchange = 0;
hfp_connection->command = HFP_CMD_AG_SEND_COMMON_CODEC;
break;
default:
break;
}
}
// disconnect
if (!cmd_sent && (hfp_connection->command == HFP_CMD_NONE) && (hfp_connection->state == HFP_W2_DISCONNECT_RFCOMM)){
hfp_connection->state = HFP_W4_RFCOMM_DISCONNECTED;
rfcomm_disconnect(hfp_connection->rfcomm_cid);
}
if (cmd_sent){
hfp_connection->command = HFP_CMD_NONE;