Commit Graph

120 Commits

Author SHA1 Message Date
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
a19be8952f cinterion: report selected RTS/CTS flow control to modem 2018-09-12 17:15:46 +00:00
Aleksander Morgado
59e79c996b cinterion: new 'MMSharedCinterion' interface
Implement a new interface to keep the code shared between the QMI and
non-QMI modem implementations.

While doing that, also fix the parent interface pointer handling, so
that it isn't a static pointer applicable to all modems, and make it a
per-modem specific pointer. Without this fix, ModemManager would crash
if e.g. running with both a QMI and non-QMI Cinterion modem at the
same time.

The new shared Cinterion logic will be in charge of managing all GPS
sources not already managed by the parent interface. E.g. if the
parent implementation already supports QMI-based GPS location (using
the LOC service for example) prefer that to the custom AT-based
logic.
2018-08-21 17:06:55 +00: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
b8c7773a74 cinterion: fix band related unit tests
The sort_band() method used in the tester was totally wrong, it was
comparing the addresses of the variables instead of the MMModemBand
values.

Use the common mm_common_bands_garray_sort() instead, which works as
expected.
2018-07-31 00:23:25 +02:00
Reinhard Speyerer
ebe9fcd574 mm-modem-helpers-cinterion: update band table for PLS8-J
The default AT^SCFG="Radio/Band" value for Cinterion PLS8-J devices is
"16819472". Add UMTS band 19 and LTE band 19 entries based on the
information given in the PLS8 datasheet.
2018-07-30 21:22:07 +02:00
mstanger
7913fe4faf mm-modem-helpers-cinterion: update freq/band table
This info comes from PLS8-X/E/J/V/US, HC25 & PHS8 references, the
last two can be found publicly via Google search.

Swapped bit-mask locations for G850 & PCS bands as they may have
changed with FW or where accidently put in the wrong place.

Updated many 3G & 4G bit-mask fields.
2018-07-27 17:47:23 +02: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
882f6b04d6 cinterion: port modem_create_bearer to GTask 2017-10-07 14:10:12 +02:00
Aleksander Morgado
e9f56ddf15 cinterion: port after_sim_unlock to GTask 2017-10-07 13:58:55 +02:00
Aleksander Morgado
b1948f83a5 cinterion: port load_unlock_retries_context to GTask 2017-10-07 13:40:30 +02:00
Aleksander Morgado
e1b2b88e68 cinterion: port setup_flow_control to GTask 2017-10-07 13:40:30 +02:00
Aleksander Morgado
926e0176fb cinterion: port set_current_bands to GTask 2017-10-07 13:40:30 +02:00
Aleksander Morgado
ea58d35947 cinterion: port load_current_bands to GTask 2017-10-07 13:40:30 +02:00
Aleksander Morgado
c1e17b9cad cinterion: port load_supported_bands to GTask 2017-10-07 13:40:30 +02:00
Aleksander Morgado
7f2520a83d cinterion: port register_in_network to GTask 2017-10-07 13:40:30 +02:00
Aleksander Morgado
f9e2ebf3a0 cinterion: port modem_power_off to GTask 2017-10-07 13:40:30 +02:00
Aleksander Morgado
00aa9cd09b cinterion: port modem_power_down to GTask 2017-10-07 13:40:30 +02:00
Aleksander Morgado
73f748f7ac cinterion: port messaging_check_support to GTask 2017-10-07 13:40:30 +02:00
Aleksander Morgado
d09f9adafe cinterion: port messaging_enable_unsolicited_events to GTask 2017-10-07 13:40:30 +02:00
Aleksander Morgado
7e478e408d cinterion: port plugin custom_init to GTask 2017-10-07 13:40:30 +02:00
Aleksander Morgado
aae7105743 cinterion: update frequency bands support
Updated to use the non-deprecated MMModemBand values.
2017-09-07 10:55:17 +02:00
Ben Chan
344d96af44 cinterion: check error returned by g_task_propagate_error instead
When returning an enum value via g_task_return_int, some code assumes
the enum value is always non-negative and thus considers that a negative
value implies an error. This assumption could be invalidated if a
negative value is later added to the enum. To make it less error prone
to future changes, this patch modifies the code to check if the GError
argument to g_task_propagate_error is populated instead.
2017-07-07 10:15:07 +02:00
Aleksander Morgado
f4c4e36461 cinterion: use ^SIND unsolicited messages for access tech reporting
If the modem supports ^SIND psinfo reporting, we enable the URC and
flag the access technology polling unsupported, so that we only update
access technology via the +CIEV URCs.

