108
109
case 1: /* GSM */
110
tech = ACCESS_TECHNOLOGY_GSM;
111
112
case 2: /* GPRS */
113
tech = ACCESS_TECHNOLOGY_GSM;
114
115
case 3: /* EDGE */
116
tech = ACCESS_TECHNOLOGY_GSM_EGPRS;
119
123
switch (ouwcti) {
120
124
case 1: /* UMTS */
125
tech = ACCESS_TECHNOLOGY_UTRAN;
123
127
case 2: /* HSDPA */
128
tech = ACCESS_TECHNOLOGY_UTRAN_HSDPA;
126
130
case 3: /* HSUPA */
131
tech = ACCESS_TECHNOLOGY_UTRAN_HSUPA;
129
133
case 4: /* HSPA */
134
tech = ACCESS_TECHNOLOGY_UTRAN_HSDPA_HSUPA;
196
197
g_at_chat_send(nd->chat, "AT*ERINFO?", none_prefix,
197
198
NULL, NULL, NULL);
200
case OFONO_VENDOR_GOBI:
202
* Send *CNTI=0 to find out the current tech, it will be
203
* intercepted in gobi_cnti_notify
205
g_at_chat_send(nd->chat, "AT*CNTI=0", none_prefix,
199
208
case OFONO_VENDOR_NOVATEL:
201
210
* Send $CNTI=0 to find out the current tech, it will be
220
229
at_creg_cb, cbd, g_free) > 0)
226
234
CALLBACK_WITH_FAILURE(cb, -1, -1, -1, -1, data);
260
268
/* Default to GSM */
261
269
if (g_at_result_iter_next_number(&iter, &tech) == FALSE)
270
tech = ACCESS_TECHNOLOGY_GSM;
264
272
strncpy(op.name, name, OFONO_MAX_OPERATOR_NAME_LENGTH);
265
273
op.name[OFONO_MAX_OPERATOR_NAME_LENGTH] = '\0';
408
412
DBG("Got %d elements", num);
410
414
list = g_try_new0(struct ofono_network_operator, num);
413
416
CALLBACK_WITH_FAILURE(cb, 0, NULL, cbd->data);
455
458
extract_mcc_mnc(n, list[num].mcc, list[num].mnc);
457
460
if (!g_at_result_iter_next_number(&iter, &tech))
461
tech = ACCESS_TECHNOLOGY_GSM;
460
463
list[num].tech = tech;
492
495
struct netreg_data *nd = ofono_netreg_get_data(netreg);
493
496
struct cb_data *cbd = cb_data_new(cb, data);
498
498
if (g_at_chat_send(nd->chat, "AT+COPS=?", cops_prefix,
499
499
cops_list_cb, cbd, g_free) > 0)
505
504
CALLBACK_WITH_FAILURE(cb, 0, NULL, data);
522
521
struct netreg_data *nd = ofono_netreg_get_data(netreg);
523
522
struct cb_data *cbd = cb_data_new(cb, data);
528
524
if (g_at_chat_send(nd->chat, "AT+COPS=0", none_prefix,
529
525
register_cb, cbd, g_free) > 0)
535
530
CALLBACK_WITH_FAILURE(cb, data);
543
538
struct cb_data *cbd = cb_data_new(cb, data);
549
541
snprintf(buf, sizeof(buf), "AT+COPS=1,2,\"%s%s\"", mcc, mnc);
551
543
if (g_at_chat_send(nd->chat, buf, none_prefix,
552
544
register_cb, cbd, g_free) > 0)
558
CALLBACK_WITH_FAILURE(cb, data);
561
static void at_deregister(struct ofono_netreg *netreg,
562
ofono_netreg_register_cb_t cb, void *data)
564
struct netreg_data *nd = ofono_netreg_get_data(netreg);
565
struct cb_data *cbd = cb_data_new(cb, data);
570
if (g_at_chat_send(nd->chat, "AT+COPS=2", none_prefix,
571
register_cb, cbd, g_free) > 0)
577
549
CALLBACK_WITH_FAILURE(cb, data);
667
639
else if (ind == 7)
670
642
strength = (ind * 15);
672
ofono_netreg_strength_notify(netreg, ind);
644
ofono_netreg_strength_notify(netreg, strength);
675
647
static void ciev_notify(GAtResult *result, gpointer user_data)
700
672
static void ctzv_notify(GAtResult *result, gpointer user_data)
702
//struct ofono_netreg *netreg = user_data;
703
//struct netreg_data *nd = ofono_netreg_get_data(netreg);
674
struct ofono_netreg *netreg = user_data;
675
struct netreg_data *nd = ofono_netreg_get_data(netreg);
705
677
GAtResultIter iter;
982
954
case 1: /* UMTS */
955
nd->tech = ACCESS_TECHNOLOGY_UTRAN;
985
957
case 2: /* UMTS + HSDPA */
958
nd->tech = ACCESS_TECHNOLOGY_UTRAN_HSDPA;
963
static int cnti_to_tech(const char *cnti)
965
if (g_str_equal(cnti, "GSM") == TRUE ||
966
g_str_equal(cnti, "GPRS") == TRUE)
967
return ACCESS_TECHNOLOGY_GSM;
968
else if (g_str_equal(cnti, "EDGE") == TRUE)
969
return ACCESS_TECHNOLOGY_GSM_EGPRS;
970
else if (g_str_equal(cnti, "UMTS") == TRUE)
971
return ACCESS_TECHNOLOGY_UTRAN;
972
else if (g_str_equal(cnti, "HSDPA") == TRUE)
973
return ACCESS_TECHNOLOGY_UTRAN_HSDPA;
974
else if (g_str_equal(cnti, "HSUPA") == TRUE)
975
return ACCESS_TECHNOLOGY_UTRAN_HSUPA;
980
static void gobi_cnti_notify(GAtResult *result, gpointer user_data)
982
struct ofono_netreg *netreg = user_data;
983
struct netreg_data *nd = ofono_netreg_get_data(netreg);
988
g_at_result_iter_init(&iter, result);
990
if (g_at_result_iter_next(&iter, "*CNTI:") == FALSE)
993
if (g_at_result_iter_next_number(&iter, &option) == FALSE)
999
if (g_at_result_iter_next_unquoted_string(&iter, &tech) == FALSE)
1002
nd->tech = cnti_to_tech(tech);
993
1005
static void nw_cnti_notify(GAtResult *result, gpointer user_data)
995
//struct ofono_netreg *netreg = user_data;
996
//struct netreg_data *nd = ofono_netreg_get_data(netreg);
1007
struct ofono_netreg *netreg = user_data;
1008
struct netreg_data *nd = ofono_netreg_get_data(netreg);
997
1009
GAtResultIter iter;
998
1010
const char *tech;
1012
1024
if (g_at_result_iter_next_unquoted_string(&iter, &tech) == FALSE)
1015
ofono_info("CNTI: %s", tech);
1018
static void option_query_tech_cb(gboolean ok,
1019
GAtResult *result, gpointer user_data)
1021
struct tech_query *tq = user_data;
1027
nd->tech = cnti_to_tech(tech);
1030
static void cnti_query_tech_cb(gboolean ok, GAtResult *result,
1033
struct tech_query *tq = user_data;
1034
struct netreg_data *nd = ofono_netreg_get_data(tq->netreg);
1036
ofono_netreg_status_notify(tq->netreg,
1037
tq->status, tq->lac, tq->ci, nd->tech);
1040
static void option_query_tech_cb(gboolean ok, GAtResult *result,
1043
struct tech_query *tq = user_data;
1025
1047
tech = option_parse_tech(result);
1027
1051
ofono_netreg_status_notify(tq->netreg,
1028
1052
tq->status, tq->lac, tq->ci, tech);
1042
1066
if (status != 1 && status != 5)
1069
tq = g_try_new0(struct tech_query, 1);
1073
tq->status = status;
1076
tq->netreg = netreg;
1045
1078
switch (nd->vendor) {
1079
case OFONO_VENDOR_GOBI:
1080
if (g_at_chat_send(nd->chat, "AT*CNTI=0", none_prefix,
1081
cnti_query_tech_cb, tq, g_free) > 0)
1084
case OFONO_VENDOR_NOVATEL:
1085
if (g_at_chat_send(nd->chat, "AT$CNTI=0", none_prefix,
1086
cnti_query_tech_cb, tq, g_free) > 0)
1046
1089
case OFONO_VENDOR_OPTION_HSO:
1047
tq = g_new0(struct tech_query, 1);
1051
tq->status = status;
1054
tq->netreg = netreg;
1056
1090
if (g_at_chat_send(nd->chat, "AT_OCTI?;_OUWCTI?",
1057
1091
option_tech_prefix,
1058
1092
option_query_tech_cb, tq, g_free) > 0)
1065
1099
if ((status == 1 || status == 5) && tech == -1)
1066
1100
tech = nd->tech;
1198
1232
g_at_chat_send(nd->chat, "AT+CIND=?", cind_prefix,
1199
1233
cind_support_cb, netreg, NULL);
1235
case OFONO_VENDOR_GOBI:
1237
* Gobi devices don't support unsolicited notifications
1238
* of technology changes, but register a handle for
1239
* CNTI so we get notified by any query.
1241
g_at_chat_register(nd->chat, "*CNTI:", gobi_cnti_notify,
1242
FALSE, netreg, NULL);
1201
1244
case OFONO_VENDOR_NOVATEL:
1203
1246
* Novatel doesn't support unsolicited notifications
1339
1382
.list_operators = at_list_operators,
1340
1383
.register_auto = at_register_auto,
1341
1384
.register_manual = at_register_manual,
1342
.deregister = at_deregister,
1343
1385
.strength = at_signal_strength,
1346
void at_netreg_init()
1388
void at_netreg_init(void)
1348
1390
ofono_netreg_driver_register(&driver);
1351
void at_netreg_exit()
1393
void at_netreg_exit(void)
1353
1395
ofono_netreg_driver_unregister(&driver);