Commit Graph
218 Commits
Author SHA1 Message Date
Aleksander Morgado 4c36bd42d4 huawei: plug memleak when listing cdc-wdm AT ports
The returned list contains full references, so make sure we unref them
before going on. Note that it's ok to return a pointer to one object
inside this list even if we're unref-ing them all, because we're sure
that the caller knows it's peek-ing a port object.
2017-09-26 10:46:55 +02:00
Ben Chan d6d52b95c7 huawei: port connect_3gpp to use GTask 2017-09-08 17:45:29 +02:00
Ben Chan 1ada2d23a5 huawei: port disconnect_3gpp to use GTask 2017-09-08 17:45:29 +02:00
Ben Chan abf9d36183 huawei: port huawei_modem_create_bearer to use GTask 2017-09-08 17:45:29 +02:00
Ben Chan 7880a35b19 huawei: port huawei_custom_init to use GTask 2017-09-08 17:45:29 +02:00
Ben Chan e76015ac49 huawei: port get_detailed_registration_state to use GTask 2017-09-08 17:45:29 +02:00
Ben Chan 9c32a96578 huawei: port setup_registration_checks to use GTask 2017-09-08 17:45:29 +02:00
Ben Chan 39484765f1 huawei: port call_start to use GTask 2017-09-08 17:45:29 +02:00
Ben Chan 8df63e385c huawei: port modem_voice_disable_unsolicited_events to use GTask 2017-09-08 17:45:29 +02:00
Ben Chan 68075a23a7 huawei: port modem_voice_enable_unsolicited_events to use GTask 2017-09-08 17:45:29 +02:00
Ben Chan 5e8a7aad76 huawei: port modem_voice_{setup,cleanup}_unsolicited_events to use GTask 2017-09-08 17:45:29 +02:00
Ben Chan 46866b08be huawei: port modem_cdma_{setup,cleanup}_unsolicited_events to use GTask 2017-09-08 17:45:29 +02:00
Ben Chan 5f641afe07 huawei: port modem_3gpp_disable_unsolicited_events to use GTask 2017-09-08 17:45:29 +02:00
Ben Chan 074e0f89fc huawei: port modem_3gpp_enable_unsolicited_events to use GTask 2017-09-08 17:45:28 +02:00
Ben Chan 02ce611d5c huawei: port modem_3gpp_{setup,cleanup}_unsolicited_events to use GTask 2017-09-08 17:45:28 +02:00
Ben Chan 38bafe021e huawei: port {enable,disable}_location_gathering to use GTask 2017-09-08 17:45:28 +02:00
Ben Chan 6ebc07f882 huawei: port location_load_capabilities to use GTask 2017-09-08 17:45:28 +02:00
Ben Chan 36d975bd4e huawei: port modem_after_sim_unlock to use GTask 2017-09-08 17:45:28 +02:00
Ben Chan 0aae6d3e35 huawei: port modem_time_check_support to use GTask 2017-09-08 17:45:28 +02:00
Ben Chan 60129a6fde huawei: port modem_load_signal_quality to use GTask 2017-09-08 17:45:28 +02:00
Ben Chan 0c468bb1a4 huawei: port load_sim_identifier to use GTask 2017-09-08 17:45:28 +02:00
Ben Chan 1495fb1d1d huawei: port load_power_state to use GTask 2017-09-08 17:45:28 +02:00
Ben Chan 046f1b3301 huawei: port load_supported_modes to use GTask 2017-09-08 17:45:28 +02:00
Ben Chan c7ec2c4fbb huawei: port load_current_modes to use GTask 2017-09-08 17:45:28 +02:00
Ben Chan bf03f1e2d7 huawei: port set_current_modes to use GTask 2017-09-08 17:45:28 +02:00
Ben Chan 5d9c4d70a1 huawei: port set_current_bands to use GTask 2017-09-08 17:45:28 +02:00
Ben Chan 8b9402da2b huawei: port sysinfo to use GTask 2017-09-08 17:45:28 +02:00
Aleksander Morgado d135c56f0f huawei: update frequency bands support
Updated to use the non-deprecated MMModemBand values.
2017-09-07 10:55:17 +02:00
Aleksander Morgado 1f2bb64028 charsets: ensure all methods are prefixed with 'mm_' 2017-08-16 16:08:15 +02:00
Ben Chan 625c204761 huawei: remove redundant call to huawei_parse_auth_type()
This patch removes a redundant `encoded_auth = huawei_parse_auth_type (auth)`
in connect_3gpp_context_step().
2017-08-04 14:02:06 +02:00
Ben Chan e1823e605e huawei: ensure MMBearerConnectResult populated into GSimpleAsyncResult
During the CONNECT_3GPP_CONTEXT_STEP_LAST step,
connect_3gpp_context_step() conditionally creates and populates a
MMBearerConnectResult object into the GSimpleAsyncResult object when the
ipv4_config field of the Connect3gppContext struct is set. That assumes
the ipv4_config field is always initialized in
connect_dhcp_check_ready() during the
CONNECT_3GPP_CONTEXT_STEP_IP_CONFIG step. Instead of having such an
assumption, this patch modifies connect_3gpp to always initialize
the ipv4_config field, such that connect_3gpp_context_step() always
populates a MMBearerConnectResult object into the GSimpleAsyncResult
object.
2017-08-03 12:35:40 +02:00
Aleksander Morgado f1f313c214 huawei: skip unrequired explicit casts to GSimpleAsyncResult 2017-07-17 10:20:16 +02:00
Aleksander Morgado 91bbcb5c5f huawei: fix async completion in 3gpp event handlers setting 2017-07-17 10:20:16 +02:00
Aleksander Morgado c0c2e8aae8 huawei: fix async completion in voice event handlers setting 2017-07-17 10:20:16 +02:00
Aleksander Morgado 7b0c0bc96b huawei: fix async completion in cdma event handlers setting 2017-07-17 10:20:16 +02:00
Aleksander Morgado b5e94185bb huawei: let the E3372 run NDISDUP via TTY
This modem ends up exposing a cdc-wdm port and a WWAN network
interface, but the cdc-wdm port is totally unusable, it won't reply to
any AT command or anything.

