From: Olivier Guiter <olivier.guiter@linux.intel.com>
To: ofono@ofono.org
Subject: [PATCH 2/2] emulator: Add +CGMI and +CGDCONT commands
Date: Tue, 15 Feb 2011 14:19:23 +0100 [thread overview]
Message-ID: <1297775963-3426-3-git-send-email-olivier.guiter@linux.intel.com> (raw)
In-Reply-To: <1297775963-3426-1-git-send-email-olivier.guiter@linux.intel.com>
[-- Attachment #1: Type: text/plain, Size: 2200 bytes --]
---
include/emulator.h | 7 ++++++-
src/emulator.c | 28 ++++++++++++++++++++++++----
2 files changed, 30 insertions(+), 5 deletions(-)
diff --git a/include/emulator.h b/include/emulator.h
index 2334e02..94053f1 100644
--- a/include/emulator.h
+++ b/include/emulator.h
@@ -27,8 +27,13 @@ extern "C" {
#endif
#include <ofono/types.h>
+#include <gatserver.h>
-struct ofono_emulator;
+struct ofono_emulator {
+ struct ofono_atom *atom;
+ GAtServer *server;
+ struct ofono_atom *gprs_atom;
+};
enum ofono_emulator_type {
OFONO_EMULATOR_TYPE_DUN,
diff --git a/src/emulator.c b/src/emulator.c
index c49283d..0ed2ae5 100644
--- a/src/emulator.c
+++ b/src/emulator.c
@@ -28,10 +28,23 @@
#include "ofono.h"
#include "gatserver.h"
-struct ofono_emulator {
- struct ofono_atom *atom;
- GAtServer *server;
-};
+static void cgmi_cb(GAtServerRequestType type, GAtResult *cmd, gpointer user)
+{
+ struct ofono_emulator *em = user;
+ GAtServer *server = em->server;
+
+ switch (type) {
+ case G_AT_SERVER_REQUEST_TYPE_COMMAND_ONLY:
+ g_at_server_send_info(server, "oFono", TRUE);
+ g_at_server_send_final(server, G_AT_SERVER_RESULT_OK);
+ break;
+ case G_AT_SERVER_REQUEST_TYPE_SUPPORT:
+ g_at_server_send_final(server, G_AT_SERVER_RESULT_OK);
+ break;
+ default:
+ g_at_server_send_final(server, G_AT_SERVER_RESULT_ERROR);
+ };
+}
static void emulator_debug(const char *str, void *data)
{
@@ -76,6 +89,12 @@ void ofono_emulator_register(struct ofono_emulator *em, int fd)
g_at_server_set_disconnect_function(em->server,
emulator_disconnect, em);
+ /* Register local callbacks */
+ g_at_server_register(em->server, "+CGMI", cgmi_cb, em, NULL);
+
+ /* Register external (atoms) callbacks */
+ ofono_gprs_add_emulator_handler(em);
+
__ofono_atom_register(em->atom, emulator_unregister);
}
@@ -102,6 +121,7 @@ struct ofono_emulator *ofono_emulator_create(struct ofono_modem *modem,
em->atom = __ofono_modem_add_atom(modem, OFONO_ATOM_TYPE_EMULATOR_DUN,
emulator_remove, em);
+ em->gprs_atom = __ofono_modem_find_atom(modem, OFONO_ATOM_TYPE_GPRS);
return em;
}
--
1.7.1
prev parent reply other threads:[~2011-02-15 13:19 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-15 13:19 [PATCH 0/2] Add AT commands handler in emulator Olivier Guiter
2011-02-15 13:19 ` [PATCH 1/2] gprs:Add code to handle AT+CGDCONT Olivier Guiter
2011-02-16 6:32 ` Denis Kenzior
2011-02-16 6:50 ` Marcel Holtmann
2011-02-16 8:30 ` Olivier Guiter
2011-02-15 13:19 ` Olivier Guiter [this message]
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=1297775963-3426-3-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