Commit Graph
267 Commits
Author SHA1 Message Date
Aleksander Morgado 4a2e13c16f test,modem-helpers-qmi: unit tests for NAS system info registration processing
Requires the response parser methods in libqmi.
2022-11-10 10:57:54 +00:00
Aleksander Morgado f419f56628 build: drop autotools 2022-11-07 14:26:02 +00:00
Andrey Skvortsov 22ba849724 charsets: Add test_text_split_two_pdu_gsm7_extended_chars to use extended character 2022-09-13 20:49:01 +00:00
Andrey Skvortsov 2ece78c80f charsets: move mm_sms_part_3gpp_util_split_text to mm_charset_util_split_text 2022-09-13 20:49:01 +00:00
Aleksander Morgado 74fc5baca2 core: port GRegex/GMatchInfo to use autoptr()
The behavior of GRegex changed in 2.73.2 once it was ported from pcre1
to pcre2. In some cases it was made more strict, which is fine, in
other cases it exposed some change in how it behaves on certain
matches that is not extremely clear whether it's ok or not.

See https://gitlab.gnome.org/GNOME/glib/-/issues/2729
See https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/601
See https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/621

Either way, one thing that was assumed was that initializing all
GRegex/GMatchInfo variables to NULL and making sure they're NULL
before they're initialized by glib (especially the GMatchInfo) was a
good and safer approach.

So, whenever possible, g_autoptr() is used to cleanup the allocated
GMatchInfo/GRegex variables, and otherwise, g_clear_pointer() is used
to ensure that no free/unref is attempted unless the given variable is
not NULL, and also so that the variable is reseted to NULL after being
disposed.
2022-09-05 17:33:11 +00:00
Aleksander Morgado 51a333cd9a test-modem-helpers: add EOL to strings matched with G_REGEX_NEWLINE_CRLF
Looks like pcre2 (used since glib 2.73.2) requires EOLs to match if
G_REGEX_NEWLINE_CRLF is explicitly used. The tests are updated
accordingly, because the modem responses will anyway have the EOLs
as well.

See https://gitlab.gnome.org/GNOME/glib/-/issues/2729#note_1544130

Fixes https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/601
2022-09-02 17:23:56 +02:00
Aleksander Morgado d5805002c1 core: remove "all rights reserved" from copyright lines
The rights each contributor has are the ones stated by the GPL/LGPL,
not more and not less.
2022-03-29 16:36:15 +02:00
Aleksander Morgado 598d99b5bd test,modem-helpers: add test for the EM9191 COPS=? response
Including 5GNR network reporting (act=12)

https://forum.sierrawireless.com/t/5g-network-scan-with-the-em9191-operation-not-allowed/26374/9
2022-03-16 11:04:06 +00: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 9c08e54fb9 shared-qmi: filter out modes not currently available
Do not build the mask of "all" modes based only on the supported radio
interfaces, also filter out those modes that would not be available
based on the current capabilities enabled.
2022-01-31 22:48:57 +01:00
Aleksander Morgado c7ff014e07 modem-helpers-qmi: multimode devices shouldn't always have 4G/5G only modes
In GSM/UMTS+CDMA/EVDO multimode devices, the 4G and 5G mode switching
operations are exclusively limited to the capability selection that
has LTE+5GNR exclusively.

We cannot allow switching to 4G-only, 5G-only or 4G+5G if the current
capabilities have GSM/UMTS or CDMA/EVDO.

Fixes https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/503
2022-01-31 22:48:57 +01:00
Aleksander Morgado ccf0b7eba2 tests,modem-helpers-qmi: add tests for supported modes loading 2022-01-31 22:48:57 +01:00
Aleksander Morgado 6efde10714 tests,modem-helpers-qmi: add additional tests for supported capabilities loading
Including tests for 5G-only and non-multimode 5G+4G and 5G+4G+3G devices.
2022-01-31 22:48:57 +01:00
Aleksander Morgado ff51fe637d tests,modem-helpers-qmi: add tests for supported capabilities loading 2022-01-31 22:48:57 +01:00
Aleksander Morgado f370c096ec modem-helpers-qmi: refer explicitly to current capabilities in helper method
The helper method for which we have unit tests available refers
exclusively to the current capabilities loading, so rename it to
clarify that.
2022-01-31 22:48:57 +01:00
Prakash Pabba 2322988855 test-modem-helpers-qmi: add unit test for generic 5g modem 2022-01-30 15:37:05 +00:00
Prakash Pabba 3a1390f1dd test-modem-helpers-qmi: Fix tests for UML290
Change due to update in current capabilities loading logic.
2022-01-30 15:37:05 +00:00
Aleksander Morgado 03fce4775e kerneldevice,generic: input pattern to string match is not regex
The input pattern given to the string_match() method is not a regex
pattern and we cannot use it as that, because all the special
characters (e.g. '.') would not be treated correctly.

