diff --git a/plugins/atgen.c b/plugins/atgen.c index 1388dfa7..c0fbbb2f 100644 --- a/plugins/atgen.c +++ b/plugins/atgen.c @@ -28,6 +28,7 @@ #include #include +#include #define OFONO_API_SUBJECT_TO_CHANGE #include @@ -64,6 +65,7 @@ static void atgen_debug(const char *str, void *user_data) static int atgen_enable(struct ofono_modem *modem) { GAtChat *chat; + GIOChannel *channel; GAtSyntax *syntax; const char *device; @@ -73,9 +75,14 @@ static int atgen_enable(struct ofono_modem *modem) if (!device) return -EINVAL; + channel = g_at_tty_open(device, NULL); + if (!channel) + return -EIO; + syntax = g_at_syntax_new_gsmv1(); - chat = g_at_chat_new_from_tty(device, syntax); + chat = g_at_chat_new(channel, syntax); g_at_syntax_unref(syntax); + g_io_channel_unref(channel); if (!chat) return -ENOMEM; diff --git a/plugins/calypso.c b/plugins/calypso.c index 150801f9..16d4cb13 100644 --- a/plugins/calypso.c +++ b/plugins/calypso.c @@ -33,6 +33,7 @@ #include #include +#include #define OFONO_API_SUBJECT_TO_CHANGE #include @@ -179,39 +180,29 @@ static void modem_initialize(struct ofono_modem *modem) GIOChannel *io; int sk; struct termios ti; + GHashTable *options; DBG(""); device = ofono_modem_get_string(modem, "Device"); - sk = open(device, O_RDWR | O_NOCTTY); - - if (sk < 0) + options = g_hash_table_new(g_str_hash, g_str_equal); + if (options == NULL) goto error; - tcflush(sk, TCIOFLUSH); + g_hash_table_insert(options, "baud", "115200"); + g_hash_table_insert(options, "parity", "none"); + g_hash_table_insert(options, "stopbits", "1"); + g_hash_table_insert(options, "databits", "8"); + g_hash_table_insert(options, "xonxoff", "on"); + g_hash_table_insert(options, "local", "on"); + g_hash_table_insert(options, "rtscts", "on"); - /* Switch TTY to raw mode */ - memset(&ti, 0, sizeof(ti)); - cfmakeraw(&ti); + io = g_at_tty_open(device, options); + g_hash_table_destroy(options); - cfsetospeed(&ti, B115200); - cfsetispeed(&ti, B115200); - - ti.c_cflag &= ~(PARENB); - ti.c_cflag &= ~(CSTOPB); - ti.c_cflag &= ~(CSIZE); - ti.c_cflag |= CS8; - ti.c_cflag |= CRTSCTS; - ti.c_cflag |= CLOCAL; - ti.c_iflag |= (IXON | IXOFF | IXANY); - ti.c_cc[VSTART] = 17; - ti.c_cc[VSTOP] = 19; - - tcsetattr(sk, TCSANOW, &ti); - - io = g_io_channel_unix_new(sk); - g_io_channel_set_close_on_unref(io, TRUE); + if (io == NULL) + goto error; /* Calypso is normally compliant to 27.007, except the vendor-specific * notifications (like %CSTAT) are not prefixed by \r\n diff --git a/plugins/g1.c b/plugins/g1.c index 0414f495..aeb38b10 100644 --- a/plugins/g1.c +++ b/plugins/g1.c @@ -28,6 +28,7 @@ #include #include +#include #define OFONO_API_SUBJECT_TO_CHANGE #include @@ -81,6 +82,7 @@ static void cfun_set_on_cb(gboolean ok, GAtResult *result, gpointer user_data) static int g1_enable(struct ofono_modem *modem) { GAtSyntax *syntax; + GIOChannel *channel; GAtChat *chat; const char *device; @@ -90,8 +92,13 @@ static int g1_enable(struct ofono_modem *modem) if (device == NULL) return -EINVAL; + channel = g_at_tty_open(device, NULL); + if (channel == NULL) + return -EIO; + syntax = g_at_syntax_new_gsm_permissive(); - chat = g_at_chat_new_from_tty(device, syntax); + chat = g_at_chat_new(channel, syntax); + g_io_channel_unref(channel); g_at_syntax_unref(syntax); if (chat == NULL) diff --git a/plugins/hso.c b/plugins/hso.c index e678aab3..b1cc6663 100644 --- a/plugins/hso.c +++ b/plugins/hso.c @@ -29,6 +29,7 @@ #include #include +#include #define OFONO_API_SUBJECT_TO_CHANGE #include @@ -88,6 +89,7 @@ static int hso_enable(struct ofono_modem *modem) { struct hso_data *data = ofono_modem_get_data(modem); GAtSyntax *syntax; + GIOChannel *channel; const char *device; DBG("%p", modem); @@ -99,9 +101,14 @@ static int hso_enable(struct ofono_modem *modem) return -EINVAL; } + channel = g_at_tty_open(device, NULL); + if (!channel) + return -EIO; + syntax = g_at_syntax_new_gsmv1(); - data->chat = g_at_chat_new_from_tty(device, syntax); + data->chat = g_at_chat_new(channel, syntax); g_at_syntax_unref(syntax); + g_io_channel_unref(channel); if (!data->chat) return -EIO; diff --git a/plugins/huawei.c b/plugins/huawei.c index 392804da..17548460 100644 --- a/plugins/huawei.c +++ b/plugins/huawei.c @@ -29,6 +29,7 @@ #include #include +#include #define OFONO_API_SUBJECT_TO_CHANGE #include @@ -87,6 +88,7 @@ static int huawei_enable(struct ofono_modem *modem) { struct huawei_data *data = ofono_modem_get_data(modem); GAtSyntax *syntax; + GIOChannel *channel; const char *device; DBG("%p", modem); @@ -95,9 +97,14 @@ static int huawei_enable(struct ofono_modem *modem) if (!device) return -EINVAL; + channel = g_at_tty_open(device, NULL); + if (!channel) + return -EIO; + syntax = g_at_syntax_new_gsmv1(); - data->chat = g_at_chat_new_from_tty(device, syntax); + data->chat = g_at_chat_new(channel, syntax); g_at_syntax_unref(syntax); + g_io_channel_unref(channel); if (!data->chat) return -EIO; diff --git a/plugins/mbm.c b/plugins/mbm.c index ce27d47f..40568f5e 100644 --- a/plugins/mbm.c +++ b/plugins/mbm.c @@ -29,6 +29,7 @@ #include #include +#include #define OFONO_API_SUBJECT_TO_CHANGE #include @@ -87,6 +88,7 @@ static void cfun_enable(gboolean ok, GAtResult *result, gpointer user_data) static int mbm_enable(struct ofono_modem *modem) { struct mbm_data *data = ofono_modem_get_data(modem); + GIOChannel *channel; GAtSyntax *syntax; const char *device; @@ -99,9 +101,14 @@ static int mbm_enable(struct ofono_modem *modem) return -EINVAL; } + channel = g_at_tty_open(device, NULL); + if (!channel) + return -EIO; + syntax = g_at_syntax_new_gsmv1(); - data->chat = g_at_chat_new_from_tty(device, syntax); + data->chat = g_at_chat_new(channel, syntax); g_at_syntax_unref(syntax); + g_io_channel_unref(channel); if (!data->chat) return -EIO; diff --git a/plugins/novatel.c b/plugins/novatel.c index adbb36ae..b140a8a2 100644 --- a/plugins/novatel.c +++ b/plugins/novatel.c @@ -29,6 +29,7 @@ #include #include +#include #define OFONO_API_SUBJECT_TO_CHANGE #include @@ -87,6 +88,7 @@ static int novatel_enable(struct ofono_modem *modem) { struct novatel_data *data = ofono_modem_get_data(modem); GAtSyntax *syntax; + GIOChannel *channel; const char *device; DBG("%p", modem); @@ -95,9 +97,14 @@ static int novatel_enable(struct ofono_modem *modem) if (!device) return -EINVAL; + channel = g_at_tty_open(device, NULL); + if (!channel) + return -EIO; + syntax = g_at_syntax_new_gsmv1(); - data->chat = g_at_chat_new_from_tty(device, syntax); + data->chat = g_at_chat_new(channel, syntax); g_at_syntax_unref(syntax); + g_io_channel_unref(channel); if (!data->chat) return -EIO;