Re: [PATCH] mm-modem-mbm.c: add *E2NAP regexp to catch messages with error codes

2010-05-17 Thread Dan Williams
On Mon, 2010-05-17 at 10:54 +0200, Torgny Johansson wrote:
> Hi!
> 
> The following patch adds a new regular expression to be able to catch e2nap 
> unsolicited messages containg an error code e.g. *E2NAP: 0,36. 
> Without it, you could get weird responses for "get_imsi" etc where the E2NAP 
> unsolicited message would be included in the response.

Pushed, thanks!

Dan


> Regards
> Torgny Johansson
> 
> diff --git a/plugins/mm-modem-mbm.c b/plugins/mm-modem-mbm.c
> index ea7d876..feb3832 100644
> --- a/plugins/mm-modem-mbm.c
> +++ b/plugins/mm-modem-mbm.c
> @@ -847,6 +847,10 @@ grab_port (MMModem *modem,
>  regex = g_regex_new ("\\r\\n\\*E2NAP: (\\d)\\r\\n", G_REGEX_RAW 
> | G_REGEX_OPTIMIZE, 0, NULL);
>  mm_at_serial_port_add_unsolicited_msg_handler (MM_AT_SERIAL_PORT 
> (port), regex, mbm_e2nap_received, modem, NULL);
>  g_regex_unref (regex);
> +
> +regex = g_regex_new ("\\r\\n\\*E2NAP: (\\d),.*\\r\\n", 
> G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL);
> +mm_at_serial_port_add_unsolicited_msg_handler (MM_AT_SERIAL_PORT 
> (port), regex, mbm_e2nap_received, modem, NULL);
> +g_regex_unref (regex);
>  }
>  
>  regex = g_regex_new ("\\r\\n\\*EMRDY: \\d\\r\\n", G_REGEX_RAW | 
> G_REGEX_OPTIMIZE, 0, NULL);
> ___
> networkmanager-list mailing list
> networkmanager-list@gnome.org
> http://mail.gnome.org/mailman/listinfo/networkmanager-list


___
networkmanager-list mailing list
networkmanager-list@gnome.org
http://mail.gnome.org/mailman/listinfo/networkmanager-list


[PATCH] mm-modem-mbm.c: add *E2NAP regexp to catch messages with error codes

2010-05-17 Thread Torgny Johansson
Hi!

The following patch adds a new regular expression to be able to catch e2nap 
unsolicited messages containg an error code e.g. *E2NAP: 0,36. 
Without it, you could get weird responses for "get_imsi" etc where the E2NAP 
unsolicited message would be included in the response.

Regards
Torgny Johansson

diff --git a/plugins/mm-modem-mbm.c b/plugins/mm-modem-mbm.c
index ea7d876..feb3832 100644
--- a/plugins/mm-modem-mbm.c
+++ b/plugins/mm-modem-mbm.c
@@ -847,6 +847,10 @@ grab_port (MMModem *modem,
 regex = g_regex_new ("\\r\\n\\*E2NAP: (\\d)\\r\\n", G_REGEX_RAW | 
G_REGEX_OPTIMIZE, 0, NULL);
 mm_at_serial_port_add_unsolicited_msg_handler (MM_AT_SERIAL_PORT 
(port), regex, mbm_e2nap_received, modem, NULL);
 g_regex_unref (regex);
+
+regex = g_regex_new ("\\r\\n\\*E2NAP: (\\d),.*\\r\\n", G_REGEX_RAW 
| G_REGEX_OPTIMIZE, 0, NULL);
+mm_at_serial_port_add_unsolicited_msg_handler (MM_AT_SERIAL_PORT 
(port), regex, mbm_e2nap_received, modem, NULL);
+g_regex_unref (regex);
 }
 
 regex = g_regex_new ("\\r\\n\\*EMRDY: \\d\\r\\n", G_REGEX_RAW | 
G_REGEX_OPTIMIZE, 0, NULL);
___
networkmanager-list mailing list
networkmanager-list@gnome.org
http://mail.gnome.org/mailman/listinfo/networkmanager-list


RE: [PATCH] mm-modem-mbm.c: Abort connect attempt on e2nap: 0

2010-03-15 Thread Torgny Johansson
 

