summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenis Kenzior <denkenz@gmail.com>2009-10-01 17:01:15 -0500
committerDenis Kenzior <denkenz@gmail.com>2009-10-01 17:01:15 -0500
commit79cb80c7eba59a3662db7d8aaaa8f6d157df4e0a (patch)
tree4f0e1db1a7eba3fa79806fda501bf8e815c3af82
parent6a78e402d32d2fdc6b60e6269818f264d744e0f0 (diff)
downloadofono-79cb80c7eba59a3662db7d8aaaa8f6d157df4e0a.tar.bz2
Update plugins to the new g_at_tty_open API
-rw-r--r--plugins/atgen.c9
-rw-r--r--plugins/calypso.c39
-rw-r--r--plugins/g1.c9
-rw-r--r--plugins/hso.c9
-rw-r--r--plugins/huawei.c9
-rw-r--r--plugins/mbm.c9
-rw-r--r--plugins/novatel.c9
7 files changed, 63 insertions, 30 deletions
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 <glib.h>
#include <gatchat.h>
+#include <gattty.h>
#define OFONO_API_SUBJECT_TO_CHANGE
#include <ofono/plugin.h>
@@ -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 <glib.h>
#include <gatchat.h>
+#include <gattty.h>
#define OFONO_API_SUBJECT_TO_CHANGE
#include <ofono/plugin.h>
@@ -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);
-
- /* Switch TTY to raw mode */
- memset(&ti, 0, sizeof(ti));
- cfmakeraw(&ti);
-
- cfsetospeed(&ti, B115200);
- cfsetispeed(&ti, B115200);
+ 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");
- 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;
+ io = g_at_tty_open(device, options);
+ g_hash_table_destroy(options);
- 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 <glib.h>
#include <gatchat.h>
+#include <gattty.h>
#define OFONO_API_SUBJECT_TO_CHANGE
#include <ofono/plugin.h>
@@ -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 <glib.h>
#include <gatchat.h>
+#include <gattty.h>
#define OFONO_API_SUBJECT_TO_CHANGE
#include <ofono/plugin.h>
@@ -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 <glib.h>
#include <gatchat.h>
+#include <gattty.h>
#define OFONO_API_SUBJECT_TO_CHANGE
#include <ofono/plugin.h>
@@ -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 <glib.h>
#include <gatchat.h>
+#include <gattty.h>
#define OFONO_API_SUBJECT_TO_CHANGE
#include <ofono/plugin.h>
@@ -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 <glib.h>
#include <gatchat.h>
+#include <gattty.h>
#define OFONO_API_SUBJECT_TO_CHANGE
#include <ofono/plugin.h>
@@ -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;