Commit Graph

145 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
0d1952c489 option: disable preferred networks management in custom SIM object
It's been observed that running CPOL? would completely break the AT
port of the modules like the GIO225.

Fully disable this feature in the whole option and option-hso plugins,
by creating a new custom SIM object with the features disabled
completely, and setup as a new shared interface object.

Fixes https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/404
2021-07-27 00:10:02 +02:00
Aleksander Morgado
5db3e330b9 hso: query profile id from hso bearer during connecting phase
As the profile id is not really set in the base bearer object until
after connected.
2021-07-14 00:23:49 +02: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
43db860c44 base-bearer: report connection error on network initiated disconnections
By default, fallback to "unknown" mobile equipment error when the
modem gets disconnected by the network and we don't have any way to
know a more detailed reason.
2021-05-23 01:22:07 +02:00
Aleksander Morgado
25a1b28fbf core: strict return type in g_object_ref()
This is now a requirement when using glib 2.56.
2021-04-30 11:05:42 +00:00
Aleksander Morgado
887358663d broadband-bearer: rely on profile management for the cid selection
There is no longer need to perform all the CID selection logic in the
broadband bearer connection procedure, we can rely on the new profile
management operations to do the same thing.

We can do this because we're sure that all the MMBroadbandModem
objects implement the MMModem3gppProfileManager interface.

Additionally, given that we now provide the profile ID value as part
of the MMBearerConnectResult, we no longer need a custom
mm_broadband_bearer_get_3gpp_cid() as we can use the generic
mm_base_bearer_get_profile_id() for the same purpose.
2021-04-29 10:13:22 +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
1b35d74c15 kernel-device: add get_interface_number() method
We already have methods to query for interface specific attributes
like class/subclass/protocol, so add a new one for the interface
number, and make sure we use ATTRS{bInterfaceNumber} to load it
always, instead of assuming the ID_USB_INTERFACE_NUM property is set.
2021-02-24 20:47:57 +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
Giacinto Cifelli
4d58278d7f changed default authentication algorithm to CHAP
CHAP is almost universal nowadays, and so it is a better default
than PAP

