Commit Graph
3891 Commits
Author SHA1 Message Date
Aleksander Morgado a9611c6279 utils: import ptr array lookup with GEqualFunc from GLib 2.54
This fixes the build when using GLib < 2.54.
2021-03-01 15:55:22 +01:00
Pavan Holla e1372a716e iface-modem: detect hotswap on all slots
Prior to this change, hotswap was detected on the primary sim slot only.
After this change, hotswap on any slot triggers reenumeration of the
modem. SIM hotswap events happening on the non-active slot would also
trigger a full modem reprobe. The modem may already have been
connected while the SIM event happens on the secondary slot, and we force
disconnection to reload the inactive SIM info. However, a user would
expect feedback for their SIM action, so we need to reprobe the modem.
2021-02-27 15:26:43 +01:00
Teijo Kinnunen 816beeffcb libmm-glib,modem-helpers,mm-base-sim: implement Sim.PreferredNetworks
The ModemManager1.Sim.PreferredNetworks property contains the preferred
networks (and access technologies, if available) configured to the
SIM card.

This commit implements preferred networks reading with AT+CPOL.
2021-02-26 12:28:01 +01:00
Aleksander Morgado c7d366671f shared-qmi: network registration cancellation logic with asserts disabled
g_assert() calls may be disabled, and if so, the network registration
task would never get completed.
2021-02-26 11:18:22 +01:00
Aleksander Morgado aba237df4e broadband-modem-qmi: allow lookup of QMI for data without SIO port 2021-02-25 14:13:03 +01:00
Aleksander Morgado 381e2f382b base-modem: separate method to lookup exact port by name
There's no point in returning a list of all ports with a given name,
just provide a lookup method that returns the single port with the
given name.
2021-02-25 14:13:03 +01:00
Aleksander Morgado b8e076f9c4 kernel-device-udev: keep track of the client object
Instead of creating new clients internally whenever we need them, just
make sure each MMKernelDeviceUdev object keeps a full reference to the
GUdevClient that generated all GUdevDevices.
2021-02-25 12:13:16 +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 4a06a02765 charsets: detect iconv() support in runtime
The only purpose of this is to log what we found, nothing else, as a
quick way to detect platform support for the charsets we need.
2021-02-23 11:35:11 +00:00
Aleksander Morgado 8a8e00168b charsets: define common translit fallback character 2021-02-23 11:35:11 +00:00
Aleksander Morgado c84454c1b0 charsets: remove charset_hex_to_utf8()
No longer used, replaced by the new common conversion methods.
2021-02-23 11:35:11 +00:00
Aleksander Morgado 0ff3eb7ee0 charsets: remove take_and_convert methods
These methods worked in a very strict way for some encodings, and in a
very very loose way for others. E.g. when converting from hex-encoded
UCS-2, we would attempt to convert as much text as we could even if
the input string was truly not even close to UCS-2. This kind of "do
our best" could make sense when processing e.g. the operator name
reported by the modem, as that is some string to show to the user and
there may be no strict requirement to have it perfectly fine. But the
kind of loose comparison done for UCS-2 doesn't make sense e.g. when
converting USSD responses or SMS messages.
2021-02-23 11:35:11 +00: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 63fa9eee46 charsets,tests: update take_and_convert tests to str_from/to 2021-02-23 11:35:11 +00:00
Aleksander Morgado e5363b546b charsets: use new str_from_utf8() instead of take_and_convert_to_current_charset() 2021-02-23 11:35:11 +00:00
Aleksander Morgado 395ab06c03 charsets: use new bytearray_to_utf8() instead of hex_to_utf8() 2021-02-23 11:35:11 +00:00
Aleksander Morgado 5ea4a591a4 charsets: use new bytearray_to_utf8() instead of byte_array_to_utf8() 2021-02-23 11:35:11 +00:00
Aleksander Morgado 033e174e44 charsets: make charset_gsm_unpacked_to_utf8() private
Use the generic mm_modem_charset_bytearray_to_utf8() instead.
2021-02-23 11:35:11 +00:00
Aleksander Morgado 8bfdfb187b charsets: use new bytearray_from_utf8() instead of byte_array_append() 2021-02-23 11:35:11 +00:00
Aleksander Morgado 75b37e16b1 charsets: make charset_utf8_to_unpacked_gsm() private
Use the generic mm_modem_charset_bytearray_from_utf8() instead.
2021-02-23 11:35:11 +00:00
Aleksander Morgado 9c613d33e1 charsets: new common APIs to convert from/to charsets and UTF-8 2021-02-23 11:35:11 +00:00
Aleksander Morgado 6f32c8d38f charsets: avoid //TRANSLIT when converting to/from charsets
The //TRANSLIT extension is not always supported by the different
iconv() implementations that we may find out there, so let's
completely avoid using it.

