All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pekka.Pessi@nokia.com
To: ofono@ofono.org
Subject: [online PATCH 3/9] hso: implement Online property
Date: Tue, 24 Aug 2010 14:31:58 +0300	[thread overview]
Message-ID: <1282649524-31353-4-git-send-email-Pekka.Pessi@nokia.com> (raw)
In-Reply-To: <1282649524-31353-3-git-send-email-Pekka.Pessi@nokia.com>

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

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

---
 plugins/hso.c |   32 +++++++++++++++++++++++++++++---
 1 files changed, 29 insertions(+), 3 deletions(-)

diff --git a/plugins/hso.c b/plugins/hso.c
index 8611e07..7433a7b 100644
--- a/plugins/hso.c
+++ b/plugins/hso.c
@@ -46,6 +46,7 @@
 #include <ofono/log.h>
 
 #include <drivers/atmodem/vendor.h>
+#include <drivers/atmodem/atutil.h>
 
 static const char *none_prefix[] = { NULL };
 
@@ -172,7 +173,7 @@ static int hso_enable(struct ofono_modem *modem)
 	g_at_chat_send(data->control, "ATE0", none_prefix, NULL, NULL, NULL);
 	g_at_chat_send(data->app, "ATE0", none_prefix, NULL, NULL, NULL);
 
-	g_at_chat_send(data->control, "AT+CFUN=1", none_prefix,
+	g_at_chat_send(data->control, "AT+CFUN=4", none_prefix,
 					cfun_enable, modem, NULL);
 
 	return -EINPROGRESS;
@@ -213,6 +214,30 @@ static int hso_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 hso_set_online(struct ofono_modem *modem, ofono_bool_t online,
+				ofono_modem_online_cb_t cb, void *user_data)
+{
+	struct hso_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->control, command, NULL,
+			set_online_cb, cbd, g_free);
+}
+
 static void hso_pre_sim(struct ofono_modem *modem)
 {
 	struct hso_data *data = ofono_modem_get_data(modem);
@@ -228,7 +253,7 @@ static void hso_pre_sim(struct ofono_modem *modem)
 		ofono_sim_inserted_notify(sim, TRUE);
 }
 
-static void hso_post_sim(struct ofono_modem *modem)
+static void hso_post_online(struct ofono_modem *modem)
 {
 	struct hso_data *data = ofono_modem_get_data(modem);
 	struct ofono_gprs *gprs;
@@ -260,8 +285,9 @@ static struct ofono_modem_driver hso_driver = {
 	.remove		= hso_remove,
 	.enable		= hso_enable,
 	.disable	= hso_disable,
+	.set_online     = hso_set_online,
 	.pre_sim	= hso_pre_sim,
-	.post_sim	= hso_post_sim,
+	.post_online	= hso_post_online,
 };
 
 static int hso_init(void)
-- 
1.7.0.4


  reply	other threads:[~2010-08-24 11:31 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-24 11:31 [online PATCH 0/9] implement Online properties Pekka.Pessi
2010-08-24 11:31 ` [online PATCH 1/9] atgen: implement Online property Pekka.Pessi
2010-08-24 11:31   ` [online PATCH 2/9] g1: " Pekka.Pessi
2010-08-24 11:31     ` Pekka.Pessi [this message]
2010-08-24 11:31       ` [online PATCH 4/9] huawei: " Pekka.Pessi
2010-08-24 11:32         ` [online PATCH 5/9] nokia: " Pekka.Pessi
2010-08-24 11:32           ` [online PATCH 6/9] novatel: " Pekka.Pessi
2010-08-24 11:32             ` [online PATCH 7/9] palmpre: " Pekka.Pessi
2010-08-24 11:32               ` [online PATCH 8/9] ste: " Pekka.Pessi
2010-08-24 11:32                 ` [online PATCH 9/9] zte: " Pekka.Pessi
2010-08-24 16:21           ` [online PATCH 5/9] nokia: " Marcel Holtmann
2010-08-24 16:20         ` [online PATCH 4/9] huawei: " 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=1282649524-31353-4-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.