3
* oFono - Open Source Telephony
5
* Copyright (C) 2008-2011 Intel Corporation. All rights reserved.
7
* This program is free software; you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License version 2 as
9
* published by the Free Software Foundation.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
33
#define OFONO_API_SUBJECT_TO_CHANGE
34
#include <ofono/plugin.h>
35
#include <ofono/modem.h>
36
#include <ofono/devinfo.h>
37
#include <ofono/cdma-netreg.h>
38
#include <ofono/cdma-connman.h>
39
#include <ofono/log.h>
41
#include "drivers/atmodem/vendor.h"
43
struct speedupcdma_data {
48
static void speedupcdma_debug(const char *str, void *data)
50
const char *prefix = data;
52
ofono_info("%s%s", prefix, str);
55
static int speedupcdma_probe(struct ofono_modem *modem)
57
struct speedupcdma_data *data;
61
data = g_try_new0(struct speedupcdma_data, 1);
65
ofono_modem_set_data(modem, data);
70
static void speedupcdma_remove(struct ofono_modem *modem)
72
struct speedupcdma_data *data = ofono_modem_get_data(modem);
76
ofono_modem_set_data(modem, NULL);
78
/* Cleanup after hot-unplug */
79
g_at_chat_unref(data->aux);
84
static void cfun_enable(gboolean ok, GAtResult *result, gpointer user_data)
86
struct ofono_modem *modem = user_data;
87
struct speedupcdma_data *data = ofono_modem_get_data(modem);
92
g_at_chat_unref(data->modem);
95
g_at_chat_unref(data->aux);
99
ofono_modem_set_powered(modem, ok);
102
static GAtChat *open_device(struct ofono_modem *modem,
103
const char *key, char *debug)
110
device = ofono_modem_get_string(modem, key);
114
DBG("%s %s", key, device);
116
channel = g_at_tty_open(device, NULL);
120
syntax = g_at_syntax_new_gsm_permissive();
121
chat = g_at_chat_new(channel, syntax);
122
g_at_syntax_unref(syntax);
124
g_io_channel_unref(channel);
129
if (getenv("OFONO_AT_DEBUG"))
130
g_at_chat_set_debug(chat, speedupcdma_debug, debug);
135
static int speedupcdma_enable(struct ofono_modem *modem)
137
struct speedupcdma_data *data = ofono_modem_get_data(modem);
141
data->modem = open_device(modem, "Modem", "Modem: ");
142
if (data->modem == NULL)
145
data->aux = open_device(modem, "Aux", "Aux: ");
146
if (data->aux == NULL) {
147
g_at_chat_unref(data->modem);
152
g_at_chat_set_slave(data->modem, data->aux);
154
g_at_chat_send(data->modem, "ATE0 &C0 +CMEE=1", NULL, NULL, NULL, NULL);
155
g_at_chat_send(data->aux, "ATE0 &C0 +CMEE=1", NULL, NULL, NULL, NULL);
157
g_at_chat_send(data->aux, "AT+CFUN=1", NULL,
158
cfun_enable, modem, NULL);
163
static void cfun_disable(gboolean ok, GAtResult *result, gpointer user_data)
165
struct ofono_modem *modem = user_data;
166
struct speedupcdma_data *data = ofono_modem_get_data(modem);
170
g_at_chat_unref(data->aux);
174
ofono_modem_set_powered(modem, FALSE);
177
static int speedupcdma_disable(struct ofono_modem *modem)
179
struct speedupcdma_data *data = ofono_modem_get_data(modem);
183
g_at_chat_cancel_all(data->modem);
184
g_at_chat_unregister_all(data->modem);
186
g_at_chat_unref(data->modem);
189
g_at_chat_cancel_all(data->aux);
190
g_at_chat_unregister_all(data->aux);
192
g_at_chat_send(data->aux, "AT+CFUN=0", NULL,
193
cfun_disable, modem, NULL);
198
static void speedupcdma_pre_sim(struct ofono_modem *modem)
200
struct speedupcdma_data *data = ofono_modem_get_data(modem);
204
ofono_devinfo_create(modem, 0, "cdmamodem", data->aux);
207
static void speedupcdma_post_sim(struct ofono_modem *modem)
212
static void speedupcdma_post_online(struct ofono_modem *modem)
214
struct speedupcdma_data *data = ofono_modem_get_data(modem);
218
ofono_cdma_netreg_create(modem, 0, "huaweicdmamodem", data->aux);
220
ofono_cdma_connman_create(modem, OFONO_VENDOR_HUAWEI, "cdmamodem",
224
static struct ofono_modem_driver speedupcdma_driver = {
225
.name = "speedupcdma",
226
.probe = speedupcdma_probe,
227
.remove = speedupcdma_remove,
228
.enable = speedupcdma_enable,
229
.disable = speedupcdma_disable,
230
.pre_sim = speedupcdma_pre_sim,
231
.post_sim = speedupcdma_post_sim,
232
.post_online = speedupcdma_post_online,
235
static int speedupcdma_init(void)
237
return ofono_modem_driver_register(&speedupcdma_driver);
240
static void speedupcdma_exit(void)
242
ofono_modem_driver_unregister(&speedupcdma_driver);
245
OFONO_PLUGIN_DEFINE(speedupcdma, "Speed Up CDMA modem driver", VERSION,
246
OFONO_PLUGIN_PRIORITY_DEFAULT,
247
speedupcdma_init, speedupcdma_exit)