All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH_v2] huaweicdma: open 2 ttys, to use a dedicated one for PPP.
@ 2011-07-27  8:07 Bertrand Aygon
  2011-07-27 13:53 ` Marcel Holtmann
  0 siblings, 1 reply; 4+ messages in thread
From: Bertrand Aygon @ 2011-07-27  8:07 UTC (permalink / raw)
  To: ofono

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

---
 plugins/huaweicdma.c |  106 +++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 87 insertions(+), 19 deletions(-)

diff --git a/plugins/huaweicdma.c b/plugins/huaweicdma.c
index 7288850..dccf17e 100644
--- a/plugins/huaweicdma.c
+++ b/plugins/huaweicdma.c
@@ -38,7 +38,8 @@
 #include <ofono/log.h>
 
 struct huaweicdma_data {
-	GAtChat *chat;
+	GAtChat *modem;
+	GAtChat *pcui;
 };
 
 static void huaweicdma_debug(const char *str, void *data)
@@ -71,39 +72,97 @@ static void huaweicdma_remove(struct ofono_modem *modem)
 
 	ofono_modem_set_data(modem, NULL);
 
-	g_at_chat_unref(data->chat);
-
 	g_free(data);
 }
 
-static int huaweicdma_enable(struct ofono_modem *modem)
+static void cfun_enable(gboolean ok, GAtResult *result, gpointer user_data)
 {
+	struct ofono_modem *modem = user_data;
 	struct huaweicdma_data *data = ofono_modem_get_data(modem);
-	GAtSyntax *syntax;
-	GIOChannel *channel;
+
+	DBG("");
+
+	if (!ok) {
+		g_at_chat_unref(data->modem);
+		data->modem = NULL;
+
+		g_at_chat_unref(data->pcui);
+		data->pcui = NULL;
+	}
+
+	ofono_modem_set_powered(modem, ok);
+}
+
+static GAtChat *open_device(struct ofono_modem *modem,
+				const char *key, char *debug)
+{
 	const char *device;
+	GIOChannel *channel;
+	GAtSyntax *syntax;
+	GAtChat *chat;
 
-	device = ofono_modem_get_string(modem, "Device");
+	device = ofono_modem_get_string(modem, key);
 	if (device == NULL)
-		return -EINVAL;
+		return NULL;
+
+	DBG("%s %s", key, device);
 
 	channel = g_at_tty_open(device, NULL);
 	if (channel == NULL)
-		return -EIO;
+		return NULL;
 
 	syntax = g_at_syntax_new_gsm_permissive();
-	data->chat = g_at_chat_new(channel, syntax);
+	chat = g_at_chat_new(channel, syntax);
 	g_at_syntax_unref(syntax);
 
 	g_io_channel_unref(channel);
 
-	if (data->chat == NULL)
-		return -ENOMEM;
+	if (chat == NULL)
+		return NULL;
 
 	if (getenv("OFONO_AT_DEBUG"))
-		g_at_chat_set_debug(data->chat, huaweicdma_debug, "Device: ");
+		g_at_chat_set_debug(chat, huaweicdma_debug, debug);
 
-	return 0;
+	return chat;
+}
+
+static int huaweicdma_enable(struct ofono_modem *modem)
+{
+	struct huaweicdma_data *data = ofono_modem_get_data(modem);
+
+	DBG("");
+
+	data->modem = open_device(modem, "Modem", "Modem: ");
+	if (data->modem == NULL)
+		return -EINVAL;
+
+	data->pcui = open_device(modem, "Pcui", "PCUI: ");
+	if (data->pcui == NULL) {
+		g_at_chat_unref(data->modem);
+		data->modem = NULL;
+		return -EIO;
+	}
+
+	g_at_chat_send(data->modem, "ATE0 &C0 +CMEE=1", NULL, NULL, NULL, NULL);
+	g_at_chat_send(data->pcui, "ATE0 &C0 +CMEE=1", NULL, NULL, NULL, NULL);
+
+	g_at_chat_send(data->pcui, "AT+CFUN=1", NULL, cfun_enable, modem, NULL);
+
+	return -EINPROGRESS;
+}
+
+static void cfun_disable(gboolean ok, GAtResult *result, gpointer user_data)
+{
+	struct ofono_modem *modem = user_data;
+	struct huaweicdma_data *data = ofono_modem_get_data(modem);
+
+	DBG("");
+
+	g_at_chat_unref(data->pcui);
+	data->pcui = NULL;
+
+	if (ok)
+		ofono_modem_set_powered(modem, FALSE);
 }
 
 static int huaweicdma_disable(struct ofono_modem *modem)
@@ -112,10 +171,19 @@ static int huaweicdma_disable(struct ofono_modem *modem)
 
 	DBG("%p", modem);
 
-	g_at_chat_unref(data->chat);
-	data->chat = NULL;
+	g_at_chat_cancel_all(data->modem);
+	g_at_chat_unregister_all(data->modem);
 
-	return 0;
+	g_at_chat_unref(data->modem);
+	data->modem = NULL;
+
+	g_at_chat_cancel_all(data->pcui);
+	g_at_chat_unregister_all(data->pcui);
+
+	g_at_chat_send(data->pcui, "AT+CFUN=0", NULL, cfun_disable,
+				modem, NULL);
+
+	return -EINPROGRESS;
 }
 
 static void huaweicdma_pre_sim(struct ofono_modem *modem)
@@ -124,7 +192,7 @@ static void huaweicdma_pre_sim(struct ofono_modem *modem)
 
 	DBG("%p", modem);
 
-	ofono_devinfo_create(modem, 0, "cdmamodem", data->chat);
+	ofono_devinfo_create(modem, 0, "cdmamodem", data->pcui);
 }
 
 static void huaweicdma_post_sim(struct ofono_modem *modem)
@@ -138,7 +206,7 @@ static void huaweicdma_post_online(struct ofono_modem *modem)
 
 	DBG("%p", modem);
 
-	ofono_cdma_connman_create(modem, 0, "cdmamodem", data->chat);
+	ofono_cdma_connman_create(modem, 0, "cdmamodem", data->modem);
 }
 
 static struct ofono_modem_driver huaweicdma_driver = {
-- 
1.7.4.1

---------------------------------------------------------------------
Intel Corporation SAS (French simplified joint stock company)
Registered headquarters: "Les Montalets"- 2, rue de Paris, 
92196 Meudon Cedex, France
Registration Number:  302 456 199 R.C.S. NANTERRE
Capital: 4,572,000 Euros

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH_v2] huaweicdma: open 2 ttys, to use a dedicated one for PPP.
  2011-07-27  8:07 [PATCH_v2] huaweicdma: open 2 ttys, to use a dedicated one for PPP Bertrand Aygon
@ 2011-07-27 13:53 ` Marcel Holtmann
  0 siblings, 0 replies; 4+ messages in thread