Instead this modem can do NDISDUP via TTY, which is what the Windows
drivers are also doing.
2017-06-02 13:13:59 +02:00
Aleksander Morgado f824602bdd modem-helpers: if operator not in UCS2, see if already valid UTF-8
The method doing the operator name normalization takes as input the
current configured modem charset. If this is UCS2, we will now just
assume this is a hint: the string may or may not come in hex/UCS2.

This logic makes the custom operator name loading in Huawei unneeded,
if the modem is configured in UCS2, we still properly process operator
names coming in plain ASCII.
2017-04-02 10:06:07 +02:00
Ben Chan 254f2e3412 plugins: remove explicit GDestroyNotify cast on g_free / g_object_unref
g_free and g_object_unref are in form of  `void (*)(gpointer)`, which
matches the GDestroyNotify signature. An explicit GDestroyNotify cast on
g_free and g_object_unref is thus not needed.
2017-03-29 10:22:18 +02:00
Riccardo Vangelisti dc01a30c2f huawei: ignore unsolicited message ^EONS 2017-03-24 17:52:47 +01:00
Aleksander Morgado 00fb9e98f6 kernel-device: device-specific properties in either port or physdev
There are 2 main types of udev properties: device-specific and
port-specific.

The port-specific properties are set independently per port (e.g. port
type hints set per interface number for a given vid:pid).

The device-specific properties apply to all ports in the device. Some
of these properties are currently expected in the physical device
(e.g. ID_MM_PLATFORM_DRIVER_PROBE) while some others are expected in
each port (e.g. the plugin udev tag filters).

This patch tries to simplify the logic and just assume that the device
specific tags may be given in either the physical device or the port
device, by providing separate APIs to retrieve port-specific or
device-specific (global) properties. If the same tag is given in both
the device and the port, the one in the device takes preference.

For the generic backend, these new APIs are really useless, as all
device-specific and port-specific properties are always stored in the
port object themselves (there is no 'tree' of devices in the generic
backend, no 'physdev' device).

For the udev backend, though, there really is a difference, as the
tags may be set in port or device.

https://bugs.freedesktop.org/show_bug.cgi?id=100156
2017-03-22 09:40:10 +01:00
Ben Chan 31655bb5a5 glib: remove invocations of g_type_init()
g_type_init() has been deprecated (and also marked with the attribute
'deprecated') since glib 2.36 as the type system is automatically
initialized. Since the minimum version of glib required by ModemManager
is 2.36, calling g_type_init() isn't necessarily in the ModemManager
code.
2017-02-03 10:05:14 +01:00
Aleksander Morgado 820ab01ddf kernel-device: ID_USB_INTERFACE_NUM should be read as an hex string
The original g_udev_device_get_property_as_int() uses strtol() without
an explicit base (i.e. 0) so that the base is autodetected from the
string whenever possible (e.g. if prefixes with '0x' it is treated as a
hexadecimal string).

But, for ID_USB_INTERFACE_NUM, we explicitly require reading the number
as an hex string, even if we don't have any '0x' prefix.

Reported-by: Matthew Stanger <stangerm2@gmail.com>
2016-11-07 19:41:05 +01:00
Aleksander Morgado 37bd614212 broadband-modem: implement default connection monitoring logic
A default implementation to monitor the ongoing connection is provided in the
generic MMBroadbandModem, based on AT+CGACT? to check whether the PDP context
of the connection (identified by the cached cid) is active or not.

This commit also disables the connection monitoring logic in those plugins that
have custom connection methods.
2016-10-12 11:29:52 +02:00
Aleksander Morgado 467b3c57f0 modem-helpers: new COPS? response parser
Split into two different actions the actual COPS? response parsing and the
operator name normalization process.

Also, allow parsing not only the operator string, but also the format, mode
and the optional access technology value.
2016-10-12 11:29:52 +02:00
Dan Williams 14ccde2b5f huawei: handle some weird SYSCFG acquisition orders
<debug> (ttyUSB2): --> 'AT^SYSCFG?<CR>'
<debug> (ttyUSB2): <-- '<CR><LF>^SYSCFG:14,2,400380,1,2<CR><LF><CR><LF>OK<CR><LF>'
<warn>  couldn't load current allowed/preferred modes: 'No SYSCFG combination found matching the current one (14,2)'

