summaryrefslogtreecommitdiffstats
path: root/unit/test-mux.c
diff options
context:
space:
mode:
authorDenis Kenzior <denkenz@gmail.com>2009-10-11 22:36:23 -0500
committerDenis Kenzior <denkenz@gmail.com>2009-10-15 16:15:16 -0500
commite4017db3bb8b5f37060e7e7610e121f66b39c636 (patch)
treede1de450ff41a6ad94527d8ee3a2e26f3b4ccfa7 /unit/test-mux.c
parent74f350aaf7ef9022799bebce790c7689c3bb6810 (diff)
downloadofono-e4017db3bb8b5f37060e7e7610e121f66b39c636.tar.bz2
Update unit test for the new API
Diffstat (limited to 'unit/test-mux.c')
-rw-r--r--unit/test-mux.c56
1 files changed, 48 insertions, 8 deletions
diff --git a/unit/test-mux.c b/unit/test-mux.c
index 8349fa2f..5116b712 100644
--- a/unit/test-mux.c
+++ b/unit/test-mux.c
@@ -63,11 +63,6 @@ static GAtMux *mux;
static gboolean cleanup_callback(gpointer data)
{
- GAtChat *chat = data;
-
- g_at_chat_shutdown(chat);
- g_at_chat_unref(chat);
-
g_at_mux_unref(mux);
g_main_loop_quit(mainloop);
@@ -75,6 +70,14 @@ static gboolean cleanup_callback(gpointer data)
return FALSE;
}
+static gboolean chat_cleanup(gpointer data)
+{
+ GAtChat *chat = data;
+
+ g_at_chat_shutdown(chat);
+ g_at_chat_unref(chat);
+}
+
static void chat_callback(gboolean ok, GAtResult *result, gpointer user_data)
{
GAtResultIter iter;
@@ -85,7 +88,7 @@ static void chat_callback(gboolean ok, GAtResult *result, gpointer user_data)
g_print("%s\n", g_at_result_final_response(result));
- g_idle_add(cleanup_callback, user_data);
+ g_idle_add(chat_cleanup, user_data);
}
static void mux_debug(const char *str, void *data)
@@ -93,12 +96,14 @@ static void mux_debug(const char *str, void *data)
g_print("%s: %s\n", (char *) data, str);
}
-static void mux_setup(GAtMux *mux, gpointer data)
+static void mux_setup(GAtMux *m, gpointer data)
{
GAtChat *chat = data;
GIOChannel *io;
GAtSyntax *syntax;
+ mux = m;
+
g_print("mux_setup: %p\n", mux);
if (mux == NULL) {
@@ -115,10 +120,45 @@ static void mux_setup(GAtMux *mux, gpointer data)
g_at_syntax_unref(syntax);
g_io_channel_unref(io);
- g_at_chat_set_debug(chat, mux_debug, "CHAT");
+ g_at_chat_set_debug(chat, mux_debug, "CHAT1");
+ g_at_chat_set_wakeup_command(chat, "\r", 1000, 5000);
+ g_at_chat_send(chat, "AT+CGMI", NULL, NULL, NULL, NULL);
+ g_at_chat_send(chat, "AT+CGMR", NULL, chat_callback, chat, NULL);
+
+ io = g_at_mux_create_channel(mux);
+ syntax = g_at_syntax_new_gsm_permissive();
+ chat = g_at_chat_new(io, syntax);
+ g_at_syntax_unref(syntax);
+ g_io_channel_unref(io);
+
+ g_at_chat_set_debug(chat, mux_debug, "CHAT2");
+ g_at_chat_set_wakeup_command(chat, "\r", 1000, 5000);
+ g_at_chat_send(chat, "AT+CGMI", NULL, NULL, NULL, NULL);
+ g_at_chat_send(chat, "AT+CGMR", NULL, chat_callback, chat, NULL);
+
+ io = g_at_mux_create_channel(mux);
+ syntax = g_at_syntax_new_gsm_permissive();
+ chat = g_at_chat_new(io, syntax);
+ g_at_syntax_unref(syntax);
+ g_io_channel_unref(io);
+
+ g_at_chat_set_debug(chat, mux_debug, "CHAT3");
g_at_chat_set_wakeup_command(chat, "\r", 1000, 5000);
g_at_chat_send(chat, "AT+CGMI", NULL, NULL, NULL, NULL);
g_at_chat_send(chat, "AT+CGMR", NULL, chat_callback, chat, NULL);
+
+ io = g_at_mux_create_channel(mux);
+ syntax = g_at_syntax_new_gsm_permissive();
+ chat = g_at_chat_new(io, syntax);
+ g_at_syntax_unref(syntax);
+ g_io_channel_unref(io);
+
+ g_at_chat_set_debug(chat, mux_debug, "CHAT4");
+ g_at_chat_set_wakeup_command(chat, "\r", 1000, 5000);
+ g_at_chat_send(chat, "AT+CGMI", NULL, NULL, NULL, NULL);
+ g_at_chat_send(chat, "AT+CGMR", NULL, chat_callback, chat, NULL);
+
+ g_timeout_add_seconds(7, cleanup_callback, NULL);
}
static void mux_init(gboolean ok, GAtResult *result, gpointer data)