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

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

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

---
 plugins/palmpre.c |   49 ++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 46 insertions(+), 3 deletions(-)

diff --git a/plugins/palmpre.c b/plugins/palmpre.c
index 7d2aeb4..081b151 100644
--- a/plugins/palmpre.c
+++ b/plugins/palmpre.c
@@ -44,6 +44,7 @@
 #include <ofono/gprs-context.h>
 #include <ofono/sms.h>
 
+#include <drivers/atmodem/atutil.h>
 #include <drivers/atmodem/vendor.h>
 
 struct palmpre_data {
@@ -132,7 +133,7 @@ static int palmpre_enable(struct ofono_modem *modem)
 	g_at_chat_send(data->chat, "ATZ E0 +CMEE=1", NULL, NULL, NULL, NULL);
 
 	/* Power modem up */
-	g_at_chat_send(data->chat, "AT+CFUN=1", NULL,
+	g_at_chat_send(data->chat, "AT+CFUN=4", NULL,
 			cfun_set_on_cb, modem, NULL);
 
 	return 0;
@@ -167,6 +168,39 @@ static int palmpre_disable(struct ofono_modem *modem)
 	return -EINPROGRESS;
 }
 
+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 palmpre_set_online(struct ofono_modem *modem, ofono_bool_t online,
+				ofono_modem_online_cb_t cb, void *user_data)
+{
+	struct palmpre_data *data = ofono_modem_get_data(modem);
+	GAtChat *chat = data->chat;
+	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 palmpre_pre_sim(struct ofono_modem *modem)
 {
 	struct palmpre_data *data = ofono_modem_get_data(modem);
@@ -186,6 +220,14 @@ static void palmpre_pre_sim(struct ofono_modem *modem)
 static void palmpre_post_sim(struct ofono_modem *modem)
 {
 	struct palmpre_data *data = ofono_modem_get_data(modem);
+	DBG("%p", modem);
+
+	ofono_phonebook_create(modem, 0, "atmodem", data->chat);
+}
+
+static void palmpre_post_online(struct ofono_modem *modem)
+{
+	struct palmpre_data *data = ofono_modem_get_data(modem);
 	struct ofono_message_waiting *mw;
 	struct ofono_gprs *gprs;
 	struct ofono_gprs_context *gc;
@@ -195,7 +237,6 @@ static void palmpre_post_sim(struct ofono_modem *modem)
 	ofono_netreg_create(modem, 0, "atmodem", data->chat);
 	ofono_sms_create(modem, OFONO_VENDOR_QUALCOMM_MSM, "atmodem",
 				data->chat);
-	ofono_phonebook_create(modem, 0, "atmodem", data->chat);
 
 	gprs = ofono_gprs_create(modem, 0, "atmodem", data->chat);
 	gc = ofono_gprs_context_create(modem, 0, "atmodem", data->chat);
@@ -214,8 +255,10 @@ static struct ofono_modem_driver palmpre_driver = {
 	.remove		= palmpre_remove,
 	.enable		= palmpre_enable,
 	.disable	= palmpre_disable,
+	.set_online     = palmpre_set_online,
 	.pre_sim	= palmpre_pre_sim,
-	.post_sim	= palmpre_post_sim
+	.post_sim	= palmpre_post_sim,
+	.post_online	= palmpre_post_online,
 };
 
 static int palmpre_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 ` [online-impl-v2 PATCH 01/10] atgen: " Pekka.Pessi
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               ` Pekka.Pessi [this message]
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-9-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.