serial: refactor MMSerialPort into a base class and an AT-capable serial port
For QCDM devices we want most of what MMSerialPort does, but not the AT command handling stuff since the commands and responses aren't AT commands nor are they even strings. So convert everything that MMSerialPort does into a GByteArray, and let MMAtSerialPort handle the conversion to strings when necessary.
This commit is contained in:
@@ -112,7 +112,7 @@ int_from_match_item (GMatchInfo *match_info, guint32 num, gint *val)
|
||||
}
|
||||
|
||||
static void
|
||||
evdo_state_done (MMSerialPort *port,
|
||||
evdo_state_done (MMAtSerialPort *port,
|
||||
GString *response,
|
||||
GError *error,
|
||||
gpointer user_data)
|
||||
@@ -191,7 +191,7 @@ evdo_state_done (MMSerialPort *port,
|
||||
}
|
||||
|
||||
static void
|
||||
state_done (MMSerialPort *port,
|
||||
state_done (MMAtSerialPort *port,
|
||||
GString *response,
|
||||
GError *error,
|
||||
gpointer user_data)
|
||||
@@ -265,7 +265,7 @@ state_done (MMSerialPort *port,
|
||||
mm_generic_cdma_query_reg_state_set_callback_1x_state (info, reg_state);
|
||||
|
||||
/* Try for EVDO state too */
|
||||
mm_serial_port_queue_command (port, "*HSTATE?", 3, evdo_state_done, info);
|
||||
mm_at_serial_port_queue_command (port, "*HSTATE?", 3, evdo_state_done, info);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -274,10 +274,10 @@ query_registration_state (MMGenericCdma *cdma,
|
||||
gpointer user_data)
|
||||
{
|
||||
MMCallbackInfo *info;
|
||||
MMSerialPort *primary, *secondary, *port;
|
||||
MMAtSerialPort *primary, *secondary, *port;
|
||||
|
||||
port = primary = mm_generic_cdma_get_port (cdma, MM_PORT_TYPE_PRIMARY);
|
||||
secondary = mm_generic_cdma_get_port (cdma, MM_PORT_TYPE_SECONDARY);
|
||||
port = primary = mm_generic_cdma_get_at_port (cdma, MM_PORT_TYPE_PRIMARY);
|
||||
secondary = mm_generic_cdma_get_at_port (cdma, MM_PORT_TYPE_SECONDARY);
|
||||
|
||||
info = mm_generic_cdma_query_reg_state_callback_info_new (cdma, callback, user_data);
|
||||
|
||||
@@ -293,7 +293,7 @@ query_registration_state (MMGenericCdma *cdma,
|
||||
port = secondary;
|
||||
}
|
||||
|
||||
mm_serial_port_queue_command (port, "*STATE?", 3, state_done, info);
|
||||
mm_at_serial_port_queue_command (port, "*STATE?", 3, state_done, info);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
@@ -310,22 +310,22 @@ grab_port (MMModem *modem,
|
||||
GRegex *regex;
|
||||
|
||||
port = mm_generic_cdma_grab_port (MM_GENERIC_CDMA (modem), subsys, name, suggested_type, user_data, error);
|
||||
if (port && MM_IS_SERIAL_PORT (port)) {
|
||||
if (port && MM_IS_AT_SERIAL_PORT (port)) {
|
||||
/* Data state notifications */
|
||||
|
||||
/* Data call has connected */
|
||||
regex = g_regex_new ("\\r\\n\\*ACTIVE:(.*)\\r\\n", G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL);
|
||||
mm_serial_port_add_unsolicited_msg_handler (MM_SERIAL_PORT (port), regex, NULL, NULL, NULL);
|
||||
mm_at_serial_port_add_unsolicited_msg_handler (MM_AT_SERIAL_PORT (port), regex, NULL, NULL, NULL);
|
||||
g_regex_unref (regex);
|
||||
|
||||
/* Data call disconnected */
|
||||
regex = g_regex_new ("\\r\\n\\*INACTIVE:(.*)\\r\\n", G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL);
|
||||
mm_serial_port_add_unsolicited_msg_handler (MM_SERIAL_PORT (port), regex, NULL, NULL, NULL);
|
||||
mm_at_serial_port_add_unsolicited_msg_handler (MM_AT_SERIAL_PORT (port), regex, NULL, NULL, NULL);
|
||||
g_regex_unref (regex);
|
||||
|
||||
/* Modem is now dormant */
|
||||
regex = g_regex_new ("\\r\\n\\*DORMANT:(.*)\\r\\n", G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL);
|
||||
mm_serial_port_add_unsolicited_msg_handler (MM_SERIAL_PORT (port), regex, NULL, NULL, NULL);
|
||||
mm_at_serial_port_add_unsolicited_msg_handler (MM_AT_SERIAL_PORT (port), regex, NULL, NULL, NULL);
|
||||
g_regex_unref (regex);
|
||||
|
||||
/* Abnomral state notifications
|
||||
@@ -336,17 +336,17 @@ grab_port (MMModem *modem,
|
||||
|
||||
/* Network acquisition fail */
|
||||
regex = g_regex_new ("\\r\\n\\*OFFLINE:(.*)\\r\\n", G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL);
|
||||
mm_serial_port_add_unsolicited_msg_handler (MM_SERIAL_PORT (port), regex, NULL, NULL, NULL);
|
||||
mm_at_serial_port_add_unsolicited_msg_handler (MM_AT_SERIAL_PORT (port), regex, NULL, NULL, NULL);
|
||||
g_regex_unref (regex);
|
||||
|
||||
/* Registration fail */
|
||||
regex = g_regex_new ("\\r\\n\\*REGREQ:(.*)\\r\\n", G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL);
|
||||
mm_serial_port_add_unsolicited_msg_handler (MM_SERIAL_PORT (port), regex, NULL, NULL, NULL);
|
||||
mm_at_serial_port_add_unsolicited_msg_handler (MM_AT_SERIAL_PORT (port), regex, NULL, NULL, NULL);
|
||||
g_regex_unref (regex);
|
||||
|
||||
/* Authentication fail */
|
||||
regex = g_regex_new ("\\r\\n\\*AUTHREQ:(.*)\\r\\n", G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL);
|
||||
mm_serial_port_add_unsolicited_msg_handler (MM_SERIAL_PORT (port), regex, NULL, NULL, NULL);
|
||||
mm_at_serial_port_add_unsolicited_msg_handler (MM_AT_SERIAL_PORT (port), regex, NULL, NULL, NULL);
|
||||
g_regex_unref (regex);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "mm-errors.h"
|
||||
#include "mm-callback-info.h"
|
||||
#include "mm-modem-gsm-card.h"
|
||||
#include "mm-at-serial-port.h"
|
||||
|
||||
static void modem_init (MMModem *modem_class);
|
||||
static void modem_gsm_card_init (MMModemGsmCard *gsm_card_class);
|
||||
@@ -51,7 +52,7 @@ mm_modem_gobi_gsm_new (const char *device,
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
get_string_done (MMSerialPort *port,
|
||||
get_string_done (MMAtSerialPort *port,
|
||||
GString *response,
|
||||
GError *error,
|
||||
gpointer user_data)
|
||||
@@ -75,13 +76,13 @@ get_imsi (MMModemGsmCard *modem,
|
||||
MMModemStringFn callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
MMSerialPort *primary;
|
||||
MMAtSerialPort *primary;
|
||||
MMCallbackInfo *info;
|
||||
|
||||
info = mm_callback_info_string_new (MM_MODEM (modem), callback, user_data);
|
||||
primary = mm_generic_gsm_get_port (MM_GENERIC_GSM (modem), MM_PORT_TYPE_PRIMARY);
|
||||
primary = mm_generic_gsm_get_at_port (MM_GENERIC_GSM (modem), MM_PORT_TYPE_PRIMARY);
|
||||
g_assert (primary);
|
||||
mm_serial_port_queue_command_cached (primary, "+CIMI", 3, get_string_done, info);
|
||||
mm_at_serial_port_queue_command_cached (primary, "+CIMI", 3, get_string_done, info);
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
+18
-18
@@ -88,7 +88,7 @@ mm_modem_hso_new (const char *device,
|
||||
#define IGNORE_ERRORS_TAG "ignore-errors"
|
||||
|
||||
static void
|
||||
hso_call_control_done (MMSerialPort *port,
|
||||
hso_call_control_done (MMAtSerialPort *port,
|
||||
GString *response,
|
||||
GError *error,
|
||||
gpointer user_data)
|
||||
@@ -122,15 +122,15 @@ hso_call_control (MMModemHso *self,
|
||||
{
|
||||
MMCallbackInfo *info;
|
||||
char *command;
|
||||
MMSerialPort *primary;
|
||||
MMAtSerialPort *primary;
|
||||
|
||||
info = mm_callback_info_new (MM_MODEM (self), callback, user_data);
|
||||
mm_callback_info_set_data (info, IGNORE_ERRORS_TAG, GUINT_TO_POINTER (ignore_errors), NULL);
|
||||
|
||||
command = g_strdup_printf ("AT_OWANCALL=%d,%d,1", hso_get_cid (self), activate ? 1 : 0);
|
||||
primary = mm_generic_gsm_get_port (MM_GENERIC_GSM (self), MM_PORT_TYPE_PRIMARY);
|
||||
primary = mm_generic_gsm_get_at_port (MM_GENERIC_GSM (self), MM_PORT_TYPE_PRIMARY);
|
||||
g_assert (primary);
|
||||
mm_serial_port_queue_command (primary, command, 3, hso_call_control_done, info);
|
||||
mm_at_serial_port_queue_command (primary, command, 3, hso_call_control_done, info);
|
||||
g_free (command);
|
||||
}
|
||||
|
||||
@@ -203,7 +203,7 @@ clear_old_context (MMModem *modem,
|
||||
}
|
||||
|
||||
static void
|
||||
auth_done (MMSerialPort *port,
|
||||
auth_done (MMAtSerialPort *port,
|
||||
GString *response,
|
||||
GError *error,
|
||||
gpointer user_data)
|
||||
@@ -236,12 +236,12 @@ static void
|
||||
_internal_hso_modem_authenticate (MMModemHso *self, MMCallbackInfo *info)
|
||||
{
|
||||
MMModemHsoPrivate *priv = MM_MODEM_HSO_GET_PRIVATE (self);
|
||||
MMSerialPort *primary;
|
||||
MMAtSerialPort *primary;
|
||||
guint32 cid;
|
||||
char *command;
|
||||
const char *username, *password;
|
||||
|
||||
primary = mm_generic_gsm_get_port (MM_GENERIC_GSM (self), MM_PORT_TYPE_PRIMARY);
|
||||
primary = mm_generic_gsm_get_at_port (MM_GENERIC_GSM (self), MM_PORT_TYPE_PRIMARY);
|
||||
g_assert (primary);
|
||||
|
||||
cid = hso_get_cid (self);
|
||||
@@ -260,7 +260,7 @@ _internal_hso_modem_authenticate (MMModemHso *self, MMCallbackInfo *info)
|
||||
|
||||
}
|
||||
|
||||
mm_serial_port_queue_command (primary, command, 3, auth_done, info);
|
||||
mm_at_serial_port_queue_command (primary, command, 3, auth_done, info);
|
||||
g_free (command);
|
||||
}
|
||||
|
||||
@@ -390,7 +390,7 @@ ip4_config_invoke (MMCallbackInfo *info)
|
||||
}
|
||||
|
||||
static void
|
||||
get_ip4_config_done (MMSerialPort *port,
|
||||
get_ip4_config_done (MMAtSerialPort *port,
|
||||
GString *response,
|
||||
GError *error,
|
||||
gpointer user_data)
|
||||
@@ -453,13 +453,13 @@ get_ip4_config (MMModem *modem,
|
||||
{
|
||||
MMCallbackInfo *info;
|
||||
char *command;
|
||||
MMSerialPort *primary;
|
||||
MMAtSerialPort *primary;
|
||||
|
||||
info = mm_callback_info_new_full (modem, ip4_config_invoke, G_CALLBACK (callback), user_data);
|
||||
command = g_strdup_printf ("AT_OWANDATA=%d", hso_get_cid (MM_MODEM_HSO (modem)));
|
||||
primary = mm_generic_gsm_get_port (MM_GENERIC_GSM (modem), MM_PORT_TYPE_PRIMARY);
|
||||
primary = mm_generic_gsm_get_at_port (MM_GENERIC_GSM (modem), MM_PORT_TYPE_PRIMARY);
|
||||
g_assert (primary);
|
||||
mm_serial_port_queue_command (primary, command, 3, get_ip4_config_done, info);
|
||||
mm_at_serial_port_queue_command (primary, command, 3, get_ip4_config_done, info);
|
||||
g_free (command);
|
||||
}
|
||||
|
||||
@@ -469,12 +469,12 @@ disconnect (MMModem *modem,
|
||||
gpointer user_data)
|
||||
{
|
||||
MMCallbackInfo *info;
|
||||
MMSerialPort *primary;
|
||||
MMAtSerialPort *primary;
|
||||
|
||||
info = mm_callback_info_new (modem, callback, user_data);
|
||||
primary = mm_generic_gsm_get_port (MM_GENERIC_GSM (modem), MM_PORT_TYPE_PRIMARY);
|
||||
primary = mm_generic_gsm_get_at_port (MM_GENERIC_GSM (modem), MM_PORT_TYPE_PRIMARY);
|
||||
g_assert (primary);
|
||||
mm_serial_port_queue_command (primary, "AT_OWANCALL=1,0,0", 3, NULL, info);
|
||||
mm_at_serial_port_queue_command (primary, "AT_OWANCALL=1,0,0", 3, NULL, info);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
@@ -508,7 +508,7 @@ impl_hso_authenticate (MMModemHso *self,
|
||||
}
|
||||
|
||||
static void
|
||||
connection_enabled (MMSerialPort *port,
|
||||
connection_enabled (MMAtSerialPort *port,
|
||||
GMatchInfo *info,
|
||||
gpointer user_data)
|
||||
{
|
||||
@@ -676,7 +676,7 @@ grab_port (MMModem *modem,
|
||||
if (!port)
|
||||
goto out;
|
||||
|
||||
if (MM_IS_SERIAL_PORT (port)) {
|
||||
if (MM_IS_AT_SERIAL_PORT (port)) {
|
||||
g_object_set (G_OBJECT (port), MM_SERIAL_PORT_SEND_DELAY, (guint64) 10000, NULL);
|
||||
if (ptype == MM_PORT_TYPE_PRIMARY) {
|
||||
GRegex *regex;
|
||||
@@ -684,7 +684,7 @@ grab_port (MMModem *modem,
|
||||
mm_generic_gsm_set_unsolicited_registration (gsm, TRUE);
|
||||
|
||||
regex = g_regex_new ("_OWANCALL: (\\d),\\s*(\\d)\\r\\n", G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL);
|
||||
mm_serial_port_add_unsolicited_msg_handler (MM_SERIAL_PORT (port), regex, connection_enabled, modem, NULL);
|
||||
mm_at_serial_port_add_unsolicited_msg_handler (MM_AT_SERIAL_PORT (port), regex, connection_enabled, modem, NULL);
|
||||
g_regex_unref (regex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ parse_quality (const char *str, const char *detail)
|
||||
}
|
||||
|
||||
static void
|
||||
handle_1x_quality_change (MMSerialPort *port,
|
||||
handle_1x_quality_change (MMAtSerialPort *port,
|
||||
GMatchInfo *match_info,
|
||||
gpointer user_data)
|
||||
{
|
||||
@@ -99,9 +99,9 @@ handle_1x_quality_change (MMSerialPort *port,
|
||||
}
|
||||
|
||||
static void
|
||||
handle_evdo_quality_change (MMSerialPort *port,
|
||||
GMatchInfo *match_info,
|
||||
gpointer user_data)
|
||||
handle_evdo_quality_change (MMAtSerialPort *port,
|
||||
GMatchInfo *match_info,
|
||||
gpointer user_data)
|
||||
{
|
||||
MMModemHuaweiCdma *self = MM_MODEM_HUAWEI_CDMA (user_data);
|
||||
char *str;
|
||||
@@ -152,7 +152,7 @@ uint_from_match_item (GMatchInfo *match_info, guint32 num, guint32 *val)
|
||||
}
|
||||
|
||||
static void
|
||||
sysinfo_done (MMSerialPort *port,
|
||||
sysinfo_done (MMAtSerialPort *port,
|
||||
GString *response,
|
||||
GError *error,
|
||||
gpointer user_data)
|
||||
@@ -239,10 +239,10 @@ query_registration_state (MMGenericCdma *cdma,
|
||||
gpointer user_data)
|
||||
{
|
||||
MMCallbackInfo *info;
|
||||
MMSerialPort *primary, *secondary, *port;
|
||||
MMAtSerialPort *primary, *secondary, *port;
|
||||
|
||||
port = primary = mm_generic_cdma_get_port (cdma, MM_PORT_TYPE_PRIMARY);
|
||||
secondary = mm_generic_cdma_get_port (cdma, MM_PORT_TYPE_SECONDARY);
|
||||
port = primary = mm_generic_cdma_get_at_port (cdma, MM_PORT_TYPE_PRIMARY);
|
||||
secondary = mm_generic_cdma_get_at_port (cdma, MM_PORT_TYPE_SECONDARY);
|
||||
|
||||
info = mm_generic_cdma_query_reg_state_callback_info_new (cdma, callback, user_data);
|
||||
|
||||
@@ -258,7 +258,7 @@ query_registration_state (MMGenericCdma *cdma,
|
||||
port = secondary;
|
||||
}
|
||||
|
||||
mm_serial_port_queue_command (port, "^SYSINFO", 3, sysinfo_done, info);
|
||||
mm_at_serial_port_queue_command (port, "^SYSINFO", 3, sysinfo_done, info);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
@@ -275,14 +275,14 @@ grab_port (MMModem *modem,
|
||||
GRegex *regex;
|
||||
|
||||
port = mm_generic_cdma_grab_port (MM_GENERIC_CDMA (modem), subsys, name, suggested_type, user_data, error);
|
||||
if (port && MM_IS_SERIAL_PORT (port)) {
|
||||
if (port && MM_IS_AT_SERIAL_PORT (port)) {
|
||||
gboolean evdo0 = FALSE, evdoA = FALSE;
|
||||
|
||||
g_object_set (G_OBJECT (port), MM_PORT_CARRIER_DETECT, FALSE, NULL);
|
||||
|
||||
/* 1x signal level */
|
||||
regex = g_regex_new ("\\r\\n\\^RSSILVL:(\\d+)\\r\\n", G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL);
|
||||
mm_serial_port_add_unsolicited_msg_handler (MM_SERIAL_PORT (port), regex, handle_1x_quality_change, modem, NULL);
|
||||
mm_at_serial_port_add_unsolicited_msg_handler (MM_AT_SERIAL_PORT (port), regex, handle_1x_quality_change, modem, NULL);
|
||||
g_regex_unref (regex);
|
||||
|
||||
g_object_get (G_OBJECT (modem),
|
||||
@@ -293,7 +293,7 @@ grab_port (MMModem *modem,
|
||||
if (evdo0 || evdoA) {
|
||||
/* EVDO signal level */
|
||||
regex = g_regex_new ("\\r\\n\\^HRSSILVL:(\\d+)\\r\\n", G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL);
|
||||
mm_serial_port_add_unsolicited_msg_handler (MM_SERIAL_PORT (port), regex, handle_evdo_quality_change, modem, NULL);
|
||||
mm_at_serial_port_add_unsolicited_msg_handler (MM_AT_SERIAL_PORT (port), regex, handle_evdo_quality_change, modem, NULL);
|
||||
g_regex_unref (regex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#include "mm-modem-gsm-network.h"
|
||||
#include "mm-errors.h"
|
||||
#include "mm-callback-info.h"
|
||||
#include "mm-serial-port.h"
|
||||
#include "mm-at-serial-port.h"
|
||||
#include "mm-serial-parsers.h"
|
||||
|
||||
static void modem_init (MMModem *modem_class);
|
||||
@@ -101,7 +101,7 @@ parse_syscfg (MMModemHuaweiGsm *self,
|
||||
}
|
||||
|
||||
static void
|
||||
set_network_mode_done (MMSerialPort *port,
|
||||
set_network_mode_done (MMAtSerialPort *port,
|
||||
GString *response,
|
||||
GError *error,
|
||||
gpointer user_data)
|
||||
@@ -120,7 +120,7 @@ set_network_mode_done (MMSerialPort *port,
|
||||
}
|
||||
|
||||
static void
|
||||
set_network_mode_get_done (MMSerialPort *port,
|
||||
set_network_mode_get_done (MMAtSerialPort *port,
|
||||
GString *response,
|
||||
GError *error,
|
||||
gpointer user_data)
|
||||
@@ -169,7 +169,7 @@ set_network_mode_get_done (MMSerialPort *port,
|
||||
}
|
||||
|
||||
command = g_strdup_printf ("AT^SYSCFG=%d,%d,%X,%d,%d", a, b, band, u1, u2);
|
||||
mm_serial_port_queue_command (port, command, 3, set_network_mode_done, info);
|
||||
mm_at_serial_port_queue_command (port, command, 3, set_network_mode_done, info);
|
||||
g_free (command);
|
||||
}
|
||||
}
|
||||
@@ -182,7 +182,7 @@ set_network_mode (MMModemGsmNetwork *modem,
|
||||
gpointer user_data)
|
||||
{
|
||||
MMCallbackInfo *info;
|
||||
MMSerialPort *primary;
|
||||
MMAtSerialPort *primary;
|
||||
|
||||
info = mm_callback_info_new (MM_MODEM (modem), callback, user_data);
|
||||
|
||||
@@ -200,9 +200,9 @@ set_network_mode (MMModemGsmNetwork *modem,
|
||||
case MM_MODEM_GSM_MODE_3G_ONLY:
|
||||
/* Allowed values */
|
||||
mm_callback_info_set_data (info, "mode", GUINT_TO_POINTER (mode), NULL);
|
||||
primary = mm_generic_gsm_get_port (MM_GENERIC_GSM (modem), MM_PORT_TYPE_PRIMARY);
|
||||
primary = mm_generic_gsm_get_at_port (MM_GENERIC_GSM (modem), MM_PORT_TYPE_PRIMARY);
|
||||
g_assert (primary);
|
||||
mm_serial_port_queue_command (primary, "AT^SYSCFG?", 3, set_network_mode_get_done, info);
|
||||
mm_at_serial_port_queue_command (primary, "AT^SYSCFG?", 3, set_network_mode_get_done, info);
|
||||
return;
|
||||
default:
|
||||
info->error = g_error_new_literal (MM_MODEM_ERROR, MM_MODEM_ERROR_GENERAL, "Invalid mode.");
|
||||
@@ -213,7 +213,7 @@ set_network_mode (MMModemGsmNetwork *modem,
|
||||
}
|
||||
|
||||
static void
|
||||
get_network_mode_done (MMSerialPort *port,
|
||||
get_network_mode_done (MMAtSerialPort *port,
|
||||
GString *response,
|
||||
GError *error,
|
||||
gpointer user_data)
|
||||
@@ -249,17 +249,17 @@ get_network_mode (MMModemGsmNetwork *modem,
|
||||
} else {
|
||||
/* Get it from modem */
|
||||
MMCallbackInfo *info;
|
||||
MMSerialPort *primary;
|
||||
MMAtSerialPort *primary;
|
||||
|
||||
info = mm_callback_info_uint_new (MM_MODEM (modem), callback, user_data);
|
||||
primary = mm_generic_gsm_get_port (MM_GENERIC_GSM (modem), MM_PORT_TYPE_PRIMARY);
|
||||
primary = mm_generic_gsm_get_at_port (MM_GENERIC_GSM (modem), MM_PORT_TYPE_PRIMARY);
|
||||
g_assert (primary);
|
||||
mm_serial_port_queue_command (primary, "AT^SYSCFG?", 3, get_network_mode_done, info);
|
||||
mm_at_serial_port_queue_command (primary, "AT^SYSCFG?", 3, get_network_mode_done, info);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
set_band_done (MMSerialPort *port,
|
||||
set_band_done (MMAtSerialPort *port,
|
||||
GString *response,
|
||||
GError *error,
|
||||
gpointer user_data)
|
||||
@@ -278,7 +278,7 @@ set_band_done (MMSerialPort *port,
|
||||
}
|
||||
|
||||
static void
|
||||
set_band_get_done (MMSerialPort *port,
|
||||
set_band_get_done (MMAtSerialPort *port,
|
||||
GString *response,
|
||||
GError *error,
|
||||
gpointer user_data)
|
||||
@@ -320,7 +320,7 @@ set_band_get_done (MMSerialPort *port,
|
||||
}
|
||||
|
||||
command = g_strdup_printf ("AT^SYSCFG=%d,%d,%X,%d,%d", a, b, band, u1, u2);
|
||||
mm_serial_port_queue_command (port, command, 3, set_band_done, info);
|
||||
mm_at_serial_port_queue_command (port, command, 3, set_band_done, info);
|
||||
g_free (command);
|
||||
}
|
||||
}
|
||||
@@ -333,7 +333,7 @@ set_band (MMModemGsmNetwork *modem,
|
||||
gpointer user_data)
|
||||
{
|
||||
MMCallbackInfo *info;
|
||||
MMSerialPort *primary;
|
||||
MMAtSerialPort *primary;
|
||||
|
||||
info = mm_callback_info_new (MM_MODEM (modem), callback, user_data);
|
||||
|
||||
@@ -344,9 +344,9 @@ set_band (MMModemGsmNetwork *modem,
|
||||
case MM_MODEM_GSM_BAND_U2100:
|
||||
case MM_MODEM_GSM_BAND_PCS:
|
||||
mm_callback_info_set_data (info, "band", GUINT_TO_POINTER (band), NULL);
|
||||
primary = mm_generic_gsm_get_port (MM_GENERIC_GSM (modem), MM_PORT_TYPE_PRIMARY);
|
||||
primary = mm_generic_gsm_get_at_port (MM_GENERIC_GSM (modem), MM_PORT_TYPE_PRIMARY);
|
||||
g_assert (primary);
|
||||
mm_serial_port_queue_command (primary, "AT^SYSCFG?", 3, set_band_get_done, info);
|
||||
mm_at_serial_port_queue_command (primary, "AT^SYSCFG?", 3, set_band_get_done, info);
|
||||
return;
|
||||
default:
|
||||
info->error = g_error_new_literal (MM_MODEM_ERROR, MM_MODEM_ERROR_GENERAL, "Invalid band.");
|
||||
@@ -357,7 +357,7 @@ set_band (MMModemGsmNetwork *modem,
|
||||
}
|
||||
|
||||
static void
|
||||
get_band_done (MMSerialPort *port,
|
||||
get_band_done (MMAtSerialPort *port,
|
||||
GString *response,
|
||||
GError *error,
|
||||
gpointer user_data)
|
||||
@@ -382,7 +382,7 @@ get_band (MMModemGsmNetwork *modem,
|
||||
gpointer user_data)
|
||||
{
|
||||
MMModemHuaweiGsmPrivate *priv = MM_MODEM_HUAWEI_GSM_GET_PRIVATE (modem);
|
||||
MMSerialPort *primary;
|
||||
MMAtSerialPort *primary;
|
||||
|
||||
if (priv->band != MM_MODEM_GSM_BAND_ANY) {
|
||||
/* have cached mode (from an unsolicited message). Use that */
|
||||
@@ -396,9 +396,9 @@ get_band (MMModemGsmNetwork *modem,
|
||||
MMCallbackInfo *info;
|
||||
|
||||
info = mm_callback_info_uint_new (MM_MODEM (modem), callback, user_data);
|
||||
primary = mm_generic_gsm_get_port (MM_GENERIC_GSM (modem), MM_PORT_TYPE_PRIMARY);
|
||||
primary = mm_generic_gsm_get_at_port (MM_GENERIC_GSM (modem), MM_PORT_TYPE_PRIMARY);
|
||||
g_assert (primary);
|
||||
mm_serial_port_queue_command (primary, "AT^SYSCFG?", 3, get_band_done, info);
|
||||
mm_at_serial_port_queue_command (primary, "AT^SYSCFG?", 3, get_band_done, info);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -428,7 +428,7 @@ get_signal_quality (MMModemGsmNetwork *modem,
|
||||
/* Unsolicited message handlers */
|
||||
|
||||
static void
|
||||
handle_signal_quality_change (MMSerialPort *port,
|
||||
handle_signal_quality_change (MMAtSerialPort *port,
|
||||
GMatchInfo *match_info,
|
||||
gpointer user_data)
|
||||
{
|
||||
@@ -454,7 +454,7 @@ handle_signal_quality_change (MMSerialPort *port,
|
||||
}
|
||||
|
||||
static void
|
||||
handle_mode_change (MMSerialPort *port,
|
||||
handle_mode_change (MMAtSerialPort *port,
|
||||
GMatchInfo *match_info,
|
||||
gpointer user_data)
|
||||
{
|
||||
@@ -494,7 +494,7 @@ handle_mode_change (MMSerialPort *port,
|
||||
}
|
||||
|
||||
static void
|
||||
handle_status_change (MMSerialPort *port,
|
||||
handle_status_change (MMAtSerialPort *port,
|
||||
GMatchInfo *match_info,
|
||||
gpointer user_data)
|
||||
{
|
||||
@@ -546,16 +546,16 @@ grab_port (MMModem *modem,
|
||||
}
|
||||
|
||||
if (usbif == 0) {
|
||||
if (!mm_generic_gsm_get_port (gsm, MM_PORT_TYPE_PRIMARY))
|
||||
if (!mm_generic_gsm_get_at_port (gsm, MM_PORT_TYPE_PRIMARY))
|
||||
ptype = MM_PORT_TYPE_PRIMARY;
|
||||
} else if (suggested_type == MM_PORT_TYPE_SECONDARY) {
|
||||
if (!mm_generic_gsm_get_port (gsm, MM_PORT_TYPE_SECONDARY))
|
||||
if (!mm_generic_gsm_get_at_port (gsm, MM_PORT_TYPE_SECONDARY))
|
||||
ptype = MM_PORT_TYPE_SECONDARY;
|
||||
}
|
||||
|
||||
port = mm_generic_gsm_grab_port (gsm, subsys, name, ptype, error);
|
||||
|
||||
if (port && MM_IS_SERIAL_PORT (port)) {
|
||||
if (port && MM_IS_AT_SERIAL_PORT (port)) {
|
||||
g_object_set (G_OBJECT (port), MM_PORT_CARRIER_DETECT, FALSE, NULL);
|
||||
if (ptype == MM_PORT_TYPE_SECONDARY) {
|
||||
GRegex *regex;
|
||||
@@ -563,19 +563,19 @@ grab_port (MMModem *modem,
|
||||
mm_generic_gsm_set_unsolicited_registration (MM_GENERIC_GSM (modem), TRUE);
|
||||
|
||||
regex = g_regex_new ("\\r\\n\\^RSSI:(\\d+)\\r\\n", G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL);
|
||||
mm_serial_port_add_unsolicited_msg_handler (MM_SERIAL_PORT (port), regex, handle_signal_quality_change, modem, NULL);
|
||||
mm_at_serial_port_add_unsolicited_msg_handler (MM_AT_SERIAL_PORT (port), regex, handle_signal_quality_change, modem, NULL);
|
||||
g_regex_unref (regex);
|
||||
|
||||
regex = g_regex_new ("\\r\\n\\^MODE:(\\d),(\\d)\\r\\n", G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL);
|
||||
mm_serial_port_add_unsolicited_msg_handler (MM_SERIAL_PORT (port), regex, handle_mode_change, modem, NULL);
|
||||
mm_at_serial_port_add_unsolicited_msg_handler (MM_AT_SERIAL_PORT (port), regex, handle_mode_change, modem, NULL);
|
||||
g_regex_unref (regex);
|
||||
|
||||
regex = g_regex_new ("\\r\\n\\^DSFLOWRPT:(.+)\\r\\n", G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL);
|
||||
mm_serial_port_add_unsolicited_msg_handler (MM_SERIAL_PORT (port), regex, handle_status_change, modem, NULL);
|
||||
mm_at_serial_port_add_unsolicited_msg_handler (MM_AT_SERIAL_PORT (port), regex, handle_status_change, modem, NULL);
|
||||
g_regex_unref (regex);
|
||||
|
||||
regex = g_regex_new ("\\r\\n\\^BOOT:.+\\r\\n", G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL);
|
||||
mm_serial_port_add_unsolicited_msg_handler (MM_SERIAL_PORT (port), regex, NULL, modem, NULL);
|
||||
mm_at_serial_port_add_unsolicited_msg_handler (MM_AT_SERIAL_PORT (port), regex, NULL, modem, NULL);
|
||||
g_regex_unref (regex);
|
||||
}
|
||||
}
|
||||
|
||||
+57
-56
@@ -120,15 +120,15 @@ register_done (gpointer user_data)
|
||||
MMModemMbm *self = MM_MODEM_MBM (reg_data->modem);
|
||||
MMModemMbmPrivate *priv = MM_MODEM_MBM_GET_PRIVATE (self);
|
||||
MMModemGsmNetwork *parent_modem_iface;
|
||||
MMSerialPort *primary;
|
||||
MMAtSerialPort *primary;
|
||||
|
||||
priv->reg_id = 0;
|
||||
|
||||
primary = mm_generic_gsm_get_port (MM_GENERIC_GSM (self), MM_PORT_TYPE_PRIMARY);
|
||||
primary = mm_generic_gsm_get_at_port (MM_GENERIC_GSM (self), MM_PORT_TYPE_PRIMARY);
|
||||
g_assert (primary);
|
||||
|
||||
mm_serial_port_queue_command (primary, "+CREG=1", 3, NULL, NULL);
|
||||
mm_serial_port_queue_command (primary, "+CMER=3,0,0,1", 3, NULL, NULL);
|
||||
mm_at_serial_port_queue_command (primary, "+CREG=1", 3, NULL, NULL);
|
||||
mm_at_serial_port_queue_command (primary, "+CMER=3,0,0,1", 3, NULL, NULL);
|
||||
|
||||
parent_modem_iface = g_type_interface_peek_parent (MM_MODEM_GSM_NETWORK_GET_INTERFACE (self));
|
||||
parent_modem_iface->do_register (MM_MODEM_GSM_NETWORK (self),
|
||||
@@ -185,7 +185,7 @@ mbm_parse_network_mode (MMModemGsmMode network_mode)
|
||||
}
|
||||
|
||||
static void
|
||||
mbm_set_network_mode_done (MMSerialPort *port,
|
||||
mbm_set_network_mode_done (MMAtSerialPort *port,
|
||||
GString *response,
|
||||
GError *error,
|
||||
gpointer user_data)
|
||||
@@ -206,19 +206,19 @@ set_network_mode (MMModemGsmNetwork *modem,
|
||||
{
|
||||
MMCallbackInfo *info;
|
||||
char *command;
|
||||
MMSerialPort *primary;
|
||||
MMAtSerialPort *primary;
|
||||
|
||||
info = mm_callback_info_new (MM_MODEM (modem), callback, user_data);
|
||||
primary = mm_generic_gsm_get_port (MM_GENERIC_GSM (modem), MM_PORT_TYPE_PRIMARY);
|
||||
primary = mm_generic_gsm_get_at_port (MM_GENERIC_GSM (modem), MM_PORT_TYPE_PRIMARY);
|
||||
g_assert (primary);
|
||||
|
||||
command = g_strdup_printf ("+CFUN=%d", mbm_parse_network_mode (mode));
|
||||
mm_serial_port_queue_command (primary, command, 3, mbm_set_network_mode_done, info);
|
||||
mm_at_serial_port_queue_command (primary, command, 3, mbm_set_network_mode_done, info);
|
||||
g_free (command);
|
||||
}
|
||||
|
||||
static void
|
||||
get_network_mode_done (MMSerialPort *port,
|
||||
get_network_mode_done (MMAtSerialPort *port,
|
||||
GString *response,
|
||||
GError *error,
|
||||
gpointer user_data)
|
||||
@@ -273,12 +273,12 @@ get_network_mode (MMModemGsmNetwork *modem,
|
||||
gpointer user_data)
|
||||
{
|
||||
MMCallbackInfo *info;
|
||||
MMSerialPort *primary;
|
||||
MMAtSerialPort *primary;
|
||||
|
||||
info = mm_callback_info_uint_new (MM_MODEM (modem), callback, user_data);
|
||||
primary = mm_generic_gsm_get_port (MM_GENERIC_GSM (modem), MM_PORT_TYPE_PRIMARY);
|
||||
primary = mm_generic_gsm_get_at_port (MM_GENERIC_GSM (modem), MM_PORT_TYPE_PRIMARY);
|
||||
g_assert (primary);
|
||||
mm_serial_port_queue_command (primary, "*ERINFO?", 3, get_network_mode_done, info);
|
||||
mm_at_serial_port_queue_command (primary, "*ERINFO?", 3, get_network_mode_done, info);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
@@ -311,7 +311,7 @@ simple_connect (MMModemSimple *simple,
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
mbm_enable_done (MMSerialPort *port,
|
||||
mbm_enable_done (MMAtSerialPort *port,
|
||||
GString *response,
|
||||
GError *error,
|
||||
gpointer user_data)
|
||||
@@ -322,7 +322,7 @@ mbm_enable_done (MMSerialPort *port,
|
||||
}
|
||||
|
||||
static void
|
||||
mbm_enap0_done (MMSerialPort *port,
|
||||
mbm_enap0_done (MMAtSerialPort *port,
|
||||
GString *response,
|
||||
GError *error,
|
||||
gpointer user_data)
|
||||
@@ -335,12 +335,12 @@ mbm_enap0_done (MMSerialPort *port,
|
||||
priv->network_mode = MBM_NETWORK_MODE_ANY;
|
||||
|
||||
command = g_strdup_printf ("+CFUN=%d", priv->network_mode);
|
||||
mm_serial_port_queue_command (port, command, 3, mbm_enable_done, info);
|
||||
mm_at_serial_port_queue_command (port, command, 3, mbm_enable_done, info);
|
||||
g_free (command);
|
||||
}
|
||||
|
||||
static void
|
||||
mbm_init_done (MMSerialPort *port,
|
||||
mbm_init_done (MMAtSerialPort *port,
|
||||
GString *response,
|
||||
GError *error,
|
||||
gpointer user_data)
|
||||
@@ -356,17 +356,17 @@ mbm_init_done (MMSerialPort *port,
|
||||
if (!priv->network_mode)
|
||||
priv->network_mode = MBM_NETWORK_MODE_ANY;
|
||||
|
||||
mm_serial_port_queue_command (port, "*ENAP=0", 3, mbm_enap0_done, info);
|
||||
mm_at_serial_port_queue_command (port, "*ENAP=0", 3, mbm_enap0_done, info);
|
||||
}
|
||||
|
||||
static void
|
||||
do_init (MMSerialPort *port, MMCallbackInfo *info)
|
||||
do_init (MMAtSerialPort *port, MMCallbackInfo *info)
|
||||
{
|
||||
mm_serial_port_queue_command (port, "&F E0 V1 X4 &C1 +CMEE=1", 3, mbm_init_done, info);
|
||||
mm_at_serial_port_queue_command (port, "&F E0 V1 X4 &C1 +CMEE=1", 3, mbm_init_done, info);
|
||||
}
|
||||
|
||||
static void
|
||||
mbm_emrdy_done (MMSerialPort *port,
|
||||
mbm_emrdy_done (MMAtSerialPort *port,
|
||||
GString *response,
|
||||
GError *error,
|
||||
gpointer user_data)
|
||||
@@ -389,18 +389,18 @@ do_enable (MMGenericGsm *self, MMModemFn callback, gpointer user_data)
|
||||
{
|
||||
MMModemMbmPrivate *priv = MM_MODEM_MBM_GET_PRIVATE (self);
|
||||
MMCallbackInfo *info;
|
||||
MMSerialPort *primary;
|
||||
MMAtSerialPort *primary;
|
||||
|
||||
info = mm_callback_info_new (MM_MODEM (self), callback, user_data);
|
||||
|
||||
primary = mm_generic_gsm_get_port (self, MM_PORT_TYPE_PRIMARY);
|
||||
primary = mm_generic_gsm_get_at_port (self, MM_PORT_TYPE_PRIMARY);
|
||||
g_assert (primary);
|
||||
|
||||
if (priv->have_emrdy) {
|
||||
/* Modem is ready, no need to check EMRDY */
|
||||
do_init (primary, info);
|
||||
} else
|
||||
mm_serial_port_queue_command (primary, "*EMRDY?", 5, mbm_emrdy_done, info);
|
||||
mm_at_serial_port_queue_command (primary, "*EMRDY?", 5, mbm_emrdy_done, info);
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
@@ -410,7 +410,7 @@ typedef struct {
|
||||
} DisableInfo;
|
||||
|
||||
static void
|
||||
disable_creg_cmer_done (MMSerialPort *port,
|
||||
disable_creg_cmer_done (MMAtSerialPort *port,
|
||||
GString *response,
|
||||
GError *error,
|
||||
gpointer user_data)
|
||||
@@ -429,7 +429,7 @@ disable (MMModem *modem,
|
||||
MMModemFn callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
MMSerialPort *primary;
|
||||
MMAtSerialPort *primary;
|
||||
DisableInfo *info;
|
||||
|
||||
info = g_malloc0 (sizeof (DisableInfo));
|
||||
@@ -437,11 +437,11 @@ disable (MMModem *modem,
|
||||
info->user_data = user_data;
|
||||
info->modem = modem;
|
||||
|
||||
primary = mm_generic_gsm_get_port (MM_GENERIC_GSM (modem), MM_PORT_TYPE_PRIMARY);
|
||||
primary = mm_generic_gsm_get_at_port (MM_GENERIC_GSM (modem), MM_PORT_TYPE_PRIMARY);
|
||||
g_assert (primary);
|
||||
|
||||
/* Turn off unsolicited +CIEV signal strength indicator */
|
||||
mm_serial_port_queue_command (primary, "+CREG=0;+CMER=0", 5, disable_creg_cmer_done, info);
|
||||
mm_at_serial_port_queue_command (primary, "+CREG=0;+CMER=0", 5, disable_creg_cmer_done, info);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -467,13 +467,13 @@ disconnect (MMModem *modem,
|
||||
gpointer user_data)
|
||||
{
|
||||
MMCallbackInfo *info;
|
||||
MMSerialPort *primary;
|
||||
MMAtSerialPort *primary;
|
||||
|
||||
mm_modem_set_state (modem, MM_MODEM_STATE_DISCONNECTING, MM_MODEM_STATE_REASON_NONE);
|
||||
|
||||
primary = mm_generic_gsm_get_port (MM_GENERIC_GSM (modem), MM_PORT_TYPE_PRIMARY);
|
||||
primary = mm_generic_gsm_get_at_port (MM_GENERIC_GSM (modem), MM_PORT_TYPE_PRIMARY);
|
||||
g_assert (primary);
|
||||
mm_serial_port_queue_command (primary, "*ENAP=0", 3, NULL, NULL);
|
||||
mm_at_serial_port_queue_command (primary, "*ENAP=0", 3, NULL, NULL);
|
||||
|
||||
mm_generic_gsm_update_enabled_state (MM_GENERIC_GSM (modem), FALSE, MM_MODEM_STATE_REASON_NONE);
|
||||
|
||||
@@ -484,7 +484,7 @@ disconnect (MMModem *modem,
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
mbm_emrdy_received (MMSerialPort *port,
|
||||
mbm_emrdy_received (MMAtSerialPort *port,
|
||||
GMatchInfo *info,
|
||||
gpointer user_data)
|
||||
{
|
||||
@@ -492,7 +492,7 @@ mbm_emrdy_received (MMSerialPort *port,
|
||||
}
|
||||
|
||||
static void
|
||||
mbm_pacsp_received (MMSerialPort *port,
|
||||
mbm_pacsp_received (MMAtSerialPort *port,
|
||||
GMatchInfo *info,
|
||||
gpointer user_data)
|
||||
{
|
||||
@@ -500,7 +500,7 @@ mbm_pacsp_received (MMSerialPort *port,
|
||||
}
|
||||
|
||||
static void
|
||||
mbm_ciev_received (MMSerialPort *port,
|
||||
mbm_ciev_received (MMAtSerialPort *port,
|
||||
GMatchInfo *info,
|
||||
gpointer user_data)
|
||||
{
|
||||
@@ -532,7 +532,7 @@ mbm_do_connect_done (MMModemMbm *self)
|
||||
}
|
||||
|
||||
static void
|
||||
mbm_e2nap_received (MMSerialPort *port,
|
||||
mbm_e2nap_received (MMAtSerialPort *port,
|
||||
GMatchInfo *info,
|
||||
gpointer user_data)
|
||||
{
|
||||
@@ -558,7 +558,7 @@ mbm_e2nap_received (MMSerialPort *port,
|
||||
}
|
||||
|
||||
static void
|
||||
enap_poll_response (MMSerialPort *port,
|
||||
enap_poll_response (MMAtSerialPort *port,
|
||||
GString *response,
|
||||
GError *error,
|
||||
gpointer user_data)
|
||||
@@ -593,20 +593,21 @@ static gboolean
|
||||
enap_poll (gpointer user_data)
|
||||
{
|
||||
MMCallbackInfo *info = (MMCallbackInfo *) user_data;
|
||||
MMSerialPort *port = mm_generic_gsm_get_port (MM_GENERIC_GSM (info->modem), MM_PORT_TYPE_PRIMARY);
|
||||
MMAtSerialPort *port;
|
||||
|
||||
port = mm_generic_gsm_get_at_port (MM_GENERIC_GSM (info->modem), MM_PORT_TYPE_PRIMARY);
|
||||
g_assert (port);
|
||||
|
||||
mm_serial_port_queue_command (port, "AT*ENAP?", 3, enap_poll_response, user_data);
|
||||
mm_at_serial_port_queue_command (port, "AT*ENAP?", 3, enap_poll_response, user_data);
|
||||
/* we cancel this in the _done function if all is fine */
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
enap_done (MMSerialPort *port,
|
||||
GString *response,
|
||||
GError *error,
|
||||
gpointer user_data)
|
||||
enap_done (MMAtSerialPort *port,
|
||||
GString *response,
|
||||
GError *error,
|
||||
gpointer user_data)
|
||||
{
|
||||
MMCallbackInfo *info = (MMCallbackInfo *) user_data;
|
||||
guint tid;
|
||||
@@ -619,11 +620,11 @@ enap_done (MMSerialPort *port,
|
||||
tid = g_timeout_add_seconds (1, enap_poll, user_data);
|
||||
/* remember poll id as callback info object, with source_remove as free func */
|
||||
mm_callback_info_set_data (info, "mbm-enap-poll-id", GUINT_TO_POINTER (tid), (GFreeFunc) g_source_remove);
|
||||
mm_serial_port_queue_command (port, "AT*E2NAP=1", 3, NULL, NULL);
|
||||
mm_at_serial_port_queue_command (port, "AT*E2NAP=1", 3, NULL, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
mbm_auth_done (MMSerialPort *port,
|
||||
mbm_auth_done (MMAtSerialPort *port,
|
||||
GString *response,
|
||||
GError *error,
|
||||
gpointer user_data)
|
||||
@@ -640,7 +641,7 @@ mbm_auth_done (MMSerialPort *port,
|
||||
|
||||
cid = mm_generic_gsm_get_cid (modem);
|
||||
command = g_strdup_printf ("AT*ENAP=1,%d", cid);
|
||||
mm_serial_port_queue_command (port, command, 3, enap_done, user_data);
|
||||
mm_at_serial_port_queue_command (port, command, 3, enap_done, user_data);
|
||||
g_free (command);
|
||||
}
|
||||
|
||||
@@ -650,9 +651,9 @@ mbm_modem_authenticate (MMModemMbm *self,
|
||||
const char *password,
|
||||
gpointer user_data)
|
||||
{
|
||||
MMSerialPort *primary;
|
||||
MMAtSerialPort *primary;
|
||||
|
||||
primary = mm_generic_gsm_get_port (MM_GENERIC_GSM (self), MM_PORT_TYPE_PRIMARY);
|
||||
primary = mm_generic_gsm_get_at_port (MM_GENERIC_GSM (self), MM_PORT_TYPE_PRIMARY);
|
||||
g_assert (primary);
|
||||
|
||||
if (username || password) {
|
||||
@@ -663,7 +664,7 @@ mbm_modem_authenticate (MMModemMbm *self,
|
||||
username ? username : "",
|
||||
password ? password : "");
|
||||
|
||||
mm_serial_port_queue_command (primary, command, 3, mbm_auth_done, user_data);
|
||||
mm_at_serial_port_queue_command (primary, command, 3, mbm_auth_done, user_data);
|
||||
g_free (command);
|
||||
} else
|
||||
mbm_auth_done (primary, NULL, NULL, user_data);
|
||||
@@ -723,43 +724,43 @@ grab_port (MMModem *modem,
|
||||
|
||||
if (!strcmp (subsys, "tty")) {
|
||||
if (suggested_type == MM_PORT_TYPE_UNKNOWN) {
|
||||
if (!mm_generic_gsm_get_port (gsm, MM_PORT_TYPE_PRIMARY))
|
||||
if (!mm_generic_gsm_get_at_port (gsm, MM_PORT_TYPE_PRIMARY))
|
||||
ptype = MM_PORT_TYPE_PRIMARY;
|
||||
else if (!mm_generic_gsm_get_port (gsm, MM_PORT_TYPE_SECONDARY))
|
||||
else if (!mm_generic_gsm_get_at_port (gsm, MM_PORT_TYPE_SECONDARY))
|
||||
ptype = MM_PORT_TYPE_SECONDARY;
|
||||
} else
|
||||
ptype = suggested_type;
|
||||
}
|
||||
|
||||
port = mm_generic_gsm_grab_port (gsm, subsys, name, ptype, error);
|
||||
if (port && MM_IS_SERIAL_PORT (port) && (ptype == MM_PORT_TYPE_PRIMARY)) {
|
||||
if (port && MM_IS_AT_SERIAL_PORT (port) && (ptype == MM_PORT_TYPE_PRIMARY)) {
|
||||
GRegex *regex;
|
||||
|
||||
mm_generic_gsm_set_unsolicited_registration (MM_GENERIC_GSM (modem), TRUE);
|
||||
|
||||
regex = g_regex_new ("\\r\\n\\*EMRDY: \\d\\r\\n", G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL);
|
||||
mm_serial_port_add_unsolicited_msg_handler (MM_SERIAL_PORT (port), regex, mbm_emrdy_received, modem, NULL);
|
||||
mm_at_serial_port_add_unsolicited_msg_handler (MM_AT_SERIAL_PORT (port), regex, mbm_emrdy_received, modem, NULL);
|
||||
g_regex_unref (regex);
|
||||
|
||||
regex = g_regex_new ("\\r\\n\\*E2NAP: (\\d)\\r\\n", G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL);
|
||||
mm_serial_port_add_unsolicited_msg_handler (MM_SERIAL_PORT (port), regex, mbm_e2nap_received, modem, NULL);
|
||||
mm_at_serial_port_add_unsolicited_msg_handler (MM_AT_SERIAL_PORT (port), regex, mbm_e2nap_received, modem, NULL);
|
||||
g_regex_unref (regex);
|
||||
|
||||
regex = g_regex_new ("\\r\\n\\+PACSP(\\d)\\r\\n", G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL);
|
||||
mm_serial_port_add_unsolicited_msg_handler (MM_SERIAL_PORT (port), regex, mbm_pacsp_received, modem, NULL);
|
||||
mm_at_serial_port_add_unsolicited_msg_handler (MM_AT_SERIAL_PORT (port), regex, mbm_pacsp_received, modem, NULL);
|
||||
g_regex_unref (regex);
|
||||
|
||||
regex = g_regex_new ("\\r\\n\\+CIEV: (\\d),(\\d)\\r\\n", G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL);
|
||||
mm_serial_port_add_unsolicited_msg_handler (MM_SERIAL_PORT (port), regex, mbm_ciev_received, modem, NULL);
|
||||
mm_at_serial_port_add_unsolicited_msg_handler (MM_AT_SERIAL_PORT (port), regex, mbm_ciev_received, modem, NULL);
|
||||
g_regex_unref (regex);
|
||||
|
||||
/* also consume unsolicited mbm messages we are not interested in them - see LP: #416418 */
|
||||
regex = g_regex_new ("\\R\\*ESTKSMENU:.*\\R", G_REGEX_RAW | G_REGEX_OPTIMIZE | G_REGEX_MULTILINE | G_REGEX_NEWLINE_CRLF, G_REGEX_MATCH_NEWLINE_CRLF, NULL);
|
||||
mm_serial_port_add_unsolicited_msg_handler (MM_SERIAL_PORT (port), regex, NULL, modem, NULL);
|
||||
mm_at_serial_port_add_unsolicited_msg_handler (MM_AT_SERIAL_PORT (port), regex, NULL, modem, NULL);
|
||||
g_regex_unref (regex);
|
||||
|
||||
regex = g_regex_new ("\\r\\n\\*EMWI: (\\d),(\\d).*\\r\\n", G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL);
|
||||
mm_serial_port_add_unsolicited_msg_handler (MM_SERIAL_PORT (port), regex, NULL, NULL, NULL);
|
||||
mm_at_serial_port_add_unsolicited_msg_handler (MM_AT_SERIAL_PORT (port), regex, NULL, NULL, NULL);
|
||||
g_regex_unref (regex);
|
||||
}
|
||||
|
||||
|
||||
@@ -56,19 +56,19 @@ grab_port (MMModem *modem,
|
||||
MMPort *port = NULL;
|
||||
|
||||
if (suggested_type == MM_PORT_TYPE_UNKNOWN) {
|
||||
if (!mm_generic_gsm_get_port (gsm, MM_PORT_TYPE_PRIMARY))
|
||||
if (!mm_generic_gsm_get_at_port (gsm, MM_PORT_TYPE_PRIMARY))
|
||||
ptype = MM_PORT_TYPE_PRIMARY;
|
||||
else if (!mm_generic_gsm_get_port (gsm, MM_PORT_TYPE_SECONDARY))
|
||||
else if (!mm_generic_gsm_get_at_port (gsm, MM_PORT_TYPE_SECONDARY))
|
||||
ptype = MM_PORT_TYPE_SECONDARY;
|
||||
} else
|
||||
ptype = suggested_type;
|
||||
|
||||
port = mm_generic_gsm_grab_port (gsm, subsys, name, ptype, error);
|
||||
if (port && MM_IS_SERIAL_PORT (port)) {
|
||||
mm_serial_port_set_response_parser (MM_SERIAL_PORT (port),
|
||||
mm_serial_parser_v1_e1_parse,
|
||||
mm_serial_parser_v1_e1_new (),
|
||||
mm_serial_parser_v1_e1_destroy);
|
||||
if (port && MM_IS_AT_SERIAL_PORT (port)) {
|
||||
mm_at_serial_port_set_response_parser (MM_AT_SERIAL_PORT (port),
|
||||
mm_serial_parser_v1_e1_parse,
|
||||
mm_serial_parser_v1_e1_new (),
|
||||
mm_serial_parser_v1_e1_destroy);
|
||||
}
|
||||
|
||||
return !!port;
|
||||
|
||||
@@ -49,7 +49,7 @@ mm_modem_novatel_gsm_new (const char *device,
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
init_modem_done (MMSerialPort *port,
|
||||
init_modem_done (MMAtSerialPort *port,
|
||||
GString *response,
|
||||
GError *error,
|
||||
gpointer user_data)
|
||||
@@ -64,7 +64,7 @@ pin_check_done (MMModem *modem, GError *error, gpointer user_data)
|
||||
{
|
||||
MMCallbackInfo *info = (MMCallbackInfo *) user_data;
|
||||
MMGenericGsm *self = MM_GENERIC_GSM (modem);
|
||||
MMSerialPort *primary;
|
||||
MMAtSerialPort *primary;
|
||||
|
||||
if (error) {
|
||||
mm_generic_gsm_enable_complete (self, error, info);
|
||||
@@ -72,13 +72,13 @@ pin_check_done (MMModem *modem, GError *error, gpointer user_data)
|
||||
}
|
||||
|
||||
/* Finish the initialization */
|
||||
primary = mm_generic_gsm_get_port (self, MM_PORT_TYPE_PRIMARY);
|
||||
primary = mm_generic_gsm_get_at_port (self, MM_PORT_TYPE_PRIMARY);
|
||||
g_assert (primary);
|
||||
mm_serial_port_queue_command (primary, "Z E0 V1 X4 &C1 +CMEE=1;+CFUN=1", 10, init_modem_done, info);
|
||||
mm_at_serial_port_queue_command (primary, "Z E0 V1 X4 &C1 +CMEE=1;+CFUN=1", 10, init_modem_done, info);
|
||||
}
|
||||
|
||||
static void
|
||||
pre_init_done (MMSerialPort *port,
|
||||
pre_init_done (MMAtSerialPort *port,
|
||||
GString *response,
|
||||
GError *error,
|
||||
gpointer user_data)
|
||||
@@ -104,29 +104,29 @@ enable_flash_done (MMSerialPort *port, GError *error, gpointer user_data)
|
||||
if (error)
|
||||
mm_generic_gsm_enable_complete (MM_GENERIC_GSM (info->modem), error, info);
|
||||
else
|
||||
mm_serial_port_queue_command (port, "E0 V1", 3, pre_init_done, user_data);
|
||||
mm_at_serial_port_queue_command (MM_AT_SERIAL_PORT (port), "E0 V1", 3, pre_init_done, user_data);
|
||||
}
|
||||
|
||||
static void
|
||||
do_enable (MMGenericGsm *modem, MMModemFn callback, gpointer user_data)
|
||||
{
|
||||
MMCallbackInfo *info;
|
||||
MMSerialPort *primary;
|
||||
MMAtSerialPort *primary;
|
||||
|
||||
primary = mm_generic_gsm_get_port (modem, MM_PORT_TYPE_PRIMARY);
|
||||
primary = mm_generic_gsm_get_at_port (modem, MM_PORT_TYPE_PRIMARY);
|
||||
g_assert (primary);
|
||||
|
||||
info = mm_callback_info_new (MM_MODEM (modem), callback, user_data);
|
||||
mm_serial_port_flash (primary, 100, enable_flash_done, info);
|
||||
mm_serial_port_flash (MM_SERIAL_PORT (primary), 100, enable_flash_done, info);
|
||||
}
|
||||
|
||||
static void
|
||||
dmat_callback (MMSerialPort *port,
|
||||
dmat_callback (MMAtSerialPort *port,
|
||||
GString *response,
|
||||
GError *error,
|
||||
gpointer user_data)
|
||||
{
|
||||
mm_serial_port_close (port);
|
||||
mm_serial_port_close (MM_SERIAL_PORT (port));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@@ -142,18 +142,18 @@ grab_port (MMModem *modem,
|
||||
MMPort *port = NULL;
|
||||
|
||||
if (suggested_type == MM_PORT_TYPE_UNKNOWN) {
|
||||
if (!mm_generic_gsm_get_port (gsm, MM_PORT_TYPE_PRIMARY))
|
||||
if (!mm_generic_gsm_get_at_port (gsm, MM_PORT_TYPE_PRIMARY))
|
||||
ptype = MM_PORT_TYPE_PRIMARY;
|
||||
else if (!mm_generic_gsm_get_port (gsm, MM_PORT_TYPE_SECONDARY))
|
||||
else if (!mm_generic_gsm_get_at_port (gsm, MM_PORT_TYPE_SECONDARY))
|
||||
ptype = MM_PORT_TYPE_SECONDARY;
|
||||
} else
|
||||
ptype = suggested_type;
|
||||
|
||||
port = mm_generic_gsm_grab_port (gsm, subsys, name, ptype, error);
|
||||
if (port && MM_IS_SERIAL_PORT (port) && (ptype == MM_PORT_TYPE_PRIMARY)) {
|
||||
if (port && MM_IS_AT_SERIAL_PORT (port) && (ptype == MM_PORT_TYPE_PRIMARY)) {
|
||||
/* Flip secondary ports to AT mode */
|
||||
if (mm_serial_port_open (MM_SERIAL_PORT (port), NULL))
|
||||
mm_serial_port_queue_command (MM_SERIAL_PORT (port), "$NWDMAT=1", 2, dmat_callback, NULL);
|
||||
mm_at_serial_port_queue_command (MM_AT_SERIAL_PORT (port), "$NWDMAT=1", 2, dmat_callback, NULL);
|
||||
}
|
||||
|
||||
return !!port;
|
||||
|
||||
@@ -98,7 +98,7 @@ enable (MMModem *modem,
|
||||
}
|
||||
|
||||
static void
|
||||
get_network_mode_done (MMSerialPort *port,
|
||||
get_network_mode_done (MMAtSerialPort *port,
|
||||
GString *response,
|
||||
GError *error,
|
||||
gpointer user_data)
|
||||
@@ -149,16 +149,16 @@ get_network_mode (MMModemGsmNetwork *modem,
|
||||
gpointer user_data)
|
||||
{
|
||||
MMCallbackInfo *info;
|
||||
MMSerialPort *primary;
|
||||
MMAtSerialPort *primary;
|
||||
|
||||
info = mm_callback_info_uint_new (MM_MODEM (modem), callback, user_data);
|
||||
primary = mm_generic_gsm_get_port (MM_GENERIC_GSM (modem), MM_PORT_TYPE_PRIMARY);
|
||||
primary = mm_generic_gsm_get_at_port (MM_GENERIC_GSM (modem), MM_PORT_TYPE_PRIMARY);
|
||||
g_assert (primary);
|
||||
mm_serial_port_queue_command (primary, "AT_OPSYS?", 3, get_network_mode_done, info);
|
||||
mm_at_serial_port_queue_command (primary, "AT_OPSYS?", 3, get_network_mode_done, info);
|
||||
}
|
||||
|
||||
static void
|
||||
set_network_mode_done (MMSerialPort *port,
|
||||
set_network_mode_done (MMAtSerialPort *port,
|
||||
GString *response,
|
||||
GError *error,
|
||||
gpointer user_data)
|
||||
@@ -178,7 +178,7 @@ set_network_mode (MMModemGsmNetwork *modem,
|
||||
gpointer user_data)
|
||||
{
|
||||
MMCallbackInfo *info;
|
||||
MMSerialPort *primary;
|
||||
MMAtSerialPort *primary;
|
||||
char *command;
|
||||
int i;
|
||||
|
||||
@@ -210,9 +210,9 @@ set_network_mode (MMModemGsmNetwork *modem,
|
||||
}
|
||||
|
||||
command = g_strdup_printf ("AT_OPSYS=%d,2", i);
|
||||
primary = mm_generic_gsm_get_port (MM_GENERIC_GSM (modem), MM_PORT_TYPE_PRIMARY);
|
||||
primary = mm_generic_gsm_get_at_port (MM_GENERIC_GSM (modem), MM_PORT_TYPE_PRIMARY);
|
||||
g_assert (primary);
|
||||
mm_serial_port_queue_command (primary, command, 3, set_network_mode_done, info);
|
||||
mm_at_serial_port_queue_command (primary, command, 3, set_network_mode_done, info);
|
||||
g_free (command);
|
||||
}
|
||||
|
||||
|
||||
@@ -110,7 +110,7 @@ sys_mode_has_service (SysMode mode)
|
||||
}
|
||||
|
||||
static void
|
||||
status_done (MMSerialPort *port,
|
||||
status_done (MMAtSerialPort *port,
|
||||
GString *response,
|
||||
GError *error,
|
||||
gpointer user_data)
|
||||
@@ -293,11 +293,11 @@ query_registration_state (MMGenericCdma *cdma,
|
||||
gpointer user_data)
|
||||
{
|
||||
MMCallbackInfo *info;
|
||||
MMSerialPort *primary, *secondary;
|
||||
MMSerialPort *port;
|
||||
MMAtSerialPort *primary, *secondary;
|
||||
MMAtSerialPort *port;
|
||||
|
||||
port = primary = mm_generic_cdma_get_port (cdma, MM_PORT_TYPE_PRIMARY);
|
||||
secondary = mm_generic_cdma_get_port (cdma, MM_PORT_TYPE_SECONDARY);
|
||||
port = primary = mm_generic_cdma_get_at_port (cdma, MM_PORT_TYPE_PRIMARY);
|
||||
secondary = mm_generic_cdma_get_at_port (cdma, MM_PORT_TYPE_SECONDARY);
|
||||
|
||||
info = mm_generic_cdma_query_reg_state_callback_info_new (cdma, callback, user_data);
|
||||
|
||||
@@ -313,11 +313,11 @@ query_registration_state (MMGenericCdma *cdma,
|
||||
port = secondary;
|
||||
}
|
||||
|
||||
mm_serial_port_queue_command (port, "!STATUS", 3, status_done, info);
|
||||
mm_at_serial_port_queue_command (port, "!STATUS", 3, status_done, info);
|
||||
}
|
||||
|
||||
static void
|
||||
pcstate_done (MMSerialPort *port,
|
||||
pcstate_done (MMAtSerialPort *port,
|
||||
GString *response,
|
||||
GError *error,
|
||||
gpointer user_data)
|
||||
@@ -334,14 +334,14 @@ post_enable (MMGenericCdma *cdma,
|
||||
gpointer user_data)
|
||||
{
|
||||
MMCallbackInfo *info;
|
||||
MMSerialPort *primary;
|
||||
MMAtSerialPort *primary;
|
||||
|
||||
info = mm_callback_info_new (MM_MODEM (cdma), callback, user_data);
|
||||
|
||||
primary = mm_generic_cdma_get_port (cdma, MM_PORT_TYPE_PRIMARY);
|
||||
primary = mm_generic_cdma_get_at_port (cdma, MM_PORT_TYPE_PRIMARY);
|
||||
g_assert (primary);
|
||||
|
||||
mm_serial_port_queue_command (primary, "!pcstate=1", 5, pcstate_done, info);
|
||||
mm_at_serial_port_queue_command (primary, "!pcstate=1", 5, pcstate_done, info);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -350,14 +350,14 @@ post_disable (MMGenericCdma *cdma,
|
||||
gpointer user_data)
|
||||
{
|
||||
MMCallbackInfo *info;
|
||||
MMSerialPort *primary;
|
||||
MMAtSerialPort *primary;
|
||||
|
||||
info = mm_callback_info_new (MM_MODEM (cdma), callback, user_data);
|
||||
|
||||
primary = mm_generic_cdma_get_port (cdma, MM_PORT_TYPE_PRIMARY);
|
||||
primary = mm_generic_cdma_get_at_port (cdma, MM_PORT_TYPE_PRIMARY);
|
||||
g_assert (primary);
|
||||
|
||||
mm_serial_port_queue_command (primary, "!pcstate=0", 5, pcstate_done, info);
|
||||
mm_at_serial_port_queue_command (primary, "!pcstate=0", 5, pcstate_done, info);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
@@ -108,22 +108,22 @@ grab_port (MMModem *modem,
|
||||
MMPort *port;
|
||||
|
||||
if (suggested_type == MM_PORT_TYPE_UNKNOWN) {
|
||||
if (!mm_generic_gsm_get_port (gsm, MM_PORT_TYPE_PRIMARY))
|
||||
if (!mm_generic_gsm_get_at_port (gsm, MM_PORT_TYPE_PRIMARY))
|
||||
ptype = MM_PORT_TYPE_PRIMARY;
|
||||
else if (!mm_generic_gsm_get_port (gsm, MM_PORT_TYPE_SECONDARY))
|
||||
else if (!mm_generic_gsm_get_at_port (gsm, MM_PORT_TYPE_SECONDARY))
|
||||
ptype = MM_PORT_TYPE_SECONDARY;
|
||||
} else
|
||||
ptype = suggested_type;
|
||||
|
||||
port = mm_generic_gsm_grab_port (gsm, subsys, name, ptype, error);
|
||||
|
||||
if (port && MM_IS_SERIAL_PORT (port)) {
|
||||
if (port && MM_IS_AT_SERIAL_PORT (port)) {
|
||||
GRegex *regex;
|
||||
|
||||
g_object_set (G_OBJECT (port), MM_PORT_CARRIER_DETECT, FALSE, NULL);
|
||||
|
||||
regex = g_regex_new ("\\r\\n\\+PACSP0\\r\\n", G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL);
|
||||
mm_serial_port_add_unsolicited_msg_handler (MM_SERIAL_PORT (port), regex, NULL, NULL, NULL);
|
||||
mm_at_serial_port_add_unsolicited_msg_handler (MM_AT_SERIAL_PORT (port), regex, NULL, NULL, NULL);
|
||||
g_regex_unref (regex);
|
||||
}
|
||||
|
||||
|
||||
+24
-24
@@ -56,7 +56,7 @@ mm_modem_zte_new (const char *device,
|
||||
/* Modem class override functions */
|
||||
/*****************************************************************************/
|
||||
|
||||
static void cpms_try_done (MMSerialPort *port,
|
||||
static void cpms_try_done (MMAtSerialPort *port,
|
||||
GString *response,
|
||||
GError *error,
|
||||
gpointer user_data);
|
||||
@@ -67,17 +67,17 @@ cpms_timeout_cb (gpointer user_data)
|
||||
MMCallbackInfo *info = user_data;
|
||||
MMModem *modem = info->modem;
|
||||
MMModemZtePrivate *priv = MM_MODEM_ZTE_GET_PRIVATE (modem);
|
||||
MMSerialPort *primary;
|
||||
MMAtSerialPort *primary;
|
||||
|
||||
priv->cpms_timeout = 0;
|
||||
|
||||
primary = mm_generic_gsm_get_port (MM_GENERIC_GSM (modem), MM_PORT_TYPE_PRIMARY);
|
||||
mm_serial_port_queue_command (primary, "+CPMS?", 10, cpms_try_done, info);
|
||||
primary = mm_generic_gsm_get_at_port (MM_GENERIC_GSM (modem), MM_PORT_TYPE_PRIMARY);
|
||||
mm_at_serial_port_queue_command (primary, "+CPMS?", 10, cpms_try_done, info);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
cpms_try_done (MMSerialPort *port,
|
||||
cpms_try_done (MMAtSerialPort *port,
|
||||
GString *response,
|
||||
GError *error,
|
||||
gpointer user_data)
|
||||
@@ -103,7 +103,7 @@ cpms_try_done (MMSerialPort *port,
|
||||
}
|
||||
|
||||
static void
|
||||
init_modem_done (MMSerialPort *port,
|
||||
init_modem_done (MMAtSerialPort *port,
|
||||
GString *response,
|
||||
GError *error,
|
||||
gpointer user_data)
|
||||
@@ -115,14 +115,14 @@ init_modem_done (MMSerialPort *port,
|
||||
* done during probing, but if the device has a PIN enabled it won't
|
||||
* accept the +CPMS? during the probe and we have to do it here.
|
||||
*/
|
||||
mm_serial_port_queue_command (port, "+CPMS?", 10, cpms_try_done, info);
|
||||
mm_at_serial_port_queue_command (port, "+CPMS?", 10, cpms_try_done, info);
|
||||
}
|
||||
|
||||
static void
|
||||
pin_check_done (MMModem *modem, GError *error, gpointer user_data)
|
||||
{
|
||||
MMCallbackInfo *info = (MMCallbackInfo *) user_data;
|
||||
MMSerialPort *primary;
|
||||
MMAtSerialPort *primary;
|
||||
|
||||
if (error) {
|
||||
mm_generic_gsm_enable_complete (MM_GENERIC_GSM (modem), error, info);
|
||||
@@ -130,9 +130,9 @@ pin_check_done (MMModem *modem, GError *error, gpointer user_data)
|
||||
}
|
||||
|
||||
/* Finish the initialization */
|
||||
primary = mm_generic_gsm_get_port (MM_GENERIC_GSM (modem), MM_PORT_TYPE_PRIMARY);
|
||||
primary = mm_generic_gsm_get_at_port (MM_GENERIC_GSM (modem), MM_PORT_TYPE_PRIMARY);
|
||||
g_assert (primary);
|
||||
mm_serial_port_queue_command (primary, "Z E0 V1 X4 &C1 +CMEE=1;+CFUN=1;", 10, init_modem_done, info);
|
||||
mm_at_serial_port_queue_command (primary, "Z E0 V1 X4 &C1 +CMEE=1;+CFUN=1;", 10, init_modem_done, info);
|
||||
}
|
||||
|
||||
static void enable_flash_done (MMSerialPort *port,
|
||||
@@ -140,7 +140,7 @@ static void enable_flash_done (MMSerialPort *port,
|
||||
gpointer user_data);
|
||||
|
||||
static void
|
||||
pre_init_done (MMSerialPort *port,
|
||||
pre_init_done (MMAtSerialPort *port,
|
||||
GString *response,
|
||||
GError *error,
|
||||
gpointer user_data)
|
||||
@@ -153,7 +153,7 @@ pre_init_done (MMSerialPort *port,
|
||||
if ( !priv->init_retried
|
||||
&& g_error_matches (error, MM_SERIAL_ERROR, MM_SERIAL_RESPONSE_TIMEOUT)) {
|
||||
priv->init_retried = TRUE;
|
||||
enable_flash_done (port, NULL, user_data);
|
||||
enable_flash_done (MM_SERIAL_PORT (port), NULL, user_data);
|
||||
} else
|
||||
mm_generic_gsm_enable_complete (MM_GENERIC_GSM (info->modem), error, info);
|
||||
} else {
|
||||
@@ -171,7 +171,7 @@ enable_flash_done (MMSerialPort *port, GError *error, gpointer user_data)
|
||||
if (error)
|
||||
mm_generic_gsm_enable_complete (MM_GENERIC_GSM (info->modem), error, info);
|
||||
else
|
||||
mm_serial_port_queue_command (port, "E0 V1", 3, pre_init_done, user_data);
|
||||
mm_at_serial_port_queue_command (MM_AT_SERIAL_PORT (port), "E0 V1", 3, pre_init_done, user_data);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -179,15 +179,15 @@ do_enable (MMGenericGsm *modem, MMModemFn callback, gpointer user_data)
|
||||
{
|
||||
MMModemZtePrivate *priv = MM_MODEM_ZTE_GET_PRIVATE (modem);
|
||||
MMCallbackInfo *info;
|
||||
MMSerialPort *primary;
|
||||
MMAtSerialPort *primary;
|
||||
|
||||
priv->init_retried = FALSE;
|
||||
|
||||
primary = mm_generic_gsm_get_port (modem, MM_PORT_TYPE_PRIMARY);
|
||||
primary = mm_generic_gsm_get_at_port (modem, MM_PORT_TYPE_PRIMARY);
|
||||
g_assert (primary);
|
||||
|
||||
info = mm_callback_info_new (MM_MODEM (modem), callback, user_data);
|
||||
mm_serial_port_flash (primary, 100, enable_flash_done, info);
|
||||
mm_serial_port_flash (MM_SERIAL_PORT (primary), 100, enable_flash_done, info);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -218,42 +218,42 @@ grab_port (MMModem *modem,
|
||||
MMPort *port = NULL;
|
||||
|
||||
if (suggested_type == MM_PORT_TYPE_UNKNOWN) {
|
||||
if (!mm_generic_gsm_get_port (gsm, MM_PORT_TYPE_PRIMARY))
|
||||
if (!mm_generic_gsm_get_at_port (gsm, MM_PORT_TYPE_PRIMARY))
|
||||
ptype = MM_PORT_TYPE_PRIMARY;
|
||||
else if (!mm_generic_gsm_get_port (gsm, MM_PORT_TYPE_SECONDARY))
|
||||
else if (!mm_generic_gsm_get_at_port (gsm, MM_PORT_TYPE_SECONDARY))
|
||||
ptype = MM_PORT_TYPE_SECONDARY;
|
||||
} else
|
||||
ptype = suggested_type;
|
||||
|
||||
port = mm_generic_gsm_grab_port (gsm, subsys, name, ptype, error);
|
||||
if (port && MM_IS_SERIAL_PORT (port)) {
|
||||
if (port && MM_IS_AT_SERIAL_PORT (port)) {
|
||||
GRegex *regex;
|
||||
|
||||
mm_generic_gsm_set_unsolicited_registration (gsm, TRUE);
|
||||
g_object_set (port, MM_PORT_CARRIER_DETECT, FALSE, NULL);
|
||||
|
||||
regex = g_regex_new ("\\r\\n\\+ZUSIMR:(.*)\\r\\n", G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL);
|
||||
mm_serial_port_add_unsolicited_msg_handler (MM_SERIAL_PORT (port), regex, NULL, NULL, NULL);
|
||||
mm_at_serial_port_add_unsolicited_msg_handler (MM_AT_SERIAL_PORT (port), regex, NULL, NULL, NULL);
|
||||
g_regex_unref (regex);
|
||||
|
||||
/* Unsolicted operator display */
|
||||
regex = g_regex_new ("\\r\\n\\+ZDONR: (.*)\\r\\n", G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL);
|
||||
mm_serial_port_add_unsolicited_msg_handler (MM_SERIAL_PORT (port), regex, NULL, NULL, NULL);
|
||||
mm_at_serial_port_add_unsolicited_msg_handler (MM_AT_SERIAL_PORT (port), regex, NULL, NULL, NULL);
|
||||
g_regex_unref (regex);
|
||||
|
||||
/* Current network and service domain */
|
||||
regex = g_regex_new ("\\r\\n\\+ZPASR: (.*)\\r\\n", G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL);
|
||||
mm_serial_port_add_unsolicited_msg_handler (MM_SERIAL_PORT (port), regex, NULL, NULL, NULL);
|
||||
mm_at_serial_port_add_unsolicited_msg_handler (MM_AT_SERIAL_PORT (port), regex, NULL, NULL, NULL);
|
||||
g_regex_unref (regex);
|
||||
|
||||
/* SIM request to Build Main Menu */
|
||||
regex = g_regex_new ("\\r\\n\\+ZPSTM: (.*)\\r\\n", G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL);
|
||||
mm_serial_port_add_unsolicited_msg_handler (MM_SERIAL_PORT (port), regex, NULL, NULL, NULL);
|
||||
mm_at_serial_port_add_unsolicited_msg_handler (MM_AT_SERIAL_PORT (port), regex, NULL, NULL, NULL);
|
||||
g_regex_unref (regex);
|
||||
|
||||
/* SIM request to Rebuild Main Menu */
|
||||
regex = g_regex_new ("\\r\\n\\+ZEND\\r\\n", G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL);
|
||||
mm_serial_port_add_unsolicited_msg_handler (MM_SERIAL_PORT (port), regex, NULL, NULL, NULL);
|
||||
mm_at_serial_port_add_unsolicited_msg_handler (MM_AT_SERIAL_PORT (port), regex, NULL, NULL, NULL);
|
||||
g_regex_unref (regex);
|
||||
}
|
||||
|
||||
|
||||
+11
-10
@@ -26,6 +26,7 @@
|
||||
#include "mm-modem-huawei-gsm.h"
|
||||
#include "mm-modem-huawei-cdma.h"
|
||||
#include "mm-serial-parsers.h"
|
||||
#include "mm-at-serial-port.h"
|
||||
|
||||
G_DEFINE_TYPE (MMPluginHuawei, mm_plugin_huawei, MM_TYPE_PLUGIN_BASE)
|
||||
|
||||
@@ -69,7 +70,7 @@ probe_result (MMPluginBase *base,
|
||||
#define TAG_SUPPORTS_INFO "huawei-supports-info"
|
||||
|
||||
typedef struct {
|
||||
MMSerialPort *serial;
|
||||
MMAtSerialPort *serial;
|
||||
guint id;
|
||||
gboolean secondary;
|
||||
} HuaweiSupportsInfo;
|
||||
@@ -106,7 +107,7 @@ probe_secondary_supported (gpointer user_data)
|
||||
}
|
||||
|
||||
static void
|
||||
probe_secondary_handle_msg (MMSerialPort *port,
|
||||
probe_secondary_handle_msg (MMAtSerialPort *port,
|
||||
GMatchInfo *match_info,
|
||||
gpointer user_data)
|
||||
{
|
||||
@@ -135,12 +136,12 @@ probe_secondary_timeout (gpointer user_data)
|
||||
}
|
||||
|
||||
static void
|
||||
add_regex (MMSerialPort *port, const char *match, gpointer user_data)
|
||||
add_regex (MMAtSerialPort *port, const char *match, gpointer user_data)
|
||||
{
|
||||
GRegex *regex;
|
||||
|
||||
regex = g_regex_new (match, G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL);
|
||||
mm_serial_port_add_unsolicited_msg_handler (port, regex, probe_secondary_handle_msg, user_data, NULL);
|
||||
mm_at_serial_port_add_unsolicited_msg_handler (port, regex, probe_secondary_handle_msg, user_data, NULL);
|
||||
g_regex_unref (regex);
|
||||
}
|
||||
|
||||
@@ -208,13 +209,13 @@ supports_port (MMPluginBase *base,
|
||||
/* Listen for Huawei-specific unsolicited messages */
|
||||
info = g_malloc0 (sizeof (HuaweiSupportsInfo));
|
||||
|
||||
info->serial = mm_serial_port_new (name, MM_PORT_TYPE_PRIMARY);
|
||||
info->serial = mm_at_serial_port_new (name, MM_PORT_TYPE_PRIMARY);
|
||||
g_object_set (G_OBJECT (info->serial), MM_PORT_CARRIER_DETECT, FALSE, NULL);
|
||||
|
||||
mm_serial_port_set_response_parser (info->serial,
|
||||
mm_serial_parser_v1_parse,
|
||||
mm_serial_parser_v1_new (),
|
||||
mm_serial_parser_v1_destroy);
|
||||
mm_at_serial_port_set_response_parser (info->serial,
|
||||
mm_serial_parser_v1_parse,
|
||||
mm_serial_parser_v1_new (),
|
||||
mm_serial_parser_v1_destroy);
|
||||
|
||||
add_regex (info->serial, "\\r\\n\\^RSSI:(\\d+)\\r\\n", task);
|
||||
add_regex (info->serial, "\\r\\n\\^MODE:(\\d),(\\d)\\r\\n", task);
|
||||
@@ -227,7 +228,7 @@ supports_port (MMPluginBase *base,
|
||||
g_object_set_data_full (G_OBJECT (task), TAG_SUPPORTS_INFO,
|
||||
info, huawei_supports_info_destroy);
|
||||
|
||||
if (!mm_serial_port_open (info->serial, &error)) {
|
||||
if (!mm_serial_port_open (MM_SERIAL_PORT (info->serial), &error)) {
|
||||
g_warning ("%s: (Huawei) %s: couldn't open serial port: (%d) %s",
|
||||
__func__, name,
|
||||
error ? error->code : -1,
|
||||
|
||||
Reference in New Issue
Block a user