port-serial-at: use GIO Async API like methods

This commit is contained in:
Aleksander Morgado
2014-02-13 13:40:21 +01:00
parent 81ee07832d
commit d4dfd661b9
10 changed files with 276 additions and 211 deletions
+13 -6
View File
@@ -67,20 +67,22 @@ static void longcheer_custom_init_step (LongcheerCustomInitContext *ctx);
static void
gmr_ready (MMPortSerialAt *port,
GString *response,
GError *error,
GAsyncResult *res,
LongcheerCustomInitContext *ctx)
{
const gchar *p;
const gchar *response;
GError *error = NULL;
response = mm_port_serial_at_command_finish (port, res, &error);
if (error) {
/* Just retry... */
longcheer_custom_init_step (ctx);
return;
goto out;
}
/* Note the lack of a ':' on the GMR; the X200 doesn't send one */
p = mm_strip_tag (response->str, "AT+GMR");
p = mm_strip_tag (response, "AT+GMR");
if (p && *p == 'L') {
/* X200 modems have a GMR firmware revision that starts with 'L', and
* as far as I can tell X060s devices have a revision starting with 'C'.
@@ -98,6 +100,10 @@ gmr_ready (MMPortSerialAt *port,
}
longcheer_custom_init_context_complete_and_free (ctx);
out:
if (error)
g_error_free (error);
}
static void
@@ -124,13 +130,14 @@ longcheer_custom_init_step (LongcheerCustomInitContext *ctx)
}
ctx->retries--;
mm_port_serial_at_queue_command (
mm_port_serial_at_command (
ctx->port,
"AT+GMR",
3,
FALSE, /* raw */
FALSE, /* allow_cached */
ctx->cancellable,
(MMPortSerialAtResponseFn)gmr_ready,
(GAsyncReadyCallback)gmr_ready,
ctx);
}