Commit Graph

30 Commits

Author SHA1 Message Date
Aleksander Morgado
b3f315ad2d core,log: new 'MSG' log level between 'INFO' and 'WARN'
We're bumping the current "INFO" level messages to the new "MSG"
level, also making the new level the default.

The old "INFO" level will be used to setup an intermediate level of
logging which is not as verbose as "DEBUG" but still provides some
capabilities to analyze the behavior of a modem.
2022-11-04 13:12:56 +00:00
Freedom Liu
21ae558fe3 mmcli,manager: add 'wwan' subsystem to kernel event auto scan report 2021-04-29 00:58:35 +00:00
Frederic Martinsons
18b72a046e mmcli: don't assume that mm_object_peek_modem or mm_object_get_modem return non null
This very peculiar case can happen when an intermediate initiliazition step
of a modem fails.

The ModemManager daemon should always expose the modem interface but let not
assume that in mmcli and protect these calls.

Signed-off-by: Frederic Martinsons <frederic.martinsons@sigfox.com>
2020-12-21 13:00:40 +00:00
Aleksander Morgado
cab4b54ad1 core: new 'rpmsg' subsystem
Most older Qualcomm SoCs (e.g. MSM8916, MSM8974, ...) communicate with
the integrated modem via shared memory (SMD channels). This is similar
to QRTR on newer SoCs, but without the "network" layer. In fact, the
older SoCs also have QRTR, but the modem QMI services are not exposed
there.

The mainline Linux kernel exposes SMD channels via the "remote processor
messaging bus" (rpmsg). Through special IOCTL calls it is possible to
create a char device for a rpmsg/SMD channel. We can then use these to
send QMI/AT messages to the modem, much like the ordinary serial char
devices when using a Qualcomm modem through USB.

This commit introduces support for the new 'rpmsg' subsystem, which
allows exporting QMI-capable and AT-capable ports.

By default NO rpmsg port is flagged as candidate, it is assumed that
the plugin adding support for the rpmsg subsystem will add specific
rules to do so (e.g. so that non-modem ports are explicitly not
flagged as candidate).

All rpmsg ports will be probed for AT or QMI capabilities, unless
explicit port type hints (e.g. ID_MM_PORT_TYPE_QMI or
ID_MM_PORT_TYPE_AT_PRIMARY) are set.

These changes are highly based on the initial integration work done by
Stephan Gerhold <stephan@gerhold.net> in postmarketOS, see:
  https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/merge_requests/363
2020-11-20 09:24:51 +00:00
Aleksander Morgado
f1e77cdbe6 cli: context: add ':' to the section titles
So that --help-all print all sections in the same way as the Help and
Application option groups.
2020-03-21 15:40:13 +01:00
Aleksander Morgado
1fa7e1260d cli: fix warnings with -Wshadow
mmcli-manager.c: In function ‘context_free’:
  mmcli-manager.c:167:24: error: declaration of ‘ctx’ shadows a global declaration [-Werror=shadow]
    167 | context_free (Context *ctx)
        |               ~~~~~~~~~^~~
  mmcli-manager.c:51:17: note: shadowed declaration is here
     51 | static Context *ctx;
        |                 ^~~
  ...
2020-01-31 15:18:35 +01:00
Aleksander Morgado
2212d3e054 api,manager: new InhibitDevice() method
This new method allows users of the ModemManager API to take full
control of a given device.

Unlike other operations in the API, the inhibition is maintained as
long as the caller exists in the bus, or until the same caller
uninhibits the device.

https://gitlab.freedesktop.org/mobile-broadband/ModemManager/issues/98
2019-01-03 21:05:58 +01:00
Aleksander Morgado
c7af14cc80 api,manager: new 'Version' property
This string shows the runtime version of the ModemManager daemon.

https://gitlab.freedesktop.org/mobile-broadband/ModemManager/issues/94
2018-12-04 17:26:59 +00:00
Aleksander Morgado
b0fba14b1e cli: allow multiple output format types
In addition to the standard human-friendly output, we now allow a
machine-friendly key-value pair output, much easier to parse and use
by programs that look at the mmcli output.

This new key-value pair output should be treated as API from now on, so
third-party programs can assume the output is compatible from one
release to another.
2018-11-26 16:51:35 +00:00
Aleksander Morgado
b2a859a782 build: WITH_UDEV is only defined when enabled
Looks like the preprocessor doesn't choke when using #if WITH_UDEV and
it isn't defined to any value, but anyway, better explicitly say that
we're checking if it's defined or not.
2017-06-22 10:43:45 +02:00
Ben Chan
b225b7a267 cli: remove explicit GDestroyNotify cast on g_object_unref
g_object_unref is in form of  `void (*)(gpointer)`, which matches the
GDestroyNotify signature. An explicit GDestroyNotify cast on
g_object_unref is thus not needed.
2017-03-29 10:22:28 +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
c4a584416a core: allow disabling auto-scan and notifying ports one by one via API
This commit enables a new core ModemManager daemon option, so that automatic
detection of available modems is totally disabled: '--no-auto-scan'. Note that
this option also replaces the previously used '--test-no-auto-scan' option,
which was only used during tests.

