All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pekka.Pessi@nokia.com
To: ofono@ofono.org
Subject: [online-impl-v2 PATCH 01/10] atgen: implement Online property
Date: Mon, 06 Sep 2010 21:46:11 +0300	[thread overview]
Message-ID: <1283798780-16363-2-git-send-email-Pekka.Pessi@nokia.com> (raw)
In-Reply-To: <1283798780-16363-1-git-send-email-Pekka.Pessi@nokia.com>

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

From: Pekka Pessi <Pekka.Pessi@nokia.com>

---
 plugins/atgen.c |   47 ++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 46 insertions(+), 1 deletions(-)

diff --git a/plugins/atgen.c b/plugins/atgen.c
index a6eee60..1ce2467 100644
--- a/plugins/atgen.c
+++ b/plugins/atgen.c
@@ -49,6 +49,7 @@
 #include <ofono/ussd.h>
 #include <ofono/voicecall.h>
 
+#include <drivers/atmodem/atutil.h>
 #include <drivers/atmodem/sim-poll.h>
 
 #include <ofono/gprs.h>
@@ -154,11 +155,45 @@ static int atgen_disable(struct ofono_modem *modem)
 
 	ofono_modem_set_data(modem, NULL);
 
+	g_at_chat_send(chat, "AT+CFUN=4", NULL, NULL, NULL, NULL);
+
 	g_at_chat_unref(chat);
 
 	return 0;
 }
 
+static void set_online_cb(gboolean ok, GAtResult *result, gpointer user_data)
+{
+	struct cb_data *cbd = user_data;
+	ofono_modem_online_cb_t cb = cbd->cb;
+
+	if (ok)
+		CALLBACK_WITH_SUCCESS(cb, cbd->data);
+	else
+		CALLBACK_WITH_FAILURE(cb, cbd->data);
+}
+
+static void atgen_set_online(struct ofono_modem *modem, ofono_bool_t online,
+				ofono_modem_online_cb_t cb, void *user_data)
+{
+	GAtChat *chat = ofono_modem_get_data(modem);
+	struct cb_data *cbd = cb_data_new(cb, user_data);
+	char const *command = online ? "AT+CFUN=1" : "AT+CFUN=4";
+
+	DBG("modem %p %s", modem, online ? "online" : "offline");
+
+	if (!cbd)
+		goto error;
+
+	if (g_at_chat_send(chat, command, NULL, set_online_cb, cbd, g_free))
+		return;
+
+error:
+	g_free(cbd);
+
+	CALLBACK_WITH_FAILURE(cb, cbd->data);
+}
+
 static void atgen_pre_sim(struct ofono_modem *modem)
 {
 	GAtChat *chat = ofono_modem_get_data(modem);
@@ -177,6 +212,15 @@ static void atgen_pre_sim(struct ofono_modem *modem)
 static void atgen_post_sim(struct ofono_modem *modem)
 {
 	GAtChat *chat = ofono_modem_get_data(modem);
+
+	DBG("%p", modem);
+
+	ofono_phonebook_create(modem, 0, "atmodem", chat);
+}
+
+static void atgen_post_online(struct ofono_modem *modem)
+{
+	GAtChat *chat = ofono_modem_get_data(modem);
 	struct ofono_message_waiting *mw;
 	struct ofono_gprs *gprs;
 	struct ofono_gprs_context *gc;
@@ -191,7 +235,6 @@ static void atgen_post_sim(struct ofono_modem *modem)
 	ofono_call_barring_create(modem, 0, "atmodem", chat);
 	ofono_ssn_create(modem, 0, "atmodem", chat);
 	ofono_sms_create(modem, 0, "atmodem", chat);
-	ofono_phonebook_create(modem, 0, "atmodem", chat);
 	gprs = ofono_gprs_create(modem,0, "atmodem", chat);
 	gc = ofono_gprs_context_create(modem, 0, "atmodem", chat);
 	if (gprs && gc)
@@ -208,8 +251,10 @@ static struct ofono_modem_driver atgen_driver = {
 	.remove		= atgen_remove,
 	.enable		= atgen_enable,
 	.disable	= atgen_disable,
+	.set_online     = atgen_set_online,
 	.pre_sim	= atgen_pre_sim,
 	.post_sim	= atgen_post_sim,
+	.post_online	= atgen_post_online,
 };
 
 static int atgen_init(void)
-- 
1.7.0.4


  reply	other threads:[~2010-09-06 18:46 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-06 18:46 [online-impl-v2 PATCH 00/10] implement Online property Pekka.Pessi
2010-09-06 18:46 ` Pekka.Pessi [this message]
2010-09-06 18:46   ` [online-impl-v2 PATCH 02/10] calypso: " Pekka.Pessi
2010-09-06 18:46     ` [online-impl-v2 PATCH 03/10] g1: " Pekka.Pessi
2010-09-06 18:46       ` [online-impl-v2 PATCH 04/10] hso: " Pekka.Pessi
2010-09-06 18:46         ` [online-impl-v2 PATCH 05/10] huawei: " Pekka.Pessi
2010-09-06 18:46           ` [online-impl-v2 PATCH 06/10] mbm: " Pekka.Pessi
2010-09-06 18:46             ` [online-impl-v2 PATCH 07/10] novatel: " Pekka.Pessi
2010-09-06 18:46               ` [online-impl-v2 PATCH 08/10] palmpre: " Pekka.Pessi
2010-09-06 18:46                 ` [online-impl-v2 PATCH 09/10] ste: " Pekka.Pessi
2010-09-06 18:46                   ` [online-impl-v2 PATCH 10/10] zte: " Pekka.Pessi
2010-09-08 23:30                     ` Marcel Holtmann
2010-09-08 23:30                   ` [online-impl-v2 PATCH 09/10] ste: " Marcel Holtmann
2010-09-08 23:30               ` [online-impl-v2 PATCH 07/10] novatel: " Marcel Holtmann
2010-09-08 23:30             ` [online-impl-v2 PATCH 06/10] mbm: " Marcel Holtmann
2010-09-08 23:30           ` [online-impl-v2 PATCH 05/10] huawei: " Marcel Holtmann
2010-09-08 23:30         ` [online-impl-v2 PATCH 04/10] hso: " Marcel Holtmann
2010-09-08 23:30   ` [online-impl-v2 PATCH 01/10] atgen: " Marcel Holtmann
2010-09-08 23:36 ` [online-impl-v2 PATCH 00/10] " Marcel Holtmann
2010-09-14 18:49   ` Pekka Pessi
2010-09-14 21:30     ` Marcel Holtmann
2010-09-14 20:06   ` Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
2010-09-14 21:28     ` Marcel Holtmann

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=1283798780-16363-2-git-send-email-Pekka.Pessi@nokia.com \
    --to=pekka.pessi@nokia.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.