example/hfp_hf_demo: support lc3-swb

This commit is contained in:
Matthias Ringwald 2023-03-02 10:55:02 +01:00
parent 5a5b7bc7b0
commit d0452d6c2c

View File

@ -81,40 +81,34 @@ static void show_usage(void);
#endif
static hci_con_handle_t acl_handle = HCI_CON_HANDLE_INVALID;
static hci_con_handle_t sco_handle = HCI_CON_HANDLE_INVALID;
static uint8_t codecs[] = {
HFP_CODEC_CVSD,
#ifdef ENABLE_HFP_WIDE_BAND_SPEECH
static uint8_t codecs[] = {HFP_CODEC_CVSD, HFP_CODEC_MSBC};
#else
static uint8_t codecs[] = {HFP_CODEC_CVSD};
HFP_CODEC_MSBC,
#endif
#ifdef ENABLE_HFP_SUPER_WIDE_BAND_SPEECH
HFP_CODEC_LC3_SWB,
#endif
};
static uint16_t indicators[1] = {0x01};
static uint8_t negotiated_codec = HFP_CODEC_CVSD;
static btstack_packet_callback_registration_t hci_event_callback_registration;
static char cmd;
static void dump_supported_codecs(void){
unsigned int i;
int mSBC_skipped = 0;
printf("Supported codecs: ");
for (i = 0; i < sizeof(codecs); i++){
switch(codecs[i]){
case HFP_CODEC_CVSD:
printf("CVSD");
break;
case HFP_CODEC_MSBC:
if (hci_extended_sco_link_supported()){
printf(", mSBC");
} else {
mSBC_skipped = 1;
}
break;
default:
btstack_assert(false);
break;
}
}
printf("\n");
if (mSBC_skipped){
printf("mSBC codec disabled because eSCO not supported by local controller.\n");
printf("Supported codecs: CVSD");
if (hci_extended_sco_link_supported()) {
#ifdef ENABLE_HFP_WIDE_BAND_SPEECH
printf(", mSBC");
#endif
#ifdef ENABLE_HFP_SUPER_WIDE_BAND_SPEECH
printf(", LC3-SWB");
#endif
printf("\n");
} else {
printf("\nmSBC and/or LC3-SWB disabled as eSCO not supported by local controller.\n");
}
}
@ -548,12 +542,15 @@ static void hfp_hf_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t
printf("Audio connection established with SCO handle 0x%04x.\n", sco_handle);
negotiated_codec = hfp_subevent_audio_connection_established_get_negotiated_codec(event);
switch (negotiated_codec){
case 0x01:
case HFP_CODEC_CVSD:
printf("Using CVSD codec.\n");
break;
case 0x02:
case HFP_CODEC_MSBC:
printf("Using mSBC codec.\n");
break;
case HFP_CODEC_LC3_SWB:
printf("Using LC3-SWB codec.\n");
break;
default:
printf("Using unknown codec 0x%02x.\n", negotiated_codec);
break;