diff options
-rw-r--r-- | introspection/org.freedesktop.ModemManager.Modem.xml | 13 | ||||
-rw-r--r-- | plugins/mm-modem-anydata-cdma.c | 19 | ||||
-rw-r--r-- | plugins/mm-modem-mbm.c | 19 | ||||
-rw-r--r-- | src/mm-modem.c | 51 | ||||
-rw-r--r-- | src/mm-modem.h | 8 |
5 files changed, 109 insertions, 1 deletions
diff --git a/introspection/org.freedesktop.ModemManager.Modem.xml b/introspection/org.freedesktop.ModemManager.Modem.xml index 1c032aa6..1eecbf2f 100644 --- a/introspection/org.freedesktop.ModemManager.Modem.xml +++ b/introspection/org.freedesktop.ModemManager.Modem.xml @@ -63,9 +63,20 @@ </arg> </method> + <method name="Reset"> + <tp:docstring> + Clear non-persistent configuration and state, and return the device to + a newly-powered-on state. This command may power-cycle the device. + </tp:docstring> + <annotation name="org.freedesktop.DBus.GLib.Async" value=""/> + <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_modem_reset"/> + </method> + <method name="FactoryReset"> <tp:docstring> - Reset the modem to as close to factory state as possible. + Clear the modem's configuration (including persistent configuration and + state), and return the device to a factory-default state. This command + may or may not power-cycle the device. </tp:docstring> <annotation name="org.freedesktop.DBus.GLib.Async" value=""/> <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_modem_factory_reset"/> diff --git a/plugins/mm-modem-anydata-cdma.c b/plugins/mm-modem-anydata-cdma.c index 3bf15ed8..02454b00 100644 --- a/plugins/mm-modem-anydata-cdma.c +++ b/plugins/mm-modem-anydata-cdma.c @@ -272,6 +272,24 @@ query_registration_state (MMGenericCdma *cdma, /*****************************************************************************/ +static void +reset (MMModem *modem, + MMModemFn callback, + gpointer user_data) +{ + MMCallbackInfo *info; + MMAtSerialPort *port; + + info = mm_callback_info_new (MM_MODEM (modem), callback, user_data); + + /* Ensure we have a usable port to use for the command */ + port = mm_generic_cdma_get_best_at_port (MM_GENERIC_CDMA (modem), &info->error); + if (port) + mm_at_serial_port_queue_command (port, "*RESET", 3, NULL, NULL); + + mm_callback_info_schedule (info); +} + static gboolean grab_port (MMModem *modem, const char *subsys, @@ -333,6 +351,7 @@ static void modem_init (MMModem *modem_class) { modem_class->grab_port = grab_port; + modem_class->reset = reset; } static void diff --git a/plugins/mm-modem-mbm.c b/plugins/mm-modem-mbm.c index 53e98ba6..554ebc27 100644 --- a/plugins/mm-modem-mbm.c +++ b/plugins/mm-modem-mbm.c @@ -510,6 +510,24 @@ do_disconnect (MMGenericGsm *gsm, } static void +reset (MMModem *modem, + MMModemFn callback, + gpointer user_data) +{ + MMCallbackInfo *info; + MMAtSerialPort *port; + + info = mm_callback_info_new (MM_MODEM (modem), callback, user_data); + + /* Ensure we have a usable port to use for the command */ + port = mm_generic_gsm_get_best_at_port (MM_GENERIC_GSM (modem), &info->error); + if (port) + mm_at_serial_port_queue_command (port, "*E2RESET", 3, NULL, NULL); + + mm_callback_info_schedule (info); +} + +static void factory_reset_done (MMAtSerialPort *port, GString *response, GError *error, @@ -940,6 +958,7 @@ modem_init (MMModem *modem_class) modem_class->grab_port = grab_port; modem_class->disable = disable; modem_class->connect = do_connect; + modem_class->reset = reset; modem_class->factory_reset = factory_reset; } diff --git a/src/mm-modem.c b/src/mm-modem.c index c65bee54..3535cded 100644 --- a/src/mm-modem.c +++ b/src/mm-modem.c @@ -28,6 +28,7 @@ static void impl_modem_connect (MMModem *modem, const char *number, DBusGMethodI static void impl_modem_disconnect (MMModem *modem, DBusGMethodInvocation *context); static void impl_modem_get_ip4_config (MMModem *modem, DBusGMethodInvocation *context); static void impl_modem_get_info (MMModem *modem, DBusGMethodInvocation *context); +static void impl_modem_reset (MMModem *modem, DBusGMethodInvocation *context); static void impl_modem_factory_reset (MMModem *modem, const char *code, DBusGMethodInvocation *context); #include "mm-modem-glue.h" @@ -478,6 +479,56 @@ impl_modem_get_info (MMModem *modem, /*****************************************************************************/ static void +reset_auth_cb (MMAuthRequest *req, + GObject *owner, + DBusGMethodInvocation *context, + gpointer user_data) +{ + MMModem *self = MM_MODEM (owner); + GError *error = NULL; + + /* Return any authorization error, otherwise try to reset the modem */ + if (!mm_modem_auth_finish (self, req, &error)) { + dbus_g_method_return_error (context, error); + g_error_free (error); + } else + mm_modem_reset (self, async_call_done, context); +} + +static void +impl_modem_reset (MMModem *modem, DBusGMethodInvocation *context) +{ + GError *error = NULL; + + /* Make sure the caller is authorized to reset the device */ + if (!mm_modem_auth_request (MM_MODEM (modem), + MM_AUTHORIZATION_DEVICE_CONTROL, + context, + reset_auth_cb, + NULL, NULL, + &error)) { + dbus_g_method_return_error (context, error); + g_error_free (error); + } +} + +void +mm_modem_reset (MMModem *self, + MMModemFn callback, + gpointer user_data) +{ + g_return_if_fail (MM_IS_MODEM (self)); + g_return_if_fail (callback != NULL); + + if (MM_MODEM_GET_INTERFACE (self)->reset) + MM_MODEM_GET_INTERFACE (self)->reset (self, callback, user_data); + else + async_op_not_supported (self, callback, user_data); +} + +/*****************************************************************************/ + +static void factory_reset_auth_cb (MMAuthRequest *req, GObject *owner, DBusGMethodInvocation *context, diff --git a/src/mm-modem.h b/src/mm-modem.h index 1faf3838..8a755d88 100644 --- a/src/mm-modem.h +++ b/src/mm-modem.h @@ -194,6 +194,10 @@ struct _MMModem { MMAuthRequest *req, GError **error); + void (*reset) (MMModem *self, + MMModemFn callback, + gpointer user_data); + void (*factory_reset) (MMModem *self, const char *code, MMModemFn callback, @@ -257,6 +261,10 @@ void mm_modem_set_charset (MMModem *self, MMModemFn callback, gpointer user_data); +void mm_modem_reset (MMModem *self, + MMModemFn callback, + gpointer user_data); + void mm_modem_factory_reset (MMModem *self, const char *code, MMModemFn callback, |