E.g.:

    (ttyACM1): --> 'AT^SIND="psinfo",1<CR>'
    (ttyACM1): <-- '<CR><LF>^SIND: psinfo,1,10<CR><LF><CR><LF>OK<CR><LF>'
    Reporting initial access technologies...
    Modem /org/freedesktop/ModemManager1/Modem/0: access technology changed (unknown -> hsdpa, hsupa)
    ...
    (ttyACM1): <-- '<CR><LF>+CIEV: psinfo,4<CR><LF>'
    Modem /org/freedesktop/ModemManager1/Modem/0: access technology changed (hsdpa, hsupa -> edge)
    ...
2017-06-06 15:21:08 +02:00
Aleksander Morgado
2c19b1f778 iface-modem: if bands, capabilities or modes change, refresh signal
We also remove the explicit refresh request from the Cinterion plugin,
as this is a generic action applicable to all modems that require
polling for signal quality and/or access technology.
2017-06-06 15:20:56 +02:00
Aleksander Morgado
8ad868cea2 iface-modem: consolidate signal quality and access tech polling
Plugins have two ways to update signal quality and access technology
values: via unsolicited messages or via polling periodically.

Instead of keeping separate contexts for polling signal quality and
access technology values, we setup a common timeout to trigger
both. This allows us to simplify in which case the explicit update is
required, whenever one is needed to be explicitly updated, the other
one should also be.

The logic now also allows plugins to return an UNSUPPORTED error in
either load_signal_quality() and/or load_access_technologies() to tell
the interface logic that the polling of the specific item shouldn't be
performed (e.g. if the updates are expected via unsolicited messages).

If both signal quality and access technology polling is flagged as
disabled, we totally disable the polling logic internally.

The new SignalCheckContext is bound to the lifetime of the object so
that we can keep the value of the supported flags until the object is
destroyed.
2017-06-06 15:20:51 +02:00
Aleksander Morgado
e2e2c3e019 cinterion: retry GPS Engine activation up to 3 times
The default setup with 100ms between GPS commands doesn't seem to be
always enough for the Engine activation step:

   [1495016625.392972] (ttyACM1): --> 'AT^SGPSC="NMEA/Output","on"<CR>'
   [1495016625.503885] (ttyACM1): <-- '<CR><LF>^SGPSC: "Nmea/Output","on"<CR><LF><CR><LF><CR><LF>OK<CR><LF>'
   [1495016625.607650] (ttyACM1): --> 'AT^SGPSC="Power/Antenna","on"<CR>'
   [1495016625.697862] (ttyACM1): <-- '<CR><LF>^SGPSC: "Power/Antenna","on"<CR><LF><CR><LF>OK<CR><LF>'
   [1495016625.809393] (ttyACM1): --> 'AT^SGPSC="Engine","1"<CR>'
   [1495016625.895970] (ttyACM1): <-- '<CR><LF>+CME ERROR: 767<CR><LF>'

We now setup up to 3 retries for the Engine activation step before
returning an error, and we also update to 2000ms the wait time before
the Engine activation command is run.
2017-05-30 21:06:12 +02:00
Aleksander Morgado
aa8ac416f8 cinterion: support AT^SGPSC capable modems
The AT^SGPSS command provides an easy way to just start/stop GPS, but
unfortunately it isn't supported by all Cinterion modems.

The AT^SGPSC command instead is more widely available but it requires
several steps to start and stop the different elements of the GPS
receiver.

Implement support for both, preferring AT^SGPSSS if available and
falling back to AT^SGPSC otherwise.
2017-05-30 21:06:04 +02:00
Aleksander Morgado
d772301cd4 cinterion: setup GPS port only if GPS support detected
i.e. if AT^SGPSS not supported, we don't even add traces handler to
the GPS data port.
2017-05-30 21:05:56 +02:00
Aleksander Morgado
1857e9b36e cinterion: flag PLS8 GPS data port 2017-05-30 21:05:50 +02:00
Aleksander Morgado
bf549d1bca cinterion,location: refactor enable/disable and capabilities checks
When checking for location capabilities, we will make sure AT^SGPSS is
supported and if it isn't we won't report GPS capabilities.

