Wrong SIM-Pin not detected by MM?

2011-11-13 Thread Thomas Bechtold
Hi,

i tried NM 0.9 (latest from git) with MM 0.5 (from ubuntu 11.10) and
recognized that MM does not detect a wrong SIM-Pin (with a Nokia N900).
i used a wrong Pin (1234) and got the attached NM logs when i tried to
activate the connection with nmcli con up id simyo.

NM output this: GSM PIN unlock failed: (32) Unknown error. I think to
get a correct error mm_serial_parser_v1_parse () should handle the
serial response for 'AT+CPIN=1234CR' correct. But currently i get:

# MM log 
[mm-at-serial-port.c:298] debug_log(): (ttyACM0): -- 'AT
+CPIN=1234CR'
[mm-at-serial-port.c:298] debug_log(): (ttyACM0): --
'CRLFERRORCRLF'
[mm-serial-parsers.c:412] mm_serial_parser_v1_parse(): Got failure code
100: Unknown error


Are there any reasons why this response is not handled as an known
error? eg as MM_MOBILE_ERROR_WRONG_SIM_PIN.

Cheers,

Tom



# NM log 
NetworkManager[32314]: info Activation (ttyACM0) starting connection
'simyo'
NetworkManager[32314]: info (ttyACM0): device state change:
disconnected - prepare (reason 'none') [30 40 0]
NetworkManager[32314]: info Activation (ttyACM0) Stage 1 of 5 (Device
Prepare) scheduled...
NetworkManager[32314]: info Activation (ttyACM0) Stage 1 of 5 (Device
Prepare) started...
NetworkManager[32314]: info (ttyACM0): device state change: prepare -
need-auth (reason 'none') [40 60 0]
NetworkManager[32314]: info Activation (ttyACM0) Stage 1 of 5 (Device
Prepare) complete.
NetworkManager[32314]: info Activation (ttyACM0) Stage 1 of 5 (Device
Prepare) scheduled...
NetworkManager[32314]: info Activation (ttyACM0) Stage 1 of 5 (Device
Prepare) started...
NetworkManager[32314]: info (ttyACM0): device state change: need-auth
- prepare (reason 'none') [60 40 0]
NetworkManager[32314]: info Activation (ttyACM0) Stage 1 of 5 (Device
Prepare) complete.
NetworkManager[32314]: warn GSM modem enable failed: (32) SIM PIN
required
NetworkManager[32314]: warn GSM PIN unlock failed: (32) Unknown error
NetworkManager[32314]: warn unmapped dbus error detected:
'org.freedesktop.ModemManager.Modem.Gsm.Unknown'
NetworkManager[32314]: info (ttyACM0): device state change: prepare -
failed (reason 'modem-init-failed') [40 120 28]
NetworkManager[32314]: warn Activation (ttyACM0) failed.
NetworkManager[32314]: info (ttyACM0): device state change: failed -
disconnected (reason 'none') [120 30 0]


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


[PATCH] modem: map modemmanager errors more detailed

2011-11-13 Thread Thomas Bechtold
Hi,

attached is a patch to handle some ModemManager errors more detailed.
But i still have some questions about the code and i'm not sure if this
patch is the correct way to solve the problem that NM does not know the
exact reason why a modem connection fails.
Here are my questions:

- should NM have a NMDeviceStateReason for every MM error 
  or should some MM errors be combined to one NMDeviceStateReason?
- in NM/include/NetworkManager.h are some NMDeviceStateReason defined 
  which are never used. eg NM_DEVICE_STATE_REASON_MODEM_NO_DIAL_TONE, 
  NM_DEVICE_STATE_REASON_MODEM_NO_CARRIER, 
  NM_DEVICE_STATE_REASON_MODEM_DIAL_FAILED, 
  NM_DEVICE_STATE_REASON_GSM_APN_FAILED, 
  NM_DEVICE_STATE_REASON_GSM_PIN_CHECK_FAILED
  maybe there are some more unused NMDeviceStateReason. 
  Why are these reason available?


Cheers,

Tom




* add 4 new NMDeviceStateReason to map ModemManager errors more detailed
* fix wrong error mapping for MM_MODEM_CONNECT_ERROR_NO_DIALTONE
---
 include/NetworkManager.h |   12 +++
 src/modem-manager/nm-modem-gsm.c |   65 -
 src/nm-device.c  |8 +
 3 files changed, 69 insertions(+), 16 deletions(-)

diff --git a/include/NetworkManager.h b/include/NetworkManager.h
index 4755f30..eb72564 100644
--- a/include/NetworkManager.h
+++ b/include/NetworkManager.h
@@ -463,6 +463,18 @@ typedef enum {
/* The Bluetooth connection failed or timed out */
NM_DEVICE_STATE_REASON_BT_FAILED = 44,
 
+   /* GSM Modem's SIM Card not inserted */
+   NM_DEVICE_STATE_REASON_GSM_SIM_NOT_INSERTED = 45,
+
+   /* GSM Modem's SIM Pin required */
+   NM_DEVICE_STATE_REASON_GSM_SIM_PIN_REQUIRED = 46,
+
+   /* GSM Modem's SIM Puk required */
+   NM_DEVICE_STATE_REASON_GSM_SIM_PUK_REQUIRED = 47,
+
+   /* GSM Modem's SIM wrong */
+   NM_DEVICE_STATE_REASON_GSM_SIM_WRONG = 48,
+
/* Unused */
NM_DEVICE_STATE_REASON_LAST = 0x
 } NMDeviceStateReason;
