Open Source Telephony
 help / color / mirror / Atom feed
From: Olivier Guiter <olivier.guiter@linux.intel.com>
To: ofono@ofono.org
Subject: [PATCH] dun: Add ATX command in emulator (X0 only)
Date: Thu, 24 Mar 2011 16:29:51 +0100	[thread overview]
Message-ID: <1300980591-9395-1-git-send-email-olivier.guiter@linux.intel.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 2290 bytes --]

---
 src/emulator.c |   57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 56 insertions(+), 1 deletions(-)

diff --git a/src/emulator.c b/src/emulator.c
index c84f0a9..101d6b8 100644
--- a/src/emulator.c
+++ b/src/emulator.c
@@ -177,6 +177,59 @@ error:
 	g_at_server_send_final(em->server, G_AT_SERVER_RESULT_ERROR);
 }
 
+static gboolean get_result_value(GAtServer *server, GAtResult *result,
+						int min, int max, int *value)
+{
+	GAtResultIter iter;
+	int val;
+
+	g_at_result_iter_init(&iter, result);
+
+	if (!g_at_result_iter_next(&iter, ""))
+		return FALSE;
+
+	if (!g_at_result_iter_next_number(&iter, &val))
+		return FALSE;
+
+	if (val < min || val > max)
+		return FALSE;
+
+	if (value != NULL)
+		*value = val;
+
+	return TRUE;
+}
+
+static void at_x_cb(GAtServer *server, GAtServerRequestType type,
+				GAtResult *result, gpointer user_data)
+{
+	switch (type) {
+	case G_AT_SERVER_REQUEST_TYPE_SET:
+		if (!get_result_value(server, result, 0, 0, NULL)) {
+			g_at_server_send_final(server,
+						G_AT_SERVER_RESULT_ERROR);
+			return;
+		}
+		/* the value is not stored, as there's only one choice */
+		g_at_server_send_final(server, G_AT_SERVER_RESULT_OK);
+		break;
+
+	case G_AT_SERVER_REQUEST_TYPE_QUERY:
+		g_at_server_send_info(server, "000", TRUE);
+		g_at_server_send_final(server, G_AT_SERVER_RESULT_OK);
+		break;
+
+	case G_AT_SERVER_REQUEST_TYPE_SUPPORT:
+		g_at_server_send_info(server, "X: (0-0)", TRUE);
+		g_at_server_send_final(server, G_AT_SERVER_RESULT_OK);
+		break;
+
+	default:
+		g_at_server_send_final(server, G_AT_SERVER_RESULT_ERROR);
+		break;
+	}
+}
+
 static void brsf_cb(GAtServer *server, GAtServerRequestType type,
 			GAtResult *result, gpointer user_data)
 {
@@ -466,8 +519,10 @@ void ofono_emulator_register(struct ofono_emulator *em, int fd)
 
 	__ofono_atom_register(em->atom, emulator_unregister);
 
-	if (em->type == OFONO_EMULATOR_TYPE_DUN)
+	if (em->type == OFONO_EMULATOR_TYPE_DUN) {
 		g_at_server_register(em->server, "D", dial_cb, em, NULL);
+		g_at_server_register(em->server, "X", at_x_cb, em, NULL);
+	}
 	else if (em->type == OFONO_EMULATOR_TYPE_HFP)
 		g_at_server_set_echo(em->server, FALSE);
 }
-- 
1.7.1


             reply	other threads:[~2011-03-24 15:29 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-24 15:29 Olivier Guiter [this message]
2011-03-25 17:36 ` [PATCH] dun: Add ATX command in emulator (X0 only) Denis Kenzior
2011-03-28  7:49   ` Olivier Guiter
2011-03-28 16:20     ` 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=1300980591-9395-1-git-send-email-olivier.guiter@linux.intel.com \
    --to=olivier.guiter@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox