All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mbm: implement Online property
@ 2010-08-23 17:49 Pekka.Pessi
  0 siblings, 0 replies; only message in thread
From: Pekka.Pessi @ 2010-08-23 17:49 UTC (permalink / raw)
  To: ofono

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

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

---
 plugins/mbm.c |   42 ++++++++++++++++++++++++++++++++++++++----
 1 files changed, 38 insertions(+), 4 deletions(-)

diff --git a/plugins/mbm.c b/plugins/mbm.c
index 753a4f1..c9b0ea4 100644
--- a/plugins/mbm.c
+++ b/plugins/mbm.c
@@ -47,6 +47,7 @@
 #include <ofono/log.h>
 
 #include <drivers/atmodem/vendor.h>
+#include <drivers/atmodem/atutil.h>
 
 static const char *cfun_prefix[] = { "+CFUN:", NULL };
 static const char *cpin_prefix[] = { "+CPIN:", NULL };
@@ -169,8 +170,8 @@ static void cfun_query(gboolean ok, GAtResult *result, gpointer user_data)
 
 	g_at_result_iter_next_number(&iter, &status);
 
-	if (status == 4) {
-		g_at_chat_send(data->modem_port, "AT+CFUN=1", none_prefix,
+	if (status != 4) {
+		g_at_chat_send(data->modem_port, "AT+CFUN=4", none_prefix,
 				cfun_enable, modem, NULL);
 		return;
 	}
@@ -365,6 +366,30 @@ static int mbm_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 mbm_set_online(struct ofono_modem *modem, ofono_bool_t online,
+				ofono_modem_online_cb_t cb, void *user_data)
+{
+	struct mbm_data *data = 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");
+
+	g_at_chat_send(data->modem_port, command, NULL,
+			set_online_cb, cbd, g_free);
+}
+
 static void mbm_pre_sim(struct ofono_modem *modem)
 {
 	struct mbm_data *data = ofono_modem_get_data(modem);
@@ -383,12 +408,19 @@ static void mbm_pre_sim(struct ofono_modem *modem)
 static void mbm_post_sim(struct ofono_modem *modem)
 {
 	struct mbm_data *data = ofono_modem_get_data(modem);
-	struct ofono_gprs *gprs;
-	struct ofono_gprs_context *gc;
 
 	DBG("%p", modem);
 
 	ofono_stk_create(modem, 0, "mbmmodem", data->modem_port);
+}
+
+static void mbm_post_online(struct ofono_modem *modem)
+{
+	struct mbm_data *data = ofono_modem_get_data(modem);
+	struct ofono_gprs *gprs;
+	struct ofono_gprs_context *gc;
+
+	DBG("%p", modem);
 
 	ofono_netreg_create(modem, OFONO_VENDOR_MBM,
 					"atmodem", data->modem_port);
@@ -412,8 +444,10 @@ static struct ofono_modem_driver mbm_driver = {
 	.remove		= mbm_remove,
 	.enable		= mbm_enable,
 	.disable	= mbm_disable,
+	.set_online     = mbm_set_online,
 	.pre_sim	= mbm_pre_sim,
 	.post_sim	= mbm_post_sim,
+	.post_online    = mbm_post_online,
 };
 
 static int mbm_init(void)
-- 
1.7.0.4


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2010-08-23 17:49 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-23 17:49 [PATCH] mbm: implement Online property Pekka.Pessi

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.