From: Marcel Holtmann @ 2011-07-27 13:53 UTC (permalink / raw)
  To: ofono

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

Hi Bertrand,

>  plugins/huaweicdma.c |  106 +++++++++++++++++++++++++++++++++++++++++---------
>  1 files changed, 87 insertions(+), 19 deletions(-)

patch has been applied. Thanks.

Regards

Marcel



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH_v2] huaweicdma: open 2 ttys, to use a dedicated one for PPP.
  2011-07-26  9:25 Bertrand Aygon
@ 2011-07-26 10:21 ` Marcel Holtmann
  0 siblings, 0 replies; 4+ messages in thread
From: Marcel Holtmann @ 2011-07-26 10:21 UTC (permalink / raw)
  To: ofono

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

Hi Bertrand,

>  plugins/huaweicdma.c |  132 ++++++++++++++++++++++++++++++++++++++++++--------
>  1 files changed, 111 insertions(+), 21 deletions(-)

since the code is still the same as speedupcdma, same comments apply
here (minus the s/aux/pcui/ changes) ;)

Regards

Marcel



^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH_v2] huaweicdma: open 2 ttys, to use a dedicated one for PPP.
@ 2011-07-26  9:25 Bertrand Aygon
  2011-07-26 10:21 ` Marcel Holtmann
  0 siblings, 1 reply; 4+ messages in thread
From: Bertrand Aygon @ 2011-07-26  9:25 UTC (permalink / raw)
  To: ofono

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

---
 plugins/huaweicdma.c |  132 ++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 111 insertions(+), 21 deletions(-)

diff --git a/plugins/huaweicdma.c b/plugins/huaweicdma.c
index 7288850..f819a24 100644
--- a/plugins/huaweicdma.c
+++ b/plugins/huaweicdma.c
@@ -37,8 +37,11 @@
 #include <ofono/cdma-connman.h>
 #include <ofono/log.h>
 
+static const char *none_prefix[] = { NULL };
+
 struct huaweicdma_data {
-	GAtChat *chat;
+	GAtChat *modem;
+	GAtChat *pcui;
 };
 
 static void huaweicdma_debug(const char *str, void *data)
@@ -71,39 +74,114 @@ static void huaweicdma_remove(struct ofono_modem *modem)
 
 	ofono_modem_set_data(modem, NULL);
 
-	g_at_chat_unref(data->chat);
-
 	g_free(data);
 }
 
