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).
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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[] = {
|
||||
|
||||
@@ -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)
|
||||
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 = context;
|
||||
Band *b = g_slist_nth_data (ctx->check_bands, ctx->idx++);
|
||||
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
|
||||
|
||||
@@ -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[] = {
|
||||
|
||||
@@ -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 }
|
||||
};
|
||||
|
||||
@@ -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[] = {
|
||||
|
||||
Reference in New Issue
Block a user