hfpmodem: Send AT+BAC with the supported codecs
authorVinicius Costa Gomes <vinicius.gomes@openbossa.org>
Mon, 8 Apr 2013 22:41:02 +0000 (19:41 -0300)
committerDenis Kenzior <denkenz@gmail.com>
Tue, 9 Apr 2013 19:33:41 +0000 (14:33 -0500)
Before, the AT+BAC command was being sent with fixed information,
now we send the command (that inform the AG of the codecs supported by
the HF) with the codecs supported by the registered Handsfree Audio
Agent.

drivers/hfpmodem/slc.c

index 0e80ef000c8e8e8679faae5901fccfe9692c77b2..40b22a18630efa5a49b7fbea7a06e18ecb8709b9 100644 (file)
@@ -34,6 +34,7 @@
 #include <ofono/log.h>
 #include <ofono/modem.h>
 #include <ofono/emulator.h>
+#include <ofono/handsfree-audio.h>
 
 #include <drivers/atmodem/atutil.h>
 
@@ -305,9 +306,18 @@ static void brsf_cb(gboolean ok, GAtResult *result, gpointer user_data)
 
        if (info->ag_features & HFP_AG_FEATURE_CODEC_NEGOTIATION &&
                        info->hf_features & HFP_HF_FEATURE_CODEC_NEGOTIATION) {
+               char str[32];
+
+               memset(str, 0, sizeof(str));
+
+               if (ofono_handsfree_audio_has_wideband())
+                       sprintf(str, "AT+BAC=%d,%d", HFP_CODEC_CVSD,
+                                                       HFP_CODEC_MSBC);
+               else
+                       sprintf(str, "AT+BAC=%d", HFP_CODEC_CVSD);
 
                slc_establish_data_ref(sed);
-               g_at_chat_send(info->chat, "AT+BAC=1", NULL, bac_cb, sed,
+               g_at_chat_send(info->chat, str, NULL, bac_cb, sed,
                                                slc_establish_data_unref);
                return;
        }