diff --git a/src/hfp.c b/src/hfp.c index 825c8663a..a8537d462 100644 --- a/src/hfp.c +++ b/src/hfp.c @@ -1310,6 +1310,7 @@ void hfp_establish_service_level_connection(bd_addr_t bd_addr, uint16_t service_ void hfp_release_service_level_connection(hfp_connection_t * context){ if (!context) return; + hfp_release_audio_connection(context); if (context->state < HFP_W4_RFCOMM_CONNECTED){ context->state = HFP_IDLE; diff --git a/src/hfp.h b/src/hfp.h index 94c13f2a8..f257fab8e 100644 --- a/src/hfp.h +++ b/src/hfp.h @@ -37,13 +37,13 @@ // ***************************************************************************** // -// HFP Hands-Free (HF) unit and Audio-Gateway Commons +// HFP Hands-Free (HF) unit and Audio Gateway Commons // // ***************************************************************************** -#ifndef btstack_hfp_h -#define btstack_hfp_h +#ifndef __BTSTACK_HFP_H +#define __BTSTACK_HFP_H #include "hci.h" #include "sdp_query_rfcomm.h" diff --git a/src/hfp_hf.c b/src/hfp_hf.c index b6a2c32f3..114e29562 100644 --- a/src/hfp_hf.c +++ b/src/hfp_hf.c @@ -120,7 +120,7 @@ static int has_hf_indicators_feature(hfp_connection_t * connection){ static void packet_handler(void * connection, uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size); -void hfp_hf_create_sdp_record(uint8_t * service, int rfcomm_channel_nr, const char * name, uint16_t supported_features){ +void hfp_hf_create_sdp_record(uint8_t * service, int rfcomm_channel_nr, const char * name, uint32_t supported_features){ if (!name){ name = default_hfp_hf_service_name; } @@ -1022,7 +1022,20 @@ static void packet_handler(void * connection, uint8_t packet_type, uint16_t chan hfp_run(); } -void hfp_hf_set_codecs(uint8_t * codecs, int codecs_nr){ +void hfp_hf_init(uint16_t rfcomm_channel_nr){ + l2cap_init(); + l2cap_register_packet_handler(packet_handler); + rfcomm_register_packet_handler(packet_handler); + hfp_init(rfcomm_channel_nr); + + hfp_supported_features = HFP_DEFAULT_HF_SUPPORTED_FEATURES; + hfp_codecs_nr = 0; + hfp_indicators_nr = 0; + hfp_hf_speaker_gain = 9; + hfp_hf_microphone_gain = 9; +} + +void hfp_hf_set_codecs(int codecs_nr, uint8_t * codecs){ if (codecs_nr > HFP_MAX_NUM_CODECS){ log_error("hfp_hf_set_codecs: codecs_nr (%d) > HFP_MAX_NUM_CODECS (%d)", codecs_nr, HFP_MAX_NUM_CODECS); return; @@ -1047,26 +1060,23 @@ void hfp_hf_set_codecs(uint8_t * codecs, int codecs_nr){ } } -void hfp_hf_init(uint16_t rfcomm_channel_nr, uint32_t supported_features, uint16_t * indicators, int indicators_nr, uint32_t indicators_status){ - l2cap_init(); - l2cap_register_packet_handler(packet_handler); - rfcomm_register_packet_handler(packet_handler); - hfp_init(rfcomm_channel_nr); - +void hfp_hf_set_supported_features(uint32_t supported_features){ hfp_supported_features = supported_features; +} +void hfp_hf_set_indicators(int indicators_nr, uint16_t * indicators){ hfp_indicators_nr = indicators_nr; - hfp_indicators_status = indicators_status; int i; for (i=0; i