diff options
Diffstat (limited to 'src/mm-base-modem-at.c')
-rw-r--r-- | src/mm-base-modem-at.c | 44 |
1 files changed, 34 insertions, 10 deletions
diff --git a/src/mm-base-modem-at.c b/src/mm-base-modem-at.c index ed354063..cc2bc5a0 100644 --- a/src/mm-base-modem-at.c +++ b/src/mm-base-modem-at.c @@ -91,8 +91,13 @@ typedef struct { gpointer response_processor_context; GDestroyNotify response_processor_context_free; GVariant *result; + guint next_command_wait_id; } AtSequenceContext; +static void at_sequence_parse_response (MMPortSerialAt *port, + GAsyncResult *res, + GTask *task); + static void at_sequence_context_free (AtSequenceContext *ctx) { @@ -109,6 +114,11 @@ at_sequence_context_free (AtSequenceContext *ctx) g_object_unref (ctx->parent_cancellable); } + if (ctx->next_command_wait_id > 0) { + g_source_remove (ctx->next_command_wait_id); + ctx->next_command_wait_id = 0; + } + if (ctx->result) g_variant_unref (ctx->result); g_free (ctx); @@ -140,6 +150,28 @@ mm_base_modem_at_sequence_full_finish (MMBaseModem *self, return result; } +static gboolean +at_sequence_next_command (GTask *task) +{ + AtSequenceContext *ctx; + + ctx = g_task_get_task_data (task); + ctx->next_command_wait_id = 0; + + /* Schedule the next command in the probing group */ + mm_port_serial_at_command ( + ctx->port, + ctx->current->command, + ctx->current->timeout, + FALSE, + ctx->current->allow_cached, + g_task_get_cancellable (task), + (GAsyncReadyCallback)at_sequence_parse_response, + task); + + return G_SOURCE_REMOVE; +} + static void at_sequence_parse_response (MMPortSerialAt *port, GAsyncResult *res, @@ -201,16 +233,8 @@ at_sequence_parse_response (MMPortSerialAt *port, if (processor_result == MM_BASE_MODEM_AT_RESPONSE_PROCESSOR_RESULT_CONTINUE) { ctx->current++; if (ctx->current->command) { - /* Schedule the next command in the probing group */ - mm_port_serial_at_command ( - ctx->port, - ctx->current->command, - ctx->current->timeout, - FALSE, - ctx->current->allow_cached, - g_task_get_cancellable (task), - (GAsyncReadyCallback)at_sequence_parse_response, - task); + g_assert (!ctx->next_command_wait_id); + ctx->next_command_wait_id = g_timeout_add_seconds (ctx->current->wait_seconds, (GSourceFunc) at_sequence_next_command, task); return; } /* On last command, end. */ |