The location enable and disable paths are refactored to make it easier
to add possible new GPS commands to use instead of AT^SGPSS, if this
isn't supported (e.g. in the PLS8 devices).
2017-05-30 21:05:44 +02:00
Aleksander Morgado
2b8a7e4c16 telit: remove custom +CMER enabling
This is now managed directly in the generic plugin.
2017-05-29 14:59:16 +02:00
Aleksander Morgado
ec98b9e956 cinterion: remove custom +CMER enabling
This is now managed directly in the generic plugin.
2017-05-29 14:59:01 +02:00
Aleksander Morgado
7f3b552804 cinterion: support changing modes in LTE capable devices 2017-05-29 14:46:03 +02:00
Aleksander Morgado
0f99328af6 cinterion: don't enable simstatus URCs
When polling for the SIM status, we want to read the value (mode 2)
without enabling indications (mode 1).
2017-05-21 21:39:52 +02:00
Aleksander Morgado
4fe464f5f7 core: prefer g_task_return_error_if_cancelled() than custom errors
When the GCancellable is added to the GTask, we can use a single
method call to check for the task being cancelled, and complete it
right away if so.

This patch also clears up the logic in the Novatel plugin, where the
code was trying to return "TRUE" when the task was cancelled, but
wouldn't work as the check-cancellable flag in the GTask is TRUE by
default (i.e. when completing the GTask, if it was cancelled, a
G_IO_ERROR_CANCELLED would be returned by default, regardless of any
other return value set).

This patch also introduces a small variation of the logic in the
Cinterion plugin: instead of running SWWAN=0 before completing the
async action, the command is now sent just after completion of the
async action. This shouldn't be an issue, as the SWWAN result itself
is ignored.
2017-04-18 19:31:02 +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
Aleksander Morgado
c1d04f4cc0 cinterion: improve ^SCFG=? response parser to handle EHS5 format
Two main changes in the regex:
  * Ignore double quotes around interval numbers.
  * Ignore second set of values (i.e. the one after the comma), as it
  may not even be given).

We now support at least these two formats:
   ^SCFG: "Radio/Band",("1-511","0-1")
   ^SCFG: "Radio/Band\",("1"-"147")

Reported-by: Colin Helliwell <colin.helliwell@ln-systems.com>
2017-03-07 18:40:51 +01:00
Aleksander Morgado
37df2643d2 cinterion: improve ^SMONG response parser:
* Allow whitespaces prefixing the values row.
  * Allow more than one \r\n between the title and the table header.

Reported-by: Colin Helliwell <colin.helliwell@ln-systems.com>
2017-02-16 12:27:57 +01:00
Aleksander Morgado
97eb23a964 cinterion: fix 'ds' setting in CNMI command builder
Reported-by: Colin Helliwell <colin.helliwell@ln-systems.com>
2017-02-14 09:46:05 +01:00
Aleksander Morgado
421713208b cinterion: support number ranges in CNMI=? parser
https://lists.freedesktop.org/archives/modemmanager-devel/2017-February/003911.html
2017-02-13 10:47:20 +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
11297bcc79 cinterion: implement connection status monitoring via ^SWWAN?
And consolidate the connection status checks done during connection and
disconnection so that we re-use the same logic.
2017-01-04 14:11:17 +01:00
Aleksander Morgado
9f725bc96a cinterion: default to PAP if no auth explicitly given
This is the same logic used in other implementations (e.g. QMI).
2017-01-04 14:11:17 +01:00
Aleksander Morgado
af2d6c1c4b cinterion: don't use predefined CIDs
The suggestion to use specific PDP context CIDs was given by Cinterion
for the special case of the Verizon operator, which 'reserves' specific
CIDs for specific purposes.

We don't want to impose that at the Cinterion plugin level, so remove
the PDP context mapping we had.

Therefore, simplify the connection procedure by just overriding the
'dialing' step of the default 3GPP connection sequence, instead of
overriding the whole connection sequence.

Also, we don't need to override the step to gather IP config because
this is already handled by the generic plugin (for DHCP over a network
interface).

We port to GTask for both 3GPP dial and 3GPP disconnect at the same time.
2017-01-04 14:11:17 +01:00
Aleksander Morgado
7d576a084c cinterion: fix typo in comment 2017-01-04 14:11:17 +01:00
Aleksander Morgado
1919138c68 cinterion: don't check for ^SWWAN support during enabling
Better check for ^SWWAN support during the first time a bearer is going
to be created.

The enabling phase isn't the correct one because this logic is only run
whenever a modem is detected but not hotplugged (i.e. this step is to
'reset' the modem to generic runtime settings).
2017-01-04 14:11:17 +01:00
Aleksander Morgado
9ca3fde06b cinterion: minor coding style fixes 2017-01-04 14:11:17 +01:00
Aleksander Morgado
37521ed2b6 cinterion: simplify ^SWWAN response parsing
We get as input the ^SWWAN index we're interested in, and we loop
through the list of ^SWWAN lines looking for the one we need.

This updated helper method allows working with multi-line ^SWWAN
responses, e.g. given when more than one PDP context is active.
2017-01-04 14:11:17 +01:00