Commit Graph

45 Commits

Author SHA1 Message Date
Aleksander Morgado
ccf16e00a7 ublox,helpers: avoid cast-align errors
We can safely cast the data in a GArray to gpointer first, and then
to the pointer type we require.

  ublox/mm-modem-helpers-ublox.c: In function 'parse_bands_from_string':
  ublox/mm-modem-helpers-ublox.c:1612:48: error: cast increases required alignment of target type [-Werror=cast-align]
           tmpstr = mm_common_build_bands_string ((MMModemBand *)(bands->data), bands->len);
                                                  ^
2020-05-19 13:44:23 +02:00
Aleksander Morgado
ccd0f6de5a ublox: port to use object logging 2020-04-08 16:35:10 +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
20c5d7fd92 ublox: return error when no bands are parsed
If load_current_bands_finish() returns a NULL GArray, we must set the
GError or otherwise the daemon will segfault when the caller
dereferences the GError:

    current_bands = MM_IFACE_MODEM_GET_INTERFACE (self)->load_current_bands_finish (self, res, &error);
    if (!current_bands) {
        /* Errors when getting current bands won't be critical */
        mm_warn ("couldn't load current Bands: '%s'", error->message);
        g_error_free (error);
    }

This may happen with an empty but balid +UACT response, e.g.:
   AT+UACT?
   +UACT: ,,,
   OK

Or when it replies a full empty string:
   AT+UACT?
   OK
2019-06-13 10:26:53 +02:00
Ben Chan
43d454ab7f ublox: fix out-of-bounds array accesses
This patch fixes several invalid checks like this:

   array[i] && i < G_N_ELEMENTS (array)

which should instead be:

   i < G_N_ELEMENTS (array) && array[i]

to avoid an out-of-bounds access of the array.

Fixes: c1aa658802
2019-03-29 13:34:10 -07:00
Aleksander Morgado
0944e59252 ublox: parse +UGCNTRD stats as unsigned 64bit values
[1551646332.583651] (ttyACM2): --> 'AT+UGCNTRD<CR>'
  [1551646332.626567] (ttyACM2): <-- '<CR><LF>+UGCNTRD: 1,0,0,0,0<CR><LF><CR><LF>+UGCNTRD: 2,1397316870,113728263578,1397316870,113728263578<CR><LF><CR><LF>OK<CR><LF>'
  [1551646332.627120] Reloading stats failed: Couldn't load primary PDP context 2 statistics: Error parsing session RX bytes
2019-03-29 10:07:29 +00:00
Aleksander Morgado
0f6f89801e ublox: fix parser to report only bands supported by the module
We were filtering the 4G bands supported by the module when parsing
+UBANDSEL responses, e.g. so that we would not reply unsupported bands
for a given ubandsel value.

