static void port_grabbed (MMGenericCdma *cdma, MMPort *port, MMAtPortFlags pflags, gpointer user_data) { GRegex *regex; gboolean evdo0 = FALSE, evdoA = FALSE; if (MM_IS_AT_SERIAL_PORT (port)) { 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_at_serial_port_add_unsolicited_msg_handler (MM_AT_SERIAL_PORT (port), regex, handle_1x_quality_change, cdma, NULL); g_regex_unref (regex); g_object_get (G_OBJECT (cdma), MM_GENERIC_CDMA_EVDO_REV0, &evdo0, MM_GENERIC_CDMA_EVDO_REVA, &evdoA, NULL); 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_at_serial_port_add_unsolicited_msg_handler (MM_AT_SERIAL_PORT (port), regex, handle_evdo_quality_change, cdma, NULL); g_regex_unref (regex); } } }
void mm_modem_icera_register_unsolicted_handlers (MMModemIcera *self, MMAtSerialPort *port) { GRegex *regex; /* %NWSTATE: <rssi>,<mccmnc>,<tech>,<connection state>,<regulation> * * <connection state> shows the actual access technology in-use when a * PS connection is active. */ regex = g_regex_new ("\\r\\n%NWSTATE:\\s*(-?\\d+),(\\d+),([^,]*),([^,]*),(\\d+)\\r\\n", G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL); mm_at_serial_port_add_unsolicited_msg_handler (port, regex, nwstate_changed, self, NULL); g_regex_unref (regex); regex = g_regex_new ("\\r\\n\\+PACSP(\\d)\\r\\n", G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL); mm_at_serial_port_add_unsolicited_msg_handler (port, regex, pacsp_received, self, NULL); g_regex_unref (regex); /* %IPDPACT: <cid>,<status>,0 */ regex = g_regex_new ("\\r\\n%IPDPACT:\\s*(\\d+),\\s*(\\d+),\\s*(\\d+)\\r\\n", G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL); mm_at_serial_port_add_unsolicited_msg_handler (port, regex, connection_enabled, self, NULL); g_regex_unref (regex); }
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; const char *sys[] = { "tty", "net", NULL }; GUdevClient *client; GUdevDevice *device = NULL; MMPort *port = NULL; const char *sysfs_path; client = g_udev_client_new (sys); if (!client) { g_set_error (error, 0, 0, "Could not get udev client."); return FALSE; } device = g_udev_client_query_by_subsystem_and_name (client, subsys, name); if (!device) { g_set_error (error, 0, 0, "Could not get udev device."); goto out; } sysfs_path = g_udev_device_get_sysfs_path (device); if (!sysfs_path) { g_set_error (error, 0, 0, "Could not get udev device sysfs path."); goto out; } if (!strcmp (subsys, "tty")) { char *hsotype_path; char *contents = NULL; hsotype_path = g_build_filename (sysfs_path, "hsotype", NULL); if (g_file_get_contents (hsotype_path, &contents, NULL, NULL)) { if (g_str_has_prefix (contents, "Control")) ptype = MM_PORT_TYPE_PRIMARY; else if (g_str_has_prefix (contents, "Application") || g_str_has_prefix (contents, "Application2")) ptype = MM_PORT_TYPE_SECONDARY; g_free (contents); } g_free (hsotype_path); } port = mm_generic_gsm_grab_port (gsm, subsys, name, ptype, error); if (!port) goto out; 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; regex = g_regex_new ("_OWANCALL: (\\d),\\s*(\\d)\\r\\n", G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL); mm_at_serial_port_add_unsolicited_msg_handler (MM_AT_SERIAL_PORT (port), regex, connection_enabled, modem, NULL); g_regex_unref (regex); regex = g_regex_new ("\\r\\n\\+PACSP0\\r\\n", G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL); mm_at_serial_port_add_unsolicited_msg_handler (MM_AT_SERIAL_PORT (port), regex, NULL, NULL, NULL); g_regex_unref (regex); } option_register_unsolicted_handlers (gsm, MM_AT_SERIAL_PORT (port)); } out: if (device) g_object_unref (device); g_object_unref (client); return !!port; }