Commit Graph

136 Commits

Author SHA1 Message Date
Aleksander Morgado
dec53d6ef6 modem-helpers: allow unquoted strings in +CCLK responses
Also:
  * define the leading '+' as a escaped value
  * allow any number of spaces between '+CCLK' and the string value.
2017-08-09 21:59:31 +02:00
Aleksander Morgado
4db3ccf2af helpers: +CNUM parser doesn't return any error 2017-07-19 11:21:27 +02:00
Ben Chan
94a289a1b3 modem-helpers: minor coding style fixes 2017-07-14 10:59:46 +02:00
Daniele Palmas
5820666495 helpers: extend +WS46=? response parser to support ranges
Telit LTE modems could reply to +WS46=? with:

+WS46: (12,22,25,28-31)

This patch extends +WS46=? response parser to support ranges.
2017-06-16 15:48:18 +02:00
Ben Chan
75e8527987 helpers: remove unnecessary `>= 0' checks on guint value
This CL removes the unnecessary `>= 0' check on `mode_val' and
`ind_val', which are both guint values extracted from a GArray with
guint values, in mm_3gpp_parse_cmer_test_response to address the
following compiler warnings:

mm-modem-helpers.c:2933:22: error: comparison of unsigned expression >=
0 is always true [-Werror,-Wtautological-compare]
        if (mode_val >= 0 && mode_val <= 3)
            ~~~~~~~~ ^  ~
mm-modem-helpers.c:2943:21: error: comparison of unsigned expression >=
0 is always true [-Werror,-Wtautological-compare]
        if (ind_val >= 0 && ind_val <= 2)
            ~~~~~~~ ^  ~
2017-06-07 09:17:15 +02:00
Aleksander Morgado
e753911a4e helpers: new 'AT+CMER=?' parser 2017-05-29 14:56:54 +02:00
Aleksander Morgado
973c7d0970 helpers: new parser for AT+IFC=?
Instead of having the parser return separate list of supported flow
controls for TE and TA, we simplify it by only returning those
settings that apply to both TE and TA.

This logic isn't perfect either, though, as some settings (e.g. '3' in
TE in some modems, specifying a different XON/XOFF behavior) may not
have a corresponding setting in the other end.

The most common cases we care about (i.e. standard XON/XOFF, RTS/CTS)
should be properly reported with this logic.
2017-04-18 18:08:57 +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
Aleksander Morgado
f824602bdd modem-helpers: if operator not in UCS2, see if already valid UTF-8
The method doing the operator name normalization takes as input the
current configured modem charset. If this is UCS2, we will now just
assume this is a hint: the string may or may not come in hex/UCS2.

This logic makes the custom operator name loading in Huawei unneeded,
if the modem is configured in UCS2, we still properly process operator
names coming in plain ASCII.
2017-04-02 10:06:07 +02:00
Aleksander Morgado
1600911439 broadband-modem,helpers: implement AT+WS46=? response parser
We want a parser that returns the full list of combinations found.
2017-03-24 21:28:34 +01:00
Aleksander Morgado
51e3d3d837 modem-helpers: improve +CCLK parsing
Added support for 4-digit format years (i.e. YYYY), and also made the
timezone information optional, as per +CSDF in 3GPP TS 27.007.

https://bugs.freedesktop.org/show_bug.cgi?id=95319
2016-11-18 10:25:07 +01:00
Aleksander Morgado
5a9f093839 modem-helpers: implement less strict APN comparison
u-blox modems will append a string showing the MCC and MNC info to the access
point name listed in AT+CGDCONT? responses. We will try to detect when that
happens, and we just accept the match.

The logic doesn't just look for a string prefix; it also looks for the special
MCC + MNC suffix, which is much more restrictive, to try to avoid false
positives.
2016-10-12 13:24:09 +02:00
Aleksander Morgado
7ab3d3e727 modem-helpers: new helper to parse +CESQ response into MMSignal objects 2016-10-12 13:24:08 +02:00
Aleksander Morgado
df6f6d1f37 modem-helpers: new +CESQ response parser 2016-10-12 13:24:08 +02:00
Aleksander Morgado
fe460b2f54 3gpp: update registration state enumeration with CSFB related states
Introduce "sms only" and "CSFB not preferred" home/roaming states to be reported
for the CS context, while already registered on LTE.

Based on 3GPP TS 27.007 v13.5.0.
2016-10-12 13:24:08 +02:00
Aleksander Morgado
aca6bb1c02 modem-helpers: new +CFUN? response parser 2016-10-12 11:29:52 +02:00
Aleksander Morgado
3a886d848d modem-helpers: new uint list parser, including interval support 2016-10-12 11:29:52 +02:00
Aleksander Morgado
61fbab286c modem-helpers: new CGACT? response parser 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
Aleksander Morgado
654f718b06 modem-helpers: new +CGCONTRDP=N response parser 2016-10-12 11:29:52 +02:00
Dan Williams
03a6d969ab broadband-modem-huawei: implement Modem.Signal extended signal info interface
Implement the detailed signal info interface for some Huawei 3GPP modems
including those based on HiSilicon chipsets like the E3276.  Known not to
work on many Qualcomm-based Huawei modems like E392, E397, and E367 as
they don't support the ^HCSQ command, but they do support QMI and so
have access to the extended signal interface via QMI.
2016-08-31 09:43:32 -05:00
Dan Williams
0a9cbf65ea modem-helpers: fix handling split PDP context ID reporting in CGDCONT=? response
Cinterion PHS8-US devices send split PDP context ID like "(1-17,101-112)" and
that caused the modem-helpers to choke.
2016-03-15 10:34:28 -05:00
Carlo Lobrano
be317e8b80 broadband-modem: fix +CPMS empty parameter support
* Add new async virtual method init_current_storages to
  MMIfaceModemMessaging
* Add logic of init_current_storages to MMBroadbandModem
* Add step "INIT_CURRENT_STORAGES" in MMIfaceModemMessaging
  initialization in order to load and store current SMS
  storages for mem1 and mem2.
* Add usage of current sms storage value for mem1 in place
  of an empty string parameter when the command AT+CPMS
  is used.

https://bugs.freedesktop.org/show_bug.cgi?id=93135
2016-03-09 14:43:08 +01:00
Aleksander Morgado
7c2d5b1aa3 helpers: fix check for pid when creating device identifier
https://bugs.freedesktop.org/show_bug.cgi?id=94364
2016-03-02 17:09:33 +01:00
Aleksander Morgado
cffba7e0ee modem-helpers: regex creation should never fail
We should really consider errors if we expect that the regex string may not
compile; but in this case the pattern is fixed, so should never happen.
2016-02-13 14:33:12 +01:00
Thomas Sailer
95876c6f57 helpers: move +CRSM parsing to mm_3gpp_parse_crsm_response
Also added test cases.

Signed-off-by: Thomas Sailer <t.sailer@alumni.ethz.ch>
2016-02-13 14:27:51 +01:00
Thomas Sailer
a33615d6cb helpers: allow optional quotes in +CREG: <stat>,"<lac>","<ci>"
GSM 07.07 CREG=2 unsolicited pattern.

Added testcase for Thuraya XT.

Signed-off-by: Thomas Sailer <t.sailer@alumni.ethz.ch>
2016-02-13 14:24:54 +01:00
Thomas Sailer
4442173dcf modem-helpers: allow optional whitespace in +CGDCONT response
Add testcase for Thuraya XT.

Signed-off-by: Thomas Sailer <t.sailer@alumni.ethz.ch>
2016-02-11 15:34:25 +01:00
Aleksander Morgado
0ebf6d5da5 mbm: query supported modes to the modem with +CFUN=?
We were trying to load the generic modes supported reported by either *CNTI=2 or
AT+WS46=?, so that then we could filter out the MBM-specific modes unsupported.

But, this may not be ideal, as both these two commands may fail:

    [mm-broadband-modem.c:1612] modem_load_supported_modes(): loading supported modes...
    [mm-port-serial.c:1237] mm_port_serial_open(): (ttyACM1) device open count is 3 (open)
    [mm-port-serial.c:1294] _close_internal(): (ttyACM1) device open count is 2 (close)
    [mm-port-serial-at.c:440] debug_log(): (ttyACM1): --> 'AT*CNTI=2<CR>'
    [mm-port-serial-at.c:440] debug_log(): (ttyACM1): <-- '<CR><LF>ERROR<CR><LF>'
    [mm-serial-parsers.c:364] mm_serial_parser_v1_parse(): Got failure code 100: Unknown error
    [mm-broadband-modem.c:1546] supported_modes_cnti_ready(): Generic query of supported 3GPP networks with *CNTI failed: 'Unknown error'
    [mm-port-serial.c:1237] mm_port_serial_open(): (ttyACM1) device open count is 3 (open)
    [mm-port-serial.c:1294] _close_internal(): (ttyACM1) device open count is 2 (close)
    [mm-port-serial-at.c:440] debug_log(): (ttyACM1): --> 'AT+WS46=?<CR>'
    [mm-port-serial-at.c:440] debug_log(): (ttyACM1): <-- '<CR><LF>ERROR<CR><LF>'
    [mm-serial-parsers.c:364] mm_serial_parser_v1_parse(): Got failure code 100: Unknown error
    [mm-broadband-modem.c:1494] supported_modes_ws46_test_ready(): Generic query of supported 3GPP networks with WS46=? failed: 'Unknown error'
    [mm-iface-modem.c:3974] load_supported_modes_ready(): couldn't load Supported Modes: 'Couldn't retrieve supported modes'

Instead, we'll ask the modem for the list of modes supported, and return that
directly.
2016-01-10 17:46:12 +01:00
Aleksander Morgado
508a37a891 modem-helpers: fix parsing CPMS=? responses without groups
The CPMS test parser was expecting 3 groups (parenthesis enclosed lists) of
memory IDs, e.g.:

   +CPMS: ("SM","ME"),("SM","ME"),("SM","ME")

But some modems like the Huawei MU609 may just report single elements, not
groups, e.g.:

   +CPMS: "SM","SM","SM"

This patch avoids using g_strsplit() to split the groups, as that is unaware
of the possible replies without groups. Instead, a new helper method is
implemented which does the group/item split itself, considering also the
possibility of a reply with mixed groups and non-groups, like e.g.:

   +CPMS: ("SM","ME"),"SM","SM"

Additionally, we also now support the case where the groups are empty, e.g.:

   +CPMS: (),(),()

https://bugs.freedesktop.org/show_bug.cgi?id=92243
2015-12-02 22:34:37 +01:00
Nick Stevens
eaf65ed98d core: process SMS +CGMR response with regex
Variability in the response style from certain modems causes the parsing
of the +CGMR response to fail. For example, the Telit HE910 inserts an
empty string ("") in the second field of the response, causing the
sscanf implementation to fail.

This patch converts the parsing of the CGMR response to a regex that
allows for more flexibility and robustness, and adds unit tests around
the parsing call.

Signed-off-by: Nick Stevens <Nick.Stevens@digi.com>
2015-09-22 09:24:18 +02:00
Aleksander Morgado
9f3801df3f core,voice: remove explicit "NO CARRIER" response matching
This response is already managed by the generic AT serial port and translates
it into a proper error. This change also avoids the Call.Start() call to report
a timeout in the serial port, instead we get a proper no-carrier error.

Before:

    $ sudo mmcli -m 0 --voice-create-call="number=12345678"
    Successfully created new call:
	    /org/freedesktop/ModemManager1/Call/1 outgoing (unknown)
    $ sudo mmcli -o 1 --start
    error: couldn't start the call: 'GDBus.Error:org.freedesktop.ModemManager1.Error.Serial.ResponseTimeout: Serial command timed out'

After:

    $ sudo mmcli -m 0 --voice-create-call="number=12345678"
    Successfully created new call:
	    /org/freedesktop/ModemManager1/Call/1 outgoing (unknown)
    $ sudo mmcli -o 1 --start
    error: couldn't start the call: 'GDBus.Error:org.freedesktop.ModemManager1.Error.Connection.NoCarrier: No carrier'
2015-08-02 10:39:48 +02:00
Marco Bascetta
bf416045df huawei: acquire incoming DTMF on active call 2015-08-02 10:39:47 +02:00
Marco Bascetta
65a64c9248 core: set number of incoming call 2015-08-02 10:39:47 +02:00
Marco Bascetta
6d85146bba core: handle incoming calls (RING/CRING, CLIP, NO CARRIER). 2015-08-02 10:39:13 +02:00
Riccardo Vangelisti
5c446c3f43 broadband-modem: added voice call support 2015-08-02 10:39:12 +02:00
Jason Simmons
3ad64c8f5a broadband-modem: default implementation of the network time interface
Add a default implementation that queries the real-time clock using the
AT+CCLK? command.  Also set AT+CTZU=1 in case a modem requires it.
2015-03-23 11:31:32 +01:00
Aleksander Morgado
60cd66b4fa helpers: avoid segfault when empty pdp type string is given
https://bugzilla.redhat.com/show_bug.cgi?id=1183250
2015-01-29 21:28:52 +01:00
Aleksander Morgado
98f21ec195 modem-helpers: fix IP4 -> IPV4
Stupid me, introduced a bug when manually writing the previous patch.

:/
2014-10-30 00:08:51 +01:00
Oskar Enoksson
01bd5006f5 modem-helpers: handle "IPV4" pdp type response
My modem (Samsung GI B3740) responded "IPV4" to "CGDCONT=?". This was
not handled in mm-modem-helpers.c. The obvious fix was to return
MM_BEARER_IP_FAMILY_IPV4.
2014-10-29 23:13:22 +01:00
Aleksander Morgado
e0f3716d26 modem-helpers: don't return any result if an error happens when parsing CPMS=?
We shouldn't rely on the caller to cleanup intermediate results when returning
an error.
2014-06-27 09:20:40 +02:00
Aleksander Morgado
4406b1e6ec modem-helpers: improve +CMTI indication regex
Allow whitespaces added in several places, like between the comma and the index,
which is what the Cinterion PHS8 does:
  <CR><LF>+CMTI: "MT", 5<CR><LF>
2014-06-25 17:40:06 +02:00
Ben Chan
37b0402ee5 core: minor coding style fixes 2014-05-20 09:32:29 +02:00
Ben Chan
31a19c2299 broadband-modem,modem-helpers: improve +CGDCONT? error handling
This patch fixes the following crash, which happens when
MMBroadbandBearer tries to parse the NULL response of a failed +CGDCONT?
query. It also fixes a leak in parse_pdp_list where it fails to free the
GError object return by mm_3gpp_parse_cgdcont_read_response.

Thread 0 *CRASHED* ( SIGSEGV @ 0x00000000 )

0x7feb15564c11   [ModemManager]            - mm-modem-helpers.c:850      mm_3gpp_parse_cgdcont_read_response
0x7feb15518e51   [ModemManager]            - mm-broadband-bearer.c:927   parse_pdp_list
0x7feb1551ada2   [ModemManager]            - mm-base-modem-at.c:189      at_sequence_parse_response
0x7feb151d4b86   [libgio-2.0.so.0.3400.3]  - gsimpleasyncresult.c:775    g_simple_async_result_complete
0x7feb1556e223   [ModemManager]            - mm-port-serial-at.c:355     serial_command_ready
0x7feb151d4b86   [libgio-2.0.so.0.3400.3]  - gsimpleasyncresult.c:775    g_simple_async_result_complete
0x7feb1556a834   [ModemManager]            - mm-port-serial.c:141        command_context_complete_and_free
0x7feb1556bc26   [ModemManager]            - mm-port-serial.c:734        port_serial_got_response
0x7feb1556c51a   [ModemManager]            - mm-port-serial.c:758        port_serial_timed_out
0x7feb1508cc33   [libglib-2.0.so.0.3400.3] - gmain.c:4026                g_timeout_dispatch
0x7feb1508c087   [libglib-2.0.so.0.3400.3] - gmain.c:2715                g_main_context_dispatch
0x7feb1508c437   [libglib-2.0.so.0.3400.3] - gmain.c:3290                g_main_context_iterate
0x7feb1508c891   [libglib-2.0.so.0.3400.3] - gmain.c:3484                g_main_loop_run
0x7feb1550ad16   [ModemManager]            - main.c:154                  main
0x7feb14a9e9c6   [libc-2.15.so]            - libc-start.c:234            __libc_start_main
0x7feb1550a808   [ModemManager             + 0x00023808
2014-03-14 08:31:32 +01:00
Ben Chan
c28ff0d547 modem-helpers: recognize "3G" as UMTS access technology
Some modems (e.g. ZTE MF190) report UMTS access technology as "3G":

  --> 'AT+ZPAS?<CR>'
  <-- '<CR><LF>+ZPAS: "3G","CS_PS"<CR><LF><CR><LF>OK<CR><LF>'
2014-01-29 10:15:17 -06:00
Aleksander Morgado
1b3114a0f9 modem-helpers: handle +CGDCONT=? replies with single context
https://bugzilla.gnome.org/show_bug.cgi?id=708983
2013-11-01 15:50:12 +01:00
Ben Chan
b5ef861d12 modem-helpers,sim: auto-detect if ICCID response is character swapped
This patch modifies mm_3gpp_parse_iccid() to auto-detect if an ICCID
response is character swapped or not by comparsing the major industry
identifier part of the ICCID response to the known value (89) for
telecommunication purposes. This addresses the issue where the same AT
command (e.g. AT^ICCID used by the huawei plugin) does not report ICCID
in a consistent format.
2013-09-26 20:23:51 +02:00
Dan Williams
11a7e3dfdf core: add helper for parsing and validating the ICCID 2013-09-10 09:42:36 +02:00
Ben Chan
ffac6f17b5 modem-helpers: fix parsing of CREG/CGREG/CEREG responses
The format of CREG/CGREG/CEREG responses is not very precisely defined
in or strictly enforced by the 3GPP specifications. That leads to the
fact that some modems put leading zeros in integer type fields (e.g.
<n>, <stat>, <AcT>), and not all modems put double quotes around string
type fields (e.g. <lac>, <ci>) in those C*REG responses.

For example, 0001 can be a valid value for both <stat> and <lac>. The
original C*REG parsing code in ModemManager could potentially interpret
'+CREG: <stat>,<lac>,<ci>,<AcT>' as '+CREG: <n>,<stat>,<lac>,<ci>'. This
patch addresses this issue by refining the regular expressions returned
by mm_3gpp_creg_regex_get() with the following assumptions:

1. If a modem puts leading zeros in integer type fields, it puts double
   quotes around string type fields.
2. If a modem omits double quotes around string type fields, it does not
   put leading zeros in integer type fields.
2013-08-06 16:14:35 -05:00
Aleksander Morgado
700ebc5c07 api,introspection: rename 'ModemCapabilities' to 'SupportedCapabilities'
And also make it a list of masks, specifying which are the specific combinations
supported, not just one mask with all.

E.g.:
  -------------------------
  Hardware |   manufacturer: 'Sierra Wireless, Incorporated'
           |          model: 'MC7710'
           |       revision: 'SWI9200X_03.05.19.04ap r5475 carmd-en-10527 2012/09/17 17:57:14'
           |      supported: 'gsm-umts
           |                  gsm-umts, lte'
           |        current: 'gsm-umts, lte'
           |   equipment id: '358178040668164'
2013-06-05 19:15:15 +02:00