From: =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis <frederic.danis@linux.intel.com>
To: ofono@ofono.org
Subject: [PATCH 1/2] emulator: add CMER support
Date: Wed, 23 Feb 2011 20:00:25 +0100 [thread overview]
Message-ID: <1298487626-16827-2-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: 3876 bytes --]
---
src/emulator.c | 107 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 105 insertions(+), 2 deletions(-)
diff --git a/src/emulator.c b/src/emulator.c
index f0ca8c8..ca36c0e 100644
--- a/src/emulator.c
+++ b/src/emulator.c
@@ -43,6 +43,8 @@ struct ofono_emulator {
GAtServer *server;
GAtPPP *ppp;
guint source;
+ int events_mode;
+ gboolean events_ind;
GSList *indicators;
};
@@ -251,6 +253,103 @@ fail:
}
}
+static void cmer_cb(GAtServer *server, GAtServerRequestType type,
+ GAtResult *result, gpointer user_data)
+{
+ struct ofono_emulator *em = user_data;
+ char buf[32];
+
+ switch (type) {
+ case G_AT_SERVER_REQUEST_TYPE_QUERY:
+ sprintf(buf, "+CMER: %d,0,0,%d,0", em->events_mode,
+ em->events_ind);
+ g_at_server_send_info(em->server, buf, TRUE);
+ g_at_server_send_final(server, G_AT_SERVER_RESULT_OK);
+ break;
+
+ case G_AT_SERVER_REQUEST_TYPE_SUPPORT:
+ sprintf(buf, "+CMER: (0,3),(0),(0),(0,1),(0)");
+ g_at_server_send_info(em->server, buf, TRUE);
+ g_at_server_send_final(server, G_AT_SERVER_RESULT_OK);
+ break;
+
+ case G_AT_SERVER_REQUEST_TYPE_SET:
+ {
+ GAtResultIter iter;
+ int mode;
+ int ind = em->events_ind;
+ int val;
+
+ g_at_result_iter_init(&iter, result);
+ g_at_result_iter_next(&iter, "");
+
+ /* mode */
+ if (g_at_result_iter_next_number(&iter, &mode) == FALSE)
+ goto fail;
+
+ if ((mode != 0) && (mode != 3))
+ goto fail;
+
+ /* keyp */
+ if (g_at_result_iter_next_number(&iter, &val) == FALSE) {
+ if (g_at_result_iter_skip_next(&iter) == FALSE)
+ goto done;
+ goto fail;
+ }
+
+ if (val != 0)
+ goto fail;
+
+ /* disp */
+ if (g_at_result_iter_next_number(&iter, &val) == FALSE) {
+ if (g_at_result_iter_skip_next(&iter) == FALSE)
+ goto done;
+ goto fail;
+ }
+
+ if (val != 0)
+ goto fail;
+
+ /* ind */
+ if (g_at_result_iter_next_number(&iter, &ind) == FALSE) {
+ if (g_at_result_iter_skip_next(&iter) == FALSE)
+ goto done;
+ goto fail;
+ }
+
+ if ((ind != 0) && (ind != 1))
+ goto fail;
+
+ /* bfr */
+ if (g_at_result_iter_next_number(&iter, &val) == FALSE) {
+ if (g_at_result_iter_skip_next(&iter) == FALSE)
+ goto done;
+ goto fail;
+ }
+
+ if (val != 0)
+ goto fail;
+
+ /* check that bfr is last parameter */
+ if (g_at_result_iter_skip_next(&iter) == TRUE)
+ goto fail;
+
+done:
+ em->events_mode = mode;
+ em->events_ind = ind;
+
+ 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 emulator_add_indicator(struct ofono_emulator *em, const char* name,
int min, int max, int dflt)
{
@@ -324,6 +423,7 @@ void ofono_emulator_register(struct ofono_emulator *em, int fd)
emulator_add_indicator(em, OFONO_EMULATOR_IND_BATTERY, 0, 5, 5);
g_at_server_register(em->server, "+CIND", cind_cb, em, NULL);
+ g_at_server_register(em->server, "+CMER", cmer_cb, em, NULL);
}
__ofono_atom_register(em->atom, emulator_unregister);
@@ -364,6 +464,7 @@ struct ofono_emulator *ofono_emulator_create(struct ofono_modem *modem,
return NULL;
em->type = type;
+ em->events_mode = 3; /* default mode is forwarding events */
em->atom = __ofono_modem_add_atom_offline(modem, atom_t,
emulator_remove, em);
@@ -546,8 +647,10 @@ void ofono_emulator_set_indicator(struct ofono_emulator *em,
ind->value = value;
- sprintf(buf, "+CIEV: %d,%d", i, ind->value);
- g_at_server_send_info(em->server, buf, TRUE);
+ if (em->events_mode == 3 && em->events_ind) {
+ sprintf(buf, "+CIEV: %d,%d", i, ind->value);
+ g_at_server_send_info(em->server, buf, TRUE);
+ }
return;
}
--
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 ` =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis [this message]
2011-02-23 20:13 ` [PATCH 1/2] emulator: add CMER support Denis Kenzior
2011-02-24 10:56 ` Frederic Danis
2011-02-23 19:00 ` [PATCH 2/2] emulator: add BRSF support =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2011-02-23 20:13 ` 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-2-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.