Commit Graph

82 Commits

Author SHA1 Message Date
Rukun Mao
3da84c2079 suspend: add suspend/resume support with powerd on ChromeOS
ModemManager handles suspend and resume signals sent from powerd

Fixes https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/547
2022-06-09 08:32:13 +00:00
Daniele Palmas
654c5f5014 base-modem: add subsystem vendor ID property
Subsystem vendor ID can be used for identifying PCI modems,
so expose the property.
2022-05-24 09:22:06 +02:00
Aleksander Morgado
2c8cfb4768 modem-helpers: improve and fix COPS=? numeric fields parsing
The numeric fields in the +COPS=? response were relying on a very weak
parsing logic, assuming that they were single-digit numeric values and
not using the common string to integer conversion utilities.

This commit improves the conversion from the 3GPP/ETSI defined network
availability and access technology values to the MM defined ones,
providing enum-based matches even if the numeric values are the same.

The commit also fixes the parsing of access technology values > 10,
required to report 5G related values.
2022-03-16 11:04:06 +00:00
Aleksander Morgado
6fae479bd7 plugins: ignore reload_connection_status() where not supported
Some of the AT-based connection methods don't have any way to query
connection status, or we don't have a proper implementation for those
yet. Ignore the reload operation in all those.
2021-05-26 13:14:52 +00:00
Aleksander Morgado
5d176a1e61 base-modem: explicitly say if NET or TTY data ports are supported
A modem that creates exclusively bearer objects that work with NET
ports (e.g. all QMI or MBIM modems) must not add any TTY port in the
list of data ports.

A modem that creates exclusively bearer objects that work with TTY
ports (e.g. the generic modem) must not add any NET port in the
list of data ports.

A modem that may use both TTY and NET ports should add all in the list
of data ports.

Fixes https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/324
Fixes https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/329
2021-03-04 18:03:28 +01:00
Aleksander Morgado
16df1e17e6 helpers: rework normalize_operator() to use str_to_utf8()
Instead of blindly assuming that we can take whatever string given as
valid UTF-8, we'll always attempt to convert from the current modem
charset into UTF-8. Before we were doing this for hex-encoded UCS2,
but not for example for GSM-7.

And due to the now applied GSM-7 conversion, the mf627a/mf627b +COPS
parsing unit tests are updated accordingly, because when converting
from an input string that contains byte 0x40 ('@' in UTF-8) as if it
were GSM-7, the 0x40 is taken as character '¡', encoded as 0xc2,0xa1
in UTF-8).
2021-02-23 11:35:11 +00:00
Aleksander Morgado
34de613dea libmm-glib,common-helpers: make hexstr2bin() return a guint8 array
It makes much more sense than returning a gchar array, as gchar is
signed.
2021-02-23 11:35:11 +00:00
Aleksander Morgado
a211981d4a libmm-glib,common-helpers: make hexstr2bin() accept input string length
Optionally given explicitly, and -1 can be used to assume it's
NUL-terminated.
2021-02-23 11:35:11 +00:00
Aleksander Morgado
657cabcfce libmm-glib,common-helpers: make hexstr2bin() return a GError
This util method checks whether the input string is a valid hex
string, so make sure we return a GError on failure.
2021-02-23 11:35:11 +00:00
Aleksander Morgado
7f88280929 altair: make sure parse_vendor_pco_info() always returns an error
The parse_vendor_pco_info() method was returning NULL without error if
the pco info string was empty.

Under this situation, the code would have tried to add a NULL MMPco
into the pco_list list, which is not desired.

Avoid this, by making sure a NULL return always sets an error.
2020-12-19 10:45:14 +01:00
Aleksander Morgado
5d150ed23e core,plugins: consolidate connection/disconnection timeout values
Each different plugin or protocol had a different connection attempt
value. E.g. QMI and MBIM both used 60s max for the connection attempt,
while the u-blox plugin had up to 180s for ECM based connection
setups.

This commit consolidates all plugins and protocols to use the same
timeout values for commands that may take long to respond, e.g. a
connection atempt under low signal quality conditions.

A value of 180s for the connection attempt steps and 120s for a
disconnection attempt step is considered. Note, though, that in some
cases (like a IPv4v6 setup attempt using QMI) we may have more than
one such long step, so this doesn't mean that a connection attempt
will always take less than 180s.

Users of the connection/disconnection APIs should be able to handle
the case where the attempt times out in their side (e.g. with a lower
DBus request timeout), and which would not mean the actual request
they did really failed. E.g. a connection attempt with a DBus timeout
of 30s may fail in the user with a timeout error, but the attempt
would still go on for as much as the plugin/protocol needs.

