aboutsummaryrefslogtreecommitdiff
path: root/src/mm-base-modem-at.h
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2020-06-28 14:05:58 +0200
committerAleksander Morgado <aleksander@aleksander.es>2020-06-28 15:07:34 +0200
commit4b37b7d3cfd8c8e98af25eed334b1880b6b6c597 (patch)
treeabff683b28c0ffda31b0974107cd4d2b1d93fcbe /src/mm-base-modem-at.h
parentc4d82aaf1e7cf10475204102533ac7784f83f0d3 (diff)
base-modem,at: response processors return a more specific enum
Instead of using the FALSE return of the method to indicate either a fatal error (if result_error was set) or the continuation request (if result_error wasn't set), provide a enum that has explicit states for all three possible values (failure, success or continue).
Diffstat (limited to 'src/mm-base-modem-at.h')
-rw-r--r--src/mm-base-modem-at.h112
1 files changed, 66 insertions, 46 deletions
diff --git a/src/mm-base-modem-at.h b/src/mm-base-modem-at.h
index f5f0601e..770c0e4b 100644
--- a/src/mm-base-modem-at.h
+++ b/src/mm-base-modem-at.h
@@ -21,19 +21,25 @@
#include "mm-base-modem.h"
#include "mm-port-serial-at.h"
+typedef enum {
+ MM_BASE_MODEM_AT_RESPONSE_PROCESSOR_RESULT_CONTINUE,
+ MM_BASE_MODEM_AT_RESPONSE_PROCESSOR_RESULT_SUCCESS,
+ MM_BASE_MODEM_AT_RESPONSE_PROCESSOR_RESULT_FAILURE,
+} MMBaseModemAtResponseProcessorResult;
+
/*
* The expected result depends on the specific operation, so the GVariant
* created by the response processor needs to match the one expected in
* finish().
*
- * TRUE must be returned when the operation is to be considered successful,
+ * SUCCESS must be returned when the operation is to be considered successful,
* and a result may be given.
*
- * FALSE must be returned when:
- * - A GError is propagated into result_error, which will be treated as a
- * critical error and therefore the operation will be aborted.
- * - When no result_error is given, to instruct the operation to go on with
- * the next scheduled command.
+ * FAILURE must be returned when a GError is propagated into result_error,
+ * which will be treated as a critical error and therefore the operation will be aborted.
+ *
+ * CONTINUE must be returned when neither result nor result_error are given and
+ * the operation should go on with the next scheduled command.
*
* This setup, therefore allows:
* - Running a single command and processing its result.
@@ -42,14 +48,14 @@
* - Running a set of N commands out of M (N<M), where the global result is
* obtained without having executed all configured commands.
*/
-typedef gboolean (* MMBaseModemAtResponseProcessor) (MMBaseModem *self,
- gpointer response_processor_context,
- const gchar *command,
- const gchar *response,
- gboolean last_command,
- const GError *error,
- GVariant **result,
- GError **result_error);
+typedef MMBaseModemAtResponseProcessorResult (* MMBaseModemAtResponseProcessor) (MMBaseModem *self,
+ gpointer response_processor_context,
+ const gchar *command,
+ const gchar *response,
+ gboolean last_command,
+ const GError *error,
+ GVariant **result,
+ GError **result_error);
/* Struct to configure AT command operations (constant) */
typedef struct {
@@ -98,28 +104,28 @@ GVariant *mm_base_modem_at_sequence_full_finish (MMBaseModem *self,
* failure in the command triggers a failure in the sequence. If successful,
* provides the output result as a STRING.
*/
-gboolean mm_base_modem_response_processor_string (MMBaseModem *self,
- gpointer none,
- const gchar *command,
- const gchar *response,
- gboolean last_command,
- const GError *error,
- GVariant **result,
- GError **result_error);
+MMBaseModemAtResponseProcessorResult mm_base_modem_response_processor_string (MMBaseModem *self,
+ gpointer none,
+ const gchar *command,
+ const gchar *response,
+ gboolean last_command,
+ const GError *error,
+ GVariant **result,
+ GError **result_error);
/*
* Response processor for commands that are treated as MANDATORY, where a
* failure in the command triggers a failure in the sequence. If successful,
* provides the output result as a BOOLEAN.
*/
-gboolean mm_base_modem_response_processor_no_result (MMBaseModem *self,
- gpointer none,
- const gchar *command,
- const gchar *response,
- gboolean last_command,
- const GError *error,
- GVariant **result,
- GError **result_error);
+MMBaseModemAtResponseProcessorResult mm_base_modem_response_processor_no_result (MMBaseModem *self,
+ gpointer none,
+ const gchar *command,
+ const gchar *response,
+ gboolean last_command,
+ const GError *error,
+ GVariant **result,
+ GError **result_error);
/*
* Response processor for commands that are treated as MANDATORY, where a
@@ -129,14 +135,14 @@ gboolean mm_base_modem_response_processor_no_result (MMBaseModem *self,
* E.g. used when we provide a list of commands and we want to run all of
* them successfully, and fail the sequence if one of them fails.
*/
-gboolean mm_base_modem_response_processor_no_result_continue (MMBaseModem *self,
- gpointer none,
- const gchar *command,
- const gchar *response,
- gboolean last_command,
- const GError *error,
- GVariant **result,
- GError **result_error);
+MMBaseModemAtResponseProcessorResult mm_base_modem_response_processor_no_result_continue (MMBaseModem *self,
+ gpointer none,
+ const gchar *command,
+ const gchar *response,
+ gboolean last_command,
+ const GError *error,
+ GVariant **result,
+ GError **result_error);
/*
* Response processor for commands that are treated as OPTIONAL, where a
@@ -146,15 +152,29 @@ gboolean mm_base_modem_response_processor_no_result_continue (MMBaseModem *sel
* E.g. used when we provide a list of commands and we want to stop
* as soon as one of them doesn't fail.
*/
-gboolean mm_base_modem_response_processor_continue_on_error (MMBaseModem *self,
- gpointer none,
- const gchar *command,
- const gchar *response,
- gboolean last_command,
- const GError *error,
- GVariant **result,
- GError **result_error);
+MMBaseModemAtResponseProcessorResult mm_base_modem_response_processor_continue_on_error (MMBaseModem *self,
+ gpointer none,
+ const gchar *command,
+ const gchar *response,
+ gboolean last_command,
+ const GError *error,
+ GVariant **result,
+ GError **result_error);
+/*
+ * Response processor for commands that are partialy treated as OPTIONAL, where
+ * a failure in the command triggers a failure in the sequence only for non-AT
+ * generic errors. If successful, it finishes the sequence with the response of
+ * the command which didn't fail.
+ */
+MMBaseModemAtResponseProcessorResult mm_base_modem_response_processor_string_ignore_at_errors (MMBaseModem *self,
+ gpointer none,
+ const gchar *command,
+ const gchar *response,
+ gboolean last_command,
+ const GError *error,
+ GVariant **result,
+ GError **result_error);
/* Generic AT command handling, using the best AT port available and without
* explicit cancellations. */