diff options
author | Aleksander Morgado <aleksander@lanedo.com> | 2012-02-14 14:19:57 +0100 |
---|---|---|
committer | Aleksander Morgado <aleksander@lanedo.com> | 2012-03-15 14:15:07 +0100 |
commit | 789cf58acee0334990e18fb4793f3f872626e697 (patch) | |
tree | 5fa42e0319f135f0833c720ba4af3372126aa87c | |
parent | 8456dae53dabfed294f02926424892a2bd81168e (diff) |
iridium: setup RTS/CTS flow control
-rw-r--r-- | plugins/mm-broadband-modem-iridium.c | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/plugins/mm-broadband-modem-iridium.c b/plugins/mm-broadband-modem-iridium.c index e59665af..d1b92698 100644 --- a/plugins/mm-broadband-modem-iridium.c +++ b/plugins/mm-broadband-modem-iridium.c @@ -35,6 +35,63 @@ G_DEFINE_TYPE_EXTENDED (MMBroadbandModemIridium, mm_broadband_modem_iridium, MM_ G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM, iface_modem_init)); /*****************************************************************************/ +/* Flow control (Modem interface) */ + +static gboolean +setup_flow_control_finish (MMIfaceModem *self, + GAsyncResult *res, + GError **error) +{ + return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error); +} + +static void +setup_flow_control_ready (MMBroadbandModemIridium *self, + GAsyncResult *res, + GSimpleAsyncResult *operation_result) +{ + GError *error = NULL; + + if (!mm_base_modem_at_command_finish (MM_BASE_MODEM (self), res, &error)) + /* Let the error be critical. We DO need RTS/CTS in order to have + * proper modem disabling. */ + g_simple_async_result_take_error (operation_result, error); + else + g_simple_async_result_set_op_res_gboolean (operation_result, TRUE); + + g_simple_async_result_complete (operation_result); + g_object_unref (operation_result); +} + +static void +setup_flow_control (MMIfaceModem *self, + GAsyncReadyCallback callback, + gpointer user_data) +{ + GSimpleAsyncResult *result; + + result = g_simple_async_result_new (G_OBJECT (self), + callback, + user_data, + setup_flow_control); + + /* Enable RTS/CTS flow control. + * Other available values: + * AT&K0: Disable flow control + * AT&K3: RTS/CTS + * AT&K4: XOFF/XON + * AT&K6: Both RTS/CTS and XOFF/XON + */ + mm_base_modem_at_command (MM_BASE_MODEM (self), + "&K3", + 3, + FALSE, + NULL, /* cancellable */ + (GAsyncReadyCallback)setup_flow_control_ready, + result); +} + +/*****************************************************************************/ MMBroadbandModemIridium * mm_broadband_modem_iridium_new (const gchar *device, @@ -60,6 +117,10 @@ mm_broadband_modem_iridium_init (MMBroadbandModemIridium *self) static void iface_modem_init (MMIfaceModem *iface) { + /* RTS/CTS flow control */ + iface->setup_flow_control = setup_flow_control; + iface->setup_flow_control_finish = setup_flow_control_finish; + /* No need to power-up/power-down the modem */ iface->modem_power_up = NULL; iface->modem_power_up_finish = NULL; |