fix for register of AT driver
Hi All,
i recently noticed that the at driver did not reach the state "registered". marcel pointer me to the message
+CMER not supported by this modem. If this is an error please submit patches to support this hardware
and i started digging. problem was parsing of the response
+CMER: (0,3),(0,2),0,(0-1),0
that expresses the allowed options of CMER. neither (a list of) single integer "(0,3)" (in opposite to range "(0-1)") nor missing brackets "0" were supported by ofono so i added this (see patch).
i'm not sure if missing brackets are allowed or espress something different, maybe a AT-guru can tell. for now "(0)" behaves like "0".
i assume that also other response-parsing flows in ofono have that problem so either a generic aproach should be implemented or other places be reviewed.
marcel already pointer out that a generic aproach may be unnecessarily complex where i agree if it comes to strings and nested brackets but for plain integer cases it would be quite useful to get this done in one place for all. if interested i could implement such stuff into gatchat/gatresult.c which then can be used for the integer-only cases. what do you think?
regards,
michael
Signature · 1 line
M. Dietrich
Quoted 1 line
From
2328b03067a0d982ff2ca08f110ac4b0fa23002aMon Sep 17 00:00:00 2001
From: "M. Dietrich" <[email protected]>
Date: Sun, 30 Dec 2012 21:26:33 +0100
Subject: [PATCH] enhance parser for CMER response
--- drivers/atmodem/network-registration.c | 39 ++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 10 deletions(-)
drivers/atmodem/network-registration.c +29 -10
@@ -1615,26 +1615,45 @@ static void at_cmer_query_cb(ofono_bool_t ok, GAtResult *result,g_at_result_iter_init (&iter, result); -if (!g_at_result_iter_next (&iter,"+CMER:" )) +if (!g_at_result_iter_next (&iter,"+CMER:" )) { +DBG ("parsing error, probably begin tag not found" ); goto error; + }for (opt =0 ; opt < cmer_opts_cnt; opt++) {int min, max; -if (!g_at_result_iter_open_list (&iter)) - goto error; - -while (g_at_result_iter_next_range (&iter, &min, &max)) { -for (mode = min; mode <= max; mode++) - cmer_opts[opt] |=1 << mode; +if (!g_at_result_iter_open_list (&iter)) { + max =-1 ; +while (g_at_result_iter_next_number (&iter, &min)) { +if (max <0 ) + max = min; +for (mode = min; mode <= max; mode++) + cmer_opts[opt] |=1 << mode; + } } +else + { + max =-1 ; +while (g_at_result_iter_next_range (&iter, &min, &max) + ||g_at_result_iter_next_number (&iter, &min)) { +if (max <0 ) + max = min; +for (mode = min; mode <= max; mode++) + cmer_opts[opt] |=1 << mode; + } -if (!g_at_result_iter_close_list (&iter)) - goto error; +if (!g_at_result_iter_close_list (&iter)) { +DBG ("parsing error: end not found" ); + goto error; + } + } } -if (build_cmer_string (buf, cmer_opts, nd) == FALSE) +if (build_cmer_string (buf, cmer_opts, nd) == FALSE) { +DBG ("could not build cmer" ); goto error; + }g_at_chat_send (nd->chat, buf, cmer_prefix, at_cmer_set_cb, netreg,NULL );
Signature · 1 line
1.7.10.4