summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMikel Astiz <mikel.astiz@bmw-carit.de>2011-10-21 18:51:28 +0200
committerDenis Kenzior <denkenz@gmail.com>2011-10-21 13:14:19 -0500
commitbb0bcef256e878469d66cecb386071b55fe5f39a (patch)
tree39d6c2c3d766ca9a3dbb21de9e8301ecc09e1a79
parentc5f7886cf2b35877940f4333fb9b5a0dfe9e2bc1 (diff)
downloadofono-bb0bcef256e878469d66cecb386071b55fe5f39a.tar.bz2
hfpmodem: Support for AT+BVRA
-rw-r--r--drivers/hfpmodem/handsfree.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/drivers/hfpmodem/handsfree.c b/drivers/hfpmodem/handsfree.c
index 54a5fbae..ad656ce2 100644
--- a/drivers/hfpmodem/handsfree.c
+++ b/drivers/hfpmodem/handsfree.c
@@ -43,12 +43,25 @@
#include "slc.h"
static const char *binp_prefix[] = { "+BINP:", NULL };
+static const char *bvra_prefix[] = { "+BVRA:", NULL };
struct hf_data {
GAtChat *chat;
unsigned int ag_features;
};
+static void hf_generic_set_cb(gboolean ok, GAtResult *result,
+ gpointer user_data)
+{
+ struct cb_data *cbd = user_data;
+ ofono_handsfree_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 bsir_notify(GAtResult *result, gpointer user_data)
{
struct ofono_handsfree *hf = user_data;
@@ -66,12 +79,30 @@ static void bsir_notify(GAtResult *result, gpointer user_data)
ofono_handsfree_set_inband_ringing(hf, (ofono_bool_t) value);
}
+static void bvra_notify(GAtResult *result, gpointer user_data)
+{
+ struct ofono_handsfree *hf = user_data;
+ GAtResultIter iter;
+ int value;
+
+ g_at_result_iter_init(&iter, result);
+
+ if (!g_at_result_iter_next(&iter, "+BVRA:"))
+ return;
+
+ if (!g_at_result_iter_next_number(&iter, &value))
+ return;
+
+ ofono_handsfree_voice_recognition_notify(hf, (ofono_bool_t) value);
+}
+
static gboolean hfp_handsfree_register(gpointer user_data)
{
struct ofono_handsfree *hf = user_data;
struct hf_data *hd = ofono_handsfree_get_data(hf);
g_at_chat_register(hd->chat, "+BSIR:", bsir_notify, FALSE, hf, NULL);
+ g_at_chat_register(hd->chat, "+BVRA:", bvra_notify, FALSE, hf, NULL);
if (hd->ag_features & HFP_AG_FEATURE_IN_BAND_RING_TONE)
ofono_handsfree_set_inband_ringing(hf, TRUE);
@@ -169,11 +200,33 @@ static void hfp_request_phone_number(struct ofono_handsfree *hf,
CALLBACK_WITH_FAILURE(cb, NULL, data);
}
+static void hfp_voice_recognition(struct ofono_handsfree *hf,
+ ofono_bool_t enabled,
+ ofono_handsfree_cb_t cb, void *data)
+{
+ struct hf_data *hd = ofono_handsfree_get_data(hf);
+ struct cb_data *cbd = cb_data_new(cb, data);
+ char buf[64];
+
+ snprintf(buf, sizeof(buf), "AT+BVRA=%d",
+ (int)(enabled));
+
+ if (g_at_chat_send(hd->chat, buf, bvra_prefix,
+ hf_generic_set_cb,
+ cbd, g_free) > 0)
+ return;
+
+ g_free(cbd);
+
+ CALLBACK_WITH_FAILURE(cb, data);
+}
+
static struct ofono_handsfree_driver driver = {
.name = "hfpmodem",
.probe = hfp_handsfree_probe,
.remove = hfp_handsfree_remove,
.request_phone_number = hfp_request_phone_number,
+ .voice_recognition = hfp_voice_recognition,
};
void hfp_handsfree_init(void)