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

馋奶兔 提交于 2019-12-06 02:44:49

问题


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.


回答1:


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




回答2:


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).




回答3:


I was working on a homework, in which I had to determine the indoor location by means of signal strengths of access points in a building. I was using

iwlist wlan0 scanning

command in order to see get the signal strength of the access points nearby. Then I was processing the output of it in Bash and redirecting it to C++ executable file, which is easy in Bash. I hope it will help you.



来源:https://stackoverflow.com/questions/17322154/how-to-get-3g-modem-signal-strength-in-c-linux

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!