Commit Graph

64 Commits

Author SHA1 Message Date
Florian Eckert
c3365a36f0 cli,output: print valid json for network scan result
A network scan with json output currently returns the following:

root@G3-10940 ~ # mmcli -m 0 -J --3gpp-scan --timeout=300 | jq
{
  "modem": {
    "3gpp": {
      "scan-networks": [
        "operator-code: 26201, operator-name: TDG, access-technologies: lte, availability: forbidden",
        "operator-code: 26203, operator-name: o2 - de, access-technologies: lte, availability: forbidden",
        "operator-code: 26202, operator-name: vodafone.de, access-technologies: lte, availability: current"
      ]
    }
  }
}

This is a valid JSON, but in order to be able to access the individual
data elements more easily, the line can also be dumped as a json object.

The following commit converts the lines into a JSON obejct, so that it
looks like this:

root@G3-10940 ~ # mmcli -m 0 -J --3gpp-scan --timeout=300 | jq
{
  "modem": {
    "3gpp": {
      "scan-networks": [
        {
          "operator-code": "26201",
          "operator-name": "TDG",
          "access-technologies": "lte",
          "availability": "forbidden"
        },
        {
          "operator-code": "26203",
          "operator-name": "o2 - de",
          "access-technologies": "lte",
          "availability": "forbidden"
        },
        {
          "operator-code": "26202",
          "operator-name": "vodafone.de",
          "access-technologies": "lte",
          "availability": "current"
        }
      ]
    }
  }
}

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2023-02-17 10:15:36 +00:00
Frederic Martinsons
766962167c cli: add formating option (json and key/value) for created SMS
Fixes #657

Signed-off-by: Frederic Martinsons <frederic.martinsons@gmail.com>
2023-01-18 11:00:17 +00:00
Aleksander Morgado
a114e131ab libmm-glib,3gpp-profile: new print() method
Can be used right away in the mmcli output generation logic.
2022-11-04 13:12:56 +00:00
Aleksander Morgado
bfba265009 libmm-glib,common-helpers: don't assume new_from_unix_utc() always succeeds
The g_date_time_new_from_unix_utc() method in glib2 may fail if the
given timestamp is too far into the future. The value is supposed to
be seconds since unix time origin, but internally it will be converted
into usecs, so any value longer than G_MAXINT64 / USEC_PER_SECOND
isn't allowed.

This is currently used in the CLI, and we're anyway ignoring the error
returned in that case, but at least it won't crash if it ever happens.
2022-10-05 09:06:22 +00:00
Aleksander Morgado
129807c417 cli,output: plug leak of OutputItemListItem items 2022-08-19 22:43:33 +00:00
Aleksander Morgado
210020c7d2 cli,sim: print GID1 and GID2 fields if available 2022-08-19 15:53:43 +00:00
Aleksander Morgado
9fa1b32e34 cli: don't print signal quality unless modem is enabled
We don't have a clear way to report "unknown" signal quality, so for
now just skip printing it altogether in the mmcli human output if the
modem is not yet enabled.
2022-05-25 11:15:29 +02:00
Amol Lad
4d0400b77f mmcli: correctly set key_length
Fixes https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/559
2022-04-28 12:02:02 +02:00
Aleksander Morgado
c4f59aebe0 mmcli,modem: new '--get-cell-info' action 2022-01-18 09:00:10 +00:00
Aleksander Morgado
791fb38417 cli: fix 3GPP location mcc/mnc field names 2021-12-26 11:04:05 +01:00
Aleksander Morgado
2bfa6863c4 mmcli: new '--3gpp-profile-manager-status' operation
In order to show the properties of the profile management interface, e.g.:

  $ sudo mmcli -m a --3gpp-profile-manager-status
    -----------------------------------
    3GPP profile manager | index field: apn-type
