mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-02-06 03:40:16 +00:00
hfp_hf: emit voice recognition status
This commit is contained in:
parent
9cc9ffe44a
commit
56f1adacb8
@ -650,8 +650,9 @@ typedef struct hfp_connection {
|
||||
uint8_t hf_deactivate_calling_line_notification;
|
||||
uint8_t hf_activate_echo_canceling_and_noise_reduction;
|
||||
uint8_t hf_deactivate_echo_canceling_and_noise_reduction;
|
||||
uint8_t hf_activate_voice_recognition_notification;
|
||||
uint8_t hf_deactivate_voice_recognition_notification;
|
||||
|
||||
uint8_t voice_recognition_state_required;
|
||||
uint8_t voice_recognition_state_current; // 1-enabled; 0-dissabled
|
||||
|
||||
uint8_t clcc_idx;
|
||||
uint8_t clcc_dir;
|
||||
|
@ -675,21 +675,12 @@ static void hfp_hf_run_for_context(hfp_connection_t * hfp_connection){
|
||||
return;
|
||||
}
|
||||
|
||||
if (hfp_connection->hf_deactivate_voice_recognition_notification){
|
||||
hfp_connection->hf_deactivate_voice_recognition_notification = 0;
|
||||
if (hfp_connection->voice_recognition_state_required != hfp_connection->voice_recognition_state_current){
|
||||
hfp_connection->ok_pending = 1;
|
||||
hfp_hf_set_voice_recognition_notification_cmd(hfp_connection->rfcomm_cid, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
if (hfp_connection->hf_activate_voice_recognition_notification){
|
||||
hfp_connection->hf_activate_voice_recognition_notification = 0;
|
||||
hfp_connection->ok_pending = 1;
|
||||
hfp_hf_set_voice_recognition_notification_cmd(hfp_connection->rfcomm_cid, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (hfp_connection->hf_deactivate_call_waiting_notification){
|
||||
hfp_connection->hf_deactivate_call_waiting_notification = 0;
|
||||
hfp_connection->ok_pending = 1;
|
||||
@ -1003,6 +994,14 @@ static void hfp_hf_switch_on_ok(hfp_connection_t *hfp_connection){
|
||||
}
|
||||
break;
|
||||
default:
|
||||
switch (hfp_connection->command){
|
||||
case HFP_CMD_HF_ACTIVATE_VOICE_RECOGNITION:
|
||||
hfp_connection->voice_recognition_state_current = hfp_connection->voice_recognition_state_required;
|
||||
hfp_emit_event(hfp_connection, HFP_SUBEVENT_VOICE_RECOGNITION_STATUS, hfp_connection->voice_recognition_state_current);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1077,13 +1076,14 @@ static void hfp_hf_handle_rfcomm_command(hfp_connection_t * hfp_connection){
|
||||
hfp_emit_event(hfp_connection, HFP_SUBEVENT_EXTENDED_AUDIO_GATEWAY_ERROR, hfp_connection->extended_audio_gateway_error_value);
|
||||
break;
|
||||
case HFP_CMD_ERROR:
|
||||
hfp_connection->command = HFP_CMD_NONE;
|
||||
hfp_connection->ok_pending = 0;
|
||||
hfp_reset_context_flags(hfp_connection);
|
||||
|
||||
switch (hfp_connection->state){
|
||||
case HFP_SERVICE_LEVEL_CONNECTION_ESTABLISHED:
|
||||
switch (hfp_connection->codecs_state){
|
||||
case HFP_CODECS_RECEIVED_TRIGGER_CODEC_EXCHANGE:
|
||||
hfp_connection->command = HFP_CMD_NONE;
|
||||
hfp_emit_sco_event(hfp_connection, HFP_REMOTE_REJECTS_AUDIO_CONNECTION, 0, hfp_connection->remote_addr, hfp_connection->negotiated_codec);
|
||||
return;
|
||||
default:
|
||||
@ -1092,6 +1092,17 @@ static void hfp_hf_handle_rfcomm_command(hfp_connection_t * hfp_connection){
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
switch (hfp_connection->command){
|
||||
case HFP_CMD_HF_ACTIVATE_VOICE_RECOGNITION:
|
||||
// reset required voice recognition flag
|
||||
hfp_connection->voice_recognition_state_required = hfp_connection->voice_recognition_state_current;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
hfp_connection->command = HFP_CMD_NONE;
|
||||
hfp_emit_event(hfp_connection, HFP_SUBEVENT_COMPLETE, 1);
|
||||
break;
|
||||
case HFP_CMD_OK:
|
||||
@ -1622,8 +1633,14 @@ void hfp_hf_activate_voice_recognition_notification(hci_con_handle_t acl_handle)
|
||||
log_error("HFP HF: ACL handle 0x%2x is not found.", acl_handle);
|
||||
return;
|
||||
}
|
||||
|
||||
hfp_connection->hf_activate_voice_recognition_notification = 1;
|
||||
|
||||
if (hfp_connection->voice_recognition_state_current == 1){
|
||||
hfp_emit_event(hfp_connection, HFP_SUBEVENT_VOICE_RECOGNITION_STATUS, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
hfp_connection->command = HFP_CMD_HF_ACTIVATE_VOICE_RECOGNITION;
|
||||
hfp_connection->voice_recognition_state_required = 1;
|
||||
hfp_hf_run_for_context(hfp_connection);
|
||||
}
|
||||
|
||||
@ -1634,7 +1651,13 @@ void hfp_hf_deactivate_voice_recognition_notification(hci_con_handle_t acl_handl
|
||||
return;
|
||||
}
|
||||
|
||||
hfp_connection->hf_deactivate_voice_recognition_notification = 1;
|
||||
if (hfp_connection->voice_recognition_state_current == 0){
|
||||
hfp_emit_event(hfp_connection, HFP_SUBEVENT_VOICE_RECOGNITION_STATUS, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
hfp_connection->command = HFP_CMD_HF_ACTIVATE_VOICE_RECOGNITION;
|
||||
hfp_connection->voice_recognition_state_required = 0;
|
||||
hfp_hf_run_for_context(hfp_connection);
|
||||
}
|
||||
|
||||
@ -1809,11 +1832,11 @@ void hfp_hf_create_sdp_record(uint8_t * service, uint32_t service_record_handle,
|
||||
}
|
||||
|
||||
if (supported_features & (1 << HFP_HFSF_ENHANCED_VOICE_RECOGNITION_STATUS)){
|
||||
sdp_features |= 1 << 5;
|
||||
sdp_features |= 1 << 6;
|
||||
}
|
||||
|
||||
if (supported_features & (1 << HFP_HFSF_VOICE_RECOGNITION_TEXT)){
|
||||
sdp_features |= 1 << 5;
|
||||
sdp_features |= 1 << 7;
|
||||
}
|
||||
|
||||
de_add_number(service, DE_UINT, DE_SIZE_16, 0x0311); // Hands-Free Profile - SupportedFeatures
|
||||
|
@ -65,7 +65,8 @@
|
||||
uint8_t hfp_service_buffer[150];
|
||||
const uint8_t rfcomm_channel_nr = 1;
|
||||
const char hfp_hf_service_name[] = "HFP HF Demo";
|
||||
|
||||
static const int wide_band_speech = 1;
|
||||
|
||||
#ifdef HAVE_BTSTACK_STDIN
|
||||
// static const char * device_addr_string = "6C:72:E7:10:22:EE";
|
||||
static const char * device_addr_string = "00:1B:DC:08:E2:5C";
|
||||
@ -562,6 +563,9 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t * even
|
||||
printf(" - type : %d \n", hfp_subevent_subscriber_number_information_get_bnip_type(event));
|
||||
printf(" - number : %s \n", hfp_subevent_subscriber_number_information_get_bnip_number(event));
|
||||
break;
|
||||
|
||||
case HFP_SUBEVENT_VOICE_RECOGNITION_STATUS:
|
||||
printf("Voice recognition status %d\n", hfp_subevent_voice_recognition_status_get_activated(event));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -610,7 +614,6 @@ int btstack_main(int argc, const char * argv[]){
|
||||
(1<<HFP_HFSF_CODEC_NEGOTIATION) |
|
||||
(1<<HFP_HFSF_ENHANCED_CALL_STATUS) |
|
||||
(1<<HFP_HFSF_ENHANCED_CALL_CONTROL) |
|
||||
int wide_band_speech = 1;
|
||||
(1<<HFP_HFSF_VOICE_RECOGNITION_FUNCTION) |
|
||||
(1<<HFP_HFSF_THREE_WAY_CALLING) |
|
||||
(1<<HFP_HFSF_EC_NR_FUNCTION) |
|
||||
|
Loading…
x
Reference in New Issue
Block a user