193
ossys_to_mm (char ossys, MMModemGsmAccessTech *out_act)
196
*out_act = MM_MODEM_GSM_ACCESS_TECH_GPRS;
198
} else if (ossys == '2') {
199
*out_act = MM_MODEM_GSM_ACCESS_TECH_UMTS;
201
} else if (ossys == '3') {
202
*out_act = MM_MODEM_GSM_ACCESS_TECH_UNKNOWN;
193
209
parse_octi_response (GString *response, MMModemGsmAccessTech *act)
195
211
MMModemGsmAccessTech cur_act = MM_MODEM_GSM_ACCESS_TECH_UNKNOWN;
242
parse_ossys_response (GString *response, MMModemGsmAccessTech *act)
244
MMModemGsmAccessTech cur_act = MM_MODEM_GSM_ACCESS_TECH_UNKNOWN;
247
GMatchInfo *match_info;
249
gboolean success = FALSE;
251
g_return_val_if_fail (act != NULL, FALSE);
252
g_return_val_if_fail (response != NULL, FALSE);
254
p = mm_strip_tag (response->str, "_OSSYS:");
256
r = g_regex_new ("(\\d),(\\d)", G_REGEX_UNGREEDY, 0, NULL);
257
g_return_val_if_fail (r != NULL, FALSE);
259
g_regex_match (r, p, 0, &match_info);
260
if (g_match_info_matches (match_info)) {
261
str = g_match_info_fetch (match_info, 2);
262
if (str && ossys_to_mm (str[0], &cur_act)) {
268
g_match_info_free (match_info);
226
275
ossys_octi_request_done (MMAtSerialPort *port,
227
276
GString *response,
263
312
str = g_match_info_fetch (info, 1);
265
switch (atoi (str)) {
267
act = MM_MODEM_GSM_ACCESS_TECH_GPRS;
270
act = MM_MODEM_GSM_ACCESS_TECH_UMTS;
314
ossys_to_mm (str[0], &act);
278
317
mm_generic_gsm_update_access_technology (MM_GENERIC_GSM (user_data), act);
409
448
MMCallbackInfo *info = user_data;
410
449
MMModemGsmAccessTech octi = MM_MODEM_GSM_ACCESS_TECH_UNKNOWN;
411
MMModemGsmAccessTech owcti;
450
MMModemGsmAccessTech act;
413
452
/* If the modem has already been removed, return without
414
453
* scheduling callback */
419
458
if (parse_octi_response (response, &octi)) {
420
/* If no 3G tech yet or current tech isn't 3G, then 2G tech is the best */
421
owcti = GPOINTER_TO_UINT (mm_callback_info_get_data (info, "owcti"));
459
/* If current tech is 2G or unknown then use the more specific
462
act = GPOINTER_TO_UINT (mm_callback_info_get_result (info));
463
if (act < MM_MODEM_GSM_ACCESS_TECH_UMTS)
423
464
mm_callback_info_set_result (info, GUINT_TO_POINTER (octi), NULL);
446
487
p = mm_strip_tag (response->str, "_OWCTI:");
447
if (owcti_to_mm (*p, &owcti)) {
448
/* 3G tech always takes precedence over 2G tech */
450
mm_callback_info_set_result (info, GUINT_TO_POINTER (owcti), NULL);
488
if (owcti_to_mm (*p, &owcti) && owcti)
489
mm_callback_info_set_result (info, GUINT_TO_POINTER (owcti), NULL);
492
mm_callback_info_chain_complete_one (info);
496
get_act_ossys_request_done (MMAtSerialPort *port,
501
MMCallbackInfo *info = user_data;
502
MMModemGsmAccessTech ossys = MM_MODEM_GSM_ACCESS_TECH_UNKNOWN;
503
gboolean check_2g = TRUE, check_3g = TRUE;
505
/* If the modem has already been removed, return without
506
* scheduling callback */
507
if (mm_callback_info_check_modem_removed (info))
510
/* If for some reason the OSSYS request failed, still try to check
511
* explicit 2G/3G mode with OCTI and OWCTI; maybe we'll get something.
515
/* Response is _OSSYS: <n>,<act> so we must skip the <n> */
516
if (parse_ossys_response (response, &ossys)) {
517
mm_callback_info_set_result (info, GUINT_TO_POINTER (ossys), NULL);
519
/* If the OSSYS response indicated a generic access tech type
520
* then only check for more specific access tech of that type.
522
if (ossys == MM_MODEM_GSM_ACCESS_TECH_GPRS)
524
if (ossys == MM_MODEM_GSM_ACCESS_TECH_UMTS)
530
mm_at_serial_port_queue_command (port, "_OCTI?", 3, get_act_octi_request_done, info);
532
mm_callback_info_chain_complete_one (info); /* complete it if it wasn't used */
535
mm_at_serial_port_queue_command (port, "_OWCTI?", 3, get_act_owcti_request_done, info);
537
mm_callback_info_chain_complete_one (info); /* complete it if it wasn't used */
454
539
mm_callback_info_chain_complete_one (info);
463
548
MMCallbackInfo *info;
465
550
info = mm_callback_info_uint_new (MM_MODEM (modem), callback, user_data);
466
mm_callback_info_chain_start (info, 2);
551
mm_callback_info_chain_start (info, 3);
468
553
port = mm_generic_gsm_get_best_at_port (modem, &info->error);
474
mm_at_serial_port_queue_command (port, "_OCTI?", 3, get_act_octi_request_done, info);
475
mm_at_serial_port_queue_command (port, "_OWCTI?", 3, get_act_owcti_request_done, info);
559
mm_at_serial_port_queue_command (port, "_OSSYS?", 3, get_act_ossys_request_done, info);