public async Task <bool> ConnectAsync() { try { if (!await WiFi.ConnectAsync()) { return(false); } StartVideoListener(); if (!await Client.BindPortAsync(handler, "Tello")) { return(false); } await Client.SendRawAsync(TelloCommand.CONN_REQ); await Task.Run(() => { while (!Connected) { Thread.Sleep(100); } }); return(true); } catch (Exception ex) { logger.LogError(ex.Message, ex); return(false); } }
public static DeviceConfig CreateChangeObject(DeviceConfig currentConfig, DeviceConfig newConfig) { var change = new DeviceConfig(); if (currentConfig.Name != newConfig.Name) { change.Name = newConfig.Name; } if (currentConfig.DeviceID != newConfig.DeviceID) { change.Name = newConfig.DeviceID; } if (!currentConfig.WiFi.Equals(newConfig.WiFi)) { change.WiFi = WiFi.CreateChangeObject(currentConfig.WiFi, newConfig.WiFi); } if (!currentConfig.MQTT.Equals(newConfig.MQTT)) { change.MQTT = MQTT.CreateChangeObject(currentConfig.MQTT, newConfig.MQTT); } if (!currentConfig.OTA.Equals(newConfig.OTA)) { change.OTA = OTA.CreateChangeObject(currentConfig.OTA, newConfig.OTA); } change.Settings = CreateChangeSettings(currentConfig.Settings, newConfig.Settings); return(change); }
public ActionResult AddDevice(string submitButton) { Device newDevice; switch (submitButton) { default: newDevice = new Lamp(false, BrightnessLevel.Low); break; case "Add Heater": newDevice = new Heater(false, HeatLevel.Low); break; case "Add Wi-Fi": newDevice = new WiFi(false); break; case "Add TV": newDevice = new TV(false, ChannelNumber.BBC, new StereoSystem(false, 0)); break; } id = (int)Session["NextId"]; id++; Session["NextId"] = id; deviceCollection = (Dictionary <int, Device>)Session["S"]; deviceCollection.Add(id, newDevice); Session["S"] = deviceCollection; return(RedirectToAction("Index")); }
public static async Task <TetheringState> SwitchTethering(bool enable) { var state = await Bluetooth.SwitchTethering(enable); await Tile.UpdateTile(state); switch (state) { case TetheringState.Enabled: await WiFi.WaitForWiFiConnection(); break; case TetheringState.Error: await ShowError(); break; case TetheringState.NoBluetooth: await ShowBluetoothError(); break; } return(state); }
private static void LocalSync() { Notification.Display($"Using Local Sync! WIFI CONNECT {HOME_SSID}!", Environment.UserName, TimeSpan.FromSeconds(10)); WiFi.Connect(HOME_SSID); var output = Shell.GetValue("rsync", $"-avh [email protected]:/mnt/SDA/SyncMusic/ /home/{Environment.UserName}/music/"); Notification.Display($"Synchronized Music!{Environment.NewLine}{output}", Environment.UserName, TimeSpan.FromSeconds(10)); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (!(value is int channelCenterFrequencyInKilohertz)) { return("-/-"); } return($"{WiFi.ConvertChannelFrequencyToGigahertz(channelCenterFrequencyInKilohertz)} GHz"); }
/* Translate the name of the accent */ public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (!(value is NetworkAuthenticationType type)) { return("-/-"); } return($"{WiFi.GetHumanReadableNetworkAuthenticationType(type)}"); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (!(value is WiFiPhyKind phyKind)) { return("-/-"); } return($"{WiFi.GetHumandReadablePhyKind(phyKind)} ({phyKind})"); }
public override int GetHashCode() { return ((Name != null ? Name.GetHashCode() : 0) + (DeviceID != null ? DeviceID.GetHashCode() : 0) + (WiFi != null ? WiFi.GetHashCode() : 0) + (MQTT != null ? MQTT.GetHashCode() : 0) + (OTA != null ? OTA.GetHashCode() : 0) + (Settings != null ? Settings.Select(item => (item.Key.GetHashCode() + item.Value.GetHashCode()).GetHashCode()).Sum(item => (long)item).GetHashCode() : 0)); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (!(value is WiFiNetworkInfo info)) { return("-/-"); } double ghz = WiFi.ConvertChannelFrequencyToGigahertz(info.ChannelCenterFrequencyInKilohertz) > 5 ? 5 : 2.4; return($"{ghz} GHz / Channel {WiFi.GetChannelFromChannelFrequency(info.ChannelCenterFrequencyInKilohertz)} ({info.NetworkRssiInDecibelMilliwatts} dBm)"); }
/// <summary> /// wifi /// </summary> protected void QR_wifi() { WiFi generator = new WiFi("Wifi_Name", "Wifi_Password", WiFi.Authentication.WPA); string payload = generator.ToString(); QRCodeGenerator qrGenerator = new QRCodeGenerator(); QRCodeData qrCodeData = qrGenerator.CreateQrCode(payload, QRCodeGenerator.ECCLevel.Q); QRCode qrCode = new QRCode(qrCodeData); QR = qrCode.GetGraphic(4, Color.Red, Color.Green, (Bitmap)Bitmap.FromFile("D:\\1122\\02\\NG\\1 (1).jpg")); QR_show.Image = QR.GetThumbnailImage(300, 300, null, IntPtr.Zero); }
private void btnTulsaGen_Click(object sender, RoutedEventArgs e) { WiFi generator = new WiFi("brenternet_att", "katieanna", WiFi.Authentication.WPA); string payload = generator.ToString(); QRCodeGenerator qrGenerator = new QRCodeGenerator(); QRCodeData qrCodeData = qrGenerator.CreateQrCode(payload, QRCodeGenerator.ECCLevel.Q); QRCode qrCode = new QRCode(qrCodeData); Bitmap qrCodeAsBitmap = qrCode.GetGraphic(20); imgTulsa.BeginInit(); imgTulsa.Source = BitmapToImageSource(qrCodeAsBitmap); imgTulsa.EndInit(); }
private void btnNormanGen_Click(object sender, RoutedEventArgs e) { WiFi generator = new WiFi("katiejordan", "blackbanana1", WiFi.Authentication.WPA); string payload = generator.ToString(); QRCodeGenerator qrGenerator = new QRCodeGenerator(); QRCodeData qrCodeData = qrGenerator.CreateQrCode(payload, QRCodeGenerator.ECCLevel.Q); QRCode qrCode = new QRCode(qrCodeData); Bitmap qrCodeAsBitmap = qrCode.GetGraphic(20); imgNorman.BeginInit(); imgNorman.Source = BitmapToImageSource(qrCodeAsBitmap); imgNorman.EndInit(); }
private void generateQR() { barcodegcode = ""; QRCodeGenerator qrGenerator = new QRCodeGenerator(); QRCodeData qrCodeData; if (tCQRPayload.SelectedIndex == 0) { Logger.Trace("TabControl 0"); qrCodeData = qrGenerator.CreateQrCode(tBQRText.Text, QRCodeGenerator.ECCLevel.Q); } else if (tCQRPayload.SelectedIndex == 1) { Logger.Trace("TabControl 1"); Url generator = new Url(tBQRURL.Text); string payload = generator.ToString(); qrCodeData = qrGenerator.CreateQrCode(payload, QRCodeGenerator.ECCLevel.Q); } else //if (tCQRPayload.SelectedIndex == 2) { Logger.Trace("TabControl 2"); WiFi.Authentication auth = WiFi.Authentication.nopass; if (rBWLAN1.Checked) { auth = WiFi.Authentication.WPA; } if (rBWLAN2.Checked) { auth = WiFi.Authentication.WEP; } WiFi generator = new WiFi(tBWLAN1.Text, tBWLAN2.Text, auth, cBWLAN1.Checked); string payload = generator.ToString(); qrCodeData = qrGenerator.CreateQrCode(payload, QRCodeGenerator.ECCLevel.Q); } QRCode qrCode = new QRCode(qrCodeData); if (cBInsertLogo.Checked) { qrCodeImage = qrCode.GetGraphic((int)Properties.Settings.Default.importBarcode2DLines, System.Drawing.Color.Black, System.Drawing.Color.White, (System.Drawing.Bitmap)pictureBox3.Image); } else { qrCodeImage = qrCode.GetGraphic((int)Properties.Settings.Default.importBarcode2DLines); // pixel per module } pictureBox2.Image = qrCodeImage; btnClipboardBarcode2D.Visible = true; }
void LoadVals() { Props.Add(PropMethods.GetHostName()); Props.Add(PropMethods.GetName()); Props.Add(PropMethods.GetModel()); Props.Add(PropMethods.GetDeviceType()); Props.Add(PropMethods.GetIdiom()); Props.Add(PropMethods.GetManufacturer()); Props.Add(PropMethods.GetPlatform()); Props.Add(PropMethods.GetVersion()); Props.Add(PropMethods.GetSerialNumber()); Props.Add(PropMethods.GetBuildVersion()); WiFi.Add(PropMethods.GetIpAddress()); }
public ExpensesModel() { WiFi = new WiFi(); Food = new Food(); Electricity = new Electricity(); Fun = new Fun(); Gas = new Gas(); GymMembership = new GymMembership(); StudentLoans = new Loans(); Rent = new Rent(); PhoneBill = new Phone(); CarInsurance = new CarInsurance(); CarPayment = new CarPayment(); HuluSpotify = new HuluSpotify(); }
public IActionResult GetWIFIQRCode(int pixel) { if (pixel <= 0) { return(BadRequest("pixel <= 0")); } var payload = new WiFi("ssid", "password", WiFi.Authentication.WPA); var bitmap = _qrCode.GetQRCode(payload.ToString(), pixel); var ms = new MemoryStream(); bitmap.Save(ms, ImageFormat.Jpeg); return(File(ms.GetBuffer(), "image/jpeg")); }
public WiFiReconnecter(Wifi oWiFi = null) { WriteToConsole(ConsoleType.ServiceStart); WiFi = oWiFi ?? new Wifi(); oAPs = WiFi?.GetAccessPoints()?.Where(x => x.HasProfile).ToList(); oAP = oAPs.Where(x => x.IsConnected)?.FirstOrDefault(); if (oAP == null && CheckForProblems()) { return; } WiFi.ConnectionStatusChanged += WiFi_ConnectionStatusChanged; WriteToConsole(ConsoleType.WiFiConnected); }
private static void Network() { RunningConfiguration.Network.NetworkInterfaces = cmds.Network.Get(); cmds.Network.SetTuns(); cmds.Network.SetTaps(); Brctl.Apply(); Bond.Apply(); RunningConfiguration.Network.NetworkInterfaces = cmds.Network.Get(); cmds.Network.Prepare(); WiFi.Apply(); cmds.Network.Set(); cmds.Network.ApplyNetwork(CurrentConfiguration.Network.InternalNetwork); cmds.Network.ApplyNetwork(CurrentConfiguration.Network.ExternalNetwork); Route.SetRoutingTable(); Route.Set(); ConsoleLogger.Log("[network] ready"); }
public void GenerateWIFIQR(System.Windows.Controls.Image imageViewer) { string ssid = mainWindow.wifiData.WifiSSID; string password = mainWindow.wifiData.WifiPassword; SpongeQR.Types.WIFIAuthTypes authMode = mainWindow.wifiData.WifiAuthType; WiFi.Authentication auth = CheckWIFIAuthTypeSelected(authMode); WiFi generator = new WiFi(ssid, password, auth); string payload = generator.ToString(); Console.WriteLine(payload); QRCode qrCode = GenerateQRData(payload); ConvertBitmapToSourceAndDisplay(qrCodeImage, qrCode, Bitmapsource, imageViewer); }
public WiFiModule() : base("/wifi") { Get["/"] = x => { return JsonConvert.SerializeObject(Application.CurrentConfiguration.Network.WpaSupplicant); }; Post["/save"] = x => { string data = Request.Form.Data; var objects = JsonConvert.DeserializeObject<WpaSupplicant>(data); Application.CurrentConfiguration.Network.WpaSupplicant = objects; ConfigRepo.Save(); return HttpStatusCode.OK; }; Post["/apply"] = x => { WiFi.Apply(); return HttpStatusCode.OK; }; }
public static WiFi CreateChangeObject(WiFi currentWiFi, WiFi newWiFi) { var change = new WiFi(); if (currentWiFi.SSID != newWiFi.SSID) { change.SSID = newWiFi.SSID; } if (currentWiFi.Password != newWiFi.Password) { change.Password = newWiFi.Password; } if (currentWiFi.BSSID != newWiFi.BSSID) { change.BSSID = newWiFi.BSSID; } if (currentWiFi.Channel != newWiFi.Channel) { change.Channel = newWiFi.Channel; } if (currentWiFi.IP != newWiFi.IP) { change.IP = newWiFi.IP; } if (currentWiFi.Mask != newWiFi.Mask) { change.Mask = newWiFi.Mask; } if (currentWiFi.GW != newWiFi.GW) { change.GW = newWiFi.GW; } if (currentWiFi.DNS1 != newWiFi.DNS1) { change.DNS1 = newWiFi.DNS1; } if (currentWiFi.DNS2 != newWiFi.DNS2) { change.DNS2 = newWiFi.DNS2; } return(change); }
public Byte[] GererarQR() { WiFi wifi = new WiFi("nombredelared", "lapass", WiFi.Authentication.WPA); QRCodeGenerator qrGenerator = new QRCodeGenerator(); QRCodeData qrCodeData = qrGenerator.CreateQrCode(wifi, QRCodeGenerator.ECCLevel.Q); QRCode qrCode = new QRCode(qrCodeData); Bitmap qrCodeAsByteArray; using (var qrBitmap = new BitmapByteQRCode(qrCodeData)) { qrCodeAsByteArray = qrCode.GetGraphic(20, "#FF0000", "#FFFFFF"); MemoryStream stream = new MemoryStream(); qrCodeAsByteArray.Save(stream, ImageFormat.Png); byte[] result = stream.ToArray(); return(result); } }
static void Main(string[] args) { var parser = new FluentCommandLineParser(); string ssid = ""; string password = ""; string filename = "wifi.png"; parser.IsCaseSensitive = false; parser .Setup <string>('s', "SSID") .Callback(v => ssid = v) .Required(); parser.Setup <string>('p', "password") .Callback(v => password = v); parser.Setup <string>('f', "filename") .Callback(v => filename = v); var result = parser.Parse(args); if (result.HasErrors) { Console.Error.WriteLine(result.ErrorText); } else { var obfuscatedPassword = string.Join( string.Empty, Enumerable.Repeat('*', password.Length)); Console.WriteLine($"{ssid}:{obfuscatedPassword}"); } WiFi generator = new WiFi(ssid, password, WiFi.Authentication.WPA); string payload = generator.ToString(); QRCodeGenerator qrGenerator = new QRCodeGenerator(); QRCodeData qrCodeData = qrGenerator.CreateQrCode(payload, QRCodeGenerator.ECCLevel.Q); QRCode qrCode = new QRCode(qrCodeData); var qrCodeAsBitmap = qrCode.GetGraphic(20); qrCodeAsBitmap.Save(filename, ImageFormat.Png); }
public static void Main() { // Netduino 3 D7 pin // PinNumber is a local method GpioPin D7 = GpioController.GetDefault().OpenPin(PinNumber('A', 1)); // Netduino 3 D8 pin GpioPin D8 = GpioController.GetDefault().OpenPin(PinNumber('A', 0)); // Local method not used in testing // Use if needed // ResetDevice(D7, D8); // Constructor for ESP8266 serial WiFi WiFi ESP8266 = new WiFi(); // Get firmware version ESP8266.GetVersion(); ESP8266.Connect("SSID", "Password"); //***Rem Uncomment to set time //ESP8266.SetTime(); ESP8266.StartServer(); //***Rem Uncomment for AP mode // ESP8266.StartAPMode(); Console.WriteLine("IP Address: >> " + ESP8266.GetIPAddress()); while (true) { Thread.Sleep(1000); } }
private async Task <QRCodeData> GenerateWifiQrCode(CreateWifiModel model) { var wifi = new WiFi(model.Ssid, model.Password, model.Authentication, model.Hidden); return(await GenerateAsync(wifi)); }
private void GenerateQRForWifi(string name, string password, string auth) { try { using (FolderBrowserDialog f = new FolderBrowserDialog()) { // if this is empty then this will not execute : // TODO : Check the pass only on WPA or WEP if (auth == "nopass") { WiFi generator = new WiFi(name, password, WiFi.Authentication.nopass); string payload = generator.ToString(); QRCodeGenerator qrGenerator = new QRCodeGenerator(); QRCodeData qrCodeData = qrGenerator.CreateQrCode(payload, QRCodeGenerator.ECCLevel.Q); QRCode qrCode = new QRCode(qrCodeData); Bitmap qrCodeAsBitmap = qrCode.GetGraphic(20); if (save_image_wifi == true) { if (f.ShowDialog() == DialogResult.OK) { qrCodeAsBitmap.Save(Path.Combine(f.SelectedPath, "qr-code-wifi-no-pass.png")); } } pictureBoxWifi.Image = qrCodeAsBitmap; //free ram qrGenerator.Dispose(); qrCodeData.Dispose(); qrCode.Dispose(); Clear(); } else if (auth == "WPA") { WiFi generator = new WiFi(name, password, WiFi.Authentication.WPA); string payload = generator.ToString(); QRCodeGenerator qrGenerator = new QRCodeGenerator(); QRCodeData qrCodeData = qrGenerator.CreateQrCode(payload, QRCodeGenerator.ECCLevel.Q); QRCode qrCode = new QRCode(qrCodeData); Bitmap qrCodeAsBitmap = qrCode.GetGraphic(20); if (save_image_wifi == true) { if (f.ShowDialog() == DialogResult.OK) { qrCodeAsBitmap.Save(Path.Combine(f.SelectedPath, "qr-code-wifi-pass.png")); } } pictureBoxWifi.Image = qrCodeAsBitmap; qrGenerator.Dispose(); qrCodeData.Dispose(); qrCode.Dispose(); Clear(); } else if (auth == "WEP") { WiFi generator = new WiFi(name, password, WiFi.Authentication.WEP); string payload = generator.ToString(); QRCodeGenerator qrGenerator = new QRCodeGenerator(); QRCodeData qrCodeData = qrGenerator.CreateQrCode(payload, QRCodeGenerator.ECCLevel.Q); QRCode qrCode = new QRCode(qrCodeData); Bitmap qrCodeAsBitmap = qrCode.GetGraphic(20); if (save_image_wifi == true) { if (f.ShowDialog() == DialogResult.OK) { qrCodeAsBitmap.Save(Path.Combine(f.SelectedPath, "qr-code-wifi-pass.png")); } } pictureBoxWifi.Image = qrCodeAsBitmap; qrGenerator.Dispose(); qrCodeData.Dispose(); qrCode.Dispose(); Clear(); } } } catch (Exception e) { MetroSetMessageBox.Show(this, "An error : " + e.Message, "QR Creator"); } }
public string GetLocation(WiFi wifi, _3G thirdGeneration, GPS gps) { return(_geolocation.GetLocation(wifi, thirdGeneration, gps)); }