canonical / nm.dart

Native Dart client library to access NetworkManager on Linux.
https://pub.dev/packages/nm
Mozilla Public License 2.0
29 stars 11 forks source link

Remove wrong assertions #56

Closed jpnurmi closed 2 years ago

jpnurmi commented 2 years ago

NetworkManager does not require specifying an access point when adding and activating a hidden Wi-Fi connection. The access point is not known at that point anyway.

jpnurmi commented 2 years ago

Test code in Python:

import dbus

bus = dbus.SystemBus()
client = dbus.Interface(bus.get_object("org.freedesktop.NetworkManager", "/org/freedesktop/NetworkManager"), "org.freedesktop.NetworkManager")

connection = dbus.Dictionary({
    "connection": dbus.Dictionary({
        "id": "<name>",
        "type": "802-11-wireless",
    }),
    "802-11-wireless": dbus.Dictionary({
        "ssid": dbus.ByteArray("<ssid>".encode("utf-8")),
    }),
    "802-11-wireless-security": dbus.Dictionary({
        "key-mgmt": "wpa-psk",
        "psk": "<password>"
    }),
})

device = dbus.ObjectPath("/org/freedesktop/NetworkManager/Devices/<num>")
ap = dbus.ObjectPath("/") # <== the AP is not known, "/" is fine

print(client.AddAndActivateConnection(connection, device, ap))
jpnurmi commented 2 years ago

@robert-ancell, could you publish this, please? It's needed for https://github.com/canonical/ubuntu-desktop-installer/pull/630.

robert-ancell commented 2 years ago

Published as nm 0.4.3