Commit Graph

126 Commits

Author SHA1 Message Date
Aleksander Morgado
8722215f7e plugins: use logging module name as plugin name 2020-04-08 17:53:42 +02:00
Aleksander Morgado
e956bac47b log: common logging method definition for all testers and helpers 2020-04-08 17:53:42 +02:00
Aleksander Morgado
078c638165 telit: 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
9bcadea172 log: new object logging support
So that we can provide the specific object id in every log associated
to a given object.
2020-04-08 16:35:08 +02: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
35649aa110 telit,tests: different errors for invalid vs unmatched band combinations 2020-01-31 15:18:35 +01:00
Aleksander Morgado
5ba6a684af telit: fix warnings with -Wimplicit-fallthrough
telit/mm-broadband-modem-telit.c: In function ‘qss_setup_step’:
  telit/mm-broadband-modem-telit.c:619:22: error: this statement may fall through [-Werror=implicit-fallthrough=]
    619 |             ctx->step++;
        |             ~~~~~~~~~^~
  telit/mm-broadband-modem-telit.c:620:9: note: here
    620 |         case QSS_SETUP_STEP_QUERY:
        |         ^~~~
  telit/mm-broadband-modem-telit.c:653:22: error: this statement may fall through [-Werror=implicit-fallthrough=]
    653 |             ctx->step++;
        |             ~~~~~~~~~^~
  telit/mm-broadband-modem-telit.c:654:9: note: here
    654 |         case QSS_SETUP_STEP_LAST:
        |         ^~~~
  telit/mm-broadband-modem-telit.c: In function ‘load_unlock_retries_step’:
  telit/mm-broadband-modem-telit.c:906:22: error: this statement may fall through [-Werror=implicit-fallthrough=]
    906 |             ctx->step++;
        |             ~~~~~~~~~^~
  telit/mm-broadband-modem-telit.c:907:9: note: here
    907 |         case LOAD_UNLOCK_RETRIES_STEP_LOCK:
        |         ^~~~
2020-01-31 14:52:50 +01:00
Aleksander Morgado
7e19ed0a79 telit: fix warnings with -Wdiscarded-qualifiers
telit/mm-broadband-modem-telit.c: At top level:
  telit/mm-broadband-modem-telit.c:1184:7: error: initialization discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
   1184 |     { "#PSNT?",    3, FALSE, response_processor_psnt_ignore_at_errors },
        |       ^~~~~~~~
  telit/mm-broadband-modem-telit.c:1185:7: error: initialization discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
   1185 |     { "+SERVICE?", 3, FALSE, response_processor_service_ignore_at_errors },
        |       ^~~~~~~~~~~
