aboutsummaryrefslogtreecommitdiff
path: root/plugins/mm-bearer-iridium.c
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@lanedo.com>2012-02-16 20:07:04 +0100
committerAleksander Morgado <aleksander@lanedo.com>2012-03-15 14:15:08 +0100
commit4e55b16f9aa7cedb531d1b04b20df87b4f942031 (patch)
tree1b75c706ce3b8bc2419057dde6dd8b56026b960a /plugins/mm-bearer-iridium.c
parentb14bf797f1a7bc5501757c5e01830615dbfbba83 (diff)
iridium: close and open the port during disconnection
The Iridium modem doesn't seem to like only the port flashing during the disconnection, so we fully close and open again the port.
Diffstat (limited to 'plugins/mm-bearer-iridium.c')
-rw-r--r--plugins/mm-bearer-iridium.c46
1 files changed, 41 insertions, 5 deletions
diff --git a/plugins/mm-bearer-iridium.c b/plugins/mm-bearer-iridium.c
index 9af1b701..c38f05e2 100644
--- a/plugins/mm-bearer-iridium.c
+++ b/plugins/mm-bearer-iridium.c
@@ -299,6 +299,38 @@ primary_flash_ready (MMSerialPort *port,
g_object_unref (result);
}
+static gboolean
+after_disconnect_sleep_cb (GSimpleAsyncResult *simple)
+{
+ GError *error = NULL;
+ MMAtSerialPort *primary;
+ MMBearer *self;
+ MMBaseModem *modem;
+
+ self = MM_BEARER (g_async_result_get_source_object (G_ASYNC_RESULT (simple)));
+ g_object_get (self,
+ MM_BEARER_MODEM, &modem,
+ NULL);
+ primary = mm_base_modem_get_port_primary (modem);
+
+ /* Propagate errors when reopening the port */
+ if (!mm_serial_port_open (MM_SERIAL_PORT (primary), &error)) {
+ g_simple_async_result_take_error (simple, error);
+ g_simple_async_result_complete (simple);
+ g_object_unref (simple);
+ } else {
+ mm_serial_port_flash (MM_SERIAL_PORT (primary),
+ 1000,
+ TRUE,
+ (MMSerialFlashFn)primary_flash_ready,
+ simple);
+ }
+
+ g_object_unref (modem);
+ g_object_unref (self);
+ return FALSE;
+}
+
static void
disconnect (MMBearer *self,
GAsyncReadyCallback callback,
@@ -331,11 +363,15 @@ disconnect (MMBearer *self,
callback,
user_data,
disconnect);
- mm_serial_port_flash (MM_SERIAL_PORT (primary),
- 1000,
- TRUE,
- (MMSerialFlashFn)primary_flash_ready,
- result);
+
+ /* When we enable the modem we kept one open count in the primary port.
+ * We now need to fully close that one, as if we were disabled, and reopen
+ * it again afterwards. */
+ mm_serial_port_close (MM_SERIAL_PORT (primary));
+ g_warn_if_fail (!mm_serial_port_is_open (MM_SERIAL_PORT (primary)));
+
+ mm_dbg ("Waiting some seconds before reopening the port...");
+ g_timeout_add_seconds (5, (GSourceFunc)after_disconnect_sleep_cb, result);
}
/*****************************************************************************/