70
70
/*****************************************************************************/
71
71
/* Load supported modes (Modem interface) */
74
add_supported_mode (GArray **combinations,
77
MMModemModeCombination combination;
81
mm_dbg ("Modem supports 2G-only mode");
82
combination.allowed = MM_MODEM_MODE_2G;
83
combination.preferred = MM_MODEM_MODE_NONE;
86
mm_dbg ("Modem supports 3G-only mode");
87
combination.allowed = MM_MODEM_MODE_3G;
88
combination.preferred = MM_MODEM_MODE_NONE;
91
mm_dbg ("Modem supports 2G/3G mode with 2G preferred");
92
combination.allowed = (MM_MODEM_MODE_2G | MM_MODEM_MODE_3G);
93
combination.preferred = MM_MODEM_MODE_2G;
96
mm_dbg ("Modem supports 2G/3G mode with 3G preferred");
97
combination.allowed = (MM_MODEM_MODE_2G | MM_MODEM_MODE_3G);
98
combination.preferred = MM_MODEM_MODE_3G;
101
mm_dbg ("Modem supports 'any', but not explicitly listing it");
102
/* Any, no need to add it to the list */
105
mm_warn ("Unsupported Icera mode found: %u", mode);
109
if (*combinations == NULL)
110
*combinations = g_array_sized_new (FALSE, FALSE, sizeof (MMModemModeCombination), 5);
112
g_array_append_val (*combinations, combination);
74
116
load_supported_modes_finish (MMIfaceModem *self,
75
117
GAsyncResult *res,
78
if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error))
81
return g_array_ref (g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (res)));
85
parent_load_supported_modes_ready (MMIfaceModem *self,
87
GSimpleAsyncResult *simple)
93
MMModemModeCombination mode;
95
all = iface_modem_parent->load_supported_modes_finish (self, res, &error);
97
g_simple_async_result_take_error (simple, error);
98
g_simple_async_result_complete (simple);
99
g_object_unref (simple);
103
/* Build list of combinations */
104
combinations = g_array_sized_new (FALSE, FALSE, sizeof (MMModemModeCombination), 5);
107
mode.allowed = MM_MODEM_MODE_2G;
108
mode.preferred = MM_MODEM_MODE_NONE;
109
g_array_append_val (combinations, mode);
111
mode.allowed = MM_MODEM_MODE_3G;
112
mode.preferred = MM_MODEM_MODE_NONE;
113
g_array_append_val (combinations, mode);
115
mode.allowed = (MM_MODEM_MODE_2G | MM_MODEM_MODE_3G);
116
mode.preferred = MM_MODEM_MODE_NONE;
117
g_array_append_val (combinations, mode);
118
/* 2G and 3G, 2G preferred */
119
mode.allowed = (MM_MODEM_MODE_2G | MM_MODEM_MODE_3G);
120
mode.preferred = MM_MODEM_MODE_2G;
121
g_array_append_val (combinations, mode);
122
/* 2G and 3G, 3G preferred */
123
mode.allowed = (MM_MODEM_MODE_2G | MM_MODEM_MODE_3G);
124
mode.preferred = MM_MODEM_MODE_3G;
125
g_array_append_val (combinations, mode);
127
/* Filter out those unsupported modes */
128
filtered = mm_filter_supported_modes (all, combinations);
130
g_array_unref (combinations);
132
g_simple_async_result_set_op_res_gpointer (simple, filtered, (GDestroyNotify) g_array_unref);
133
g_simple_async_result_complete (simple);
134
g_object_unref (simple);
120
GArray *combinations = NULL;
121
const gchar *response;
122
gchar **split = NULL;
123
GMatchInfo *match_info;
127
response = mm_base_modem_at_command_finish (MM_BASE_MODEM (self), res, error);
131
/* Reply goes like this:
133
* %IPSYS: (0-3,5),(0-3)
136
r = g_regex_new ("\\%IPSYS:\\s*\\((.*)\\)\\s*,\\((.*)\\)",
137
G_REGEX_RAW, 0, NULL);
138
g_assert (r != NULL);
140
g_regex_match (r, response, 0, &match_info);
141
if (g_match_info_matches (match_info)) {
144
aux = mm_get_string_unquoted_from_match_info (match_info, 1);
146
split = g_strsplit (aux, ",", -1);
151
g_match_info_free (match_info);
157
MM_CORE_ERROR_FAILED,
158
"%%IPSYS=? response didn't match");
163
for (i = 0; split[i]; i++) {
164
gchar *interval_separator;
166
g_strstrip (split[i]);
167
interval_separator = strstr (split[i], "-");
168
if (interval_separator) {
169
/* Add all in interval */
171
guint modefirst, modelast;
173
first = g_strdup (split[i]);
174
interval_separator = strstr (first, "-");
175
*(interval_separator++) = '\0';
176
last = interval_separator;
178
if (mm_get_uint_from_str (first, &modefirst) &&
179
mm_get_uint_from_str (last, &modelast) &&
180
modefirst < modelast &&
184
for (j = modefirst; j <= modelast; j++)
185
add_supported_mode (&combinations, j);
187
mm_warn ("Couldn't parse mode interval (%s) in %%IPSYS=? response", split[i]);
193
if (mm_get_uint_from_str (split[i], &mode))
194
add_supported_mode (&combinations, mode);
196
mm_warn ("Couldn't parse mode (%s) in %%IPSYS=? response", split[i]);
205
MM_CORE_ERROR_FAILED,
206
"No mode combinations were parsed from the %%IPSYS=? response (%s)",