diff options
author | Vinicius Costa Gomes <vinicius.gomes@openbossa.org> | 2013-04-08 19:40:58 -0300 |
---|---|---|
committer | Denis Kenzior <denkenz@gmail.com> | 2013-04-09 14:33:41 -0500 |
commit | 3697794f9ea70b1efbc4c67db86e47bacec9d8f4 (patch) | |
tree | 76a66cc644462279712b7f9c742af9c81eb8f8db /plugins | |
parent | dcf4ccb94749905c20981e6e5fa25c2e59bbf1e5 (diff) | |
download | ofono-3697794f9ea70b1efbc4c67db86e47bacec9d8f4.tar.bz2 |
hfp_hf_bluez5: Add audio card .connect() for HFP 1.6
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/hfp_hf_bluez5.c | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/plugins/hfp_hf_bluez5.c b/plugins/hfp_hf_bluez5.c index ac6189da..d4a9b238 100644 --- a/plugins/hfp_hf_bluez5.c +++ b/plugins/hfp_hf_bluez5.c @@ -324,11 +324,39 @@ static void hfp16_card_remove(struct ofono_handsfree_card *card) } +static void bcc_cb(gboolean ok, GAtResult *result, gpointer user_data) +{ + struct cb_data *cbd = user_data; + ofono_handsfree_card_connect_cb_t cb = cbd->cb; + struct ofono_error error; + + decode_at_error(&error, g_at_result_final_response(result)); + + cb(&error, cbd->data); +} + static void hfp16_card_connect(struct ofono_handsfree_card *card, ofono_handsfree_card_connect_cb_t cb, void *data) { - CALLBACK_WITH_FAILURE(cb, data); + struct hfp *hfp = ofono_handsfree_card_get_data(card); + struct hfp_slc_info *info = &hfp->info; + + if ((info->hf_features & HFP_HF_FEATURE_CODEC_NEGOTIATION && + info->ag_features & HFP_AG_FEATURE_CODEC_NEGOTIATION)) { + struct cb_data *cbd = cb_data_new(cb, data); + + g_at_chat_send(info->chat, "AT+BCC", NULL, bcc_cb, cbd, g_free); + return; + } + + /* + * If any side (remote or local) doesn't support codec negotiation, + * fallback to direct SCO connection. Calling connect_sco() + * hands the connection responsibility to the core, so no need + * to call the callback + */ + ofono_handsfree_card_connect_sco(card); } static struct ofono_handsfree_card_driver hfp16_hf_driver = { |