Open Source Telephony
 help / color / mirror / Atom feed
* [PATCH v2 0/6] Huawei GPRS support
@ 2010-04-30 12:54 Kalle Valo
  2010-04-30 12:54 ` [PATCH v2 1/6] atmodem: create struct atmodem_gprs Kalle Valo
                   ` (5 more replies)
  0 siblings, 6 replies; 12+ messages in thread
From: Kalle Valo @ 2010-04-30 12:54 UTC (permalink / raw)
  To: ofono

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

Hello all,

here's my current patch set of adding Huawei GPRS support to ofono. I
have tested it with Huawei E1552 USB dongle and finnish Saunalahti prepaid
sim.

Because I had to somehow provide the second GAtChat to atmodem's gprs and
netreg modules, I decided to add two new structs.

There's one major bug still, ofono segfaults when I deactivate the gprs
context. I don't know the reason for this yet.

Please comment.

---

Kalle Valo (6):
      huawei: add gprs context
      atmodem: add signal strength support for huawei
      atmodem: follow separate event chat with huawei
      huawei: detect SecondaryDevice which is used for events
      atmodem: create struct atmodem_network_registration
      atmodem: create struct atmodem_gprs


 drivers/atmodem/gprs.c                 |   23 ++++++++---
 drivers/atmodem/gprs.h                 |   29 ++++++++++++++
 drivers/atmodem/network-registration.c |   37 ++++++++++++++++--
 drivers/atmodem/network-registration.h |   29 ++++++++++++++
 plugins/atgen.c                        |    7 +++
 plugins/calypso.c                      |    7 +++
 plugins/em770.c                        |    2 +
 plugins/g1.c                           |    8 +++-
 plugins/hso.c                          |   15 ++++++-
 plugins/huawei.c                       |   66 +++++++++++++++++++++++++++++++-
 plugins/mbm.c                          |   14 ++++++-
 plugins/novatel.c                      |    9 ++++
 plugins/palmpre.c                      |   15 ++++++-
 plugins/phonesim.c                     |   16 ++++++--
 plugins/ste.c                          |   15 ++++++-
 plugins/udev.c                         |   61 ++++++++++++++++++++++++++----
 16 files changed, 319 insertions(+), 34 deletions(-)
 create mode 100644 drivers/atmodem/gprs.h
 create mode 100644 drivers/atmodem/network-registration.h


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

* [PATCH v2 1/6] atmodem: create struct atmodem_gprs
  2010-04-30 12:54 [PATCH v2 0/6] Huawei GPRS support Kalle Valo