Also, the prefix matching with the wildcard at the end of the string
needs to be converted to a proper regex wildcard, i.e. '.*'.

This logic also adds support for suffix matching, with a wildcard at
the beginning of the string, e.g. as the ones used for the wwan kernel
device name matching rules (i.e. '*MBIM').

Unit tests are added to cover all cases, most of these tests were
failing without the fixes implemented here.
2021-11-09 10:50:26 +01:00
Aleksander Morgado a37ce05a02 core: replace 'slave' with 'secondary' 2021-11-04 22:50:23 +01:00
Aleksander Morgado e8ebd3af7e core: replace 'master' with 'main' 2021-11-04 22:50:00 +01:00
Frederic Martinsons 9d82d30978 cli, plugins: factorize usage of iso8601 datetime format
Signed-off-by: Frederic Martinsons <frederic.martinsons@sigfox.com>

Includes updates by Aleksander Morgado to fix coding style issues.
2021-10-22 13:48:20 +02:00
Dylan Van Assche 92ad38432c mm-modem-helpers: only parse calls in voice mode
Calls in a CLCC response in data-only or fax-only mode
do not count as actuall calls.
2021-09-08 07:59:16 +00:00
Iñigo Martínez 77d1c24361 build: Port to meson
meson is a build system focused on speed an ease of use, which
helps speeding up the software development. This patch adds meson
support along autotools.
2021-09-07 10:55:43 +00:00
Teijo Kinnunen 0610267fa8 test,modem-helpers: add test case of AT+CPOL? response parsing 2021-08-02 12:42:13 +03:00
Aleksander Morgado 4cf12bb8bc helpers: skip g_warning() in mm_3gpp_parse_ws46_test_response()
Use mm_obj_warn() instead.
2021-06-16 11:59:51 +02:00
Aleksander Morgado 8da8fd0248 api: update MMMobileEquipmentError enum values
Update the list of mobile equipment error codes according to v17.1.0
of 3GPP TS 27.007 (March 2021).

A lot of the enum values that were prefixed with the 'GPRS_' keyword
have now been flagged as deprecated, and a new enum name given to the
corresponding value.

The deprecated symbol names are kept in the compat support to avoid
breaking API/ABI.
2021-05-22 22:58:37 +00:00
Aleksander Morgado d1bd0a2971 core: improve error helpers
First, simplify the logic that attempts to find the correct error code
associated to an error text string. This logic is very flaky, as it
relies on knowing what the modems report as text string for the
different error codes, and obviously that is not always the same.
Instead of supporting all error codes in this logic, we now limit them
to a small subset with common error codes and hopefully common error
strings.

Second, in order to quickly get the error description string for a
given error code, we rework the array of supported errors so that
the index of the array is the error code itself. For mobile equipment
errors the logic is straightforward, as they're always in the [0,255]
range, but for the message errors we create an array where the index
of the array is equal to the code plus 300 as they're always in the
[300,500] range. By doing this, we avoid having an array with 300 NULL
items before the actual values we want to support.
2021-05-22 22:58:37 +00:00
Teijo Kinnunen 14c4f27ae4 modem-helpers: add 3 digit MNC output to mm_3gpp_parse_operator_id()
MNC digit count information is lost on conversion to integers. Make it
possible for the caller to get this information through a separate
boolean.
2021-05-17 12:46:52 +03:00
Aleksander Morgado 62cbf7fa86 modem-helpers: new profile list helpers
The new helpers allow converting a PDP context list returned from the
+CGDCONT? parser to a list of 3GPP profile objects.

