Re: LibNM in C++ Wireless management



On Wed, 2017-03-22 at 18:07 +0100, Francesco Andrisani wrote:
I started to work on an application that use LibNM for wireless
netwoak
management (Scan, Connection, disconnection).
I successfull write a scanning interface helped by the examples at
this
page
https://github.com/lcp/NetworkManager/blob/master/examples/C/glib/get
-ap-info-libnm-glib.c
but my question is...can someone help me to know how can I manage
connection and disconnection of wireless (wifi) board.
I tried to find some examples, but nothing.

Some examples are here:

https://cgit.freedesktop.org/NetworkManager/NetworkManager/tree/examples/C/glib/add-connection-libnm.c
https://cgit.freedesktop.org/NetworkManager/NetworkManager/tree/examples/C/glib/list-connections-libnm.c

and there are more in other languages.

The general process is that you need a "Connection" object to describe
the properties the network connection requires.  To connect to an AP,
you'd do something like:

1) identify the AP you want to connect to (see get-ap-info-libnm.c)

2) check if there's an existing WiFi connection for that SSID already
defined; if there is, just activate it with ActivateConnection()

3) if there isn't, you can call AddAndActivateConnection() with the AP
object and NetworkManager will fill in the details for you

to disconnect, you can get the current active connection on the device
and call DeactivateConnection().  Or you can call the Disconnect()
method on the device which doesn't require a conneciton, but that will
block further autoconnects.

Dan


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