Skip to contentSkip to conversation

Support for U-Blox Toby L2 modems

PATCH Applied Dragos Tatulea 2 participants 30 messages Mar 9, 2016 – Mar 10, 2016 Kbuild

lore
Share & tools
lore
#0 lore raw

cover Support for U-Blox Toby L2 modems

This patchset adds support for Toby L2 modems in high throughput mode.

Besides basic support, the following things are supported:
* bridged AND routed modes.
* LTE default bearers.
* Multiple primary PDP contexts.

Dongsu Park (4):
plugins/udevng: support the U-Blox TOBY-L2 series plugins/udevng: support different interface strings to detect TOBY
series
plugins/ublox: read network mode
ubloxmodem: add routed mode support

Dragos Tatulea (15):
plugins/udevng: ublox: set model string
include: vendor.h: add vendor for ublox toby plugins/ublox: allow enabling of TOBY L2 modems plugins/ublox: use vendor from structure instead of fixed
atmodem: ublox: EPS now supported by newer ublox
atmodem: add support for U-Blox TOBY L2 modems
atmodem: work around CGREG issues in UBlox Toby L2
ubloxmodem: add Toby L2 gprs context driver gprs-context.h: add function for setting APN
gprs: allow APN updates from gprs-context driver
ubloxmodem: push back APN into gprs context plugins/ublox: give names to model ids plugins/ublox: enable ubloxmodem driver when possible plugins/ublox: support more internet contexts
ubloxmodem: support authentication

 Makefile.am                            |   7 +
 drivers/atmodem/gprs-context.c         |   2 +
 drivers/atmodem/gprs.c                 |  27 +-
 drivers/atmodem/network-registration.c |  12 +-
 drivers/atmodem/sim.c                  |   1 +
 drivers/atmodem/vendor.h               |   1 +
 drivers/ubloxmodem/gprs-context.c      | 714 +++++++++++++++++++++++++++++++++
 drivers/ubloxmodem/ubloxmodem.c        |  49 +++
 drivers/ubloxmodem/ubloxmodem.h        |  25 ++
 include/gprs-context.h                 |   3 +
 plugins/ublox.c                        | 129 +++++-
 plugins/udevng.c                       |  25 +-
 src/gprs.c                             |  25 +-
 13 files changed, 987 insertions(+), 33 deletions(-)
 create mode 100644 drivers/ubloxmodem/gprs-context.c
 create mode 100644 drivers/ubloxmodem/ubloxmodem.c
 create mode 100644 drivers/ubloxmodem/ubloxmodem.h
Signature · 1 line
2.5.0
#1 lore raw

PATCH 1/19 plugins/udevng: support the U-Blox TOBY-L2 series

From: Dongsu Park <[email protected]>

The newest generation of U-Blox TOBY-L2 series can be detected with VID 0x1546 (the same as before), and one of the following PIDs:

* "0x1146" : high throughput profile
* "0x1141" : fairly back-compatible profile
* "0x1143" : low/medium throughput profile

This patch adds detection for high throughput mode.

---
 plugins/udevng.c | 2 ++
 1 file changed, 2 insertions(+)
plugins/udevng.c +2 -0
index e43d045..52b667e 100644
@@ -1120,6 +1120,8 @@ static struct {
 	{ "samsung",	"kalmia"			},
 	{ "quectel",	"option",	"05c6", "9090"	},
 	{ "ublox",	"cdc_acm",	"1546", "1102"	},
+	{ "ublox",	"rndis_host",	"1546", "1146"	},
+	{ "ublox",	"cdc_acm",	"1546", "1146"	},
 	{ }
 };
 
Signature · 1 line
2.5.0
#2 lore raw

Re: [PATCH 01/19] plugins/udevng: support the U-Blox TOBY-L2 series

Hi Dongsu,

Quoted 5 lines · Dragos Tatulea

From: Dongsu Park <[email protected]>

The newest generation of U-Blox TOBY-L2 series can be detected with VID 0x1546 (the same as before), and one of the following PIDs:

Quoted 9 lines

* "0x1146" : high throughput profile
* "0x1141" : fairly back-compatible profile
* "0x1143" : low/medium throughput profile

This patch adds detection for high throughput mode.

---
  plugins/udevng.c | 2 ++
  1 file changed, 2 insertions(+)

Applied, thanks.

Regards,
-Denis

#3 lore raw

PATCH 2/19 plugins/udevng: support different interface strings to detect TOBY series

In reply to Dragos Tatulea

From: Dongsu Park <[email protected]>

Each modem expresses their interfaces with its own interface string, which is composed of 3 different USB attributes:
"bInterfaceClass/bInterfaceSubClass/bInterfaceProtocol". While the old models like LISA support only "2/2/1" for modem interfaces, TOBY-L2 also supports an unique string for NetworkInterface for each profile.

* low-medium throughput profile : 2/6/0
* fairly backward-compatible profile : 10/0/0
* high throughput profile : 224/1/3

Besides the condition for checking NULL for mdm/aux/net should be relaxed a little bit.

---
 plugins/udevng.c | 22 +++++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)
plugins/udevng.c +19 -3
index 52b667e..2170c90 100644
@@ -838,7 +838,7 @@ static gboolean setup_quectel(struct modem_info *modem)
 
 static gboolean setup_ublox(struct modem_info *modem)
 {
-	const char *aux = NULL, *mdm = NULL;
+	const char *aux = NULL, *mdm = NULL, *net = NULL;
 	GSList *list;
 
 	DBG("%s", modem->syspath);
@@ -857,21 +857,37 @@ static gboolean setup_ublox(struct modem_info *modem)
 			mdm = info->devnode;
 			if (aux != NULL)
 				break;
+		/*
+		 * "2/2/1"
+		 *  - a common modem interface both for older models like LISA,
+		 *    and for newer models like TOBY.
+		 * For TOBY-L2, NetworkInterface can be detected for each profile:
+		 *  - low-medium throughput profile : 2/6/0
+		 *  - fairly backward-compatible profile : 10/0/0
+		 *  - high throughput profile : 224/1/3
+		 * */
 		} else if (g_strcmp0(info->interface, "2/2/1") == 0) {
 			if (g_strcmp0(info->number, "02") == 0)
 				aux = info->devnode;
 			else if (g_strcmp0(info->number, "00") == 0)
 				mdm = info->devnode;
+		} else if (g_strcmp0(info->interface, "2/6/0") == 0 ||
+			   g_strcmp0(info->interface, "10/0/0") == 0 ||
+			   g_strcmp0(info->interface, "224/1/3") == 0) {
+			net = info->devnode;
 		}
 	}
 
-	if (aux == NULL || mdm == NULL)
+	/* Abort only if both interfaces are NULL, as it's highly possible that
+	 * only one of 2 interfaces is available for U-blox modem. */
+	if (aux == NULL && mdm == NULL)
 		return FALSE;
 
-	DBG("aux=%s modem=%s", aux, mdm);
+	DBG("aux=%s modem=%s net=%s", aux, mdm, net);
 
 	ofono_modem_set_string(modem->modem, "Aux", aux);
 	ofono_modem_set_string(modem->modem, "Modem", mdm);
+	ofono_modem_set_string(modem->modem, "NetworkInterface", net);
 
 	return TRUE;
 }
Signature · 1 line
2.5.0
#4 lore raw

Re: [PATCH 02/19] plugins/udevng: support different interface strings to detect TOBY series

Hi Dongsu,

Quoted 50 lines · Dragos Tatulea

From: Dongsu Park <[email protected]>

Each modem expresses their interfaces with its own interface string, which is composed of 3 different USB attributes:
"bInterfaceClass/bInterfaceSubClass/bInterfaceProtocol". While the old models like LISA support only "2/2/1" for modem interfaces, TOBY-L2 also supports an unique string for NetworkInterface for each profile.

* low-medium throughput profile : 2/6/0
* fairly backward-compatible profile : 10/0/0
* high throughput profile : 224/1/3

Besides the condition for checking NULL for mdm/aux/net should be relaxed a little bit.

---
  plugins/udevng.c | 22 +++++++++++++++++++---
  1 file changed, 19 insertions(+), 3 deletions(-)
plugins/udevng.c +10 -1
index 52b667e..2170c90 100644
@@ -838,7 +838,7 @@ static gboolean setup_quectel(struct modem_info *modem)
 
  static gboolean setup_ublox(struct modem_info *modem)
  {
-	const char *aux = NULL, *mdm = NULL;
+	const char *aux = NULL, *mdm = NULL, *net = NULL;
  	GSList *list;
 
  	DBG("%s", modem->syspath);
@@ -857,21 +857,37 @@ static gboolean setup_ublox(struct modem_info *modem)
  			mdm = info->devnode;
  			if (aux != NULL)
  				break;
+		/*
+		 * "2/2/1"
+		 *  - a common modem interface both for older models like LISA,
+		 *    and for newer models like TOBY.
+		 * For TOBY-L2, NetworkInterface can be detected for each profile:
+		 *  - low-medium throughput profile : 2/6/0
+		 *  - fairly backward-compatible profile : 10/0/0
+		 *  - high throughput profile : 224/1/3
+		 * */
  		} else if (g_strcmp0(info->interface, "2/2/1") == 0) {
  			if (g_strcmp0(info->number, "02") == 0)
  				aux = info->devnode;
  			else if (g_strcmp0(info->number, "00") == 0)
  				mdm = info->devnode;

plugins/udevng.c static gboolean setup_ublox(struct modem_info *modem) · line 882

Quoted 10 lines
plugins/udevng.c +6 -1
+		} else if (g_strcmp0(info->interface, "2/6/0") == 0 ||
+			   g_strcmp0(info->interface, "10/0/0") == 0 ||
+			   g_strcmp0(info->interface, "224/1/3") == 0) {
+			net = info->devnode;
  		}
  	}
 