> -Original Message-
> From: Dan Williams [mailto:d...@redhat.com] 
> Sent: den 12 mars 2010 00:32
> To: Torgny Johansson
> Cc: networkmanager-list@gnome.org
> Subject: RE: [PATCH] mm-modem-mbm.c: Abort connect attempt on e2nap: 0
> 
> On Thu, 2010-03-11 at 13:39 +0100, Torgny Johansson wrote:
> > > 
> > > Hi!
> > > 
> > > The attached patch slightly modifies the handling of e2nap 
> > > unsolicited messages. If e2nap: 0 is received while 
> connecting the 
> > > connect attempt is now aborted since it will not be successful. 
> > > Without this patch MM will poll enap for an additional 
> ~50 seconds 
> > > before giving up.
> > > 
> > > The patch also moves the at*e2nap=1 call before the 
> at*enap=1 call 
> > > to make sure that no unsolicited message can be missed.
> > > 
> > 
> > Hi!
> > 
> > I did not get any response on the above patch so this is 
> just a bump...
> 
> Sorry, I landed it a few days back but hadn't sent mail yet.

Ah, guess I could've checked the commit log too... Thanks!

Regards
Torgny
___
NetworkManager-list mailing list
NetworkManager-list@gnome.org
http://mail.gnome.org/mailman/listinfo/networkmanager-list


RE: [PATCH] mm-modem-mbm.c: Abort connect attempt on e2nap: 0

2010-03-11 Thread Dan Williams
On Thu, 2010-03-11 at 13:39 +0100, Torgny Johansson wrote:
> > 
> > Hi!
> > 
> > The attached patch slightly modifies the handling of e2nap 
> > unsolicited messages. If e2nap: 0 is received while 
> > connecting the connect attempt is now aborted since it will 
> > not be successful. Without this patch MM will poll enap for 
> > an additional ~50 seconds before giving up.
> > 
> > The patch also moves the at*e2nap=1 call before the at*enap=1 
> > call to make sure that no unsolicited message can be missed.
> > 
> 
> Hi!
> 
> I did not get any response on the above patch so this is just a bump...

Sorry, I landed it a few days back but hadn't sent mail yet.

Dan


___
NetworkManager-list mailing list
NetworkManager-list@gnome.org
http://mail.gnome.org/mailman/listinfo/networkmanager-list


RE: [PATCH] mm-modem-mbm.c: Abort connect attempt on e2nap: 0

2010-03-11 Thread Torgny Johansson

> 
> Hi!
> 
> The attached patch slightly modifies the handling of e2nap 
> unsolicited messages. If e2nap: 0 is received while 
> connecting the connect attempt is now aborted since it will 
> not be successful. Without this patch MM will poll enap for 
> an additional ~50 seconds before giving up.
> 
> The patch also moves the at*e2nap=1 call before the at*enap=1 
> call to make sure that no unsolicited message can be missed.
> 

Hi!

I did not get any response on the above patch so this is just a bump...

Any thoughts?

Regards
Torgny Johansson


mbm-disconnect-on-e2nap0.patch
Description: mbm-disconnect-on-e2nap0.patch
___
NetworkManager-list mailing list
NetworkManager-list@gnome.org
http://mail.gnome.org/mailman/listinfo/networkmanager-list


[PATCH] mm-modem-mbm.c: Abort connect attempt on e2nap: 0

2010-03-02 Thread Torgny Johansson
Hi!

The attached patch slightly modifies the handling of e2nap unsolicited
messages. If e2nap: 0 is received while connecting the connect attempt
is now aborted since it will not be successful. Without this patch MM
will poll enap for an additional ~50 seconds before giving up.

The patch also moves the at*e2nap=1 call before the at*enap=1 call to
make sure that no unsolicited message can be missed.

Regards
Torgny Johansson
diff --git a/plugins/mm-modem-mbm.c b/plugins/mm-modem-mbm.c
index 4e08c68..c29e7c1 100644
--- a/plugins/mm-modem-mbm.c
+++ b/plugins/mm-modem-mbm.c
@@ -521,12 +521,20 @@ mbm_ciev_received (MMSerialPort *port,
 }
 
 static void
