mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-02-20 18:40:31 +00:00
hfp: support de-init
This commit is contained in:
parent
d76b111942
commit
20b2edb6e6
@ -70,64 +70,90 @@
|
||||
#define HFP_HF_FEATURES_SIZE 10
|
||||
#define HFP_AG_FEATURES_SIZE 12
|
||||
|
||||
typedef struct {
|
||||
hfp_role_t local_role;
|
||||
bd_addr_t remote_address;
|
||||
} hfp_sdp_query_context_t;
|
||||
|
||||
// globals
|
||||
|
||||
static hfp_sdp_query_context_t sdp_query_context;
|
||||
static btstack_context_callback_registration_t hfp_handle_sdp_client_query_request;
|
||||
|
||||
static btstack_linked_list_t hfp_connections ;
|
||||
|
||||
static btstack_packet_handler_t hfp_hf_callback;
|
||||
static btstack_packet_handler_t hfp_ag_callback;
|
||||
|
||||
static btstack_packet_handler_t hfp_hf_rfcomm_packet_handler;
|
||||
static btstack_packet_handler_t hfp_ag_rfcomm_packet_handler;
|
||||
|
||||
static hfp_connection_t * sco_establishment_active;
|
||||
|
||||
static uint16_t hfp_allowed_sco_packet_types;
|
||||
|
||||
// prototypes
|
||||
static hfp_link_settings_t hfp_next_link_setting_for_connection(hfp_link_settings_t current_setting, hfp_connection_t * hfp_connection, uint8_t eSCO_S4_supported);
|
||||
static void parse_sequence(hfp_connection_t * context);
|
||||
|
||||
|
||||
static const char * hfp_hf_features[] = {
|
||||
"EC and/or NR function",
|
||||
"Three-way calling",
|
||||
"CLI presentation capability",
|
||||
"Voice recognition activation",
|
||||
"Remote volume control",
|
||||
"EC and/or NR function",
|
||||
"Three-way calling",
|
||||
"CLI presentation capability",
|
||||
"Voice recognition activation",
|
||||
"Remote volume control",
|
||||
|
||||
"Enhanced call status",
|
||||
"Enhanced call control",
|
||||
|
||||
"Codec negotiation",
|
||||
|
||||
"HF Indicators",
|
||||
"eSCO S4 (and T2) Settings Supported",
|
||||
"Reserved for future definition"
|
||||
"Enhanced call status",
|
||||
"Enhanced call control",
|
||||
|
||||
"Codec negotiation",
|
||||
|
||||
"HF Indicators",
|
||||
"eSCO S4 (and T2) Settings Supported",
|
||||
"Reserved for future definition"
|
||||
};
|
||||
|
||||
static const char * hfp_ag_features[] = {
|
||||
"Three-way calling",
|
||||
"EC and/or NR function",
|
||||
"Voice recognition function",
|
||||
"In-band ring tone capability",
|
||||
"Attach a number to a voice tag",
|
||||
"Ability to reject a call",
|
||||
"Enhanced call status",
|
||||
"Enhanced call control",
|
||||
"Extended Error Result Codes",
|
||||
"Codec negotiation",
|
||||
"HF Indicators",
|
||||
"eSCO S4 (and T2) Settings Supported",
|
||||
"Reserved for future definition"
|
||||
"Three-way calling",
|
||||
"EC and/or NR function",
|
||||
"Voice recognition function",
|
||||
"In-band ring tone capability",
|
||||
"Attach a number to a voice tag",
|
||||
"Ability to reject a call",
|
||||
"Enhanced call status",
|
||||
"Enhanced call control",
|
||||
"Extended Error Result Codes",
|
||||
"Codec negotiation",
|
||||
"HF Indicators",
|
||||
"eSCO S4 (and T2) Settings Supported",
|
||||
"Reserved for future definition"
|
||||
};
|
||||
|
||||
static const char * hfp_enhanced_call_dir[] = {
|
||||
"outgoing",
|
||||
"incoming"
|
||||
"outgoing",
|
||||
"incoming"
|
||||
};
|
||||
|
||||
static const char * hfp_enhanced_call_status[] = {
|
||||
"active",
|
||||
"held",
|
||||
"outgoing dialing",
|
||||
"outgoing alerting",
|
||||
"incoming",
|
||||
"incoming waiting",
|
||||
"call held by response and hold"
|
||||
"active",
|
||||
"held",
|
||||
"outgoing dialing",
|
||||
"outgoing alerting",
|
||||
"incoming",
|
||||
"incoming waiting",
|
||||
"call held by response and hold"
|
||||
};
|
||||
|
||||
static const char * hfp_enhanced_call_mode[] = {
|
||||
"voice",
|
||||
"data",
|
||||
"fax"
|
||||
"voice",
|
||||
"data",
|
||||
"fax"
|
||||
};
|
||||
|
||||
static const char * hfp_enhanced_call_mpty[] = {
|
||||
"not a conference call",
|
||||
"conference call"
|
||||
"not a conference call",
|
||||
"conference call"
|
||||
};
|
||||
|
||||
const char * hfp_enhanced_call_dir2str(uint16_t index){
|
||||
@ -150,32 +176,6 @@ const char * hfp_enhanced_call_mpty2str(uint16_t index){
|
||||
return "not defined";
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
hfp_role_t local_role;
|
||||
bd_addr_t remote_address;
|
||||
} hfp_sdp_query_context_t;
|
||||
|
||||
static hfp_sdp_query_context_t sdp_query_context;
|
||||
static btstack_context_callback_registration_t hfp_handle_sdp_client_query_request;
|
||||
|
||||
static void parse_sequence(hfp_connection_t * context);
|
||||
|
||||
static btstack_linked_list_t hfp_connections = NULL;
|
||||
|
||||
static btstack_packet_handler_t hfp_hf_callback;
|
||||
static btstack_packet_handler_t hfp_ag_callback;
|
||||
|
||||
static btstack_packet_handler_t hfp_hf_rfcomm_packet_handler;
|
||||
static btstack_packet_handler_t hfp_ag_rfcomm_packet_handler;
|
||||
|
||||
static hfp_connection_t * sco_establishment_active;
|
||||
|
||||
// HFP_SCO_PACKET_TYPES_NONE == no choice/override
|
||||
static uint16_t hfp_allowed_sco_packet_types;
|
||||
|
||||
// prototypes
|
||||
static hfp_link_settings_t hfp_next_link_setting_for_connection(hfp_link_settings_t current_setting, hfp_connection_t * hfp_connection, uint8_t eSCO_S4_supported);
|
||||
|
||||
static uint16_t hfp_parse_indicator_index(hfp_connection_t * hfp_connection){
|
||||
uint16_t index = btstack_atoi((char *)&hfp_connection->line_buffer[0]);
|
||||
|
||||
@ -1697,6 +1697,17 @@ void hfp_init(void){
|
||||
hfp_allowed_sco_packet_types = SCO_PACKET_TYPES_ALL;
|
||||
}
|
||||
|
||||
void hfp_deinit(void){
|
||||
hfp_connections = NULL;
|
||||
hfp_hf_callback = NULL;
|
||||
hfp_ag_callback = NULL;
|
||||
hfp_hf_rfcomm_packet_handler = NULL;
|
||||
hfp_ag_rfcomm_packet_handler = NULL;
|
||||
sco_establishment_active = NULL;
|
||||
(void) memset(&sdp_query_context, 0, sizeof(hfp_sdp_query_context_t));
|
||||
(void) memset(&hfp_handle_sdp_client_query_request, 0, sizeof(btstack_context_callback_registration_t));
|
||||
}
|
||||
|
||||
void hfp_set_sco_packet_types(uint16_t packet_types){
|
||||
hfp_allowed_sco_packet_types = packet_types;
|
||||
}
|
||||
|
@ -672,6 +672,7 @@ void hfp_set_hf_callback(btstack_packet_handler_t callback);
|
||||
void hfp_set_hf_rfcomm_packet_handler(btstack_packet_handler_t handler);
|
||||
|
||||
void hfp_init(void);
|
||||
void hfp_deinit(void);
|
||||
|
||||
void hfp_create_sdp_record(uint8_t * service, uint32_t service_record_handle, uint16_t service_uuid, int rfcomm_channel_nr, const char * name);
|
||||
void hfp_handle_hci_event(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size, hfp_role_t local_role);
|
||||
|
@ -79,34 +79,36 @@ void set_hfp_ag_indicators(hfp_ag_indicator_t * indicators, int indicator_nr);
|
||||
int get_hfp_ag_indicators_nr(hfp_connection_t * context);
|
||||
hfp_ag_indicator_t * get_hfp_ag_indicators(hfp_connection_t * context);
|
||||
|
||||
static btstack_packet_callback_registration_t hfp_ag_hci_event_callback_registration;
|
||||
|
||||
// gobals
|
||||
// const
|
||||
static const char default_hfp_ag_service_name[] = "Voice gateway";
|
||||
|
||||
static uint16_t hfp_supported_features = HFP_DEFAULT_AG_SUPPORTED_FEATURES;
|
||||
// globals
|
||||
static btstack_packet_callback_registration_t hfp_ag_hci_event_callback_registration;
|
||||
|
||||
static uint8_t hfp_codecs_nr = 0;
|
||||
static uint16_t hfp_supported_features;
|
||||
|
||||
static uint8_t hfp_codecs_nr;
|
||||
static uint8_t hfp_codecs[HFP_MAX_NUM_CODECS];
|
||||
|
||||
static int hfp_ag_indicators_nr = 0;
|
||||
static int hfp_ag_indicators_nr;
|
||||
static hfp_ag_indicator_t hfp_ag_indicators[HFP_MAX_NUM_INDICATORS];
|
||||
|
||||
static int hfp_generic_status_indicators_nr = 0;
|
||||
static int hfp_generic_status_indicators_nr;
|
||||
static hfp_generic_status_indicator_t hfp_generic_status_indicators[HFP_MAX_NUM_INDICATORS];
|
||||
|
||||
static int hfp_ag_call_hold_services_nr = 0;
|
||||
static int hfp_ag_call_hold_services_nr;
|
||||
static char *hfp_ag_call_hold_services[6];
|
||||
static btstack_packet_handler_t hfp_ag_callback;
|
||||
|
||||
static hfp_response_and_hold_state_t hfp_ag_response_and_hold_state;
|
||||
static int hfp_ag_response_and_hold_active = 0;
|
||||
|
||||
// Subcriber information entries
|
||||
static hfp_phone_number_t * subscriber_numbers = NULL;
|
||||
static int subscriber_numbers_count = 0;
|
||||
static int hfp_ag_response_and_hold_active;
|
||||
|
||||
// Subscriber information entries
|
||||
static hfp_phone_number_t * subscriber_numbers;
|
||||
static int subscriber_numbers_count;
|
||||
|
||||
// code
|
||||
static void hfp_ag_emit_simple_event(uint8_t event_subtype){
|
||||
uint8_t event[3];
|
||||
event[0] = HCI_EVENT_HFP_META;
|
||||
@ -2101,6 +2103,13 @@ void hfp_ag_init_call_hold_services(int call_hold_services_nr, const char * call
|
||||
void hfp_ag_init(uint16_t rfcomm_channel_nr){
|
||||
|
||||
hfp_init();
|
||||
hfp_ag_call_hold_services_nr = 0;
|
||||
hfp_ag_response_and_hold_active = 0;
|
||||
hfp_ag_indicators_nr = 0;
|
||||
hfp_codecs_nr = 0;
|
||||
hfp_supported_features = HFP_DEFAULT_AG_SUPPORTED_FEATURES;
|
||||
subscriber_numbers = NULL;
|
||||
subscriber_numbers_count = 0;
|
||||
|
||||
hfp_ag_hci_event_callback_registration.callback = &hfp_ag_hci_event_packet_handler;
|
||||
hci_add_event_handler(&hfp_ag_hci_event_callback_registration);
|
||||
@ -2109,14 +2118,19 @@ void hfp_ag_init(uint16_t rfcomm_channel_nr){
|
||||
|
||||
// used to set packet handler for outgoing rfcomm connections - could be handled by emitting an event to us
|
||||
hfp_set_ag_rfcomm_packet_handler(&hfp_ag_rfcomm_packet_handler);
|
||||
|
||||
hfp_ag_response_and_hold_active = 0;
|
||||
subscriber_numbers = NULL;
|
||||
subscriber_numbers_count = 0;
|
||||
|
||||
hfp_gsm_init();
|
||||
}
|
||||
|
||||
void hfp_ag_deinit(void){
|
||||
hfp_deinit();
|
||||
hfp_gsm_deinit();
|
||||
(void) memset(&hfp_ag_hci_event_callback_registration, 0, sizeof(btstack_packet_callback_registration_t));
|
||||
(void) memset(&hfp_ag_callback, 0, sizeof(btstack_packet_handler_t));
|
||||
(void) memset(&hfp_ag_call_hold_services, 0, sizeof(hfp_ag_call_hold_services));
|
||||
(void) memset(&hfp_ag_response_and_hold_state, 0, sizeof(hfp_response_and_hold_state_t));
|
||||
}
|
||||
|
||||
void hfp_ag_establish_service_level_connection(bd_addr_t bd_addr){
|
||||
hfp_establish_service_level_connection(bd_addr, BLUETOOTH_SERVICE_CLASS_HANDSFREE, HFP_ROLE_AG);
|
||||
}
|
||||
|
@ -357,6 +357,11 @@ void hfp_ag_send_dtmf_code_done(hci_con_handle_t acl_handle);
|
||||
*/
|
||||
void hfp_ag_report_extended_audio_gateway_error_result_code(hci_con_handle_t acl_handle, hfp_cme_error_t error);
|
||||
|
||||
/**
|
||||
* @brief De-Init HFP AG
|
||||
*/
|
||||
void hfp_ag_deinit(void);
|
||||
|
||||
/* API_END */
|
||||
|
||||
// testing
|
||||
|
@ -65,7 +65,7 @@
|
||||
#define HFP_GSM_MAX_CALL_NUMBER_SIZE 25
|
||||
|
||||
static hfp_gsm_call_t gsm_calls[HFP_GSM_MAX_NR_CALLS];
|
||||
static hfp_callsetup_status_t callsetup_status = HFP_CALLSETUP_STATUS_NO_CALL_SETUP_IN_PROGRESS;
|
||||
static hfp_callsetup_status_t callsetup_status;
|
||||
|
||||
static uint8_t clip_type;
|
||||
static char clip_number[HFP_GSM_MAX_CALL_NUMBER_SIZE];
|
||||
@ -147,7 +147,7 @@ static void free_call_slot(int index_in_table){
|
||||
}
|
||||
|
||||
void hfp_gsm_init(void){
|
||||
set_callsetup_status(HFP_CALLSETUP_STATUS_NO_CALL_SETUP_IN_PROGRESS);
|
||||
callsetup_status = HFP_CALLSETUP_STATUS_NO_CALL_SETUP_IN_PROGRESS;
|
||||
clip_type = 0;
|
||||
memset(clip_number, 0, sizeof(clip_number));
|
||||
memset(last_dialed_number, 0, sizeof(last_dialed_number));
|
||||
@ -156,7 +156,10 @@ void hfp_gsm_init(void){
|
||||
for (i = 0; i < HFP_GSM_MAX_NR_CALLS; i++){
|
||||
free_call_slot(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void hfp_gsm_deinit(void){
|
||||
}
|
||||
|
||||
static int get_number_calls_with_enhanced_status(hfp_enhanced_call_status_t enhanced_status){
|
||||
int i, count = 0;
|
||||
|
@ -83,9 +83,11 @@ uint8_t hfp_gsm_clip_type(void);
|
||||
char * hfp_gsm_clip_number(void);
|
||||
|
||||
void hfp_gsm_init(void);
|
||||
void hfp_gsm_deinit(void);
|
||||
|
||||
void hfp_gsm_handler(hfp_ag_call_event_t event, uint8_t index, uint8_t type, const char * number);
|
||||
|
||||
|
||||
/* API_END */
|
||||
|
||||
#if defined __cplusplus
|
||||
|
@ -64,19 +64,22 @@
|
||||
#include "hci_dump.h"
|
||||
#include "l2cap.h"
|
||||
|
||||
// const
|
||||
static const char default_hfp_hf_service_name[] = "Hands-Free unit";
|
||||
|
||||
// globals
|
||||
static btstack_packet_callback_registration_t hfp_hf_hci_event_callback_registration;
|
||||
|
||||
static const char default_hfp_hf_service_name[] = "Hands-Free unit";
|
||||
static uint16_t hfp_supported_features = HFP_DEFAULT_HF_SUPPORTED_FEATURES;
|
||||
static uint8_t hfp_codecs_nr = 0;
|
||||
static uint8_t hfp_codecs_nr;
|
||||
static uint8_t hfp_codecs[HFP_MAX_NUM_CODECS];
|
||||
|
||||
static uint8_t hfp_indicators_nr = 0;
|
||||
static uint8_t hfp_indicators_nr;
|
||||
static uint8_t hfp_indicators[HFP_MAX_NUM_INDICATORS];
|
||||
static uint32_t hfp_indicators_value[HFP_MAX_NUM_INDICATORS];
|
||||
|
||||
static uint8_t hfp_hf_speaker_gain = 9;
|
||||
static uint8_t hfp_hf_microphone_gain = 9;
|
||||
static uint8_t hfp_hf_speaker_gain;
|
||||
static uint8_t hfp_hf_microphone_gain;
|
||||
|
||||
static btstack_packet_handler_t hfp_hf_callback;
|
||||
|
||||
@ -1194,6 +1197,15 @@ static void hfp_hf_hci_event_packet_handler(uint8_t packet_type, uint16_t channe
|
||||
|
||||
void hfp_hf_init(uint16_t rfcomm_channel_nr){
|
||||
hfp_init();
|
||||
hfp_supported_features = HFP_DEFAULT_HF_SUPPORTED_FEATURES;
|
||||
hfp_call_status = HFP_CALL_STATUS_NO_HELD_OR_ACTIVE_CALLS;
|
||||
hfp_callsetup_status = HFP_CALLSETUP_STATUS_NO_CALL_SETUP_IN_PROGRESS;
|
||||
hfp_callheld_status= HFP_CALLHELD_STATUS_NO_CALLS_HELD;
|
||||
hfp_codecs_nr = 0;
|
||||
hfp_hf_speaker_gain = 9;
|
||||
hfp_hf_microphone_gain = 9;
|
||||
hfp_indicators_nr = 0;
|
||||
hfp_supported_features = HFP_DEFAULT_HF_SUPPORTED_FEATURES;
|
||||
|
||||
hfp_hf_hci_event_callback_registration.callback = &hfp_hf_hci_event_packet_handler;
|
||||
hci_add_event_handler(&hfp_hf_hci_event_callback_registration);
|
||||
@ -1202,12 +1214,13 @@ void hfp_hf_init(uint16_t rfcomm_channel_nr){
|
||||
|
||||
// used to set packet handler for outgoing rfcomm connections - could be handled by emitting an event to us
|
||||
hfp_set_hf_rfcomm_packet_handler(&hfp_hf_rfcomm_packet_handler);
|
||||
|
||||
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_deinit(void){
|
||||
hfp_deinit();
|
||||
(void) memset(&hfp_hf_hci_event_callback_registration, 0, sizeof(btstack_packet_callback_registration_t));
|
||||
(void) memset(&hfp_hf_callback, 0, sizeof(btstack_packet_handler_t));
|
||||
(void) memset(phone_number, 0, sizeof(phone_number));
|
||||
}
|
||||
|
||||
void hfp_hf_init_codecs(int codecs_nr, uint8_t * codecs){
|
||||
|
@ -422,6 +422,11 @@ void hfp_hf_set_hf_indicator(hci_con_handle_t acl_handle, int assigned_number, i
|
||||
*/
|
||||
int hfp_hf_in_band_ringtone_active(hci_con_handle_t acl_handle);
|
||||
|
||||
/**
|
||||
* @brief De-Init HFP HF
|
||||
*/
|
||||
void hfp_hf_deinit(void);
|
||||
|
||||
/* API_END */
|
||||
|
||||
#if defined __cplusplus
|
||||
|
@ -56,6 +56,7 @@
|
||||
#define MSBC_PADDING_SIZE 1
|
||||
#define MSBC_EXTRA_SIZE (MSBC_HEADER_H2_SIZE + MSBC_PADDING_SIZE)
|
||||
|
||||
// const
|
||||
static const uint8_t msbc_header_h2_byte_0 = 1;
|
||||
static const uint8_t msbc_header_h2_byte_1_table[] = { 0x08, 0x38, 0xc8, 0xf8 };
|
||||
|
||||
@ -71,6 +72,10 @@ void hfp_msbc_init(void){
|
||||
msbc_sequence_number = 0;
|
||||
}
|
||||
|
||||
void hfp_msbc_deinit(void){
|
||||
(void) memset(&state, 0, sizeof(btstack_sbc_encoder_state_t));
|
||||
}
|
||||
|
||||
int hfp_msbc_can_encode_audio_frame_now(void){
|
||||
return (sizeof(msbc_buffer) - msbc_buffer_offset) >= (MSBC_FRAME_SIZE + MSBC_EXTRA_SIZE);
|
||||
}
|
||||
|
@ -86,6 +86,11 @@ int hfp_msbc_num_bytes_in_stream(void);
|
||||
*/
|
||||
void hfp_msbc_read_from_stream(uint8_t * buffer, int size);
|
||||
|
||||
/**
|
||||
* @brief De-Init HFP mSBC Codec
|
||||
*/
|
||||
void hfp_msbc_deinit(void);
|
||||
|
||||
/* API_END */
|
||||
|
||||
#if defined __cplusplus
|
||||
|
Loading…
x
Reference in New Issue
Block a user