2020-01-31 14:52:50 +01:00
Aleksander Morgado
26e565f6a3 telit: fix warnings with -Wswitch-default
telit/mm-broadband-modem-telit.c: In function ‘qss_setup_step’:
  telit/mm-broadband-modem-telit.c:616:5: error: switch missing default case [-Werror=switch-default]
    616 |     switch (ctx->step) {
        |     ^~~~~~
2020-01-31 14:52:50 +01:00
Aleksander Morgado
cfd5cad882 telit: fix warnings with -Wsign-compare
telit/mm-broadband-modem-telit.c: In function ‘gps_enabled_ready’:
  telit/mm-broadband-modem-telit.c:191:30: error: comparison of integer expressions of different signedness: ‘gint’ {aka ‘int’} and ‘long unsigned int’ [-Werror=sign-compare]
    191 |     if (ctx->gps_enable_step < G_N_ELEMENTS (gps_enable)) {
        |                              ^
  telit/mm-broadband-modem-telit.c: In function ‘parent_enable_location_gathering_ready’:
  telit/mm-broadband-modem-telit.c:254:43: error: comparison of integer expressions of different signedness: ‘gint’ {aka ‘int’} and ‘long unsigned int’ [-Werror=sign-compare]
    254 |     if (start_gps && ctx->gps_enable_step < G_N_ELEMENTS (gps_enable)) {
        |                                           ^
2020-01-31 14:52:50 +01:00
Aleksander Morgado
10c9ac18f7 telit: use integers to compare interface numbers 2020-01-31 14:52:50 +01:00
Aleksander Morgado
759ab6d94d telit,helpers: fix format of flags built during #BND request generation
We explicitly need 64bit values for 3G flags and 4G flags.
2020-01-31 14:52:49 +01:00
Aleksander Morgado
ee8e81e55c telit,helpers: use correct flag to check caps when building #BND request 2020-01-31 14:52:49 +01:00
Aleksander Morgado
7655f3b35c telit: fix warnings with -Wdiscarded-qualifiers
telit/tests/test-mm-modem-helpers-telit.c:48:9: error: initialization discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
     48 |         "#BND: (0-3)", TRUE, FALSE, FALSE, FALSE, 4,
        |         ^~~~~~~~~~~~~
  ...
2020-01-31 14:52:49 +01:00
Aleksander Morgado
1d1f597b55 telit: setup as loadable 'shared' utils 2019-11-27 10:11:43 +00:00
Daniele Palmas
c9e603a388 telit: add AT$GPSNMUN description 2019-11-05 15:52:31 +01:00
Krzysztof Drobinski
4a2e907e30 telit: minor coding style fix 2019-11-02 17:34:13 +01:00
Eric Caruso
c79d945073 mm-modem-helpers-telit: fix undefined bitshifts
Since this plugin uses a bitmask to represent bands, we have
to be wary of shifting outside the precision of the bitmask
storage type. In this case, it was possible to generate 1 << 31
in a signed integer type as an intermediate step of B3G_FLAG,
which is undefined behavior (and usually results in INT_MIN,
breaking comparisons with the value).

Bug was reported to the chromium tracker at crbug.com/1019301

Original patch updated by Aleksander Morgado to leave
MM_MODEM_BAND_TELIT_3G_LAST as MM_MODEM_BAND_UTRAN_19, as that is the
highest 3G band supported by the current implementation. Worth noting
that this was not a real bug as the maximum flag we would have been
setting was (1 << 19) anyway.
2019-10-31 15:36:50 +01:00
Aleksander Morgado
e0f0d62369 telit: fix crash if AT$GPSP=? is supported but no GPS data port
We would have been de-referencing a NULL GError.
2019-10-31 15:14:27 +01:00
Aleksander Morgado
5def58d327 telit: minor coding style fixes 2019-10-31 15:12:54 +01:00
Krzysztof Drobinski
eb3f17ddcc telit: Allow enabling GNSS events if NMEA port was detected 2019-10-30 17:53:22 +01:00
Krzysztof Drobinski
ef30dd800c telit: increase timeout for AT#REBOOT
It was observed that sporadically it may take more than 5 seconds for modem to
respond to AT#REBOOT. Increase the timeout on AT command to not report
unnecessary errors to the user.
2019-10-21 11:40:39 +02:00
Aleksander Morgado
d5d0ed0b24 tests: print MM logs only on verbose test mode
Therefore, avoid needing ENABLE_TEST_MESSAGE_TRACES build symbol.
2019-10-14 15:30:27 +02:00
Aleksander Morgado
be4fa661c1 plugins,telit: refactor #BND command support
And added support for several new things, including:
 * Setting "any" band now attempts to set all supported bands.
 * Added new 2G band value '5' (egsm+dcs+pcs+g850).
 * Setup support for two different 3G band combinations, a default one
   plus an alternate one applicable to the LM940/960 models only. The
   alternate combination is selected via udev tags.

During the refactor, the following Telit-specific helpers were also
removed and exchanged with more generic counterparts.
 * mm_telit_bands_contains() -> mm_common_bands_garray_lookup()
 * mm_telit_get_band_flags_from_string() -> mm_parse_uint_list()
2019-09-17 10:52:42 +02:00
Aleksander Morgado
2ecb96b6ad telit: add LE922 port type hints
P:  Vendor=1bc7 ProdID=1040 Rev=03.10
  S:  Manufacturer=Android
  S:  Product=Android
  S:  SerialNumber=2d9e48a4
  C:  #Ifs= 7 Cfg#= 1 Atr=80 MxPwr=500mA
  I:  If#=0x0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=option
  I:  If#=0x1 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=42 Prot=01 Driver=(none)
  I:  If#=0x2 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=ff Driver=qmi_wwan
  I:  If#=0x3 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
  I:  If#=0x4 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
  I:  If#=0x5 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
  I:  If#=0x6 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
2019-09-13 17:30:39 +02:00
Aleksander Morgado
edac8c37e8 telit: add port type hints for the ME910 using the correct PID 2019-09-09 12:21:11 +02:00
Aleksander Morgado
e6932c9336 Revert "telit: additional port type hints for the ME910"
This reverts commit ef89dd154b.

The PID of the ME910 is 1101, not 1011... :D
2019-09-09 12:21:11 +02:00
Aleksander Morgado
ef89dd154b telit: additional port type hints for the ME910 2019-07-13 23:21:55 +02:00
Aleksander Morgado
254da81ebd telit: loading access tech should never use cached replies 2019-05-18 16:00:19 +02:00
Daniele Palmas
c7be4af542 telit: add Telit MBIM broadband modem
Modes and band support are added through AT commands.
2019-02-28 16:09:10 +01:00
Daniele Palmas
3921c120b3 telit: move shared functions to mm-shared-telit 2019-02-28 15:42:28 +01:00
Aleksander Morgado
7d9c7e0bf4 telit: avoid using deprecated band symbols 2018-12-16 09:20:25 +01:00
Aleksander Morgado
548b7f8847 base-modem: load AT port type hints when adding port
We keep the pflags input in mm_base_modem_grab_port() so that plugins
can use other methods to gather port type hints (e.g. querying with AT
commands as in Huawei/Telit or looking at sysfs properties as in HSO).

For standard udev tag port type hints, it will be the base modem
looking them up.

Note that there is no longer any need to ignore non-flagged ports for
those modems that require primary/secondary flags. They will be
implicitly ignored when mm_base_modem_organize_ports() decides which
ports to use, as the flagged ones are preferred over the non-flagged
ones.
2018-08-10 04:19:13 +00:00
Aleksander Morgado
6b0424cfac plugins: consolidate ID_MM_PORT_TYPE_AT_* flag names
We define 3 common udev tag ids to be used by all plugins:

 * ID_MM_PORT_TYPE_AT_PRIMARY: the primary modem port. It will be used
   for AT control and also as PPP if there is no other port flagged
   explicitly to do PPP.

 * ID_MM_PORT_TYPE_AT_SECONDARY: the secondary modem port. It will be
   used when/if the primary port gets connected to do PPP.

 * ID_MM_PORT_TYPE_PPP: the port to be used to do PPP only. This tag
   makes sense only when the primary port shouldn't be used for PPP,
   i.e. when there is a port dedicated to do PPP and one port
   dedicated for control.
2018-08-10 04:19:13 +00:00
Aleksander Morgado
86f840d97b port-probe: explicitly report GPS port type if port flagged
And remove all custom logic from all plugins that were doing just that.
2018-08-10 04:19:13 +00:00
Aleksander Morgado
85adbdbdd1 plugins: consolidate ID_MM_PORT_TYPE_GPS flag name
Use the same flag name across all plugins with support for
NMEA-capable TTYs.
2018-08-10 04:19:13 +00:00
Aleksander Morgado
c07382a486 udev: add tags also on bind action
When a new USB device is hotplugged, e.g. a USB<->RS232 converter that
exposes a single ttyUSB0, these udev events happen:

  add  /devices/pci0000:00/0000:00:14.0/usb2/2-1 (usb/usb-device)
  add  /devices/pci0000:00/0000:00:14.0/usb2/2-1/2-1:1.0 (usb/usb-interface)
  add  /devices/pci0000:00/0000:00:14.0/usb2/2-1/2-1:1.0/ttyUSB0 (usb-serial)
  add  /devices/pci0000:00/0000:00:14.0/usb2/2-1/2-1:1.0/ttyUSB0/tty/ttyUSB0 (tty)
  bind /devices/pci0000:00/0000:00:14.0/usb2/2-1/2-1:1.0/ttyUSB0 (usb-serial)
  bind /devices/pci0000:00/0000:00:14.0/usb2/2-1/2-1:1.0 (usb/usb-interface)
  bind /devices/pci0000:00/0000:00:14.0/usb2/2-1 (usb/usb-device)

Our udev rules in MM only added tags in the 'add' events, and it looks
like the only ones 'persistent' after this sequence are those of the
last event happening on the specific path.

This meant that all TTY subsystem rules (e.g. ID_MM_CANDIDATE) would
be stored for later check (e.g. if ModemManager is started after these
rules have been applied), which was ok. "udevadm info -p ..." would
show these tags correctly always.

But this also meant that the 'bind' udev event happening for the USB
device didn't get any of our device-specific tags, and so we would be
missing them (e.g. ID_MM_DEVICE_MANUAL_SCAN_ONLY) if MM is started
after the last event has happened. "udevadm info -p ..." would
not show these tags.

Modify all our rules to also run at the 'bind' events.

See, for context:
  https://github.com/systemd/systemd/issues/8221
2018-06-02 16:54:37 +02:00
Ville Skyttä
90b89bb9f4 *: Spelling fixes 2018-01-25 09:52:12 +01:00
Aleksander Morgado
d8c7251687 telit: use parent logic to load unlock retries
The generic broadband modem provides a common method to load unlock
retries based on CSIM queries. We modify the Telit plugin to use the
generic method but keeping the CSIM locking/unlocking logic in place.
2018-01-06 18:51:53 +01:00
Colin Helliwell
8f26848ef0 helpers: move generic load_unlock_retries from Telit plugin
As a precursor to a generic load_unlock_retries method, move the
CSIM Response parser from the Telit plugin into the core code.
2018-01-01 18:37:10 +01:00
Eric Caruso
c44b928206 mm-iface-modem: add check_for_sim_swap method and enable steps
When in low-power mode, some modems will not dispatch unsolicited
notifications, such as for SIM hot swapping. There is code in
MMBroadbandModemTelit to handle this by checking the SIM identifier
during modem power up against the identifier cached in the SIM
D-Bus object. If they're different, the SIM has likely been
swapped while we were powered down.

We can move this code out to MMBroadbandModem because it doesn't
actually rely on any Telit-specific details, and invoke it from
MMIfaceModem via a new method.
2017-12-18 10:16:18 +01:00
Aleksander Morgado
44a850f8ad telit: update frequency bands support
Updated to use the non-deprecated MMModemBand values.

Also, use explicit enums for 2G/3G bands when building internal flags,
as relying on UTRAN band 7 (MM_MODEM_BAND_U2600) being greater than
UTRAN bands 8 and 9 is a MM implementation issue.
2017-09-07 10:55:17 +02:00
Aleksander Morgado
530ebf9063 telit: reorder code to keep the bottom-top flow for async methods 2017-09-04 17:59:59 +02:00
Aleksander Morgado
ada9934e90 telit: explicitly flag as const the constant string 2017-09-04 17:59:59 +02:00
Aleksander Morgado
f6ae514405 telit: plug memleak when SIM object cannot be acquired
The GTask wasn't being disposed.
2017-09-04 17:59:59 +02:00
Aleksander Morgado
be079381c0 telit: avoid leaking SIM object
We were getting the SIM object for all paths, but only using (and
disposing it) in the AFTER_POWER_UP_STEP_GET_SIM_IDENTIFIER step.

Update the logic to only retrieve, use and dispose the SIM object in
the step that is needed, and therefore avoid leaking it in the
remaining steps.
2017-09-04 17:59:59 +02:00
Carlo Lobrano
76916de313 telit-plugin: handle QSS unsolicited due to power state transitions
When transitioning between power-low and power-on modes, Telit modems
switch the SIM off/on, which leads to the emission of #QSS unsolicited not
related to actual SIM swaps.

To handle this #QSS unsolicited, this patch:

* disables reacting on #QSS unsolicited when modem_power_down is received
* implements modem_after_power_up that:
    - checks whether the SIM has been changed, matching cached SIM
      Identifier with the value in the current SIM. If SIM Identifier,
      is different, sim hot swap ports detected is called.
    - re-enables reacting on #QSS unsolicited
2017-09-04 17:59:59 +02:00
Carlo Lobrano
b5dba9ad1c telit-plugin: ignore QSS when SIM-ME interface is locked
With some modems, the lock/unlock of the SIM-ME interface with +CSIM=1/0
command is followed by #QSS unsolicited messages. With the current
implementation, this messages are mistaken for SIM swap events and so the
modem is first dropped and then re-probed.

With this patch, the plugin takes into account the SIM-ME lock state when
parsing #QSS unsolicited, so that the QSS handler can correctly
elaborate the messages that are not related to SIM swap events.
2017-08-01 10:11:12 +02:00
Carlo Lobrano
9cdc237241 sim hot swap: improved error management
Currently, when SIM hot swap fails in either mm-iface or plugin, the
ModemManager still opens ports context and prints a message saying that
SIM hot swap is supported and that it's waiting for SIM insertion,
instead of clearly saying that SIM hot swap is not working.

This patch:

1. introduces a new property MM_IFACE_MODEM_SIM_HOT_SWAP_CONFIGURED
   which is FALSE by default and set to TRUE only when
   setup_sim_hot_swap_finish() succeded.
2. subordinates the completion of SIM hot swap setup (in
   mm-broadband-modem) and the related messages to the the value of
   MM_IFACE_MODEM_SIM_HOT_SWAP_CONFIGURED

Finally, this patch replaces the MBIM's sim_hot_swap_on private property
with the new property MM_IFACE_MODEM_SIM_HOT_SWAP_CONFIGURED, since they have the
same meaning.
2017-08-01 10:02:01 +02:00