aboutsummaryrefslogtreecommitdiff
path: root/plugins
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 /plugins
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 'plugins')
-rw-r--r--plugins/altair/mm-broadband-modem-altair-lte.c27
-rw-r--r--plugins/huawei/mm-broadband-modem-huawei.c22
-rw-r--r--plugins/icera/mm-broadband-modem-icera.c29
-rw-r--r--plugins/novatel/mm-broadband-modem-novatel-lte.c61
-rw-r--r--plugins/sierra/mm-broadband-modem-sierra.c28
-rw-r--r--plugins/telit/mm-broadband-modem-telit.c81
6 files changed, 131 insertions, 117 deletions
diff --git a/plugins/altair/mm-broadband-modem-altair-lte.c b/plugins/altair/mm-broadband-modem-altair-lte.c
index 54702172..9e555f5b 100644
--- a/plugins/altair/mm-broadband-modem-altair-lte.c
+++ b/plugins/altair/mm-broadband-modem-altair-lte.c
@@ -857,30 +857,11 @@ modem_3gpp_cleanup_unsolicited_events (MMIfaceModem3gpp *self,
/*****************************************************************************/
/* Enabling unsolicited events (3GPP interface) */
-static gboolean
-response_processor_no_result_stop_on_error (MMBaseModem *self,
- gpointer none,
- const gchar *command,
- const gchar *response,
- gboolean last_command,
- const GError *error,
- GVariant **result,
- GError **result_error)
-{
- if (error) {
- *result_error = g_error_copy (error);
- return TRUE;
- }
-
- *result = NULL;
- return FALSE;
-}
-
static const MMBaseModemAtCommand unsolicited_events_enable_sequence[] = {
- { "%STATCM=1", 10, FALSE, response_processor_no_result_stop_on_error },
- { "%NOTIFYEV=\"SIMREFRESH\",1", 10, FALSE, NULL },
- { "%PCOINFO=1", 10, FALSE, NULL },
- { NULL }
+ { "%STATCM=1", 10, FALSE, mm_base_modem_response_processor_no_result_continue },
+ { "%NOTIFYEV=\"SIMREFRESH\",1", 10, FALSE, NULL },
+ { "%PCOINFO=1", 10, FALSE, NULL },
+ { NULL }
};
static gboolean
diff --git a/plugins/huawei/mm-broadband-modem-huawei.c b/plugins/huawei/mm-broadband-modem-huawei.c
index a676b7a7..82e439e1 100644
--- a/plugins/huawei/mm-broadband-modem-huawei.c
+++ b/plugins/huawei/mm-broadband-modem-huawei.c
@@ -4137,15 +4137,15 @@ modem_time_check_ready (MMBaseModem *_self,
g_object_unref (task);
}
-static gboolean
-modem_check_time_reply (MMBaseModem *_self,
- gpointer none,
- const gchar *command,
- const gchar *response,
- gboolean last_command,
- const GError *error,
- GVariant **result,
- GError **result_error)
+static MMBaseModemAtResponseProcessorResult
+modem_check_time_reply (MMBaseModem *_self,
+ gpointer none,
+ const gchar *command,
+ const gchar *response,
+ gboolean last_command,
+ const GError *error,
+ GVariant **result,
+ GError **result_error)
{
MMBroadbandModemHuawei *self = MM_BROADBAND_MODEM_HUAWEI (_self);
@@ -4161,7 +4161,9 @@ modem_check_time_reply (MMBaseModem *_self,
self->priv->time_support = FEATURE_NOT_SUPPORTED;
}
- return FALSE;
+ *result = NULL;
+ *result_error = NULL;
+ return MM_BASE_MODEM_AT_RESPONSE_PROCESSOR_RESULT_CONTINUE;
}
static const MMBaseModemAtCommand time_cmd_sequence[] = {
diff --git a/plugins/icera/mm-broadband-modem-icera.c b/plugins/icera/mm-broadband-modem-icera.c
index b459cb57..ebaac9ad 100644
--- a/plugins/icera/mm-broadband-modem-icera.c
+++ b/plugins/icera/mm-broadband-modem-icera.c
@@ -1223,18 +1223,21 @@ load_supported_bands_ready (MMBaseModem *self,
g_object_unref (task);
}
-static gboolean
-load_supported_bands_response_processor (MMBaseModem *self,
- gpointer context,
- const gchar *command,
- const gchar *response,
- gboolean last_command,
- const GError *error,
- GVariant **result,
- GError **result_error)
-{
- SupportedBandsContext *ctx = context;
- Band *b = g_slist_nth_data (ctx->check_bands, ctx->idx++);
+static MMBaseModemAtResponseProcessorResult
+load_supported_bands_response_processor (MMBaseModem *self,
+ gpointer context,
+ const gchar *command,
+ const gchar *response,
+ gboolean last_command,
+ const GError *error,
+ GVariant **result,
+ GError **result_error)
+{
+ SupportedBandsContext *ctx;
+ Band *b;
+
+ ctx = context;
+ b = g_slist_nth_data (ctx->check_bands, ctx->idx++);
/* If there was no error setting the band, that band is supported. We
* abuse the 'enabled' item to mean supported/unsupported.
@@ -1242,7 +1245,7 @@ load_supported_bands_response_processor (MMBaseModem *self,
b->enabled = !error;
/* Continue to next band */
- return FALSE;
+ return MM_BASE_MODEM_AT_RESPONSE_PROCESSOR_RESULT_CONTINUE;
}
static void
diff --git a/plugins/novatel/mm-broadband-modem-novatel-lte.c b/plugins/novatel/mm-broadband-modem-novatel-lte.c
index ebcbe499..df331381 100644
--- a/plugins/novatel/mm-broadband-modem-novatel-lte.c
+++ b/plugins/novatel/mm-broadband-modem-novatel-lte.c
@@ -184,54 +184,65 @@ load_own_numbers_finish (MMIfaceModem *self,
return own_numbers;
}
-static gboolean
-response_processor_cnum_ignore_at_errors (MMBaseModem *self,
- gpointer none,
- const gchar *command,
- const gchar *response,
- gboolean last_command,
- const GError *error,
- GVariant **result,
- GError **result_error)
+static MMBaseModemAtResponseProcessorResult
+response_processor_cnum_ignore_at_errors (MMBaseModem *self,
+ gpointer none,
+ const gchar *command,
+ const gchar *response,
+ gboolean last_command,
+ const GError *error,
+ GVariant **result,
+ GError **result_error)
{
GStrv own_numbers;
+ *result = NULL;
+ *result_error = NULL;
+
if (error) {
/* Ignore AT errors (ie, ERROR or CMx ERROR) */
- if (error->domain != MM_MOBILE_EQUIPMENT_ERROR || last_command)
+ if (error->domain != MM_MOBILE_EQUIPMENT_ERROR || last_command) {
*result_error = g_error_copy (error);
+ return MM_BASE_MODEM_AT_RESPONSE_PROCESSOR_RESULT_FAILURE;
+ }
- return FALSE;
+ return MM_BASE_MODEM_AT_RESPONSE_PROCESSOR_RESULT_CONTINUE;
}
own_numbers = mm_3gpp_parse_cnum_exec_response (response);
if (!own_numbers)
- return FALSE;
+ return MM_BASE_MODEM_AT_RESPONSE_PROCESSOR_RESULT_CONTINUE;
*result = g_variant_new_strv ((const gchar *const *) own_numbers, -1);
g_strfreev (own_numbers);
- return TRUE;
+ return MM_BASE_MODEM_AT_RESPONSE_PROCESSOR_RESULT_SUCCESS;
}
-static gboolean
-response_processor_nwmdn_ignore_at_errors (MMBaseModem *self,
- gpointer none,
- const gchar *command,
- const gchar *response,
- gboolean last_command,
- const GError *error,
- GVariant **result,
- GError **result_error)
+static MMBaseModemAtResponseProcessorResult
+response_processor_nwmdn_ignore_at_errors (MMBaseModem *self,
+ gpointer none,
+ const gchar *command,
+ const gchar *response,
+ gboolean last_command,
+ const GError *error,
+ GVariant **result,
+ GError **result_error)
{
g_auto(GStrv) own_numbers = NULL;
GPtrArray *array;
gchar *mdn;
+ *result = NULL;
+ *result_error = NULL;
+
if (error) {
/* Ignore AT errors (ie, ERROR or CMx ERROR) */
- if (error->domain != MM_MOBILE_EQUIPMENT_ERROR || last_command)
+ if (error->domain != MM_MOBILE_EQUIPMENT_ERROR || last_command) {
*result_error = g_error_copy (error);
- return FALSE;
+ return MM_BASE_MODEM_AT_RESPONSE_PROCESSOR_RESULT_FAILURE;
+ }
+
+ return MM_BASE_MODEM_AT_RESPONSE_PROCESSOR_RESULT_CONTINUE;
}
mdn = g_strdup (mm_strip_tag (response, "$NWMDN:"));
@@ -242,7 +253,7 @@ response_processor_nwmdn_ignore_at_errors (MMBaseModem *self,
own_numbers = (GStrv) g_ptr_array_free (array, FALSE);
*result = g_variant_new_strv ((const gchar *const *) own_numbers, -1);
- return TRUE;
+ return MM_BASE_MODEM_AT_RESPONSE_PROCESSOR_RESULT_SUCCESS;
}
static const MMBaseModemAtCommand own_numbers_commands[] = {
diff --git a/plugins/sierra/mm-broadband-modem-sierra.c b/plugins/sierra/mm-broadband-modem-sierra.c
index c08aec48..7e2dba9b 100644
--- a/plugins/sierra/mm-broadband-modem-sierra.c
+++ b/plugins/sierra/mm-broadband-modem-sierra.c
@@ -1780,16 +1780,18 @@ modem_time_check_ready (MMBaseModem *self,
g_object_unref (task);
}
-static gboolean
-parse_time_reply (MMBaseModem *self,
- gpointer none,
- const gchar *command,
- const gchar *response,
- gboolean last_command,
- const GError *error,
- GVariant **result,
- GError **result_error)
-{
+static MMBaseModemAtResponseProcessorResult
+parse_time_reply (MMBaseModem *self,
+ gpointer none,
+ const gchar *command,
+ const gchar *response,
+ gboolean last_command,
+ const GError *error,
+ GVariant **result,
+ GError **result_error)
+{
+ *result_error = NULL;
+
/* If error, try next command */
if (!error) {
if (strstr (command, "!TIME"))
@@ -1799,11 +1801,13 @@ parse_time_reply (MMBaseModem *self,
}
/* Stop sequence if we get a result, but not on errors */
- return *result ? TRUE : FALSE;
+ return (*result ?
+ MM_BASE_MODEM_AT_RESPONSE_PROCESSOR_RESULT_SUCCESS :
+ MM_BASE_MODEM_AT_RESPONSE_PROCESSOR_RESULT_CONTINUE);
}
static const MMBaseModemAtCommand time_check_sequence[] = {
- { "!TIME?", 3, FALSE, parse_time_reply }, /* 3GPP */
+ { "!TIME?", 3, FALSE, parse_time_reply }, /* 3GPP */
{ "!SYSTIME?", 3, FALSE, parse_time_reply }, /* CDMA */
{ NULL }
};
diff --git a/plugins/telit/mm-broadband-modem-telit.c b/plugins/telit/mm-broadband-modem-telit.c
index 48ae4de1..94a6ddcc 100644
--- a/plugins/telit/mm-broadband-modem-telit.c
+++ b/plugins/telit/mm-broadband-modem-telit.c
@@ -1080,23 +1080,30 @@ load_access_technologies_finish (MMIfaceModem *self,
return TRUE;
}
-static gboolean
-response_processor_psnt_ignore_at_errors (MMBaseModem *self,
- gpointer none,
- const gchar *command,
- const gchar *response,
- gboolean last_command,
- const GError *error,
- GVariant **result,
- GError **result_error)
+static MMBaseModemAtResponseProcessorResult
+response_processor_psnt_ignore_at_errors (MMBaseModem *self,
+ gpointer none,
+ const gchar *command,
+ const gchar *response,
+ gboolean last_command,
+ const GError *error,
+ GVariant **result,
+ GError **result_error)
{
- const gchar *psnt, *mode;
+ const gchar *psnt;
+ const gchar *mode;
+
+ *result = NULL;
+ *result_error = NULL;
if (error) {
/* Ignore AT errors (ie, ERROR or CMx ERROR) */
- if (error->domain != MM_MOBILE_EQUIPMENT_ERROR || last_command)
+ if (error->domain != MM_MOBILE_EQUIPMENT_ERROR || last_command) {
*result_error = g_error_copy (error);
- return FALSE;
+ return MM_BASE_MODEM_AT_RESPONSE_PROCESSOR_RESULT_FAILURE;
+ }
+
+ return MM_BASE_MODEM_AT_RESPONSE_PROCESSOR_RESULT_CONTINUE;
}
psnt = mm_strip_tag (response, "#PSNT:");
@@ -1105,26 +1112,26 @@ response_processor_psnt_ignore_at_errors (MMBaseModem *self,
switch (atoi (++mode)) {
case 0:
*result = g_variant_new_uint32 (MM_MODEM_ACCESS_TECHNOLOGY_GPRS);
- return TRUE;
+ return MM_BASE_MODEM_AT_RESPONSE_PROCESSOR_RESULT_SUCCESS;
case 1:
*result = g_variant_new_uint32 (MM_MODEM_ACCESS_TECHNOLOGY_EDGE);
- return TRUE;
+ return MM_BASE_MODEM_AT_RESPONSE_PROCESSOR_RESULT_SUCCESS;
case 2:
*result = g_variant_new_uint32 (MM_MODEM_ACCESS_TECHNOLOGY_UMTS);
- return TRUE;
+ return MM_BASE_MODEM_AT_RESPONSE_PROCESSOR_RESULT_SUCCESS;
case 3:
*result = g_variant_new_uint32 (MM_MODEM_ACCESS_TECHNOLOGY_HSDPA);
- return TRUE;
+ return MM_BASE_MODEM_AT_RESPONSE_PROCESSOR_RESULT_SUCCESS;
case 4:
if (mm_iface_modem_is_3gpp_lte (MM_IFACE_MODEM (self)))
*result = g_variant_new_uint32 (MM_MODEM_ACCESS_TECHNOLOGY_LTE);
else
*result = g_variant_new_uint32 (MM_MODEM_ACCESS_TECHNOLOGY_UNKNOWN);
- return TRUE;
+ return MM_BASE_MODEM_AT_RESPONSE_PROCESSOR_RESULT_SUCCESS;
case 5:
if (mm_iface_modem_is_3gpp_lte (MM_IFACE_MODEM (self))) {
*result = g_variant_new_uint32 (MM_MODEM_ACCESS_TECHNOLOGY_UNKNOWN);
- return TRUE;
+ return MM_BASE_MODEM_AT_RESPONSE_PROCESSOR_RESULT_SUCCESS;
}
/* Fall-through since #PSNT: 5 is not supported in other than lte modems */
default:
@@ -1137,26 +1144,32 @@ response_processor_psnt_ignore_at_errors (MMBaseModem *self,
MM_CORE_ERROR_FAILED,
"Failed to parse #PSNT response: '%s'",
response);
- return FALSE;
+ return MM_BASE_MODEM_AT_RESPONSE_PROCESSOR_RESULT_FAILURE;
}
-static gboolean
-response_processor_service_ignore_at_errors (MMBaseModem *self,
- gpointer none,
- const gchar *command,
- const gchar *response,
- gboolean last_command,
- const GError *error,
- GVariant **result,
- GError **result_error)
+static MMBaseModemAtResponseProcessorResult
+response_processor_service_ignore_at_errors (MMBaseModem *self,
+ gpointer none,
+ const gchar *command,
+ const gchar *response,
+ gboolean last_command,
+ const GError *error,
+ GVariant **result,
+ GError **result_error)
{
const gchar *service;
+ *result = NULL;
+ *result_error = NULL;
+
if (error) {
/* Ignore AT errors (ie, ERROR or CMx ERROR) */
- if (error->domain != MM_MOBILE_EQUIPMENT_ERROR || last_command)
+ if (error->domain != MM_MOBILE_EQUIPMENT_ERROR || last_command) {
*result_error = g_error_copy (error);
- return FALSE;
+ return MM_BASE_MODEM_AT_RESPONSE_PROCESSOR_RESULT_FAILURE;
+ }
+
+ return MM_BASE_MODEM_AT_RESPONSE_PROCESSOR_RESULT_CONTINUE;
}
service = mm_strip_tag (response, "+SERVICE:");
@@ -1164,13 +1177,13 @@ response_processor_service_ignore_at_errors (MMBaseModem *self,
switch (atoi (service)) {
case 1:
*result = g_variant_new_uint32 (MM_MODEM_ACCESS_TECHNOLOGY_1XRTT);
- return TRUE;
+ return MM_BASE_MODEM_AT_RESPONSE_PROCESSOR_RESULT_SUCCESS;
case 2:
*result = g_variant_new_uint32 (MM_MODEM_ACCESS_TECHNOLOGY_EVDO0);
- return TRUE;
+ return MM_BASE_MODEM_AT_RESPONSE_PROCESSOR_RESULT_SUCCESS;
case 3:
*result = g_variant_new_uint32 (MM_MODEM_ACCESS_TECHNOLOGY_EVDOA);
- return TRUE;
+ return MM_BASE_MODEM_AT_RESPONSE_PROCESSOR_RESULT_SUCCESS;
default:
break;
}
@@ -1181,7 +1194,7 @@ response_processor_service_ignore_at_errors (MMBaseModem *self,
MM_CORE_ERROR_FAILED,
"Failed to parse +SERVICE response: '%s'",
response);
- return FALSE;
+ return MM_BASE_MODEM_AT_RESPONSE_PROCESSOR_RESULT_FAILURE;
}
static const MMBaseModemAtCommand access_tech_commands[] = {