1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
Index: network-manager-0.7.0/src/nm-gsm-device.c
===================================================================
--- network-manager-0.7.0.orig/src/nm-gsm-device.c 2008-11-12 22:29:43.000000000 +0100
+++ network-manager-0.7.0/src/nm-gsm-device.c 2008-12-16 10:03:48.000000000 +0100
@@ -51,6 +51,15 @@
guint init_tries;
} NMGsmDevicePrivate;
+/* Various possible init sequences */
+const gchar *modem_init_sequences[] = {
+ "ATZ E0 V1 X4 &C1 +FCLASS=0",
+ "ATZ E0 V1 &C1",
+ "AT&F E0 V1",
+ NULL
+};
+
+
enum {
PROP_0,
PROP_MONITOR_IFACE,
@@ -69,7 +78,7 @@
static void enter_pin (NMGsmDevice *device, NMGsmSecret secret_type, gboolean retry);
static void manual_registration (NMGsmDevice *device);
static void automatic_registration (NMGsmDevice *device);
-static void init_modem (NMSerialDevice *device, gpointer user_data);
+static void init_modem (NMSerialDevice *device);
NMGsmDevice *
nm_gsm_device_new (const char *udi,
@@ -431,7 +440,7 @@
const char *responses[] = { "+CREG: 0,0", "+CREG: 0,1", "+CREG: 0,2", "+CREG: 0,3", "+CREG: 0,5", NULL };
const char *terminators[] = { "OK", "ERROR", "ERR", NULL };
- modem_wait_for_reply (device, "AT+CREG?", 15, responses, terminators, automatic_registration_response, NULL);
+ modem_wait_for_reply (device, "AT+CREG?", 25, responses, terminators, automatic_registration_response, NULL);
}
static void
@@ -496,13 +505,14 @@
static void
init_modem_full (NMGsmDevice *device)
{
+ NMGsmDevicePrivate *priv = NM_GSM_DEVICE_GET_PRIVATE (device);
const char *responses[] = { "OK", "ERROR", "ERR", NULL };
/* Send E0 too because some devices turn echo back on after CPIN which
* just breaks stuff since echo-ed commands are interpreted as replies.
* rh #456770
*/
- modem_wait_for_reply (device, "ATZ E0 V1 X4 &C1 +FCLASS=0", 10, responses, responses, init_full_done, NULL);
+ modem_wait_for_reply (device, modem_init_sequences[priv->init_tries], 10, responses, responses, init_full_done, NULL);
}
static void
@@ -647,7 +657,6 @@
switch (reply_index) {
case 0:
- priv->init_tries = 0;
check_pin (NM_GSM_DEVICE (device));
break;
case -1:
@@ -657,35 +666,26 @@
NM_DEVICE_STATE_REASON_MODEM_INIT_FAILED);
break;
default:
- switch (priv->init_tries) {
- case 0:
- nm_warning ("Trying alternate modem initialization");
- init_modem (device, "ATZ E0 V1 &C1");
- break;
- case 1:
- nm_warning ("Trying second alternate modem initialization");
- init_modem (device, "AT&F E0 V1");
- break;
- default:
+ priv->init_tries++;
+ if (modem_init_sequences[priv->init_tries] != NULL) {
+ nm_warning ("Trying alternate modem initialization (%d)",
+ priv->init_tries);
+ init_modem (device);
+ } else {
nm_warning ("Modem initialization failed");
nm_device_state_changed (NM_DEVICE (device),
NM_DEVICE_STATE_FAILED,
NM_DEVICE_STATE_REASON_MODEM_INIT_FAILED);
- break;
}
- priv->init_tries++;
- return;
}
}
static void
-init_modem (NMSerialDevice *device, gpointer user_data)
+init_modem (NMSerialDevice *device)
{
+ NMGsmDevicePrivate *priv = NM_GSM_DEVICE_GET_PRIVATE (device);
const char *responses[] = { "OK", "ERROR", "ERR", NULL };
- const char *init_string = user_data;
-
- if (!init_string)
- init_string = "ATZ E0 V1 X4 &C1 +FCLASS=0";
+ const char *init_string = modem_init_sequences[priv->init_tries];
modem_wait_for_reply (NM_GSM_DEVICE (device), init_string, 10, responses, responses, init_done, NULL);
}
@@ -706,7 +706,7 @@
NM_GSM_DEVICE_GET_PRIVATE (device)->init_tries = 0;
- id = nm_serial_device_flash (serial_device, 100, init_modem, NULL);
+ id = nm_serial_device_flash (serial_device, 100, (NMSerialFlashFn) init_modem, NULL);
if (!id)
*reason = NM_DEVICE_STATE_REASON_UNKNOWN;
Index: network-manager-0.7.0/src/nm-serial-device.c
===================================================================
--- network-manager-0.7.0.orig/src/nm-serial-device.c 2008-11-20 18:12:16.000000000 +0100
+++ network-manager-0.7.0/src/nm-serial-device.c 2008-12-16 10:03:48.000000000 +0100
@@ -415,6 +415,7 @@
}
priv->channel = g_io_channel_unix_new (priv->fd);
+ g_io_channel_set_encoding (priv->channel, NULL, NULL);
return TRUE;
}
|