2021-12-26 10:12:32 +01:00
Aleksander Morgado
e7c55f5f70 cli: indent all profile property names to the same column 2021-12-24 14:05:35 +01:00
Aleksander Morgado
a896f88bf9 cli: don't use dashes in 3GPP profile human output 2021-12-24 14:05:35 +01:00
Aleksander Morgado
3c0d94ac03 cli: new 'profile-source' setting in 3GPP profile 2021-12-24 14:05:35 +01:00
Aleksander Morgado
fb0b00db16 cli: new 'roaming-allowance' in 3GPP profile and bearer properties 2021-12-24 14:05:35 +01:00
Aleksander Morgado
99ca2f5a1c cli: new 'profile enabled' setting in 3GPP profile 2021-12-24 14:05:35 +01:00
Aleksander Morgado
41887b3fb7 cli: new 'access-type-preference' in 3GPP profile and bearer properties 2021-12-24 14:05:32 +01:00
Aleksander Morgado
a6dd7ac60f cli,modem: add 5GNR registration settings in modem info output 2021-12-24 12:41:27 +00:00
Aleksander Morgado
f8719e6308 cli,sim: new 'SimType', 'Removability' and 'EsimStatus' properties 2021-12-11 12:53:37 +01:00
Som_SP
511859ef0a api,bearer: add 'uplink-speed' and 'downlink-speed' stats
These values show the rates that have been negotiated with the network
during the PS domain attach.

These are not the current ongoing data rates associated to the network
usage at some given moment.

Includes updates by Aleksander Morgado to fix coding style issues and
add missing documentation items.
2021-11-03 12:41:51 +01:00
Aleksander Morgado
f55ea211a9 api,3gpp: new 'PacketServiceState' property
This property allows the user to know whether the device is attached
or detached from the packet domain service.
2021-11-02 09:50:17 +00: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
Frederic Martinsons
0510e9aef8 api,bearer: new 'start-date' field in bearer statistics
It stores the epoch timestamp of the current bearer session start.
If there is no connected bearer, it is set to 0 and not displayed
in mmcli output.

Signed-off-by: Frederic Martinsons <frederic.martinsons@sigfox.com>

Includes updates by Aleksander Morgado to fix coding style issues.
2021-10-22 13:48:13 +02:00
Som_SP
925f0bae11 libmm-glib,mmcli: add support for the new signal 'SetupThresholds()' API
Includes updates by Aleksander Morgado to fix mostly coding style issues.
2021-10-20 22:09:18 +02:00
Som_SP
9537261651 libmm-glib,mmcli: add support for 'error-rate' measurements in signal info
Includes updates by Aleksander Morgado to fix mostly coding style issues.
2021-10-20 22:07:24 +02:00
Andrew Lassalle
8ecf7fc83e 3gpp-profile: Add profile name
QMI modems also report a profile name, and that value can be used to
select and update a specific profile.
2021-10-17 17:56:44 +02:00
lvmaorui
07a6b6032b mmcli:add SAR command --sar-status/--sar-enable/--sar-disable/--set-power-level 2021-10-13 13:14:10 +02:00
Teemu Ikonen
fa19b2b9b1 cli, location: Fix multi-sentence NMEA message output
Multi-sentence NMEA messages were printed as is, that is with
linebreaks, which made mmcli --location-get output look broken.

Split NMEA sentences with linebreaks to separate output list items, so
that they line up correctly.
2021-09-01 15:50:38 +00:00
Aleksander Morgado
de6b1324cb api,bearer: new 'ConnectionError' property
This new property will provide detailed information about the failed
connection attempt, or about the network initiated disconnection. The
property will be cleared only if a new connection attempt is
triggered, and so it can be used to investigate why a given attempt
failed without needing to be the one who triggered the attempt (e.g.
so that failures in NetworkManager-triggered connection attempts can
be investigated looking at the DBus API).

The property is built as a (ss) tuple, but the libmm-glib interface
provides methods to read this property as a GError.
2021-05-23 01:22:07 +02:00
Aleksander Morgado
9fd5aced67 api,bearer: new 'ProfileId' property
To report which is the currently active profile with this bearer, if
known. If the modem doesn't support profiles, or if the bearer is
disconnected, -1 (MM_3GPP_PROFILE_ID_UNKNOWN) will be reported.

