summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorVinicius Costa Gomes <vinicius.gomes@openbossa.org>2013-04-15 10:54:50 -0300
committerDenis Kenzior <denkenz@gmail.com>2013-04-15 07:00:39 -0500
commit4e7f0690e9827eef6cf413611c589bb023fcb7c1 (patch)
tree6b8c387e321c906218592ee2c47496480b4e182b /plugins
parent9ef5953a562234714389e574703d2506d4cd3112 (diff)
downloadofono-4e7f0690e9827eef6cf413611c589bb023fcb7c1.tar.bz2
hfp_hf_bluez5: Watch for changes in the selected codec
This patch adds a function to monitor when the AG sends a new codec before establishing the SCO connection.
Diffstat (limited to 'plugins')
-rw-r--r--plugins/hfp_hf_bluez5.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/plugins/hfp_hf_bluez5.c b/plugins/hfp_hf_bluez5.c
index c63b1a20..2c67a215 100644
--- a/plugins/hfp_hf_bluez5.c
+++ b/plugins/hfp_hf_bluez5.c
@@ -314,9 +314,49 @@ static struct ofono_modem_driver hfp_driver = {
.post_sim = hfp_post_sim,
};
+static void bcs_notify(GAtResult *result, gpointer user_data)
+{
+ struct hfp *hfp = user_data;
+ struct hfp_slc_info *info = &hfp->info;
+ GAtResultIter iter;
+ char str[32];
+ int value;
+
+ g_at_result_iter_init(&iter, result);
+
+ if (!g_at_result_iter_next(&iter, "+BCS:"))
+ return;
+
+ if (!g_at_result_iter_next_number(&iter, &value))
+ return;
+
+ if (ofono_handsfree_card_set_codec(hfp->card, value) == FALSE) {
+ /* Unsupported codec, re-send our codecs */
+ 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);
+
+ goto done;
+ }
+
+ /* Confirm the codec */
+ sprintf(str, "AT+BCS=%d", value);
+
+done:
+ g_at_chat_send(info->chat, str, NULL, NULL, NULL, NULL);
+}
+
static int hfp16_card_probe(struct ofono_handsfree_card *card,
unsigned int vendor, void *data)
{
+ struct hfp *hfp = data;
+ struct hfp_slc_info *info = &hfp->info;
+
+ g_at_chat_register(info->chat, "+BCS:", bcs_notify, FALSE,
+ hfp, NULL);
+
return 0;
}