diff options
author | Aleksander Morgado <aleksander@lanedo.com> | 2013-04-09 12:29:03 +0200 |
---|---|---|
committer | Aleksander Morgado <aleksander@lanedo.com> | 2013-04-09 12:43:42 +0200 |
commit | 0f63737460a99dd91f9e177568f83f61c779ef6e (patch) | |
tree | 30bcf07fe0821bead690258c54c7505513a820f1 | |
parent | 664636ed36c4bb3f6b6b6c275fdee595f806004c (diff) |
modem-helpers: new +CGPADDR parser
-rw-r--r-- | src/mm-modem-helpers.c | 31 | ||||
-rw-r--r-- | src/mm-modem-helpers.h | 5 |
2 files changed, 36 insertions, 0 deletions
diff --git a/src/mm-modem-helpers.c b/src/mm-modem-helpers.c index 9652c6f4..80924f00 100644 --- a/src/mm-modem-helpers.c +++ b/src/mm-modem-helpers.c @@ -1102,6 +1102,37 @@ mm_3gpp_parse_cscs_test_response (const gchar *reply, /*************************************************************************/ gboolean +mm_3gpp_parse_cgpaddr_write_response (const gchar *reply, + guint *cid, + gchar **ip) +{ + GRegex *r; + GMatchInfo *match_info; + gboolean success = FALSE; + + g_return_val_if_fail (reply != NULL, FALSE); + g_return_val_if_fail (cid != NULL, FALSE); + g_return_val_if_fail (ip != NULL, FALSE); + + r = g_regex_new ("\\+CGPADDR:\\s*(\\d+)\\s*,\\s*\"(.*)\"", + G_REGEX_OPTIMIZE | G_REGEX_RAW, + 0, NULL); + g_assert (r != NULL); + + if (g_regex_match (r, reply, 0, &match_info)) { + if (mm_get_uint_from_match_info (match_info, 1, cid) && + (*ip = mm_get_string_unquoted_from_match_info (match_info, 2)) != NULL) + success = TRUE; + } + g_match_info_free (match_info); + g_regex_unref (r); + + return success; +} + +/*************************************************************************/ + +gboolean mm_3gpp_parse_clck_test_response (const gchar *reply, MMModem3gppFacility *out_facilities) { diff --git a/src/mm-modem-helpers.h b/src/mm-modem-helpers.h index eb02337e..47091925 100644 --- a/src/mm-modem-helpers.h +++ b/src/mm-modem-helpers.h @@ -125,6 +125,11 @@ gboolean mm_3gpp_parse_cpms_test_response (const gchar *reply, gboolean mm_3gpp_parse_cscs_test_response (const gchar *reply, MMModemCharset *out_charsets); +/* AT+CGPADDR=X (IP address) response parser */ +gboolean mm_3gpp_parse_cgpaddr_write_response (const gchar *reply, + guint *cid, + gchar **ip); + /* AT+CLCK=? (Supported locks) response parser */ gboolean mm_3gpp_parse_clck_test_response (const gchar *reply, MMModem3gppFacility *out_facilities); |