Re: Newbie: how to talk to NM by C or C++? Need some hints.

On Tuesday 30 of November 2010 10:27:14 inthawadee C. wrote:
> Hello all,
> How can I get the current statuses such as signal strength and maximum bit
> rate (also connection status). of wireless access point from NetworkManager
> by programming in C/C++?
> I have read many pages recommended in archives such as
> op.NetworkManager.AccessPoint<http:///>
> but still have no clue how to talk to NetworkManager.
> I just want to use the mentioned parameters as input factors of my
> experiment implemented in C.
> Previously, I worked with iwconfig and iwlist but want to try the program
> through Network Manager.
> Thanks in advance.
> Papagei

As others pointed out, you can talk to NetworkManager via D-Bus protocol
NM D-Bus API description is available here

You can talk on D-Bus in many different ways according to 
tools/languages/libraries you choose.
1. command-line tools:
example (getting AP signal strength)
qdbus --system --literal org.freedesktop.NetworkManager 

example (getting AP signal strength):
dbus-send --system --print-reply --dest=org.freedesktop.NetworkManager 
org.freedesktop.DBus.Properties.Get string:org.freedesktop.NetworkManager 

e.g.: cnetworkmanager --ai=00:3A:98:A0:70:40

e.g.: mcli -f NAME,SSID,BSSID,SIGNAL dev wifi list 

2. python
see examples in

3. C/C++
You can use low-level D-Bus library (part of dbus package) or some higher 
level libraries such as dbus-glib or  dbus-qt.
Moreover, NM comes with libnm-glib library that wraps direct D-Bus calls and 
makes the communication even more easy.
See examples in
I've added
ap-info-libnm-glib.c, that will show you how to get info about APs (you are 
interested in).


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]