Skip to contentSkip to conversation

Huawei GPRS support

PATCH Superseded Kalle Valo 2 participants 12 messages Apr 30, 2010 – May 3, 2010

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

Kalle Valo

author
#0 lore raw

v2 cover Huawei GPRS support

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
author
#1 lore raw

PATCH v2 1/6 atmodem: create struct atmodem_gprs

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
drivers/atmodem/gprs.c +4 -3
index 052417a..d12d9eb 100644
@@ -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;
drivers/atmodem/gprs.h new file +29 -0
new file mode 100644
index 0000000..36388e3
@@ -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;
+};
plugins/hso.c +7 -1
index dd9be67..26f6c81 100644
@@ -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)
plugins/mbm.c +6 -1
index c67c7a5..518aaaa 100644
@@ -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)
plugins/palmpre.c +7 -1
index 7d2aeb4..9292e55 100644
@@ -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)
plugins/phonesim.c +6 -1
index d0cd7f3..becd06a 100644
@@ -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)
plugins/ste.c +6 -1
index f3ae0b2..a744797 100644
@@ -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)
author
#4 lore raw

PATCH v2 2/6 atmodem: create struct atmodem_network_registration

In reply to Kalle Valo

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
drivers/atmodem/network-registration.c +4 -3
index f7aafbe..777cbc3 100644
@@ -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;
drivers/atmodem/network-registration.h new file +26 -0
new file mode 100644
index 0000000..506ed7d
@@ -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;
+};
plugins/atgen.c +6 -1
index 7c38fde..7d3b280 100644
@@ -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);
plugins/calypso.c +6 -1
index 60f3242..5497d67 100644
@@ -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]);
plugins/em770.c +2 -0
index de82f94..bf7978d 100644
@@ -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 {
plugins/g1.c +7 -1
index fa96eb1..45d0290 100644
@@ -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);
plugins/hso.c +6 -1
index 26f6c81..67e5335 100644
@@ -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));
plugins/huawei.c +8 -1
index df4d177..94cbb68 100644
@@ -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);
 }
 
plugins/mbm.c +6 -1
index 518aaaa..226ec11 100644
@@ -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);
plugins/novatel.c +8 -1
index 792e17f..b0ea27f 100644
@@ -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 = {
plugins/palmpre.c +6 -1
index 9292e55..509224f 100644
@@ -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);
plugins/phonesim.c +7 -2
index becd06a..f5058bb 100644
@@ -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);
plugins/ste.c +7 -1
index a744797..68ff792 100644
@@ -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);
author
#6 lore raw

PATCH v2 3/6 huawei: detect SecondaryDevice which is used for events

In reply to Kalle Valo

---

 plugins/huawei.c |   39 ++++++++++++++++++++++++++++++++++-
 plugins/udev.c   |   61 +++++++++++++++++++++++++++++++++++++++++++++++-------
 2 files changed, 91 insertions(+), 9 deletions(-)
plugins/huawei.c +38 -1
index 94cbb68..e895d16 100644
@@ -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;
 
plugins/udev.c +53 -8

77 lines not on this page · raw message

author
#7 lore raw

PATCH v2 4/6 atmodem: follow separate event chat with huawei

In reply to Kalle Valo

CGREG notifications are received in this channel.
---

 drivers/atmodem/gprs.c |   16 +++++++++++++---
 1 files changed, 13 insertions(+), 3 deletions(-)
drivers/atmodem/gprs.c +13 -3
index d12d9eb..36f5ce3 100644
@@ -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);
author
#8 lore raw

PATCH v2 5/6 atmodem: add signal strength support for huawei

In reply to Kalle Valo

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(-)
drivers/atmodem/network-registration.c +30 -0
index 777cbc3..95da94d 100644
@@ -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);
drivers/atmodem/network-registration.h +3 -0
index 506ed7d..7c832ea 100644
@@ -23,4 +23,7 @@ struct atmodem_network_registration
 {
 	/* primary chat channel */
 	GAtChat *chat;
+
+	/* secondary chat channel for events */
+	GAtChat *event;
 };
plugins/huawei.c +1 -0
index e895d16..30e98f9 100644
@@ -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);
author
#11 lore raw

PATCH v2 6/6 huawei: add gprs context

In reply to Kalle Valo

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

 plugins/huawei.c |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)
plugins/huawei.c +17 -0
index 30e98f9..e188394 100644
@@ -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 = {
#2 lore raw

Re: [PATCH v2 1/6] atmodem: create struct atmodem_gprs

In reply to Kalle Valo

Hi Kalle,

Quoted 12 lines

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

#5 lore raw

Re: [PATCH v2 2/6] atmodem: create struct atmodem_network_registration

In reply to Kalle Valo

Hi Kalle,

Quoted 18 lines

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

#9 lore raw

Re: [PATCH v2 5/6] atmodem: add signal strength support for huawei

In reply to Kalle Valo

Hi Kalle,

Quoted 6 lines

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

author
#3 lore raw

Re: [PATCH v2 1/6] atmodem: create struct atmodem_gprs

In reply to Marcel Holtmann
Quoted 1 line · Marcel Holtmann

Hi Kalle,

Hi Marcel,

Quoted 8 lines

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.

Signature · 1 line
Kalle Valo
author
#10 lore raw

Re: [PATCH v2 5/6] atmodem: add signal strength support for huawei

In reply to Marcel Holtmann
Quoted 7 lines · Marcel Holtmann

Hi Kalle,

Quoted 5 lines

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

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

Quoted 7 lines
Quoted 1 line

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.

Signature · 1 line
Kalle Valo