Fixes https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/270
2020-11-14 09:41:43 +00:00
Aleksander Morgado
4b37b7d3cf base-modem,at: response processors return a more specific enum
Instead of using the FALSE return of the method to indicate either a
fatal error (if result_error was set) or the continuation request (if
result_error wasn't set), provide a enum that has explicit states for
all three possible values (failure, success or continue).
2020-06-28 15:07:34 +02:00
Aleksander Morgado
05301f23a1 iface-modem-3gpp: new 5GS network support 2020-04-09 12:38:50 +00:00
Aleksander Morgado
4b058872a0 plugins: don't add plugin name in log message explicitly 2020-04-08 17:53:42 +02:00
Aleksander Morgado
8722215f7e plugins: use logging module name as plugin name 2020-04-08 17:53:42 +02:00
Aleksander Morgado
f5ce4a722a altair: port to use object logging 2020-04-08 16:35:09 +02:00
Aleksander Morgado
9e24226364 port-probe: MMPortProbeAtCommand always has constant command strings 2020-01-31 15:18:35 +01:00
Aleksander Morgado
accd1a5841 base-modem: define new helper MMBaseModemAtCommandAlloc
It has the same exact format as MMBaseModemAtCommand, but its contents
are assumed heap allocated.

The only real purpose of this type is to allow defining static
constant MMBaseModemAtCommand variables without warnings when using
-Wdiscarded-qualifiers.
2020-01-31 15:18:35 +01:00
Aleksander Morgado
c1aac8ed26 altair: fix warnings with -Wdiscarded-qualifiers
altair/mm-plugin-altair-lte.c:44:7: error: initialization discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
     44 |     { "AT",  7, mm_port_probe_response_processor_is_at },
        |       ^~~~
  altair/mm-plugin-altair-lte.c:45:7: error: initialization discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
     45 |     { "AT",  7, mm_port_probe_response_processor_is_at },
        |       ^~~~
  altair/mm-plugin-altair-lte.c:46:7: error: initialization discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
     46 |     { "AT",  7, mm_port_probe_response_processor_is_at },
        |       ^~~~
  altair/mm-broadband-modem-altair-lte.c:886:5: error: initialization discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
    886 |   { "%STATCM=1", 10, FALSE, response_processor_no_result_stop_on_error },
        |     ^~~~~~~~~~~
  altair/mm-broadband-modem-altair-lte.c:887:5: error: initialization discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
    887 |   { "%NOTIFYEV=\"SIMREFRESH\",1", 10, FALSE, NULL },
        |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
  altair/mm-broadband-modem-altair-lte.c:888:5: error: initialization discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
    888 |   { "%PCOINFO=1", 10, FALSE, NULL },
        |     ^~~~~~~~~~~~
  ...
2020-01-31 15:18:35 +01:00
Aleksander Morgado
20c23edb83 altair,helpers: fix warnings with -Wsign-compare
CC       altair/tests/test_modem_helpers_altair_lte-test-modem-helpers-altair-lte.o
  In file included from /usr/lib/glib-2.0/include/glibconfig.h:9,
                   from /usr/include/glib-2.0/glib/gtypes.h:32,
                   from /usr/include/glib-2.0/glib/galloca.h:32,
                   from /usr/include/glib-2.0/glib.h:30,
                   from altair/tests/test-modem-helpers-altair-lte.c:20:
  altair/tests/test-modem-helpers-altair-lte.c: In function ‘test_parse_cid’:
  altair/tests/test-modem-helpers-altair-lte.c:98:58: error: comparison of integer expressions of different signedness: ‘guint’ {aka ‘unsigned int’} and ‘int’ [-Werror=sign-compare]
     98 |     g_assert (mm_altair_parse_cid ("%CGINFO:blah", NULL) == -1);
        |                                                          ^~
  /usr/include/glib-2.0/glib/gmacros.h:937:25: note: in definition of macro ‘G_LIKELY’
    937 | #define G_LIKELY(expr) (expr)
        |                         ^~~~
  altair/tests/test-modem-helpers-altair-lte.c:98:5: note: in expansion of macro ‘g_assert’
     98 |     g_assert (mm_altair_parse_cid ("%CGINFO:blah", NULL) == -1);
        |     ^~~~~~~~
2020-01-31 14:52:49 +01:00
Aleksander Morgado
40e9434cc3 altair-lte: use autoptr support from glib 2020-01-15 18:56:01 +01:00
Ben Chan
49f391b10d altair-lte: remove unused fields in DetailedDisconnectContext 2019-04-08 13:30:14 -07:00
Ben Chan
0d6e2dc9f5 altair-lte: use mm_autoptr instead of g_autoptr
commit 397faef3c5 ("mm-common-helpers: add mm_autoptr helpers for
GRegex and GMatchInfo") introduces mm_autoptr(), which implements
g_autoptr() that isn't available before glib 2.44. This patch fixes the
code to consistently uses mm_autoptr().
2018-12-13 10:48:21 +01:00
Dan Williams
397faef3c5 mm-common-helpers: add mm_autoptr helpers for GRegex and GMatchInfo
Alias them to g_autoptr() on glib >= 2.44, otherwise re-implement.
2018-12-04 17:39:15 +00:00
Ben Chan
bf1b396596 tests: use memcmp() instead of g_assert_cmpmem() for now
g_assert_cmpmem() isn't available until glib 2.46, while the minimum
glib version required by ModemManager is 2.36. This patch replaces the
uses of g_assert_cmpmem() with memcmp() instead.
2018-11-08 17:00:59 +01:00
Ben Chan
408a2a9c6c altair-lte: migrate from SubscriptionState to Pco property
In preparation of deprecating the SubscriptionState property in the
Modem3gpp interface, this CL updates the altair-lte plugin to update the
Pco property in the Modem3gpp interface upon receiving %PCOINFO
notification.
2018-10-26 09:41:44 -07:00
Ville Skyttä
90b89bb9f4 *: Spelling fixes 2018-01-25 09:52:12 +01:00
Aleksander Morgado
d1436ac0c6 altair: port 3gpp_register_in_network to GTask
And also use mm_base_modem_at_command() instead of the full() version,
as we're anyway mm_base_modem_peek_best_at_port().

This commit also fixes the logic where we make sure the finish()
method completes the GTask that is created in the async method
originally.
2017-10-06 09:44:41 +02:00
Ben Chan
fbf397cd6f altair-lte: don't use send-delay=0
On the modem with firmware revision ALT3100_04_05_06_10_A8_TF
(LTEUSB_02_04_05_10_53), it's observed that port probing doesn't
complete successfully when send-delay=0 is used.
2017-08-04 15:18:35 +02:00
Ben Chan
03d9619759 altair-lte: port modem_3gpp_load_subscription_state, altair_pco_info_changed to use GTask 2017-07-19 17:26:40 +02:00
Ben Chan
de4432da21 altair-lte: port modem_3gpp_disable_unsolicited_events to use GTask 2017-07-19 17:26:40 +02:00
Ben Chan
e2b161c684 altair-lte: port modem_3gpp_enable_unsolicited_events to use GTask 2017-07-19 17:26:40 +02:00
Ben Chan
00aaa1864a altair-lte: port modem_3gpp_{setup,cleanup}_unsolicited_events to use GTask 2017-07-19 17:26:40 +02:00
Ben Chan
282ed056a6 altair-lte: port load_current_bands to use GTask 2017-07-19 17:26:40 +02:00
Ben Chan
2d82c505e4 altair-lte: port load_supported_bands to use GTask 2017-07-19 17:26:40 +02:00
Ben Chan
4ea38c26e0 altair-lte: port load_unlock_retries to use GTask 2017-07-19 17:26:40 +02:00
Ben Chan
e2e7121e44 altair-lte: port load_current_capabilities to use GTask 2017-07-19 17:26:40 +02:00
Ben Chan
a96e8f824b altair-lte: port modem_create_bearer to use GTask 2017-07-19 17:26:40 +02:00
Ben Chan
555883d107 altair-lte: port modem_3gpp_run_registration_checks to use GTask 2017-07-19 17:26:40 +02:00
Ben Chan
15109a8513 altair-lte: port disconnect_3gpp to use GTask 2017-07-19 17:26:40 +02:00
Ben Chan
710d5c036b altair-lte: port connect_3gpp to use GTask 2017-07-19 17:26:40 +02:00
Aleksander Morgado
0be6e7d2ea altair-lte: fix async completion in 3gpp event handlers setting 2017-07-17 10:20:17 +02:00
Ben Chan
989ade7b8c enums: replace Roman numeral suffixes in MM_MODEM_BAND_EUTRAN_*
3GPP TS 36.101 Table 5.5-1 refers the E-UTRA operating bands as 1, 2, 3,
..., etc.
2017-06-28 18:21:25 +02:00
Aleksander Morgado
2eb55d3224 plugins: use G_N_ELEMENTS when iterating ports array 2017-05-30 17:28:23 +02:00
Aleksander Morgado
fcd4a8c5dc altair,hso,samsung: setup send-delay=0 for probing
The Altair, Option HSO and Samsung plugins all use the send-delay=0
setting once the modem object has been created. For consistency, use
the same setting during port probing.
2017-05-30 17:18:32 +02:00
Aleksander Morgado
fba49d8d00 broadband-modem: normalize also operator code
The operator code (MCCMNC) may also be given encoded in the current
charset (e.g. UCS2).

Based on a patch from Colin Helliwell <colin.helliwell@ln-systems.com>
2017-04-02 10:06:13 +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
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