mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-24 04:43:36 +00:00
hfp: use default codec
This commit is contained in:
parent
251f271866
commit
555cc8ad1e
@ -353,7 +353,7 @@ static int hfp_ag_cmd_suggest_codec(uint16_t cid, uint8_t codec){
|
||||
|
||||
static uint8_t hfp_ag_suggest_codec(hfp_connection_t *context){
|
||||
int i,j;
|
||||
uint8_t codec = 0;
|
||||
uint8_t codec = HFP_CODEC_CVSD;
|
||||
for (i = 0; i < hfp_codecs_nr; i++){
|
||||
for (j = 0; j < context->remote_codecs_nr; j++){
|
||||
if (context->remote_codecs[j] == hfp_codecs[i]){
|
||||
@ -793,7 +793,7 @@ void hfp_ag_init(uint16_t rfcomm_channel_nr, uint32_t supported_features,
|
||||
rfcomm_register_packet_handler(packet_handler);
|
||||
|
||||
hfp_init(rfcomm_channel_nr);
|
||||
|
||||
|
||||
hfp_supported_features = supported_features;
|
||||
hfp_codecs_nr = codecs_nr;
|
||||
|
||||
@ -804,9 +804,6 @@ void hfp_ag_init(uint16_t rfcomm_channel_nr, uint32_t supported_features,
|
||||
|
||||
hfp_ag_indicators_nr = ag_indicators_nr;
|
||||
memcpy(hfp_ag_indicators, ag_indicators, ag_indicators_nr * sizeof(hfp_ag_indicator_t));
|
||||
for (i=0; i<hfp_ag_indicators_nr; i++){
|
||||
printf("ag ind %s\n", hfp_ag_indicators[i].name);
|
||||
}
|
||||
|
||||
set_hfp_generic_status_indicators(hf_indicators, hf_indicators_nr);
|
||||
|
||||
@ -851,7 +848,6 @@ void hfp_ag_establish_audio_connection(bd_addr_t bd_addr){
|
||||
|
||||
if (!has_codec_negotiation_feature(connection)){
|
||||
log_info("hfp_ag_establish_audio_connection - no codec negotiation feature, using defaults");
|
||||
connection->negotiated_codec = HFP_CODEC_CVSD;
|
||||
connection->codecs_state = HFP_CODECS_EXCHANGED;
|
||||
}
|
||||
|
||||
|
@ -84,6 +84,9 @@ static hfp_ag_indicator_t ag_indicators[] = {
|
||||
{7, "callheld", 0, 2, 0, 1, 1, 0}
|
||||
};
|
||||
|
||||
static int supported_features_with_codec_negotiation = 1007; // 0011 1110 1111
|
||||
static int supported_features_without_codec_negotiation = 495; // 0001 1110 1111
|
||||
|
||||
static int call_hold_services_nr = 5;
|
||||
static const char* call_hold_services[] = {"1", "1x", "2", "2x", "3"};
|
||||
|
||||
@ -186,6 +189,12 @@ TEST_GROUP(HFPClient){
|
||||
service_level_connection_established = 0;
|
||||
codecs_connection_established = 0;
|
||||
audio_connection_established = 0;
|
||||
|
||||
hfp_ag_init(rfcomm_channel_nr, supported_features_with_codec_negotiation,
|
||||
codecs, sizeof(codecs),
|
||||
ag_indicators, ag_indicators_nr,
|
||||
hf_indicators, hf_indicators_nr,
|
||||
call_hold_services, call_hold_services_nr);
|
||||
}
|
||||
|
||||
void teardown(void){
|
||||
@ -226,7 +235,7 @@ TEST(HFPClient, HFAnswerIncomingCallWithInBandRingTone){
|
||||
}
|
||||
|
||||
|
||||
TEST(HFPClient, HFAudioConnectionEstablished){
|
||||
TEST(HFPClient, HFAudioConnectionEstablishedWithCodecNegtiation){
|
||||
setup_hfp_service_level_connection(default_slc_setup(), default_slc_setup_size());
|
||||
CHECK_EQUAL(service_level_connection_established, 1);
|
||||
|
||||
@ -240,6 +249,26 @@ TEST(HFPClient, HFAudioConnectionEstablished){
|
||||
CHECK_EQUAL(audio_connection_established, 0);
|
||||
}
|
||||
|
||||
TEST(HFPClient, HFAudioConnectionEstablishedWithDefaultCodec){
|
||||
hfp_ag_init(rfcomm_channel_nr, supported_features_without_codec_negotiation,
|
||||
codecs, sizeof(codecs),
|
||||
ag_indicators, ag_indicators_nr,
|
||||
hf_indicators, hf_indicators_nr,
|
||||
call_hold_services, call_hold_services_nr);
|
||||
|
||||
setup_hfp_service_level_connection(hfp_slc_tests()[1].test, hfp_slc_tests()[1].len);
|
||||
CHECK_EQUAL(service_level_connection_established, 1);
|
||||
|
||||
setup_hfp_codecs_connection(default_cc_setup(), default_cc_setup_size());
|
||||
CHECK_EQUAL(codecs_connection_established, 1);
|
||||
|
||||
hfp_ag_establish_audio_connection(device_addr);
|
||||
CHECK_EQUAL(audio_connection_established, 1);
|
||||
|
||||
hfp_ag_release_audio_connection(device_addr);
|
||||
CHECK_EQUAL(audio_connection_established, 0);
|
||||
}
|
||||
|
||||
TEST(HFPClient, HFCodecsConnectionEstablished){
|
||||
for (int i = 0; i < cc_tests_size(); i++){
|
||||
setup_hfp_service_level_connection(default_slc_setup(), default_slc_setup_size());
|
||||
@ -259,20 +288,22 @@ TEST(HFPClient, HFServiceLevelConnectionCommands){
|
||||
}
|
||||
}
|
||||
|
||||
TEST(HFPClient, HFServiceLevelConnectionEstablished){
|
||||
for (int i = 0; i < slc_tests_size(); i++){
|
||||
setup_hfp_service_level_connection(hfp_slc_tests()[i].test, hfp_slc_tests()[i].len);
|
||||
CHECK_EQUAL(service_level_connection_established, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int main (int argc, const char * argv[]){
|
||||
hfp_ag_init(rfcomm_channel_nr, 1007, codecs, sizeof(codecs),
|
||||
TEST(HFPClient, HFServiceLevelConnectionEstablishedWithoutCodecNegotiation){
|
||||
hfp_ag_init(rfcomm_channel_nr, supported_features_without_codec_negotiation,
|
||||
codecs, sizeof(codecs),
|
||||
ag_indicators, ag_indicators_nr,
|
||||
hf_indicators, hf_indicators_nr,
|
||||
call_hold_services, call_hold_services_nr);
|
||||
setup_hfp_service_level_connection(hfp_slc_tests()[1].test, hfp_slc_tests()[1].len);
|
||||
CHECK_EQUAL(service_level_connection_established, 1);
|
||||
}
|
||||
|
||||
TEST(HFPClient, HFServiceLevelConnectionEstablishedWithCodecNegotiation){
|
||||
setup_hfp_service_level_connection(hfp_slc_tests()[0].test, hfp_slc_tests()[0].len);
|
||||
CHECK_EQUAL(service_level_connection_established, 1);
|
||||
}
|
||||
|
||||
int main (int argc, const char * argv[]){
|
||||
hfp_ag_register_packet_handler(packet_handler);
|
||||
|
||||
return CommandLineTestRunner::RunAllTests(argc, argv);
|
||||
|
@ -53,6 +53,7 @@
|
||||
|
||||
/* Service Level Connection (slc) test sequences */
|
||||
|
||||
// with codec negotiation feature
|
||||
const char * slc_test1[] = {
|
||||
"AT+BRSF=438",
|
||||
"+BRSF:1007",
|
||||
@ -72,8 +73,27 @@ const char * slc_test1[] = {
|
||||
"OK"
|
||||
};
|
||||
|
||||
// without codec negotiation feature
|
||||
const char * slc_test2[] = {
|
||||
"AT+BRSF=438",
|
||||
"+BRSF:495",
|
||||
"OK",
|
||||
"AT+CIND=?",
|
||||
"+CIND:(\"service\",(0,1)),(\"call\",(0,1)),(\"callsetup\",(0,3)),(\"battchg\",(0,5)),(\"signal\",(0,5)),(\"roam\",(0,1)),(\"callheld\",(0,2))",
|
||||
"OK",
|
||||
"AT+CIND?",
|
||||
"+CIND:1,0,0,3,5,0,0",
|
||||
"OK",
|
||||
"AT+CMER=3,0,0,1",
|
||||
"OK",
|
||||
"AT+CHLD=?",
|
||||
"+CHLD:(1,1x,2,2x,3)",
|
||||
"OK"
|
||||
};
|
||||
|
||||
hfp_test_item_t slc_tests[] = {
|
||||
TEST_SEQUENCE(slc_test1)
|
||||
TEST_SEQUENCE(slc_test1),
|
||||
TEST_SEQUENCE(slc_test2)
|
||||
};
|
||||
|
||||
/* Service Level Connection (slc) common commands */
|
||||
|
Loading…
x
Reference in New Issue
Block a user