-	if (aux == NULL || mdm == NULL)
+	/* Abort only if both interfaces are NULL, as it's highly possible that
+	 * only one of 2 interfaces is available for U-blox modem. */

Not our comment style, please look at doc/coding-style.txt item M2

plugins/udevng.c static gboolean setup_ublox(struct modem_info *modem) · line 893

Quoted 13 lines
plugins/udevng.c +3 -1
+	if (aux == NULL && mdm == NULL)
  		return FALSE;
 
-	DBG("aux=%s modem=%s", aux, mdm);
+	DBG("aux=%s modem=%s net=%s", aux, mdm, net);
 
  	ofono_modem_set_string(modem->modem, "Aux", aux);
  	ofono_modem_set_string(modem->modem, "Modem", mdm);
+	ofono_modem_set_string(modem->modem, "NetworkInterface", net);
 
  	return TRUE;
  }

Regards,
-Denis

#5 lore raw

PATCH 3/19 plugins/udevng: ublox: set model string

In reply to Dragos Tatulea

Necessary for supporting the ublox TOBY L2 modem.

---
 plugins/udevng.c | 1 +
 1 file changed, 1 insertion(+)
plugins/udevng.c +1 -0
index 2170c90..4b84323 100644
@@ -888,6 +888,7 @@ static gboolean setup_ublox(struct modem_info *modem)
 	ofono_modem_set_string(modem->modem, "Aux", aux);
 	ofono_modem_set_string(modem->modem, "Modem", mdm);
 	ofono_modem_set_string(modem->modem, "NetworkInterface", net);
+	ofono_modem_set_string(modem->modem, "Model", modem->model);
 
 	return TRUE;
 }
Signature · 1 line
2.5.0
#6 lore raw

Re: [PATCH 03/19] plugins/udevng: ublox: set model string

Hi Dragos,

Quoted 5 lines · Dragos Tatulea

Necessary for supporting the ublox TOBY L2 modem.

---
  plugins/udevng.c | 1 +
  1 file changed, 1 insertion(+)

Applied, thanks.

Regards,
-Denis

#7 lore raw

PATCH 4/19 include: vendor.h: add vendor for ublox toby

In reply to Dragos Tatulea

Required to differentiate between the old LISA family of supported devices and future TOBY L2 devices.

---
 drivers/atmodem/vendor.h | 1 +
 1 file changed, 1 insertion(+)
drivers/atmodem/vendor.h +1 -0
index 52071c8..71a9af7 100644
@@ -45,5 +45,6 @@ enum ofono_vendor {
 	OFONO_VENDOR_ALCATEL,
 	OFONO_VENDOR_QUECTEL,
 	OFONO_VENDOR_UBLOX,
+	OFONO_VENDOR_UBLOX_TOBY_L2,
 	OFONO_VENDOR_CINTERION,
 };
Signature · 1 line
2.5.0
#8 lore raw

Re: [PATCH 04/19] include: vendor.h: add vendor for ublox toby

Hi Dragos,

Quoted 6 lines · Dragos Tatulea

Required to differentiate between the old LISA family of supported devices and future TOBY L2 devices.

---
  drivers/atmodem/vendor.h | 1 +
  1 file changed, 1 insertion(+)

Applied, thanks.

Regards,
-Denis

#9 lore raw

PATCH 5/19 plugins/ublox: allow enabling of TOBY L2 modems

In reply to Dragos Tatulea

For this we need to:
* Set the vendor family based on model id.
* Not use modem interface for the TOBY L2 family.

---
 plugins/ublox.c | 53 ++++++++++++++++++++++++++++++++++++++++++++---------
 1 file changed, 44 insertions(+), 9 deletions(-)
plugins/ublox.c +44 -9
index 89ca709..171d59d 100644
@@ -47,6 +47,7 @@ static const char *none_prefix[] = { NULL };
 struct ublox_data {
 	GAtChat *modem;
 	GAtChat *aux;
+	enum ofono_vendor vendor_family;
 };
 
 static void ublox_debug(const char *str, void *user_data)