@ 2010-04-30 12:54 ` Kalle Valo
  2010-04-30 13:34   ` Marcel Holtmann
  2010-04-30 12:55 ` [PATCH v2 2/6] atmodem: create struct atmodem_network_registration Kalle Valo
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 12+ messages in thread
From: Kalle Valo @ 2010-04-30 12:54 UTC (permalink / raw)
  To: ofono

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

This is need to to provide more chat channels to atmodem gprs module.
---

 drivers/atmodem/gprs.c |    7 ++++---
 drivers/atmodem/gprs.h |   29 +++++++++++++++++++++++++++++
 plugins/hso.c          |    8 +++++++-
 plugins/mbm.c          |    7 ++++++-
 plugins/palmpre.c      |    8 +++++++-
 plugins/phonesim.c     |    7 ++++++-
 plugins/ste.c          |    7 ++++++-
 7 files changed, 65 insertions(+), 8 deletions(-)
 create mode 100644 drivers/atmodem/gprs.h

diff --git a/drivers/atmodem/gprs.c b/drivers/atmodem/gprs.c
index 052417a..d12d9eb 100644
--- a/drivers/atmodem/gprs.c
+++ b/drivers/atmodem/gprs.c
@@ -40,6 +40,7 @@
 
 #include "atmodem.h"
 #include "vendor.h"
+#include "gprs.h"
 
 static const char *cgreg_prefix[] = { "+CGREG:", NULL };
 static const char *cgdcont_prefix[] = { "+CGDCONT:", NULL };
@@ -291,16 +292,16 @@ error:
 static int at_gprs_probe(struct ofono_gprs *gprs,
 					unsigned int vendor, void *data)
 {
-	GAtChat *chat = data;
+	struct atmodem_gprs *atmodem = data;
 	struct gprs_data *gd;
 
 	gd = g_new0(struct gprs_data, 1);
-	gd->chat = chat;
+	gd->chat = atmodem->chat;
 	gd->vendor = vendor;
 
 	ofono_gprs_set_data(gprs, gd);
 
-	g_at_chat_send(chat, "AT+CGDCONT=?", cgdcont_prefix,
+	g_at_chat_send(gd->chat, "AT+CGDCONT=?", cgdcont_prefix,
 			at_cgdcont_test_cb, gprs, NULL);
 
 	return 0;
diff --git a/drivers/atmodem/gprs.h b/drivers/atmodem/gprs.h
new file mode 100644
index 0000000..36388e3
--- /dev/null
+++ b/drivers/atmodem/gprs.h
@@ -0,0 +1,29 @@
+/*
+ *
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2010 Canonical Ltd. All rights reserved.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+struct atmodem_gprs
+{
+	/* primary chat channel */
+	GAtChat *chat;
+
+	/* secondary chat channel for events */
+	GAtChat *event;
+};
diff --git a/plugins/hso.c b/plugins/hso.c
index dd9be67..26f6c81 100644
--- a/plugins/hso.c
+++ b/plugins/hso.c
@@ -26,6 +26,7 @@
 #include <stdio.h>
 #include <errno.h>
 #include <stdlib.h>
+#include <string.h>
 
 #include <glib.h>
 #include <gatchat.h>
@@ -42,6 +43,7 @@
 #include <ofono/gprs-context.h>
 #include <ofono/log.h>
 
+#include <drivers/atmodem/gprs.h>
 #include <drivers/atmodem/vendor.h>
 
 static const char *none_prefix[] = { NULL };
@@ -212,6 +214,7 @@ static void hso_post_sim(struct ofono_modem *modem)
 	struct hso_data *data = ofono_modem_get_data(modem);
 	struct ofono_gprs *gprs;
 	struct ofono_gprs_context *gc;
+	struct atmodem_gprs atmodem_gprs;
 
 	DBG("%p", modem);
 
@@ -219,7 +222,10 @@ static void hso_post_sim(struct ofono_modem *modem)
 				"atmodem", data->app);
 	ofono_sms_create(modem, 0, "atmodem", data->app);
 
-	gprs = ofono_gprs_create(modem, 0, "atmodem", data->app);
+	memset(&atmodem_gprs, 0, sizeof(atmodem_gprs));
+	atmodem_gprs.chat = data->app;
+
+	gprs = ofono_gprs_create(modem, 0, "atmodem", &atmodem_gprs);
 	gc = ofono_gprs_context_create(modem, 0, "hso", data->control);
 
 	if (gprs && gc)
diff --git a/plugins/mbm.c b/plugins/mbm.c
index c67c7a5..518aaaa 100644
--- a/plugins/mbm.c
+++ b/plugins/mbm.c
@@ -26,6 +26,7 @@
 #include <stdio.h>
 #include <errno.h>
 #include <stdlib.h>
+#include <string.h>
 
 #include <glib.h>
 #include <gatchat.h>
@@ -51,6 +52,7 @@
 #include <ofono/gprs.h>
 #include <ofono/gprs-context.h>
 #include <ofono/log.h>
+#include <drivers/atmodem/gprs.h>
 #include <drivers/atmodem/vendor.h>
 
 static const char *cfun_prefix[] = { "+CFUN:", NULL };
@@ -301,6 +303,7 @@ static void mbm_post_sim(struct ofono_modem *modem)
 	struct ofono_message_waiting *mw;
 	struct ofono_gprs *gprs;
 	struct ofono_gprs_context *gc;
+	struct atmodem_gprs atmodem_gprs;
 
 	DBG("%p", modem);
 
@@ -317,7 +320,9 @@ static void mbm_post_sim(struct ofono_modem *modem)
 	ofono_sms_create(modem, 0, "atmodem", data->modem_port);
 	ofono_cbs_create(modem, 0, "atmodem", data->modem_port);
 
-	gprs = ofono_gprs_create(modem, 0, "atmodem", data->modem_port);
+	memset(&atmodem_gprs, 0, sizeof(atmodem_gprs));
+	atmodem_gprs.chat = data->modem_port;
+	gprs = ofono_gprs_create(modem, 0, "atmodem", &atmodem_gprs);
 	gc = ofono_gprs_context_create(modem, 0, "mbm", data->modem_port);
 
 	if (gprs && gc)
diff --git a/plugins/palmpre.c b/plugins/palmpre.c
index 7d2aeb4..9292e55 100644
--- a/plugins/palmpre.c
+++ b/plugins/palmpre.c
@@ -25,6 +25,7 @@
 
 #include <errno.h>
 #include <stdlib.h>
+#include <string.h>
 
 #include <glib.h>
 #include <gatchat.h>
@@ -44,6 +45,7 @@
 #include <ofono/gprs-context.h>
 #include <ofono/sms.h>
 
+#include <drivers/atmodem/gprs.h>
 #include <drivers/atmodem/vendor.h>
 
 struct palmpre_data {
@@ -189,6 +191,7 @@ static void palmpre_post_sim(struct ofono_modem *modem)
 	struct ofono_message_waiting *mw;
 	struct ofono_gprs *gprs;
 	struct ofono_gprs_context *gc;
+	struct atmodem_gprs atmodem_gprs;
 
 	DBG("%p", modem);
 
@@ -197,7 +200,10 @@ static void palmpre_post_sim(struct ofono_modem *modem)
 				data->chat);
 	ofono_phonebook_create(modem, 0, "atmodem", data->chat);
 
-	gprs = ofono_gprs_create(modem, 0, "atmodem", data->chat);
+	memset(&atmodem_gprs, 0, sizeof(atmodem_gprs));
+	atmodem_gprs.chat = data->chat;
+
+	gprs = ofono_gprs_create(modem, 0, "atmodem", &atmodem_gprs);
 	gc = ofono_gprs_context_create(modem, 0, "atmodem", data->chat);
 
 	if (gprs && gc)
diff --git a/plugins/phonesim.c b/plugins/phonesim.c
index d0cd7f3..becd06a 100644
--- a/plugins/phonesim.c
+++ b/plugins/phonesim.c
@@ -58,6 +58,7 @@
 #include <ofono/gprs.h>
 #include <ofono/gprs-context.h>
 
+#include <drivers/atmodem/gprs.h>
 #include <drivers/atmodem/vendor.h>
 #include <drivers/atmodem/sim-poll.h>
 
@@ -301,6 +302,7 @@ static void phonesim_post_sim(struct ofono_modem *modem)
 	struct ofono_message_waiting *mw;
 	struct ofono_gprs *gprs;
 	struct ofono_gprs_context *gc;
+	struct atmodem_gprs atmodem_gprs;
 
 	DBG("%p", modem);
 
@@ -326,7 +328,10 @@ static void phonesim_post_sim(struct ofono_modem *modem)
 		ofono_cbs_create(modem, 0, "atmodem", data->chat);
 	}
 
-	gprs = ofono_gprs_create(modem, 0, "atmodem", data->chat);
+	memset(&atmodem_gprs, 0, sizeof(atmodem_gprs));
+	atmodem_gprs.chat = data->chat;
+
+	gprs = ofono_gprs_create(modem, 0, "atmodem", &atmodem_gprs);
 	gc = ofono_gprs_context_create(modem, 0, "atmodem", data->chat);
 
 	if (gprs && gc)
diff --git a/plugins/ste.c b/plugins/ste.c
index f3ae0b2..a744797 100644
--- a/plugins/ste.c
+++ b/plugins/ste.c
@@ -54,6 +54,7 @@
 #include <ofono/voicecall.h>
 #include <ofono/gprs.h>
 #include <ofono/gprs-context.h>
+#include <drivers/atmodem/gprs.h>
 #include <drivers/atmodem/vendor.h>
 
 #include <drivers/stemodem/caif_socket.h>
@@ -225,6 +226,7 @@ static void ste_post_sim(struct ofono_modem *modem)
 	struct ofono_message_waiting *mw;
 	struct ofono_gprs *gprs;
 	struct ofono_gprs_context *gc;
+	struct atmodem_gprs atmodem_gprs;
 
 	DBG("%p", modem);
 
@@ -239,8 +241,11 @@ static void ste_post_sim(struct ofono_modem *modem)
 	ofono_phonebook_create(modem, 0, "atmodem", data->chat);
 	ofono_call_volume_create(modem, 0, "atmodem", data->chat);
 
+	memset(&atmodem_gprs, 0, sizeof(atmodem_gprs));
+	atmodem_gprs.chat = data->chat;
+
 	gprs = ofono_gprs_create(modem,
-			OFONO_VENDOR_STE, "atmodem", data->chat);
+			OFONO_VENDOR_STE, "atmodem", &atmodem_gprs);
 	gc = ofono_gprs_context_create(modem, 0, "stemodem", data->chat);
 
 	if (gprs && gc)


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

* [PATCH v2 2/6] atmodem: create struct atmodem_network_registration
  2010-04-30 12:54 [PATCH v2 0/6] Huawei GPRS support Kalle Valo
  2010-04-30 12:54 ` [PATCH v2 1/6] atmodem: create struct atmodem_gprs Kalle Valo
