diff options
author | Denis Kenzior <denkenz@gmail.com> | 2011-03-25 17:03:04 -0500 |
---|---|---|
committer | Denis Kenzior <denkenz@gmail.com> | 2011-03-28 18:06:59 -0500 |
commit | b6d62821585380b9218f26e027df84f07e89ccc8 (patch) | |
tree | 01f88125eccb14f239ea9c626798b361891227e9 /gatchat/gatsyntax.c | |
parent | 57faa0c9316b64f19218aed53c6b7786d463ec5d (diff) | |
download | ofono-b6d62821585380b9218f26e027df84f07e89ccc8.tar.gz |
gatsyntax: support short prompt for permissive
Diffstat (limited to 'gatchat/gatsyntax.c')
-rw-r--r-- | gatchat/gatsyntax.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/gatchat/gatsyntax.c b/gatchat/gatsyntax.c index 83aa5c0f..3e472d65 100644 --- a/gatchat/gatsyntax.c +++ b/gatchat/gatsyntax.c @@ -53,6 +53,8 @@ enum GSM_PERMISSIVE_STATE { GSM_PERMISSIVE_STATE_GUESS_PDU, GSM_PERMISSIVE_STATE_PDU, GSM_PERMISSIVE_STATE_PROMPT, + GSM_PERMISSIVE_STATE_GUESS_SHORT_PROMPT, + GSM_PERMISSIVE_STATE_SHORT_PROMPT, }; static void gsmv1_hint(GAtSyntax *syntax, GAtSyntaxExpectHint hint) @@ -242,6 +244,8 @@ static void gsm_permissive_hint(GAtSyntax *syntax, GAtSyntaxExpectHint hint) { if (hint == G_AT_SYNTAX_EXPECT_PDU) syntax->state = GSM_PERMISSIVE_STATE_GUESS_PDU; + else if (hint == G_AT_SYNTAX_EXPECT_SHORT_PROMPT) + syntax->state = GSM_PERMISSIVE_STATE_GUESS_SHORT_PROMPT; } static GAtSyntaxResult gsm_permissive_feed(GAtSyntax *syntax, @@ -306,6 +310,27 @@ static GAtSyntaxResult gsm_permissive_feed(GAtSyntax *syntax, syntax->state = GSM_PERMISSIVE_STATE_RESPONSE; return G_AT_SYNTAX_RESULT_UNSURE; + case GSM_PERMISSIVE_STATE_GUESS_SHORT_PROMPT: + if (byte == '\n') + /* ignore */; + else if (byte == '\r') + syntax->state = + GSM_PERMISSIVE_STATE_SHORT_PROMPT; + else + syntax->state = GSM_PERMISSIVE_STATE_RESPONSE; + break; + + case GSM_PERMISSIVE_STATE_SHORT_PROMPT: + if (byte == '\n') { + syntax->state = GSM_PERMISSIVE_STATE_IDLE; + i += 1; + res = G_AT_SYNTAX_RESULT_PROMPT; + goto out; + } + + syntax->state = GSM_PERMISSIVE_STATE_RESPONSE; + return G_AT_SYNTAX_RESULT_UNSURE; + default: break; }; |