Not changed for uBlox, that prefers an error if not specified,
and for Huawei, which uses NONE with user/pwd and has 2 CHAP choices
2020-07-24 16:34:40 +02:00
Aleksander Morgado
8722215f7e plugins: use logging module name as plugin name 2020-04-08 17:53:42 +02:00
Aleksander Morgado
662f8afc56 option,hso: port to use object logging 2020-04-08 16:35:09 +02:00
Aleksander Morgado
0f708daf0b modem-helpers: port supported modes filtering to use object logging 2020-04-08 16:35:09 +02:00
Aleksander Morgado
00dc961cad iface-modem-location: common helper code to test raw gps 2020-02-07 14:42:16 +00: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
68f3eeeaa7 option,hso: fix warnings with -Wsign-compare
option/mm-broadband-bearer-hso.c: In function ‘ip_config_ready’:
  option/mm-broadband-bearer-hso.c:128:21: error: comparison of integer expressions of different signedness: ‘gint’ {aka ‘int’} and ‘guint’ {aka ‘unsigned int’} [-Werror=sign-compare]
    128 |                 num != ctx->cid) {
        |                     ^~
2020-01-31 15:18:35 +01:00
Aleksander Morgado
bbeabb495e helpers: new macro to CLAMP high threshold only
Useful when clamping a unsigned integer with low threshold set to 0,
which would give us compiler warnings with -Wtype-limits when using
CLAMP(), e.g.:

  via/mm-broadband-modem-via.c: In function ‘handle_evdo_quality_change’:
  /usr/include/glib-2.0/glib/gmacros.h:811:63: error: comparison of unsigned expression < 0 is always false [-Werror=type-limits]
    811 | #define CLAMP(x, low, high)  (((x) > (high)) ? (high) : (((x) < (low)) ? (low) : (x)))
        |                                                               ^
  via/mm-broadband-modem-via.c:284:19: note: in expansion of macro ‘CLAMP’
    284 |         quality = CLAMP (quality, 0, 100);
        |                   ^~~~~
2020-01-31 15:18:35 +01:00
Aleksander Morgado
92cc41e060 option: fix warnings with -Wimplicit-fallthrough
option/mm-broadband-modem-option.c: In function ‘load_access_technologies_step’:
  option/mm-broadband-modem-option.c:565:18: error: this statement may fall through [-Werror=implicit-fallthrough=]
    565 |         ctx->step++;
        |         ~~~~~~~~~^~
  option/mm-broadband-modem-option.c:567:5: note: here
    567 |     case ACCESS_TECHNOLOGIES_STEP_OSSYS:
        |     ^~~~
  option/mm-broadband-modem-option.c:587:18: error: this statement may fall through [-Werror=implicit-fallthrough=]
    587 |         ctx->step++;
        |         ~~~~~~~~~^~
  option/mm-broadband-modem-option.c:589:5: note: here
    589 |     case ACCESS_TECHNOLOGIES_STEP_OWCTI:
        |     ^~~~
  option/mm-broadband-modem-option.c:600:18: error: this statement may fall through [-Werror=implicit-fallthrough=]
    600 |         ctx->step++;
        |         ~~~~~~~~~^~
  option/mm-broadband-modem-option.c:602:5: note: here
    602 |     case ACCESS_TECHNOLOGIES_STEP_LAST:
        |     ^~~~
2020-01-31 14:52:50 +01:00
Aleksander Morgado
cff9d4a797 option: fix warnings with -Wdiscarded-qualifiers
option/mm-broadband-modem-option.c:978:7: error: initialization discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
    978 |     { "_OSSYS=1",  3, FALSE, NULL },
        |       ^~~~~~~~~~
  option/mm-broadband-modem-option.c:979:7: error: initialization discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
    979 |     { "_OCTI=1",   3, FALSE, NULL },
        |       ^~~~~~~~~
  option/mm-broadband-modem-option.c:980:7: error: initialization discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
    980 |     { "_OUWCTI=1", 3, FALSE, NULL },
        |       ^~~~~~~~~~~
  option/mm-broadband-modem-option.c:981:7: error: initialization discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
    981 |     { "_OSQI=1",   3, FALSE, NULL },
        |       ^~~~~~~~~
  option/mm-broadband-modem-option.c:1033:7: error: initialization discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
   1033 |     { "_OSSYS=0",  3, FALSE, NULL },
        |       ^~~~~~~~~~
  option/mm-broadband-modem-option.c:1034:7: error: initialization discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
   1034 |     { "_OCTI=0",   3, FALSE, NULL },
        |       ^~~~~~~~~
  option/mm-broadband-modem-option.c:1035:7: error: initialization discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
   1035 |     { "_OUWCTI=0", 3, FALSE, NULL },
        |       ^~~~~~~~~~~
  option/mm-broadband-modem-option.c:1036:7: error: initialization discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
   1036 |     { "_OSQI=0",   3, FALSE, NULL },
        |       ^~~~~~~~~
2020-01-31 14:52:50 +01:00
Aleksander Morgado
2fd6d401f5 option: fix warnings with -Wswitch-default 2020-01-31 14:52:49 +01:00
Aleksander Morgado
2d779b97c4 option: setup as loadable 'shared' utils 2019-11-27 10:11:43 +00:00
Aleksander Morgado
09d563fd34 hso: make report_connection_status() a separate logical block
This block is a subclassed method from MMBaseBearer, which we just
happen to also use as part of the 3GPP dial logic in the connection
attempt.

So make it a separate logical block, and call the processing of the
connection attempt if one is found.

This change makes it similar to the same logic in the Icera plugin.
2017-12-05 10:55:41 +01:00
Aleksander Morgado
b6e3cb463d hso: use a 60s timeout to wait for connection unsolicited messages
Same amount of time as in the Icera plugin.
2017-12-05 10:55:41 +01:00
Aleksander Morgado
90116bf1be hso: port dial_3gpp() to GTask 2017-12-05 10:55:41 +01:00
Ben Chan
795ecad0e6 hso: port disconnect_3gpp to use GTask 2017-09-20 09:30:27 -07:00
Ben Chan
ee80e1f660 hso: port get_ip_config_3gpp to use GTask 2017-09-20 09:30:27 -07:00
Ben Chan
8bae1a785a hso: port {enable,disable}_location_gathering to use GTask 2017-09-20 09:30:27 -07:00
Ben Chan
227eae3f31 hso: port location_load_capabilities to use GTask 2017-09-20 09:30:27 -07:00
Ben Chan
616cfa9959 hso: port modem_3gpp_{setup,cleanup}_unsolicited_events to use GTask 2017-09-20 09:30:27 -07:00
Ben Chan
0131f9b006 hso: port modem_create_bearer to use GTask 2017-09-20 09:30:27 -07:00
Ben Chan
d23dd2343a hso: port load_unlock_retries to use GTask 2017-09-20 09:30:27 -07:00
Ben Chan
a62d34c35a hso: port hso_custom_init to use GTask 2017-09-20 09:30:27 -07:00
Aleksander Morgado
bb5cd9b4e2 option: remove unneeded explicit casts 2017-09-18 21:23:05 -07:00
Ben Chan
5ffc3b7a92 option: port modem_3gpp_disable_unsolicited_events to use GTask 2017-09-18 20:25:28 -07:00
Ben Chan
cb23ba7cba option: port modem_3gpp_enable_unsolicited_events to use GTask 2017-09-18 20:25:28 -07:00
Ben Chan
3fdfe5e3ab option: port modem_3gpp_{setup,cleanup}_unsolicited_events to use GTask 2017-09-18 20:25:28 -07:00
Ben Chan
7546b95122 option: port modem_after_power_up to use GTask 2017-09-18 20:25:28 -07:00
Ben Chan
6ad9ccbfa2 option: port set_current_modes to use GTask 2017-09-18 20:25:28 -07:00
Ben Chan
78432e7910 option: port load_access_technologies to use GTask 2017-09-18 20:25:28 -07:00
Ben Chan
0c726981ca option: port load_supported_modes to use GTask 2017-09-18 20:25:28 -07:00
Aleksander Morgado
a29610f25d plugin,port-probe: always cast SEND_DELAY value to guint64
Program received signal SIGSEGV, Segmentation fault.
    strchr () at ../sysdeps/arm/armv6/strchr.S:28
    28    ../sysdeps/arm/armv6/strchr.S: No such file or directory.
    (gdb) bt
    #0  strchr () at ../sysdeps/arm/armv6/strchr.S:28
    #1  0x76b121c8 in g_param_spec_pool_lookup () from ~/buildroot/output/staging/lib/libgobject-2.0.so.0
    #2  0x76b0cf44 in g_object_new_valist () from ~/buildroot/output/staging/lib/libgobject-2.0.so.0
    #3  0x76b0d39c in g_object_new () from ~/buildroot/output/staging/lib/libgobject-2.0.so.0
    #4  0x75f75e40 in mm_plugin_create () at ublox/mm-plugin-ublox.c:99
    #5  0x00031550 in load_plugin (path=0xe9b68 "/usr/lib/ModemManager/libmm-plugin-ublox.so") at mm-plugin-manager.c:1521
    #6  load_plugins (error=0x7efffa68, self=0xdc4f0) at mm-plugin-manager.c:1574
    #7  initable_init (initable=<optimized out>, cancellable=<optimized out>, error=0x7efffa68) at mm-plugin-manager.c:1679
    #8  0x76b9b278 in g_initable_new_valist () from ~/buildroot/output/staging/lib/libgio-2.0.so.0
    #9  0x76b9b2e0 in g_initable_new () from ~/buildroot/output/staging/lib/libgio-2.0.so.0
    #10 0x000324d0 in mm_plugin_manager_new (plugin_dir=0xe9c40 "/usr/lib/ModemManager", error=error@entry=0x7efffa68) at mm-plugin-manager.c:1620
    #11 0x0002da08 in initable_init (initable=0xddb40, cancellable=<optimized out>, error=0x7efffa68) at mm-base-manager.c:1113
    #12 0x76b9b278 in g_initable_new_valist () from ~/buildroot/output/staging/lib/libgio-2.0.so.0
    #13 0x76b9b2e0 in g_initable_new () from ~/buildroot/output/staging/lib/libgio-2.0.so.0
    #14 0x0002e81c in mm_base_manager_new (connection=connection@entry=0xe1070, plugin_dir=plugin_dir@entry=0x9efb0 "/usr/lib/ModemManager",
        auto_scan=auto_scan@entry=1, initial_kernel_events=initial_kernel_events@entry=0x0, enable_test=0, error=0x7efffa68, error@entry=0x7efffa60)
        at mm-base-manager.c:957
    #15 0x0002b6ec in bus_acquired_cb (connection=0xe1070, name=<optimized out>, user_data=<optimized out>) at main.c:87
    #16 0x76c26864 in connection_get_cb () from ~/buildroot/output/staging/lib/libgio-2.0.so.0
    #17 0x76bc76cc in g_task_return_now () from ~/buildroot/output/staging/lib/libgio-2.0.so.0
    #18 0x76bc7d50 in g_task_return () from
    ~/buildroot/output/staging/lib/libgio-2.0.so.0

See similar bug in GStreamer:
https://bugzilla.gnome.org/show_bug.cgi?id=740191
2017-09-05 20:16:18 +02:00
Aleksander Morgado
a3c980c78b option,hso: fix async completion in 3gpp event handlers setting 2017-07-17 10:20:17 +02:00
Aleksander Morgado
f3a301db3c option: 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
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
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
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