@ 2010-04-30 12:55 ` Kalle Valo
  2010-04-30 13:35   ` Marcel Holtmann
  2010-04-30 12:55 ` [PATCH v2 3/6] huawei: detect SecondaryDevice which is used for events Kalle Valo
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 12+ messages in thread
From: Kalle Valo @ 2010-04-30 12:55 UTC (permalink / raw)
  To: ofono

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

Needed to provide more channels to atmodem network_registration module.
---

 drivers/atmodem/network-registration.c |    7 ++++---
 drivers/atmodem/network-registration.h |   26 ++++++++++++++++++++++++++
 plugins/atgen.c                        |    7 ++++++-
 plugins/calypso.c                      |    7 ++++++-
 plugins/em770.c                        |    2 ++
 plugins/g1.c                           |    8 +++++++-
 plugins/hso.c                          |    7 ++++++-
 plugins/huawei.c                       |    9 ++++++++-
 plugins/mbm.c                          |    7 ++++++-
 plugins/novatel.c                      |    9 ++++++++-
 plugins/palmpre.c                      |    7 ++++++-
 plugins/phonesim.c                     |    9 +++++++--
 plugins/ste.c                          |    8 +++++++-
 13 files changed, 99 insertions(+), 14 deletions(-)
 create mode 100644 drivers/atmodem/network-registration.h

diff --git a/drivers/atmodem/network-registration.c b/drivers/atmodem/network-registration.c
index f7aafbe..777cbc3 100644
--- a/drivers/atmodem/network-registration.c
+++ b/drivers/atmodem/network-registration.c
@@ -40,6 +40,7 @@
 
 #include "atmodem.h"
 #include "vendor.h"
+#include "network-registration.h"
 
 static const char *none_prefix[] = { NULL };
 static const char *creg_prefix[] = { "+CREG:", NULL };
@@ -972,17 +973,17 @@ error:
 static int at_netreg_probe(struct ofono_netreg *netreg, unsigned int vendor,
 				void *data)
 {
-	GAtChat *chat = data;
+	struct atmodem_network_registration *nr = data;
 	struct netreg_data *nd;
 
 	nd = g_new0(struct netreg_data, 1);
 
-	nd->chat = chat;
+	nd->chat = nr->chat;
 	nd->vendor = vendor;
 	nd->tech = -1;
 	ofono_netreg_set_data(netreg, nd);
 
-	g_at_chat_send(chat, "AT+CREG=?", creg_prefix,
+	g_at_chat_send(nd->chat, "AT+CREG=?", creg_prefix,
 			at_creg_test_cb, netreg, NULL);
 
 	return 0;
diff --git a/drivers/atmodem/network-registration.h b/drivers/atmodem/network-registration.h
new file mode 100644
index 0000000..506ed7d
--- /dev/null
+++ b/drivers/atmodem/network-registration.h
@@ -0,0 +1,26 @@
+/*
+ *
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2010 Canonical Ltd. All rights reserved.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+struct atmodem_network_registration
+{
+	/* primary chat channel */
+	GAtChat *chat;
+};
diff --git a/plugins/atgen.c b/plugins/atgen.c
index 7c38fde..7d3b280 100644
--- a/plugins/atgen.c
+++ b/plugins/atgen.c
@@ -25,6 +25,7 @@
 
 #include <errno.h>
 #include <stdlib.h>
+#include <string.h>
 
 #include <glib.h>
 #include <gatchat.h>
@@ -50,6 +51,7 @@
 #include <ofono/voicecall.h>
 
 #include <drivers/atmodem/sim-poll.h>
+#include <drivers/atmodem/network-registration.h>
 
 static const char *tty_opts[] = {
 	"Baud",
@@ -174,13 +176,16 @@ static void atgen_post_sim(struct ofono_modem *modem)
 {
 	GAtChat *chat = ofono_modem_get_data(modem);
 	struct ofono_message_waiting *mw;
+	struct atmodem_network_registration atmodem_netreg;
 
 	DBG("%p", modem);
 
+	memset(&atmodem_netreg, 0, sizeof(atmodem_netreg));
+
 	ofono_ussd_create(modem, 0, "atmodem", chat);
 	ofono_call_forwarding_create(modem, 0, "atmodem", chat);
 	ofono_call_settings_create(modem, 0, "atmodem", chat);
-	ofono_netreg_create(modem, 0, "atmodem", chat);
+	ofono_netreg_create(modem, 0, "atmodem", &atmodem_netreg);
 	ofono_call_meter_create(modem, 0, "atmodem", chat);
 	ofono_call_barring_create(modem, 0, "atmodem", chat);
 	ofono_ssn_create(modem, 0, "atmodem", chat);
diff --git a/plugins/calypso.c b/plugins/calypso.c
index 60f3242..5497d67 100644
--- a/plugins/calypso.c
+++ b/plugins/calypso.c
@@ -56,6 +56,7 @@
 #include <ofono/voicecall.h>
 
 #include <drivers/atmodem/vendor.h>
+#include <drivers/atmodem/network-registration.h>
 
 #define CALYPSO_POWER_PATH "/sys/bus/platform/devices/neo1973-pm-gsm.0/power_on"
 #define CALYPSO_RESET_PATH "/sys/bus/platform/devices/neo1973-pm-gsm.0/reset"
@@ -445,14 +446,18 @@ static void calypso_post_sim(struct ofono_modem *modem)
 {
 	struct calypso_data *data = ofono_modem_get_data(modem);
 	struct ofono_message_waiting *mw;
+	struct atmodem_network_registration atmodem_netreg;
 
 	DBG("");
 
+	memset(&atmodem_netreg, 0, sizeof(atmodem_netreg));
+	atmodem_netreg.chat = data->dlcs[NETREG_DLC];
+
 	ofono_ussd_create(modem, 0, "atmodem", data->dlcs[AUX_DLC]);
 	ofono_call_forwarding_create(modem, 0, "atmodem", data->dlcs[AUX_DLC]);
 	ofono_call_settings_create(modem, 0, "atmodem", data->dlcs[AUX_DLC]);
 	ofono_netreg_create(modem, OFONO_VENDOR_CALYPSO, "atmodem",
-				data->dlcs[NETREG_DLC]);
+			    &atmodem_netreg);
 	ofono_call_meter_create(modem, 0, "atmodem", data->dlcs[AUX_DLC]);
 	ofono_call_barring_create(modem, 0, "atmodem", data->dlcs[AUX_DLC]);
 	ofono_ssn_create(modem, 0, "atmodem", data->dlcs[AUX_DLC]);
diff --git a/plugins/em770.c b/plugins/em770.c
index de82f94..bf7978d 100644
--- a/plugins/em770.c
+++ b/plugins/em770.c
@@ -26,6 +26,7 @@
 #include <stdio.h>
 #include <errno.h>
 #include <stdlib.h>
+#include <string.h>
 
 #include <glib.h>
 #include <gatchat.h>
@@ -50,6 +51,7 @@
 #include <ofono/gprs.h>
 #include <ofono/voicecall.h>
 
+#include <drivers/atmodem/network-registration.h>
 #include <drivers/atmodem/vendor.h>
 
 struct em770_data {
diff --git a/plugins/g1.c b/plugins/g1.c
index fa96eb1..45d0290 100644
--- a/plugins/g1.c
+++ b/plugins/g1.c
@@ -25,6 +25,7 @@
 
 #include <stdlib.h>
 #include <errno.h>
+#include <string.h>
 
 #include <glib.h>
 #include <gatchat.h>
@@ -48,6 +49,7 @@
 #include <ofono/ussd.h>
 #include <ofono/voicecall.h>
 
+#include <drivers/atmodem/network-registration.h>
 #include <drivers/atmodem/vendor.h>
 
 static void g1_debug(const char *str, void *data)
@@ -172,13 +174,17 @@ static void g1_post_sim(struct ofono_modem *modem)
 {
 	GAtChat *chat = ofono_modem_get_data(modem);
 	struct ofono_message_waiting *mw;
+	struct atmodem_network_registration atmodem_netreg;
 
 	DBG("");
 
+	memset(&atmodem_netreg, 0, sizeof(atmodem_netreg));
+	atmodem_netreg.chat = chat;
+
 	ofono_ussd_create(modem, 0, "atmodem", chat);
 	ofono_call_forwarding_create(modem, 0, "atmodem", chat);
 	ofono_call_settings_create(modem, 0, "atmodem", chat);
-	ofono_netreg_create(modem, 0, "atmodem", chat);
+	ofono_netreg_create(modem, 0, "atmodem", &atmodem_netreg);
 	ofono_call_meter_create(modem, 0, "atmodem", chat);
 	ofono_call_barring_create(modem, 0, "atmodem", chat);
 	ofono_ssn_create(modem, 0, "atmodem", chat);
diff --git a/plugins/hso.c b/plugins/hso.c
index 26f6c81..67e5335 100644
--- a/plugins/hso.c
+++ b/plugins/hso.c
@@ -44,6 +44,7 @@
 #include <ofono/log.h>
 
 #include <drivers/atmodem/gprs.h>
+#include <drivers/atmodem/network-registration.h>
 #include <drivers/atmodem/vendor.h>
 
 static const char *none_prefix[] = { NULL };
@@ -215,11 +216,15 @@ static void hso_post_sim(struct ofono_modem *modem)
 	struct ofono_gprs *gprs;
 	struct ofono_gprs_context *gc;
 	struct atmodem_gprs atmodem_gprs;
+	struct atmodem_network_registration atmodem_netreg;
 
 	DBG("%p", modem);
 
+	memset(&atmodem_netreg, 0, sizeof(atmodem_netreg));
+	atmodem_netreg.chat = data->app;
+
 	ofono_netreg_create(modem, OFONO_VENDOR_OPTION_HSO,
-				"atmodem", data->app);
+				"atmodem", &atmodem_netreg);
 	ofono_sms_create(modem, 0, "atmodem", data->app);
 
 	memset(&atmodem_gprs, 0, sizeof(atmodem_gprs));
diff --git a/plugins/huawei.c b/plugins/huawei.c
index df4d177..94cbb68 100644
--- a/plugins/huawei.c
+++ b/plugins/huawei.c
@@ -26,6 +26,7 @@
 #include <stdio.h>
 #include <errno.h>
 #include <stdlib.h>
+#include <string.h>
 
 #include <glib.h>
 #include <gatchat.h>
@@ -42,6 +43,7 @@
 #include <ofono/voicecall.h>
 #include <ofono/log.h>
 
+#include <drivers/atmodem/network-registration.h>
 #include <drivers/atmodem/vendor.h>
 
 struct huawei_data {
@@ -177,10 +179,15 @@ static void huawei_pre_sim(struct ofono_modem *modem)
 static void huawei_post_sim(struct ofono_modem *modem)
 {
 	struct huawei_data *data = ofono_modem_get_data(modem);
+	struct atmodem_network_registration atmodem_netreg;
 
 	DBG("%p", modem);
 
-	ofono_netreg_create(modem, OFONO_VENDOR_HUAWEI, "atmodem", data->chat);
+	memset(&atmodem_netreg, 0, sizeof(atmodem_netreg));
+	atmodem_netreg.chat = data->chat;
+
+	ofono_netreg_create(modem, OFONO_VENDOR_HUAWEI, "atmodem",
+			    &atmodem_netreg);
 	ofono_sms_create(modem, OFONO_VENDOR_QUALCOMM_MSM, "atmodem", data->chat);
 }
 
diff --git a/plugins/mbm.c b/plugins/mbm.c
index 518aaaa..226ec11 100644
--- a/plugins/mbm.c
+++ b/plugins/mbm.c
@@ -53,6 +53,7 @@
 #include <ofono/gprs-context.h>
 #include <ofono/log.h>
 #include <drivers/atmodem/gprs.h>
+#include <drivers/atmodem/network-registration.h>
 #include <drivers/atmodem/vendor.h>
 
 static const char *cfun_prefix[] = { "+CFUN:", NULL };
@@ -304,9 +305,13 @@ static void mbm_post_sim(struct ofono_modem *modem)
 	struct ofono_gprs *gprs;
 	struct ofono_gprs_context *gc;
 	struct atmodem_gprs atmodem_gprs;
+	struct atmodem_network_registration atmodem_netreg;
 
 	DBG("%p", modem);
 
+	memset(&atmodem_netreg, 0, sizeof(atmodem_netreg));
+	atmodem_netreg.chat = data->modem_port;
+
 	ofono_call_forwarding_create(modem, 0, "atmodem", data->modem_port);
 	ofono_call_settings_create(modem, 0, "atmodem", data->modem_port);
 	ofono_call_meter_create(modem, 0, "atmodem", data->modem_port);
@@ -314,7 +319,7 @@ static void mbm_post_sim(struct ofono_modem *modem)
 
 	ofono_ussd_create(modem, 0, "atmodem", data->modem_port);
 	ofono_netreg_create(modem, OFONO_VENDOR_MBM, "atmodem",
-				data->modem_port);
+			    &atmodem_netreg);
 	ofono_phonebook_create(modem, 0, "atmodem", data->modem_port);
 	ofono_ssn_create(modem, 0, "atmodem", data->modem_port);
 	ofono_sms_create(modem, 0, "atmodem", data->modem_port);
diff --git a/plugins/novatel.c b/plugins/novatel.c
index 792e17f..b0ea27f 100644
--- a/plugins/novatel.c
+++ b/plugins/novatel.c
@@ -26,6 +26,7 @@
 #include <stdio.h>
 #include <errno.h>
 #include <stdlib.h>
+#include <string.h>
 
 #include <glib.h>
 #include <gatchat.h>
@@ -39,6 +40,8 @@
 #include <ofono/sms.h>
 #include <ofono/log.h>
 
+#include <drivers/atmodem/network-registration.h>
+
 struct novatel_data {
 	GAtChat *chat;
 };
@@ -162,10 +165,14 @@ static void novatel_pre_sim(struct ofono_modem *modem)
 static void novatel_post_sim(struct ofono_modem *modem)
 {
 	struct novatel_data *data = ofono_modem_get_data(modem);
+	struct atmodem_network_registration atmodem_netreg;
 
 	DBG("%p", modem);
 
-	ofono_netreg_create(modem, 0, "atmodem", data->chat);
+	memset(&atmodem_netreg, 0, sizeof(atmodem_netreg));
+	atmodem_netreg.chat = data->chat;
+
+	ofono_netreg_create(modem, 0, "atmodem", &atmodem_netreg);
 }
 
 static struct ofono_modem_driver novatel_driver = {
diff --git a/plugins/palmpre.c b/plugins/palmpre.c
index 9292e55..509224f 100644
--- a/plugins/palmpre.c
+++ b/plugins/palmpre.c
@@ -46,6 +46,7 @@
 #include <ofono/sms.h>
 
 #include <drivers/atmodem/gprs.h>
+#include <drivers/atmodem/network-registration.h>
 #include <drivers/atmodem/vendor.h>
 
 struct palmpre_data {
@@ -192,10 +193,14 @@ static void palmpre_post_sim(struct ofono_modem *modem)
 	struct ofono_gprs *gprs;
 	struct ofono_gprs_context *gc;
 	struct atmodem_gprs atmodem_gprs;
+	struct atmodem_network_registration atmodem_netreg;
 
 	DBG("%p", modem);
 
-	ofono_netreg_create(modem, 0, "atmodem", data->chat);
+	memset(&atmodem_netreg, 0, sizeof(atmodem_netreg));
+	atmodem_netreg.chat = data->chat;
+
+	ofono_netreg_create(modem, 0, "atmodem", &atmodem_netreg);
 	ofono_sms_create(modem, OFONO_VENDOR_QUALCOMM_MSM, "atmodem",
 				data->chat);
 	ofono_phonebook_create(modem, 0, "atmodem", data->chat);
diff --git a/plugins/phonesim.c b/plugins/phonesim.c
index becd06a..f5058bb 100644
--- a/plugins/phonesim.c
+++ b/plugins/phonesim.c
@@ -59,6 +59,7 @@
 #include <ofono/gprs-context.h>
 
 #include <drivers/atmodem/gprs.h>
+#include <drivers/atmodem/network-registration.h>
 #include <drivers/atmodem/vendor.h>
 #include <drivers/atmodem/sim-poll.h>
 
@@ -303,6 +304,7 @@ static void phonesim_post_sim(struct ofono_modem *modem)
 	struct ofono_gprs *gprs;
 	struct ofono_gprs_context *gc;
 	struct atmodem_gprs atmodem_gprs;
+	struct atmodem_network_registration atmodem_netreg;
 
 	DBG("%p", modem);
 
@@ -310,12 +312,15 @@ static void phonesim_post_sim(struct ofono_modem *modem)
 	ofono_call_forwarding_create(modem, 0, "atmodem", data->chat);
 	ofono_call_settings_create(modem, 0, "atmodem", data->chat);
 
+	memset(&atmodem_netreg, 0, sizeof(atmodem_netreg));
+	atmodem_netreg.chat = data->chat;
+
 	if (data->calypso)
 		ofono_netreg_create(modem, OFONO_VENDOR_CALYPSO,
-							"atmodem", data->chat);
+				    "atmodem", &atmodem_netreg);
 	else
 		ofono_netreg_create(modem, OFONO_VENDOR_PHONESIM,
-							"atmodem", data->chat);
+				    "atmodem", &atmodem_netreg);
 
 	ofono_call_meter_create(modem, 0, "atmodem", data->chat);
 	ofono_call_barring_create(modem, 0, "atmodem", data->chat);
diff --git a/plugins/ste.c b/plugins/ste.c
index a744797..68ff792 100644
--- a/plugins/ste.c
+++ b/plugins/ste.c
@@ -55,6 +55,7 @@
 #include <ofono/gprs.h>
 #include <ofono/gprs-context.h>
 #include <drivers/atmodem/gprs.h>
+#include <drivers/atmodem/network-registration.h>
 #include <drivers/atmodem/vendor.h>
 
 #include <drivers/stemodem/caif_socket.h>
@@ -227,13 +228,18 @@ static void ste_post_sim(struct ofono_modem *modem)
 	struct ofono_gprs *gprs;
 	struct ofono_gprs_context *gc;
 	struct atmodem_gprs atmodem_gprs;
+	struct atmodem_network_registration atmodem_netreg;
 
 	DBG("%p", modem);
 
+	memset(&atmodem_netreg, 0, sizeof(atmodem_netreg));
+	atmodem_netreg.chat = data->chat;
+
 	ofono_ussd_create(modem, 0, "atmodem", data->chat);
 	ofono_call_forwarding_create(modem, 0, "atmodem", data->chat);
 	ofono_call_settings_create(modem, 0, "atmodem", data->chat);
-	ofono_netreg_create(modem, OFONO_VENDOR_STE, "atmodem", data->chat);
+	ofono_netreg_create(modem, OFONO_VENDOR_STE, "atmodem",
+			    &atmodem_netreg);
 	ofono_call_meter_create(modem, 0, "atmodem", data->chat);
 	ofono_call_barring_create(modem, 0, "atmodem", data->chat);
 	ofono_ssn_create(modem, 0, "atmodem", data->chat);


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

* [PATCH v2 3/6] huawei: detect SecondaryDevice which is used for events
  2010-04-30 12:54 [PATCH v2 0/6] Huawei GPRS support Kalle Valo
  2010-04-30 12:54 ` [PATCH v2 1/6] atmodem: create struct atmodem_gprs Kalle Valo
  2010-04-30 12:55 ` [PATCH v2 2/6] atmodem: create struct atmodem_network_registration Kalle Valo
@ 2010-04-30 12:55 ` Kalle Valo
  2010-04-30 12:55 ` [PATCH v2 4/6] atmodem: follow separate event chat with huawei Kalle Valo
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 12+ messages in thread
From: Kalle Valo @ 2010-04-30 12:55 UTC (permalink / raw)
  To: ofono

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


---

 plugins/huawei.c |   39 ++++++++++++++++++++++++++++++++++-
 plugins/udev.c   |   61 +++++++++++++++++++++++++++++++++++++++++++++++-------
 2 files changed, 91 insertions(+), 9 deletions(-)

diff --git a/plugins/huawei.c b/plugins/huawei.c
index 94cbb68..e895d16 100644
--- a/plugins/huawei.c
+++ b/plugins/huawei.c
@@ -47,7 +47,7 @@
 #include <drivers/atmodem/vendor.h>
 
 struct huawei_data {
-	GAtChat *chat;
+	GAtChat *chat, *event;
 };
 
 static int huawei_probe(struct ofono_modem *modem)
@@ -74,6 +74,7 @@ static void huawei_remove(struct ofono_modem *modem)
 	ofono_modem_set_data(modem, NULL);
 
 	g_at_chat_unref(data->chat);
+	g_at_chat_unref(data->event);
 	g_free(data);
 }
 
@@ -82,6 +83,11 @@ static void huawei_debug(const char *str, void *user_data)
 	ofono_info("%s", str);
 }
 
+static void huawei_event_debug(const char *str, void *user_data)
+{
+	ofono_info("* %s", str);
+}
+
 static void cfun_enable(gboolean ok, GAtResult *result, gpointer user_data)
 {
 	struct ofono_modem *modem = user_data;
@@ -122,6 +128,29 @@ static int huawei_enable(struct ofono_modem *modem)
 	if (getenv("OFONO_AT_DEBUG"))
 		g_at_chat_set_debug(data->chat, huawei_debug, NULL);
 
+	device = ofono_modem_get_string(modem, "SecondaryDevice");
+	if (!device)
+		return -EINVAL;
+
+	channel = g_at_tty_open(device, NULL);
+	if (!channel)
+		return -EIO;
+
+	syntax = g_at_syntax_new_gsm_permissive();
+	data->event = g_at_chat_new(channel, syntax);
+	g_at_syntax_unref(syntax);
+	g_io_channel_unref(channel);
+
+	if (!data->event)
+		return -EIO;
+
+	g_at_chat_add_terminator(data->event, "COMMAND NOT SUPPORT", -1,
+				 FALSE);
+
+	if (getenv("OFONO_AT_DEBUG"))
+		g_at_chat_set_debug(data->event, huawei_event_debug, NULL);
+
+
 	g_at_chat_send(data->chat, "ATE0", NULL, NULL, NULL, NULL);
 
 	g_at_chat_send(data->chat, "AT+CFUN=1", NULL,
@@ -140,6 +169,9 @@ static void cfun_disable(gboolean ok, GAtResult *result, gpointer user_data)
 	g_at_chat_unref(data->chat);
 	data->chat = NULL;
 
+	g_at_chat_unref(data->event);
+	data->event = NULL;
+
 	if (ok)
 		ofono_modem_set_powered(modem, FALSE);
 }
@@ -150,6 +182,11 @@ static int huawei_disable(struct ofono_modem *modem)
 
 	DBG("%p", modem);
 
+	if (data->event) {
+		g_at_chat_cancel_all(data->event);
+		g_at_chat_unregister_all(data->event);
+	}
+
 	if (!data->chat)
 		return 0;
 
diff --git a/plugins/udev.c b/plugins/udev.c
index 964ac65..8ad4f83 100644
--- a/plugins/udev.c
+++ b/plugins/udev.c
@@ -88,6 +88,24 @@ static const char *get_serial(struct udev_device *udev_device)
 	return serial;
 }
 
+static const char *get_usb_num(struct udev_device *udev_device)
+{
+	struct udev_list_entry *entry;
+	const char *num = NULL;
+
+	entry = udev_device_get_properties_list_entry(udev_device);
+	while (entry) {
+		const char *name = udev_list_entry_get_name(entry);
+
+		if (g_strcmp0(name, "ID_USB_INTERFACE_NUM") == 0)
+			num = udev_list_entry_get_value(entry);
+
+		entry = udev_list_entry_get_next(entry);
+	}
+
+	return num;
+}
+
 #define MODEM_DEVICE		"ModemDevice"
 #define DATA_DEVICE		"DataDevice"
 #define GPS_DEVICE		"GPSDevice"
@@ -199,18 +217,45 @@ static void add_hso(struct ofono_modem *modem,
 static void add_huawei(struct ofono_modem *modem,
 					struct udev_device *udev_device)
 {
-	const char *devnode;
-	int registered;
+	const char *devnode, *num;
+	int primary, secondary;
 
-	registered = ofono_modem_get_integer(modem, "Registered");
-	if (registered != 0)
+	primary = ofono_modem_get_integer(modem, "PrimaryRegistered");
+	secondary = ofono_modem_get_integer(modem, "SecondaryRegistered");
+
+	if (primary && secondary)
 		return;
 
-	devnode = udev_device_get_devnode(udev_device);
-	ofono_modem_set_string(modem, "Device", devnode);
+	num = get_usb_num(udev_device);
 
-	ofono_modem_set_integer(modem, "Registered", 1);
-	ofono_modem_register(modem);
+	/*
+	 * Here is is assumed that that usb port number 0 is the control
+	 * port and port 2 is the event port. This assumption will surely
+	 * be false with some devices and better heuristics is needed.
+	 */
+	if (g_strcmp0(num, "00") == 0) {
+		if (primary != 0)
+			return;
+
+		devnode = udev_device_get_devnode(udev_device);
+		ofono_modem_set_string(modem, "Device", devnode);
+
+		primary = 1;
+		ofono_modem_set_integer(modem, "PrimaryRegistered", primary);
+	} else if (g_strcmp0(num, "02") == 0) {
+		if (secondary != 0)
+			return;
+
+		devnode = udev_device_get_devnode(udev_device);
+		ofono_modem_set_string(modem, "SecondaryDevice", devnode);
+
+		secondary = 1;
+		ofono_modem_set_integer(modem, "SecondaryRegistered",
+					secondary);
+	}
+
+	if (primary && secondary)
+		ofono_modem_register(modem);
 }
 
 static void add_em770(struct ofono_modem *modem,


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

* [PATCH v2 4/6] atmodem: follow separate event chat with huawei
  2010-04-30 12:54 [PATCH v2 0/6] Huawei GPRS support Kalle Valo
                   ` (2 preceding siblings ...)
  2010-04-30 12:55 ` [PATCH v2 3/6] huawei: detect SecondaryDevice which is used for events Kalle Valo
@ 2010-04-30 12:55 ` Kalle Valo
  2010-04-30 12:55 ` [PATCH v2 5/6] atmodem: add signal strength support for huawei Kalle Valo
  2010-04-30 12:55 ` [PATCH v2 6/6] huawei: add gprs context Kalle Valo
  5 siblings, 0 replies; 12+ messages in thread
