summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorDenis Kenzior <denkenz@gmail.com>2015-04-22 18:07:14 -0500
committerDenis Kenzior <denkenz@gmail.com>2015-05-13 09:57:53 -0500
commit8d47f97106f2a39c8b5b1ab472a8c5aacda46761 (patch)
treeb5e51c79d39febcec044d5d97def59d772da2ab6 /plugins
parentfdba39b8ed234f5553050b210e0a4121eeaf0af5 (diff)
downloadofono-8d47f97106f2a39c8b5b1ab472a8c5aacda46761.tar.bz2
hfp_hf_bluez5: Implement sco_connected_hint
Diffstat (limited to 'plugins')
-rw-r--r--plugins/hfp_hf_bluez5.c48
1 files changed, 42 insertions, 6 deletions
diff --git a/plugins/hfp_hf_bluez5.c b/plugins/hfp_hf_bluez5.c
index 2bed2a12..5ee70c55 100644
--- a/plugins/hfp_hf_bluez5.c
+++ b/plugins/hfp_hf_bluez5.c
@@ -69,6 +69,7 @@ struct hfp {
struct hfp_slc_info info;
DBusMessage *msg;
struct ofono_handsfree_card *card;
+ unsigned int bcc_id;
};
static const char *none_prefix[] = { NULL };
@@ -372,8 +373,12 @@ 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_handsfree_card *card = cbd->user;
+ struct hfp *hfp = ofono_handsfree_card_get_data(card);
struct ofono_error error;
+ hfp->bcc_id = 0;
+
decode_at_error(&error, g_at_result_final_response(result));
cb(&error, cbd->data);
@@ -390,8 +395,10 @@ static void hfp16_card_connect(struct ofono_handsfree_card *card,
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", none_prefix, bcc_cb,
- cbd, g_free);
+ cbd->user = card;
+ hfp->bcc_id = g_at_chat_send(info->chat, "AT+BCC",
+ none_prefix, bcc_cb,
+ cbd, g_free);
return;
}
@@ -404,11 +411,40 @@ static void hfp16_card_connect(struct ofono_handsfree_card *card,
ofono_handsfree_card_connect_sco(card);
}
+static void hfp16_sco_connected_hint(struct ofono_handsfree_card *card)
+{
+ struct hfp *hfp = ofono_handsfree_card_get_data(card);
+ struct hfp_slc_info *info = &hfp->info;
+ struct cb_data *cbd;
+ ofono_handsfree_card_connect_cb_t cb;
+
+ /*
+ * SCO has just been connected, probably initiated by the AG.
+ * If we have any outstanding BCC requests, then lets cancel these
+ * as they're no longer needed
+ */
+
+ if (hfp->bcc_id == 0)
+ return;
+
+ cbd = g_at_chat_get_userdata(info->chat, hfp->bcc_id);
+ if (cbd == NULL)
+ return;
+
+ cb = cbd->cb;
+ CALLBACK_WITH_SUCCESS(cb, cbd->data);
+
+ /* cbd will be freed once cancel is processed */
+ g_at_chat_cancel(info->chat, hfp->bcc_id);
+ hfp->bcc_id = 0;
+}
+
static struct ofono_handsfree_card_driver hfp16_hf_driver = {
- .name = HFP16_HF_DRIVER,
- .probe = hfp16_card_probe,
- .remove = hfp16_card_remove,
- .connect = hfp16_card_connect,
+ .name = HFP16_HF_DRIVER,
+ .probe = hfp16_card_probe,
+ .remove = hfp16_card_remove,
+ .connect = hfp16_card_connect,
+ .sco_connected_hint = hfp16_sco_connected_hint,
};
static ofono_bool_t device_path_compare(struct ofono_modem *modem,