From 855977c4c7c1ead7dedd710671ca0359b277c417 Mon Sep 17 00:00:00 2001 From: Sven Schwermer Date: Fri, 5 Aug 2022 15:09:28 +0200 Subject: [PATCH] fibocom: Implement power down/off Also bump the timeout for the +CFUN operations as they may take up to 10s according to the AT command manual (e.g. MA510). Signed-off-by: Sven Schwermer --- plugins/fibocom/mm-broadband-modem-fibocom.c | 40 +++++++++++++++++--- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/plugins/fibocom/mm-broadband-modem-fibocom.c b/plugins/fibocom/mm-broadband-modem-fibocom.c index 9a819432..747d0769 100644 --- a/plugins/fibocom/mm-broadband-modem-fibocom.c +++ b/plugins/fibocom/mm-broadband-modem-fibocom.c @@ -164,12 +164,12 @@ modem_create_bearer (MMIfaceModem *_self, } /*****************************************************************************/ -/* Reset (Modem interface) */ +/* Reset / Power (Modem interface) */ static gboolean -modem_reset_finish (MMIfaceModem *self, - GAsyncResult *res, - GError **error) +modem_common_power_finish (MMIfaceModem *self, + GAsyncResult *res, + GError **error) { return !!mm_base_modem_at_command_finish (MM_BASE_MODEM (self), res, error); } @@ -181,6 +181,32 @@ modem_reset (MMIfaceModem *self, { mm_base_modem_at_command (MM_BASE_MODEM (self), "+CFUN=15", + 15, + FALSE, + callback, + user_data); +} + +static void +modem_power_down (MMIfaceModem *self, + GAsyncReadyCallback callback, + gpointer user_data) +{ + mm_base_modem_at_command (MM_BASE_MODEM (self), + "+CFUN=4", + 15, + FALSE, + callback, + user_data); +} + +static void +modem_power_off (MMIfaceModem *self, + GAsyncReadyCallback callback, + gpointer user_data) +{ + mm_base_modem_at_command (MM_BASE_MODEM (self), + "+CPWROFF", 3, FALSE, callback, @@ -261,7 +287,11 @@ iface_modem_init (MMIfaceModem *iface) iface->create_bearer = modem_create_bearer; iface->create_bearer_finish = modem_create_bearer_finish; iface->reset = modem_reset; - iface->reset_finish = modem_reset_finish; + iface->reset_finish = modem_common_power_finish; + iface->modem_power_down = modem_power_down; + iface->modem_power_down_finish = modem_common_power_finish; + iface->modem_power_off = modem_power_off; + iface->modem_power_off_finish = modem_common_power_finish; } static void