[Networkmanager] Creating, enabling, disabling wifi access point using libnm-glib

VT102 VT102 at protonmail.com
Mon Jan 23 11:19:07 UTC 2023


Thank you for taking the time to respond. I have been able to get some C code working to create a hot spot on the wlan0 device, however it is not clear to me how to close/delete the connection from the nmlib API.

I see that nmcli deletes connections using the nm_remote_connection_delete_aysnc api, however this does not work with the NMConnection that I created. Can you provide any guidance on this?

Thank you,

Sent with Proton Mail secure email.

------- Original Message -------
On Friday, January 20th, 2023 at 3:23 AM, Beniamino Galvani <bgalvani at redhat.com> wrote:

> On Thu, Jan 19, 2023 at 12:07:11AM +0000, VT102 wrote:
> > Hello,
> > I have been looking through the source code documentation and
> > examples but I'm not clear on if it would be possible to create,
> > enable, and disable a wifi access point using the libnm-glib API?
> Yes, it's possible. Note that "libnm-glib" is the name of an old
> library to control NM that has been replaced by "libnm". What you want
> to use really is libnm.
> > I see that there is an example showing how to see existing AP's
> > https://github.com/lcp/NetworkManager/blob/master/examples/C/glib/get-ap-info-libnm-glib.c
> This git repo contains very old code, please check out the official
> repository at
> https://gitlab.freedesktop.org/NetworkManager/NetworkManager .
> > I also see there is an NMAccessPoint data type from which I can get
> > access point information, but I dont see any way to set it.
> > https://developer-old.gnome.org/libnm-glib/stable/NMAccessPoint.html
> You need to add new connection profile that contains the hotspot
> parameters, and then call nm_client_add_and_activate_connection_async().
> You can use the implementation of the "nmcli device wifi hotspot" as a
> reference:
> https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/blob/1.40.10/src/nmcli/devices.c#L4475
> This article also explain the basic concepts of libnm and how to use
> it from Python:
> https://fedoramagazine.org/using-python-and-networkmanager-to-control-the-network/
> Beniamino

More information about the Networkmanager mailing list