mirror of git://git.sysmocom.de/ofono
Cleanup previous patch
This commit is contained in:
parent
a55b43123f
commit
6d31b05b95
|
@ -48,23 +48,17 @@
|
|||
#include <ofono/ussd.h>
|
||||
#include <ofono/voicecall.h>
|
||||
|
||||
static const char *tty_opts[] =
|
||||
{
|
||||
"Baud",
|
||||
"Read",
|
||||
"Local",
|
||||
"StopBits",
|
||||
"DataBits",
|
||||
"Parity",
|
||||
"XonXoff",
|
||||
"Rtscts",
|
||||
NULL,
|
||||
};
|
||||
|
||||
static void unregister_tty_option(gpointer data)
|
||||
{
|
||||
g_free(data);
|
||||
}
|
||||
static const char *tty_opts[] = {
|
||||
"Baud",
|
||||
"Read",
|
||||
"Local",
|
||||
"StopBits",
|
||||
"DataBits",
|
||||
"Parity",
|
||||
"XonXoff",
|
||||
"RtsCts",
|
||||
NULL,
|
||||
};
|
||||
|
||||
static int atgen_probe(struct ofono_modem *modem)
|
||||
{
|
||||
|
@ -88,7 +82,7 @@ static int atgen_enable(struct ofono_modem *modem)
|
|||
const char *device;
|
||||
const char *value;
|
||||
GHashTable *options;
|
||||
int i = 0;
|
||||
int i;
|
||||
|
||||
DBG("%p", modem);
|
||||
|
||||
|
@ -97,23 +91,25 @@ static int atgen_enable(struct ofono_modem *modem)
|
|||
return -EINVAL;
|
||||
|
||||
options = g_hash_table_new_full(g_str_hash, g_str_equal,
|
||||
g_free, unregister_tty_option);
|
||||
g_free, g_free);
|
||||
if (!options)
|
||||
return -ENOMEM;
|
||||
|
||||
while (tty_opts[i]) {
|
||||
|
||||
for (i = 0; tty_opts[i]; i++) {
|
||||
value = ofono_modem_get_string(modem, tty_opts[i]);
|
||||
if (value) {
|
||||
g_hash_table_replace(options, g_strdup(tty_opts[i]),
|
||||
g_strdup(value));
|
||||
}
|
||||
i++;
|
||||
};
|
||||
|
||||
if (value == NULL)
|
||||
continue;
|
||||
|
||||
g_hash_table_insert(options, g_strdup(tty_opts[i]),
|
||||
g_strdup(value));
|
||||
}
|
||||
|
||||
channel = g_at_tty_open(device, options);
|
||||
|
||||
g_hash_table_destroy(options);
|
||||
|
||||
if (!channel) {
|
||||
g_hash_table_destroy(options);
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
|
@ -122,18 +118,14 @@ static int atgen_enable(struct ofono_modem *modem)
|
|||
g_at_syntax_unref(syntax);
|
||||
g_io_channel_unref(channel);
|
||||
|
||||
if (!chat) {
|
||||
g_hash_table_destroy(options);
|
||||
if (!chat)
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
if (getenv("OFONO_AT_DEBUG"))
|
||||
g_at_chat_set_debug(chat, atgen_debug, NULL);
|
||||
|
||||
ofono_modem_set_data(modem, chat);
|
||||
|
||||
g_hash_table_destroy(options);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -35,6 +35,18 @@
|
|||
|
||||
static GSList *modem_list = NULL;
|
||||
|
||||
static const char *tty_opts[] = {
|
||||
"Baud",
|
||||
"Read",
|
||||
"Local",
|
||||
"StopBits",
|
||||
"DataBits",
|
||||
"Parity",
|
||||
"XonXoff",
|
||||
"RtsCts",
|
||||
NULL,
|
||||
};
|
||||
|
||||
static int set_address(struct ofono_modem *modem,
|
||||
GKeyFile *keyfile, const char *group)
|
||||
{
|
||||
|
@ -72,7 +84,9 @@ static int set_address(struct ofono_modem *modem,
|
|||
static int set_device(struct ofono_modem *modem,
|
||||
GKeyFile *keyfile, const char *group)
|
||||
{
|
||||
char *device, *value;
|
||||
char *device;
|
||||
char *value;
|
||||
int i;
|
||||
|
||||
device = g_key_file_get_string(keyfile, group, "Device", NULL);
|
||||
if (!device)
|
||||
|
@ -82,62 +96,16 @@ static int set_device(struct ofono_modem *modem,
|
|||
|
||||
g_free(device);
|
||||
|
||||
value = g_key_file_get_string(keyfile, group, "Baud", NULL);
|
||||
if (value) {
|
||||
ofono_modem_set_string(modem, "Baud", value);
|
||||
g_free(value);
|
||||
} else
|
||||
ofono_modem_set_string(modem, "Baud", "115200");
|
||||
for (i = 0; tty_opts[i]; i++) {
|
||||
value = g_key_file_get_string(keyfile, group,
|
||||
tty_opts[i], NULL);
|
||||
|
||||
value = g_key_file_get_string(keyfile, group, "Read", NULL);
|
||||
if (value) {
|
||||
ofono_modem_set_string(modem, "Read", value);
|
||||
g_free(value);
|
||||
} else
|
||||
ofono_modem_set_string(modem, "Read", "on");
|
||||
if (value == NULL)
|
||||
continue;
|
||||
|
||||
value = g_key_file_get_string(keyfile, group, "Local", NULL);
|
||||
if (value) {
|
||||
ofono_modem_set_string(modem, "Local", value);
|
||||
ofono_modem_set_string(modem, tty_opts[i], value);
|
||||
g_free(value);
|
||||
} else
|
||||
ofono_modem_set_string(modem, "Local", "none");
|
||||
|
||||
value = g_key_file_get_string(keyfile, group, "StopBits", NULL);
|
||||
if (value) {
|
||||
ofono_modem_set_string(modem, "StopBits", value);
|
||||
g_free(value);
|
||||
} else
|
||||
ofono_modem_set_string(modem, "StopBits", "1");
|
||||
|
||||
value = g_key_file_get_string(keyfile, group, "DataBits", NULL);
|
||||
if (value) {
|
||||
ofono_modem_set_string(modem, "DataBits", value);
|
||||
g_free(value);
|
||||
} else
|
||||
ofono_modem_set_string(modem, "Databits", "8");
|
||||
|
||||
value = g_key_file_get_string(keyfile, group, "Parity", NULL);
|
||||
if (value) {
|
||||
ofono_modem_set_string(modem, "Parity", value);
|
||||
g_free(value);
|
||||
} else
|
||||
ofono_modem_set_string(modem, "Parity", "none");
|
||||
|
||||
value = g_key_file_get_string(keyfile, group, "XonXoff", NULL);
|
||||
if (value) {
|
||||
ofono_modem_set_string(modem, "XonXoff", value);
|
||||
g_free(value);
|
||||
} else
|
||||
ofono_modem_set_string(modem, "XonXoff", "off");
|
||||
|
||||
value = g_key_file_get_string(keyfile, group, "Rtscts", NULL);
|
||||
if (value) {
|
||||
ofono_modem_set_string(modem, "Rtscts", value);
|
||||
g_free(value);
|
||||
} else
|
||||
ofono_modem_set_string(modem, "Rtscts", "on");
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue