Commit Graph

106 Commits

Author SHA1 Message Date
Aleksander Morgado
d5d0ed0b24 tests: print MM logs only on verbose test mode
Therefore, avoid needing ENABLE_TEST_MESSAGE_TRACES build symbol.
2019-10-14 15:30:27 +02:00
Aleksander Morgado
8092e301fc port-serial: allow deciding whether the command is queued last or run next
By default all the commands we were sending through the serial port
were added at the tail of the pending queue, but we may want to queue
them at the head in very specific cases (e.g. while sending an SMS).
2019-06-03 03:50:22 +00:00
Ben Chan
7de6b6f2e1 core: remove unnecessary NULL checks for g_match_info_free()
g_match_info_free() already check if the given pointer is NULL and does
nothing on a NULL pointer.
2018-10-18 13:17:36 +02:00
Aleksander Morgado
86f840d97b port-probe: explicitly report GPS port type if port flagged
And remove all custom logic from all plugins that were doing just that.
2018-08-10 04:19:13 +00:00
Aleksander Morgado
85adbdbdd1 plugins: consolidate ID_MM_PORT_TYPE_GPS flag name
Use the same flag name across all plugins with support for
NMEA-capable TTYs.
2018-08-10 04:19:13 +00:00
Aleksander Morgado
c07382a486 udev: add tags also on bind action
When a new USB device is hotplugged, e.g. a USB<->RS232 converter that
exposes a single ttyUSB0, these udev events happen:

  add  /devices/pci0000:00/0000:00:14.0/usb2/2-1 (usb/usb-device)
  add  /devices/pci0000:00/0000:00:14.0/usb2/2-1/2-1:1.0 (usb/usb-interface)
  add  /devices/pci0000:00/0000:00:14.0/usb2/2-1/2-1:1.0/ttyUSB0 (usb-serial)
  add  /devices/pci0000:00/0000:00:14.0/usb2/2-1/2-1:1.0/ttyUSB0/tty/ttyUSB0 (tty)
  bind /devices/pci0000:00/0000:00:14.0/usb2/2-1/2-1:1.0/ttyUSB0 (usb-serial)
  bind /devices/pci0000:00/0000:00:14.0/usb2/2-1/2-1:1.0 (usb/usb-interface)
  bind /devices/pci0000:00/0000:00:14.0/usb2/2-1 (usb/usb-device)

Our udev rules in MM only added tags in the 'add' events, and it looks
like the only ones 'persistent' after this sequence are those of the
last event happening on the specific path.

This meant that all TTY subsystem rules (e.g. ID_MM_CANDIDATE) would
be stored for later check (e.g. if ModemManager is started after these
rules have been applied), which was ok. "udevadm info -p ..." would
show these tags correctly always.

But this also meant that the 'bind' udev event happening for the USB
device didn't get any of our device-specific tags, and so we would be
missing them (e.g. ID_MM_DEVICE_MANUAL_SCAN_ONLY) if MM is started
after the last event has happened. "udevadm info -p ..." would
not show these tags.

Modify all our rules to also run at the 'bind' events.

See, for context:
  https://github.com/systemd/systemd/issues/8221
