Commit Graph

41 Commits

Author SHA1 Message Date
Aleksander Morgado
064e92e9b7 api,simple: new 'multiplex' setting in bearer properties
Both the Simple.Connect() and Modem.CreateBearer() are updated to
allow a new 'multiplex' setting in the properties provided by the user
in both of these methods.

The new setting expects a MMBearerMultiplexSupport enum indicating
what kind of multiplex needs the user has:
 * none: if multiplex must not be used.
 * requested: if multiplex should be used if available.
 * required: if multiplex must be used.

The underlying implementations will take care of accepting or
rejecting the setting depending on the system and modem capabilities.
2021-03-10 10:59:19 +01:00
Teijo Kinnunen
0919abaa2f mmcli,sim: implement --sim-set-preferred-networks function 2021-03-09 08:52:55 +02: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
6d8610d63e libmm-glib,common-helpers: ishexstr() fails on empty input string 2021-02-23 11:35:11 +00:00
Aleksander Morgado
8c30a6b6f8 libmm-glib,common-helpers: hexstr2bin fails on empty input string
Also, remove the trailing NUL byte that was appended to the output
binary stream, as it's not needed in any case.
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
8bf1329481 libmm-glib,helpers: use locale-independent strtod()
Otherwise parsing may fail, e.g. as in this unit test:

  # Start of smoni tests
  # DEBUG: testing SMONI response: ^SMONI: 2G,71,-61,262,02,0143,83BA,33,33,3,6,G,NOCONN
  # DEBUG: testing SMONI response: ^SMONI: 2G,SEARCH,SEARCH
  # DEBUG: testing SMONI response: ^SMONI: 2G,673,-89,262,07,4EED,A500,16,16,7,4,G,5,-107,LIMSRV
  # DEBUG: testing SMONI response: ^SMONI: 2G,673,-80,262,07,4EED,A500,35,35,7,4,G,643,4,0,-80,0,S_FR
  # DEBUG: testing SMONI response: ^SMONI: 3G,10564,296,-7.5,-79,262,02,0143,00228FF,-92,-78,NOCONN
  **
  ERROR:cinterion/tests/test-modem-helpers-cinterion.c:1036:test_smoni_response: assertion failed (fabs (ecn0 - smoni_response_tests[i].ecn0) < 0.1): (0,5 < 0,1)
  Bail out! ERROR:cinterion/tests/test-modem-helpers-cinterion.c:1036:test_smoni_response: assertion failed (fabs (ecn0 - smoni_response_tests[i].ecn0) < 0.1): (0,5 < 0,1)
  Aborted (core dumped)
2020-05-19 13:44:23 +02:00
Aleksander Morgado
ccb45a8941 libmm-glib,helpers: ignore all leading whitespaces when parsing numbers 2020-04-09 12:38:50 +00:00
Aleksander Morgado
1c7304eb71 libmm-glib,helpers: allow reading hex strings from match info 2020-04-09 12:38:50 +00:00
Aleksander Morgado
539562af01 libmm-glib,helpers: skip quotes when reading numbers from match infos
Useful when the regex applied to the parseable strings don't have an
special ignore rule for the quotes.
2020-04-09 12:38:50 +00:00
Aleksander Morgado
6de1363174 api,modem: improve capabilities related documentation
And remove the unused mm_common_build_capability_combinations_any()
method in the common non-public library code.
2020-04-09 06:46:02 +02:00
Aleksander Morgado
280363e0d6 libmm-glib,helpers: allow \r\n in string to number conversions
It's not uncommon that we may want to parse a simple AT response that
contains a single number by doing mm_strip_tag() followed by
mm_get_uint_from_str(). In order to do this, we need to have the
helper methods that convert strings to numbers support \r\n characters
at the end of the string, as we would have in AT responses.
2020-01-31 15:48:16 +01:00
Aleksander Morgado
15e8a78a15 libmm-glib,common-helpers: allow yes/no as booleans in string
E.g. so that the settings passed on Simple.Connect() or
Bearer.Connect() are parsed correctly from the user string:

  daemon.notice netifd: wan (30476): simple connect=apn=internet,ip-type=ipv4,allow-roaming=yes
  daemon.notice netifd: wan (30476): Error parsing connect string:
  'Invalid properties string, unexpected key 'allow-roaming''