The new mm_3gpp_profile_list_find_best() method is equivalent to the
mm_3gpp_select_best_cid() one, but using profile objects as
input/output instead of specific settings.

The unit tests that were testing mm_3gpp_select_best_cid() are also
converted to use mm_3gpp_profile_list_find_best().
2021-04-29 10:13:22 +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 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 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 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
Andrew Lassalle 8ccd63ef64 test-sms-part-cdma: fix memory leak 2021-01-08 10:51:04 -08:00
Dylan Van Assche d531992897 tests: added parse ERROR response test 2020-12-01 20:42:55 +00:00
Dylan Van Assche c05580ca9a tests: added parse OK response test 2020-12-01 20:42:55 +00:00
Aleksander Morgado 3be07bb38d tests,cdma: test CDMA SMS with different text lengths 2020-11-20 00:40:39 +01:00
Eric Caruso 1800983b6c mm-modem-helpers: add low_nybble_first argument to mm_bcd_to_string
All BCD-encoded strings used by MM currently have the low nybble
of each byte come before the high nybble, but some strings (such
as the EID string returned by QMI Get Slot Status) are meant to
be read in order with the high nybble before the low one. As such,
extend mm_bcd_to_string to decode both.
2020-10-16 11:22:37 -07:00
Aleksander Morgado 599f545c0d sms-part-3gpp: allow sending UTF-16 as if it were UCS-2
Despite 3GPP TS 23.038 specifies that Unicode SMS messages are
encoded in UCS-2, UTF-16 encoding is commonly used instead on many
modern platforms to allow encoding code points that fall outside the
Basic Multilingual Plane (BMP), such as Emoji.

Update the logic to always use UTF-16 instead of UCS-2 when creating
or parsing PDUs (even if we always report as sending or receiving
UCS-2). For all purposes, UCS-2 is considered a subset of UTF-16
(assuming that code points out of the [U+0000,U+D7FF] and
[U+E000,U+FFFF] ranges are not applicable in UCS-2).

Fixes https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/250
2020-08-20 18:15:37 +02:00
Aleksander Morgado eb5443b197 charsets: add UTF-16BE as a possible modem charset
Just as an implementation detail to be taken as an extension of
UCS2BE, never really to be used as a real modem charset.
2020-08-20 18:13:18 +02:00
Aleksander Morgado a399c7e42a charsets: take_and_convert() methods should support GSM encoding
The iconv() operation would fail because we wouldn't give any proper
charset string to convert to/from. Use our custom GSM encoding support
instead.
2020-05-26 15:05:52 +02:00
Aleksander Morgado c994576953 charsets,test: extend UCS2->UTF-8 testing for the reverse operation 2020-05-26 15:05:52 +02:00
Aleksander Morgado 0926031119 Revert "charsets: don't warn in unlikely case of needing to convert to HEX from UTF-8"
This reverts commit 6a7dd87f30.

Reverting because the merge request was set to squash all together....
2020-05-26 15:04:20 +02:00
Giacinto Cifelli 6a7dd87f30 charsets: don't warn in unlikely case of needing to convert to HEX from UTF-8
This would really be an implementation detail, not a real use
case. Just don't warn in this case, as in the conversion in the
opposite direction.
2020-05-26 12:45:40 +00:00
Aleksander Morgado c7dee320c0 test-qcdm-serial-port: fix warnings with -Wsign-compare
test-qcdm-serial-port.c: In function 'wait_for_child':
  test-qcdm-serial-port.c:57:52: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
           if (d->child && (now.tv_sec - start.tv_sec > timeout)) {
                                                      ^
2020-05-19 13:44:23 +02:00
Aleksander Morgado 426f69d64b tests,modem-helpers: regex number is index of an array, so starts at 0 2020-04-09 12:38:50 +00:00
Aleksander Morgado 8aec9e3889 test,modem-helpers: use MMModem3gppRegistrationState values in tests 2020-04-09 12:38:50 +00:00
Aleksander Morgado c78da3de7e broadband-modem: run +C5GREG state checks
The generic CREG parser is improved to also allow parsing +C5GREG
responses and URCs.
2020-04-09 12:38:50 +00:00