add support of void parameters in CMER
v2 cover add support of void parameters in CMER
following commands are supported :
AT+CMER=3,0,0,1,0
OK
AT+CMER=3,0,0,1
OK
AT+CMER=3,,,1
OK
AT+CMER=3,,,1,
OK
AT+CMER=,,0,1,
OK
AT+CMER=3, ,,1
OK
AT+CMER=3,a,0,1
ERROR
AT+CMER=3,"a",0,1
ERROR
AT+CMER=3,
OK
AT+CMER=3
OK
Frédéric Danis (2):
gatchat: add g_at_result_iter_next_number_default API
emulator: add support of void parameters in CMER
gatchat/gatresult.c | 30 ++++++++++++++++++++++++++++++ gatchat/gatresult.h | 2 ++ src/emulator.c | 24 ++++++++++++------------ 3 files changed, 44 insertions(+), 12 deletions(-)
PATCH v2 1/2 gatchat: add g_at_result_iter_next_number_default API
--- gatchat/gatresult.c | 30 ++++++++++++++++++++++++++++++ gatchat/gatresult.h | 2 ++ 2 files changed, 32 insertions(+), 0 deletions(-)
gatchat/gatresult.c +30 -0
@@ -292,6 +292,36 @@ gboolean g_at_result_iter_next_number(GAtResultIter *iter, gint *number)return TRUE; } +gboolean g_at_result_iter_next_number_default (GAtResultIter *iter,gint dflt, +gint *number) +{ +unsigned int pos; +int len; +char *line; + +if (iter ==NULL ) +return FALSE; + +if (iter->l ==NULL ) +return FALSE; + + line = iter->l->data; + len =strlen (line); + + pos =skip_to_next_field (line, iter->line_pos, len); + +if (pos != iter->line_pos) { + iter->line_pos = pos; + +if (number) + *number = dflt; + +return TRUE; + } + +return g_at_result_iter_next_number (iter, number); +} +gboolean g_at_result_iter_next_range (GAtResultIter *iter,gint *min,gint *max) {int pos;
gatchat/gatresult.h +2 -0
@@ -58,6 +58,8 @@ gboolean g_at_result_iter_next_string(GAtResultIter *iter, const char **str);gboolean g_at_result_iter_next_unquoted_string (GAtResultIter *iter,const char **str);gboolean g_at_result_iter_next_number (GAtResultIter *iter,gint *number); +gboolean g_at_result_iter_next_number_default (GAtResultIter *iter,gint dflt, +gint *number);gboolean g_at_result_iter_next_hexstring (GAtResultIter *iter,const guint8 **str,gint *length);
Signature · 1 line
1.7.1
PATCH v2 2/2 emulator: add support of void parameters in CMER
In reply to Frédéric Danis--- src/emulator.c | 24 ++++++++++++------------ 1 files changed, 12 insertions(+), 12 deletions(-)
src/emulator.c +12 -12
@@ -312,7 +312,7 @@ static void cmer_cb(GAtServer *server, GAtServerRequestType type,case G_AT_SERVER_REQUEST_TYPE_SET : {GAtResultIter iter; -int mode; +int mode = em->events_mode;int ind = em->events_ind;int val;
@@ -320,15 +320,15 @@ static void cmer_cb(GAtServer *server, GAtServerRequestType type,g_at_result_iter_next (&iter,"" );/* mode */ -if (g_at_result_iter_next_number (&iter, &mode) == FALSE) +if (!g_at_result_iter_next_number_default (&iter, mode, &mode)) goto fail;if (mode !=0 && mode !=3 ) goto fail;/* keyp */ -if (g_at_result_iter_next_number (&iter, &val) == FALSE) { -if (g_at_result_iter_skip_next (&iter) == FALSE) +if (!g_at_result_iter_next_number_default (&iter,0 , &val)) { +if (!g_at_result_iter_skip_next (&iter)) goto done; goto fail; }
@@ -337,8 +337,8 @@ static void cmer_cb(GAtServer *server, GAtServerRequestType type, goto fail;/* disp */ -if (g_at_result_iter_next_number (&iter, &val) == FALSE) { -if (g_at_result_iter_skip_next (&iter) == FALSE) +if (!g_at_result_iter_next_number_default (&iter,0 , &val)) { +if (!g_at_result_iter_skip_next (&iter)) goto done; goto fail; }
@@ -347,18 +347,18 @@ static void cmer_cb(GAtServer *server, GAtServerRequestType type, goto fail;/* ind */ -if (g_at_result_iter_next_number (&iter, &ind) == FALSE) { -if (g_at_result_iter_skip_next (&iter) == FALSE) +if (!g_at_result_iter_next_number_default (&iter, ind, &ind)) { +if (!g_at_result_iter_skip_next (&iter)) goto done; goto fail; } -if ((ind !=0 ) && (ind !=1 )) +if (ind !=0 && ind !=1 ) goto fail;/* bfr */ -if (g_at_result_iter_next_number (&iter, &val) == FALSE) { -if (g_at_result_iter_skip_next (&iter) == FALSE) +if (!g_at_result_iter_next_number_default (&iter,0 , &val)) { +if (!g_at_result_iter_skip_next (&iter)) goto done; goto fail; }
@@ -367,7 +367,7 @@ static void cmer_cb(GAtServer *server, GAtServerRequestType type, goto fail;/* check that bfr is last parameter */ -if (g_at_result_iter_skip_next (&iter) == TRUE) +if (g_at_result_iter_skip_next (&iter)) goto fail; done:
Signature · 1 line
1.7.1
Hi Frédéric,
Quoted 32 lines · Frédéric Danis
following commands are supported :
AT+CMER=3,0,0,1,0OK
AT+CMER=3,0,0,1OK
AT+CMER=3,,,1OK
AT+CMER=3,,,1,OK
AT+CMER=,,0,1,OK
AT+CMER=3, ,,1OK
AT+CMER=3,a,0,1ERROR
AT+CMER=3,"a",0,1ERROR
AT+CMER=3,OK
AT+CMER=3OK
Quoted 9 lines
Frédéric Danis (2):
gatchat: addg_at_result_iter_next_number_defaultAPI
emulator: add support of void parameters in CMERgatchat/gatresult.c | 30 ++++++++++++++++++++++++++++++ gatchat/gatresult.h | 2 ++ src/emulator.c | 24 ++++++++++++------------ 3 files changed, 44 insertions(+), 12 deletions(-)
Both patches have been applied, thanks.
Regards,
-Denis