diff --git a/src/manager.c b/src/manager.c index 2b466e3..78bf98b 100644 --- a/src/manager.c +++ b/src/manager.c @@ -135,14 +135,20 @@ error: manager->modem_state = EG25_STATE_RESETTING; } -void modem_suspend(struct EG25Manager *manager) +void modem_suspend_pre(struct EG25Manager *manager) { + manager->modem_state = EG25_STATE_SUSPENDING; gpio_sequence_suspend(manager); +} + +void modem_suspend_post(struct EG25Manager *manager) +{ at_sequence_suspend(manager); } void modem_resume_pre(struct EG25Manager *manager) { + manager->modem_state = EG25_STATE_RESUMING; gpio_sequence_resume(manager); } diff --git a/src/manager.h b/src/manager.h index 714a812..be92a09 100644 --- a/src/manager.h +++ b/src/manager.h @@ -51,7 +51,8 @@ struct EG25Manager { void modem_configure(struct EG25Manager *data); void modem_reset(struct EG25Manager *data); -void modem_suspend(struct EG25Manager *data); +void modem_suspend_pre(struct EG25Manager *data); +void modem_suspend_post(struct EG25Manager *data); void modem_resume_pre(struct EG25Manager *data); void modem_resume_post(struct EG25Manager *data); void modem_update_state(struct EG25Manager *data, MMModemState state); diff --git a/src/mm-iface.c b/src/mm-iface.c index f1021de..9bf9209 100644 --- a/src/mm-iface.c +++ b/src/mm-iface.c @@ -132,6 +132,9 @@ static void object_removed_cb(struct EG25Manager *manager, GDBusObject *object) path = g_dbus_object_get_object_path(object); g_message("ModemManager object `%s' removed", path); + if (manager->modem_state == EG25_STATE_SUSPENDING) + modem_suspend_post(manager); + manager->mm_modem = NULL; if (manager->modem_usb_id) { g_free(manager->modem_usb_id); diff --git a/src/suspend.c b/src/suspend.c index 8296696..42a18f7 100644 --- a/src/suspend.c +++ b/src/suspend.c @@ -92,13 +92,11 @@ static void signal_cb(GDBusProxy *proxy, if (is_about_to_suspend) { g_message("system is about to suspend"); - manager->modem_state = EG25_STATE_SUSPENDING; - modem_suspend(manager); + modem_suspend_pre(manager); } else { g_message("system is resuming"); take_inhibitor(manager); modem_resume_pre(manager); - manager->modem_state = EG25_STATE_RESUMING; manager->suspend_source = g_timeout_add_seconds(8, G_SOURCE_FUNC(check_modem_resume), manager); } }