diff --git a/cli/mmcli-common.c b/cli/mmcli-common.c
index 57651725..b7d6fe66 100644
--- a/cli/mmcli-common.c
+++ b/cli/mmcli-common.c
@@ -1063,6 +1063,8 @@ mmcli_get_state_reason_string (MMModemStateChangeReason reason)
return "User request";
case MM_MODEM_STATE_CHANGE_REASON_SUSPEND:
return "Suspend";
+ case MM_MODEM_STATE_CHANGE_REASON_FAILURE:
+ return "Failure";
}
g_warn_if_reached ();
diff --git a/cli/mmcli-modem.c b/cli/mmcli-modem.c
index fac1798b..7027f53e 100644
--- a/cli/mmcli-modem.c
+++ b/cli/mmcli-modem.c
@@ -351,13 +351,18 @@ print_modem_info (void)
g_print (" -------------------------\n"
" Status | lock: '%s'\n"
" | unlock retries: '%s'\n"
- " | state: '%s'\n"
- " | power state: '%s'\n"
- " | access tech: '%s'\n"
- " | signal quality: '%u' (%s)\n",
+ " | state: '%s'\n",
mm_modem_lock_get_string (mm_modem_get_unlock_required (ctx->modem)),
VALIDATE_UNKNOWN (unlock_retries_string),
- VALIDATE_UNKNOWN (mm_modem_state_get_string (mm_modem_get_state (ctx->modem))),
+ VALIDATE_UNKNOWN (mm_modem_state_get_string (mm_modem_get_state (ctx->modem))));
+
+ if (mm_modem_get_state (ctx->modem) == MM_MODEM_STATE_FAILED)
+ g_print (" | failed reason: '%s'\n",
+ VALIDATE_UNKNOWN (mm_modem_state_failed_reason_get_string (mm_modem_get_state_failed_reason (ctx->modem))));
+
+ g_print (" | power state: '%s'\n"
+ " | access tech: '%s'\n"
+ " | signal quality: '%u' (%s)\n",
VALIDATE_UNKNOWN (mm_modem_power_state_get_string (mm_modem_get_power_state (ctx->modem))),
VALIDATE_UNKNOWN (access_technologies_string),
signal_quality, signal_quality_recent ? "recent" : "cached");
diff --git a/docs/reference/api/ModemManager-sections.txt b/docs/reference/api/ModemManager-sections.txt
index b9837661..37309e9d 100644
--- a/docs/reference/api/ModemManager-sections.txt
+++ b/docs/reference/api/ModemManager-sections.txt
@@ -20,6 +20,7 @@ MMModemLocationSource
MMModemLock
MMModemMode
MMModemState
+MMModemStateFailedReason
MMModemStateChangeReason
MMModemPowerState
MMSmsPduType
diff --git a/docs/reference/libmm-glib/libmm-glib-sections.txt b/docs/reference/libmm-glib/libmm-glib-sections.txt
index 6f5663f5..87b840ed 100644
--- a/docs/reference/libmm-glib/libmm-glib-sections.txt
+++ b/docs/reference/libmm-glib/libmm-glib-sections.txt
@@ -77,6 +77,7 @@ MMModem
mm_modem_get_path
mm_modem_dup_path
mm_modem_get_state
+mm_modem_get_state_failed_reason
mm_modem_get_power_state
mm_modem_get_modem_capabilities
mm_modem_get_current_capabilities
@@ -957,6 +958,7 @@ mm_bearer_ip_family_get_string
mm_bearer_allowed_auth_build_string_from_mask
mm_modem_capability_build_string_from_mask
mm_modem_state_get_string
+mm_modem_state_failed_reason_get_string
mm_modem_state_change_reason_get_string
mm_modem_power_state_get_string
mm_modem_lock_get_string
@@ -981,6 +983,7 @@ mm_firmware_image_type_get_string
mm_modem_capability_get_string
mm_modem_lock_build_string_from_mask
mm_modem_state_build_string_from_mask
+mm_modem_state_failed_reason_build_string_from_mask
mm_modem_state_change_reason_build_string_from_mask
mm_modem_power_state_build_string_from_mask
mm_modem_access_technology_get_string
@@ -1023,6 +1026,7 @@ MM_TYPE_MODEM_LOCATION_SOURCE
MM_TYPE_MODEM_LOCK
MM_TYPE_MODEM_MODE
MM_TYPE_MODEM_STATE
+MM_TYPE_MODEM_STATE_FAILED_REASON
MM_TYPE_MODEM_STATE_CHANGE_REASON
MM_TYPE_MODEM_POWER_STATE
MM_TYPE_SMS_DELIVERY_STATE
@@ -1049,6 +1053,7 @@ mm_modem_lock_get_type
mm_modem_mode_get_type
mm_modem_state_change_reason_get_type
mm_modem_state_get_type
+mm_modem_state_failed_reason_get_type
mm_modem_power_state_get_type
mm_sms_delivery_state_get_type
mm_sms_pdu_type_get_type
@@ -1437,6 +1442,7 @@ mm_gdbus_modem_dup_signal_quality
mm_gdbus_modem_get_sim
mm_gdbus_modem_dup_sim
mm_gdbus_modem_get_state
+mm_gdbus_modem_get_state_failed_reason
mm_gdbus_modem_get_supported_bands
mm_gdbus_modem_dup_supported_bands
mm_gdbus_modem_get_supported_modes
@@ -1496,6 +1502,7 @@ mm_gdbus_modem_set_revision
mm_gdbus_modem_set_signal_quality
mm_gdbus_modem_set_sim
mm_gdbus_modem_set_state
+mm_gdbus_modem_set_state_failed_reason
mm_gdbus_modem_set_power_state
mm_gdbus_modem_set_supported_bands
mm_gdbus_modem_set_supported_modes
diff --git a/include/ModemManager-enums.h b/include/ModemManager-enums.h
index e7554160..abdd2575 100644
--- a/include/ModemManager-enums.h
+++ b/include/ModemManager-enums.h
@@ -128,6 +128,22 @@ typedef enum { /*< underscore_name=mm_modem_state >*/
MM_MODEM_STATE_CONNECTED = 11
} MMModemState;
+/**
+ * MMModemStateFailedReason:
+ * @MM_MODEM_STATE_FAILED_REASON_NONE: No error.
+ * @MM_MODEM_STATE_FAILED_REASON_UNKNOWN: Unknown error.
+ * @MM_MODEM_STATE_FAILED_REASON_SIM_MISSING: SIM is required but missing.
+ * @MM_MODEM_STATE_FAILED_REASON_SIM_ERROR: SIM is available, but unusable (e.g. permanently locked).
+ *
+ * Enumeration of possible errors when the modem is in @MM_MODEM_STATE_FAILED.
+ */
+typedef enum { /*< underscore_name=mm_modem_state_failed_reason >*/
+ MM_MODEM_STATE_FAILED_REASON_NONE = 0,
+ MM_MODEM_STATE_FAILED_REASON_UNKNOWN = 1,
+ MM_MODEM_STATE_FAILED_REASON_SIM_MISSING = 2,
+ MM_MODEM_STATE_FAILED_REASON_SIM_ERROR = 3,
+} MMModemStateFailedReason;
+
/**
* MMModemPowerState:
* @MM_MODEM_POWER_STATE_UNKNOWN: Unknown power state.
@@ -149,6 +165,7 @@ typedef enum { /*< underscore_name=mm_modem_power_state >*/
* @MM_MODEM_STATE_CHANGE_REASON_UNKNOWN: Reason unknown or not reportable.
* @MM_MODEM_STATE_CHANGE_REASON_USER_REQUESTED: State change was requested by an interface user.
* @MM_MODEM_STATE_CHANGE_REASON_SUSPEND: State change was caused by a system suspend.
+ * @MM_MODEM_STATE_CHANGE_REASON_FAILURE: State change was caused by an unrecoverable error.
*
* Enumeration of possible reasons to have changed the modem state.
*/
@@ -156,6 +173,7 @@ typedef enum { /*< underscore_name=mm_modem_state_change_reason >*/
MM_MODEM_STATE_CHANGE_REASON_UNKNOWN = 0,
MM_MODEM_STATE_CHANGE_REASON_USER_REQUESTED = 1,
MM_MODEM_STATE_CHANGE_REASON_SUSPEND = 2,
+ MM_MODEM_STATE_CHANGE_REASON_FAILURE = 3,
} MMModemStateChangeReason;
/**
diff --git a/introspection/org.freedesktop.ModemManager1.Modem.xml b/introspection/org.freedesktop.ModemManager1.Modem.xml
index dfcf97e3..42f80419 100644
--- a/introspection/org.freedesktop.ModemManager1.Modem.xml
+++ b/introspection/org.freedesktop.ModemManager1.Modem.xml
@@ -356,6 +356,16 @@
-->
+
+
+