From abc05e86e56b660c8fe00aebce31e5ad2e715da6 Mon Sep 17 00:00:00 2001 From: Arnaud Ferraris Date: Wed, 30 Dec 2020 16:20:32 +0100 Subject: [PATCH] manager: only toggle GPIOs for suspend after executing all AT commands --- src/at.c | 3 +-- src/manager.c | 10 ++++++++-- src/manager.h | 3 ++- src/suspend.c | 2 +- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/at.c b/src/at.c index a7b8b73..45ba844 100644 --- a/src/at.c +++ b/src/at.c @@ -80,8 +80,7 @@ static gboolean send_at_command(struct EG25Manager *manager) else manager->modem_state = EG25_STATE_CONFIGURED; } else if (manager->modem_state == EG25_STATE_SUSPENDING) { - g_message("suspend sequence is over, drop inhibitor"); - suspend_inhibit(manager, FALSE); + modem_suspend_post(manager); } else if (manager->modem_state == EG25_STATE_RESETTING) { manager->modem_state = EG25_STATE_POWERED; } diff --git a/src/manager.c b/src/manager.c index bc08ddb..17e58b2 100644 --- a/src/manager.c +++ b/src/manager.c @@ -162,10 +162,16 @@ error: at_sequence_reset(manager); } -void modem_suspend(struct EG25Manager *manager) +void modem_suspend_pre(struct EG25Manager *manager) +{ + at_sequence_suspend(manager); +} + +void modem_suspend_post(struct EG25Manager *manager) { gpio_sequence_suspend(manager); - at_sequence_suspend(manager); + g_message("suspend sequence is over, drop inhibitor"); + suspend_inhibit(manager, FALSE); } void modem_resume_pre(struct EG25Manager *manager) diff --git a/src/manager.h b/src/manager.h index c51f32f..605d73e 100644 --- a/src/manager.h +++ b/src/manager.h @@ -54,7 +54,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/suspend.c b/src/suspend.c index 2e1301e..6d34594 100644 --- a/src/suspend.c +++ b/src/suspend.c @@ -94,7 +94,7 @@ 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);