For some of the charsets it actually didn't make much sense anyway,
e.g. as converting to UTF-16 or UTF-8 would always be possible without
requiring //TRANSLIT to take effect.

The //TRANSLIT extension was also being used sometimes in the source
charset identification, which was also not fully correct, as we would
only expect it in the target charset identification.
2021-02-23 11:35:11 +00:00
Aleksander Morgado bc449cbe87 charsets: make translit optional in utf8_to_unpacked_gsm()
If the conversion is not fully compatible, the user of the method
needs to request transliteration enabled explicitly in order to avoid
returning errors in this method.
2021-02-23 11:35:11 +00:00
Aleksander Morgado 5ce97abd73 charsets: make translit optional in gsm_unpacked_to_utf8()
Until now, this method would automatically apply transliteration;
i.e. replacing characters with '?' when no direct translation was
available.

We can attempt to do that transliteration on strings that are not
critical, e.g. the operator name reported by the network. But we
should not do that on other types of strings, e.g. on SMS contents
that may really have additional purposes than just being
human-readable.

This commit makes the transliteration option to be explicitly
requested by the caller.
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 dbdf67e9f7 charsets: remove unused charset_utf8_to_hex() method 2021-02-23 11:35:11 +00:00
Aleksander Morgado 8b590721df charsets: don't allow quoting in byte_array_append()
There's no point in adding a quoting option to this method; if the
caller needs the appended string quoted, it should quote it before
passing it to this method.

It was nowhere used anyway.
2021-02-23 11:35:11 +00:00
Aleksander Morgado 38a4a9c842 charsets: remove HEX charset type
This is no real charset, it is the fake one we used to represent a
UCS2 hex-encoded string.
2021-02-23 11:35:10 +00:00
Aleksander Morgado a025e83e5a charsets: define charset enum explicitly as flags 2021-02-23 11:35:10 +00:00
Aleksander Morgado a546201470 bearer-mbim: IP type may be reported as deactivated and still have IP settings
If we were requesting for IPv4v6 and we only got IPv4 reported as
activated, we would right away ignore the IPv6 bits, even if we
received IPv6 settings later on when querying for them. Change that,
so that if an IP address of a given type is received, we assume the
corresponding context was really activated even if the modem didn't
report it in the connect set response.

