diff options
author | Aleksander Morgado <aleksander@lanedo.com> | 2011-06-30 19:48:23 +0200 |
---|---|---|
committer | Aleksander Morgado <aleksander@lanedo.com> | 2011-06-30 19:48:23 +0200 |
commit | 7762d401e8201efc05d643b9da32f3e60a42c470 (patch) | |
tree | c1de587432ca1c0b1a766127aabbc14a77ac75a0 /src | |
parent | 881f928c40f1460bcb03fae3eaf96b23f40fca3f (diff) | |
parent | 7e69d2cf307efdb4ddec5ef0eef9f6141bf8fa65 (diff) |
Merge remote-tracking branch 'lanedo/power-up-check-needed'
Diffstat (limited to 'src')
-rw-r--r-- | src/mm-generic-gsm.c | 34 | ||||
-rw-r--r-- | src/mm-generic-gsm.h | 11 | ||||
-rw-r--r-- | src/mm-serial-port.c | 21 | ||||
-rw-r--r-- | src/mm-serial-port.h | 1 |
4 files changed, 60 insertions, 7 deletions
diff --git a/src/mm-generic-gsm.c b/src/mm-generic-gsm.c index c3c3d472..95540590 100644 --- a/src/mm-generic-gsm.c +++ b/src/mm-generic-gsm.c @@ -1541,6 +1541,27 @@ enable_done (MMAtSerialPort *port, } static void +enable_power_up_check_needed_done (MMModem *self, + guint32 needed, + GError *error, + gpointer user_data) +{ + MMGenericGsmPrivate *priv = MM_GENERIC_GSM_GET_PRIVATE (self); + char *cmd = NULL; + + if (needed) + g_object_get (G_OBJECT (self), MM_GENERIC_GSM_POWER_UP_CMD, &cmd, NULL); + else + mm_dbg ("Power-up not needed, skipping..."); + + if (cmd && strlen (cmd)) + mm_at_serial_port_queue_command (MM_AT_SERIAL_PORT (priv->primary), cmd, 5, enable_done, user_data); + else + enable_done (MM_AT_SERIAL_PORT (priv->primary), NULL, NULL, user_data); + g_free (cmd); +} + +static void init_done (MMAtSerialPort *port, GString *response, GError *error, @@ -1573,12 +1594,13 @@ init_done (MMAtSerialPort *port, mm_at_serial_port_queue_command (port, cmd, 2, NULL, NULL); g_free (cmd); - g_object_get (G_OBJECT (info->modem), MM_GENERIC_GSM_POWER_UP_CMD, &cmd, NULL); - if (cmd && strlen (cmd)) - mm_at_serial_port_queue_command (port, cmd, 5, enable_done, user_data); + /* Plugins can now check if they need the power up command or not */ + if (MM_GENERIC_GSM_GET_CLASS (info->modem)->do_enable_power_up_check_needed) + MM_GENERIC_GSM_GET_CLASS (info->modem)->do_enable_power_up_check_needed (MM_GENERIC_GSM (info->modem), + enable_power_up_check_needed_done, + info); else - enable_done (port, NULL, NULL, user_data); - g_free (cmd); + enable_power_up_check_needed_done (info->modem, TRUE, NULL, info); } static void @@ -4875,7 +4897,7 @@ ussd_send_done (MMAtSerialPort *port, ussd_update_state (MM_GENERIC_GSM (info->modem), MM_MODEM_GSM_USSD_STATE_IDLE); } - /* Otherwise if no error wait for the response to show up via the + /* Otherwise if no error wait for the response to show up via the * unsolicited response code. */ } diff --git a/src/mm-generic-gsm.h b/src/mm-generic-gsm.h index 57b65bf8..73a03ad2 100644 --- a/src/mm-generic-gsm.h +++ b/src/mm-generic-gsm.h @@ -90,7 +90,15 @@ typedef struct { * encountered during the process and the MMCallbackInfo created from the * callback and user_data passed in here. */ - void (*do_enable) (MMGenericGsm *self, MMModemFn callback, gpointer user_data); + void (*do_enable) (MMGenericGsm *self, + MMModemFn callback, + gpointer user_data); + + /* Called before issuing the power-up command, to check whether it should + * really be issued or not. */ + void (*do_enable_power_up_check_needed) (MMGenericGsm *self, + MMModemUIntFn callback, + gpointer user_data); /* Called after the generic class has attempted to power up the modem. * Subclasses can handle errors here if they know the device supports their @@ -143,6 +151,7 @@ typedef struct { void (*get_sim_iccid) (MMGenericGsm *self, MMModemStringFn callback, gpointer user_data); + } MMGenericGsmClass; GType mm_generic_gsm_get_type (void); diff --git a/src/mm-serial-port.c b/src/mm-serial-port.c index 70e33672..617da5a3 100644 --- a/src/mm-serial-port.c +++ b/src/mm-serial-port.c @@ -45,6 +45,7 @@ enum { PROP_SEND_DELAY, PROP_FD, PROP_SPEW_CONTROL, + PROP_RTS_CTS, LAST_PROP }; @@ -78,6 +79,7 @@ typedef struct { guint stopbits; guint64 send_delay; gboolean spew_control; + gboolean rts_cts; guint queue_id; guint watch_id; @@ -1059,6 +1061,7 @@ get_speed (MMSerialPort *self, speed_t *speed, GError **error) static gboolean set_speed (MMSerialPort *self, speed_t speed, GError **error) { + MMSerialPortPrivate *priv = MM_SERIAL_PORT_GET_PRIVATE (self); struct termios options; int fd, count = 4; gboolean success = FALSE; @@ -1079,6 +1082,10 @@ set_speed (MMSerialPort *self, speed_t speed, GError **error) cfsetospeed (&options, speed); options.c_cflag |= (CLOCAL | CREAD); + /* Configure flow control as well here */ + if (priv->rts_cts) + options.c_cflag |= (CRTSCTS); + while (count-- > 0) { if (tcsetattr (fd, TCSANOW, &options) == 0) { success = TRUE; @@ -1311,6 +1318,9 @@ set_property (GObject *object, guint prop_id, case PROP_SPEW_CONTROL: priv->spew_control = g_value_get_boolean (value); break; + case PROP_RTS_CTS: + priv->rts_cts = g_value_get_boolean (value); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -1345,6 +1355,9 @@ get_property (GObject *object, guint prop_id, case PROP_SPEW_CONTROL: g_value_set_boolean (value, priv->spew_control); break; + case PROP_RTS_CTS: + g_value_set_boolean (value, priv->rts_cts); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -1455,6 +1468,14 @@ mm_serial_port_class_init (MMSerialPortClass *klass) FALSE, G_PARAM_READWRITE)); + g_object_class_install_property + (object_class, PROP_RTS_CTS, + g_param_spec_boolean (MM_SERIAL_PORT_RTS_CTS, + "RTSCTS", + "Enable RTS/CTS flow control", + FALSE, + G_PARAM_READWRITE)); + /* Signals */ signals[BUFFER_FULL] = g_signal_new ("buffer-full", diff --git a/src/mm-serial-port.h b/src/mm-serial-port.h index e9997a58..a9f34402 100644 --- a/src/mm-serial-port.h +++ b/src/mm-serial-port.h @@ -35,6 +35,7 @@ #define MM_SERIAL_PORT_PARITY "parity" #define MM_SERIAL_PORT_STOPBITS "stopbits" #define MM_SERIAL_PORT_SEND_DELAY "send-delay" +#define MM_SERIAL_PORT_RTS_CTS "rts-cts" #define MM_SERIAL_PORT_FD "fd" /* Construct-only */ #define MM_SERIAL_PORT_SPEW_CONTROL "spew-control" /* Construct-only */ |