All of lore.kernel.org
 help / color / mirror / Atom feed
* Huawei E3372
@ 2017-02-14  9:53 Christophe Ronco
  2017-02-14 15:47 ` Denis Kenzior
  0 siblings, 1 reply; 9+ messages in thread
From: Christophe Ronco @ 2017-02-14  9:53 UTC (permalink / raw)
  To: ofono

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

Hi,

I try to connect using a USB dongle. It is a Huawei E3372h-153. I will 
try to give information on this modem because looking at Internet, it 
seems that E3372 is a generic name for different hardwares (or firmwares?).

Before usb_modeswitch my USB dongle present itself as a CDROM and a mass 
storage media with these vendor and product ids:

usb 1-1: New USB device found, idVendor=12d1, idProduct=15cf

After usb_modeswitch, product id changes:

usb 1-1: New USB device found, idVendor=12d1, idProduct=15b7

And devices are:

  - 2 serial ports:

[   16.010158] option 1-1:1.0: GSM modem (1-port) converter detected
[   16.065118] usb 1-1: GSM modem (1-port) converter now attached to ttyUSB0
[   16.141589] option 1-1:1.1: GSM modem (1-port) converter detected
[   16.208587] usb 1-1: GSM modem (1-port) converter now attached to ttyUSB1

  - a CDC NCM net device (/dev/cdc-wdm0):

[   16.358721] huawei_cdc_ncm 1-1:1.2: MAC-Address: 00:1e:10:1f:00:00
[   16.417550] huawei_cdc_ncm 1-1:1.2: NDP will be placed at end of 
frame for this device.
[   16.455455] huawei_cdc_ncm 1-1:1.2: cdc-wdm0: USB WDM device
[   16.520626] huawei_cdc_ncm 1-1:1.2 wwan0: register 'huawei_cdc_ncm' 
at usb-ci_hdrc.0-1, Huawei CDC NCM device, 00:1e:10:1f:00:00

  - a mass storage device


Using ATI, modem present itself like that:

Manufacturer: huawei
Model: E3372H
Revision: 21.315.01.00.314
IMEI: XXXX
+GCAP: +CGSM,+DS,+ES


Using an unmodified Ofono, I fail to activate gprs context:

Feb 14 08:43:55 klk-lpbs-040070 daemon.debug ofonod[1238]: 
../git/drivers/atmodem/gprs-context.c:at_gprs_activate_primary() cid 1
Feb 14 08:43:55 klk-lpbs-040070 daemon.info ofonod[1238]: Modem: > 
AT+CGDCONT=1,"IP","orange.m2m.spec"\r
Feb 14 08:43:55 klk-lpbs-040070 daemon.info ofonod[1238]: Modem: < 
\r\nOK\r\n
Feb 14 08:43:55 klk-lpbs-040070 daemon.debug ofonod[1238]: 
../git/drivers/atmodem/gprs-context.c:at_cgdcont_cb() ok 1
Feb 14 08:43:55 klk-lpbs-040070 daemon.info ofonod[1238]: Modem: > 
AT+CGDATA="PPP",1\r
Feb 14 08:43:55 klk-lpbs-040070 daemon.info ofonod[1238]: Modem: < 
\r\n+CME ERROR: 50\r\n
Feb 14 08:43:55 klk-lpbs-040070 daemon.debug ofonod[1238]: 
../git/drivers/atmodem/gprs-context.c:at_cgdata_cb() ok 0
Feb 14 08:43:55 klk-lpbs-040070 daemon.info ofonod[1238]: Unable to 
enter data state
Feb 14 08:43:55 klk-lpbs-040070 daemon.debug ofonod[1238]: 
../git/src/gprs.c:pri_activate_callback() 0x41f4f8
Feb 14 08:43:55 klk-lpbs-040070 daemon.debug ofonod[1238]: 
../git/src/gprs.c:pri_activate_callback() Activating context failed with 
error: Incorrect parameters


So activation fails because AT+CGDATA="PPP",1 fails. Here is what this 
modem claims to support:

AT+CGDATA=?
+CGDATA: ("NULL")

OK

I didn't try to send AT+CGDATA="NULL",1 before PPP setup. Instead I used 
ATD*99***1#. So I modified function at_cgdcont_cb in 
drivers/atmodem/gprs-context.c to send this command instead of 
AT+CGDATA="PPP",1 and I managed to connect. Here are the traces:

Feb 14 08:57:30 klk-lpbs-040070 daemon.debug ofonod[1252]: 
../git/drivers/atmodem/gprs-context.c:at_gprs_activate_primary() cid 1
Feb 14 08:57:30 klk-lpbs-040070 daemon.info ofonod[1252]: Modem: > 
AT+CGDCONT=1,"IP","orange.m2m.spec"\r
Feb 14 08:57:30 klk-lpbs-040070 daemon.info ofonod[1252]: Modem: < 
\r\nOK\r\n
Feb 14 08:57:30 klk-lpbs-040070 daemon.debug ofonod[1252]: 
../git/drivers/atmodem/gprs-context.c:at_cgdcont_cb() ok 1
Feb 14 08:57:30 klk-lpbs-040070 daemon.info ofonod[1252]: Modem: > 
ATD*99***1#\r
Feb 14 08:57:30 klk-lpbs-040070 daemon.info ofonod[1252]: Modem: < 
\r\nCONNECT\r\n
Feb 14 08:57:30 klk-lpbs-040070 daemon.debug ofonod[1252]: 
../git/drivers/atmodem/gprs-context.c:at_cgdata_cb() ok 1
Feb 14 08:57:30 klk-lpbs-040070 daemon.debug ofonod[1252]: 
../git/drivers/atmodem/gprs-context.c:setup_ppp()
Feb 14 08:57:30 klk-lpbs-040070 daemon.info ofonod[1252]: PPP: lcp: 
pppcp_generate_event: current state 0:INITIAL

... (PPP debug)

Feb 14 08:57:33 klk-lpbs-040070 daemon.info ofonod[1252]: PPP: 
../git/gatchat/gatppp.c:ppp_enter_phase() 4
Feb 14 08:57:33 klk-lpbs-040070 daemon.debug ofonod[1252]: 
../git/drivers/atmodem/gprs-context.c:ppp_connect()
Feb 14 08:57:33 klk-lpbs-040070 daemon.info ofonod[1252]: IP: 10.47.149.108
Feb 14 08:57:33 klk-lpbs-040070 daemon.info ofonod[1252]: DNS: 
192.168.10.110, 194.51.3.56
Feb 14 08:57:33 klk-lpbs-040070 daemon.debug ofonod[1252]: 
../git/src/gprs.c:pri_activate_callback() 0x3654e8


My problem now is how to know if I should send AT+CGDATA="PPP",1 or 
ATD*99***1# when activating context in@modem driver. I see in this 
driver and others that a VENDOR information can be sent from plugin but 
I imagine that other Huawei devices support AT+CGDATA="PPP",1.

Do you have any idea of what I should do to support this modem without 
disturbing other devices?

Christophe


PS: I am aware that using PPP to connect this modem might not be the 
best solution. I spent days to try to get interface wwan0 up. I managed 
to get IP address, gateway and DNS servers for this interface using 
something similar to what is done in telitmodem/gprs-context-ncm.c (I 
might send traces if someone is interested) but I never managed to send 
or receive a packet on wwan0 interface. Problem might come from my 
kernel (4.1) even if I applied all patches from Vanilla linked to 
drivers/net/usb/cdc_ncm.c, drivers/net/usb/huawei_cdc_ncm.c or 
drivers/usb/class/cdc-wdm.c.




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

* Re: Huawei E3372
  2017-02-14  9:53 Huawei E3372 Christophe Ronco
@ 2017-02-14 15:47 ` Denis Kenzior
  2017-02-14 16:37   ` Christophe Ronco
  0 siblings, 1 reply; 9+ messages in thread
From: Denis Kenzior @ 2017-02-14 15:47 UTC (permalink / raw)
  To: ofono

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

Hi Christophe,

> usb 1-1: New USB device found, idVendor=12d1, idProduct=15b7
 > Using ATI, modem present itself like that:
 >
 > Manufacturer: huawei
 > Model: E3372H
 > Revision: 21.315.01.00.314
 > IMEI: XXXX
 > +GCAP: +CGSM,+DS,+ES
 >
 > My problem now is how to know if I should send AT+CGDATA="PPP",1 or
 > ATD*99***1# when activating context in at modem driver. I see in this
 > driver and others that a VENDOR information can be sent from plugin but
 > I imagine that other Huawei devices support AT+CGDATA="PPP",1.
 >
 > Do you have any idea of what I should do to support this modem without
 > disturbing other devices?

You could build a database of various quirks that are required for each 
model.  The index into the database could be the product id if it is 
unique, or the model / revision information from 'ATI"

Another idea would be to have the gprs context driver try to parse the 
AT+CGDATA=? response.  If 'PPP' L2P is not found, then fallback to using 
ATD*99.

Regards,
-Denis

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

* Re: Huawei E3372
  2017-02-14 15:47 ` Denis Kenzior
