mirror of git://git.sysmocom.de/ofono
Update plugins to the new g_at_tty_open API
This commit is contained in:
parent
6a78e402d3
commit
79cb80c7eb
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue