ports: add port initialization sequences instead of iface-modem's modem_init()
Instead of a custom modem_init() step in the 'Modem' interface, just add a sequence of port initialization commands in each port. While enabling for the first time a non-hotplugged modem, we will issue the port initialization commands only after having run the enabling_modem_init() step (i.e. after ATZ usually).
This commit is contained in:
@@ -43,37 +43,6 @@ G_DEFINE_TYPE_EXTENDED (MMBroadbandModemIridium, mm_broadband_modem_iridium, MM_
|
||||
G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM_3GPP, iface_modem_3gpp_init)
|
||||
G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM_MESSAGING, iface_modem_messaging_init));
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Initializing the modem (Modem interface) */
|
||||
|
||||
static const MMBaseModemAtCommand modem_init_sequence[] = {
|
||||
/* Init command */
|
||||
{ "E0 V1", 3, FALSE, NULL },
|
||||
{ "+CMEE=1", 3, FALSE, NULL },
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
static gboolean
|
||||
modem_init_finish (MMIfaceModem *self,
|
||||
GAsyncResult *res,
|
||||
GError **error)
|
||||
{
|
||||
return !!mm_base_modem_at_sequence_finish (MM_BASE_MODEM (self), res, NULL, error);
|
||||
}
|
||||
|
||||
static void
|
||||
modem_init (MMIfaceModem *self,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
mm_base_modem_at_sequence (MM_BASE_MODEM (self),
|
||||
modem_init_sequence,
|
||||
NULL, /* response_processor_context */
|
||||
NULL, /* response_processor_context_free */
|
||||
callback,
|
||||
user_data);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Operator Code and Name loading (3GPP interface) */
|
||||
|
||||
@@ -338,6 +307,16 @@ create_bearer (MMIfaceModem *self,
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static const gchar *primary_init_sequence[] = {
|
||||
/* Disable echo */
|
||||
"E0",
|
||||
/* Get word responses */
|
||||
"V1",
|
||||
/* Extended numeric codes */
|
||||
"+CMEE=1",
|
||||
NULL
|
||||
};
|
||||
|
||||
static void
|
||||
setup_ports (MMBroadbandModem *self)
|
||||
{
|
||||
@@ -354,6 +333,7 @@ setup_ports (MMBroadbandModem *self)
|
||||
|
||||
g_object_set (G_OBJECT (primary),
|
||||
MM_SERIAL_PORT_BAUD, 9600,
|
||||
MM_AT_SERIAL_PORT_INIT_SEQUENCE, primary_init_sequence,
|
||||
NULL);
|
||||
}
|
||||
|
||||
@@ -387,10 +367,6 @@ mm_broadband_modem_iridium_init (MMBroadbandModemIridium *self)
|
||||
static void
|
||||
iface_modem_init (MMIfaceModem *iface)
|
||||
{
|
||||
/* Initialization */
|
||||
iface->modem_init = modem_init;
|
||||
iface->modem_init_finish = modem_init_finish;
|
||||
|
||||
/* Create Iridium-specific SIM and bearer*/
|
||||
iface->create_sim = create_sim;
|
||||
iface->create_sim_finish = create_sim_finish;
|
||||
|
||||
@@ -304,35 +304,6 @@ set_allowed_modes (MMIfaceModem *_self,
|
||||
g_free (command);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Initializing the modem (Modem interface) */
|
||||
|
||||
static gboolean
|
||||
modem_init_finish (MMIfaceModem *self,
|
||||
GAsyncResult *res,
|
||||
GError **error)
|
||||
{
|
||||
/* Ignore errors */
|
||||
mm_base_modem_at_command_full_finish (MM_BASE_MODEM (self), res, NULL);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
modem_init (MMIfaceModem *self,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
mm_base_modem_at_command_full (MM_BASE_MODEM (self),
|
||||
mm_base_modem_peek_port_primary (MM_BASE_MODEM (self)),
|
||||
"E0 V1 X4 &C1 +CMEE=1",
|
||||
3,
|
||||
FALSE,
|
||||
FALSE,
|
||||
NULL, /* cancellable */
|
||||
callback,
|
||||
user_data);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Initializing the modem (during first enabling) */
|
||||
|
||||
@@ -1128,8 +1099,6 @@ iface_modem_init (MMIfaceModem *iface)
|
||||
iface->load_allowed_modes_finish = load_allowed_modes_finish;
|
||||
iface->set_allowed_modes = set_allowed_modes;
|
||||
iface->set_allowed_modes_finish = set_allowed_modes_finish;
|
||||
iface->modem_init = modem_init;
|
||||
iface->modem_init_finish = modem_init_finish;
|
||||
iface->reset = reset;
|
||||
iface->reset_finish = reset_finish;
|
||||
iface->factory_reset = factory_reset;
|
||||
|
||||
@@ -102,45 +102,6 @@ modem_load_supported_modes (MMIfaceModem *self,
|
||||
g_object_unref (result);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Modem initialization (Modem interface) */
|
||||
|
||||
static gboolean
|
||||
modem_init_finish (MMIfaceModem *self,
|
||||
GAsyncResult *res,
|
||||
GError **error)
|
||||
{
|
||||
return !mm_base_modem_at_sequence_finish (MM_BASE_MODEM (self), res, NULL, error);
|
||||
}
|
||||
|
||||
static const MMBaseModemAtCommand modem_init_sequence[] = {
|
||||
/* Also, when initializing a Nokia phone, first enable the echo,
|
||||
* and then disable it, so that we get it properly disabled.
|
||||
*/
|
||||
{ "E1 E0 V1", 3, FALSE, NULL },
|
||||
|
||||
/* Setup errors */
|
||||
{ "+CMEE=1", 3, FALSE, NULL },
|
||||
|
||||
/* Additional OPTIONAL initialization */
|
||||
{ "X4 &C1", 3, FALSE, NULL },
|
||||
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
static void
|
||||
modem_init (MMIfaceModem *self,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
mm_base_modem_at_sequence (MM_BASE_MODEM (self),
|
||||
modem_init_sequence,
|
||||
NULL, /* response_processor_context */
|
||||
NULL, /* response_processor_context_free */
|
||||
callback,
|
||||
user_data);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Initializing the modem (during first enabling) */
|
||||
|
||||
@@ -235,6 +196,39 @@ enabling_modem_init (MMBroadbandModem *self,
|
||||
retry_atz (ctx);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Setup ports (Broadband modem class) */
|
||||
|
||||
static const gchar *primary_init_sequence[] = {
|
||||
/* When initializing a Nokia port, first enable the echo,
|
||||
* and then disable it, so that we get it properly disabled. */
|
||||
"E1 E0",
|
||||
/* Get word responses */
|
||||
"V1",
|
||||
/* Extended numeric codes */
|
||||
"+CMEE=1",
|
||||
/* Report all call status */
|
||||
"X4",
|
||||
/* Assert DCD when carrier detected */
|
||||
"&C1",
|
||||
NULL
|
||||
};
|
||||
|
||||
static void
|
||||
setup_ports (MMBroadbandModem *self)
|
||||
{
|
||||
MMAtSerialPort *primary;
|
||||
|
||||
/* Call parent's setup ports first always */
|
||||
MM_BROADBAND_MODEM_CLASS (mm_broadband_modem_nokia_parent_class)->setup_ports (self);
|
||||
|
||||
primary = mm_base_modem_peek_port_primary (MM_BASE_MODEM (self));
|
||||
|
||||
g_object_set (primary,
|
||||
MM_AT_SERIAL_PORT_INIT_SEQUENCE, primary_init_sequence,
|
||||
NULL);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
MMBroadbandModemNokia *
|
||||
@@ -269,10 +263,6 @@ iface_modem_messaging_init (MMIfaceModemMessaging *iface)
|
||||
static void
|
||||
iface_modem_init (MMIfaceModem *iface)
|
||||
{
|
||||
/* Setup custom modem init */
|
||||
iface->modem_init = modem_init;
|
||||
iface->modem_init_finish = modem_init_finish;
|
||||
|
||||
/* Create Nokia-specific SIM*/
|
||||
iface->create_sim = create_sim;
|
||||
iface->create_sim_finish = create_sim_finish;
|
||||
@@ -302,6 +292,7 @@ mm_broadband_modem_nokia_class_init (MMBroadbandModemNokiaClass *klass)
|
||||
{
|
||||
MMBroadbandModemClass *broadband_modem_class = MM_BROADBAND_MODEM_CLASS (klass);
|
||||
|
||||
broadband_modem_class->setup_ports = setup_ports;
|
||||
broadband_modem_class->enabling_modem_init = enabling_modem_init;
|
||||
broadband_modem_class->enabling_modem_init_finish = enabling_modem_init_finish;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user