Add option to phonesim to run with or without multiplexer

This commit is contained in:
Marcel Holtmann 2009-09-08 09:24:52 +02:00
parent 154102e873
commit c155a91313
2 changed files with 39 additions and 1 deletions

View File

@ -60,6 +60,12 @@ static int set_address(struct ofono_modem *modem,
g_free(value);
}
value = g_key_file_get_string(keyfile, group, "Multiplexer", NULL);
if (value) {
ofono_modem_set_string(modem, "Multiplexer", value);
g_free(value);
}
return 0;
}

View File

@ -32,6 +32,7 @@
#include <arpa/inet.h>
#include <glib.h>
#include <gatmux.h>
#include <gatchat.h>
#define OFONO_API_SUBJECT_TO_CHANGE
@ -55,8 +56,10 @@
#include <drivers/atmodem/vendor.h>
struct phonesim_data {
GAtMux *mux;
GAtChat *chat;
gboolean calypso;
gboolean use_mux;
};
static int phonesim_probe(struct ofono_modem *modem)
@ -122,6 +125,10 @@ static int phonesim_enable(struct ofono_modem *modem)
if (!g_strcmp0(value, "calypso"))
data->calypso = TRUE;
value = ofono_modem_get_string(modem, "Multiplexer");
if (!g_strcmp0(value, "internal"))
data->use_mux = TRUE;
sk = socket(PF_INET, SOCK_STREAM, 0);
if (sk < 0)
return -EINVAL;
@ -143,15 +150,33 @@ static int phonesim_enable(struct ofono_modem *modem)
return -ENOMEM;
}
if (data->use_mux) {
data->mux = g_at_mux_new(io);
if (!data->mux)
return -ENOMEM;
if (getenv("OFONO_AT_DEBUG"))
g_at_mux_set_debug(data->mux, phonesim_debug, NULL);
}
if (data->calypso)
syntax = g_at_syntax_new_gsm_permissive();
else
syntax = g_at_syntax_new_gsmv1();
data->chat = g_at_chat_new(io, syntax);
if (data->mux)
data->chat = g_at_mux_create_chat(data->mux, syntax);
else
data->chat = g_at_chat_new(io, syntax);
g_at_syntax_unref(syntax);
if (!data->chat) {
if (data->mux) {
g_at_mux_unref(data->mux);
data->mux = NULL;
}
g_io_channel_unref(io);
return -ENOMEM;
}
@ -186,6 +211,13 @@ static int phonesim_disable(struct ofono_modem *modem)
g_at_chat_unref(data->chat);
data->chat = NULL;
if (data->mux) {
g_at_mux_shutdown(data->mux);
g_at_mux_unref(data->mux);
data->mux = NULL;
}
return 0;
}