diff options
author | Denis Kenzior <denis.kenzior@intel.com> | 2009-09-04 13:26:12 -0500 |
---|---|---|
committer | Denis Kenzior <denkenz@gmail.com> | 2009-09-04 20:37:48 -0500 |
commit | 85cbb8bfe9a36d3875c7242df8f75709b6ba49fa (patch) | |
tree | 1530c4efaf6aa4c7ccc18d344cc6ac7bba289629 /plugins | |
parent | 740312f8fb7525d2a2f9363dc4634aa3052edd68 (diff) | |
download | ofono-85cbb8bfe9a36d3875c7242df8f75709b6ba49fa.tar.bz2 |
Make G1 driver use the permissive parser
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/g1.c | 86 |
1 files changed, 1 insertions, 85 deletions
diff --git a/plugins/g1.c b/plugins/g1.c index 6b7ff9fa..8229ec53 100644 --- a/plugins/g1.c +++ b/plugins/g1.c @@ -49,90 +49,6 @@ #include <drivers/atmodem/vendor.h> -/* Supply our own syntax parser */ - -enum G1_STATE_ { - G1_STATE_IDLE = 0, - G1_STATE_RESPONSE, - G1_STATE_GUESS_PDU, - G1_STATE_PDU, - G1_STATE_PROMPT, -}; - -static void g1_hint(GAtSyntax *syntax, GAtSyntaxExpectHint hint) -{ - if (hint == G_AT_SYNTAX_EXPECT_PDU) - syntax->state = G1_STATE_GUESS_PDU; -} - -static GAtSyntaxResult g1_feed(GAtSyntax *syntax, - const char *bytes, gsize *len) -{ - gsize i = 0; - GAtSyntaxResult res = G_AT_SYNTAX_RESULT_UNSURE; - - while (i < *len) { - char byte = bytes[i]; - - switch (syntax->state) { - case G1_STATE_IDLE: - if (byte == '\r' || byte == '\n') - /* ignore */; - else if (byte == '>') - syntax->state = G1_STATE_PROMPT; - else - syntax->state = G1_STATE_RESPONSE; - break; - - case G1_STATE_RESPONSE: - if (byte == '\r') { - syntax->state = G1_STATE_IDLE; - - i += 1; - res = G_AT_SYNTAX_RESULT_LINE; - goto out; - } - break; - - case G1_STATE_GUESS_PDU: - /* keep going until we find a LF that leads the PDU */ - if (byte == '\n') - syntax->state = G1_STATE_PDU; - break; - - case G1_STATE_PDU: - if (byte == '\r') { - syntax->state = G1_STATE_IDLE; - - i += 1; - res = G_AT_SYNTAX_RESULT_PDU; - goto out; - } - break; - - case G1_STATE_PROMPT: - if (byte == ' ') { - syntax->state = G1_STATE_IDLE; - i += 1; - res = G_AT_SYNTAX_RESULT_PROMPT; - goto out; - } - - syntax->state = G1_STATE_RESPONSE; - return G_AT_SYNTAX_RESULT_UNSURE; - - default: - break; - }; - - i += 1; - } - -out: - *len = i; - return res; -} - static void g1_debug(const char *str, void *data) { DBG("%s", str); @@ -151,7 +67,7 @@ static int g1_probe(struct ofono_modem *modem) if (device == NULL) return -EINVAL; - syntax = g_at_syntax_new_full(g1_feed, g1_hint, G1_STATE_IDLE); + syntax = g_at_syntax_new_gsm_permissive(); chat = g_at_chat_new_from_tty(device, syntax); g_at_syntax_unref(syntax); |