-mbm_do_connect_done (MMModemMbm *self)
+mbm_do_connect_done (MMModemMbm *self, gboolean success)
 {
 MMModemMbmPrivate *priv = MM_MODEM_MBM_GET_PRIVATE (self);
 
 if (priv->pending_connect_info) {
-mm_generic_gsm_connect_complete (MM_GENERIC_GSM (self), NULL, priv->pending_connect_info);
+if (success)
+mm_generic_gsm_connect_complete (MM_GENERIC_GSM (self), NULL, priv->pending_connect_info);
+else {
+GError *connect_error;
+
+connect_error = mm_modem_connect_error_for_code (MM_MODEM_CONNECT_ERROR_BUSY);
+mm_generic_gsm_connect_complete (MM_GENERIC_GSM (self), connect_error, priv->pending_connect_info);
+g_error_free (connect_error);
+}   
 priv->pending_connect_info = NULL;
 }
 }
@@ -543,11 +551,12 @@ mbm_e2nap_received (MMSerialPort *port,
 if (str)
 state = atoi (str);
 
-if (MBM_E2NAP_DISCONNECTED == state)
+if (MBM_E2NAP_DISCONNECTED == state) {
 g_debug ("%s, disconnected", __func__);
-else if (MBM_E2NAP_CONNECTED == state) {
+mbm_do_connect_done (MM_MODEM_MBM (user_data), FALSE);
+} else if (MBM_E2NAP_CONNECTED == state) {
 g_debug ("%s, connected", __func__);
-mbm_do_connect_done (MM_MODEM_MBM (user_data));
+mbm_do_connect_done (MM_MODEM_MBM (user_data), TRUE);
 } else if (MBM_E2NAP_CONNECTING == state)
 g_debug("%s, connecting", __func__);
 else {
@@ -619,7 +628,6 @@ enap_done (MMSerialPort *port,
 tid = g_timeout_add_seconds (1, enap_poll, user_data);
 /* remember poll id as callback info object, with source_remove as free func */
 mm_callback_info_set_data (info, "mbm-enap-poll-id", GUINT_TO_POINTER (tid), (GFreeFunc) g_source_remove);
-mm_serial_port_queue_command (port, "AT*E2NAP=1", 3, NULL, NULL);
 }
 
 static void
@@ -639,6 +647,9 @@ mbm_auth_done (MMSerialPort *port,
 }
 
 cid = mm_generic_gsm_get_cid (modem);
+
+mm_serial_port_queue_command (port, "AT*E2NAP=1", 3, NULL, NULL);
+
 command = g_strdup_printf ("AT*ENAP=1,%d", cid);
 mm_serial_port_queue_command (port, command, 3, enap_done, user_data);
 g_free (command);
___
NetworkManager-list mailing list
NetworkManager-list@gnome.org
http://mail.gnome.org/mailman/listinfo/networkmanager-list


Re: [PATCH] mm-modem-mbm.c

2008-10-28 Thread Tambet Ingo
On Mon, Oct 27, 2008 at 7:25 PM, bjornrun <[EMAIL PROTECTED]> wrote:
> Hope this makes the patch more useful!

Thanks! I committed your patch with some minor changes (use spaces
instead of tabs everywhere, remove some debug output).

Why does the MBM modem not query signal quality while connected? The
generic modem code does that because it has ppp connection on the
serial port while connected and thus can't issue any AT commands.

Tambet
___
NetworkManager-list mailing list
NetworkManager-list@gnome.org
http://mail.gnome.org/mailman/listinfo/networkmanager-list


Re: [PATCH] mm-modem-mbm.c

2008-10-27 Thread bjornrun
GsmNetwork *modem,
> +MMModemUIntFn callback,
> +gpointer user_data)
> +{
> +MMCallbackInfo *info;
> +
> + g_debug("mbm get_signal_quality");
> +if (mm_serial_is_connected (MM_SERIAL (modem))) {
> +g_message ("Returning saved signal quality %d",
> MM_MODEM_MBM_GET_PRIVATE (modem)->signal_quality);
> +callback (MM_MODEM (modem), MM_MODEM_MBM_GET_PRIVATE
> (modem)->signal_quality, NULL, user_data);
> +return;
> +}
> +
> +info = mm_callback_info_uint_new (MM_MODEM (modem), callback,
> user_data);
> +mm_serial_queue_command (MM_SERIAL (modem), "+CIND?", 3,
> get_signal_quality_done, info);
> +}
> +
> 
> /*/
>  
>  static void
> @@ -260,6 +375,8 @@
>  {
>  class->do_register = do_register;
>  class->set_apn = set_apn;
> +class->get_network_mode = get_network_mode;
> +class->get_signal_quality = get_signal_quality;
>  }
>  
> 
> --- ../foss/modemmanager/mainline/plugins/mm-modem-mbm.h      2008-10-27
> 04:57:58.0 -0700
> +++ ../src/modemmanager/plugins/mm-modem-mbm.h2008-10-27
> 07:26:48.0 -0700
> @@ -4,8 +4,9 @@
>for supporting Ericsson modules like F3507g.
>  
>Author: Per Hallsmark <[EMAIL PROTECTED]>
> +  Bjorn Runaker <[EMAIL PROTECTED]>
>  
>This program is free software; you can redistribute it and/or modify
>it under the terms of the GNU General Public License as published by
> 
> 
> 

Hi Dan!

Hope this makes the patch more useful!

Regards,
Bjorn


http://www.nabble.com/file/p20192267/mm-modem-mbm.c.patch
mm-modem-mbm.c.patch 
http://www.nabble.com/file/p20192267/mm-modem-mbm.h.patch
mm-modem-mbm.h.patch 

-- 
View this message in context: 
http://www.nabble.com/-PATCH--mm-modem-mbm.c-tp20189529p20192267.html
Sent from the Gnome - NetworkManager mailing list archive at Nabble.com.

___
NetworkManager-list mailing list
NetworkManager-list@gnome.org
http://mail.gnome.org/mailman/listinfo/networkmanager-list


Re: [PATCH] mm-modem-mbm.c

2008-10-27 Thread Dan Williams
On Mon, 2008-10-27 at 08:07 -0700, bjornrun wrote:
> Hello NetworkManager people!
> 
> This patch relates to the Modem-Manager and the addition of MBM broadband
> modem. The diff is taken today from
> git://gitorious.org/modemmanager/mainline.git
> 
> This will add support of showing network mode and signal quality using
> +CIND?
> 
> Related nm-applet patch will come shortly

Hmm, your patch is line-wrapped, could you repost and make sure you use
the "preformat" setting or something?  Or, you can add the patch as an
attachment if you like.

Thanks!
Dan


> Regards,
> Bjorn
> 
> ---
> 
> --- ../foss/modemmanager/mainline/plugins/mm-modem-mbm.c  2008-10-27
> 04:57:58.0 -0700
> +++ ../src/modemmanager/plugins/mm-modem-mbm.c2008-10-27 
> 07:22:24.0
> -0700
> @@ -4,6 +4,7 @@
>for supporting Ericsson modules like F3507g.
>  
>Author: Per Hallsmark <[EMAIL PROTECTED]>
> +  Bjorn Runaker <[EMAIL PROTECTED]>
>  
>This program is free software; you can redistribute it and/or modify
>it under the terms of the GNU General Public License as published by
> @@ -42,6 +43,7 @@
>  
>  typedef struct {
>  char *network_device;
> +guint32 signal_quality;
>  } MMModemMbmPrivate;
>  
>  enum {
> @@ -242,6 +244,119 @@
>  
>  }
>  
> +static gboolean
> +parse_erinfo (const char *reply, int *mode, int *gsm_rinfo, int
> *umts_rinfo)
> +{
> +if (reply == NULL || strncmp (reply, "*ERINFO:", 8))
> +return FALSE;
> +
> +if (sscanf (reply + 8, "%d,%d,%d", mode, gsm_rinfo, umts_rinfo))
> +return TRUE;
> +
> +return FALSE;
> +}
> +
> +static void
> +get_network_mode_done (MMSerial *serial,
> +   GString *response,
> +   GError *error,
> +   gpointer user_data)
> +{
> +MMCallbackInfo *info = (MMCallbackInfo *) user_data;
> +
> +g_debug("get_network_mode_done");
> +if (error)
> +info->error = g_error_copy (error);
> +else {
> +int mode;
> +int gsm_rinfo;
> +int umts_rinfo;
> +guint32 result = 0;
> +
> +if (parse_erinfo (response->str, &mode, &gsm_rinfo, &umts_rinfo)) {
> + if (umts_rinfo == 2)
> + result = MM_MODEM_GSM_NETWORK_MODE_HSDPA;
> + else if (umts_rinfo && !gsm_rinfo)
> + result = MM_MODEM_GSM_NETWORK_MODE_3G;
> +else if (umts_rinfo && gsm_rinfo)
> +result = MM_MODEM_GSM_NETWORK_MODE_PREFER_3G;
> +else if (gsm_rinfo)
> +result = MM_MODEM_GSM_NETWORK_MODE_GPRS;
> +}
> +
> +if (result == 0)
> +info->error = g_error_new (MM_MODEM_ERROR,
> MM_MODEM_ERROR_GENERAL,
> +   "%s", "Could not parse network mode
> results");
> +else
> +mm_callback_info_set_result (info, GUINT_TO_POINTER (result),
> NULL);
> +}
> +
> +mm_callback_info_schedule (info);
> +}
> +
> +static void
> +get_network_mode (MMModemGsmNetwork *modem,
> +  MMModemUIntFn callback,
> +  gpointer user_data)
> +{
> +MMCallbackInfo *info;
> +g_debug("get_network_mode");
> +info = mm_callback_info_uint_new (MM_MODEM (modem), callback,
> user_data);
> +mm_serial_queue_command (MM_SERIAL (modem), "AT*ERINFO?", 3,
> get_network_mode_done, info);
> +}
> +
> +/* GetSignalQuality */
> +
> +static void
> +get_signal_quality_done (MMSerial *serial,
> + GString *response,
> + GError *error,
> + gpointer user_data)
> +{
> +MMCallbackInfo *info = (MMCallbackInfo *) user_data;
> +char *reply = response->str;
> +
> +if (error)
> +info->error = g_error_copy (error);
> +else if (!strncmp (reply, "+CIND: ", 7)) {
> +/* Got valid reply */
> +int battch;
> +int signal;
> +
> +reply += 7;
> +
> +if (sscanf (reply, "%d,%d", &battch, &signal)) {
> +   /* Normalize the quality */
> +signal = signal * 100 / 5;
> +
> +MM_MODEM_MBM_GET_PRIVATE (serial)->signal_quality = signal;
> +mm_callback_info_set_result (info, GUINT_TO_POINTER (signal),
> NULL);
> +} else
> +info->error = g_error_new_literal (MM_MODEM_ERROR,
> MM_MODEM_ERROR_GENERAL,
> +   "Could not parse signal
> quality results");
> +}
> +
> +mm_callback_info_schedule (info);
> +}
> +
> +static void
> +get_signal_quality (MMModemGsmNetwork *modem,
> +MMModemUIntFn callback,
> +gpointer user_data)
> +{
> +MMCallbackInfo *info;
> +
> + g_debug("mbm get_signal_quality");
> +if (mm_serial_is_connected (MM_SERIAL (modem))) {
> +g_message ("Returning saved signal quality %d",
> MM_MODEM_MBM_GET_PRIVATE (modem)->signal_quality);
> +callback (MM_MODEM (modem), MM_MODEM_MBM_

[PATCH] mm-modem-mbm.c

2008-10-27 Thread bjornrun
/
 
 static void
@@ -260,6 +375,8 @@
 {
 class->do_register = do_register;
 class->set_apn = set_apn;
+class->get_network_mode = get_network_mode;
+class->get_signal_quality = get_signal_quality;
 }
 

--- ../foss/modemmanager/mainline/plugins/mm-modem-mbm.h2008-10-27
04:57:58.0 -0700
+++ ../src/modemmanager/plugins/mm-modem-mbm.h  2008-10-27 07:26:48.0
-0700
@@ -4,8 +4,9 @@
   for supporting Ericsson modules like F3507g.
 
   Author: Per Hallsmark <[EMAIL PROTECTED]>
+  Bjorn Runaker <[EMAIL PROTECTED]>
 
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by


-- 
View this message in context: 
http://www.nabble.com/-PATCH--mm-modem-mbm.c-tp20189529p20189529.html
Sent from the Gnome - NetworkManager mailing list archive at Nabble.com.

___
NetworkManager-list mailing list
NetworkManager-list@gnome.org
http://mail.gnome.org/mailman/listinfo/networkmanager-list