3
3
* oFono - Open Source Telephony
5
* Copyright (C) 2008-2010 Intel Corporation. All rights reserved.
5
* Copyright (C) 2008-2011 Intel Corporation. All rights reserved.
7
7
* This program is free software; you can redistribute it and/or modify
8
8
* it under the terms of the GNU General Public License version 2 as
80
80
"/dev/ttyGSM5", "/dev/ttyGSM6" };
82
82
static const char *none_prefix[] = { NULL };
83
static const char *xdrv_prefix[] = { "+XDRV:", NULL };
83
static const char *xgendata_prefix[] = { "+XGENDATA:", NULL };
84
static const char *xsimstate_prefix[] = { "+XSIMSTATE:", NULL };
86
87
GIOChannel *device;
141
static void xsim_notify(GAtResult *result, gpointer user_data)
137
static void ifx_set_sim_state(struct ifx_data *data, int state)
143
struct ofono_modem *modem = user_data;
144
struct ifx_data *data = ofono_modem_get_data(modem);
149
if (data->sim == NULL)
152
g_at_result_iter_init(&iter, result);
154
if (!g_at_result_iter_next(&iter, "+XSIM:"))
157
if (!g_at_result_iter_next_number(&iter, &state))
160
139
DBG("state %d", state);
168
static void xsim_notify(GAtResult *result, gpointer user_data)
170
struct ofono_modem *modem = user_data;
171
struct ifx_data *data = ofono_modem_get_data(modem);
176
if (data->sim == NULL)
179
g_at_result_iter_init(&iter, result);
181
if (!g_at_result_iter_next(&iter, "+XSIM:"))
184
if (!g_at_result_iter_next_number(&iter, &state))
187
ifx_set_sim_state(data, state);
190
static void xsimstate_query(gboolean ok, GAtResult *result, gpointer user_data)
192
struct ofono_modem *modem = user_data;
193
struct ifx_data *data = ofono_modem_get_data(modem);
203
g_at_result_iter_init(&iter, result);
205
if (!g_at_result_iter_next(&iter, "+XSIMSTATE:"))
208
if (!g_at_result_iter_next_number(&iter, &mode))
211
if (!g_at_result_iter_next_number(&iter, &state))
214
ifx_set_sim_state(data, state);
189
217
static void shutdown_device(struct ifx_data *data)
282
310
DBG("\n%s", gendata);
284
if (g_str_has_prefix(gendata, " XMM6260") == TRUE) {
285
ofono_info("Detected XMM6260 modem");
286
data->audio_source = 4;
287
data->audio_dest = 3;
288
data->audio_context = 0;
312
/* switch to GSM character set instead of IRA */
313
g_at_chat_send(data->dlcs[AUX_DLC], "AT+CSCS=\"GSM\"", none_prefix,
291
316
/* disable UART for power saving */
292
317
g_at_chat_send(data->dlcs[AUX_DLC], "AT+XPOW=0,0,0", none_prefix,
293
318
NULL, NULL, NULL);
295
if (data->audio_setting && data->audio_source && data->audio_dest) {
298
/* configure source */
299
snprintf(buf, sizeof(buf), "AT+XDRV=40,4,%d,%d,%s",
302
data->audio_setting);
303
g_at_chat_send(data->dlcs[AUX_DLC], buf, xdrv_prefix,
306
/* configure destination */
307
snprintf(buf, sizeof(buf), "AT+XDRV=40,5,%d,%d,%s",
310
data->audio_setting);
311
g_at_chat_send(data->dlcs[AUX_DLC], buf, xdrv_prefix,
314
if (data->audio_loopback) {
315
/* set destination for source */
316
snprintf(buf, sizeof(buf), "AT+XDRV=40,6,%d,%d",
317
data->audio_source, data->audio_dest);
318
g_at_chat_send(data->dlcs[AUX_DLC], buf, xdrv_prefix,
322
snprintf(buf, sizeof(buf), "AT+XDRV=40,2,%d",
324
g_at_chat_send(data->dlcs[AUX_DLC], buf, xdrv_prefix,
329
320
data->have_sim = FALSE;
331
322
/* notify that the modem is ready so that pre_sim gets called */
338
329
g_at_chat_send(data->dlcs[AUX_DLC], "AT+XSIMSTATE=1", none_prefix,
339
330
NULL, NULL, NULL);
332
g_at_chat_send(data->dlcs[AUX_DLC], "AT+XSIMSTATE?", xsimstate_prefix,
333
xsimstate_query, modem, NULL);
361
g_at_chat_send(data->dlcs[AUX_DLC], "AT+XGENDATA", NULL,
355
g_at_chat_send(data->dlcs[AUX_DLC], "AT+XGENDATA", xgendata_prefix,
362
356
xgendata_query, modem, NULL);
542
536
static int ifx_enable(struct ofono_modem *modem)
544
538
struct ifx_data *data = ofono_modem_get_data(modem);
545
const char *device, *ldisc, *audio, *loopback;
539
const char *device, *ldisc;
546
540
GAtSyntax *syntax;
555
549
DBG("%s", device);
557
audio = ofono_modem_get_string(modem, "AudioSetting");
558
if (g_strcmp0(audio, "FULL_DUPLEX") == 0)
559
data->audio_setting = "0,0,0,0,0,0,0,0,0";
560
else if (g_strcmp0(audio, "BURSTMODE_48KHZ") == 0)
561
data->audio_setting = "0,0,8,0,2,0,0,0,0";
562
else if (g_strcmp0(audio, "BURSTMODE_96KHZ") == 0)
563
data->audio_setting = "0,0,9,0,2,0,0,0,0";
565
loopback = ofono_modem_get_string(modem, "AudioLoopback");
566
if (loopback != NULL)
567
data->audio_loopback = atoi(loopback);
569
551
ldisc = ofono_modem_get_string(modem, "LineDiscipline");
570
552
if (ldisc != NULL) {
571
553
data->mux_ldisc = atoi(ldisc);
576
558
data->device = g_at_tty_open(device, NULL);
577
559
if (data->device == NULL)
580
562
syntax = g_at_syntax_new_gsmv1();
581
563
chat = g_at_chat_new(data->device, syntax);
592
574
g_at_chat_send(chat, "ATE0 +CMEE=1", NULL,
593
575
NULL, NULL, NULL);
577
/* Enable multiplexer */
595
578
data->frame_size = 1509;
597
580
g_at_chat_send(chat, "AT+CMUX=0,0,,1509,10,3,30,,", NULL,
635
618
g_at_chat_unregister_all(data->dlcs[i]);
638
g_at_chat_send(data->dlcs[AUX_DLC], "AT+CFUN=4", NULL,
621
g_at_chat_send(data->dlcs[AUX_DLC], "AT+CFUN=0", NULL,
639
622
cfun_disable, modem, NULL);
641
624
return -EINPROGRESS;
646
629
struct cb_data *cbd = user_data;
647
630
ofono_modem_online_cb_t cb = cbd->cb;
631
struct ofono_error error;
650
CALLBACK_WITH_SUCCESS(cb, cbd->data);
652
CALLBACK_WITH_FAILURE(cb, cbd->data);
633
decode_at_error(&error, g_at_result_final_response(result));
634
cb(&error, cbd->data);
655
637
static void ifx_set_online(struct ofono_modem *modem, ofono_bool_t online,
662
644
DBG("%p %s", modem, online ? "online" : "offline");
664
if (g_at_chat_send(data->dlcs[AUX_DLC], command, NULL,
646
if (g_at_chat_send(data->dlcs[AUX_DLC], command, none_prefix,
665
647
set_online_cb, cbd, g_free) > 0)
650
CALLBACK_WITH_FAILURE(cb, cbd->data);
670
CALLBACK_WITH_FAILURE(cb, cbd->data);
673
655
static void ifx_pre_sim(struct ofono_modem *modem)
716
698
ofono_cbs_create(modem, 0, "atmodem", data->dlcs[AUX_DLC]);
717
699
ofono_ussd_create(modem, 0, "atmodem", data->dlcs[AUX_DLC]);
719
ofono_ssn_create(modem, 0, "atmodem", data->dlcs[AUX_DLC]);
701
ofono_gnss_create(modem, 0, "atmodem", data->dlcs[AUX_DLC]);
720
703
ofono_call_settings_create(modem, 0, "atmodem", data->dlcs[AUX_DLC]);
721
704
ofono_call_meter_create(modem, 0, "atmodem", data->dlcs[AUX_DLC]);
722
705
ofono_call_barring_create(modem, 0, "atmodem", data->dlcs[AUX_DLC]);