Fixes https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/320
2021-02-23 09:29:29 +01:00
Aleksander Morgado b2f9771b85 broadband-modem-mbim: detect 5G support in custom data class
Fixes https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/301
2021-02-15 00:43:15 +01:00
Aleksander Morgado f3f05f397a device: avoid trying to remove source multiple times
ModemManager[115879]: <debug> [1613341789.760031] [modem3] completely disposed

   (ModemManager:115879): GLib-CRITICAL **: 23:29:49.760: Source ID 2379 was not found when attempting to remove it

   Thread 1 "ModemManager" received signal SIGTRAP, Trace/breakpoint trap.
   0x00007ffff774b343 in g_logv () from /usr/lib/libglib-2.0.so.0
   (gdb)
   (gdb) bt
   #0  0x00007ffff774b343 in g_logv () at /usr/lib/libglib-2.0.so.0
   #1  0x00007ffff774b5c0 in g_log () at /usr/lib/libglib-2.0.so.0
   #2  0x00007ffff7741c9e in g_source_remove () at /usr/lib/libglib-2.0.so.0
   #3  0x00005555555aad02 in dispose (object=0x555555831260) at mm-device.c:802
   #4  0x00007ffff7843755 in g_object_unref () at /usr/lib/libgobject-2.0.so.0
   #5  0x00005555555a5107 in glib_autoptr_clear_MMDevice (_ptr=0x555555831260) at mm-device.h:63
   #6  0x00005555555a5125 in glib_autoptr_cleanup_MMDevice (_ptr=0x7fffffffe090) at mm-device.h:63
   #7  0x00005555555a59ab in device_removed (self=0x555555769220, subsystem=0x55555577dc50 "tty", name=0x555555869a40 "ttyUSB3") at mm-base-manager.c:237
   #8  0x00005555555a620d in handle_uevent (self=0x555555769220, action=0x5555558987b0 "remove", device=0x555555893840) at mm-base-manager.c:445
   #9  0x00007ffff7381acd in  () at /usr/lib/libffi.so.7
   #10 0x00007ffff738103a in  () at /usr/lib/libffi.so.7
   #11 0x00007ffff783c8fe in g_cclosure_marshal_generic () at /usr/lib/libgobject-2.0.so.0
   #12 0x00007ffff7837072 in g_closure_invoke () at /usr/lib/libgobject-2.0.so.0
   #13 0x00007ffff785fa85 in  () at /usr/lib/libgobject-2.0.so.0
   #14 0x00007ffff78535dd in g_signal_emit_valist () at /usr/lib/libgobject-2.0.so.0
   #15 0x00007ffff7853b40 in g_signal_emit () at /usr/lib/libgobject-2.0.so.0
   #16 0x00007ffff7e792aa in  () at /usr/lib/libgudev-1.0.so.0
   #17 0x00007ffff7742b84 in g_main_context_dispatch () at /usr/lib/libglib-2.0.so.0
   #18 0x00007ffff7796c21 in  () at /usr/lib/libglib-2.0.so.0
   #19 0x00007ffff77420d3 in g_main_loop_run () at /usr/lib/libglib-2.0.so.0
   #20 0x00005555555a1df4 in main (argc=2, argv=0x7fffffffea88) at main.c:213
2021-02-14 23:34:36 +01:00
Dylan Van Assche 7159b8e27a context: add test-no-suspend-resume cli parameter
Disables suspend/resume support at runtime.
This is useful for modems which are never turned off
or suspended when the host suspends.
2021-02-14 12:27:42 +00:00
Aleksander Morgado 6107774bb2 filter: add missing reference to rpmsg filter 2021-02-06 15:32:11 +01:00
Andrew Lassalle e732a9afcc broadband-modem-qmi: remove unused variables 2021-02-03 09:31:28 -08:00
Aleksander Morgado 268bf4f98a core: update copyright years to 2021 2021-01-17 10:33:45 +01:00
Aleksander Morgado d12ab8a25a iface-modem: avoid leaking the MmGdbusModem when bearers are updated
See See https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/302
2021-01-11 14:27:46 +01:00
Andrew Lassalle 8ccd63ef64 test-sms-part-cdma: fix memory leak 2021-01-08 10:51:04 -08:00
Frederic Martinsons 2f53a08e5f iface-modem: don't consider charset setup failure as fatal.
On some modem (for example SORACOM SC-QGLC4-C1) , the character set setup
step fails with "Unknown error" when the SIM card is missing or locked.
This leads to not expose Modem interface and not being able to unlocked
the SIM.
We should not consider this step as fatal but just issue a warning to let
other steps continue (which will let modem in failed state anyway).

Closes #289

Signed-off-by: Frederic Martinsons <frederic.martinsons@sigfox.com>
2020-12-21 13:00:40 +00:00
Aleksander Morgado 3d4dd64dd0 broadband-modem-qmi: disable signal/access-tech polling if indications enabled
We can rely on QMI indications when the signal quality and access tech
changes happen, instead of doing explicit polling.

