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/log.h>
36 #include <ofono/modem.h>
37 #include <ofono/call-barring.h>
38 #include <ofono/call-forwarding.h>
39 #include <ofono/call-meter.h>
40 #include <ofono/call-settings.h>
41 #include <ofono/devinfo.h>
42 #include <ofono/message-waiting.h>
43 #include <ofono/netreg.h>
44 #include <ofono/phonebook.h>
45 #include <ofono/sim.h>
46 #include <ofono/sms.h>
47 #include <ofono/ussd.h>
48 #include <ofono/voicecall.h>
50 #include <drivers/atmodem/vendor.h>
53 static int wavecom_probe(struct ofono_modem *modem)
58 static void wavecom_remove(struct ofono_modem *modem)
62 static void wavecom_debug(const char *str, void *user_data)
64 const char *prefix = user_data;
66 ofono_info("%s%s", prefix, str);
69 static int wavecom_enable(struct ofono_modem *modem)
79 device = ofono_modem_get_string(modem, "Device");
83 options = g_hash_table_new(g_str_hash, g_str_equal);
88 g_hash_table_insert(options, "Baud", "115200");
89 g_hash_table_insert(options, "Parity", "none");
90 g_hash_table_insert(options, "StopBits", "1");
91 g_hash_table_insert(options, "DataBits", "8");
93 channel = g_at_tty_open(device, options);
95 g_hash_table_destroy(options);
101 * Could not figure out whether it is fully compliant or not, use
104 syntax = g_at_syntax_new_gsm_permissive();
106 chat = g_at_chat_new(channel, syntax);
107 g_at_syntax_unref(syntax);
108 g_io_channel_unref(channel);
113 if (getenv("OFONO_AT_DEBUG"))
114 g_at_chat_set_debug(chat, wavecom_debug, "");
116 ofono_modem_set_data(modem, chat);
121 static int wavecom_disable(struct ofono_modem *modem)
123 GAtChat *chat = ofono_modem_get_data(modem);
127 ofono_modem_set_data(modem, NULL);
129 g_at_chat_unref(chat);
134 static void wavecom_pre_sim(struct ofono_modem *modem)
136 GAtChat *chat = ofono_modem_get_data(modem);
140 ofono_devinfo_create(modem, 0, "atmodem", chat);
141 ofono_sim_create(modem, OFONO_VENDOR_WAVECOM, "atmodem", chat);
142 ofono_voicecall_create(modem, 0, "atmodem", chat);
145 static void wavecom_post_sim(struct ofono_modem *modem)
147 GAtChat *chat = ofono_modem_get_data(modem);
148 struct ofono_message_waiting *mw;
152 ofono_ussd_create(modem, 0, "atmodem", chat);
153 ofono_call_forwarding_create(modem, 0, "atmodem", chat);
154 ofono_call_settings_create(modem, 0, "atmodem", chat);
155 ofono_netreg_create(modem, 0, "atmodem", chat);
156 ofono_call_meter_create(modem, 0, "atmodem", chat);
157 ofono_call_barring_create(modem, 0, "atmodem", chat);
158 ofono_sms_create(modem, 0, "atmodem", chat);
159 ofono_phonebook_create(modem, 0, "atmodem", chat);
161 mw = ofono_message_waiting_create(modem);
163 ofono_message_waiting_register(mw);
166 static struct ofono_modem_driver wavecom_driver = {
168 .probe = wavecom_probe,
169 .remove = wavecom_remove,
170 .enable = wavecom_enable,
171 .disable = wavecom_disable,
172 .pre_sim = wavecom_pre_sim,
173 .post_sim = wavecom_post_sim,
176 static int wavecom_init(void)
178 return ofono_modem_driver_register(&wavecom_driver);
181 static void wavecom_exit(void)
183 ofono_modem_driver_unregister(&wavecom_driver);
186 OFONO_PLUGIN_DEFINE(wavecom, "Wavecom driver", VERSION,
187 OFONO_PLUGIN_PRIORITY_DEFAULT, wavecom_init, wavecom_exit)