@ 2017-02-14 16:37   ` Christophe Ronco
  2017-02-14 16:47     ` Denis Kenzior
  0 siblings, 1 reply; 9+ messages in thread
From: Christophe Ronco @ 2017-02-14 16:37 UTC (permalink / raw)
  To: ofono

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

Hello Denis,
On 02/14/2017 04:47 PM, Denis Kenzior wrote:
> Hi Christophe,
>
>> usb 1-1: New USB device found, idVendor=12d1, idProduct=15b7
> > Using ATI, modem present itself like that:
> >
> > Manufacturer: huawei
> > Model: E3372H
> > Revision: 21.315.01.00.314
> > IMEI: XXXX
> > +GCAP: +CGSM,+DS,+ES
> >
> > My problem now is how to know if I should send AT+CGDATA="PPP",1 or
> > ATD*99***1# when activating context in at modem driver. I see in this
> > driver and others that a VENDOR information can be sent from plugin but
> > I imagine that other Huawei devices support AT+CGDATA="PPP",1.
> >
> > Do you have any idea of what I should do to support this modem without
> > disturbing other devices?
>
> You could build a database of various quirks that are required for 
> each model.  The index into the database could be the product id if it 
> is unique, or the model / revision information from 'ATI"
My problem with this idea is that I only have one huawei modem. I have 
no idea what other huawei modems support activation using 
AT+CGDATA="PPP",1, what are their product ids, .... I could say that all 
models except E3372H use this AT command and be quite safe, except if it 
depends on firmware version.
>
> Another idea would be to have the gprs context driver try to parse the 
> AT+CGDATA=? response.  If 'PPP' L2P is not found, then fallback to 
> using ATD*99.
I can do that in huawei plugin or in gprs-context atmodem driver.