-static int huaweicdma_enable(struct ofono_modem *modem)
+static void cfun_enable(gboolean ok, GAtResult *result, gpointer user_data)
 {
+	struct ofono_modem *modem = user_data;
 	struct huaweicdma_data *data = ofono_modem_get_data(modem);
+
+	DBG("");
+
+	if (!ok) {
+		g_at_chat_unref(data->modem);
+		data->modem = NULL;
+
+
+		g_at_chat_unref(data->pcui);
+		data->pcui = NULL;
+
+		ofono_modem_set_powered(modem, FALSE);
+		return;
+	}
+
+	ofono_modem_set_powered(modem, TRUE);
+}
+
+static GAtChat *create_port(const char *device)
+{
 	GAtSyntax *syntax;
 	GIOChannel *channel;
-	const char *device;
-
-	device = ofono_modem_get_string(modem, "Device");
-	if (device == NULL)
-		return -EINVAL;
+	GAtChat *chat;
 
 	channel = g_at_tty_open(device, NULL);
 	if (channel == NULL)
-		return -EIO;
+		return NULL;
 
 	syntax = g_at_syntax_new_gsm_permissive();
-	data->chat = g_at_chat_new(channel, syntax);
+	chat = g_at_chat_new(channel, syntax);
 	g_at_syntax_unref(syntax);
-
 	g_io_channel_unref(channel);
 
-	if (data->chat == NULL)
-		return -ENOMEM;
+	if (chat == NULL)
+		return NULL;
+
+	return chat;
+}
+
+static GAtChat *open_device(struct ofono_modem *modem,
+				const char *key, char *debug)
+{
+	const char *device;
+	GAtChat *chat;
+
+	device = ofono_modem_get_string(modem, key);
+	if (device == NULL)
+		return NULL;
+
+	DBG("%s %s", key, device);
+
+	chat = create_port(device);
+	if (chat == NULL)
+		return NULL;
+
+	g_at_chat_add_terminator(chat, "COMMAND NOT SUPPORT", -1, FALSE);
 
 	if (getenv("OFONO_AT_DEBUG"))
-		g_at_chat_set_debug(data->chat, huaweicdma_debug, "Device: ");
+		g_at_chat_set_debug(chat, huaweicdma_debug, debug);
 
-	return 0;
+	return chat;
+}
+
+static int huaweicdma_enable(struct ofono_modem *modem)
+{
+	struct huaweicdma_data *data = ofono_modem_get_data(modem);
+
+	DBG("");
+
+	data->modem = open_device(modem, "Modem", "Modem: ");
+	if (data->modem == NULL)
+		return -EINVAL;
+
+	data->pcui = open_device(modem, "Pcui", "PCUI: ");
+	if (data->pcui == NULL) {
+		g_at_chat_unref(data->modem);
+		data->modem = NULL;
+		return -EIO;
+	}
+
+	g_at_chat_send(data->pcui, "ATE0 +CMEE=1", none_prefix,
+						NULL, NULL, NULL);
+
+	g_at_chat_send(data->pcui, "AT+CFUN=1", none_prefix,
+					cfun_enable, modem, NULL);
+
+	return -EINPROGRESS;
+}
+
+static void cfun_disable(gboolean ok, GAtResult *result, gpointer user_data)
+{
+	struct ofono_modem *modem = user_data;
+	struct huaweicdma_data *data = ofono_modem_get_data(modem);
+
+	DBG("");
+
+	g_at_chat_unref(data->pcui);
+	data->pcui = NULL;
+
+	if (ok)
+		ofono_modem_set_powered(modem, FALSE);
 }
 
 static int huaweicdma_disable(struct ofono_modem *modem)
@@ -112,10 +190,22 @@ static int huaweicdma_disable(struct ofono_modem *modem)
 
 	DBG("%p", modem);
 
-	g_at_chat_unref(data->chat);
-	data->chat = NULL;
+	if (data->modem) {
+		g_at_chat_cancel_all(data->modem);
+		g_at_chat_unregister_all(data->modem);
+		g_at_chat_unref(data->modem);
+		data->modem = NULL;
+	}
 
-	return 0;
+	if (data->pcui == NULL)
+		return 0;
+
+	g_at_chat_cancel_all(data->pcui);
+	g_at_chat_unregister_all(data->pcui);
+	g_at_chat_send(data->pcui, "AT+CFUN=0", none_prefix,
+					cfun_disable, modem, NULL);
+
+	return -EINPROGRESS;
 }
 
 static void huaweicdma_pre_sim(struct ofono_modem *modem)
@@ -124,7 +214,7 @@ static void huaweicdma_pre_sim(struct ofono_modem *modem)
 
 	DBG("%p", modem);
 
-	ofono_devinfo_create(modem, 0, "cdmamodem", data->chat);
+	ofono_devinfo_create(modem, 0, "cdmamodem", data->pcui);
 }
 
 static void huaweicdma_post_sim(struct ofono_modem *modem)
@@ -138,7 +228,7 @@ static void huaweicdma_post_online(struct ofono_modem *modem)
 
 	DBG("%p", modem);
 
-	ofono_cdma_connman_create(modem, 0, "cdmamodem", data->chat);
+	ofono_cdma_connman_create(modem, 0, "cdmamodem", data->modem);
 }
 
 static struct ofono_modem_driver huaweicdma_driver = {
-- 
1.7.4.1

---------------------------------------------------------------------
Intel Corporation SAS (French simplified joint stock company)
Registered headquarters: "Les Montalets"- 2, rue de Paris, 
92196 Meudon Cedex, France
Registration Number:  302 456 199 R.C.S. NANTERRE
Capital: 4,572,000 Euros

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-07-27 13:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-27  8:07 [PATCH_v2] huaweicdma: open 2 ttys, to use a dedicated one for PPP Bertrand Aygon
2011-07-27 13:53 ` Marcel Holtmann
  -- strict thread matches above, loose matches on Subject: below --
2011-07-26  9:25 Bertrand Aygon
2011-07-26 10:21 ` Marcel Holtmann

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.