@@ -138,24 +139,58 @@ static void cfun_enable(gboolean ok, GAtResult *result, gpointer user_data)
 static int ublox_enable(struct ofono_modem *modem)
 {
 	struct ublox_data *data = ofono_modem_get_data(modem);
+	const char *model_str = NULL;
+	int model_id;
 
 	DBG("%p", modem);
 
-	data->modem = open_device(modem, "Modem", "Modem: ");
-	if (data->modem == NULL)
+	model_str = ofono_modem_get_string(modem, "Model");
+	if (model_str == NULL)
 		return -EINVAL;
 
+	/*
+	 * Toby L2 devices are more complex and special than previously
+	 * supported U-Blox devices. So they need a vendor of their own.
+	 */
+	model_id = atoi(model_str);
+	switch (model_id) {
+		case 1102:
+			data->vendor_family = OFONO_VENDOR_UBLOX;
+			break;
+		case 1141:
+		case 1146:
+			data->vendor_family = OFONO_VENDOR_UBLOX_TOBY_L2;
+			break;
+		case 1143:
+			DBG("low/medium throughtput profile unsupported");
+		default:
+			DBG("unknown ublox model id %d", model_id);
+			return -EINVAL;
+	}
+
 	data->aux = open_device(modem, "Aux", "Aux: ");
-	if (data->aux == NULL) {
-		g_at_chat_unref(data->modem);
-		data->modem = NULL;
-		return -EIO;
+	if (data->aux == NULL)
+		return -EINVAL;
+
+	if (data->vendor_family == OFONO_VENDOR_UBLOX) {
+
+		data->modem = open_device(modem, "Modem", "Modem: ");
+		if (data->modem == NULL) {
+			g_at_chat_unref(data->aux);
+			data->aux = NULL;
+			return -EIO;
+		}
+
+		g_at_chat_set_slave(data->modem, data->aux);
+
+		g_at_chat_send(data->modem, "ATE0 +CMEE=1", none_prefix,
+						NULL, NULL, NULL);
+
 	}
 
-	g_at_chat_set_slave(data->modem, data->aux);
+	/* The modem can take a while to wake up if just powered on. */
+	g_at_chat_set_wakeup_command(data->aux, "AT\r", 1000, 11000);
 
-	g_at_chat_send(data->modem, "ATE0 +CMEE=1", none_prefix,
-					NULL, NULL, NULL);
 	g_at_chat_send(data->aux, "ATE0 +CMEE=1", none_prefix,
 					NULL, NULL, NULL);
 
Signature · 1 line
2.5.0
#10 lore raw

Re: [PATCH 05/19] plugins/ublox: allow enabling of TOBY L2 modems

Hi Dragos,

Quoted 54 lines · Dragos Tatulea

For this we need to:
* Set the vendor family based on model id.
* Not use modem interface for the TOBY L2 family.

---
  plugins/ublox.c | 53 ++++++++++++++++++++++++++++++++++++++++++++---------
  1 file changed, 44 insertions(+), 9 deletions(-)
plugins/ublox.c +25 -2
index 89ca709..171d59d 100644
@@ -47,6 +47,7 @@ static const char *none_prefix[] = { NULL };
  struct ublox_data {
  	GAtChat *modem;
  	GAtChat *aux;
+	enum ofono_vendor vendor_family;
  };
 
  static void ublox_debug(const char *str, void *user_data)
@@ -138,24 +139,58 @@ static void cfun_enable(gboolean ok, GAtResult *result, gpointer user_data)
  static int ublox_enable(struct ofono_modem *modem)
  {
  	struct ublox_data *data = ofono_modem_get_data(modem);
+	const char *model_str = NULL;
+	int model_id;
 
  	DBG("%p", modem);
 
-	data->modem = open_device(modem, "Modem", "Modem: ");
-	if (data->modem == NULL)
+	model_str = ofono_modem_get_string(modem, "Model");
+	if (model_str == NULL)
  		return -EINVAL;
 
+	/*
+	 * Toby L2 devices are more complex and special than previously
+	 * supported U-Blox devices. So they need a vendor of their own.
+	 */
+	model_id = atoi(model_str);
+	switch (model_id) {
+		case 1102:
+			data->vendor_family = OFONO_VENDOR_UBLOX;
+			break;
+		case 1141:
+		case 1146:
+			data->vendor_family = OFONO_VENDOR_UBLOX_TOBY_L2;
+			break;
+		case 1143:
+			DBG("low/medium throughtput profile unsupported");
+		default:
+			DBG("unknown ublox model id %d", model_id);
+			return -EINVAL;
+	}
+

plugins/ublox.c static void cfun_enable(gboolean ok, GAtResult *result, gpointer user_data) · line 176

Quoted 10 lines
plugins/ublox.c +5 -4
  	data->aux = open_device(modem, "Aux", "Aux: ");
-	if (data->aux == NULL) {
-		g_at_chat_unref(data->modem);
-		data->modem = NULL;
-		return -EIO;
+	if (data->aux == NULL)
+		return -EINVAL;
+
+	if (data->vendor_family == OFONO_VENDOR_UBLOX) {
+

No empty line here please

plugins/ublox.c static void cfun_enable(gboolean ok, GAtResult *result, gpointer user_data) · line 188

Quoted 12 lines
plugins/ublox.c +12 -0
+		data->modem = open_device(modem, "Modem", "Modem: ");
+		if (data->modem == NULL) {
+			g_at_chat_unref(data->aux);
+			data->aux = NULL;
+			return -EIO;
+		}
+
+		g_at_chat_set_slave(data->modem, data->aux);
+
+		g_at_chat_send(data->modem, "ATE0 +CMEE=1", none_prefix,
+						NULL, NULL, NULL);
+

No unneeded whitespace here please

plugins/ublox.c static void cfun_enable(gboolean ok, GAtResult *result, gpointer user_data) · line 192

Quoted 5 lines
plugins/ublox.c +2 -1
  	}
 
-	g_at_chat_set_slave(data->modem, data->aux);
+	/* The modem can take a while to wake up if just powered on. */
+	g_at_chat_set_wakeup_command(data->aux, "AT\r", 1000, 11000);

This is a pretty nasty hack specific for TI Calypso. I wouldn't use it unless you really need it.

plugins/ublox.c static void cfun_enable(gboolean ok, GAtResult *result, gpointer user_data)

Quoted 7 lines
plugins/ublox.c +0 -2
-	g_at_chat_send(data->modem, "ATE0 +CMEE=1", none_prefix,
-					NULL, NULL, NULL);
  	g_at_chat_send(data->aux, "ATE0 +CMEE=1", none_prefix,
  					NULL, NULL, NULL);
 
 

Regards,
-Denis

#11 lore raw

PATCH 6/19 plugins/ublox: use vendor from structure instead of fixed

In reply to Dragos Tatulea

That's because we need to differentiate between multiple ublox devices.

---
 plugins/ublox.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
plugins/ublox.c +6 -6
index 171d59d..0965ad1 100644
@@ -269,8 +269,8 @@ static void ublox_pre_sim(struct ofono_modem *modem)
 
 	DBG("%p", modem);
 
-	ofono_devinfo_create(modem, 0, "atmodem", data->aux);
-	sim = ofono_sim_create(modem, OFONO_VENDOR_UBLOX, "atmodem",
+	ofono_devinfo_create(modem, data->vendor_family, "atmodem", data->aux);
+	sim = ofono_sim_create(modem, data->vendor_family, "atmodem",
 					data->aux);
 
 	if (sim)
@@ -285,10 +285,10 @@ static void ublox_post_sim(struct ofono_modem *modem)
 
 	DBG("%p", modem);
 
-	gprs = ofono_gprs_create(modem, OFONO_VENDOR_UBLOX, "atmodem",
+	gprs = ofono_gprs_create(modem, data->vendor_family, "atmodem",
 					data->aux);
-	gc = ofono_gprs_context_create(modem, OFONO_VENDOR_UBLOX, "atmodem",
-					data->modem);
+	gc = ofono_gprs_context_create(modem, data->vendor_family, "atmodem",
+					data->modem ? data->modem : data->aux);
 
 	if (gprs && gc)
 		ofono_gprs_add_context(gprs, gc);
@@ -298,7 +298,7 @@ static void ublox_post_online(struct ofono_modem *modem)
 {
 	struct ublox_data *data = ofono_modem_get_data(modem);
 
-	ofono_netreg_create(modem, 0, "atmodem", data->aux);
+	ofono_netreg_create(modem, data->vendor_family, "atmodem", data->aux);
 }
 
 static struct ofono_modem_driver ublox_driver = {
Signature · 1 line
2.5.0
#12 lore raw

PATCH 7/19 atmodem: ublox: EPS now supported by newer ublox

In reply to Dragos Tatulea

Based on UBX-13002752 R33

---
 drivers/atmodem/gprs.c | 4 ----
 1 file changed, 4 deletions(-)
drivers/atmodem/gprs.c +0 -4
index 5551316..0165253 100644
@@ -303,10 +303,6 @@ static void ublox_ureg_notify(GAtResult *result, gpointer user_data)
 	case 5:
 		bearer = 4;
 		break;
-	case 7:
-		/* XXX: reserved - assume none. */
-		bearer = 0;
-		break;
 	case 8:
 		bearer = 1;
 		break;
Signature · 1 line
2.5.0
#13 lore raw

Re: [PATCH 07/19] atmodem: ublox: EPS now supported by newer ublox

Hi Dragos,

Quoted 5 lines · Dragos Tatulea

Based on UBX-13002752 R33

---
  drivers/atmodem/gprs.c | 4 ----
  1 file changed, 4 deletions(-)

Applying: atmodem: ublox: EPS now supported by newer ublox
error: patch failed: drivers/atmodem/gprs.c:303
error: drivers/atmodem/gprs.c: patch does not apply
Patch failed at 0001 atmodem: ublox: EPS now supported by newer ublox

drivers/atmodem/gprs.c static void ublox_ureg_notify(GAtResult *result, gpointer user_data) · line 309

Quoted 12 lines
drivers/atmodem/gprs.c +0 -4
index 5551316..0165253 100644
@@ -303,10 +303,6 @@ static void ublox_ureg_notify(GAtResult *result, gpointer user_data)
  	case 5:
  		bearer = 4;
  		break;
-	case 7:
-		/* XXX: reserved - assume none. */
-		bearer = 0;
-		break;

I don't see this code upstream.

drivers/atmodem/gprs.c static void ublox_ureg_notify(GAtResult *result, gpointer user_data) · line 308

Quoted 4 lines
drivers/atmodem/gprs.c +0 -0
  	case 8:
  		bearer = 1;
  		break;

Regards,
-Denis

#14 lore raw

Re: [PATCH 07/19] atmodem: ublox: EPS now supported by newer ublox

In reply to Dragos Tatulea

Hi Dragos,

Quoted 5 lines · Dragos Tatulea

Based on UBX-13002752 R33

---
  drivers/atmodem/gprs.c | 4 ----
  1 file changed, 4 deletions(-)

Ignore my previous message, this was applied now.

Regards,
-Denis

#15 lore raw

PATCH 8/19 atmodem: add support for U-Blox TOBY L2 modems

In reply to Dragos Tatulea

Besides exceptions below, act like normal U-Blox devices.

gprs-context: don't set auth for TOBY L2. U-Blox Toby L2 doesn't support PAP/CHAP APN auth method.

atmodem: TOBY L2 supports only CMER mode 1. Also chaged original mode variable to ind, which is a more appropriate name. mode is what is being set first.

---
 drivers/atmodem/gprs-context.c         |  2 ++
 drivers/atmodem/gprs.c                 |  1 +
 drivers/atmodem/network-registration.c | 12 +++++++-----
 drivers/atmodem/sim.c                  |  1 +
 4 files changed, 11 insertions(+), 5 deletions(-)
drivers/atmodem/gprs-context.c +2 -0
index f6e6c2e..ab47b25 100644
@@ -304,6 +304,8 @@ static void at_gprs_activate_primary(struct ofono_gprs_context *gc,
 				break;
 			}
 			break;
+		case OFONO_VENDOR_UBLOX_TOBY_L2:
+			/* Above not true for Toby L2 family, default is ok. */
 		default:
 			snprintf(buf + len, sizeof(buf) - len - 3, ",\"%s\"",
 					ctx->apn);
drivers/atmodem/gprs.c +1 -0
index 0165253..4505477 100644
@@ -351,6 +351,7 @@ static void gprs_initialized(gboolean ok, GAtResult *result, gpointer user_data)
 						FALSE, gprs, NULL);
 		break;
 	case OFONO_VENDOR_UBLOX:
+	case OFONO_VENDOR_UBLOX_TOBY_L2:
 		g_at_chat_register(gd->chat, "+UREG:", ublox_ureg_notify,
 						FALSE, gprs, NULL);
 		g_at_chat_send(gd->chat, "AT+UREG=1", none_prefix,
drivers/atmodem/network-registration.c +7 -5
index 7cfd6b2..81e8b8d 100644
@@ -1580,8 +1580,10 @@ static inline ofono_bool_t append_cmer_element(char *buf, int *len, int cap,
 static ofono_bool_t build_cmer_string(char *buf, int *cmer_opts,
 					struct netreg_data *nd)
 {
-	const char *mode;
+	const char *ind;
 	int len = sprintf(buf, "AT+CMER=");
+	/* UBX-13002752 R33: TOBY L2 doesn't support mode 2 and 3 */
+	const char *mode = nd->vendor == OFONO_VENDOR_UBLOX_TOBY_L2 ? "1":"3";
 
 	DBG("");
 
@@ -1590,7 +1592,7 @@ static ofono_bool_t build_cmer_string(char *buf, int *cmer_opts,
 	 * TA‑TE link specific inband technique used to embed result codes and
 	 * data when TA is in on‑line data mode
 	 */
-	if (!append_cmer_element(buf, &len, cmer_opts[0], "3", FALSE))
+	if (!append_cmer_element(buf, &len, cmer_opts[0], mode, FALSE))
 		return FALSE;
 
 	/* No keypad event reporting */
@@ -1607,14 +1609,14 @@ static ofono_bool_t build_cmer_string(char *buf, int *cmer_opts,
 		 * Telit does not support mode 1.
 		 * All indicator events shall be directed from TA to TE.
 		 */
-		mode = "2";
+		ind = "2";
 		break;
 	default:
 		/*
 		 * Only those indicator events, which are not caused by +CIND
 		 * shall be indicated by the TA to the TE.
 		 */
-		mode = "1";
+		ind = "1";
 		break;
 	}
 
@@ -1623,7 +1625,7 @@ static ofono_bool_t build_cmer_string(char *buf, int *cmer_opts,
 	 * <ind> indicates the indicator order number (as specified for +CIND)
 	 * and <value> is the new value of indicator.
 	 */
-	if (!append_cmer_element(buf, &len, cmer_opts[3], mode, TRUE))
+	if (!append_cmer_element(buf, &len, cmer_opts[3], ind, TRUE))
 		return FALSE;
 
 	return TRUE;
drivers/atmodem/sim.c +1 -0
index d6a0dcf..081d342 100644
@@ -1120,6 +1120,7 @@ static void at_pin_retries_query(struct ofono_sim *sim,
 			return;
 		break;
 	case OFONO_VENDOR_UBLOX:
+	case OFONO_VENDOR_UBLOX_TOBY_L2:
 		if (g_at_chat_send(sd->chat, "AT+UPINCNT", upincnt_prefix,
 					upincnt_cb, cbd, g_free) > 0)
 			return;
Signature · 1 line
2.5.0
#16 lore raw

Re: [PATCH 08/19] atmodem: add support for U-Blox TOBY L2 modems

Hi Dragos,

Quoted 20 lines · Dragos Tatulea

Besides exceptions below, act like normal U-Blox devices.

gprs-context: don't set auth for TOBY L2. U-Blox Toby L2 doesn't support PAP/CHAP APN auth method.

atmodem: TOBY L2 supports only CMER mode 1. Also chaged original mode variable to ind, which is a more appropriate name. mode is what is being set first.

---
  drivers/atmodem/gprs-context.c         |  2 ++
  drivers/atmodem/gprs.c                 |  1 +
  drivers/atmodem/network-registration.c | 12 +++++++-----
  drivers/atmodem/sim.c                  |  1 +
  4 files changed, 11 insertions(+), 5 deletions(-)
drivers/atmodem/gprs-context.c +0 -0
index f6e6c2e..ab47b25 100644

drivers/atmodem/gprs-context.c static void at_gprs_activate_primary(struct ofono_gprs_context *gc, · line 308

Quoted 5 lines
drivers/atmodem/gprs-context.c +2 -0
@@ -304,6 +304,8 @@ static void at_gprs_activate_primary(struct ofono_gprs_context *gc,
  				break;
  			}
  			break;
+		case OFONO_VENDOR_UBLOX_TOBY_L2:
+			/* Above not true for Toby L2 family, default is ok. */

Why is this needed?

Quoted 20 lines
drivers/atmodem/gprs-context.c +0 -0
  		default:
  			snprintf(buf + len, sizeof(buf) - len - 3, ",\"%s\"",
  					ctx->apn);
drivers/atmodem/gprs.c +1 -0
index 0165253..4505477 100644
@@ -351,6 +351,7 @@ static void gprs_initialized(gboolean ok, GAtResult *result, gpointer user_data)
  						FALSE, gprs, NULL);
  		break;
  	case OFONO_VENDOR_UBLOX:
+	case OFONO_VENDOR_UBLOX_TOBY_L2:
  		g_at_chat_register(gd->chat, "+UREG:", ublox_ureg_notify,
  						FALSE, gprs, NULL);
  		g_at_chat_send(gd->chat, "AT+UREG=1", none_prefix,
drivers/atmodem/network-registration.c +0 -0
index 7cfd6b2..81e8b8d 100644

drivers/atmodem/network-registration.c static inline ofono_bool_t append_cmer_element(char *buf, int *len, int cap, · line 1586

Quoted 8 lines
drivers/atmodem/network-registration.c +3 -1
@@ -1580,8 +1580,10 @@ static inline ofono_bool_t append_cmer_element(char *buf, int *len, int cap,
  static ofono_bool_t build_cmer_string(char *buf, int *cmer_opts,
  					struct netreg_data *nd)
  {
-	const char *mode;
+	const char *ind;
  	int len = sprintf(buf, "AT+CMER=");
+	/* UBX-13002752 R33: TOBY L2 doesn't support mode 2 and 3 */
+	const char *mode = nd->vendor == OFONO_VENDOR_UBLOX_TOBY_L2 ? "1":"3";

Lets make this into a switch/case statement.

e.g. const char *mode;

drivers/atmodem/network-registration.c static inline ofono_bool_t append_cmer_element(char *buf, int *len, int cap, · line 1588

Quoted 2 lines
drivers/atmodem/network-registration.c +0 -0
  	DBG("");

switch (nd->vendor) {
case OFONO_VENDOR_UBLOX_TOBY_L2:

	mode = 1;
	break;
default:
	mode = 3;
	break;
}
Quoted 42 lines
drivers/atmodem/network-registration.c +4 -4
@@ -1590,7 +1592,7 @@ static ofono_bool_t build_cmer_string(char *buf, int *cmer_opts,
  	 * TA‑TE link specific inband technique used to embed result codes and
  	 * data when TA is in on‑line data mode
  	 */
-	if (!append_cmer_element(buf, &len, cmer_opts[0], "3", FALSE))
+	if (!append_cmer_element(buf, &len, cmer_opts[0], mode, FALSE))
  		return FALSE;
 
  	/* No keypad event reporting */
@@ -1607,14 +1609,14 @@ static ofono_bool_t build_cmer_string(char *buf, int *cmer_opts,
  		 * Telit does not support mode 1.
  		 * All indicator events shall be directed from TA to TE.
  		 */
-		mode = "2";
+		ind = "2";
  		break;
  	default:
  		/*
  		 * Only those indicator events, which are not caused by +CIND
  		 * shall be indicated by the TA to the TE.
  		 */
-		mode = "1";
+		ind = "1";
  		break;
  	}
 
@@ -1623,7 +1625,7 @@ static ofono_bool_t build_cmer_string(char *buf, int *cmer_opts,
  	 * <ind> indicates the indicator order number (as specified for +CIND)
  	 * and <value> is the new value of indicator.
  	 */
-	if (!append_cmer_element(buf, &len, cmer_opts[3], mode, TRUE))
+	if (!append_cmer_element(buf, &len, cmer_opts[3], ind, TRUE))
  		return FALSE;
 
  	return TRUE;
drivers/atmodem/sim.c +0 -0
index d6a0dcf..081d342 100644

drivers/atmodem/sim.c static void at_pin_retries_query(struct ofono_sim *sim, · line 1126

Quoted 7 lines
drivers/atmodem/sim.c +1 -0
@@ -1120,6 +1120,7 @@ static void at_pin_retries_query(struct ofono_sim *sim,
  			return;
  		break;
  	case OFONO_VENDOR_UBLOX:
+	case OFONO_VENDOR_UBLOX_TOBY_L2:
  		if (g_at_chat_send(sd->chat, "AT+UPINCNT", upincnt_prefix,
  					upincnt_cb, cbd, g_free) > 0)
  			return;

Regards,
-Denis

#17 lore raw

Re: [PATCH 08/19] atmodem: add support for U-Blox TOBY L2 modems

Hi,

Quoted 18 lines · Denis Kenzior

Hi Dragos,

Quoted 15 lines · Dragos Tatulea

Besides exceptions below, act like normal U-Blox devices.

gprs-context: don't set auth for TOBY L2. U-Blox Toby L2 doesn't support PAP/CHAP APN auth method.

atmodem: TOBY L2 supports only CMER mode 1. Also chaged original mode variable to ind, which is a more appropriate name. mode is what is being set first.

---
  drivers/atmodem/gprs-context.c         |  2 ++
  drivers/atmodem/gprs.c                 |  1 +
  drivers/atmodem/network-registration.c | 12 +++++++-----
  drivers/atmodem/sim.c                  |  1 +
  4 files changed, 11 insertions(+), 5 deletions(-)
Quoted 13 lines

drivers/atmodem/gprs-context.c static void at_gprs_activate_primary(struct ofono_gprs_context *gc, · line 308

Quoted 10 lines
drivers/atmodem/gprs-context.c +2 -0
index f6e6c2e..ab47b25 100644
@@ -304,6 +304,8 @@ static void at_gprs_activate_primary(struct ofono_gprs_context *gc,
                  break;
              }
              break;
+        case OFONO_VENDOR_UBLOX_TOBY_L2:
+            /* Above not true for Toby L2 family, default is ok. */

Why is this needed?

It was needed in an older version of the code. Not needed anymore.

Quoted 36 lines
Quoted 20 lines
drivers/atmodem/gprs-context.c +0 -0
          default:
              snprintf(buf + len, sizeof(buf) - len - 3, ",\"%s\"",
                      ctx->apn);
drivers/atmodem/gprs.c +1 -0
index 0165253..4505477 100644
@@ -351,6 +351,7 @@ static void gprs_initialized(gboolean ok, GAtResult *result, gpointer user_data)
                          FALSE, gprs, NULL);
          break;
      case OFONO_VENDOR_UBLOX:
+    case OFONO_VENDOR_UBLOX_TOBY_L2:
          g_at_chat_register(gd->chat, "+UREG:", ublox_ureg_notify,
                          FALSE, gprs, NULL);
          g_at_chat_send(gd->chat, "AT+UREG=1", none_prefix,
drivers/atmodem/network-registration.c +0 -0
index 7cfd6b2..81e8b8d 100644

drivers/atmodem/network-registration.c static inline ofono_bool_t append_cmer_element(char *buf, int *len, int cap, · line 1586

Quoted 8 lines
drivers/atmodem/network-registration.c +3 -1
@@ -1580,8 +1580,10 @@ static inline ofono_bool_t append_cmer_element(char *buf, int *len, int cap,
  static ofono_bool_t build_cmer_string(char *buf, int *cmer_opts,
                      struct netreg_data *nd)
  {
-    const char *mode;
+    const char *ind;
      int len = sprintf(buf, "AT+CMER=");
+    /* UBX-13002752 R33: TOBY L2 doesn't support mode 2 and 3 */
+    const char *mode = nd->vendor == OFONO_VENDOR_UBLOX_TOBY_L2 ? "1":"3";

Lets make this into a switch/case statement.

e.g. const char *mode;

drivers/atmodem/network-registration.c static inline ofono_bool_t append_cmer_element(char *buf, int *len, int cap, · line 1588

Quoted 2 lines
drivers/atmodem/network-registration.c +0 -0
      DBG("");
Quoted 9 lines

switch (nd->vendor) {
case OFONO_VENDOR_UBLOX_TOBY_L2:

    mode = 1;
    break;
default:
    mode = 3;
    break;
}

Will do.

Quoted 48 lines
Quoted 48 lines
drivers/atmodem/network-registration.c +4 -4
@@ -1590,7 +1592,7 @@ static ofono_bool_t build_cmer_string(char *buf, int *cmer_opts,
       * TA‑TE link specific inband technique used to embed result codes and
       * data when TA is in on‑line data mode
       */
-    if (!append_cmer_element(buf, &len, cmer_opts[0], "3", FALSE))
+    if (!append_cmer_element(buf, &len, cmer_opts[0], mode, FALSE))
          return FALSE;
 
      /* No keypad event reporting */
@@ -1607,14 +1609,14 @@ static ofono_bool_t build_cmer_string(char *buf, int *cmer_opts,
           * Telit does not support mode 1.
           * All indicator events shall be directed from TA to TE.
           */
-        mode = "2";
+        ind = "2";
          break;
      default:
          /*
           * Only those indicator events, which are not caused by +CIND
           * shall be indicated by the TA to the TE.
           */
-        mode = "1";
+        ind = "1";
          break;
      }
 
@@ -1623,7 +1625,7 @@ static ofono_bool_t build_cmer_string(char *buf, int *cmer_opts,
       * <ind> indicates the indicator order number (as specified for +CIND)
       * and <value> is the new value of indicator.
       */
-    if (!append_cmer_element(buf, &len, cmer_opts[3], mode, TRUE))
+    if (!append_cmer_element(buf, &len, cmer_opts[3], ind, TRUE))
          return FALSE;
 
      return TRUE;
drivers/atmodem/sim.c +1 -0
index d6a0dcf..081d342 100644
@@ -1120,6 +1120,7 @@ static void at_pin_retries_query(struct ofono_sim *sim,
              return;
          break;
      case OFONO_VENDOR_UBLOX:
+    case OFONO_VENDOR_UBLOX_TOBY_L2:
          if (g_at_chat_send(sd->chat, "AT+UPINCNT", upincnt_prefix,
                      upincnt_cb, cbd, g_free) > 0)
              return;
Quoted 8 lines
Quoted 1 line

Regards,
-Denis
_______________________________________________
ofono mailing list
ofono(a)ofono.org
https://lists.ofono.org/mailman/listinfo/ofono

Thanks

Signature · 12 lines
Dragos Tatulea
Software Developer @ Endocode AG
dragos(a)endocode.com

Endocode AG, Brückenstraße 5A, 10179 Berlin
+49 30 1206 4472 | info(a)endocode.com | www.endocode.com

Vorstandsvorsitzender: Mirko Boehm
Vorstände: Dr. Thomas Fricke, Sebastian Sucker
Aufsichtsratsvorsitzende: Alexandra Boehm

Registergericht: Amtsgericht Charlottenburg - HRB 150748 B
#18 lore raw

PATCH 9/19 atmodem: work around CGREG issues in UBlox Toby L2

In reply to Dragos Tatulea

Don't use CGREG for network notifications. It will return 4 both when registered in LTE and in unknown state.

For the CGREG? query, interpret 4 as registered.

---
 drivers/atmodem/gprs.c | 24 +++++++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)
drivers/atmodem/gprs.c +21 -3
index 4505477..0b4bce8 100644
@@ -101,6 +101,17 @@ static void at_cgreg_cb(gboolean ok, GAtResult *result, gpointer user_data)
 		return;
 	}
 
+	if (gd->vendor == OFONO_VENDOR_UBLOX_TOBY_L2 && status == 4) {
+		/*
+		 * UBX-13002752-R33 says:
+		 * If the module is registered to E-UTRAN the <stat> parameter is 4.
+		 * So this means we are actually registered.
+		 * It could also mean that state is unknown, but if we are
+		 * here we know we already registered.
+		 */
+		 status = 1;
+	}
+
 	cb(&error, status, cbd->data);
 }
 
@@ -342,16 +353,23 @@ static void gprs_initialized(gboolean ok, GAtResult *result, gpointer user_data)
 	struct gprs_data *gd = ofono_gprs_get_data(gprs);
 
 	g_at_chat_register(gd->chat, "+CGEV:", cgev_notify, FALSE, gprs, NULL);
-	g_at_chat_register(gd->chat, "+CGREG:", cgreg_notify,
-						FALSE, gprs, NULL);
+
+	/*
+	 * You really don't want to get CGREG notifications on Toby l2.
+	 * It sends 4 when BOTH for unknown state and for registered in LTE.
+	 * +UREG usage is recommended by them.
+	 */
+	if (gd->vendor != OFONO_VENDOR_UBLOX_TOBY_L2)
+		g_at_chat_register(gd->chat, "+CGREG:", cgreg_notify,
+							FALSE, gprs, NULL);
 
 	switch (gd->vendor) {
 	case OFONO_VENDOR_HUAWEI:
 		g_at_chat_register(gd->chat, "^MODE:", huawei_mode_notify,
 						FALSE, gprs, NULL);
 		break;
-	case OFONO_VENDOR_UBLOX:
 	case OFONO_VENDOR_UBLOX_TOBY_L2:
+	case OFONO_VENDOR_UBLOX:
 		g_at_chat_register(gd->chat, "+UREG:", ublox_ureg_notify,
 						FALSE, gprs, NULL);
 		g_at_chat_send(gd->chat, "AT+UREG=1", none_prefix,
Signature · 1 line
2.5.0
#19 lore raw

Re: [PATCH 09/19] atmodem: work around CGREG issues in UBlox Toby L2

Hi Dragos,

Quoted 17 lines · Dragos Tatulea

Don't use CGREG for network notifications. It will return 4 both when registered in LTE and in unknown state.

For the CGREG? query, interpret 4 as registered.

---
  drivers/atmodem/gprs.c | 24 +++++++++++++++++++++---
  1 file changed, 21 insertions(+), 3 deletions(-)
drivers/atmodem/gprs.c +1 -0
index 4505477..0b4bce8 100644
@@ -101,6 +101,17 @@ static void at_cgreg_cb(gboolean ok, GAtResult *result, gpointer user_data)
  		return;
  	}
 
+	if (gd->vendor == OFONO_VENDOR_UBLOX_TOBY_L2 && status == 4) {

drivers/atmodem/gprs.c static void at_cgreg_cb(gboolean ok, GAtResult *result, gpointer user_data) · line 114

Quoted 10 lines
drivers/atmodem/gprs.c +10 -0
+		/*
+		 * UBX-13002752-R33 says:
+		 * If the module is registered to E-UTRAN the <stat> parameter is 4.
+		 * So this means we are actually registered.
+		 * It could also mean that state is unknown, but if we are
+		 * here we know we already registered.
+		 */
+		 status = 1;
+	}
+

Does ublox support AT+UREG? ? Perhaps that would be easier than making this hack. The core polls gprs_driver->attached_status in various cases, so assuming that 4==1 here seems unsafe.

Quoted 21 lines
drivers/atmodem/gprs.c +9 -2
  	cb(&error, status, cbd->data);
  }
 
@@ -342,16 +353,23 @@ static void gprs_initialized(gboolean ok, GAtResult *result, gpointer user_data)
  	struct gprs_data *gd = ofono_gprs_get_data(gprs);
 
  	g_at_chat_register(gd->chat, "+CGEV:", cgev_notify, FALSE, gprs, NULL);
-	g_at_chat_register(gd->chat, "+CGREG:", cgreg_notify,
-						FALSE, gprs, NULL);
+
+	/*
+	 * You really don't want to get CGREG notifications on Toby l2.
+	 * It sends 4 when BOTH for unknown state and for registered in LTE.
+	 * +UREG usage is recommended by them.
+	 */
+	if (gd->vendor != OFONO_VENDOR_UBLOX_TOBY_L2)
+		g_at_chat_register(gd->chat, "+CGREG:", cgreg_notify,
+							FALSE, gprs, NULL);
 
  	switch (gd->vendor) {

drivers/atmodem/gprs.c static void gprs_initialized(gboolean ok, GAtResult *result, gpointer user_data) · line 375

Quoted 10 lines
drivers/atmodem/gprs.c +1 -1
  	case OFONO_VENDOR_HUAWEI:
  		g_at_chat_register(gd->chat, "^MODE:", huawei_mode_notify,
  						FALSE, gprs, NULL);
  		break;
-	case OFONO_VENDOR_UBLOX:
  	case OFONO_VENDOR_UBLOX_TOBY_L2:
+	case OFONO_VENDOR_UBLOX:
  		g_at_chat_register(gd->chat, "+UREG:", ublox_ureg_notify,
  						FALSE, gprs, NULL);
  		g_at_chat_send(gd->chat, "AT+UREG=1", none_prefix,

Regards,
-Denis

#20 lore raw

PATCH 10/19 ubloxmodem: add Toby L2 gprs context driver

In reply to Dragos Tatulea

For now the driver works only with bridged mode.

Once it activates the context it reads the ip, netmask, gw, dns and sets them in the context settings.

4G default bearer is supported as well by reading the automatic activation cid and using it in the first context activation.

---
 Makefile.am                       |   7 +
 drivers/ubloxmodem/gprs-context.c | 498 ++++++++++++++++++++++++++++++++++++++
 drivers/ubloxmodem/ubloxmodem.c   |  49 ++++
 drivers/ubloxmodem/ubloxmodem.h   |  25 ++
 4 files changed, 579 insertions(+)
 create mode 100644 drivers/ubloxmodem/gprs-context.c
 create mode 100644 drivers/ubloxmodem/ubloxmodem.c
 create mode 100644 drivers/ubloxmodem/ubloxmodem.h
Makefile.am +7 -0
index cde998d..7652cfe 100644
@@ -374,6 +374,13 @@ builtin_sources += drivers/atmodem/atutil.h \
 			drivers/speedupmodem/speedupmodem.c \
 			drivers/speedupmodem/ussd.c
 
+builtin_modules += ubloxmodem
+builtin_sources += drivers/atmodem/atutil.h \
+			drivers/ubloxmodem/ubloxmodem.h \
+			drivers/ubloxmodem/ubloxmodem.c \
+			drivers/ubloxmodem/gprs-context.c
+
+
 if PHONESIM
 builtin_modules += phonesim
 builtin_sources += plugins/phonesim.c
drivers/ubloxmodem/gprs-context.c new file +498 -0

498 lines not on this page · raw message

drivers/ubloxmodem/ubloxmodem.c new file +49 -0

49 lines not on this page · raw message

drivers/ubloxmodem/ubloxmodem.h new file +25 -0
new file mode 100644
index 0000000..0c8a621
@@ -0,0 +1,25 @@
+/*
+ *
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2016  Endocode AG. 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
+ *
+ */
+
+#include <drivers/atmodem/atutil.h>
+
+extern void ublox_gprs_context_init(void);
+extern void ublox_gprs_context_exit(void);
Signature · 1 line
2.5.0
#21 lore raw

PATCH 11/19 gprs-context.h: add function for setting APN

In reply to Dragos Tatulea
---
 include/gprs-context.h | 3 +++
 1 file changed, 3 insertions(+)
include/gprs-context.h +3 -0
index 0090cc4..11d2132 100644
@@ -107,6 +107,9 @@ enum ofono_gprs_context_type ofono_gprs_context_get_type(
 void ofono_gprs_context_set_interface(struct ofono_gprs_context *gc,
 					const char *interface);
 
+void ofono_gprs_context_set_apn(struct ofono_gprs_context *gc,
+					const char *interface);
+
 void ofono_gprs_context_set_ipv4_address(struct ofono_gprs_context *gc,
 						const char *address,
 						ofono_bool_t static_ip);
Signature · 1 line
2.5.0
#22 lore raw

PATCH 12/19 gprs: allow APN updates from gprs-context driver

In reply to Dragos Tatulea

In the context activation callback, check for a changed APN. The default PDP in a 4G network is usually automatically activated. We might not know the APN. So allow the driver to read the APN and push it back into the core context.

---
 src/gprs.c | 25 +++++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)
src/gprs.c +23 -2
index 9192e68..d31e91b 100644
@@ -103,6 +103,7 @@ struct ipv6_settings {
 };
 
 struct context_settings {
+	char *apn;
 	char *interface;
 	struct ipv4_settings *ipv4;
 	struct ipv6_settings *ipv6;
@@ -383,6 +384,9 @@ static void context_settings_free(struct context_settings *settings)
 		settings->ipv6 = NULL;
 	}
 
+	g_free(settings->apn);
+	settings->apn = NULL;
+
 	g_free(settings->interface);
 	settings->interface = NULL;
 }
@@ -867,6 +871,9 @@ static DBusMessage *pri_get_properties(DBusConnection *conn,
 	return reply;
 }
 
+static DBusMessage *pri_set_apn(struct pri_context *ctx, DBusConnection *conn,
+				DBusMessage *msg, const char *apn);
+
 static void pri_activate_callback(const struct ofono_error *error, void *data)
 {
 	struct pri_context *ctx = data;
@@ -886,6 +893,11 @@ static void pri_activate_callback(const struct ofono_error *error, void *data)
 		return;
 	}
 
+
+	if (gc->settings->apn && strcmp(gc->settings->apn, ctx->context.apn))
+		/* APN changed  during context activation. */
+		pri_set_apn(ctx, conn, NULL, gc->settings->apn);
+
 	ctx->active = TRUE;
 	__ofono_dbus_pending_reply(&ctx->pending,
 				dbus_message_new_method_return(ctx->pending));
@@ -955,13 +967,13 @@ static DBusMessage *pri_set_apn(struct pri_context *ctx, DBusConnection *conn,
 		storage_sync(ctx->gprs->imsi, SETTINGS_STORE, settings);
 	}
 
-	g_dbus_send_reply(conn, msg, DBUS_TYPE_INVALID);
+	if (msg)
+		g_dbus_send_reply(conn, msg, DBUS_TYPE_INVALID);
 
 	ofono_dbus_signal_property_changed(conn, ctx->path,
 					OFONO_CONNECTION_CONTEXT_INTERFACE,
 					"AccessPointName",
 					DBUS_TYPE_STRING, &apn);
-
 	return NULL;
 }
 
@@ -2688,6 +2700,15 @@ void ofono_gprs_context_set_interface(struct ofono_gprs_context *gc,
 	settings->interface = g_strdup(interface);
 }
 
+void ofono_gprs_context_set_apn(struct ofono_gprs_context *gc,
+					const char *apn)
+{
+	struct context_settings *settings = gc->settings;
+
+	g_free(settings->apn);
+	settings->apn = g_strdup(apn);
+}
+
 void ofono_gprs_context_set_ipv4_address(struct ofono_gprs_context *gc,
 						const char *address,
 						ofono_bool_t static_ip)
Signature · 1 line
2.5.0
#23 lore raw

PATCH 13/19 ubloxmodem: push back APN into gprs context

In reply to Dragos Tatulea

It can be that the APN is different than what a user provided. So let the core know. This happens for example when using the default bearer:
the user doesn't provide any APN, so read the one from CGCONTRDP.

---
 drivers/ubloxmodem/gprs-context.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/ubloxmodem/gprs-context.c +11 -1
index f80e1d8..b6eaa5e 100644
@@ -183,6 +183,7 @@ static void cgcontrdp_bridge_cb(gboolean ok, GAtResult *result, gpointer user_da
 	const char *laddrnetmask = NULL;
 	const char *gw = NULL;
 	const char *dns[2+1] = { NULL, NULL, NULL };
+	const char *apn = NULL;
 
 	DBG("ok %d", ok);
 
@@ -197,7 +198,6 @@ static void cgcontrdp_bridge_cb(gboolean ok, GAtResult *result, gpointer user_da
 	while (g_at_result_iter_next(&iter, "+CGCONTRDP:")) {
 		/* tmp vals for ignored fields */
 		int bearer_id;
-		char *apn;
 
 		if (!g_at_result_iter_next_number(&iter, &cid))
 			break;
@@ -234,6 +234,16 @@ static void cgcontrdp_bridge_cb(gboolean ok, GAtResult *result, gpointer user_da
 	if (dns[0])
 		ofono_gprs_context_set_ipv4_dns_servers(gc, dns);
 
+	if (gcd->active_context == ublox_data.default_context_id) {
+		/*
+		 * Only for automatic default context: the APN set by the user
+		 * might not be the correct one because the default context was
+		 * used instead.
+		 */
+		ofono_gprs_context_set_apn(gc, apn);
+		strcpy(gcd->apn, apn);
+	}
+
 	CALLBACK_WITH_SUCCESS(gcd->cb, gcd->cb_data);
 }
 
Signature · 1 line
2.5.0
#24 lore raw

PATCH 14/19 plugins/ublox: give names to model ids

In reply to Dragos Tatulea

To make it easier to understand the code.

---
 plugins/ublox.c | 24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)
plugins/ublox.c +16 -8
index 0965ad1..bdc0fa1 100644
@@ -44,9 +44,18 @@
 
 static const char *none_prefix[] = { NULL };
 
+enum supported_models {
+	UNKNOWN				= 0,
+	SARA_G270			= 1102,
+	TOBYL2_COMPATIBLE_MODE 		= 1141,
+	TOBYL2_MEDIUM_THROUGHPUT_MODE 	= 1143,
+	TOBYL2_HIGH_THROUGHPUT_MODE 	= 1146,
+};
+
 struct ublox_data {
 	GAtChat *modem;
 	GAtChat *aux;
+	int model_id;
 	enum ofono_vendor vendor_family;
 };
 
@@ -140,7 +149,6 @@ static int ublox_enable(struct ofono_modem *modem)
 {
 	struct ublox_data *data = ofono_modem_get_data(modem);
 	const char *model_str = NULL;
-	int model_id;
 
 	DBG("%p", modem);
 
@@ -152,19 +160,19 @@ static int ublox_enable(struct ofono_modem *modem)
 	 * Toby L2 devices are more complex and special than previously
 	 * supported U-Blox devices. So they need a vendor of their own.
 	 */
-	model_id = atoi(model_str);
-	switch (model_id) {
-		case 1102:
+	data->model_id = atoi(model_str);
+	switch (data->model_id) {
+		case SARA_G270:
 			data->vendor_family = OFONO_VENDOR_UBLOX;
 			break;
-		case 1141:
-		case 1146:
+		case TOBYL2_COMPATIBLE_MODE:
+		case TOBYL2_HIGH_THROUGHPUT_MODE:
 			data->vendor_family = OFONO_VENDOR_UBLOX_TOBY_L2;
 			break;
-		case 1143:
+		case TOBYL2_MEDIUM_THROUGHPUT_MODE:
 			DBG("low/medium throughtput profile unsupported");
 		default:
-			DBG("unknown ublox model id %d", model_id);
+			DBG("unknown ublox model id %d", data->model_id);
 			return -EINVAL;
 	}
 
Signature · 1 line
2.5.0
#25 lore raw

PATCH 15/19 plugins/ublox: enable ubloxmodem driver when possible

In reply to Dragos Tatulea

Where possible means Toby L2 in high speed mode.

The bridge mode is set before enabling the modem because the driver requires this.

---
 plugins/ublox.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)
plugins/ublox.c +14 -2
index bdc0fa1..032a3c4 100644
@@ -142,6 +142,11 @@ static void cfun_enable(gboolean ok, GAtResult *result, gpointer user_data)
 		return;
 	}
 
+	if (data->model_id == TOBYL2_HIGH_THROUGHPUT_MODE)
+		/* use bridged mode until routed mode support is added */
+		g_at_chat_send(data->aux, "AT+UBMCONF=2", none_prefix,
+						NULL, NULL, NULL);
+
 	ofono_modem_set_powered(modem, TRUE);
 }
 
@@ -295,8 +300,15 @@ static void ublox_post_sim(struct ofono_modem *modem)
 
 	gprs = ofono_gprs_create(modem, data->vendor_family, "atmodem",
 					data->aux);
-	gc = ofono_gprs_context_create(modem, data->vendor_family, "atmodem",
-					data->modem ? data->modem : data->aux);
+	if (data->model_id == TOBYL2_HIGH_THROUGHPUT_MODE)
+		gc = ofono_gprs_context_create(modem, data->vendor_family,
+						"ubloxmodem",
+						data->modem ? data->modem : data->aux);
+
+	else
+		gc = ofono_gprs_context_create(modem, data->vendor_family,
+						"atmodem",
+						data->modem ? data->modem : data->aux);
 
 	if (gprs && gc)
 		ofono_gprs_add_context(gprs, gc);
Signature · 1 line
2.5.0
#26 lore raw

PATCH 16/19 plugins/ublox: support more internet contexts

In reply to Dragos Tatulea

Create multiple gprs-context instances and let the gprs core use them as it sees fit.

Only for Toby L2.

---
 plugins/ublox.c | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)
plugins/ublox.c +12 -9
index 032a3c4..76f7fcf 100644
@@ -295,23 +295,26 @@ static void ublox_post_sim(struct ofono_modem *modem)
 	struct ublox_data *data = ofono_modem_get_data(modem);
 	struct ofono_gprs *gprs;
 	struct ofono_gprs_context *gc;
+	GAtChat *chat = data->modem ? data->modem : data->aux;
+	const char *driver = data->model_id == TOBYL2_HIGH_THROUGHPUT_MODE ?
+							"ubloxmodem":"atmodem";
+	/* Toby L2: Create same number of contexts as supported PDP contexts. */
+	int ncontexts = data->model_id == TOBYL2_HIGH_THROUGHPUT_MODE ? 8:1;
 
 	DBG("%p", modem);
 
 	gprs = ofono_gprs_create(modem, data->vendor_family, "atmodem",
 					data->aux);
-	if (data->model_id == TOBYL2_HIGH_THROUGHPUT_MODE)
-		gc = ofono_gprs_context_create(modem, data->vendor_family,
-						"ubloxmodem",
-						data->modem ? data->modem : data->aux);
 
-	else
+	while (ncontexts) {
 		gc = ofono_gprs_context_create(modem, data->vendor_family,
-						"atmodem",
-						data->modem ? data->modem : data->aux);
+						driver, chat);
 
-	if (gprs && gc)
-		ofono_gprs_add_context(gprs, gc);
+		if (gprs && gc)
+			ofono_gprs_add_context(gprs, gc);
+
+		--ncontexts;
+	}
 }
 
 static void ublox_post_online(struct ofono_modem *modem)
Signature · 1 line
2.5.0
#27 lore raw

PATCH 17/19 ubloxmodem: support authentication

In reply to Dragos Tatulea

If username and password specified, issue an UAUTHREQ command with the configured authentication method, selected cid and credentials.

---
 drivers/ubloxmodem/gprs-context.c | 61 +++++++++++++++++++++++++++++++++++++--
 1 file changed, 59 insertions(+), 2 deletions(-)
drivers/ubloxmodem/gprs-context.c +59 -2
index b6eaa5e..bc100d6 100644
@@ -49,6 +49,9 @@ struct gprs_context_data {
 	unsigned int active_context;
 	unsigned int gprs_cid;
 	char apn[OFONO_GPRS_MAX_APN_LENGTH + 1];
+	char username[OFONO_GPRS_MAX_USERNAME_LENGTH + 1];
+	char password[OFONO_GPRS_MAX_PASSWORD_LENGTH + 1];
+	enum ofono_gprs_auth_method auth_method;
 	ofono_gprs_context_cb_t cb;
 	void *cb_data;
 };
@@ -326,9 +329,58 @@ static void ublox_activate_ctx(struct ofono_gprs_context *gc)
 	CALLBACK_WITH_FAILURE(gcd->cb, gcd->cb_data);
 }
 
+static void uauthreq_cb(gboolean ok, GAtResult *result, gpointer user_data)
+{
+	struct ofono_gprs_context *gc = user_data;
+	struct gprs_context_data *gcd = ofono_gprs_context_get_data(gc);
+
+	DBG("ok %d", ok);
+
+	if (!ok) {
+		ofono_error("can't authenticate");
+		release_context_id(gcd->active_context);
+		callback_with_error(gcd, result);
+
+		return;
+	}
+
+	ublox_activate_ctx(gc);
+}
+
 #define UBLOX_MAX_USER_LEN 50
 #define UBLOX_MAX_PASS_LEN 50
 
+static void ublox_authenticate(struct ofono_gprs_context *gc)
+{
+	struct gprs_context_data *gcd = ofono_gprs_context_get_data(gc);
+	char buf[UBLOX_MAX_USER_LEN + UBLOX_MAX_PASS_LEN + 32];
+	unsigned auth_method;
+
+	switch (gcd->auth_method) {
+	case OFONO_GPRS_AUTH_METHOD_PAP:
+		auth_method = 1;
+		break;
+	case OFONO_GPRS_AUTH_METHOD_CHAP:
+		auth_method = 2;
+		break;
+	default:
+		ofono_error("Unsupported auth type %u", gcd->auth_method);
+		goto error;
+	}
+
+	snprintf(buf, sizeof(buf), "AT+UAUTHREQ=%u,%u,\"%s\",\"%s\"",
+			gcd->active_context, auth_method,
+			gcd->username, gcd->password);
+
+	/* If this failed, we will see it during context activation. */
+	if (g_at_chat_send(gcd->chat, buf, none_prefix,
+				uauthreq_cb, gc, NULL) > 0)
+		return;
+
+error:
+	CALLBACK_WITH_FAILURE(gcd->cb, gcd->cb_data);
+}
+
 static void ublox_gprs_activate_primary(struct ofono_gprs_context *gc,
 				const struct ofono_gprs_primary_context *ctx,
 				ofono_gprs_context_cb_t cb, void *data)
@@ -352,13 +404,18 @@ static void ublox_gprs_activate_primary(struct ofono_gprs_context *gc,
 
 	gcd->cb = cb;
 	gcd->cb_data = data;
+	gcd->auth_method = ctx->auth_method;
 	gcd->gprs_cid = ctx->cid;
 	memcpy(gcd->apn, ctx->apn, sizeof(ctx->apn));
 
-	if (gcd->active_context == ublox_data.default_context_id)
+	if (gcd->active_context == ublox_data.default_context_id) {
 		/* Default context already active, only read details. */
 		ublox_post_activation(gc);
-	else
+	} else if (strlen(ctx->username) && strlen(ctx->password)) {
+		memcpy(gcd->username, ctx->username, sizeof(ctx->username));
+		memcpy(gcd->password, ctx->password, sizeof(ctx->password));
+		ublox_authenticate(gc);
+	} else
 		ublox_activate_ctx(gc);
 }
 
Signature · 1 line
2.5.0
#28 lore raw

PATCH 18/19 plugins/ublox: read network mode

In reply to Dragos Tatulea

From: Dongsu Park <[email protected]>

Read network mode into modem string. This will let the gprs-context drive know what to do.

---
 plugins/ublox.c | 47 ++++++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 42 insertions(+), 5 deletions(-)
plugins/ublox.c +42 -5
index 76f7fcf..9cfba33 100644
@@ -42,6 +42,7 @@
 #include <drivers/atmodem/atutil.h>
 #include <drivers/atmodem/vendor.h>
 
+static const char *ubmconf_prefix[] = { "+UBMCONF:", NULL };
 static const char *none_prefix[] = { NULL };
 
 enum supported_models {
@@ -52,11 +53,17 @@ enum supported_models {
 	TOBYL2_HIGH_THROUGHPUT_MODE 	= 1146,
 };
 
+enum ublox_net_mode {
+	UBLOX_TOBYL2_NET_MODE_ROUTER = 1,
+	UBLOX_TOBYL2_NET_MODE_BRIDGE = 2,
+};
+
 struct ublox_data {
 	GAtChat *modem;
 	GAtChat *aux;
 	int model_id;
 	enum ofono_vendor vendor_family;
+	enum ublox_net_mode net_mode;
 };
 
 static void ublox_debug(const char *str, void *user_data)
@@ -93,6 +100,39 @@ static void ublox_remove(struct ofono_modem *modem)
 	g_free(data);
 }
 
+static void read_ubmconf_cb(gboolean ok, GAtResult *result, gpointer user_data)
+{
+	struct ofono_modem *modem = (struct ofono_modem *) user_data;
+	struct ublox_data *data = ofono_modem_get_data(modem);
+	int mode = 0;
+	GAtResultIter iter;
+
+	g_at_result_iter_init(&iter, result);
+
+	while (!g_at_result_iter_next(&iter, "+UBMCONF:"))
+		;	/* skip every other line that is not UBMCONF */
+
+	g_at_result_iter_next_number(&iter, &mode);
+
+	data->net_mode = mode;
+	DBG("mode=%d", mode);
+	if (mode == 1)
+		ofono_modem_set_string(modem, "NetworkMode", "routed");
+	else if (mode == 2)
+		ofono_modem_set_string(modem, "NetworkMode", "bridged");
+}
+
+static void read_net_mode(struct ofono_modem *modem)
+{
+	struct ublox_data *data = ofono_modem_get_data(modem);
+
+	if (!data->aux)
+		return;
+
+	g_at_chat_send(data->aux, "AT+UBMCONF?",
+			ubmconf_prefix, read_ubmconf_cb, modem, NULL);
+}
+
 static GAtChat *open_device(struct ofono_modem *modem,
 				const char *key, char *debug)
 {
@@ -142,11 +182,6 @@ static void cfun_enable(gboolean ok, GAtResult *result, gpointer user_data)
 		return;
 	}
 
-	if (data->model_id == TOBYL2_HIGH_THROUGHPUT_MODE)
-		/* use bridged mode until routed mode support is added */
-		g_at_chat_send(data->aux, "AT+UBMCONF=2", none_prefix,
-						NULL, NULL, NULL);
-
 	ofono_modem_set_powered(modem, TRUE);
 }
 
@@ -207,6 +242,8 @@ static int ublox_enable(struct ofono_modem *modem)
 	g_at_chat_send(data->aux, "ATE0 +CMEE=1", none_prefix,
 					NULL, NULL, NULL);
 
+	read_net_mode(modem);
+
 	g_at_chat_send(data->aux, "AT+CFUN=4", none_prefix,
 					cfun_enable, modem, NULL);
 
Signature · 1 line
2.5.0
#29 lore raw

PATCH 19/19 ubloxmodem: add routed mode support

In reply to Dragos Tatulea

From: Dongsu Park <[email protected]>

Routed mode needs a different treatment than bridged mode:

* UIPCONF needs to be used for reading the interface ip configuratuion. The spec says that DHCP should work on that interface but it doesn't. So we read the first ip in the dhcp range and use that.

* CGCONTRDP: only APN and DNS configuration is read

---
 drivers/ubloxmodem/gprs-context.c | 151 +++++++++++++++++++++++++++++++++++++-
 1 file changed, 150 insertions(+), 1 deletion(-)
drivers/ubloxmodem/gprs-context.c +150 -1
index bc100d6..4040a07 100644
@@ -43,6 +43,7 @@
 
 static const char *none_prefix[] = { NULL };
 static const char *cgcontrdp_prefix[] = { "+CGCONTRDP:", NULL };
+static const char *uipconf_prefix[] = { "+UIPCONF:", NULL };
 
 struct gprs_context_data {
 	GAtChat *chat;
@@ -250,6 +251,65 @@ static void cgcontrdp_bridge_cb(gboolean ok, GAtResult *result, gpointer user_da
 	CALLBACK_WITH_SUCCESS(gcd->cb, gcd->cb_data);
 }
 
+static void cgcontrdp_router_cb(gboolean ok, GAtResult *result, gpointer user_data)
+{
+	struct ofono_gprs_context *gc = user_data;
+	struct gprs_context_data *gcd = ofono_gprs_context_get_data(gc);
+	GAtResultIter iter;
+
+	const char *dns[2+1] = { NULL, NULL, NULL };
+	const char *apn = NULL;
+
+	DBG("ok %d", ok);
+
+	if (!ok) {
+		callback_with_error(gcd, result);
+
+		return;
+	}
+
+	g_at_result_iter_init(&iter, result);
+
+	while (g_at_result_iter_next(&iter, "+CGCONTRDP:")) {
+		/* skip cid, bearer_id */
+		g_at_result_iter_skip_next(&iter);
+		g_at_result_iter_skip_next(&iter);
+
+		/* read apn */
+		if (!g_at_result_iter_next_string(&iter, &apn))
+			break;
+
+		/* skip laddrnetmask, gw */
+		g_at_result_iter_skip_next(&iter);
+		g_at_result_iter_skip_next(&iter);
+
+		/* read dns servers */
+		if (!g_at_result_iter_next_string(&iter, &dns[0]))
+			break;
+
+		if (!g_at_result_iter_next_string(&iter, &dns[1]))
+			break;
+	}
+
+	set_gprs_context_interface(gc);
+
+	if (dns[0])
+		ofono_gprs_context_set_ipv4_dns_servers(gc, dns);
+
+	if (gcd->active_context == ublox_data.default_context_id) {
+		/*
+		 * Only for automatic default context: the APN set by the user
+		 * might not be the correct one because the default context was
+		 * used instead.
+		 */
+		ofono_gprs_context_set_apn(gc, apn);
+		strcpy(gcd->apn, apn);
+	}
+
+	CALLBACK_WITH_SUCCESS(gcd->cb, gcd->cb_data);
+	return;
+}
+
 static int ublox_read_ip_config_bridge(struct ofono_gprs_context *gc)
 {
 	struct gprs_context_data *gcd = ofono_gprs_context_get_data(gc);
@@ -262,11 +322,100 @@ static int ublox_read_ip_config_bridge(struct ofono_gprs_context *gc)
 
 }
 
+static void read_uipconf_cb(gboolean ok, GAtResult *result, gpointer user_data)
+{
+	struct ofono_gprs_context *gc = user_data;
+	struct gprs_context_data *gcd = ofono_gprs_context_get_data(gc);
+	GAtResultIter iter;
+	const char *gw, *netmask, *ipaddr, *dhcp_range_start, *dhcp_range_end;
+	gboolean found = FALSE;
+	char buf[64];
+
+	DBG("ok %d", ok);
+
+	if (!ok) {
+		release_context_id(gcd->active_context);
+		callback_with_error(gcd, result);
+
+		return;
+	}
+
+	g_at_result_iter_init(&iter, result);
+
+	/* for example, +UIPCONF: entry looks like:
+	 * +UIPCONF: "192.168.1.1","255.255.255.0","192.168.1.100",
+	 *           "192.168.1.100","fe80::48a5:b2ff:fe6f:5f86/64"
+	 */
+	while (g_at_result_iter_next(&iter, "+UIPCONF:")) {
+		if (!g_at_result_iter_next_string(&iter, &gw))
+			continue;
+
+		if (!g_at_result_iter_next_string(&iter, &netmask))
+			continue;
+
+		if (!g_at_result_iter_next_string(&iter, &dhcp_range_start))
+			continue;
+
+		if (!g_at_result_iter_next_string(&iter, &dhcp_range_end))
+			continue;
+
+		/* skip other entries like IPv6 networks */
+		found = TRUE;
+		break;
+	}
+
+	if (!found)
+		goto error;
+
+	if (dhcp_range_start && dhcp_range_end) {
+		ipaddr = dhcp_range_start;
+		ofono_gprs_context_set_ipv4_address(gc, ipaddr, 1);
+	}
+
+	if (netmask)
+		ofono_gprs_context_set_ipv4_netmask(gc, netmask);
+
+	if (gw)
+		ofono_gprs_context_set_ipv4_gateway(gc, gw);
+
+	/* read ip configuration info */
+	snprintf(buf, sizeof(buf), "AT+CGCONTRDP");
+	if (g_at_chat_send(gcd->chat, buf, cgcontrdp_prefix,
+				cgcontrdp_router_cb, gc, NULL) > 0)
+		return;
+
+error:
+	CALLBACK_WITH_FAILURE(gcd->cb, gcd->cb_data);
+}
+
+static int ublox_read_ip_config_router(struct ofono_gprs_context *gc)
+{
+	struct gprs_context_data *gcd = ofono_gprs_context_get_data(gc);
+	char buf[64];
+
+	/* read ip configuration info */
+	snprintf(buf, sizeof(buf), "AT+UIPCONF?");
+	return g_at_chat_send(gcd->chat, buf, uipconf_prefix,
+				read_uipconf_cb, gc, NULL);
+
+}
+
 static void ublox_post_activation(struct ofono_gprs_context *gc)
 {
+	struct ofono_modem *modem;
+	const char *network_mode;
 	struct gprs_context_data *gcd = ofono_gprs_context_get_data(gc);
+	int ret = 0;
+
+	modem = ofono_gprs_context_get_modem(gc);
+	network_mode = ofono_modem_get_string(modem, "NetworkMode");
+
+	if (g_str_equal(network_mode, "routed"))
+		ret = ublox_read_ip_config_router(gc) ;
+	else
+		ret = ublox_read_ip_config_bridge(gc);
 
-	if (ublox_read_ip_config_bridge(gc) < 0)
+	if (ret <= 0)
 		CALLBACK_WITH_FAILURE(gcd->cb, gcd->cb_data);
 }
 
Signature · 1 line
2.5.0