Suggested way to build up a connection with qmicl/libqmi? How to get indications, that connection not working/connection was dropped?
Aleksander Morgado
aleksandermj at chromium.org
Fri Sep 22 13:00:56 UTC 2023
> when I want to build up a connection, I send some command, which return
> an id, an IP address, ...
>
> So when using a bash script I think I need to parse the output of the
> current command,
>
> to be able to use the id for upcoming qmicli calls.
>
Take a look at the qmi-network program in the libqmi sources as well,
see https://gitlab.freedesktop.org/mobile-broadband/libqmi/-/blob/main/utils/qmi-network.in?ref_type=heads
> When doing the same via C/C++ it looks like (at least for a beginner)
> the first steps are not the easiest once.
>
> A collegue just found a python example:
>
> https://gitlab.com/linux-mobile-broadband/libqmi/-/tree/main/examples/simple-tester-python?ref_type=heads
>
Yes, this is another way to use libqmi, through gobject introspection.
>
> What is the suggested way? Are there examples to do such a thing via a
> shell script?
>
The qmi-network link from above is useful, it uses qmicli to run the QMI calls.
>
> And a question in similar area: When connection was successfully
> established, a ping is working and suddenly not more,
>
> can I somehow get an indication what happened to the connection? If
> there is currently just no data transfer possible,
>
> or connection dropped, or any other reason happened?
>
You can receive indications like those if you're directly using
libqmi, either via C or python/introspection. With qmicli there are
some operations that have builtin support to wait for and print
indications, e.g. --loc-follow-position-report. But once the qmicli
process ends, the indications are not processed any more. If you do
need to know whether the connection is still up or not, you can either
use indications with C/python/introspection or otherwise use some
polling with qmicli to periodically query the state.
--
Aleksander
More information about the libqmi-devel
mailing list