It is guaranteed that no two connected bearers will have the same
ProfileId property value.
2021-04-29 10:13:22 +00:00
Aleksander Morgado
2d43ea48e1 api,modem: new Modem3gpp.ProfileManager interface
This new interface allows modems to expose the list of available
connection profiles stored in the device and edit or delete them; as
long as the underlying device/protocol allows it.
2021-04-29 10:13:22 +00:00
Aleksander Morgado
793370f2f8 api,bearer: new 'profile-id' setting
We define a new 'profile-id' setting in the bearer properties that
users will use to specify which connection profile of the ones
available in the device should be connected.

When the 'profile-id' is given, the associated bearer object will be
bound to the 'profile-id', and the user is able to provide additional
settings to apply on top (e.g. if the profile storage doesn't allow
some of the settings we support, like 'apn-type', or if the setting is
completely unrelated to profiles, like 'multiplex').

After introducing the 'profile-id' as a valid setting in the bearer
properties, we also reimplement the properties object internals to
make use a 3GPP profile for the subset of common settings between both
objects.
2021-04-29 10:13:22 +00:00
Aleksander Morgado
ff8e21b535 api,bearer: new 'apn-type' setting
This new setting allows the user setting up the connection to specify
the purpose of the connection being brought up.

Until now, we would always assume that connections are exclusively
brought up for connecting to the Internet, also limited by the
inability to connect to multiple different APNs at the same time.

But that may really not be true as there may be additional services
that may be accessed through other APNs, like MMS services or even
private networks for companies that have their own APNs on a given
operator (e.g. not that uncommon with banks and connected cars).

The new APN type setting will not change the way the bearer is
connected, but will allow the connection manager to decide what kind
of networking setup the specific connection needs.

This new setting can be provided by the user itself, or implicitly
read from the device if the device stores this information.
2021-04-29 10:13:22 +00:00
Aleksander Morgado
73db7f205c api,bearer: new 'Multiplexed' property
This property will be TRUE if the bearer has the data session
connected through a multiplexed interface.

If the bearer is disconnected, or connected without multiplexing, the
property will report FALSE.
2021-03-10 10:59:22 +01:00
Teijo Kinnunen
a4aba0a6b2 mmcli,sim: add preferred networks list to SIM properties 2021-02-26 12:28:01 +01:00
Eric Caruso
61739ab934 libmm-glib,mmcli: add mm_sim_get_eid and add EID to mmcli output
This exposes the new EID property of the SIM object on mmcli.
2020-10-19 20:38:43 +00:00
Aleksander Morgado
e7409b6898 api,modem: new 'SimSlots' and 'PrimarySimSlot' properties
The 'SimSlots' property exposes an array of SIM object paths, with one
array item for each available SIM slot in the system. If a valid SIM
card is found in a given slot, the path of the SIM object will be
exposed in the array item; if no valid SIM card is found, the empty
object path ("/") will be exposed instead.

The 'PrimarySimSlot' property exposes which of the SIM slots available
in the system is the one configured as being primary. In a Multi-SIM
Single-Standby setup, the primary slot will be the one corresponding
to the single active SIM in the system. In a Multi-SIM Multi-Standby
setup, the primary slot will be the one configured to act as primary
(e.g. the one that will be used for the data connection) among all the
active SIM cards found.
2020-08-28 14:59:06 +00:00
Aleksander Morgado
86a183778b api,sim: new 'Active' property
In preparation for the multi-SIM setup, we need a way to tell whether
a given SIM card is active or not in the system.

On systems with one single SIM slot, the available SIM card will
always be active.

On Multi-SIM Single-Standby setups we may have multiple SIM slots with
multiple SIM cards, but only one of them will be active at any given
time.