diff --git a/src/modem-manager/nm-modem-gsm.c b/src/modem-manager/nm-modem-gsm.c
index 9a96ae9..777b2e2 100644
--- a/src/modem-manager/nm-modem-gsm.c
+++ b/src/modem-manager/nm-modem-gsm.c
@@ -140,20 +140,34 @@ translate_mm_error (GError *error)
 
if (dbus_g_error_has_name (error, MM_MODEM_CONNECT_ERROR_NO_CARRIER))
reason = NM_DEVICE_STATE_REASON_MODEM_NO_CARRIER;
-   if (dbus_g_error_has_name (error, MM_MODEM_CONNECT_ERROR_NO_DIALTONE))
-   reason = NM_DEVICE_STATE_REASON_MODEM_DIAL_TIMEOUT;
-   if (dbus_g_error_has_name (error, MM_MODEM_CONNECT_ERROR_BUSY))
+   else if (dbus_g_error_has_name (error, 
MM_MODEM_CONNECT_ERROR_NO_DIALTONE))
+   reason = NM_DEVICE_STATE_REASON_MODEM_NO_DIAL_TONE;
+   else if (dbus_g_error_has_name (error, MM_MODEM_CONNECT_ERROR_BUSY))
reason = NM_DEVICE_STATE_REASON_MODEM_BUSY;
-   if (dbus_g_error_has_name (error, MM_MODEM_CONNECT_ERROR_NO_ANSWER))
+   else if (dbus_g_error_has_name (error, 
MM_MODEM_CONNECT_ERROR_NO_ANSWER))
reason = NM_DEVICE_STATE_REASON_MODEM_DIAL_TIMEOUT;
-   if (dbus_g_error_has_name (error, MM_MODEM_ERROR_NETWORK_NOT_ALLOWED))
+   else if (dbus_g_error_has_name (error, 
MM_MODEM_ERROR_NETWORK_NOT_ALLOWED))
reason = NM_DEVICE_STATE_REASON_GSM_REGISTRATION_DENIED;
-   if (dbus_g_error_has_name (error, MM_MODEM_ERROR_NETWORK_TIMEOUT))
+   else if (dbus_g_error_has_name (error, MM_MODEM_ERROR_NETWORK_TIMEOUT))
reason = NM_DEVICE_STATE_REASON_GSM_REGISTRATION_TIMEOUT;
-   if (dbus_g_error_has_name (error, MM_MODEM_ERROR_NO_NETWORK))
+   else if (dbus_g_error_has_name (error, MM_MODEM_ERROR_NO_NETWORK))
reason = NM_DEVICE_STATE_REASON_GSM_REGISTRATION_NOT_SEARCHING;
+   else if (dbus_g_error_has_name (error, MM_MODEM_ERROR_SIM_NOT_INSERTED))
+   reason = NM_DEVICE_STATE_REASON_GSM_SIM_NOT_INSERTED;
+   else if (dbus_g_error_has_name (error, MM_MODEM_ERROR_SIM_PIN))
+   reason = NM_DEVICE_STATE_REASON_GSM_SIM_PIN_REQUIRED;
+   else if (dbus_g_error_has_name (error, MM_MODEM_ERROR_SIM_PUK))
+   reason = NM_DEVICE_STATE_REASON_GSM_SIM_PUK_REQUIRED;
+   else if (dbus_g_error_has_name (error, MM_MODEM_ERROR_SIM_WRONG))
+   reason = NM_DEVICE_STATE_REASON_GSM_SIM_WRONG;
+   else
+   {
+   /* unable to map the ModemManager error to a 
NM_DEVICE_STATE_REASON */
+   nm_log_dbg (LOGD_MB, unmapped dbus error detected: '%s', 
dbus_g_error_get_name (error));
+   reason = NM_DEVICE_STATE_REASON_UNKNOWN;
+   }
 
-   /* FIXME: We have only GSM error messages here, and we have no idea 
which 
+   /* FIXME: We have only GSM error messages here, and we have no idea 
which
   activation state failed. Reasons like:
   NM_DEVICE_STATE_REASON_MODEM_DIAL_FAILED,
   

Running dispatch scripts before sleeping

2011-11-13 Thread Lamarque V. Souza
Hi,

I have received this bug in bugs.kde.org and I think it belongs to NM, 
not Plasma NM:

https://bugs.kde.org/show_bug.cgi?id=286433

What I think is happening is that PowerDevil (KDE's power management 
widget) triggers the sleep event in UPower, NetworkManager listens for that 
event and goes to sleep before triggering the dispatch scripts in 
/etc/NetworkManager/dispatcher.d. That causes some troubles when someone needs 
to execute something before the connections are deactivated.

That problem can happen with any program that triggers UPower's sleep 
event, so it is not Powerdevil specific.

Does NM have any way to execute scripts BEFORE deactivating a 
connection? As far as I know NM executes the dispatch scripts only after the 
connection has been deactivated, right?

-- 
Lamarque V. Souza
KDE's Network Management maintainer
http://planetkde.org/pt-br
___
networkmanager-list mailing list
networkmanager-list@gnome.org
http://mail.gnome.org/mailman/listinfo/networkmanager-list