If I do that in huawei plugin, I need a way to give information to 
gprs-context driver. Maybe using ofono_modem_set_boolean with a property 
like ACTIVATE_CONTEXT_USING_ATD99.
If I do that in gprs-context atmodem driver, this is one step more at 
each context activation but no need to modify all plugins if other 
modems have same behavior.
What do you think is the best way?

Best Regards,

Christophe


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

* Re: Huawei E3372
  2017-02-14 16:37   ` Christophe Ronco
@ 2017-02-14 16:47     ` Denis Kenzior
  2017-02-15 16:38       ` [PATCH 0/1] Use ATD*99 to enter data state when needed Christophe Ronco
  0 siblings, 1 reply; 9+ messages in thread
From: Denis Kenzior @ 2017-02-14 16:47 UTC (permalink / raw)
  To: ofono

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

Hi Christophe,

On 02/14/2017 10:37 AM, Christophe Ronco wrote:
> Hello Denis,
> On 02/14/2017 04:47 PM, Denis Kenzior wrote:
>> Hi Christophe,
>>
>>> usb 1-1: New USB device found, idVendor=12d1, idProduct=15b7
>> > Using ATI, modem present itself like that:
>> >
>> > Manufacturer: huawei
>> > Model: E3372H
>> > Revision: 21.315.01.00.314
>> > IMEI: XXXX
>> > +GCAP: +CGSM,+DS,+ES
>> >
>> > My problem now is how to know if I should send AT+CGDATA="PPP",1 or
>> > ATD*99***1# when activating context in at modem driver. I see in this
>> > driver and others that a VENDOR information can be sent from plugin but
>> > I imagine that other Huawei devices support AT+CGDATA="PPP",1.
>> >
>> > Do you have any idea of what I should do to support this modem without
>> > disturbing other devices?
>>
>> You could build a database of various quirks that are required for
>> each model.  The index into the database could be the product id if it
>> is unique, or the model / revision information from 'ATI"
> My problem with this idea is that I only have one huawei modem. I have
> no idea what other huawei modems support activation using
> AT+CGDATA="PPP",1, what are their product ids, .... I could say that all
> models except E3372H use this AT command and be quite safe, except if it
> depends on firmware version.

That's life unfortunately.  There's no sure way of knowing what modem 
will work and what won't until you try it.  We have attempted to keep a 
list of 'known-good' modems in the past, but that is a fairly 
significant time investment.  Such an undertaking can be effective only 
if crowd-sourced.

>>
>> Another idea would be to have the gprs context driver try to parse the
>> AT+CGDATA=? response.  If 'PPP' L2P is not found, then fallback to
>> using ATD*99.
> I can do that in huawei plugin or in gprs-context atmodem driver.
>
> If I do that in huawei plugin, I need a way to give information to
> gprs-context driver. Maybe using ofono_modem_set_boolean with a property
> like ACTIVATE_CONTEXT_USING_ATD99.
> If I do that in gprs-context atmodem driver, this is one step more at
> each context activation but no need to modify all plugins if other
> modems have same behavior.
> What do you think is the best way?
>

It belongs in the gprs-context driver.  Also, you don't need to do it 
once per activation.  Simply probe the CGDATA once (e.g. by launching 
the query during probe() time) and store the results.

Regards,
-Denis

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

* [PATCH 0/1] Use ATD*99 to enter data state when needed
  2017-02-14 16:47     ` Denis Kenzior
