mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-04-17 02:42:33 +00:00
hfp: add indicator value test, add audio con sm to hf
This commit is contained in:
parent
bf26b831dd
commit
c5fff38cd5
@ -1040,8 +1040,8 @@ void hfp_parse(hfp_connection_t * context, uint8_t byte, int isHandsFree){
|
||||
log_info("Parsed Enable AG indicator %u('%s'): %u\n", context->parser_item_index,
|
||||
context->ag_indicators[context->parser_item_index].name, value);
|
||||
} else {
|
||||
log_info("Parsed Enable AG indicator %u('%s') - ignore (mandatory)\n",
|
||||
context->parser_item_index, context->ag_indicators[context->parser_item_index].name);
|
||||
log_info("Parsed Enable AG indicator %u('%s') - mandatory indicator, ignore value %u\n",
|
||||
context->parser_item_index, context->ag_indicators[context->parser_item_index].name, value);
|
||||
}
|
||||
context->parser_item_index++;
|
||||
break;
|
||||
|
20
src/hfp_hf.c
20
src/hfp_hf.c
@ -398,6 +398,24 @@ static int codecs_exchange_state_machine(hfp_connection_t * context){
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int hfp_hf_run_for_audio_connection(hfp_connection_t * context){
|
||||
if (context->state < HFP_SERVICE_LEVEL_CONNECTION_ESTABLISHED ||
|
||||
context->state > HFP_W2_DISCONNECT_SCO) return 0;
|
||||
|
||||
|
||||
if (context->state == HFP_AUDIO_CONNECTION_ESTABLISHED && context->release_audio_connection){
|
||||
context->state = HFP_W4_SCO_DISCONNECTED;
|
||||
context->release_audio_connection = 0;
|
||||
gap_disconnect(context->sco_handle);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (context->state == HFP_AUDIO_CONNECTION_ESTABLISHED) return 0;
|
||||
|
||||
// run codecs exchange
|
||||
return codecs_exchange_state_machine(context);
|
||||
}
|
||||
|
||||
static void hfp_run_for_context(hfp_connection_t * context){
|
||||
if (!context) return;
|
||||
if (!rfcomm_can_send_packet_now(context->rfcomm_cid)) return;
|
||||
@ -407,7 +425,7 @@ static void hfp_run_for_context(hfp_connection_t * context){
|
||||
done = hfp_hf_run_for_context_service_level_connection_queries(context);
|
||||
}
|
||||
if (!done){
|
||||
done = codecs_exchange_state_machine(context);
|
||||
done = hfp_hf_run_for_audio_connection(context);
|
||||
}
|
||||
|
||||
if (done) return;
|
||||
|
@ -169,7 +169,7 @@ TEST(HFPParser, HFP_AG_ENABLE_INDIVIDUAL_INDICATOR_STATUS_UPDATE){
|
||||
}
|
||||
}
|
||||
|
||||
TEST(HFPParser, HFP_AG_ENABLE_INDIVIDUAL_INDICATOR_STATUS_UPDATE_OPT_VALUES){
|
||||
TEST(HFPParser, HFP_AG_ENABLE_INDIVIDUAL_INDICATOR_STATUS_UPDATE_OPT_VALUES2){
|
||||
set_hfp_ag_indicators((hfp_ag_indicator_t *)&hfp_ag_indicators, hfp_ag_indicators_nr);
|
||||
context.ag_indicators_nr = hfp_ag_indicators_nr;
|
||||
memcpy(context.ag_indicators, hfp_ag_indicators, hfp_ag_indicators_nr * sizeof(hfp_ag_indicator_t));
|
||||
@ -195,6 +195,32 @@ TEST(HFPParser, HFP_AG_ENABLE_INDIVIDUAL_INDICATOR_STATUS_UPDATE_OPT_VALUES){
|
||||
}
|
||||
}
|
||||
|
||||
TEST(HFPParser, HFP_AG_ENABLE_INDIVIDUAL_INDICATOR_STATUS_UPDATE_OPT_VALUES1){
|
||||
set_hfp_ag_indicators((hfp_ag_indicator_t *)&hfp_ag_indicators, hfp_ag_indicators_nr);
|
||||
context.ag_indicators_nr = hfp_ag_indicators_nr;
|
||||
memcpy(context.ag_indicators, hfp_ag_indicators, hfp_ag_indicators_nr * sizeof(hfp_ag_indicator_t));
|
||||
|
||||
for (pos = 0; pos < hfp_ag_indicators_nr; pos++){
|
||||
CHECK_EQUAL(get_hfp_ag_indicators(&context)[pos].index, hfp_ag_indicators[pos].index);
|
||||
CHECK_EQUAL(get_hfp_ag_indicators(&context)[pos].enabled, hfp_ag_indicators[pos].enabled);
|
||||
CHECK_EQUAL(context.ag_indicators[pos].index, hfp_ag_indicators[pos].index);
|
||||
CHECK_EQUAL(context.ag_indicators[pos].enabled, hfp_ag_indicators[pos].enabled);
|
||||
}
|
||||
|
||||
sprintf(packet, "\r\nAT%s=1,,,1,1,,1\r\n",
|
||||
HFP_UPDATE_ENABLE_STATUS_FOR_INDIVIDUAL_AG_INDICATORS);
|
||||
for (pos = 0; pos < strlen(packet); pos++){
|
||||
hfp_parse(&context, packet[pos], 0);
|
||||
}
|
||||
|
||||
CHECK_EQUAL(HFP_CMD_ENABLE_INDIVIDUAL_AG_INDICATOR_STATUS_UPDATE, context.command);
|
||||
|
||||
for (pos = 0; pos < hfp_ag_indicators_nr; pos++){
|
||||
CHECK_EQUAL(get_hfp_ag_indicators(&context)[pos].enabled, 1);
|
||||
CHECK_EQUAL(context.ag_indicators[pos].enabled, 1);
|
||||
}
|
||||
}
|
||||
|
||||
TEST(HFPParser, HFP_AG_HF_QUERY_OPERATOR_SELECTION){
|
||||
context.network_operator.format = 0xff;
|
||||
sprintf(packet, "\r\nAT%s=3,0\r\n", HFP_QUERY_OPERATOR_SELECTION);
|
||||
|
@ -237,11 +237,9 @@ TEST(HFPClient, HFAudioConnectionEstablishedWithoutCodecNegotiation){
|
||||
setup_hfp_codecs_connection(default_cc_setup(), default_cc_setup_size());
|
||||
CHECK_EQUAL(codecs_connection_established, 1);
|
||||
|
||||
// hfp_hf_establish_audio_connection(device_addr);
|
||||
// CHECK_EQUAL(audio_connection_established, 1);
|
||||
|
||||
// hfp_hf_release_audio_connection(device_addr);
|
||||
// CHECK_EQUAL(audio_connection_established, 0);
|
||||
hfp_hf_establish_audio_connection(device_addr);
|
||||
hfp_hf_release_audio_connection(device_addr);
|
||||
CHECK_EQUAL(audio_connection_established, 0);
|
||||
}
|
||||
|
||||
TEST(HFPClient, HFCodecsConnectionEstablished){
|
||||
|
Loading…
x
Reference in New Issue
Block a user