Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get 3g modem signal strength in c++ linux?

without using AT commands how can we get signal strength of 3g modem? The gdbus object for NetworkManager don't have any method like getSignalStrength. Network manager is locking device file preventing to use AT commands.

nm-applet was able to display signal strength in system tray. so there should be a way to get signal strength form network manager!

nmcli is command line counter part of nm-applet. Can i get signal strength using nmcli? nothing about signal strength is mentioned in its man pages.

like image 785
Necktwi Avatar asked Jun 26 '13 13:06

Necktwi


2 Answers

Finally got the answer!

In c++ use libnm-glib to act on dbus proxy. From command line use..

gdbus call --system --dest org.freedesktop.ModemManager --object-path /org/freedesktop/ModemManager/Modems/0 --method org.freedesktop.ModemManager.Modem.Gsm.Network.GetSignalQuality

gives u the signal strength of gsm modem.

If MM says it cannot get signal quality while connected, it's because there is only one AT port for all command and data. So when the AT port is connected, no AT commands can be sent to gather signal quality. You'll need to either get a better modem with more AT ports, or switch to a non-AT modem, like a QMI or MBIM powered one. -- Aleksander Morgado

One can listen to org.freedesktop.ModemManager.Modem.Gsm.Network.GetSignalQuality signal using

gdbus monitor --system --dest org.freedesktop.NetworkManager --object-path /org/freedesktop/NetworkManager/Modems/0

Q. Does the proxy signals everytime there is a change in signal strength asynchonously or ModemManager polls modem periodically to get signal quality?

A. That depends on the modem being used; if the modem supports unsolicited quality change indications, we'll use them; otherwise MM will poll every 30s for signal quality values. The property values in the interface will be updated once we get the new values (more or less). -- Aleksander Morgado

like image 134
Necktwi Avatar answered Oct 13 '22 00:10

Necktwi


NetworkManager uses ModemManager for mobile broadband modem control. Instead of looking at the NetworkManager DBus APIs, you can look at the ModemManager ones, which will actually expose the connection/registration details, including signal quality.

If targeting to develop an application using C++ to gather information from the modem, I'd suggest to use libmm-glib (GLib-based library) to access the ModemManager DBus API transparently (i.e. without needing to know DBus).

like image 20
Aleksander Avatar answered Oct 13 '22 01:10

Aleksander