On Multi-SIM Multi-Standby setups we may have multiple SIM slots with
multiple SIM cards that may be active at the same time. E.g. the QMI
protocol allows up to 5 different active SIM cards (primary,
secondary, tertiary...).
2020-08-28 14:59:06 +00:00
Aleksander Morgado
1620f04b9b mmcli,output: use 'path' instead of 'dbus path' in field descriptions 2020-08-01 10:16:54 +02:00
Walter Hagstrom
88923ffe39 iface-modem-signal: added 5G signal information
Extended the ModemManager Signal interface to include 5G signal
information for RSRP, RSRQ and SINR via libqmi.  Also extended mmci
to print 5G signal info.
2020-07-04 05:50:41 +02:00
Maxim Anisimov
62c6f941a2 cli: make control chars in strings are escaped correctly for json output
We need to change json output escaping according to this
https://bugzilla.gnome.org/show_bug.cgi?id=730425

Signed-off-by: Maxim Anisimov <maxim.anisimov.ua@gmail.com>
2020-06-05 07:34:54 +00:00
Aleksander Morgado
d4a45315cf cli: add allowed-auth bearer property in output
Given as a list of items, because the bearer can be created with one
or more allowed authentication protocols.
2020-05-05 11:28:37 +00:00
Aleksander Morgado
79daa3099e api,bearer: add 'total-rx-bytes', 'total-tx-bytes' and 'total-duration' stats
Compiling the amount of bytes transferred and received during all
tracked connection attempts, as well as the total duration of all the
connections.
2020-04-10 11:45:03 +00:00
Aleksander Morgado
f325ef5902 api,bearer: add 'attempts' and 'failed-attempts' statistics
When we're reusing over and over the same bearer object, we can
provide statistical information about the number of connection
attempts that have been done and how many of them failed.
2020-04-10 11:45:03 +00:00
Aleksander Morgado
1216e88716 cli: fix warnings with -Wswitch-default
mmcli-output.c: In function ‘output_item_free’:
  mmcli-output.c:321:5: error: switch missing default case [-Werror=switch-default]
    321 |     switch (item->type) {
        |     ^~~~~~
  mmcli-output.c: In function ‘mmcli_output_dump’:
  mmcli-output.c:1208:5: error: switch missing default case [-Werror=switch-default]
   1208 |     switch (selected_type) {
        |     ^~~~~~
  mmcli-output.c: In function ‘mmcli_output_list_dump’:
  mmcli-output.c:1231:5: error: switch missing default case [-Werror=switch-default]
   1231 |     switch (selected_type) {
        |     ^~~~~~
2020-01-31 15:18:35 +01:00
Aleksander Morgado
9e785e145f mmcli,output: skip printing empty value lists
E.g. we shouldn't print emergency numbers field if there is none available:

  $ mmcli -i 0
    -------------------------------
    General    |         dbus path: /org/freedesktop/ModemManager1/SIM/0
    -------------------------------
    Properties |              imsi: 901700000026890
               |             iccid: 8988211000000268907
               |       operator id: 90170
               |     operator name: 901 70
               | emergency numbers:
2019-12-02 11:29:26 +00:00
Aleksander Morgado
f9ea0c1d9c cli,output: fix truncated array output when == 10 elements
The extra character size was only being applied when > 10 elements,
leaving the == 10 case out of it, so the output was being truncated.
Fix it, by using a more generic way to computing how many extra
characters we need in the size.

Fixes https://gitlab.freedesktop.org/mobile-broadband/ModemManager/issues/151
2019-10-27 15:57:30 +01:00
Aleksander Morgado
1f6c006976 api,sim: new 'Emergency Numbers' property 2019-10-17 08:31:46 +00:00
Aleksander Morgado
657833a400 voice,api: new 'EmergencyOnly' boolean flag
This new flag allows users of the API to know whether general purpose
voice calls are allowed or otherwise only voice calls to the
registered emergency numbers should be performed.

ModemManager won't really do any distinction between emergency and
non-emergency calls at this point, this flag is just an early
indication for the user of the API that no normal voice call should be
attempted.
2019-10-17 08:31:46 +00:00
Aleksander Morgado
227c290778 mmcli,firmware: don't use tabs when printing human-friendly list 2019-10-11 08:16:04 +00:00