2018-06-02 16:54:37 +02:00
Aleksander Morgado
a4271d8433 mbm: port dial_3gpp() and disconnect_3gpp() to GTask
The two connection and disconnection methods are ported to GTask, and
are also updated so that the reception of the unsolicited message
reporting either connect/disconnection is able to right away complete
the pending connection/disconnection attempts, as done in other
plugins like the Icera or HSO ones.
2017-12-05 10:55:41 +01:00
Aleksander Morgado
280b72f15e mbm: remove unused struct member 2017-09-28 11:04:55 +02:00
Aleksander Morgado
6847fb48f6 mbm: no need to re-set self pointer 2017-09-28 10:58:00 +02:00
Ben Chan
e0a3eeee5d mbm: port get_ip_config_3gpp to use GTask 2017-09-28 10:49:57 +02:00
Ben Chan
a910c45c08 mbm: port {enable,disable}_location_gathering to use GTask 2017-09-28 10:49:57 +02:00
Ben Chan
414aac9510 mbm: port location_load_capabilities to use GTask 2017-09-28 10:49:57 +02:00
Ben Chan
d19593d344 mbm: port modem_3gpp_disable_unsolicited_events to use GTask 2017-09-28 10:49:57 +02:00
Ben Chan
f79719c518 mbm: port modem_3gpp_enable_unsolicited_events to use GTask 2017-09-28 10:49:56 +02:00
Ben Chan
4454f840bc mbm: port modem_3gpp_{setup,cleanup}_unsolicited_events to use GTask 2017-09-28 10:49:56 +02:00
Ben Chan
a0e3a889b0 mbm: port enabling_modem_init to use GTask 2017-09-28 10:49:56 +02:00
Ben Chan
0b37db42b4 mbm: port set_current_modes to use GTask 2017-09-28 10:49:56 +02:00
Ben Chan
43bf7c764b mbm: port modem_after_sim_unlock to use GTask 2017-09-28 10:49:56 +02:00
Ben Chan
2e7aff84a6 mbm: port modem_create_bearer to use GTask 2017-09-28 10:49:56 +02:00
Ben Chan
9f573d3bcf mbm: port common_send_pin_puk to use GTask 2017-09-28 10:49:56 +02:00
Aleksander Morgado
f455ce33b4 mbm: set GPS data port for DellDW5560
See https://lists.freedesktop.org/archives/modemmanager-devel/2017-August/005506.html
2017-08-04 17:10:41 +02:00
Aleksander Morgado
15a221e88d mbm: fix async completion in 3gpp event handlers setting 2017-07-17 10:20:17 +02:00
Aleksander Morgado
2eb55d3224 plugins: use G_N_ELEMENTS when iterating ports array 2017-05-30 17:28:23 +02:00
Aleksander Morgado
a690937902 mbm: fix async method completion enabling unsolicited events 2017-05-21 14:42:25 +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
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
74fd7da774 mbm: new MBM specific +CFUN? response parsers 2016-10-12 11:29:52 +02: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
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
c7d8ac622a udev: fix tagging per interface number
Commit 7ff57f9808 introduced a change to try to
use ATTRS{bInterfaceNumber} as a common way to match by interface number, but
this logic is broken because all the rules that we use to match by interface
number (attribute in the interface device) also require matching by idVendor
and idProduct (attributes in the physdev device), and udev rules forbid matches
from more than one parent device at a time.

We could use ATTR{bInterfaceNumber} (instead of ATTRS) to tag the actual USB
interface device, but that would require a change in all the plugins to look for
the tag not in the TTY device, but in its parent.

So, recover the original behavior, where a hidden property is created containing
the first bInterfaceNumber found in the list of parent devices, and then run
the matches against idVendor and idProduct only if the hidden property is found
with the expected value.
2016-09-18 15:43:30 +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
Aleksander Morgado
7fb366c41a core: use MM-specific logging methods always instead of the generic GLib ones 2016-08-15 13:14:47 +02:00
Aleksander Morgado
4d53e2eb98 mbm,udev: additional per-vendor conditions for quicker processing 2016-08-06 10:41:52 +02:00
Aleksander Morgado
7ff57f9808 udev: replace ENV{.MM_USBIFNUM} conditions with ATTRS{bInterfaceNumber} 2016-08-06 10:41:52 +02:00
Ting-Yuan Huang
969189d42c plugin-manager: protect mm_plugin_{major,minor}_version
This patch makes declarations bind to definitions within the same module
to prevent the potential ambiguity if referenced directly.