14,2 means "WCDMA-only; acquire WCDMA then GSM" which is somewhat
non-sensical. The supported modes parsing doesn't generate this
combination because it doesn't really make sense, so current mode
matching failed. Just fix up the non-sensical acquisition order
to 0 (automatic).
2016-10-05 09:14:44 -05:00
Aleksander Morgado ae9ede926a core: use the kernel device object in the port object and the plugin interface
The mm_base_modem_grab_port() now receives a MMKernelDevice directly from the
plugin, which is then stored in the MMPort corresponding to the port.

This means that we have direct access to e.g. all properties set by udev rules
everywhere, and we don't need additional GUdevClient objects (e.g. like the one
used in the Huawei plugin to detect NDISDUP support during runtime).

For virtual ports (e.g. generated during unit tests), we have a new 'generic'
kernel device object which just provides the values from the kernel device
properties given during its creation.
2016-09-29 15:43:05 +02:00
Aleksander Morgado aa4577dfb9 core: new kernel device object instead of an explicit GUdevDevice
Instead of relying constantly on GUdevDevice objects reported by GUdev, we now
use a new generic object (MMKernelDevice) for which we provide an initial GUdev
based backend.
2016-09-29 15:43:05 +02:00
Aleksander Morgado 1f813c4e96 core: allow identifying devices by a user-provided 'uid'
All ports of the same modem reported by the kernel will all be associated with
a common 'uid' (unique id), which uniquely identifies the physical device. This
logic was already in place, what we do now is avoid calling it  the 'sysfs
path' of the physical device, because we may not want to use that to identify
a device.

This logic now also enables the possibility of "naming" the modems in a unique
way by setting the "ID_MM_PHYSDEV_UID" property in the "usb_device" that owns
all the ports.

E.g. a custom device has 4 modems in 4 different USB ports. The device path of
each USB device will always be the same, so the naming rules could go like this:

    $ vim /usr/lib/udev/rules.d/78-mm-naming.rules

    ACTION!="add|change|move", GOTO="mm_naming_rules_end"
    DEVPATH=="/devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.5/4-1.5.1", ENV{ID_MM_PHYSDEV_UID}="USB-MODEM-1"
    DEVPATH=="/devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.5/4-1.5.2", ENV{ID_MM_PHYSDEV_UID}="USB-MODEM-2"
    DEVPATH=="/devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.5/4-1.5.3", ENV{ID_MM_PHYSDEV_UID}="USB-MODEM-3"
    DEVPATH=="/devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.5/4-1.5.4", ENV{ID_MM_PHYSDEV_UID}="USB-MODEM-4"
    LABEL="mm_naming_rules_end"

Each of the modems found will have a unique UID retrieved from the previous list
of rules. Then, "mmcli" has also been updated to allow using the UID instead of
the modem DBus path or index, e.g.:

    $ sudo mmcli -m USB-MODEM-1
    /org/freedesktop/ModemManager1/Modem/0 (device id '988d83252c0598f670c2d69d5f41e077204a92fd')
      -------------------------
      Hardware |   manufacturer: 'ZTE CORPORATION'
               |          model: 'MF637'
               |       revision: 'BD_W7P673A3F3V1.0.0B04'
               |      supported: 'gsm-umts'
               |        current: 'gsm-umts'
               |   equipment id: '356516027657837'
      -------------------------
      System   |         device: 'USB-MODEM-1'
               |        drivers: 'option'
               |         plugin: 'ZTE'
               |   primary port: 'ttyUSB5'
               |          ports: 'ttyUSB5 (at)'
    ...

    $ sudo mmcli -m USB-MODEM-1 --enable
    ...
2016-09-29 15:41:21 +02:00
Aleksander Morgado fe6f374af6 huawei: fix interface class/subclass/protocol matching
Commit a66871a287 introduced an additional
ATTRS{idVendor} match condition in the same rules matching by interface class,
subclass and protocol. We shouldn't be doing that because we cannot mix parent
attribute matchings from different parents.
2016-09-18 16:37:14 +02:00
Aleksander Morgado aa0e108107 udev: fix SUBSYSTEMS and ATTRS{idVendor} checks
Rules with a single condition where a parent property is checked with != don't
work properly. E.g.:
  SUBSYSTEMS!="usb", GOTO="end"
or:
  ATTRS{idVendor}!="abcd", GOTO="end"

Instead, we can mix both those previous parent rules and match them:
  SUBSYSTEMS=="usb",ATTRS{idVendor}=="abcd", GOTO="next"
  GOTO="end"
  LABEL="next"
  # Apply rules here
  LABEL="end"

In this case both SUBSYSTEMS and ATTRS conditions apply to the parent usb_device
(idVendor attribute is only available in the usb_device), so they apply to all
ports of the same device.
2016-09-18 14:08:20 +02:00