This also goes inline with e.g. the --create-bearer help in the man
page that suggests using yes/no for the allow-roaming setting.
2020-01-06 14:39:45 +01: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
7330f6d581 libmm-glib,common: new helper methods to read guint64 values
We use strtoull() to read a "unsigned long long" that is always at
least 64bits, even in 32bit systems.
2019-03-29 10:07:29 +00:00
Thomas Haller
8bde29c9e2 libmm-glib: use helper function to convert enum/flags from string 2018-10-04 09:43:15 +02:00
Thomas Haller
d83f50794d libmm-glib, modem-helpers: unref enum/flags GType classes in enum getters 2018-10-04 09:43:05 +02:00
Aleksander Morgado
2e0471fe6a libmm-glib: new common helpers to check band types 2018-08-21 17:02:39 +00:00
Aleksander Morgado
d4aaa436d9 modem-3gpp: allow loading and changing EPS UE mode of operation
The UE modes of operation for LTE are defined in 3GPP TS 24.301 (e.g.
section 4.3 in v10.3.0):
  * PS mode 1: EPS only, 'voice centric'
  * PS mode 2: EPS only, 'data centric'
  * CS/PS mode 1: EPS and non-EPS, 'voice centric'
  * CS/PS mode 2: EPS and non-EPS, 'data centric'

The mode specifies, among other things, how the UE should behave w.r.t
CS fallback depending on the capabilities reported by the network.
2018-01-20 15:41:07 +01:00
Aleksander Morgado
91613543d5 libmm-glib: set clear func by default in the MMModemPortInfo array
So that we don't leak the port names allocated within each
MMModemPortInfo.

    ==261== 672 bytes in 84 blocks are definitely lost in loss record 7,314 of 7,383
    ==261== at 0x402C51E: malloc (vg_replace_malloc.c:299)
    ==261== by 0x4484878: g_malloc (gmem.c:94)
    ==261== by 0x449D51D: g_strdup (gstrfuncs.c:363)
    ==261== by 0x44B5B73: g_variant_dup_string (gvariant.c:1529)
    ==261== by 0x44B945E: g_variant_valist_get_nnp (gvariant.c:4775)
    ==261== by 0x44B945E: g_variant_valist_get_leaf (gvariant.c:4945)
    ==261== by 0x44B945E: g_variant_valist_get (gvariant.c:5126)
    ==261== by 0x44B922C: g_variant_valist_get (gvariant.c:5161)
    ==261== by 0x44B9FC9: g_variant_get_va (gvariant.c:5388)
    ==261== by 0x44BA3C5: g_variant_get_child (gvariant.c:5486)
    ==261== by 0x6613FA8: mm_common_ports_variant_to_garray (mm-common-helpers.c:238)
    ==261== by 0x6601AB9: ensure_internal_ports (mm-modem.c:766)
    ==261== by 0x6603E42: mm_modem_peek_ports (mm-modem.c:825)
    ==261== by 0x65CD94D: owns_port (nm-modem-broadband.c:196)

Reported-by: Piotr Figiel <p.figiel@camlintechnologies.com>
2017-02-10 10:29:52 +01:00
Aleksander Morgado
292914cf65 iface-modem: always sort supported and current bands before exposing them 2016-10-12 13:24:09 +02:00
Aleksander Morgado
58c955f5f2 core: allow building and running without udev
Instead of relying on the udev daemon and GUDev to manage the devices reported
by the kernel, we can now run ModemManager relying solely on the kernel events
reported via the new ReportKernelEvent() API. Therefore, the '--no-auto-scan'
option is implicit for the ModemManager daemon when udev is disabled in the
build.

Additionally, a new custom implementation of the kernel device object is
provided, which uses sysfs to load the properties and attributes required in
each kernel device, instead of using a GUdevDevice.