Along with the new ModemManager option, a new ReportKernelEvent() method in
the API is defined, which allows notifying the daemon of which interfaces it
should be accessing, as well as the main details of each interface. The only
mandatory parameters in the new method are 'action' (add/remove), 'name' (the
name of the interface) and 'subsystem' (the subsystem of the interface).

The mmcli tool has support for using the new api method via several new options:

 * The '--report-kernel-event' option allows specifying device ports one by
   one, and is a direct mapping of the ReportKernelEvent() method:
     $ sudo mmcli --report-kernel-event="action=add,name=wwan0,subsystem=net"
     $ sudo mmcli --report-kernel-event="action=add,name=cdc-wdm0,subsystem=usbmisc"

 * The '--report-kernel-event-auto-scan' option uses udev monitoring to notify
   events automatically to the daemon. This allows to operate in a way
   equivalent to the default daemon operation (with implicit auto-scan).

Worth noting that the ReportKernelEvent() method is only usable when
'--no-auto-scan' is explicitly used in the daemon. An error will be reported if
the method is tried while standard udev monitoring is enabled (implicit if
auto scan isn't explicitly disabled in the daemon).

If mmcli is going to be used only to report 'real time' events, an optional
'--initial-kernel-events=[PATH]' may be given in the ModemManager call to
automatically process a set of port kernel events one by one on boot. The file
may e.g. contain:
  action=add,name=wwan0,subsystem=net
  action=add,name=cdc-wdm0,subsystem=usbmisc
2016-09-29 15:43:05 +02:00
Aleksander Morgado
ee85a463cf license: mmcli is GPLv2+, not GPLv3+
mmcli is GPLv2+; that's what --version has always said and that's what the
README in ModemManager sources specifies:
  License.
  The ModemManager and mmcli binaries are both GPLv2+.
  The libmm-glib library is LGPLv2+.
2015-12-07 13:16:24 +01:00
Ben Chan
f0542aa809 cli: show a nicer modem description if manufacturer or model is unknown 2014-05-29 10:05:28 +02:00
Ben Chan
d4177f554b cli: consistently use spaces for indentation 2014-05-20 09:32:15 +02:00
Aleksander Morgado
c250fa3797 libmm-glib: remove the `libmm-common.h' header
Both the ModemManager daemon and the mmcli will now include `libmm-glib.h' only.

We also handle two new special `_LIBMM_INSIDE_MM' and `LIBMM_INSIDE_MMCLI'
symbols, which if included before the `libmm-glib.h' library allow us to:

 * Don't include the libmm-glib high level API in the ModemManager daemon, as
   the object names would clash with those in the core.

 * Define some of the methods of helper objects to be included only if compiling
   ModemManager daemon or the mmcli.
2012-10-04 10:17:12 +02:00
Aleksander Morgado
737b6c2fc5 cli,libmm-glib: provide mm_manager_(peek|get)_proxy()
peek() doesn't increase the reference count of the proxy object, while get()
does it.
2012-07-31 09:02:58 +02:00
Ben Chan
60405ce4ff cli,libmm-glib: set default timeout on manager DBus proxy
This patch fixes mmcli to set the default timeout on the manager proxy
interface (MmGdbusOrgFreedesktopModemManager1) instead of MMManager
itself. The later is not a GDBusProxy object.
2012-07-31 08:54:45 +02:00
Aleksander Morgado
8f8bcd7724 cli: allow modifying default DBus timeout with `--timeout'
By default 30s will be used for every operation.
2012-07-25 11:44:01 +02:00
Aleksander Morgado
e8aeb59293 cli: use g_list_free_full() when possible 2012-03-15 14:14:46 +01:00
Aleksander Morgado
73ca5dcb24 cli: don't recheck group options if already done 2012-03-15 14:14:36 +01:00
Aleksander Morgado
6246944510 cli: allow option groups to force async/sync operations
Some operations are clearly asynchronous (e.g. monitoring modem state), while
others are clearly synchronous (e.g. printing modem info). So just allow option
groups to force the operation to be async or sync based on the detected action.
2012-03-15 14:14:33 +01:00
Aleksander Morgado
6a3e91ee83 cli: use the new libmm-glib API fixes 2012-03-15 14:14:33 +01:00
Aleksander Morgado
77ff2758b3 cli: logging improvements 2012-03-15 14:14:32 +01:00
Aleksander Morgado
1257ecd136 cli: start to port Modem actions to use the new libmm-glib 2012-03-15 14:14:26 +01:00
Aleksander Morgado
9e241b7062 cli: port Manager actions to use the new libmm-glib
The original command line interface was written based on a hand-made libmm. This
commit ports the Manager interface handling to the new gdbus-codegen-based
libmm-glib.
2012-03-15 14:14:25 +01:00
Aleksander Morgado
96e07f7ab0 cli: prefix error messages with 'error: ' 2012-03-15 14:14:25 +01:00
Aleksander Morgado
387db2b259 cli: use capital letters for manager options 2012-03-15 14:14:25 +01:00
Aleksander Morgado
d8c2a63927 cli: split into different option groups, in different files 2012-03-15 14:14:25 +01:00