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

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

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

---
 plugins/calypso.c |   43 +++++++++++++++++++++++++++++++++++++++----
 1 files changed, 39 insertions(+), 4 deletions(-)

diff --git a/plugins/calypso.c b/plugins/calypso.c
index a2d4ec8..0cecc76 100644
--- a/plugins/calypso.c
+++ b/plugins/calypso.c
@@ -56,6 +56,7 @@
 #include <ofono/voicecall.h>
 #include <ofono/stk.h>
 
+#include <drivers/atmodem/atutil.h>
 #include <drivers/atmodem/vendor.h>
 
 #define CALYPSO_POWER_PATH "/sys/bus/platform/devices/neo1973-pm-gsm.0/power_on"
@@ -507,7 +508,7 @@ static void calypso_pre_sim(struct ofono_modem *modem)
 	 * mode 4 -> 1 transitions work and have no side effects.
 	 *
 	 * So in order to switch to Offline mode at startup,
-	 * AT+CFUN=1;+CFUN=4 would be needed.
+	 * AT+CFUN=1;+CFUN=4 is be needed.
 	 *
 	 * Additionally AT+CFUN=1 response is not checked: on PIN-enabled
 	 * cards, it will in most situations return "+CME ERROR: SIM PIN
@@ -518,14 +519,47 @@ static void calypso_pre_sim(struct ofono_modem *modem)
 	if (data->have_sim && data->sim)
 		ofono_stk_create(modem, 0, "calypsomodem", data->dlcs[AUX_DLC]);
 
-	g_at_chat_send(data->dlcs[AUX_DLC], "AT+CFUN=1",
+	g_at_chat_send(data->dlcs[AUX_DLC], "AT+CFUN=1;+CFUN=4",
 			none_prefix, NULL, NULL, NULL);
 
 	if (data->have_sim && data->sim)
 		ofono_sim_inserted_notify(data->sim, TRUE);
 }
 
-static void calypso_post_sim(struct ofono_modem *modem)
+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 calypso_set_online(struct ofono_modem *modem, ofono_bool_t online,
+				ofono_modem_online_cb_t cb, void *user_data)
+{
+	struct calypso_data *data = ofono_modem_get_data(modem);
+	GAtChat *chat = data->dlcs[AUX_DLC];
+	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 calypso_post_online(struct ofono_modem *modem)
 {
 	struct calypso_data *data = ofono_modem_get_data(modem);
 	struct ofono_message_waiting *mw;
@@ -553,8 +587,9 @@ static struct ofono_modem_driver calypso_driver = {
 	.remove		= calypso_remove,
 	.enable		= calypso_enable,
 	.disable	= calypso_disable,
+	.set_online     = calypso_set_online,
 	.pre_sim	= calypso_pre_sim,
-	.post_sim	= calypso_post_sim,
+	.post_online	= calypso_post_online,
 };
 
 static int calypso_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   ` Pekka.Pessi [this message]
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-3-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.