AddressSanitizer think they violated one definition rule, although
those symbols are accessed by address through their modules and do
not depend on the order of the libararies loaded.
2016-05-28 13:59:54 +02:00
Dan Williams
ba097f1a43 broadband-bearer-mbm: connect errors should trigger a disconnect
Otherwise we may leave a bearer connected when ModemManager doesn't
think it's connected.  Prevents a CME ERROR 277 loop on connect when
the bearer hasn't been torn down correctly.
2016-05-27 12:30:06 -05:00
Dan Williams
5c3461ff9c broadband-bearer-mbm: wait for disconnect to complete
Wait for either an E2NAP unsolicited disconnect status or (for older
devices) an ENAP poll response before completing the disconnect.
Otherwise the client may start connecting again (such as
NetworkManager autoconnect retry) and the unsolicited E2NAP may
abort it, or the modem may return CME ERROR 277 ("not disconnected
yet") for the next connection attempt.

https://bugs.freedesktop.org/attachment.cgi?id=123525
2016-05-27 12:30:05 -05:00
Dan Williams
9cc851954d broadband-bearer-mbm: simplify dial_3gpp connection setup flow
There are a few key parts to this patch:

1) move the poll id into the Dial3gppContext structure as it is
conceptually part of the connection context data.  This simplifies
context cleanup by keeping the poll id cleanup in one place.

2) move unsolicited connection status (E2NAP) handling into the
normal connection codepath, instead of completing the connection
context from the report_connection_status() E2NAP handler.  This
simplifies connect code by not requiring checks for a NULL context
everywhere, and allows us to pass the Dial3gppContext structure
around instead of the Bearer object, since the Dial3gppContext
will never be comleted/freed outside the normal connection flow
codepaths like GLib idles and AT command requests.

3) use the connect context cancellable for all AT command requests
in the connect path.  This lets us use the error return from
mm_base_modem_at_command_full_finish() to handle cancellation and
also not bother listening to the 'cancelled' signal of the
cancellable, since we can just check for cancellation the next time
the ENAP poll function runs.

