mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-04-17 02:42:33 +00:00
hfp ag api change: use acl_handle instead of bd_addr
This commit is contained in:
parent
0c87db9ec5
commit
d97d752d32
@ -75,7 +75,7 @@ bd_addr_t device_addr = { 0xD0, 0x39, 0x72, 0xCD, 0x83, 0x45};
|
||||
static uint8_t codecs[] = {HFP_CODEC_CVSD, HFP_CODEC_MSBC};
|
||||
static uint8_t negotiated_codec = HFP_CODEC_CVSD;
|
||||
|
||||
static uint16_t handle = -1;
|
||||
static hci_con_handle_t acl_handle = -1;
|
||||
static hci_con_handle_t sco_handle;
|
||||
static int memory_1_enabled = 1;
|
||||
|
||||
@ -349,22 +349,22 @@ static void stdin_process(btstack_data_source_t *ds, btstack_data_source_callbac
|
||||
case 'A':
|
||||
log_info("USER:\'%c\'", cmd);
|
||||
printf("Release HFP service level connection.\n");
|
||||
hfp_ag_release_service_level_connection(device_addr);
|
||||
hfp_ag_release_service_level_connection(acl_handle);
|
||||
break;
|
||||
case 'Z':
|
||||
log_info("USER:\'%c\'", cmd);
|
||||
printf("Release HFP service level connection to %s...\n", bd_addr_to_str(device_addr));
|
||||
hfp_ag_release_service_level_connection(device_addr);
|
||||
hfp_ag_release_service_level_connection(acl_handle);
|
||||
break;
|
||||
case 'b':
|
||||
log_info("USER:\'%c\'", cmd);
|
||||
printf("Establish Audio connection %s...\n", bd_addr_to_str(device_addr));
|
||||
hfp_ag_establish_audio_connection(device_addr);
|
||||
hfp_ag_establish_audio_connection(acl_handle);
|
||||
break;
|
||||
case 'B':
|
||||
log_info("USER:\'%c\'", cmd);
|
||||
printf("Release Audio connection.\n");
|
||||
hfp_ag_release_audio_connection(device_addr);
|
||||
hfp_ag_release_audio_connection(acl_handle);
|
||||
break;
|
||||
case 'c':
|
||||
log_info("USER:\'%c\'", cmd);
|
||||
@ -386,7 +386,7 @@ static void stdin_process(btstack_data_source_t *ds, btstack_data_source_callbac
|
||||
case 'd':
|
||||
log_info("USER:\'%c\'", cmd);
|
||||
printf("Report AG failure\n");
|
||||
hfp_ag_report_extended_audio_gateway_error_result_code(device_addr, HFP_CME_ERROR_AG_FAILURE);
|
||||
hfp_ag_report_extended_audio_gateway_error_result_code(acl_handle, HFP_CME_ERROR_AG_FAILURE);
|
||||
break;
|
||||
case 'e':
|
||||
log_info("USER:\'%c\'", cmd);
|
||||
@ -471,52 +471,52 @@ static void stdin_process(btstack_data_source_t *ds, btstack_data_source_callbac
|
||||
case 'n':
|
||||
log_info("USER:\'%c\'", cmd);
|
||||
printf("Disable Voice Recognition\n");
|
||||
hfp_ag_activate_voice_recognition(device_addr, 0);
|
||||
hfp_ag_activate_voice_recognition(acl_handle, 0);
|
||||
break;
|
||||
case 'N':
|
||||
log_info("USER:\'%c\'", cmd);
|
||||
printf("Enable Voice Recognition\n");
|
||||
hfp_ag_activate_voice_recognition(device_addr, 1);
|
||||
hfp_ag_activate_voice_recognition(acl_handle, 1);
|
||||
break;
|
||||
case 'o':
|
||||
log_info("USER:\'%c\'", cmd);
|
||||
printf("Set speaker gain to 0 (minimum)\n");
|
||||
hfp_ag_set_speaker_gain(device_addr, 0);
|
||||
hfp_ag_set_speaker_gain(acl_handle, 0);
|
||||
break;
|
||||
case 'O':
|
||||
log_info("USER:\'%c\'", cmd);
|
||||
printf("Set speaker gain to 9 (default)\n");
|
||||
hfp_ag_set_speaker_gain(device_addr, 9);
|
||||
hfp_ag_set_speaker_gain(acl_handle, 9);
|
||||
break;
|
||||
case 'p':
|
||||
log_info("USER:\'%c\'", cmd);
|
||||
printf("Set speaker gain to 12 (higher)\n");
|
||||
hfp_ag_set_speaker_gain(device_addr, 12);
|
||||
hfp_ag_set_speaker_gain(acl_handle, 12);
|
||||
break;
|
||||
case 'P':
|
||||
log_info("USER:\'%c\'", cmd);
|
||||
printf("Set speaker gain to 15 (maximum)\n");
|
||||
hfp_ag_set_speaker_gain(device_addr, 15);
|
||||
hfp_ag_set_speaker_gain(acl_handle, 15);
|
||||
break;
|
||||
case 'q':
|
||||
log_info("USER:\'%c\'", cmd);
|
||||
printf("Set microphone gain to 0\n");
|
||||
hfp_ag_set_microphone_gain(device_addr, 0);
|
||||
hfp_ag_set_microphone_gain(acl_handle, 0);
|
||||
break;
|
||||
case 'Q':
|
||||
log_info("USER:\'%c\'", cmd);
|
||||
printf("Set microphone gain to 9\n");
|
||||
hfp_ag_set_microphone_gain(device_addr, 9);
|
||||
hfp_ag_set_microphone_gain(acl_handle, 9);
|
||||
break;
|
||||
case 's':
|
||||
log_info("USER:\'%c\'", cmd);
|
||||
printf("Set microphone gain to 12\n");
|
||||
hfp_ag_set_microphone_gain(device_addr, 12);
|
||||
hfp_ag_set_microphone_gain(acl_handle, 12);
|
||||
break;
|
||||
case 'S':
|
||||
log_info("USER:\'%c\'", cmd);
|
||||
printf("Set microphone gain to 15\n");
|
||||
hfp_ag_set_microphone_gain(device_addr, 15);
|
||||
hfp_ag_set_microphone_gain(acl_handle, 15);
|
||||
break;
|
||||
case 'R':
|
||||
log_info("USER:\'%c\'", cmd);
|
||||
@ -525,8 +525,8 @@ static void stdin_process(btstack_data_source_t *ds, btstack_data_source_callbac
|
||||
break;
|
||||
case 't':
|
||||
log_info("USER:\'%c\'", cmd);
|
||||
printf("Terminate HCI connection. 0x%2x\n", handle);
|
||||
gap_disconnect(handle);
|
||||
printf("Terminate HCI connection. 0x%2x\n", acl_handle);
|
||||
gap_disconnect(acl_handle);
|
||||
break;
|
||||
case 'u':
|
||||
log_info("USER:\'%c\'", cmd);
|
||||
@ -592,7 +592,7 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t * even
|
||||
sco_demo_set_codec(negotiated_codec);
|
||||
break;
|
||||
case HFP_SUBEVENT_SERVICE_LEVEL_CONNECTION_ESTABLISHED:
|
||||
handle = hfp_subevent_service_level_connection_established_get_con_handle(event);
|
||||
acl_handle = hfp_subevent_service_level_connection_established_get_con_handle(event);
|
||||
hfp_subevent_service_level_connection_established_get_bd_addr(event, device_addr);
|
||||
printf("Service level connection established from %s.\n", bd_addr_to_str(device_addr));
|
||||
break;
|
||||
@ -636,11 +636,11 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t * even
|
||||
|
||||
case HFP_SUBEVENT_ATTACH_NUMBER_TO_VOICE_TAG:
|
||||
printf("\n** Attach number to voice tag. Sending '1234567\n");
|
||||
hfp_ag_send_phone_number_for_voice_tag(device_addr, "1234567");
|
||||
hfp_ag_send_phone_number_for_voice_tag(acl_handle, "1234567");
|
||||
break;
|
||||
case HFP_SUBEVENT_TRANSMIT_DTMF_CODES:
|
||||
printf("\n** Send DTMF Codes: '%s'\n", hfp_subevent_transmit_dtmf_codes_get_dtmf(event));
|
||||
hfp_ag_send_dtmf_code_done(device_addr);
|
||||
hfp_ag_send_dtmf_code_done(acl_handle);
|
||||
break;
|
||||
case HFP_SUBEVENT_CALL_ANSWERED:
|
||||
printf("Call answered by HF\n");
|
||||
|
@ -291,6 +291,18 @@ hfp_connection_t * get_hfp_connection_context_for_sco_handle(uint16_t handle){
|
||||
return NULL;
|
||||
}
|
||||
|
||||
hfp_connection_t * get_hfp_connection_context_for_acl_handle(uint16_t handle){
|
||||
btstack_linked_list_iterator_t it;
|
||||
btstack_linked_list_iterator_init(&it, hfp_get_connections());
|
||||
while (btstack_linked_list_iterator_has_next(&it)){
|
||||
hfp_connection_t * hfp_connection = (hfp_connection_t *)btstack_linked_list_iterator_next(&it);
|
||||
if (hfp_connection->acl_handle == handle){
|
||||
return hfp_connection;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void hfp_reset_context_flags(hfp_connection_t * hfp_connection){
|
||||
if (!hfp_connection) return;
|
||||
hfp_connection->ok_pending = 0;
|
||||
|
@ -643,6 +643,7 @@ void hfp_emit_codec_event(btstack_packet_handler_t callback, uint8_t status, uin
|
||||
hfp_connection_t * get_hfp_connection_context_for_rfcomm_cid(uint16_t cid);
|
||||
hfp_connection_t * get_hfp_connection_context_for_bd_addr(bd_addr_t bd_addr);
|
||||
hfp_connection_t * get_hfp_connection_context_for_sco_handle(uint16_t handle);
|
||||
hfp_connection_t * get_hfp_connection_context_for_acl_handle(uint16_t handle);
|
||||
|
||||
btstack_linked_list_t * hfp_get_connections(void);
|
||||
void hfp_parse(hfp_connection_t * connection, uint8_t byte, int isHandsFree);
|
||||
|
@ -868,7 +868,7 @@ static void hfp_timeout_stop(hfp_connection_t * hfp_connection){
|
||||
static void hfp_ag_hf_start_ringing(hfp_connection_t * hfp_connection){
|
||||
if (use_in_band_tone()){
|
||||
hfp_connection->call_state = HFP_CALL_W4_AUDIO_CONNECTION_FOR_IN_BAND_RING;
|
||||
hfp_ag_establish_audio_connection(hfp_connection->remote_addr);
|
||||
hfp_ag_establish_audio_connection(hfp_connection->acl_handle);
|
||||
} else {
|
||||
hfp_timeout_start(hfp_connection);
|
||||
hfp_connection->ag_ring = 1;
|
||||
@ -967,7 +967,7 @@ static void hfp_ag_hf_accept_call(hfp_connection_t * source){
|
||||
hfp_connection->call_state = HFP_CALL_ACTIVE;
|
||||
} else {
|
||||
hfp_connection->call_state = HFP_CALL_W4_AUDIO_CONNECTION_FOR_ACTIVE;
|
||||
hfp_ag_establish_audio_connection(hfp_connection->remote_addr);
|
||||
hfp_ag_establish_audio_connection(hfp_connection->acl_handle);
|
||||
}
|
||||
|
||||
hfp_connection->ag_indicators_status_update_bitmap = store_bit(hfp_connection->ag_indicators_status_update_bitmap, call_indicator_index, 1);
|
||||
@ -1468,7 +1468,7 @@ static void hfp_ag_call_sm(hfp_ag_call_event_t event, hfp_connection_t * hfp_con
|
||||
}
|
||||
|
||||
// start audio if needed
|
||||
hfp_ag_establish_audio_connection(hfp_connection->remote_addr);
|
||||
hfp_ag_establish_audio_connection(hfp_connection->acl_handle);
|
||||
break;
|
||||
}
|
||||
case HFP_AG_OUTGOING_CALL_RINGING:
|
||||
@ -2071,14 +2071,14 @@ void hfp_ag_establish_service_level_connection(bd_addr_t bd_addr){
|
||||
hfp_establish_service_level_connection(bd_addr, SDP_Handsfree);
|
||||
}
|
||||
|
||||
void hfp_ag_release_service_level_connection(bd_addr_t bd_addr){
|
||||
hfp_connection_t * hfp_connection = get_hfp_connection_context_for_bd_addr(bd_addr);
|
||||
void hfp_ag_release_service_level_connection(hci_con_handle_t acl_handle){
|
||||
hfp_connection_t * hfp_connection = get_hfp_connection_context_for_acl_handle(acl_handle);
|
||||
hfp_release_service_level_connection(hfp_connection);
|
||||
hfp_run_for_context(hfp_connection);
|
||||
}
|
||||
|
||||
void hfp_ag_report_extended_audio_gateway_error_result_code(bd_addr_t bd_addr, hfp_cme_error_t error){
|
||||
hfp_connection_t * hfp_connection = get_hfp_connection_context_for_bd_addr(bd_addr);
|
||||
void hfp_ag_report_extended_audio_gateway_error_result_code(hci_con_handle_t acl_handle, hfp_cme_error_t error){
|
||||
hfp_connection_t * hfp_connection = get_hfp_connection_context_for_acl_handle(acl_handle);
|
||||
if (!hfp_connection){
|
||||
log_error("HFP HF: hfp_connection doesn't exist.");
|
||||
return;
|
||||
@ -2114,17 +2114,15 @@ static void hfp_ag_setup_audio_connection(hfp_connection_t * hfp_connection){
|
||||
}
|
||||
}
|
||||
|
||||
void hfp_ag_establish_audio_connection(bd_addr_t bd_addr){
|
||||
hfp_ag_establish_service_level_connection(bd_addr);
|
||||
hfp_connection_t * hfp_connection = get_hfp_connection_context_for_bd_addr(bd_addr);
|
||||
|
||||
void hfp_ag_establish_audio_connection(hci_con_handle_t acl_handle){
|
||||
hfp_connection_t * hfp_connection = get_hfp_connection_context_for_acl_handle(acl_handle);
|
||||
hfp_connection->establish_audio_connection = 0;
|
||||
hfp_ag_setup_audio_connection(hfp_connection);
|
||||
hfp_run_for_context(hfp_connection);
|
||||
}
|
||||
|
||||
void hfp_ag_release_audio_connection(bd_addr_t bd_addr){
|
||||
hfp_connection_t * hfp_connection = get_hfp_connection_context_for_bd_addr(bd_addr);
|
||||
void hfp_ag_release_audio_connection(hci_con_handle_t acl_handle){
|
||||
hfp_connection_t * hfp_connection = get_hfp_connection_context_for_acl_handle(acl_handle);
|
||||
hfp_release_audio_connection(hfp_connection);
|
||||
hfp_run_for_context(hfp_connection);
|
||||
}
|
||||
@ -2242,17 +2240,17 @@ void hfp_ag_set_battery_level(int level){
|
||||
hfp_ag_set_ag_indicator("battchg", level);
|
||||
}
|
||||
|
||||
void hfp_ag_activate_voice_recognition(bd_addr_t bd_addr, int activate){
|
||||
void hfp_ag_activate_voice_recognition(hci_con_handle_t acl_handle, int activate){
|
||||
if (!get_bit(hfp_supported_features, HFP_AGSF_VOICE_RECOGNITION_FUNCTION)) return;
|
||||
hfp_connection_t * hfp_connection = get_hfp_connection_context_for_bd_addr(bd_addr);
|
||||
|
||||
hfp_connection_t * hfp_connection = get_hfp_connection_context_for_acl_handle(acl_handle);
|
||||
|
||||
if (!get_bit(hfp_connection->remote_supported_features, HFP_HFSF_VOICE_RECOGNITION_FUNCTION)) {
|
||||
printf("AG cannot acivate voice recognition - not supported by HF\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (activate){
|
||||
hfp_ag_establish_audio_connection(bd_addr);
|
||||
hfp_ag_establish_audio_connection(acl_handle);
|
||||
}
|
||||
|
||||
hfp_connection->ag_activate_voice_recognition = activate;
|
||||
@ -2260,8 +2258,8 @@ void hfp_ag_activate_voice_recognition(bd_addr_t bd_addr, int activate){
|
||||
hfp_run_for_context(hfp_connection);
|
||||
}
|
||||
|
||||
void hfp_ag_set_microphone_gain(bd_addr_t bd_addr, int gain){
|
||||
hfp_connection_t * hfp_connection = get_hfp_connection_context_for_bd_addr(bd_addr);
|
||||
void hfp_ag_set_microphone_gain(hci_con_handle_t acl_handle, int gain){
|
||||
hfp_connection_t * hfp_connection = get_hfp_connection_context_for_acl_handle(acl_handle);
|
||||
if (hfp_connection->microphone_gain != gain){
|
||||
hfp_connection->command = HFP_CMD_SET_MICROPHONE_GAIN;
|
||||
hfp_connection->microphone_gain = gain;
|
||||
@ -2270,8 +2268,8 @@ void hfp_ag_set_microphone_gain(bd_addr_t bd_addr, int gain){
|
||||
hfp_run_for_context(hfp_connection);
|
||||
}
|
||||
|
||||
void hfp_ag_set_speaker_gain(bd_addr_t bd_addr, int gain){
|
||||
hfp_connection_t * hfp_connection = get_hfp_connection_context_for_bd_addr(bd_addr);
|
||||
void hfp_ag_set_speaker_gain(hci_con_handle_t acl_handle, int gain){
|
||||
hfp_connection_t * hfp_connection = get_hfp_connection_context_for_acl_handle(acl_handle);
|
||||
if (hfp_connection->speaker_gain != gain){
|
||||
hfp_connection->speaker_gain = gain;
|
||||
hfp_connection->send_speaker_gain = 1;
|
||||
@ -2279,19 +2277,19 @@ void hfp_ag_set_speaker_gain(bd_addr_t bd_addr, int gain){
|
||||
hfp_run_for_context(hfp_connection);
|
||||
}
|
||||
|
||||
void hfp_ag_send_phone_number_for_voice_tag(bd_addr_t bd_addr, const char * number){
|
||||
hfp_connection_t * hfp_connection = get_hfp_connection_context_for_bd_addr(bd_addr);
|
||||
void hfp_ag_send_phone_number_for_voice_tag(hci_con_handle_t acl_handle, const char * number){
|
||||
hfp_connection_t * hfp_connection = get_hfp_connection_context_for_acl_handle(acl_handle);
|
||||
hfp_ag_set_clip(0, number);
|
||||
hfp_connection->send_phone_number_for_voice_tag = 1;
|
||||
}
|
||||
|
||||
void hfp_ag_reject_phone_number_for_voice_tag(bd_addr_t bd_addr){
|
||||
hfp_connection_t * hfp_connection = get_hfp_connection_context_for_bd_addr(bd_addr);
|
||||
void hfp_ag_reject_phone_number_for_voice_tag(hci_con_handle_t acl_handle){
|
||||
hfp_connection_t * hfp_connection = get_hfp_connection_context_for_acl_handle(acl_handle);
|
||||
hfp_connection->send_error = 1;
|
||||
}
|
||||
|
||||
void hfp_ag_send_dtmf_code_done(bd_addr_t bd_addr){
|
||||
hfp_connection_t * hfp_connection = get_hfp_connection_context_for_bd_addr(bd_addr);
|
||||
void hfp_ag_send_dtmf_code_done(hci_con_handle_t acl_handle){
|
||||
hfp_connection_t * hfp_connection = get_hfp_connection_context_for_acl_handle(acl_handle);
|
||||
hfp_connection->ok_pending = 1;
|
||||
}
|
||||
|
||||
@ -2304,8 +2302,8 @@ void hfp_ag_clear_last_dialed_number(void){
|
||||
hfp_gsm_clear_last_dialed_number();
|
||||
}
|
||||
|
||||
void hfp_ag_notify_incoming_call_waiting(bd_addr_t bd_addr){
|
||||
hfp_connection_t * hfp_connection = get_hfp_connection_context_for_bd_addr(bd_addr);
|
||||
void hfp_ag_notify_incoming_call_waiting(hci_con_handle_t acl_handle){
|
||||
hfp_connection_t * hfp_connection = get_hfp_connection_context_for_acl_handle(acl_handle);
|
||||
if (!hfp_connection->call_waiting_notification_enabled) return;
|
||||
|
||||
hfp_connection->ag_notify_incoming_call_waiting = 1;
|
||||
|
@ -150,7 +150,7 @@ void hfp_ag_establish_service_level_connection(bd_addr_t bd_addr);
|
||||
*
|
||||
* @param bd_addr Bluetooth address of the HF
|
||||
*/
|
||||
void hfp_ag_release_service_level_connection(bd_addr_t bd_addr);
|
||||
void hfp_ag_release_service_level_connection(hci_con_handle_t acl_handle);
|
||||
|
||||
/**
|
||||
* @brief Establish audio connection.
|
||||
@ -158,7 +158,7 @@ void hfp_ag_release_service_level_connection(bd_addr_t bd_addr);
|
||||
* HSP_SUBEVENT_AUDIO_CONNECTION_COMPLETE.
|
||||
* @param bd_addr Bluetooth address of the HF
|
||||
*/
|
||||
void hfp_ag_establish_audio_connection(bd_addr_t bd_addr);
|
||||
void hfp_ag_establish_audio_connection(hci_con_handle_t acl_handle);
|
||||
|
||||
/**
|
||||
* @brief Release audio connection.
|
||||
@ -166,7 +166,7 @@ void hfp_ag_establish_audio_connection(bd_addr_t bd_addr);
|
||||
* HSP_SUBEVENT_AUDIO_DISCONNECTION_COMPLETE.
|
||||
* @param bd_addr Bluetooth address of the HF
|
||||
*/
|
||||
void hfp_ag_release_audio_connection(bd_addr_t bd_addr);
|
||||
void hfp_ag_release_audio_connection(hci_con_handle_t acl_handle);
|
||||
|
||||
/**
|
||||
* @brief Put the current call on hold, if it exists, and accept incoming call.
|
||||
@ -203,14 +203,14 @@ void hfp_ag_reject_held_incoming_call(void);
|
||||
* @param bd_addr Bluetooth address of the HF
|
||||
* @param gain Valid range: [0,15]
|
||||
*/
|
||||
void hfp_ag_set_microphone_gain(bd_addr_t bd_addr, int gain);
|
||||
void hfp_ag_set_microphone_gain(hci_con_handle_t acl_handle, int gain);
|
||||
|
||||
/*
|
||||
* @brief Set speaker gain.
|
||||
* @param bd_addr Bluetooth address of the HF
|
||||
* @param gain Valid range: [0,15]
|
||||
*/
|
||||
void hfp_ag_set_speaker_gain(bd_addr_t bd_addr, int gain);
|
||||
void hfp_ag_set_speaker_gain(hci_con_handle_t acl_handle, int gain);
|
||||
|
||||
/*
|
||||
* @brief Set battery level.
|
||||
@ -229,7 +229,7 @@ void hfp_ag_clear_last_dialed_number(void);
|
||||
* has previously enabled the "Call Waiting notification" in the AG.
|
||||
* @param bd_addr Bluetooth address of the HF
|
||||
*/
|
||||
void hfp_ag_notify_incoming_call_waiting(bd_addr_t bd_addr);
|
||||
void hfp_ag_notify_incoming_call_waiting(hci_con_handle_t acl_handle);
|
||||
|
||||
// Voice Recognition
|
||||
|
||||
@ -238,20 +238,20 @@ void hfp_ag_notify_incoming_call_waiting(bd_addr_t bd_addr);
|
||||
* @param bd_addr Bluetooth address of the HF
|
||||
* @param activate
|
||||
*/
|
||||
void hfp_ag_activate_voice_recognition(bd_addr_t bd_addr, int activate);
|
||||
void hfp_ag_activate_voice_recognition(hci_con_handle_t acl_handle, int activate);
|
||||
|
||||
/*
|
||||
* @brief Send a phone number back to the HF.
|
||||
* @param bd_addr Bluetooth address of the HF
|
||||
* @param phone_number
|
||||
*/
|
||||
void hfp_ag_send_phone_number_for_voice_tag(bd_addr_t bd_addr, const char * phone_number);
|
||||
void hfp_ag_send_phone_number_for_voice_tag(hci_con_handle_t acl_handle, const char * phone_number);
|
||||
|
||||
/*
|
||||
* @brief Reject sending a phone number to the HF.
|
||||
* @param bd_addr Bluetooth address of the HF
|
||||
*/
|
||||
void hfp_ag_reject_phone_number_for_voice_tag(bd_addr_t bd_addr);
|
||||
void hfp_ag_reject_phone_number_for_voice_tag(hci_con_handle_t acl_handle);
|
||||
|
||||
/**
|
||||
* @brief Store phone number with initiated call.
|
||||
@ -322,7 +322,7 @@ void hfp_ag_set_subcriber_number_information(hfp_phone_number_t * numbers, int n
|
||||
* @brief Called by cellular unit after a DTMF code was transmitted, so that the next one can be emitted.
|
||||
* @param bd_addr Bluetooth address of the HF
|
||||
*/
|
||||
void hfp_ag_send_dtmf_code_done(bd_addr_t bd_addr);
|
||||
void hfp_ag_send_dtmf_code_done(hci_con_handle_t acl_handle);
|
||||
|
||||
/**
|
||||
* @brief Report Extended Audio Gateway Error result codes in the AG.
|
||||
@ -355,7 +355,7 @@ void hfp_ag_send_dtmf_code_done(bd_addr_t bd_addr);
|
||||
* @param bd_addr Bluetooth address of the HF
|
||||
* @param error
|
||||
*/
|
||||
void hfp_ag_report_extended_audio_gateway_error_result_code(bd_addr_t bd_addr, hfp_cme_error_t error);
|
||||
void hfp_ag_report_extended_audio_gateway_error_result_code(hci_con_handle_t acl_handle, hfp_cme_error_t error);
|
||||
|
||||
/* API_END */
|
||||
|
||||
|
@ -108,7 +108,7 @@ static hfp_generic_status_indicator_t hf_indicators[] = {
|
||||
{2, 1},
|
||||
};
|
||||
|
||||
static uint16_t handle = -1;
|
||||
static hci_con_handle_t acl_handle = -1;
|
||||
static int memory_1_enabled = 1;
|
||||
|
||||
int has_more_hfp_ag_commands(void){
|
||||
@ -128,19 +128,19 @@ static void user_command(char cmd){
|
||||
break;
|
||||
case 'A':
|
||||
printf("Release HFP service level connection.\n");
|
||||
hfp_ag_release_service_level_connection(device_addr);
|
||||
hfp_ag_release_service_level_connection(acl_handle);
|
||||
break;
|
||||
case 'Z':
|
||||
printf("Release HFP service level connection to %s...\n", bd_addr_to_str(device_addr));
|
||||
hfp_ag_release_service_level_connection(device_addr);
|
||||
hfp_ag_release_service_level_connection(acl_handle);
|
||||
break;
|
||||
case 'b':
|
||||
printf("Establish Audio connection %s...\n", bd_addr_to_str(device_addr));
|
||||
hfp_ag_establish_audio_connection(device_addr);
|
||||
hfp_ag_establish_audio_connection(acl_handle);
|
||||
break;
|
||||
case 'B':
|
||||
printf("Release Audio connection.\n");
|
||||
hfp_ag_release_audio_connection(device_addr);
|
||||
hfp_ag_release_audio_connection(acl_handle);
|
||||
break;
|
||||
case 'c':
|
||||
printf("Simulate incoming call from 1234567\n");
|
||||
@ -158,7 +158,7 @@ static void user_command(char cmd){
|
||||
break;
|
||||
case 'd':
|
||||
printf("Report AG failure\n");
|
||||
hfp_ag_report_extended_audio_gateway_error_result_code(device_addr, HFP_CME_ERROR_AG_FAILURE);
|
||||
hfp_ag_report_extended_audio_gateway_error_result_code(acl_handle, HFP_CME_ERROR_AG_FAILURE);
|
||||
break;
|
||||
case 'e':
|
||||
printf("Answer call on AG\n");
|
||||
@ -226,43 +226,43 @@ static void user_command(char cmd){
|
||||
break;
|
||||
case 'n':
|
||||
printf("Disable Voice Recognition\n");
|
||||
hfp_ag_activate_voice_recognition(device_addr, 0);
|
||||
hfp_ag_activate_voice_recognition(acl_handle, 0);
|
||||
break;
|
||||
case 'N':
|
||||
printf("Enable Voice Recognition\n");
|
||||
hfp_ag_activate_voice_recognition(device_addr, 1);
|
||||
hfp_ag_activate_voice_recognition(acl_handle, 1);
|
||||
break;
|
||||
case 'o':
|
||||
printf("Set speaker gain to 0 (minimum)\n");
|
||||
hfp_ag_set_speaker_gain(device_addr, 0);
|
||||
hfp_ag_set_speaker_gain(acl_handle, 0);
|
||||
break;
|
||||
case 'O':
|
||||
printf("Set speaker gain to 9 (default)\n");
|
||||
hfp_ag_set_speaker_gain(device_addr, 9);
|
||||
hfp_ag_set_speaker_gain(acl_handle, 9);
|
||||
break;
|
||||
case 'p':
|
||||
printf("Set speaker gain to 12 (higher)\n");
|
||||
hfp_ag_set_speaker_gain(device_addr, 12);
|
||||
hfp_ag_set_speaker_gain(acl_handle, 12);
|
||||
break;
|
||||
case 'P':
|
||||
printf("Set speaker gain to 15 (maximum)\n");
|
||||
hfp_ag_set_speaker_gain(device_addr, 15);
|
||||
hfp_ag_set_speaker_gain(acl_handle, 15);
|
||||
break;
|
||||
case 'q':
|
||||
printf("Set microphone gain to 0\n");
|
||||
hfp_ag_set_microphone_gain(device_addr, 0);
|
||||
hfp_ag_set_microphone_gain(acl_handle, 0);
|
||||
break;
|
||||
case 'Q':
|
||||
printf("Set microphone gain to 9\n");
|
||||
hfp_ag_set_microphone_gain(device_addr, 9);
|
||||
hfp_ag_set_microphone_gain(acl_handle, 9);
|
||||
break;
|
||||
case 's':
|
||||
printf("Set microphone gain to 12\n");
|
||||
hfp_ag_set_microphone_gain(device_addr, 12);
|
||||
hfp_ag_set_microphone_gain(acl_handle, 12);
|
||||
break;
|
||||
case 'S':
|
||||
printf("Set microphone gain to 15\n");
|
||||
hfp_ag_set_microphone_gain(device_addr, 15);
|
||||
hfp_ag_set_microphone_gain(acl_handle, 15);
|
||||
break;
|
||||
case 'R':
|
||||
printf("Enable in-band ring tone\n");
|
||||
@ -270,7 +270,7 @@ static void user_command(char cmd){
|
||||
break;
|
||||
case 't':
|
||||
printf("Terminate HCI connection.\n");
|
||||
gap_disconnect(handle);
|
||||
gap_disconnect(acl_handle);
|
||||
break;
|
||||
case 'u':
|
||||
printf("Join held call\n");
|
||||
@ -360,7 +360,7 @@ void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t * event, uint
|
||||
|
||||
switch (event[2]) {
|
||||
case HFP_SUBEVENT_SERVICE_LEVEL_CONNECTION_ESTABLISHED:
|
||||
handle = hfp_subevent_service_level_connection_established_get_con_handle(event);
|
||||
acl_handle = hfp_subevent_service_level_connection_established_get_con_handle(event);
|
||||
printf("Service level connection established.\n");
|
||||
break;
|
||||
case HFP_SUBEVENT_SERVICE_LEVEL_CONNECTION_RELEASED:
|
||||
@ -393,11 +393,11 @@ void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t * event, uint
|
||||
break;
|
||||
case HFP_SUBEVENT_ATTACH_NUMBER_TO_VOICE_TAG:
|
||||
printf("\n** Attach number to voice tag. Sending '1234567\n");
|
||||
hfp_ag_send_phone_number_for_voice_tag(device_addr, "1234567");
|
||||
hfp_ag_send_phone_number_for_voice_tag(acl_handle, "1234567");
|
||||
break;
|
||||
case HFP_SUBEVENT_TRANSMIT_DTMF_CODES:
|
||||
printf("\n** Send DTMF Codes: '%s'\n", &event[3]);
|
||||
hfp_ag_send_dtmf_code_done(device_addr);
|
||||
hfp_ag_send_dtmf_code_done(acl_handle);
|
||||
break;
|
||||
default:
|
||||
printf("Event not handled %u\n", event[2]);
|
||||
@ -418,8 +418,8 @@ TEST_GROUP(HFPClient){
|
||||
}
|
||||
|
||||
void teardown(void){
|
||||
hfp_ag_release_audio_connection(device_addr);
|
||||
hfp_ag_release_service_level_connection(device_addr);
|
||||
hfp_ag_release_audio_connection(acl_handle);
|
||||
hfp_ag_release_service_level_connection(acl_handle);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -272,7 +272,7 @@ static void handle_advertising_event(uint8_t * packet, int size){
|
||||
for (ad_iterator_init(&context, adv_size, (uint8_t *)adv_data) ; ad_iterator_has_more(&context) ; ad_iterator_next(&context)){
|
||||
uint8_t data_type = ad_iterator_get_data_type(&context);
|
||||
// uint8_t size = ad_iterator_get_data_len(&context);
|
||||
uint8_t * data = ad_iterator_get_data(&context);
|
||||
const uint8_t * data = ad_iterator_get_data(&context);
|
||||
switch (data_type){
|
||||
case 1: // AD_FLAGS
|
||||
if (*data & 1) printf("LE Limited Discoverable Mode, ");
|
||||
|
@ -72,12 +72,12 @@ const uint8_t rfcomm_channel_nr = 1;
|
||||
const char hfp_ag_service_name[] = "BTstack HFP AG Test";
|
||||
|
||||
static bd_addr_t device_addr;
|
||||
static hci_con_handle_t acl_handle = -1;
|
||||
//static bd_addr_t pts_addr = {0x00,0x15,0x83,0x5F,0x9D,0x46};
|
||||
static bd_addr_t pts_addr = {0x00,0x1A,0x7D,0xDA,0x71,0x0A};
|
||||
// static bd_addr_t pts_addr = {0x00,0x1b,0xDC,0x07,0x32,0xEF};
|
||||
static bd_addr_t speaker_addr = {0x00, 0x21, 0x3C, 0xAC, 0xF7, 0x38};
|
||||
static uint8_t codecs[1] = {HFP_CODEC_CVSD};
|
||||
static uint16_t handle = -1;
|
||||
static int memory_1_enabled = 1;
|
||||
|
||||
static int ag_indicators_nr = 7;
|
||||
@ -355,7 +355,7 @@ static void stdin_process(btstack_data_source_t *ds, btstack_data_source_callbac
|
||||
case 'A':
|
||||
log_info("USER:\'%c\'", cmd);
|
||||
printf("Release HFP service level connection.\n");
|
||||
hfp_ag_release_service_level_connection(device_addr);
|
||||
hfp_ag_release_service_level_connection(acl_handle);
|
||||
break;
|
||||
case 'z':
|
||||
memcpy(device_addr, speaker_addr, 6);
|
||||
@ -366,17 +366,17 @@ static void stdin_process(btstack_data_source_t *ds, btstack_data_source_callbac
|
||||
case 'Z':
|
||||
log_info("USER:\'%c\'", cmd);
|
||||
printf("Release HFP service level connection to %s...\n", bd_addr_to_str(device_addr));
|
||||
hfp_ag_release_service_level_connection(device_addr);
|
||||
hfp_ag_release_service_level_connection(acl_handle);
|
||||
break;
|
||||
case 'b':
|
||||
log_info("USER:\'%c\'", cmd);
|
||||
printf("Establish Audio connection %s...\n", bd_addr_to_str(device_addr));
|
||||
hfp_ag_establish_audio_connection(device_addr);
|
||||
hfp_ag_establish_audio_connection(acl_handle);
|
||||
break;
|
||||
case 'B':
|
||||
log_info("USER:\'%c\'", cmd);
|
||||
printf("Release Audio connection.\n");
|
||||
hfp_ag_release_audio_connection(device_addr);
|
||||
hfp_ag_release_audio_connection(acl_handle);
|
||||
break;
|
||||
case 'c':
|
||||
log_info("USER:\'%c\'", cmd);
|
||||
@ -398,7 +398,7 @@ static void stdin_process(btstack_data_source_t *ds, btstack_data_source_callbac
|
||||
case 'd':
|
||||
log_info("USER:\'%c\'", cmd);
|
||||
printf("Report AG failure\n");
|
||||
hfp_ag_report_extended_audio_gateway_error_result_code(device_addr, HFP_CME_ERROR_AG_FAILURE);
|
||||
hfp_ag_report_extended_audio_gateway_error_result_code(acl_handle, HFP_CME_ERROR_AG_FAILURE);
|
||||
break;
|
||||
case 'e':
|
||||
log_info("USER:\'%c\'", cmd);
|
||||
@ -483,52 +483,52 @@ static void stdin_process(btstack_data_source_t *ds, btstack_data_source_callbac
|
||||
case 'n':
|
||||
log_info("USER:\'%c\'", cmd);
|
||||
printf("Disable Voice Recognition\n");
|
||||
hfp_ag_activate_voice_recognition(device_addr, 0);
|
||||
hfp_ag_activate_voice_recognition(acl_handle, 0);
|
||||
break;
|
||||
case 'N':
|
||||
log_info("USER:\'%c\'", cmd);
|
||||
printf("Enable Voice Recognition\n");
|
||||
hfp_ag_activate_voice_recognition(device_addr, 1);
|
||||
hfp_ag_activate_voice_recognition(acl_handle, 1);
|
||||
break;
|
||||
case 'o':
|
||||
log_info("USER:\'%c\'", cmd);
|
||||
printf("Set speaker gain to 0 (minimum)\n");
|
||||
hfp_ag_set_speaker_gain(device_addr, 0);
|
||||
hfp_ag_set_speaker_gain(acl_handle, 0);
|
||||
break;
|
||||
case 'O':
|
||||
log_info("USER:\'%c\'", cmd);
|
||||
printf("Set speaker gain to 9 (default)\n");
|
||||
hfp_ag_set_speaker_gain(device_addr, 9);
|
||||
hfp_ag_set_speaker_gain(acl_handle, 9);
|
||||
break;
|
||||
case 'p':
|
||||
log_info("USER:\'%c\'", cmd);
|
||||
printf("Set speaker gain to 12 (higher)\n");
|
||||
hfp_ag_set_speaker_gain(device_addr, 12);
|
||||
hfp_ag_set_speaker_gain(acl_handle, 12);
|
||||
break;
|
||||
case 'P':
|
||||
log_info("USER:\'%c\'", cmd);
|
||||
printf("Set speaker gain to 15 (maximum)\n");
|
||||
hfp_ag_set_speaker_gain(device_addr, 15);
|
||||
hfp_ag_set_speaker_gain(acl_handle, 15);
|
||||
break;
|
||||
case 'q':
|
||||
log_info("USER:\'%c\'", cmd);
|
||||
printf("Set microphone gain to 0\n");
|
||||
hfp_ag_set_microphone_gain(device_addr, 0);
|
||||
hfp_ag_set_microphone_gain(acl_handle, 0);
|
||||
break;
|
||||
case 'Q':
|
||||
log_info("USER:\'%c\'", cmd);
|
||||
printf("Set microphone gain to 9\n");
|
||||
hfp_ag_set_microphone_gain(device_addr, 9);
|
||||
hfp_ag_set_microphone_gain(acl_handle, 9);
|
||||
break;
|
||||
case 's':
|
||||
log_info("USER:\'%c\'", cmd);
|
||||
printf("Set microphone gain to 12\n");
|
||||
hfp_ag_set_microphone_gain(device_addr, 12);
|
||||
hfp_ag_set_microphone_gain(acl_handle, 12);
|
||||
break;
|
||||
case 'S':
|
||||
log_info("USER:\'%c\'", cmd);
|
||||
printf("Set microphone gain to 15\n");
|
||||
hfp_ag_set_microphone_gain(device_addr, 15);
|
||||
hfp_ag_set_microphone_gain(acl_handle, 15);
|
||||
break;
|
||||
case 'R':
|
||||
log_info("USER:\'%c\'", cmd);
|
||||
@ -537,8 +537,8 @@ static void stdin_process(btstack_data_source_t *ds, btstack_data_source_callbac
|
||||
break;
|
||||
case 't':
|
||||
log_info("USER:\'%c\'", cmd);
|
||||
printf("Terminate HCI connection. 0x%2x\n", handle);
|
||||
gap_disconnect(handle);
|
||||
printf("Terminate HCI connection. 0x%2x\n", acl_handle);
|
||||
gap_disconnect(acl_handle);
|
||||
break;
|
||||
case 'u':
|
||||
log_info("USER:\'%c\'", cmd);
|
||||
@ -595,7 +595,7 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t * even
|
||||
|
||||
switch (event[2]) {
|
||||
case HFP_SUBEVENT_SERVICE_LEVEL_CONNECTION_ESTABLISHED:
|
||||
handle = hfp_subevent_service_level_connection_established_get_con_handle(event);
|
||||
acl_handle = hfp_subevent_service_level_connection_established_get_con_handle(event);
|
||||
printf("Service level connection established.\n");
|
||||
break;
|
||||
case HFP_SUBEVENT_SERVICE_LEVEL_CONNECTION_RELEASED:
|
||||
@ -629,11 +629,11 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t * even
|
||||
|
||||
case HFP_SUBEVENT_ATTACH_NUMBER_TO_VOICE_TAG:
|
||||
printf("\n** Attach number to voice tag. Sending '1234567\n");
|
||||
hfp_ag_send_phone_number_for_voice_tag(device_addr, "1234567");
|
||||
hfp_ag_send_phone_number_for_voice_tag(acl_handle, "1234567");
|
||||
break;
|
||||
case HFP_SUBEVENT_TRANSMIT_DTMF_CODES:
|
||||
printf("\n** Send DTMF Codes: '%s'\n", &event[3]);
|
||||
hfp_ag_send_dtmf_code_done(device_addr);
|
||||
hfp_ag_send_dtmf_code_done(acl_handle);
|
||||
break;
|
||||
case HFP_SUBEVENT_CALL_ANSWERED:
|
||||
printf("Call answered by HF\n");
|
||||
@ -667,7 +667,7 @@ int btstack_main(int argc, const char * argv[]){
|
||||
// init SDP, create record for SPP and register with SDP
|
||||
sdp_init();
|
||||
memset((uint8_t *)hfp_service_buffer, 0, sizeof(hfp_service_buffer));
|
||||
hfp_ag_create_sdp_record((uint8_t *)hfp_service_buffer, 0x10005, rfcomm_channel_nr, hfp_ag_service_name, 0, 0);
|
||||
hfp_ag_create_sdp_record((uint8_t *)hfp_service_buffer, 0x10005, rfcomm_channel_nr, hfp_ag_service_name, 0, 0, 0);
|
||||
|
||||
sdp_register_service((uint8_t *)hfp_service_buffer);
|
||||
|
||||
|
@ -535,7 +535,7 @@ int btstack_main(int argc, const char * argv[]){
|
||||
// init SDP, create record for SPP and register with SDP
|
||||
sdp_init();
|
||||
memset((uint8_t *)hfp_service_buffer, 0, sizeof(hfp_service_buffer));
|
||||
hfp_hf_create_sdp_record((uint8_t *)hfp_service_buffer, 0x10006, rfcomm_channel_nr, hfp_hf_service_name, 0);
|
||||
hfp_hf_create_sdp_record((uint8_t *)hfp_service_buffer, 0x10006, rfcomm_channel_nr, hfp_hf_service_name, 0, 0);
|
||||
sdp_register_service((uint8_t *)hfp_service_buffer);
|
||||
|
||||
// pre-select pts
|
||||
|
@ -105,10 +105,10 @@ int btstack_main(int argc, const char * argv[]){
|
||||
hsp_hs_create_sdp_record((uint8_t *)hsp_hs_service_buffer, 0x10004, 3, "HSP HS", 0);
|
||||
sdp_register_service((uint8_t *)hsp_hs_service_buffer);
|
||||
|
||||
hfp_ag_create_sdp_record((uint8_t *)hfp_ag_service_buffer, 0x10005, 4, "HFP AG", 0, 0);
|
||||
hfp_ag_create_sdp_record((uint8_t *)hfp_ag_service_buffer, 0x10005, 4, "HFP AG", 0, 0, 1);
|
||||
sdp_register_service((uint8_t *)hfp_ag_service_buffer);
|
||||
|
||||
hfp_hf_create_sdp_record((uint8_t *)hfp_hf_service_buffer, 0x10006, 5, "HFP HS", 0);
|
||||
hfp_hf_create_sdp_record((uint8_t *)hfp_hf_service_buffer, 0x10006, 5, "HFP HS", 0, 1);
|
||||
sdp_register_service((uint8_t *)hfp_hf_service_buffer);
|
||||
|
||||
// set CoD for all this
|
||||
|
Loading…
x
Reference in New Issue
Block a user