public void Connect(string ssid, string passphrase = null) { var conf = new WifiConfiguration { Ssid = $"\"{ssid}\"" }; // very important for unprotected networks otherwise connection doesn't go on if (passphrase == null) { conf.AllowedKeyManagement.Set((int)KeyManagementType.None); } else { conf.AllowedKeyManagement.Set((int)KeyManagementType.WpaPsk); conf.PreSharedKey = $"\"{passphrase}\""; } var netId = Wifi.AddNetwork(conf); currentNetwork = Wifi.ConnectionInfo.NetworkId; Wifi.Disconnect(); var connected = Wifi.EnableNetwork(netId, true); if (connected) { Wifi.Reconnect(); } }
protected override void OnCreate(Bundle savedInstanceState) { TabLayoutResource = Resource.Layout.Tabbar; ToolbarResource = Resource.Layout.Toolbar; base.OnCreate(savedInstanceState); // Prepare sensors Bluetooth.PrepareRegister(); Wifi.PrepareRegister(); /* * Request necessary permissions */ ActivityCompat.RequestPermissions(this, new[] { Manifest.Permission.Bluetooth, Manifest.Permission.BluetoothAdmin, Manifest.Permission.AccessCoarseLocation, Manifest.Permission.AccessFineLocation, Manifest.Permission.ChangeWifiState, Manifest.Permission.AccessWifiState }, 1); // Start Xamarin App Xamarin.Essentials.Platform.Init(this, savedInstanceState); global::Xamarin.Forms.Forms.Init(this, savedInstanceState); LoadApplication(new App()); }
private double computeScore(Place placeToCheck, ICollection <Wifi> currentWifis) { //the idea is to compute a score based on netfound/ncheck * sum((powcheck-pownet)^2) //NO! the fact is that we watn to look at similar network, our score system is max high, so we want to reward the one with the smallest distance between the 2 networks -> 100- diff //Working //Experimental: introduction of a coefficent for weighing networks: the power of t should be multiplied by a weight based on the power of the network present in list //a snapshot with a network which is heard 95 should be far more important then a newtork heard 20 //tr1::unordered_map<string,SingleNetwork>::iterator itList; //tr1::unordered_map<string,SingleNetwork>::iterator itCheck; //itList = listOfNetworks.begin(); double totalDiff = 0; float nNetFound = 0; //iterate on all current networks foreach (Wifi currentWifi in currentWifis) { //look for a current network in networks of the place to check Wifi storedWifi = placeToCheck.Wifis[currentWifi.MAC] as Wifi; if (storedWifi != null) { //found double t = 100 - Math.Abs((currentWifi.PowerPerc - storedWifi.PowerPerc)); double weigth = computeWeigthForPower(storedWifi.PowerPerc); totalDiff += Math.Pow(t, 2.0) * weigth; //totalDiff+=pow(t, 2); nNetFound += 1; //cout << "Match for " << nameNetCheck << "computed t=" << t << endl; } } //cout << "TotalDiff is " << totalDiff << " found " << nNetFound << " over " << check->listOfNetworks.size() << endl; return((nNetFound / currentWifis.Count) * totalDiff); }
private void backgroundWorker_wifi_DoWork(object sender, DoWorkEventArgs e) { Wifi wifi = new Wifi(); while (true) { try { //get list of access points accessPoints = wifi.GetAccessPoints(); //scan for ardrone foreach (AccessPoint ap in accessPoints) { if (ap.Name.StartsWith("ardrone_")) { //verify connection if (!ap.IsConnected) { //connect if not connected AuthRequest authRequest = new AuthRequest(ap); ap.Connect(authRequest); break; } } } backgroundWorker_wifi.ReportProgress(1); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } Thread.Sleep(500); } }
private void wifi_connect_button_Click(object sender, RoutedEventArgs e) { Wifi wifi = new Wifi(); // get list of access points IEnumerable <AccessPoint> accessPoints = wifi.GetAccessPoints(); // for each access point from list foreach (AccessPoint ap in accessPoints) { if (ap.IsConnected) { wifiConnect selectedItem = (wifiConnect)wifi_listView.SelectedItem; wifi_password_label.Content = "Already connected to " + selectedItem.AccesPoint; return; } else { wifiConnect selectedAp = (wifiConnect)wifi_listView.SelectedItem; if (ap.Name.StartsWith(selectedAp.AccesPoint)) { wifi_password_label.Content = ("Trying to connect..\r\n"); //AuthRequest authRequest = new AuthRequest(ap); //authRequest.Password = "******"; ConnectToWifi(ap, wifi_passwordBox.Password); } } } }
public MainPage() { this.InitializeComponent(); //Set IoT Hub & Azure Storage connection string from container for app settings IoTHubConnTextBox.Text = App.IOTHUBCONNSTRING; StorageConnTextBox.Text = App.STORAGECONNSTRING; if (App.IOTHUBCONNSTRING.Length > 0) { ListDevices(); SettingsGrid.Visibility = Visibility.Collapsed; } //Set root MainPage for all User Controls DeviceInfo.SetMainPage(this); Applications.SetMainPage(this); WindowsTelemetry.SetMainPage(this); WindowsUpdate.SetMainPage(this); Reboot.SetMainPage(this); TimeSettings.SetMainPage(this); Certificates.SetMainPage(this); DiagnosticLogs.SetMainPage(this); FactoryReset.SetMainPage(this); Wifi.SetMainPage(this); DHA.SetMainPage(this); }
public static void Start() { wifi = new Wifi(); Write(SESSION_OPENED); do { wifi._lastFailReason = ""; int input; string rawInput = Console.ReadLine(); if (!string.IsNullOrEmpty(rawInput)) { if (!int.TryParse(rawInput, out input)) { string s = new string(rawInput.ToCharArray()); Console.WriteLine("Warning! Received garbage input: " + "\"" + s + "\""); } else { Execute(input); } } else { Console.WriteLine("Warning! Received null or empty input."); } } while (true); }
private void ConnectToCam() { if (Servers.SelectedIndex < 0) { ShowSettingsPage(); return; } Settings settings = Settings.LoadSettings(Servers.Items[Servers.SelectedIndex]); IWifi wifi = new Wifi(); string server = wifi.GetSSID() == $"\"{settings.LocalSSID}\"" ? settings.LocalServerName : settings.RemoteServerName; string html = "<html><head><style>" + $"body{{Width:{CamWebView.Width - 16}px;Height:{CamWebView.Height - 16}px;}}" + $".loader{{left:{CamWebView.Width/2 - 8};margin:{CamWebView.Height/2 - 46}px auto;position:fixed;}}" + $"img{{width:{CamWebView.Width - 16};height:{CamWebView.Height - 16};position:fixed;}}" + "</style><link rel=\"stylesheet\" type=\"text/css\" href=\"car-cam.css\" /></head><body>" + "<div class=\"loader\">Loading...</div>" + $"<img class=\"camview\" src=\"http://{server}:{settings.CameraPort}/?action=stream\" onerror=\"this.src = '';\" />" + "</body></html>"; Device.BeginInvokeOnMainThread(() => CamWebView.LoadContent(html, DependencyService.Get <IBaseUrl>().Get())); }
public static bool connectwifi(string ssid, string password = "******", connectmode mode = connectmode.auto) { try { ssid = ssid.Trim(); Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); string wifitool = config.AppSettings.Settings["wifitool"].Value; string command = $"connect /ssid:{ssid} /password:{password} /username: /domain:"; string wifi_tool_path = Directory.GetFiles(AppDomain.CurrentDomain.BaseDirectory, wifitool, SearchOption.AllDirectories).FirstOrDefault(); if (wifi_tool_path != null) { var p = CatCore.runexe2(wifi_tool_path, command); p.Start(); p.WaitForExit(); Console.WriteLine(p.StandardOutput.ReadToEnd()); Console.WriteLine(p.StandardError.ReadToEnd()); var wifi = new Wifi(); if (wifi.GetAccessPoints().Where(x => x.IsConnected).Select(x => x.Name).FirstOrDefault() == ssid) { return(true); } } } catch (Exception e) { Console.WriteLine($"connectwifi FAIL"); //Console.WriteLine(e.ToString()); } return(false); }
private void Form1_Load(object sender, EventArgs e) { wifi = new Wifi(); wifi.ConnectionStatusChanged += wifi_ConnectionStatusChanged; Status(); btn_findwifi_Click(sender, e); }
private void Bingrid() { //List<Điện> listDien; //List<Nước> listNuoc; //List<Wifi> listWifi; //List<Rác> listRac; //List<Xe> listGiuXe; foreach (TextBox txt in pnlGiaTruoc.Controls) { txt.ReadOnly = true; } Điện dbDien = DB.Điện.FirstOrDefault(p => p.Mã_điện == "DD"); txtGiaDienTruoc.Text = dbDien.Giá_điện.ToString().Trim(); Nước dbNuoc = DB.Nước.FirstOrDefault(p => p.Mã_nước == "NN"); txtGiaNuocTruoc.Text = dbNuoc.Giá_nước.ToString().Trim(); Wifi dbWifi = DB.Wifis.FirstOrDefault(p => p.Mã_wifi == "WF"); txtGiaWifiTruoc.Text = dbWifi.Giá_wifi.ToString().Trim(); Xe dbXe = DB.Xes.FirstOrDefault(p => p.Mã_xe == "GX"); txtGiaXeTruoc.Text = dbXe.Giá_xe.ToString().Trim(); Rác dbRac = DB.Rác.FirstOrDefault(p => p.Mã_rác == "RC"); txtGiaRacTruoc.Text = dbRac.Giá_rác.ToString().Trim(); }
private void BtnCapnhat_Click_1(object sender, EventArgs e) { if (txtGiaDienSau.Text != "" || txtGiaNuocSau.Text != "" || txtGiaRacSau.Text != "" || txtGiaWifiSau.Text != "" | txtGiaXeSau.Text != "") { //List<Điện> listDV = DB.DỊch_vụ.ToList(); Điện dbGiaDien = DB.Điện.FirstOrDefault(p => p.Mã_điện == "DD"); Nước dbGiaNuoc = DB.Nước.FirstOrDefault(p => p.Mã_nước == "NN"); Xe dbGiaXe = DB.Xes.FirstOrDefault(p => p.Mã_xe == "GX"); Wifi dbWifi = DB.Wifis.FirstOrDefault(p => p.Mã_wifi == "WF"); Rác dbRac = DB.Rác.FirstOrDefault(p => p.Mã_rác == "RC"); dbGiaDien.Giá_điện = int.Parse(txtGiaDienSau.Text); dbGiaNuoc.Giá_nước = int.Parse(txtGiaNuocSau.Text); dbGiaXe.Giá_xe = int.Parse(txtGiaXeSau.Text); dbWifi.Giá_wifi = int.Parse(txtGiaWifiSau.Text); dbRac.Giá_rác = int.Parse(txtGiaRacSau.Text); DB.SaveChanges(); foreach (TextBox txt in pnlSau.Controls) { txt.Clear(); } Bingrid(); MessageBox.Show("Cập nhật thành công", "Thông báo"); } else { MessageBox.Show("Vui lòng nhập đầy đủ thông tin", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
static void Main(string[] args) { // Init wifi object and event handlers wifi = new Wifi(); wifi.ConnectionStatusChanged += wifi_ConnectionStatusChanged; if (wifi.NoWifiAvailable) { Console.WriteLine("\r\n-- NO WIFI CARD WAS FOUND --"); } string command = ""; do { Console.WriteLine("\r\n-- COMMAND LIST --"); Console.WriteLine("L. List access points"); Console.WriteLine("C. Connect"); Console.WriteLine("D. Disconnect"); Console.WriteLine("S. Status"); Console.WriteLine("X. Print profile XML"); Console.WriteLine("R. Remove profile"); Console.WriteLine("I. Show access point information"); Console.WriteLine("Q. Quit"); command = Console.ReadLine().ToLower(); Execute(command); } while (command != "q"); }
public static void Main() { _wifi = new Wifi(); if (_wifi.NoWifiAvailable) { Console.WriteLine("\r\n-- NO WIFI CARD WAS FOUND --"); } string command; do { Console.WriteLine("\r\n-- COMMAND LIST --"); Console.WriteLine("L. List access points"); Console.WriteLine("C. Connect"); Console.WriteLine("D. Disconnect"); Console.WriteLine("S. Status"); Console.WriteLine("X. Print profile XML"); Console.WriteLine("R. Remove profile"); Console.WriteLine("I. Show access point information"); Console.WriteLine("F. Find number of devices in each access point"); Console.WriteLine("Q. Quit"); command = Console.ReadLine()?.ToLower(); Execute(command); } while (command != "q"); }
private void wifi_listView_SelectionChanged(object sender, SelectionChangedEventArgs e) { if ((wifi_checkBox.IsChecked == true) && (wifi_listView.SelectedItem != null)) { wifiConnect selectedItem = (wifiConnect)wifi_listView.SelectedItem; if (selectedItem != null) { Wifi wifi = new Wifi(); IEnumerable <AccessPoint> accessPoints = wifi.GetAccessPoints(); // for each access point from list foreach (AccessPoint ap in accessPoints) { if (ap.Name.StartsWith(selectedItem.AccesPoint)) { //verify connection to desired SSID wifi_password_label.Content = ("connected:" + ap.Name + System.Environment.NewLine); wifi_password_label.Content += ("password needed: " + ap.IsConnected + System.Environment.NewLine); wifi_password_label.Content += ("profile" + ap.HasProfile + System.Environment.NewLine); } } } } }
private void btnBegin_Click(object sender, EventArgs e) { lblInfo.Visible = true; lstNetworks.Items.Clear(); //metroStyleManager1.Theme = MetroThemeStyle.Default; wifi = new Wifi(); accessPoints = wifi.GetAccessPoints().OrderByDescending(ap => ap.SignalStrength); foreach (AccessPoint ap in accessPoints) { if (ap.Name != "") { lstNetworks.Items.Add(ap.Name); lstNetworks.Items[lstNetworks.Items.Count - 1].SubItems.Add(ap.SignalStrength + "%"); string secure = "Unprotected"; if (ap.IsSecure) { secure = "Protected"; } lstNetworks.Items[lstNetworks.Items.Count - 1].SubItems.Add(secure); } } lstNetworks.Items[0].Focused = true; lstNetworks.Items[0].Selected = true; lstNetworks.Items[0].Checked = true; btnConnect.Visible = true; btnBegin.Text = "Refresh"; }
//PUT api/Wifi/5 public IHttpActionResult Put(int id, [FromBody] WifiVM wifi) { //check if the wifi and the id match if (wifi is null) { return(BadRequest(ErrorMsg.ItemDoesNotExist(TypeOfItems.Wifi))); } if (id != wifi.Id) { return(BadRequest(ErrorMsg.InvalidIdMatchingWith(TypeOfItems.Wifi))); } if (id <= 0) { return(BadRequest(ErrorMsg.InvalidId)); } //check if wifi is valid var isModelValid = wifi.IsModelValid(); if (!string.IsNullOrEmpty(isModelValid)) { return(BadRequest(isModelValid)); } //get current user id and modify wifi string userId = User.Identity.GetUserId(); Wifi wifiToBeModified = db.Wifis.FirstOrDefault(w => w.Id == id && w.UserId == userId); if (wifiToBeModified is null) { return(BadRequest(ErrorMsg.ItemNotFound(TypeOfItems.Wifi))); } wifiToBeModified.ModifyTo(wifi); db.SaveChanges(); return(Ok()); }
public ActionResult DeleteConfirmed(int id) { Wifi wifi = db.AgendaEventos.Find(id); db.AgendaEventos.Remove(wifi); db.SaveChanges(); return(RedirectToAction("Index")); }
// ReSharper restore InconsistentNaming // ReSharper restore UnusedMember.Global // ReSharper restore MemberCanBePrivate.Global public DeviceTest(MainForm form) { _wifi = new Wifi(); _wlanClient = new WlanClient(); _form = form; _form.UpdateTestStatusText(string.Empty); }
public static void CreateConnectionComponents() { TcpClient tcp = new TcpClient(); Wifi wifi = new Wifi(); ConnectBluegiga(tcp, wifi); SendClient(tcp, wifi); }
public void Deauth(Wifi w, string clientMAC) { //aireplay-ng -0 1 -a 00:14:6C:7E:40:80 -c 00:0F:B5:FD:FB:C2 ath0 if (clientMAC != "") { RunCommand("/usr/sbin/aireplay-ng", "-0 1 -a " + w.BSSID + " -c " + clientMAC + " " + GetInterfaceName()); } }
public MainWin() { InitializeComponent(); CheckForIllegalCrossThreadCalls = false; wifi = new Wifi(); wifi.ConnectionStatusChanged += Wifi_ConnectionStatusChanged; List(); }
private void Form1_Load(object sender, EventArgs e) { wifi = new Wifi(); wifi.ConnectionStatusChanged += wifi_ConnectionStatusChanged; linkLabel1.Links.Add(12, 7, "https://github.com/Tlgyt"); List(); label3.Text = "Status: idle"; }
public Form1() { wifi = new Wifi(); InitializeComponent(); ShowAPList(); timer_autorefresh.Start(); Logger.WriteLine("Программа запущена"); autoconnect_ap = ""; }
public IActionResult Post([FromBody] Wifi wifi) { using (var scope = new TransactionScope()) { _wifiRepository.InsertWifi(wifi); scope.Complete(); return(CreatedAtAction(nameof(Get), new { id = wifi.Id }, wifi)); } }
protected override void OnAppearing() { base.OnAppearing(); Wifi.wifiNetworks.Clear(); Bluetooth.bluetoothDevices.Clear(); Bluetooth.Register(); Wifi.Register(); receiverList.ItemsSource = new List <Receiver>(); }
private void ConnectToBroker() { if (Servers.SelectedIndex < 0) { ShowSettingsPage(); return; } if (_clientConnected) { return; } Settings settings = Settings.LoadSettings(Servers.Items[Servers.SelectedIndex]); if (!settings.EnableControls) { return; } IWifi wifi = new Wifi(); string server = wifi.GetSSID() == $"\"{settings.LocalSSID}\"" ? settings.LocalServerName : settings.RemoteServerName; string connectionString = $"tcp://{server}:{settings.MqttPort}"; Device.BeginInvokeOnMainThread(() => { if (!string.IsNullOrEmpty(settings.Username)) { client = MqttClientFactory.CreateClient(connectionString, Guid.NewGuid().ToString(), settings.Username, settings.Password); } else { client = MqttClientFactory.CreateClient(connectionString, Guid.NewGuid().ToString()); } client.Connected += ClientConnected; client.ConnectionLost += ClientConnectionLost; client.PublishArrived += ClientPublishArrived; IDeviceInfo device = new DeviceInfo(); string name = device.GetName(); try { client.Connect("car/DISCONNECT", QoS.BestEfforts, new MqttPayload(name), false, true); } catch (Exception ex) { Toaster(ex.Message, ToastPriority.Critical, ToastLength.Long); _clientConnected = false; } }); }
// Use this for initialization void Start() { controller = GetComponent<RoverMovementScript>(); wifi = GetComponent<Wifi>(); lidarRotative = GetComponent<LidarRotative>(); data = lidarRotative.GetData(); targetList = FindTargets(data); targetPosList = TripleToPos(targetList); obstaclesList = FindObstacles(data); objectList = FindObjects(data); }
public Form1() { InitializeComponent(); WiFlyIPAddress = IPAddress.Parse(ConfigurationManager.AppSettings["IPAddress"]); WiFlyPassword = ConfigurationManager.AppSettings["Password"]; WiFlyPortNumber = Convert.ToInt32(ConfigurationManager.AppSettings["PortNumber"]); MyWifi = new Wifi(); }
public static void Main() { wifi = new Wifi(); // listen to wifi changes wifi.ConnectionStatusChanged += wifi_connectionStatusChanged; NetworkChange.NetworkAddressChanged += new NetworkAddressChangedEventHandler(AddressChangedCallback); Console.WriteLine("Listening..."); Console.ReadLine(); }
private List<Wifi> createWifiPoints(String jsonDataString, Entry entry) { List<Wifi> wifiPoints = new List<Wifi>(); JArray jsonWifiPoints = JArray.Parse(jsonDataString); foreach (JObject jsonWifi in jsonWifiPoints) { Wifi wifi = new Wifi(); wifi.bssid = (string)jsonWifi["bssid"]; wifi.ssid = (string)jsonWifi["ssid"]; wifi.capabilities = (string)jsonWifi["capabilities"]; wifi.frequency = (int)jsonWifi["frequency"]; wifi.level = (int)jsonWifi["level"]; //insert wifi object. entry.Wifis.Add(wifi); wifiPoints.Add(wifi); } return wifiPoints; }