The modem will run the signal quality retrieval once, and then just
rely on indications, with polling disabled:

  ModemManager[278759]: <debug> [1606862198.230492] [modem1] signal strength (lte): -79 dBm
  ModemManager[278759]: <debug> [1606862198.230520] [modem1] signal strength: -79 dBm --> 55%
  ModemManager[278759]: <debug> [1606862198.230583] [modem1] access technology changed (unknown -> lte)
  ModemManager[278759]: <debug> [1606862198.230654] [modem1] signal quality updated (55)
  ModemManager[278759]: <debug> [1606862198.230675] [modem1] periodic signal quality and access technology checks not rescheduled: unneeded or unsupported
  ModemManager[278759]: <debug> [1606862198.230692] [modem1] periodic signal checks disabled

Fixes https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/231
2020-12-21 12:05:57 +00:00
Aleksander Morgado 47f39c9e1a broadband-modem-qmi: fix disabling of signal strength events
Attempting to disable the signal strength events was failing because
the protocol handler expects a valid set of thresholds also during the
disabling. So, just pass always the thresholds.

  ModemManager[274522]: [/dev/cdc-wdm1] sent generic request (translated)...
  <<<<<< QMUX:
  <<<<<<   length  = 17
  <<<<<<   flags   = 0x00
  <<<<<<   service = "nas"
  <<<<<<   client  = 3
  <<<<<< QMI:
  <<<<<<   flags       = "none"
  <<<<<<   transaction = 7
  <<<<<<   tlv_length  = 5
  <<<<<<   message     = "Set Event Report" (0x0002)
  <<<<<< TLV:
  <<<<<<   type       = "Signal Strength Indicator" (0x10)
  <<<<<<   length     = 2
  <<<<<<   value      = 00:00
  <<<<<<   translated = [ report = 'no' thresholds = '{}' ]

  ModemManager[274522]: [/dev/cdc-wdm1] received generic response (translated)...
  <<<<<< QMUX:
  <<<<<<   length  = 19
  <<<<<<   flags   = 0x80
  <<<<<<   service = "nas"
  <<<<<<   client  = 3
  <<<<<< QMI:
  <<<<<<   flags       = "response"
  <<<<<<   transaction = 7
  <<<<<<   tlv_length  = 7
  <<<<<<   message     = "Set Event Report" (0x0002)
  <<<<<< TLV:
  <<<<<<   type       = "Result" (0x02)
  <<<<<<   length     = 4
  <<<<<<   value      = 01:00:08:00
  <<<<<<   translated = FAILURE: NoThresholdsProvided
2020-12-21 12:05:57 +00:00
Aleksander Morgado da15958799 broadband-modem-qmi: reload initial EPS bearer on data system updates 2020-12-21 12:05:57 +00:00
Aleksander Morgado 2d9b62d23b iface-modem-3gpp: allow requesting the reload of the initial EPS bearer 2020-12-21 12:05:57 +00:00
Aleksander Morgado 5629f47a59 libmm-glib,bearer-properties: allow loose comparisons
When comparing bearer properties provided by the user versus loaded
from the modem, we shouldn't be very strict, e.g.:
 * Password or other fields may not be readable from the device.
 * Some fields may not apply at all (e.g. RM protocol for EPS bearers)
 * NULL strings could be assumed equal to empty strings.
 * If no explicit IP type specified, an IPv4 default may be assumed.
 * If no explicit allowed auth specified, 'none' default may be
   assumed.

These loose comparisons are applied when managing the initial EPS
bearer settings and status, and we keep the strict comparison only
during the connection attempt lookup of a bearer with certain
settings, as those bearer objects are all created in the same place
with the same rules.
2020-12-21 12:05:57 +00:00
Aleksander Morgado c99cc9210e iface-modem-3gpp: log requested/updates initial EPS bearer settings 2020-12-21 12:05:57 +00:00
Aleksander Morgado 5613215db8 broadband-modem-qmi: implement initial EPS bearer settings loading and setting 2020-12-21 12:05:57 +00:00
Aleksander Morgado 527b4e3232 broadband-modem-qmi: implement initial EPS bearer info loading 2020-12-21 12:05:57 +00:00
Aleksander Morgado 295400688a broadband-modem-qmi: allocate a generic WDS client
For generic WDS operations not tied to any connection attempt.
2020-12-21 12:05:57 +00:00