Re: How to connect to wireless AP with NM 0.7.1

On Wed, 2010-01-13 at 18:32 -0800, Scott Parker wrote:
> I'm creating a console application which needs to be able to identify 
> and to connect to wireless access points.
> So far I have been able to scan and parse the access point I wish to 
> connect to but I'm having trouble understanding how to actually connect 
> to it now. From reading the source for the applet I have been able to 
> come up with this.

A few useful links:

The important thing to remember here is that all the connection data is
provided by either the system settings service or the user settings
service.  You cannot make NM connect to anything that is not provided by
one of those two services.

So to start with, you need to ensure that your connection data is
provided by one of those two.  That could mean writing out
distro-specific configuration (which would be picked up and provided by
the system settings service) or writing to GConf (for GNOME) or whatever
the KDE NM applet backend store is.

Once the settings service provides the connection, you can find it by
UUID, and tell NetworkManager to start that specific connection.
Connections are exported over D-Bus by their settings service and
referred to by an "object path" in D-Bus nomenclature.  To activate a
connection, you tell NetworkManager which settings service the
connection is provided by, and what that connection's object path is (as
exported by the settings service).  Then NM can connect.


> s_wireless = (NMSettingWireless *)nm_setting_wireless_new ();
> ap_ssid = nm_access_point_get_ssid(ap);
> g_object_set(s_wireless, NM_SETTING_WIRELESS_SSID, ap_ssid, NULL);
> g_object_set(s_wireless, NM_SETTING_WIRELESS_MODE, "infrastructure", NULL);
> connection = nm_connection_new();
> nm_connection_add_setting(connection, NM_SETTING(s_wireless));
> s_con = NM_SETTING_CONNECTION(nm_setting_connection_new());
> g_object_set(s_con, NM_SETTING_CONNECTION_TYPE, 
> nm_setting_get_name(NM_SETTING(s_wireless)), NULL);
> nm_connection_add_setting(connection, NM_SETTING(s_con));
> specific_object = nm_object_get_path (NM_OBJECT(ap));
> g_assert(connection);
> con_path = nm_connection_get_path(connection);
> g_assert(con_path); /* FAILS HERE */
> nm_client_activate_connection(app->priv->client, 
>                                                        con_path, device, 
> specific_object, activate_connection_cb, app);
> After I filter and select the access point (unencrypted) that i want to 
> connect to I'm unable to get the path of the NMConnection I have 
> created. The nm-applet is not running.
> Thanks
> _______________________________________________
> NetworkManager-list mailing list
> NetworkManager-list gnome org

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