@ 2017-02-15 16:38       ` Christophe Ronco
  2017-02-15 16:38         ` [PATCH] atmodem: use ATD99 " Christophe Ronco
  0 siblings, 1 reply; 9+ messages in thread
From: Christophe Ronco @ 2017-02-15 16:38 UTC (permalink / raw)
  To: ofono

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

Here is my patch proposal.
I have a warning using checkpatch.pl:
WARNING: static const char * array should probably be static const char * const
#21: FILE: drivers/atmodem/gprs-context.c:50:
+static const char *cgdata_prefix[] = { "+CGDATA:", NULL };

I have copied what is in src/gprs.c. Let me know if it should be fixed.

Christophe Ronco (1):
  atmodem: use ATD99 to enter data state when needed

 drivers/atmodem/gprs-context.c | 45 +++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 44 insertions(+), 1 deletion(-)

-- 
2.11.0


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

* [PATCH] atmodem: use ATD99 to enter data state when needed
  2017-02-15 16:38       ` [PATCH 0/1] Use ATD*99 to enter data state when needed Christophe Ronco
@ 2017-02-15 16:38         ` Christophe Ronco
  2017-02-15 20:39           ` Denis Kenzior
  0 siblings, 1 reply; 9+ messages in thread
From: Christophe Ronco @ 2017-02-15 16:38 UTC (permalink / raw)
  To: ofono

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

Some modems do not support AT+CGDATA="PPP",X to enter data state.
Use AT+CGDATA=? to detect these modems and for them use ATD*99***X#
to enter data state.
---
 drivers/atmodem/gprs-context.c | 44 +++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 43 insertions(+), 1 deletion(-)

diff --git a/drivers/atmodem/gprs-context.c b/drivers/atmodem/gprs-context.c
index f6e6c2ef..bfe0d4b5 100644
--- a/drivers/atmodem/gprs-context.c
+++ b/drivers/atmodem/gprs-context.c
@@ -47,6 +47,7 @@
 
 #define STATIC_IP_NETMASK "255.255.255.255"
 
+static const char *cgdata_prefix[] = { "+CGDATA:", NULL };
 static const char *none_prefix[] = { NULL };
 
 enum state {
@@ -67,6 +68,7 @@ struct gprs_context_data {
 	ofono_gprs_context_cb_t cb;
 	void *cb_data;                                  /* Callback data */
 	unsigned int vendor;
+	gboolean use_atd99;
 };
 
 static void ppp_debug(const char *str, void *data)
@@ -210,7 +212,7 @@ static void at_cgdcont_cb(gboolean ok, GAtResult *result, gpointer user_data)
 		return;
 	}
 
-	if (gcd->vendor == OFONO_VENDOR_SIMCOM_SIM900)
+	if (gcd->use_atd99)
 		sprintf(buf, "ATD*99***%u#", gcd->active_context);
 	else
 		sprintf(buf, "AT+CGDATA=\"PPP\",%u", gcd->active_context);
@@ -378,6 +380,43 @@ static void cgev_notify(GAtResult *result, gpointer user_data)
 		g_at_ppp_shutdown(gcd->ppp);
 }
 
+static void at_cgdata_test_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 *data_type;
+	gboolean found = FALSE;
+
+	gcd->use_atd99 = TRUE;
+
+	if (!ok) {
+		DBG("not ok");
+		goto error;
+	}
+
+	g_at_result_iter_init(&iter, result);
+	if (!g_at_result_iter_next(&iter, "+CGDATA:")) {
+		DBG("no +CGDATA line");
+		goto error;
+	}
+
+	if (!g_at_result_iter_open_list(&iter)) {
+		DBG("no list found");
+		goto error;
+	}
+
+	while (!found && g_at_result_iter_next_string(&iter, &data_type)) {
+		if (g_str_equal(data_type, "PPP")) {
+			found = TRUE;
+			gcd->use_atd99 = FALSE;
+		}
+	}
+error:
+	DBG("use_atd99:%d", gcd->use_atd99);
+}
+
 static int at_gprs_context_probe(struct ofono_gprs_context *gc,
 					unsigned int vendor, void *data)
 {
@@ -405,6 +444,9 @@ static int at_gprs_context_probe(struct ofono_gprs_context *gc,
 	if (chat == NULL)
 		return 0;
 
+	g_at_chat_send(chat, "AT+CGDATA=?", cgdata_prefix, at_cgdata_test_cb,
+								gc, NULL);
+
 	g_at_chat_register(chat, "+CGEV:", cgev_notify, FALSE, gc, NULL);
 
 	return 0;
-- 
2.11.0


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

* Re: [PATCH] atmodem: use ATD99 to enter data state when needed
  2017-02-15 16:38         ` [PATCH] atmodem: use ATD99 " Christophe Ronco
