From c331da9e604a4ed9df714bf64837fba68b2c8bc2 Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Mon, 23 Nov 2015 22:42:03 +0100 Subject: [PATCH] hfp: add voice recognition on/off commands. start audio connection if needed --- src/hfp_ag.c | 6 +++++- test/pts/hfp_ag_test.c | 11 +++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/hfp_ag.c b/src/hfp_ag.c index 6470c8919..d30c0c62a 100644 --- a/src/hfp_ag.c +++ b/src/hfp_ag.c @@ -399,7 +399,7 @@ static int hfp_ag_cmd_suggest_codec(uint16_t cid, uint8_t codec){ static int hfp_ag_activate_voice_recognition_cmd(uint16_t cid, uint8_t activate_voice_recognition){ char buffer[30]; - sprintf(buffer, "\r\n%s:%d\r\n", HFP_ACTIVATE_VOICE_RECOGNITION, activate_voice_recognition); + sprintf(buffer, "\r\n%s: %d\r\n", HFP_ACTIVATE_VOICE_RECOGNITION, activate_voice_recognition); return send_str_over_rfcomm(cid, buffer); } @@ -1679,6 +1679,10 @@ void hfp_ag_activate_voice_recognition(bd_addr_t bd_addr, int activate){ hfp_connection_t * connection = get_hfp_connection_context_for_bd_addr(bd_addr); if (connection->ag_activate_voice_recognition == activate) return; + if (activate){ + hfp_ag_establish_audio_connection(bd_addr); + } + connection->ag_activate_voice_recognition = activate; connection->command = HFP_CMD_AG_ACTIVATE_VOICE_RECOGNITION; hfp_run_for_context(connection); diff --git a/test/pts/hfp_ag_test.c b/test/pts/hfp_ag_test.c index 3085746c1..4dc495e0f 100644 --- a/test/pts/hfp_ag_test.c +++ b/test/pts/hfp_ag_test.c @@ -152,6 +152,9 @@ static void show_usage(void){ printf("m - simulate incoming call from 7654321\n"); // printf("M - simulate call from 7654321 dropped\n"); + printf("n - Disable Voice Regocnition\n"); + printf("N - Enable Voice Recognition\n"); + printf("t - terminate connection\n"); printf("---\n"); @@ -270,6 +273,14 @@ static int stdin_process(struct data_source *ds){ printf("Last dialed number set\n"); last_number_exists = 1; break; + case 'n': + printf("Disable Voice Recognition\n"); + hfp_ag_activate_voice_recognition(device_addr, 0); + break; + case 'N': + printf("Enable Voice Recognition\n"); + hfp_ag_activate_voice_recognition(device_addr, 1); + break; case 'R': printf("Enable in-band ring tone\n"); hfp_ag_set_use_in_band_ring_tone(1);