The udev rule files are kept in place, and a simple custom parser is provided
which preloads all rules in memory once and then applies them to the different
kernel objects reported via ReportKernelEvent(), e.g. to set port type hints.
A simple unit test setup is prepared to validate the udev rules during the
`check' Makefile target.
2016-09-29 15:43:05 +02:00
Aleksander Morgado
7460793caa libmm-glib,helpers: don't warn when trying to read invalid match info index
We may want to use the mm_get_()_from_match_info() calls to read optional items,
so that the method returns FALSE if the item index doesn't apply. So, avoid the
implicit warning issued by g_return_val_if_fail().
2016-08-10 09:04:54 +02:00
Aleksander Morgado
ccc148fe9b libmm-glib,common-helpers: fix reading boolean from string
The "0" case wasn't being handled properly:
  $ sudo mmcli -m 0 --create-bearer="apn=,allow-roaming=0"
  Error parsing properties string: 'Cannot get boolean from string '0''
2016-04-19 14:02:13 +02:00
Riccardo Vangelisti
0bf4ad6b66 libmm-glib: added support for Modem.Voice and Call interfaces 2015-08-02 10:39:12 +02:00
David McCullough
b8138d93f5 libmbim-glib: handle explicit '+' on positive numbers 2014-07-29 14:16:31 -05:00
Ben Chan
5d47478d06 libmbim-glib: consistently use spaces for indentation 2014-05-20 09:32:02 +02:00
Aleksander Morgado
86795b928e libmm-glib: allow new 'teleservice-id' and 'service-category' keywords in MMSmsProperties 2013-10-25 19:49:54 +02:00
Aleksander Morgado
7751f2d6ed mmcli,oma: support for the new OMA interface 2013-09-09 10:20:40 +02:00
Aleksander Morgado
8ab38ae968 libmm-glib: support for the 'OMA' interface 2013-09-09 10:15:18 +02:00
Aleksander Morgado
3206e95663 api,introspection: new 'Ports' property in the Modem interface
We will expose a new 'Ports' property listing all ports currently known by a
given modem. Ports which are not used but are detected as being part of the
modem will be listed with an 'unknown' port type.

This change uses the new 'MMModemPortType' enum and the new 'MMModemPortInfo'
helper struct to handle these values in libmm-glib. The already available
'MMPortType' enum hasn't been re-used for the interface because it contains
values that we don't need (e.g. IGNORED).

The port list is now also included in the modem information command of mmcli:

$ sudo mmcli -m 0

/org/freedesktop/ModemManager1/Modem/0 (device id '97b7b99e3e2bea103880545b619fb05a3cc81b26')
  -------------------------
  System   |         device: '/sys/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.4'
           |        drivers: 'qcserial, qmi_wwan'
           |         plugin: 'Gobi'
           |   primary port: 'cdc-wdm0'
           |          ports: 'ttyUSB0 (qcdm), ttyUSB1 (at), cdc-wdm0 (qmi), wwp0s29u1u4 (net)'

https://bugzilla.gnome.org/show_bug.cgi?id=702678
2013-06-24 19:44:57 +02:00
Aleksander Morgado
0db920b762 mmcli: new '--set-current-capabilities' command
New command to allow changing modem capabilities, if supported. The modem will
power cycle automatically after having changed them.
2013-06-05 19:15:15 +02: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
Aleksander Morgado
45ceba7692 api,introspection: 'SupportedModes' is now a list of possible combinations
Instead of just a mask of MMModemMode values, we now provide a list of the
allowed and preferred mode combinations supported by the modem. E.g.:

$> sudo mmcli -m 0
  -------------------------
  Modes    |      supported: 'allowed: 2g; preferred: none
           |                  allowed: 3g; preferred: none
           |                  allowed: 2g, 3g; preferred: none
           |                  allowed: 2g, 3g; preferred: 2g
           |                  allowed: 2g, 3g; preferred: 3g
           |                  allowed: 4g; preferred: none
           |                  allowed: 2g, 3g, 4g; preferred: none'
2013-06-05 19:15:14 +02:00
Aleksander Morgado
804642adc2 api: let MMBearerIpFamily be flags instead of a enumeration
We want to expose in the Modem interface the list of supported IP families, and
the easiest way to do so is to have the IP family as flags, and provide in the
interface a single enum.

Also, a value of 0 for a MMBearerIpFamily specifies that no flags are set, so
just rename it to 'NONE'.

And add a new 'ANY' value which sets all flags to 1.
2013-06-05 19:15:13 +02:00
Aleksander Morgado
b1bb8e30b4 broadband-modem: don't assume the returned string is always hex-encoded 2013-02-22 19:43:49 +01:00
Dan Williams
dd51f7a6ae libmm-glib: document mm_get_uint_from_str()
Unlike strtol/stroul, this function doesn't ignore leading or
trailing non-digit characters, so document that restriction.
2012-12-05 11:43:58 -06:00
Aleksander Morgado
e2a36bd6be libmm-glib: allow 'none' authentication with more values
Specifying 'none' is really not exclusive. We may want to say that the modem can
either authenticate with a given protocol, or otherwise just try without
authentication.

The reality is that 'none' itself is usually always given in the connection
settings.
2012-10-10 16:55:24 +02:00
Aleksander Morgado
ebd792d2aa api,libmm-glib: new `allowed-auth' configuration for bearers
For bearers using STATIC or DHCP IP method, the modem itself is the one
negotiating authentication with the network. The new `allowed-auth' property
allows users to specify which authentication method(s) are allowed to be used.

See the following NetworkManager commit for more reference:
    commit 34aef8aaaa09b7473b9496aa49e550bd2def03f8
    Author: Andrew Bird <ajb@spheresystems.co.uk>
    Date:   Thu Mar 15 16:19:43 2012 -0500
2012-10-07 21:12:00 +02:00
Aleksander Morgado
b6d628b3a1 build: merge libmm-common into libmm-glib
It's pointless to have libmm-common around, just merge it into libmm-glib and
make ModemManager depend on libmm-glib directly. At the end, the non-common
stuff in libmm-glib is really minimal.
2012-10-04 10:17:05 +02:00