Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enabled to AddConnection for connecting hidden SSID #130

Open
wants to merge 26 commits into
base: master
Choose a base branch
from

Conversation

MoriKeisuke
Copy link

I add function of AddConnection in NetworkManager.Settings.
Because I want to connect to hidden SSID.

I had searched https://github.com/OpenAgricultureFoundation/python-wifi-connect flow, and found network-manager to need AddConnection function.
I built and to run wifi-connect included this branch's, and verified to connect to hidden SSID.

# from https://github.com/balena-io/wifi-connect/blob/master/src/network.rs
impl NetworkCommandHandler {
    // ...
    fn connect(&mut self, ssid: &str, identity: &str, passphrase: &str) -> Result<bool> {
        // ...
        if let Some(access_point) = find_access_point(&self.access_points, ssid) {
            // ...
        } else {
            let wifi_device = self.device.as_wifi_device().unwrap();
            // Use there!
            let _ = wifi_device.add_connection(ssid, &AccessPointCredentials::Wpa {passphrase: passphrase.to_string()});

            if let Ok(connections) = self.manager.get_connections() {
                for conn in connections {
                    if conn.settings().ssid.as_str().unwrap_or("SSID not found") == ssid {
                        match conn.activate() {
                            // same
                        }
                    }
                }
            }
        }
    }
    // ...
}

The AddConnection() method
https://developer.gnome.org/NetworkManager/stable/gdbus-org.freedesktop.NetworkManager.Settings.html#gdbus-method-org-freedesktop-NetworkManager-Settings.AddConnection

When add_val used to put String, call "can't set property of type 'GBytes' from value of type 's'"

seveas/python-networkmanager#21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant