summaryrefslogtreecommitdiffstats
path: root/gatchat/gsmdial.c
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2010-04-11 18:23:24 +0200
committerMarcel Holtmann <marcel@holtmann.org>2010-04-11 18:23:24 +0200
commit156904535ed21e974de3f7483249e0e8ff115eca (patch)
tree08404553d2582904ca0dd91bcdb915c00e13f224 /gatchat/gsmdial.c
parent3187e46799d031fde4426ba34c531bc20ec882f0 (diff)
downloadofono-156904535ed21e974de3f7483249e0e8ff115eca.tar.bz2
Check for PIN after activating the modem
Diffstat (limited to 'gatchat/gsmdial.c')
-rw-r--r--gatchat/gsmdial.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/gatchat/gsmdial.c b/gatchat/gsmdial.c
index cc324646..02d01f39 100644
--- a/gatchat/gsmdial.c
+++ b/gatchat/gsmdial.c
@@ -425,7 +425,7 @@ static void register_cb(gboolean ok, GAtResult *result, gpointer user_data)
static void start_dial(gboolean ok, GAtResult *result, gpointer user_data)
{
if (!ok) {
- g_print("Turning on the modem failed\n");
+ g_print("Checking PIN status failed\n");
exit(1);
}
@@ -436,6 +436,16 @@ static void start_dial(gboolean ok, GAtResult *result, gpointer user_data)
register_cb, NULL, NULL);
}
+static void check_pin(gboolean ok, GAtResult *result, gpointer user_data)
+{
+ if (!ok) {
+ g_print("Turning on the modem failed\n");
+ exit(1);
+ }
+
+ g_at_chat_send(control, "AT+CPIN?", NULL, start_dial, NULL, NULL);
+}
+
static void check_mode(gboolean ok, GAtResult *result, gpointer user_data)
{
GAtResultIter iter;
@@ -452,11 +462,11 @@ static void check_mode(gboolean ok, GAtResult *result, gpointer user_data)
g_print("Current modem mode is %d\n", oldmode);
if (oldmode == 1) {
- start_dial(ok, result, user_data);
+ check_pin(ok, result, user_data);
return;
}
- g_at_chat_send(control, "AT+CFUN=1", NULL, start_dial, NULL, NULL);
+ g_at_chat_send(control, "AT+CFUN=1", NULL, check_pin, NULL, NULL);
}
static int open_serial()
@@ -651,7 +661,6 @@ int main(int argc, char **argv)
event_loop = g_main_loop_new(NULL, FALSE);
g_at_chat_send(control, "ATE0Q0V1", NULL, NULL, NULL, NULL);
- g_at_chat_send(control, "AT+CPIN?", NULL, NULL, NULL, NULL);
g_at_chat_send(control, "AT+CFUN?", cfun_prefix,
check_mode, NULL, NULL);