static gboolean grab_port (MMModem *modem, const char *subsys, const char *name, MMPortType suggested_type, gpointer user_data, GError **error) { MMGenericGsm *gsm = MM_GENERIC_GSM (modem); MMPortType ptype = MM_PORT_TYPE_IGNORED; MMPort *port = NULL; if (suggested_type == MM_PORT_TYPE_UNKNOWN) { if (!mm_generic_gsm_get_at_port (gsm, MM_PORT_TYPE_PRIMARY)) ptype = MM_PORT_TYPE_PRIMARY; 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_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; }
static void _internal_hso_modem_authenticate (MMModemHso *self, MMCallbackInfo *info) { MMModemHsoPrivate *priv = MM_MODEM_HSO_GET_PRIVATE (self); MMAtSerialPort *primary; gint cid; char *command; primary = mm_generic_gsm_get_at_port (MM_GENERIC_GSM (self), MM_PORT_TYPE_PRIMARY); g_assert (primary); cid = hso_get_cid (self); g_warn_if_fail (cid >= 0); /* Both user and password are required; otherwise firmware returns an error */ if (!priv->username || !priv->password) command = g_strdup_printf ("%s=%d,0", auth_commands[priv->auth_idx], cid); else { command = g_strdup_printf ("%s=%d,1,\"%s\",\"%s\"", auth_commands[priv->auth_idx], cid, priv->password ? priv->password : "", priv->username ? priv->username : ""); } mm_at_serial_port_queue_command (primary, command, 3, auth_done, info); g_free (command); }
void mm_modem_icera_change_unsolicited_messages (MMModemIcera *self, gboolean enabled) { MMAtSerialPort *primary; primary = mm_generic_gsm_get_at_port (MM_GENERIC_GSM (self), MM_AT_PORT_FLAG_PRIMARY); g_assert (primary); mm_at_serial_port_queue_command (primary, enabled ? "%NWSTATE=1" : "%NWSTATE=0", 3, NULL, NULL); }
static void connection_enabled (MMAtSerialPort *port, GMatchInfo *match_info, gpointer user_data) { MMModemIcera *self = MM_MODEM_ICERA (user_data); MMAtSerialPort *primary; char *str; int status, cid, tmp; cid = mm_generic_gsm_get_cid (MM_GENERIC_GSM (self)); if (cid < 0) return; str = g_match_info_fetch (match_info, 1); g_return_if_fail (str != NULL); tmp = atoi (str); g_free (str); /* Make sure the unsolicited message's CID matches the current CID */ if (tmp != cid) return; str = g_match_info_fetch (match_info, 2); g_return_if_fail (str != NULL); status = atoi (str); g_free (str); switch (status) { case 0: /* Disconnected */ if (mm_modem_get_state (MM_MODEM (self)) >= MM_MODEM_STATE_CONNECTED) mm_modem_disconnect (MM_MODEM (self), icera_disconnect_done, NULL); break; case 1: /* Connected */ connect_pending_done (self); break; case 2: /* Connecting */ break; case 3: /* Call setup failure? */ primary = mm_generic_gsm_get_at_port (MM_GENERIC_GSM(self), MM_AT_PORT_FLAG_PRIMARY); g_assert (primary); /* Get additional error details */ mm_at_serial_port_queue_command (primary, "AT%IER?", 3, query_network_error_code_done, self); break; default: mm_warn ("Unknown Icera connect status %d", status); break; } }
void mm_modem_icera_get_local_timestamp (MMModemIcera *self, MMModemIceraTimestampFn callback, gpointer user_data) { MMCallbackInfo *info; MMAtSerialPort *primary; info = mm_callback_info_icera_timestamp_new (self, callback, user_data); primary = mm_generic_gsm_get_at_port (MM_GENERIC_GSM (self), MM_AT_PORT_FLAG_PRIMARY); g_assert (primary); mm_at_serial_port_queue_command (primary, "*TLTS", 3, get_local_timestamp_done, info); }
static void icera_call_control (MMModemIcera *self, gboolean activate, MMAtSerialResponseFn callback, gpointer user_data) { char *command; MMAtSerialPort *primary; primary = mm_generic_gsm_get_at_port (MM_GENERIC_GSM (self), MM_AT_PORT_FLAG_PRIMARY); g_assert (primary); command = g_strdup_printf ("%%IPDPACT=%d,%d", _get_cid (self), activate ? 1 : 0); mm_at_serial_port_queue_command (primary, command, 3, callback, user_data); g_free (command); }
static void get_ip4_config (MMModem *modem, MMModemIp4Fn callback, gpointer user_data) { MMCallbackInfo *info; char *command; 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_at_port (MM_GENERIC_GSM (modem), MM_PORT_TYPE_PRIMARY); g_assert (primary); mm_at_serial_port_queue_command (primary, command, 3, get_ip4_config_done, info); g_free (command); }
void mm_modem_icera_do_disconnect (MMGenericGsm *gsm, gint cid, MMModemFn callback, gpointer user_data) { MMCallbackInfo *info; MMAtSerialPort *primary; char *command; info = mm_callback_info_new (MM_MODEM (gsm), callback, user_data); primary = mm_generic_gsm_get_at_port (gsm, MM_AT_PORT_FLAG_PRIMARY); g_assert (primary); command = g_strdup_printf ("%%IPDPACT=%d,0", cid); mm_at_serial_port_queue_command (primary, command, 3, disconnect_ipdpact_done, info); g_free (command); }
static void do_disconnect (MMGenericGsm *gsm, gint cid, MMModemFn callback, gpointer user_data) { MMCallbackInfo *info; MMAtSerialPort *primary; char *command; info = mm_callback_info_new (MM_MODEM (gsm), callback, user_data); primary = mm_generic_gsm_get_at_port (gsm, MM_PORT_TYPE_PRIMARY); g_assert (primary); command = g_strdup_printf ("AT_OWANCALL=%d,0,0", cid); mm_at_serial_port_queue_command (primary, command, 3, disconnect_owancall_done, info); g_free (command); }
static void hso_call_control (MMModemHso *self, gboolean activate, gboolean ignore_errors, MMModemFn callback, gpointer user_data) { MMCallbackInfo *info; char *command; 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_at_port (MM_GENERIC_GSM (self), MM_PORT_TYPE_PRIMARY); g_assert (primary); mm_at_serial_port_queue_command (primary, command, 3, hso_call_control_done, info); g_free (command); }
void mm_modem_icera_get_ip4_config (MMModemIcera *self, MMModemIp4Fn callback, gpointer user_data) { MMCallbackInfo *info; char *command; MMAtSerialPort *primary; info = mm_callback_info_new_full (MM_MODEM (self), ip4_config_invoke, G_CALLBACK (callback), user_data); primary = mm_generic_gsm_get_at_port (MM_GENERIC_GSM (self), MM_AT_PORT_FLAG_PRIMARY); g_assert (primary); command = g_strdup_printf ("%%IPDPADDR=%d", _get_cid (self)); mm_at_serial_port_queue_command (primary, command, 3, get_ip4_config_done, info); g_free (command); }
void mm_modem_icera_do_connect (MMModemIcera *self, const char *number, MMModemFn callback, gpointer user_data) { MMModem *modem = MM_MODEM (self); MMModemIceraPrivate *priv = MM_MODEM_ICERA_GET_PRIVATE (self); MMCallbackInfo *info; MMAtSerialPort *primary; gint cid; char *command; mm_modem_set_state (modem, MM_MODEM_STATE_CONNECTING, MM_MODEM_STATE_REASON_NONE); info = mm_callback_info_new (modem, callback, user_data); primary = mm_generic_gsm_get_at_port (MM_GENERIC_GSM (self), MM_AT_PORT_FLAG_PRIMARY); g_assert (primary); cid = _get_cid (self); /* Both user and password are required; otherwise firmware returns an error */ if (!priv->username || !priv->password) command = g_strdup_printf ("%%IPDPCFG=%d,0,0,\"\",\"\"", cid); else { command = g_strdup_printf ("%%IPDPCFG=%d,0,1,\"%s\",\"%s\"", cid, priv->username ? priv->username : "", priv->password ? priv->password : ""); } mm_at_serial_port_queue_command (primary, command, 3, auth_done, info); g_free (command); }