https://bugs.freedesktop.org/show_bug.cgi?id=95304
2016-05-27 12:30:05 -05:00
Lubomir Rintel
e27f4a6226 mbm: clean up the context on activate_ready
Otherwise the dangling pointer to the context that's being deallocated causes a
crash on spontaneous E2NAP receipt:

  ModemManager[1567]: <info>  [1462468083.031326] [mm-iface-modem.c:1431] __iface_modem_update_state_internal(): Modem /org/freedesktop/ModemManager1/Modem/0: state changed (connecting -> registered)
  ModemManager[1567]: <debug> [1462468083.053745] [mm-port-serial-at.c:459] debug_log(): (ttyACM0): <-- '<CR><LF>*E2NAP: 0,36<CR><LF>'
  ModemManager[1567]: <debug> [1462468083.053857] [mbm/mm-broadband-modem-mbm.c:824] e2nap_received(): disconnected

  (ModemManager:1567): GLib-GIO-CRITICAL **: g_simple_async_result_set_error: assertion 'G_IS_SIMPLE_ASYNC_RESULT (simple)' failed

  Program received signal SIGTRAP, Trace/breakpoint trap.
  g_logv (log_domain=0x7ffff7086798 "GLib-GIO", log_level=G_LOG_LEVEL_CRITICAL, format=<optimized out>, args=args@entry=0x7fffffffcda0) at gmessages.c:1046
  1046              g_private_set (&g_log_depth, GUINT_TO_POINTER (depth));
  Missing separate debuginfos, use: debuginfo-install libmbim-1.12.4-2.el7.centos.x86_64 libqmi-1.14.2-1.el7.centos.x86_64
  (gdb) bt
  #0  0x00007ffff6a508c3 in g_logv (log_domain=0x7ffff7086798 "GLib-GIO", log_level=G_LOG_LEVEL_CRITICAL, format=<optimized out>, args=args@entry=0x7fffffffcda0) at gmessages.c:1046
  #1  0x00007ffff6a50a3f in g_log (log_domain=log_domain@entry=0x7ffff7086798 "GLib-GIO", log_level=log_level@entry=G_LOG_LEVEL_CRITICAL, format=format@entry=0x7ffff6abe73d "%s: assertion '%s' failed") at gmessages.c:1079
  #2  0x00007ffff6a50a79 in g_return_if_fail_warning (log_domain=log_domain@entry=0x7ffff7086798 "GLib-GIO", pretty_function=pretty_function@entry=0x7ffff7092ce0 <__FUNCTION__.13394> "g_simple_async_result_set_error", expression=expression@entry=0x7ffff7092a40 "G_IS_SIMPLE_ASYNC_RESULT (simple)") at gmessages.c:1088
  #3  0x00007ffff6ff9d3d in g_simple_async_result_set_error (simple=0x7fffe8006e40, domain=297, code=0, format=0x7ffff175b53f "Call setup failed") at gsimpleasyncresult.c:719
  #4  0x00007ffff17569ea in report_connection_status (bearer=0x7fffe4008a40 [MMBroadbandBearerMbm], status=MM_BEARER_CONNECTION_STATUS_DISCONNECTED) at mbm/mm-broadband-bearer-mbm.c:174
  #5  0x000055555559c9f1 in mm_base_bearer_report_connection_status (self=0x7fffe4008a40 [MMBroadbandBearerMbm], status=MM_BEARER_CONNECTION_STATUS_DISCONNECTED) at mm-base-bearer.c:1118
  #6  0x00007ffff17548ed in bearer_list_report_status_foreach (bearer=0x7fffe4008a40 [MMBroadbandBearerMbm], ctx=0x7fffffffd060) at mbm/mm-broadband-modem-mbm.c:805
  #7  0x00007ffff6a45f18 in g_list_foreach (list=<optimized out>, func=0x7ffff17548c9 <bearer_list_report_status_foreach>, user_data=0x7fffffffd060) at glist.c:994
  #8  0x00005555555a224b in mm_bearer_list_foreach (self=0x5555558e0680 [MMBearerList], func=0x7ffff17548c9 <bearer_list_report_status_foreach>, user_data=0x7fffffffd060) at mm-bearer-list.c:146
  #9  0x00007ffff1754a3d in e2nap_received (port=0x5555558e24c0 [MMPortSerialAt], info=0x555555935730, self=0x555555900330 [MMBroadbandModemMbm]) at mbm/mm-broadband-modem-mbm.c:850
  #10 0x000055555563d9fd in parse_unsolicited (port=0x5555558e24c0 [MMPortSerialAt], response=0x7fffe80054f0) at mm-port-serial-at.c:280
  #11 0x0000555555639915 in parse_response_buffer (self=0x5555558e24c0 [MMPortSerialAt]) at mm-port-serial.c:889
  #12 0x0000555555639f0b in common_input_available (self=0x5555558e24c0 [MMPortSerialAt], condition=G_IO_IN) at mm-port-serial.c:1019
  #13 0x0000555555639fc7 in iochannel_input_available (iochannel=0x555555926df0, condition=G_IO_IN, data=0x5555558e24c0) at mm-port-serial.c:1042
  #14 0x00007ffff6a4979a in g_main_context_dispatch (context=0x5555558a4a00) at gmain.c:3109
  #15 0x00007ffff6a4979a in g_main_context_dispatch (context=context@entry=0x5555558a4a00) at gmain.c:3708
  #16 0x00007ffff6a49ae8 in g_main_context_iterate (context=0x5555558a4a00, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at gmain.c:3779
  #17 0x00007ffff6a49dba in g_main_loop_run (loop=0x5555558acf10) at gmain.c:3973
  #18 0x000055555558d068 in main (argc=2, argv=0x7fffffffdc38) at main.c:181
  (gdb)

