From: =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis <frederic.danis@linux.intel.com>
To: ofono@ofono.org
Subject: [PATCH 2/2] emulator: add BRSF support
Date: Wed, 23 Feb 2011 20:00:26 +0100 [thread overview]
Message-ID: <1298487626-16827-3-git-send-email-frederic.danis@linux.intel.com> (raw)
In-Reply-To: <1298487626-16827-1-git-send-email-frederic.danis@linux.intel.com>
[-- Attachment #1: Type: text/plain, Size: 3137 bytes --]
---
src/emulator.c | 45 ++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 44 insertions(+), 1 deletions(-)
diff --git a/src/emulator.c b/src/emulator.c
index ca36c0e..f024468 100644
--- a/src/emulator.c
+++ b/src/emulator.c
@@ -43,6 +43,9 @@ struct ofono_emulator {
GAtServer *server;
GAtPPP *ppp;
guint source;
+ gboolean slc;
+ int l_features;
+ int r_features;
int events_mode;
gboolean events_ind;
GSList *indicators;
@@ -174,6 +177,39 @@ error:
g_at_server_send_final(em->server, G_AT_SERVER_RESULT_ERROR);
}
+static void brsf_cb(GAtServer *server, GAtServerRequestType type,
+ GAtResult *result, gpointer user_data)
+{
+ struct ofono_emulator *em = user_data;
+ GAtResultIter iter;
+ int val;
+ char buf[16];
+
+ switch (type) {
+ case G_AT_SERVER_REQUEST_TYPE_SET:
+ g_at_result_iter_init(&iter, result);
+ g_at_result_iter_next(&iter, "");
+
+ if (g_at_result_iter_next_number(&iter, &val) == FALSE)
+ goto fail;
+
+ if ((val < 0) && (val > 127))
+ goto fail;
+
+ em->r_features = val;
+
+ sprintf(buf, "+BRSF: %d", em->l_features);
+ g_at_server_send_info(em->server, buf, TRUE);
+ g_at_server_send_final(server, G_AT_SERVER_RESULT_OK);
+ break;
+
+ default:
+fail:
+ g_at_server_send_final(server, G_AT_SERVER_RESULT_ERROR);
+ break;
+ }
+}
+
static void cind_cb(GAtServer *server, GAtServerRequestType type,
GAtResult *result, gpointer user_data)
{
@@ -340,6 +376,7 @@ done:
g_at_server_send_final(server, G_AT_SERVER_RESULT_OK);
+ em->slc = TRUE;
break;
}
@@ -422,6 +459,7 @@ void ofono_emulator_register(struct ofono_emulator *em, int fd)
emulator_add_indicator(em, OFONO_EMULATOR_IND_ROAMING, 0, 1, 0);
emulator_add_indicator(em, OFONO_EMULATOR_IND_BATTERY, 0, 5, 5);
+ g_at_server_register(em->server, "+BRSF", brsf_cb, em, NULL);
g_at_server_register(em->server, "+CIND", cind_cb, em, NULL);
g_at_server_register(em->server, "+CMER", cmer_cb, em, NULL);
}
@@ -464,6 +502,8 @@ struct ofono_emulator *ofono_emulator_create(struct ofono_modem *modem,
return NULL;
em->type = type;
+ /* TODO: Check real local features */
+ em->l_features = 32;
em->events_mode = 3; /* default mode is forwarding events */
em->atom = __ofono_modem_add_atom_offline(modem, atom_t,
@@ -545,6 +585,9 @@ static void handler_proxy(GAtServer *server, GAtServerRequestType type,
struct handler *h = userdata;
struct ofono_emulator_request req;
+ if ((h->em->type == OFONO_EMULATOR_TYPE_HFP) && !h->em->slc)
+ g_at_server_send_final(h->em->server, G_AT_SERVER_RESULT_ERROR);
+
switch (type) {
case G_AT_SERVER_REQUEST_TYPE_COMMAND_ONLY:
req.type = OFONO_EMULATOR_REQUEST_TYPE_COMMAND_ONLY;
@@ -647,7 +690,7 @@ void ofono_emulator_set_indicator(struct ofono_emulator *em,
ind->value = value;
- if (em->events_mode == 3 && em->events_ind) {
+ if (em->events_mode == 3 && em->events_ind && em->slc) {
sprintf(buf, "+CIEV: %d,%d", i, ind->value);
g_at_server_send_info(em->server, buf, TRUE);
}
--
1.7.1
next prev parent reply other threads:[~2011-02-23 19:00 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-23 19:00 [PATCH 0/2] bluetooth: add CMER and BRSF support in HFP AG =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2011-02-23 19:00 ` [PATCH 1/2] emulator: add CMER support =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2011-02-23 20:13 ` Denis Kenzior
2011-02-24 10:56 ` Frederic Danis
2011-02-23 19:00 ` =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis [this message]
2011-02-23 20:13 ` [PATCH 2/2] emulator: add BRSF support Denis Kenzior
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1298487626-16827-3-git-send-email-frederic.danis@linux.intel.com \
--to=frederic.danis@linux.intel.com \
--cc=ofono@ofono.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.