But we need the same filtering in 2G and 3G bands, because for example
some modules may support a specific 4G band with a given ubandsel
value, but NOT the associated 3G band. E.g. the TOBY-R200 supports
EUTRAN-4 but not UTRAN-4.
2019-01-30 12:10:03 +01:00
Aleksander Morgado
74bdc97b34 ublox: use fixed array sizes when iterating 2019-01-30 12:10:03 +01:00
Aleksander Morgado
8b9053822b ublox: fix loop looking for a specific 4g band value
We cannot have the ubandsel value comparision inside the for(;;) stop
conditions, because that would mean the loop would stop whenever the
comparison fails. We want to look for a value, so we need to loop the
whole array and stop once we find it only.
2019-01-30 12:10:03 +01:00
Aleksander Morgado
36b5e1ee20 ublox: the whole list of supported bands is known
So, assert() if for any reason we're asking to use a band that we
don't find in the list.
2019-01-30 12:10:03 +01:00
Aleksander Morgado
fec1c43f80 ublox: don't create array with totally unrelated size 2019-01-30 12:10:03 +01:00
Aleksander Morgado
de5b9e441f ublox: coding style fixes 2019-01-30 12:10:03 +01:00
Aleksander Morgado
437fb830c8 ublox,helpers: assume all SARA/LARA devices require COPS 2019-01-30 12:10:03 +01:00
Aleksander Morgado
d12b919787 ublox,helpers: fix missing ubandsel support initializations 2019-01-30 12:10:03 +01:00
Aleksander Morgado
b1d69a69f9 ublox,helpers: rename enum
We're not going to use CFUN/COPS just for bands, but also for modes,
so use more generic names.
2019-01-30 12:10:03 +01:00
Aleksander Morgado
c3f4fe063f ublox: rework support config loading
Make mm_ublox_get_support_config() return FALSE only when GError is
set. And also, prepare a preload_support_config() method to be run
before using any information from the support configuration (i.e.
don't do it in load_supported_bands(), do it in load_current_bands()
or in set_current_bands().
2019-01-30 12:10:03 +01:00
Aleksander Morgado
421b5e48e0 ublox,helpers: remove unused variable
ublox/mm-modem-helpers-ublox.c:1291:14: error: unused variable ‘found’ [-Werror=unused-variable]
         gboolean found;
                  ^~~~~
2019-01-30 12:10:03 +01:00
Aleksander Morgado
3575fe3528 ublox,helpers: fix mixed declarations and code
ublox/mm-modem-helpers-ublox.c:1298:5: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
       guint i, j, k;
       ^~~~~
2019-01-30 12:10:03 +01:00
Aleksander Morgado
bbb96cd3f9 ublox: minor indentation fixes 2019-01-30 12:10:03 +01:00
Mark-Jablonsky
c1aa658802 ublox: add band detection support for additional modems
The u-blox plugin was originally written to support the TOBY-L4 only.
This caused issues with mmcli reporting the correct supported and
current bands because the logic was based only for the TOBY-L4 and
the AT commands used in the implementaion are only supported by
a couple of modems.

There is now a hard-coded modem list that contains the supported bands
and the supported modes. A hard-coded list was chosen over a logic
based list because ublox modems only report the frequency of the bands
they support in the current mode they are in. For further justification,
the reported frequency could relate to multiple bands that are not all
supported by the modem, and not all the supported bands are always caught
depending on the mode the modem is in (e.g. 2G, 3G, 4G). The only
realiable way to retrieve the correct supported bands is to have the list
hard-coded. Based off of the modem, the code chooses whether it is
appropriate to issue +UACT or +UBANDSEL to retrieve the current bands list.
Additionally, the appropriate AT command of +CFUN=4 or +COPS=2 is chosen
to detach from the network when the mmcli --set-current-bands command is
issued. The new setup also adds a header file that contains the modem list.
This should make adding support for future additional modems easier as long
as future modems stick to the same AT command interface that is currently
supported by the plugin.
2019-01-30 12:10:03 +01:00
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
7e94928301 ublox: fix 'any' mode building
The 'any' mode refers to the mode which includes most access
technologies and where none of them is preferred.

Fix the logic so that all combinations with one technology preferred
over the others are ignored, instead of the other way around.

Fixes assertion with the 4G-only LARA R204.

    ModemManager[424]: <debug> [-192499452.090358] (ttyACM0): --> 'AT+URAT=?<CR>'
    ModemManager[424]: <debug> [-192499452.092150] (ttyACM0): <-- '<CR><LF>+URAT: (3)<CR><LF><CR><LF>OK<CR><LF>'
    **
    ERROR:ublox/mm-modem-helpers-ublox.c:817:mm_ublox_get_modem_mode_any: assertion failed: (any != MM_MODEM_MODE_NONE)

Reported-by: Matthew Starr <mstarr@hedonline.com>
2018-04-03 15:58:49 +02:00
Aleksander Morgado
bda7b9a74a ublox: plug memleak when parsing UAUTHREQ test 2017-09-26 13:45:17 +02:00
Aleksander Morgado
b774e58dd0 ublox: new +UAUTHREQ=? tester 2017-09-15 10:31:21 -07:00
Aleksander Morgado
a0768a13f6 ublox: new AT+UACT=X command builder 2017-09-15 10:31:21 -07:00
Aleksander Morgado
826c5ad74a ublox: new AT+UACT=? test parser 2017-09-15 10:31:21 -07:00
Aleksander Morgado
dbb8f7235d ublox: new AT+UACT? response parser 2017-09-15 10:31:21 -07:00
Aleksander Morgado
55316cabd4 ublox: update frequency bands support
Updated to use the non-deprecated MMModemBand values.
2017-09-07 10:55: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
Ben Chan
c8ec731043 ublox: fix uninitialized variable issue
This patch fixes an uninitialized variable issue in
mm_ublox_parse_ugcntrd_response_for_cid(), which uses an uninitialized
`match_info' when `in_cid' is invalid.
2017-01-24 11:07:51 +01:00
Aleksander Morgado
e64b964e8e ublox: implement connection statistics loading
The implementation uses +UGCNTRD=? to query whether the per-PDP context
statistics are supported by the device, and if they are, +UGCNTRD is used to
query them.

We only process the statistics for the specific CID we're using.
2016-10-12 13:24:09 +02:00
Aleksander Morgado
e6e53467ee ublox: new +UGCNTRD? response parser
The parser returns only the results for the CID being specified as input. This
is so that we can just query the statistics of the CID currently in use by the
bearer.
2016-10-12 13:24:09 +02:00
Aleksander Morgado
1c69a847ae ublox: new +UBANDSEL=X command builder 2016-10-12 13:24:09 +02:00
Aleksander Morgado
09c9ca5749 ublox: new +UBANDSEL? response parser 2016-10-12 13:24:09 +02:00
Aleksander Morgado
4632836d40 ublox: implement supported bands loading 2016-10-12 13:24:09 +02:00
Aleksander Morgado
29517c99ba ublox: new +UPINCNT response parser 2016-10-12 13:24:08 +02:00
Aleksander Morgado
7cb11f72cd ublox: implement current modes setting and modem power up/down/off/reset
Changing current allowed/preferred modes requires the device to be in low-power
mode, so we will make sure we return an error if any power operation is already
ongoing when a new one is requested.
2016-10-12 11:29:52 +02:00
Aleksander Morgado
9d78f05cbd ublox: new +URAT=X command builder 2016-10-12 11:29:52 +02:00
Aleksander Morgado
151d608eec ublox: new u-blox specific +CFUN? response parser 2016-10-12 11:29:52 +02:00
Aleksander Morgado
bde9c4795a ublox: new +URAT? response parser 2016-10-12 11:29:52 +02:00
Aleksander Morgado
29ace8b120 ublox: implement supported modes loading
AT+URAT=? provides the format expected, but looks like it isn't implemented
differently for the different u-blox devices seen, so we need an additional
level of filtering which currently is applied per device model string.
2016-10-12 11:29:52 +02:00
Aleksander Morgado
a4466e83b7 ublox: new +URAT=? response parser 2016-10-12 11:29:52 +02:00
Aleksander Morgado
81715ee591 ublox: new +UIPADDR=N response parser 2016-10-12 11:29:52 +02:00
Aleksander Morgado
9d2c2a75cc ublox: new 'AT+UBMCONF?' response parser 2016-10-12 11:29:51 +02:00
Aleksander Morgado
241b63304b ublox: new 'AT+UUSBCONF?' response parser 2016-10-12 11:29:51 +02:00