https://bugzilla.redhat.com/show_bug.cgi?id=1333293
https://bugs.freedesktop.org/show_bug.cgi?id=95303
2016-05-10 16:25:05 -05:00
Tomas Jura
0ccbd5d85d mbm: stop echos on gps port 2016-02-11 10:05:33 +01:00
Aleksander Morgado
0ebf6d5da5 mbm: query supported modes to the modem with +CFUN=?
We were trying to load the generic modes supported reported by either *CNTI=2 or
AT+WS46=?, so that then we could filter out the MBM-specific modes unsupported.

But, this may not be ideal, as both these two commands may fail:

    [mm-broadband-modem.c:1612] modem_load_supported_modes(): loading supported modes...
    [mm-port-serial.c:1237] mm_port_serial_open(): (ttyACM1) device open count is 3 (open)
    [mm-port-serial.c:1294] _close_internal(): (ttyACM1) device open count is 2 (close)
    [mm-port-serial-at.c:440] debug_log(): (ttyACM1): --> 'AT*CNTI=2<CR>'
    [mm-port-serial-at.c:440] debug_log(): (ttyACM1): <-- '<CR><LF>ERROR<CR><LF>'
    [mm-serial-parsers.c:364] mm_serial_parser_v1_parse(): Got failure code 100: Unknown error
    [mm-broadband-modem.c:1546] supported_modes_cnti_ready(): Generic query of supported 3GPP networks with *CNTI failed: 'Unknown error'
    [mm-port-serial.c:1237] mm_port_serial_open(): (ttyACM1) device open count is 3 (open)
    [mm-port-serial.c:1294] _close_internal(): (ttyACM1) device open count is 2 (close)
    [mm-port-serial-at.c:440] debug_log(): (ttyACM1): --> 'AT+WS46=?<CR>'
    [mm-port-serial-at.c:440] debug_log(): (ttyACM1): <-- '<CR><LF>ERROR<CR><LF>'
    [mm-serial-parsers.c:364] mm_serial_parser_v1_parse(): Got failure code 100: Unknown error
    [mm-broadband-modem.c:1494] supported_modes_ws46_test_ready(): Generic query of supported 3GPP networks with WS46=? failed: 'Unknown error'
    [mm-iface-modem.c:3974] load_supported_modes_ready(): couldn't load Supported Modes: 'Couldn't retrieve supported modes'

Instead, we'll ask the modem for the list of modes supported, and return that
directly.
2016-01-10 17:46:12 +01:00
Aleksander Morgado
ffde429843 core: use G_SOURCE_REMOVE and G_SOURCE_CONTINUE in GSourceFuncs 2015-12-02 17:07:39 +01:00
Aleksander Morgado
f60b055142 mbm: enable GPS port for HS2350
https://bugs.freedesktop.org/show_bug.cgi?id=85008

As reported by Dan Williams <dcbw@redhat.com>.
2015-04-10 08:29:57 +02:00
Aleksander Morgado
5fb8e87abd mbm: enable GPS port for H5321gw
https://bugs.freedesktop.org/show_bug.cgi?id=85008

As reported by Sven Arvidsson <sa@whiz.se>.
2015-04-10 08:29:57 +02:00
Fabrice Bellet
534eea345d mbm: add GPS location gathering support
The udev rules file is updated according to the list of devices
supporting gps features provided by the udev rules file from the
mbm-gpsd project.

https://bugs.freedesktop.org/show_bug.cgi?id=85008
2015-04-10 08:29:49 +02:00
Yunlian Jiang
977cf658a6 tests: fix memory leaks 2015-03-27 20:31:24 +01:00
Aleksander Morgado
5358d6fea0 sim: rename 'MMSim' to 'MMBaseSim'
Just so that we don't have same header names in src/ and /libmm-glib.
2014-07-06 16:55:29 +02:00
Aleksander Morgado
3ca267b01f bearer: rename 'MMBearer' to 'MMBaseBearer'
Just so that we don't have same header names in src/ and /libmm-glib.
2014-07-06 16:55:29 +02:00