@ 2017-02-15 20:39           ` Denis Kenzior
  2017-02-16  8:40             ` [PATCH v2] " Christophe Ronco
  0 siblings, 1 reply; 9+ messages in thread
From: Denis Kenzior @ 2017-02-15 20:39 UTC (permalink / raw)
  To: ofono

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

Hi Christophe,

On 02/15/2017 10:38 AM, Christophe Ronco wrote:
> Some modems do not support AT+CGDATA="PPP",X to enter data state.
> Use AT+CGDATA=? to detect these modems and for them use ATD*99***X#
> to enter data state.
> ---
>  drivers/atmodem/gprs-context.c | 44 +++++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 43 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/atmodem/gprs-context.c b/drivers/atmodem/gprs-context.c
> index f6e6c2ef..bfe0d4b5 100644
> --- a/drivers/atmodem/gprs-context.c
> +++ b/drivers/atmodem/gprs-context.c
> @@ -47,6 +47,7 @@
>
>  #define STATIC_IP_NETMASK "255.255.255.255"
>
> +static const char *cgdata_prefix[] = { "+CGDATA:", NULL };
>  static const char *none_prefix[] = { NULL };
>
>  enum state {
> @@ -67,6 +68,7 @@ struct gprs_context_data {
>  	ofono_gprs_context_cb_t cb;
>  	void *cb_data;                                  /* Callback data */
>  	unsigned int vendor;
> +	gboolean use_atd99;
>  };
>
>  static void ppp_debug(const char *str, void *data)
> @@ -210,7 +212,7 @@ static void at_cgdcont_cb(gboolean ok, GAtResult *result, gpointer user_data)
>  		return;
>  	}
>
> -	if (gcd->vendor == OFONO_VENDOR_SIMCOM_SIM900)
> +	if (gcd->use_atd99)
>  		sprintf(buf, "ATD*99***%u#", gcd->active_context);
>  	else
>  		sprintf(buf, "AT+CGDATA=\"PPP\",%u", gcd->active_context);
> @@ -378,6 +380,43 @@ static void cgev_notify(GAtResult *result, gpointer user_data)
>  		g_at_ppp_shutdown(gcd->ppp);
>  }
>
> +static void at_cgdata_test_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 *data_type;
> +	gboolean found = FALSE;
> +
> +	gcd->use_atd99 = TRUE;
> +
> +	if (!ok) {
> +		DBG("not ok");
> +		goto error;
> +	}
> +
> +	g_at_result_iter_init(&iter, result);
> +	if (!g_at_result_iter_next(&iter, "+CGDATA:")) {
> +		DBG("no +CGDATA line");
> +		goto error;
> +	}
> +
> +	if (!g_at_result_iter_open_list(&iter)) {
> +		DBG("no list found");
> +		goto error;
> +	}
> +
> +	while (!found && g_at_result_iter_next_string(&iter, &data_type)) {
> +		if (g_str_equal(data_type, "PPP")) {
> +			found = TRUE;
> +			gcd->use_atd99 = FALSE;
> +		}
> +	}
> +error:
> +	DBG("use_atd99:%d", gcd->use_atd99);
> +}
> +
>  static int at_gprs_context_probe(struct ofono_gprs_context *gc,
>  					unsigned int vendor, void *data)
>  {
> @@ -405,6 +444,9 @@ static int at_gprs_context_probe(struct ofono_gprs_context *gc,
>  	if (chat == NULL)
>  		return 0;
>
> +	g_at_chat_send(chat, "AT+CGDATA=?", cgdata_prefix, at_cgdata_test_cb,
> +								gc, NULL);
> +

Looks fine to me.  My only comment would be to skip the CGDATA query if 
the vendor quirk explicitly tells us to use ATD*99.  So e.g.

switch (vendor) {
case OFONO_VENDOR_SIMCOM_SIM900:
	use_atd99 = FALSE;
	break;
default:
	g_at_chat_send(chat, "AT+CGDATA=?", ...);
}

>  	g_at_chat_register(chat, "+CGEV:", cgev_notify, FALSE, gc, NULL);
>
>  	return 0;
>

Regards,
-Denis

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

* [PATCH v2] atmodem: use ATD99 to enter data state when needed
  2017-02-15 20:39           ` Denis Kenzior
@ 2017-02-16  8:40             ` Christophe Ronco
  2017-02-16 17:53               ` Denis Kenzior
  0 siblings, 1 reply; 9+ messages in thread
From: Christophe Ronco @ 2017-02-16  8:40 UTC (permalink / raw)
  To: ofono

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

Some modems do not support AT+CGDATA="PPP",X to enter data state.
Use AT+CGDATA=? to detect these modems and for them use ATD*99***X#
to enter data state.
---
 drivers/atmodem/gprs-context.c | 50 +++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 49 insertions(+), 1 deletion(-)

diff --git a/drivers/atmodem/gprs-context.c b/drivers/atmodem/gprs-context.c
index f6e6c2ef..9b9679e8 100644
--- a/drivers/atmodem/gprs-context.c
+++ b/drivers/atmodem/gprs-context.c
@@ -47,6 +47,7 @@
 
 #define STATIC_IP_NETMASK "255.255.255.255"
 
+static const char *cgdata_prefix[] = { "+CGDATA:", NULL };
 static const char *none_prefix[] = { NULL };
 
 enum state {
@@ -67,6 +68,7 @@ struct gprs_context_data {
 	ofono_gprs_context_cb_t cb;
 	void *cb_data;                                  /* Callback data */
 	unsigned int vendor;
+	gboolean use_atd99;
 };
 
 static void ppp_debug(const char *str, void *data)
@@ -210,7 +212,7 @@ static void at_cgdcont_cb(gboolean ok, GAtResult *result, gpointer user_data)
 		return;
 	}
 
-	if (gcd->vendor == OFONO_VENDOR_SIMCOM_SIM900)
+	if (gcd->use_atd99)
 		sprintf(buf, "ATD*99***%u#", gcd->active_context);
 	else
 		sprintf(buf, "AT+CGDATA=\"PPP\",%u", gcd->active_context);
@@ -378,6 +380,43 @@ static void cgev_notify(GAtResult *result, gpointer user_data)
 		g_at_ppp_shutdown(gcd->ppp);
 }
 
+static void at_cgdata_test_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 *data_type;
+	gboolean found = FALSE;
+
+	gcd->use_atd99 = TRUE;
+
+	if (!ok) {
+		DBG("not ok");
+		goto error;
+	}
+
+	g_at_result_iter_init(&iter, result);
+	if (!g_at_result_iter_next(&iter, "+CGDATA:")) {
+		DBG("no +CGDATA line");
+		goto error;
+	}
+
+	if (!g_at_result_iter_open_list(&iter)) {
+		DBG("no list found");
+		goto error;
+	}
+
+	while (!found && g_at_result_iter_next_string(&iter, &data_type)) {
+		if (g_str_equal(data_type, "PPP")) {
+			found = TRUE;
+			gcd->use_atd99 = FALSE;
+		}
+	}
+error:
+	DBG("use_atd99:%d", gcd->use_atd99);
+}
+
 static int at_gprs_context_probe(struct ofono_gprs_context *gc,
 					unsigned int vendor, void *data)
 {
@@ -405,6 +444,15 @@ static int at_gprs_context_probe(struct ofono_gprs_context *gc,
 	if (chat == NULL)
 		return 0;
 
+	switch (vendor) {
+	case OFONO_VENDOR_SIMCOM_SIM900:
+		gcd->use_atd99 = FALSE;
+		break;
+	default:
+		g_at_chat_send(chat, "AT+CGDATA=?", cgdata_prefix,
+						at_cgdata_test_cb, gc, NULL);
+	}
+
 	g_at_chat_register(chat, "+CGEV:", cgev_notify, FALSE, gc, NULL);
 
 	return 0;
-- 
2.11.0


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

* Re: [PATCH v2] atmodem: use ATD99 to enter data state when needed
  2017-02-16  8:40             ` [PATCH v2] " Christophe Ronco
@ 2017-02-16 17:53               ` Denis Kenzior
  0 siblings, 0 replies; 9+ messages in thread
From: Denis Kenzior @ 2017-02-16 17:53 UTC (permalink / raw)
  To: ofono

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

Hi Christophe,

On 02/16/2017 02:40 AM, Christophe Ronco wrote:
> Some modems do not support AT+CGDATA="PPP",X to enter data state.
> Use AT+CGDATA=? to detect these modems and for them use ATD*99***X#
> to enter data state.
> ---
>  drivers/atmodem/gprs-context.c | 50 +++++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 49 insertions(+), 1 deletion(-)
>

Applied, thanks.

Regards,
-Denis


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

end of thread, other threads:[~2017-02-16 17:53 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-14  9:53 Huawei E3372 Christophe Ronco
2017-02-14 15:47 ` Denis Kenzior
2017-02-14 16:37   ` Christophe Ronco
2017-02-14 16:47     ` Denis Kenzior
2017-02-15 16:38       ` [PATCH 0/1] Use ATD*99 to enter data state when needed Christophe Ronco
2017-02-15 16:38         ` [PATCH] atmodem: use ATD99 " Christophe Ronco
2017-02-15 20:39           ` Denis Kenzior
2017-02-16  8:40             ` [PATCH v2] " Christophe Ronco
2017-02-16 17:53               ` Denis Kenzior

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.