On Wed, 2013-11-27 at 22:44 +0100, Marin Bašić wrote: > Dear developers, > I am writing golang program for wifi connection. > For now, I have been succesfull for scanning network, adding connection, > but I am stuck on connecting to network. > What API I must call to connect to network based on configuration?( can be > that configuration ad-hoc?)
For reference, the canonical D-Bus interface documentation is here: https://projects.gnome.org/NetworkManager/developers/api/09/spec.html The setting properties specification is here: https://projects.gnome.org/NetworkManager/developers/api/09/ref-settings.html To activate a specific network connection, call the org.freedesktop.NetworkManager.ActivateConnection() method and passing an existing connection to use, along with the device you want to start that connection on. With NM 0.9.9+, you can leave the connection blank, and NetworkManager will pick a connection for you. If there is no existing connection for that device, you can create one using the AddAndActivateConnection() method. This takes a skeleton connection hash and fills in the details for you. Different device types take different parameters for the "specific object" argument; for WiFi you pass the object path of an AccessPoint object that you would like to connect to. This adds the connection to NetworkManager, and then activates the connection on the device. For an ad-hoc connection, you need to fill in the details yourself because NetworkManager cannot autodetect them (since you're creating the network). So for that, you'd build up the WiFi connection hash with the correct properties, call org.freedesktop.NetworkManager.Settings.AddConnection() with that hash, and that returns an object path of the added connection. You'd then pass that object path, along with the device object path you wish to use, to the org.freedesktop.NetworkManager.ActivateConnection() method. This returns an "ActiveConnection" object path, which represents the live connection from start to finish. You can watch this object (or the device object itself) for success/failure. Some examples of various operations are here: http://cgit.freedesktop.org/NetworkManager/NetworkManager/tree/examples Dan _______________________________________________ networkmanager-list mailing list [email protected] https://mail.gnome.org/mailman/listinfo/networkmanager-list
