private int ConnectWpa(string ssid, string pass) { try { var wifiConfig = new NEHotspotConfiguration(ssid, pass, false) { JoinOnce = true }; var wifiManager = new NEHotspotConfigurationManager(); wifiManager.ApplyConfiguration(wifiConfig, (error) => { if (error != null) { Console.WriteLine($"Error while connecting Wifi network {ssid}:{error}"); } }); Console.WriteLine("Connected!"); return(1); } catch (Foundation.NSErrorException ext) { Console.WriteLine(ext.ToString()); return(0); } catch (Exception ext) { Console.WriteLine(ext.ToString()); return(0); } }
public bool Connect(string ssid, string password) { bool ret = false; try { var wifiManager = new NEHotspotConfigurationManager(); var wifiConfig = new NEHotspotConfiguration(ssid, password, false); wifiManager.ApplyConfiguration(wifiConfig, (error) => { ret = error == null; }); } catch (Exception ex) { } return(ret); }
public void ConnectToWifi(string ssid, string password) { var wifiManager = new NEHotspotConfigurationManager(); var wifiConfig = new NEHotspotConfiguration(ssid, password, false); wifiManager.ApplyConfiguration(wifiConfig, (error) => { if (error != null) { //var dismissed = UIAlertAction(); var alert = UIAlertController.Create(ssid, password, UIAlertControllerStyle.Alert); alert.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, (UIAlertAction obj) => { })); var rootVC = UIApplication.SharedApplication.Windows[0].RootViewController; rootVC.PresentViewController(alert, true, null); Console.WriteLine($"Error while connecting to WiFi network {ssid}: {error}"); } }); }
private async void ConnectToWifi() { try { var config = new NEHotspotConfiguration("THETAYL02102089.OSC", "02102089", false) { JoinOnce = true }; var configManager = new NEHotspotConfigurationManager(); await configManager.ApplyConfigurationAsync(config); Console.WriteLine("Connected"); } catch (Foundation.NSErrorException error) { var kek = error; } catch (Exception e) { var kek = e; } }
public bool ConnectToWifi(string ssid, string password) { try { System.Diagnostics.Debug.WriteLine("connecting to network " + ssid); var wifiConfig = new NEHotspotConfiguration(ssid, password, false); wifiConfig.JoinOnce = true; var wifiManager = new NEHotspotConfigurationManager(); wifiManager.ApplyConfiguration(wifiConfig, (error) => { if (error != null) { System.Diagnostics.Debug.WriteLine("error while connecting to network " + ssid + ", error: " + error); } }); return(true); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("connection error, ex=" + ex); return(false); } }
public WifiConnector() { this._wifiManager = new NEHotspotConfigurationManager(); }