From: Kalle Valo @ 2010-04-30 12:55 UTC (permalink / raw)
  To: ofono

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

CGREG notifications are received in this channel.
---

 drivers/atmodem/gprs.c |   16 +++++++++++++---
 1 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/drivers/atmodem/gprs.c b/drivers/atmodem/gprs.c
index d12d9eb..36f5ce3 100644
--- a/drivers/atmodem/gprs.c
+++ b/drivers/atmodem/gprs.c
@@ -47,7 +47,7 @@ static const char *cgdcont_prefix[] = { "+CGDCONT:", NULL };
 static const char *none_prefix[] = { NULL };
 
 struct gprs_data {
-	GAtChat *chat;
+	GAtChat *chat, *event;
 	unsigned int vendor;
 };
 
@@ -170,9 +170,18 @@ static void gprs_initialized(gboolean ok, GAtResult *result, gpointer user_data)
 {
 	struct ofono_gprs *gprs = user_data;
 	struct gprs_data *gd = ofono_gprs_get_data(gprs);
+	GAtChat *chat;
+
+	DBG("");
+
+	if (gd->vendor == OFONO_VENDOR_HUAWEI)
+		/* Huawei uses separate serial port for events */
+		chat = gd->event;
+	else
+		chat = gd->chat;
 
-	g_at_chat_register(gd->chat, "+CGEV:", cgev_notify, FALSE, gprs, NULL);
-	g_at_chat_register(gd->chat, "+CGREG:", cgreg_notify,
+	g_at_chat_register(chat, "+CGEV:", cgev_notify, FALSE, gprs, NULL);
+	g_at_chat_register(chat, "+CGREG:", cgreg_notify,
 				FALSE, gprs, NULL);
 
 	ofono_gprs_register(gprs);
@@ -297,6 +306,7 @@ static int at_gprs_probe(struct ofono_gprs *gprs,
 
 	gd = g_new0(struct gprs_data, 1);
 	gd->chat = atmodem->chat;
+	gd->event = atmodem->event;
 	gd->vendor = vendor;
 
 	ofono_gprs_set_data(gprs, gd);


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

* [PATCH v2 5/6] atmodem: add signal strength support for huawei
  2010-04-30 12:54 [PATCH v2 0/6] Huawei GPRS support Kalle Valo
                   ` (3 preceding siblings ...)
  2010-04-30 12:55 ` [PATCH v2 4/6] atmodem: follow separate event chat with huawei Kalle Valo
@ 2010-04-30 12:55 ` Kalle Valo
  2010-04-30 13:38   ` Marcel Holtmann
  2010-04-30 12:55 ` [PATCH v2 6/6] huawei: add gprs context Kalle Valo
  5 siblings, 1 reply; 12+ messages in thread
From: Kalle Valo @ 2010-04-30 12:55 UTC (permalink / raw)
  To: ofono

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

Huawei doesn't support CIND indications, instead it uses some non-standard
RSSI messages:

ofonod[6401]: < \r\n^RSSI:23\r\n

Add support for this to atmodem.
---

 drivers/atmodem/network-registration.c |   30 ++++++++++++++++++++++++++++++
 drivers/atmodem/network-registration.h |    3 +++
 plugins/huawei.c                       |    1 +
 3 files changed, 34 insertions(+), 0 deletions(-)

diff --git a/drivers/atmodem/network-registration.c b/drivers/atmodem/network-registration.c
index 777cbc3..95da94d 100644
--- a/drivers/atmodem/network-registration.c
+++ b/drivers/atmodem/network-registration.c
@@ -50,6 +50,7 @@ static const char *cind_prefix[] = { "+CIND:", NULL };
 
 struct netreg_data {
 	GAtChat *chat;
+	GAtChat *event;
 	char mcc[OFONO_MAX_MCC_LENGTH + 1];
 	char mnc[OFONO_MAX_MNC_LENGTH + 1];
 	int signal_index; /* If strength is reported via CIND */
@@ -511,6 +512,23 @@ static void calypso_csq_notify(GAtResult *result, gpointer user_data)
 	report_signal_strength(netreg, strength);
 }
 
+static void huawei_rssi_notify(GAtResult *result, gpointer user_data)
+{
+	struct ofono_netreg *netreg = user_data;
+	int strength;
+	GAtResultIter iter;
+
+	g_at_result_iter_init(&iter, result);
+
+	if (!g_at_result_iter_next(&iter, "^RSSI:"))
+		return;
+
+	if (!g_at_result_iter_next_number(&iter, &strength))
+		return;
+
+	report_signal_strength(netreg, strength);
+}
+
 static void option_osigq_notify(GAtResult *result, gpointer user_data)
 {
 	struct ofono_netreg *netreg = user_data;
@@ -917,6 +935,17 @@ static void at_creg_set_cb(gboolean ok, GAtResult *result, gpointer user_data)
 				cind_support_cb, netreg, NULL);
 
 		break;
+	case OFONO_VENDOR_HUAWEI:
+		if (!nd->event)
+			break;
+
+		/* huawei reports with non-standard "^RSSI:18" strings */
+		g_at_chat_register(nd->event, "^RSSI:",
+				   huawei_rssi_notify, FALSE, netreg, NULL);
+
+		ofono_netreg_register(netreg);
+
+		break;
 	default:
 		g_at_chat_send(nd->chat, "AT+CIND=?", cind_prefix,
 				cind_support_cb, netreg, NULL);
@@ -979,6 +1008,7 @@ static int at_netreg_probe(struct ofono_netreg *netreg, unsigned int vendor,
 	nd = g_new0(struct netreg_data, 1);
 
 	nd->chat = nr->chat;
+	nd->event = nr->event;
 	nd->vendor = vendor;
 	nd->tech = -1;
 	ofono_netreg_set_data(netreg, nd);
diff --git a/drivers/atmodem/network-registration.h b/drivers/atmodem/network-registration.h
index 506ed7d..7c832ea 100644
--- a/drivers/atmodem/network-registration.h
+++ b/drivers/atmodem/network-registration.h
@@ -23,4 +23,7 @@ struct atmodem_network_registration
 {
 	/* primary chat channel */
 	GAtChat *chat;
+
+	/* secondary chat channel for events */
+	GAtChat *event;
 };
diff --git a/plugins/huawei.c b/plugins/huawei.c
index e895d16..30e98f9 100644
--- a/plugins/huawei.c
+++ b/plugins/huawei.c
@@ -222,6 +222,7 @@ static void huawei_post_sim(struct ofono_modem *modem)
 
 	memset(&atmodem_netreg, 0, sizeof(atmodem_netreg));
 	atmodem_netreg.chat = data->chat;
+	atmodem_netreg.event = data->event;
 
 	ofono_netreg_create(modem, OFONO_VENDOR_HUAWEI, "atmodem",
 			    &atmodem_netreg);


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

* [PATCH v2 6/6] huawei: add gprs context
  2010-04-30 12:54 [PATCH v2 0/6] Huawei GPRS support Kalle Valo
                   ` (4 preceding siblings ...)
  2010-04-30 12:55 ` [PATCH v2 5/6] atmodem: add signal strength support for huawei Kalle Valo
@ 2010-04-30 12:55 ` Kalle Valo
  5 siblings, 0 replies; 12+ messages in thread
From: Kalle Valo @ 2010-04-30 12:55 UTC (permalink / raw)
  To: ofono

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

Tested with Huawei E1552 HSDPA USB stick using a finnish Saunalahti prepaid
SIM.
---

 plugins/huawei.c |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/plugins/huawei.c b/plugins/huawei.c
index 30e98f9..e188394 100644
--- a/plugins/huawei.c
+++ b/plugins/huawei.c
@@ -42,7 +42,10 @@
 #include <ofono/gprs.h>
 #include <ofono/voicecall.h>
 #include <ofono/log.h>
+#include <ofono/gprs.h>
+#include <ofono/gprs-context.h>
 
+#include <drivers/atmodem/gprs.h>
 #include <drivers/atmodem/network-registration.h>
 #include <drivers/atmodem/vendor.h>
 
@@ -217,6 +220,9 @@ static void huawei_post_sim(struct ofono_modem *modem)
 {
 	struct huawei_data *data = ofono_modem_get_data(modem);
 	struct atmodem_network_registration atmodem_netreg;
+ 	struct atmodem_gprs atmodem_gprs;
+	struct ofono_gprs_context *gc;
+	struct ofono_gprs *gprs;
 
 	DBG("%p", modem);
 
@@ -227,6 +233,17 @@ static void huawei_post_sim(struct ofono_modem *modem)
 	ofono_netreg_create(modem, OFONO_VENDOR_HUAWEI, "atmodem",
 			    &atmodem_netreg);
 	ofono_sms_create(modem, OFONO_VENDOR_QUALCOMM_MSM, "atmodem", data->chat);
+
+	memset(&atmodem_gprs, 0, sizeof(atmodem_gprs));
+	atmodem_gprs.chat = data->chat;
+	atmodem_gprs.event = data->event;
+
+	gprs = ofono_gprs_create(modem, OFONO_VENDOR_HUAWEI, "atmodem",
+				 &atmodem_gprs);
+	gc = ofono_gprs_context_create(modem, 0, "atmodem", data->chat);
+
+	if (gprs && gc)
+		ofono_gprs_add_context(gprs, gc);
 }
 
 static struct ofono_modem_driver huawei_driver = {


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

* Re: [PATCH v2 1/6] atmodem: create struct atmodem_gprs
  2010-04-30 12:54 ` [PATCH v2 1/6] atmodem: create struct atmodem_gprs Kalle Valo
@ 2010-04-30 13:34   ` Marcel Holtmann
  2010-05-03  6:39     ` Kalle Valo
  0 siblings, 1 reply; 12+ messages in thread
From: Marcel Holtmann @ 2010-04-30 13:34 UTC (permalink / raw)
  To: ofono

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

Hi Kalle,

> This is need to to provide more chat channels to atmodem gprs module.
> ---
> 
>  drivers/atmodem/gprs.c |    7 ++++---
>  drivers/atmodem/gprs.h |   29 +++++++++++++++++++++++++++++
>  plugins/hso.c          |    8 +++++++-
>  plugins/mbm.c          |    7 ++++++-
>  plugins/palmpre.c      |    8 +++++++-
>  plugins/phonesim.c     |    7 ++++++-
>  plugins/ste.c          |    7 ++++++-
>  7 files changed, 65 insertions(+), 8 deletions(-)
>  create mode 100644 drivers/atmodem/gprs.h

I don't really like this. You only need to catch the CGREG anyway so we
might just wanna add some indication method. Similar to what we have for
network registration with ofono_netreg_status_notify.

Then the messed up CGREG from Huawei modem doesn't dictate the whole
simple one GAtChat approach. It is really their fault with no sending
these on the proper AT command channel. No need to make other drivers
suffer.

Regards

Marcel



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

* Re: [PATCH v2 2/6] atmodem: create struct atmodem_network_registration
  2010-04-30 12:55 ` [PATCH v2 2/6] atmodem: create struct atmodem_network_registration Kalle Valo
@ 2010-04-30 13:35   ` Marcel Holtmann
  0 siblings, 0 replies; 12+ messages in thread
From: Marcel Holtmann @ 2010-04-30 13:35 UTC (permalink / raw)
  To: ofono

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

Hi Kalle,

> Needed to provide more channels to atmodem network_registration module.
> ---
> 
>  drivers/atmodem/network-registration.c |    7 ++++---
>  drivers/atmodem/network-registration.h |   26 ++++++++++++++++++++++++++
>  plugins/atgen.c                        |    7 ++++++-
>  plugins/calypso.c                      |    7 ++++++-
>  plugins/em770.c                        |    2 ++
>  plugins/g1.c                           |    8 +++++++-
>  plugins/hso.c                          |    7 ++++++-
>  plugins/huawei.c                       |    9 ++++++++-
>  plugins/mbm.c                          |    7 ++++++-
>  plugins/novatel.c                      |    9 ++++++++-
>  plugins/palmpre.c                      |    7 ++++++-
>  plugins/phonesim.c                     |    9 +++++++--
>  plugins/ste.c                          |    8 +++++++-
>  13 files changed, 99 insertions(+), 14 deletions(-)
>  create mode 100644 drivers/atmodem/network-registration.h

what is wrong with using ofono_netreg_status_notify?

Regards

Marcel



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

* Re: [PATCH v2 5/6] atmodem: add signal strength support for huawei
  2010-04-30 12:55 ` [PATCH v2 5/6] atmodem: add signal strength support for huawei Kalle Valo
@ 2010-04-30 13:38   ` Marcel Holtmann
  2010-05-03  6:43     ` Kalle Valo
  0 siblings, 1 reply; 12+ messages in thread
From: Marcel Holtmann @ 2010-04-30 13:38 UTC (permalink / raw)
  To: ofono

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

Hi Kalle,

> Huawei doesn't support CIND indications, instead it uses some non-standard
> RSSI messages:
> 
> ofonod[6401]: < \r\n^RSSI:23\r\n
> 
> Add support for this to atmodem.

please use ofono_netreg_strength_notify for this.

The Huawei specific details with this stupid extra channel need to be
handled inside the Huawei plugin. Cluttering the core with it is not a
good idea.

Regards

Marcel



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

* Re: [PATCH v2 1/6] atmodem: create struct atmodem_gprs
  2010-04-30 13:34   ` Marcel Holtmann
@ 2010-05-03  6:39     ` Kalle Valo
  0 siblings, 0 replies; 12+ messages in thread
From: Kalle Valo @ 2010-05-03  6:39 UTC (permalink / raw)
  To: ofono

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

Marcel Holtmann <marcel@holtmann.org> writes:

> Hi Kalle,

Hi Marcel,

> I don't really like this. You only need to catch the CGREG anyway so we
> might just wanna add some indication method. Similar to what we have for
> network registration with ofono_netreg_status_notify.
>
> Then the messed up CGREG from Huawei modem doesn't dictate the whole
> simple one GAtChat approach. It is really their fault with no sending
> these on the proper AT command channel. No need to make other drivers
> suffer.

Sounds very good to me. I didn't even think about this because I was
under (false) impression that all AT commands must be handled in atmodem
driver.

I'm travelling the next two weeks, so it might take a while before I
have v3 ready.

-- 
Kalle Valo

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

* Re: [PATCH v2 5/6] atmodem: add signal strength support for huawei
  2010-04-30 13:38   ` Marcel Holtmann
@ 2010-05-03  6:43     ` Kalle Valo
  0 siblings, 0 replies; 12+ messages in thread
From: Kalle Valo @ 2010-05-03  6:43 UTC (permalink / raw)
  To: ofono

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

Marcel Holtmann <marcel@holtmann.org> writes:

> Hi Kalle,
>
>> Huawei doesn't support CIND indications, instead it uses some non-standard
>> RSSI messages:
>> 
>> ofonod[6401]: < \r\n^RSSI:23\r\n
>> 
>> Add support for this to atmodem.
>
> please use ofono_netreg_strength_notify for this.
>
> The Huawei specific details with this stupid extra channel need to be
> handled inside the Huawei plugin. Cluttering the core with it is not a
> good idea.

I fully agree. I'll do this.

-- 
Kalle Valo

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

end of thread, other threads:[~2010-05-03  6:43 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-30 12:54 [PATCH v2 0/6] Huawei GPRS support Kalle Valo
2010-04-30 12:54 ` [PATCH v2 1/6] atmodem: create struct atmodem_gprs Kalle Valo
2010-04-30 13:34   ` Marcel Holtmann
2010-05-03  6:39     ` Kalle Valo
2010-04-30 12:55 ` [PATCH v2 2/6] atmodem: create struct atmodem_network_registration Kalle Valo
2010-04-30 13:35   ` Marcel Holtmann
2010-04-30 12:55 ` [PATCH v2 3/6] huawei: detect SecondaryDevice which is used for events Kalle Valo
2010-04-30 12:55 ` [PATCH v2 4/6] atmodem: follow separate event chat with huawei Kalle Valo
2010-04-30 12:55 ` [PATCH v2 5/6] atmodem: add signal strength support for huawei Kalle Valo
2010-04-30 13:38   ` Marcel Holtmann
2010-05-03  6:43     ` Kalle Valo
2010-04-30 12:55 ` [PATCH v2 6/6] huawei: add gprs context Kalle Valo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox