From 1f4fba4890eaefbd86223160a716dd909bc3d80b Mon Sep 17 00:00:00 2001 From: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com> Date: Sun, 17 Nov 2024 03:27:16 +0100 Subject: [PATCH 1/2] Feature: Support WiFi 6 GHz & WPA3 --- .../NETworkManager.Controls.csproj | 2 +- .../NETworkManager.Converters.csproj | 2 +- .../NETworkManager.Documentation.csproj | 2 +- .../NETworkManager.Localization.csproj | 2 +- .../NETworkManager.Models.csproj | 4 +- Source/NETworkManager.Models/Network/WiFi.cs | 152 ++++++++++-------- .../Network/WiFiNetworkInfo.cs | 8 +- .../Network/WiFiRadio.cs | 5 +- .../NETworkManager.Profiles.csproj | 2 +- .../NETworkManager.Settings.csproj | 2 +- .../NETworkManager.Update.csproj | 2 +- .../NETworkManager.Utilities.WPF.csproj | 2 +- .../NETworkManager.Utilities.csproj | 2 +- .../NETworkManager.Validators.csproj | 2 +- Source/NETworkManager/NETworkManager.csproj | 4 +- .../ViewModels/WiFiViewModel.cs | 117 ++++++++------ Source/NETworkManager/Views/WiFiView.xaml | 8 +- Website/docs/changelog/next-release.md | 11 +- 18 files changed, 188 insertions(+), 141 deletions(-) diff --git a/Source/NETworkManager.Controls/NETworkManager.Controls.csproj b/Source/NETworkManager.Controls/NETworkManager.Controls.csproj index 668aa79d8a..c3dd726682 100644 --- a/Source/NETworkManager.Controls/NETworkManager.Controls.csproj +++ b/Source/NETworkManager.Controls/NETworkManager.Controls.csproj @@ -4,7 +4,7 @@ Library NETworkManager.Controls NETworkManager.Controls - net8.0-windows10.0.17763.0 + net8.0-windows10.0.22621.0 win-x64 x64 false diff --git a/Source/NETworkManager.Converters/NETworkManager.Converters.csproj b/Source/NETworkManager.Converters/NETworkManager.Converters.csproj index 1ac69706c1..73e9677188 100644 --- a/Source/NETworkManager.Converters/NETworkManager.Converters.csproj +++ b/Source/NETworkManager.Converters/NETworkManager.Converters.csproj @@ -5,7 +5,7 @@ Properties NETworkManager.Converters NETworkManager.Converters - net8.0-windows10.0.17763.0 + net8.0-windows10.0.22621.0 win-x64 x64 false diff --git a/Source/NETworkManager.Documentation/NETworkManager.Documentation.csproj b/Source/NETworkManager.Documentation/NETworkManager.Documentation.csproj index 5001ab13ba..f09f4d2c47 100644 --- a/Source/NETworkManager.Documentation/NETworkManager.Documentation.csproj +++ b/Source/NETworkManager.Documentation/NETworkManager.Documentation.csproj @@ -5,7 +5,7 @@ Properties NETworkManager.Documentation NETworkManager.Documentation - net8.0-windows10.0.17763.0 + net8.0-windows10.0.22621.0 win-x64 x64 false diff --git a/Source/NETworkManager.Localization/NETworkManager.Localization.csproj b/Source/NETworkManager.Localization/NETworkManager.Localization.csproj index 7e37d45d60..75c5b633c3 100644 --- a/Source/NETworkManager.Localization/NETworkManager.Localization.csproj +++ b/Source/NETworkManager.Localization/NETworkManager.Localization.csproj @@ -4,7 +4,7 @@ Library NETworkManager.Localization NETworkManager.Localization - net8.0-windows10.0.17763.0 + net8.0-windows10.0.22621.0 win-x64 x64 false diff --git a/Source/NETworkManager.Models/NETworkManager.Models.csproj b/Source/NETworkManager.Models/NETworkManager.Models.csproj index 4f58db3530..1e1f333c8a 100644 --- a/Source/NETworkManager.Models/NETworkManager.Models.csproj +++ b/Source/NETworkManager.Models/NETworkManager.Models.csproj @@ -1,10 +1,10 @@ - + {8A2859DC-38B6-4E9D-A6B2-1828DC6641B3} Library NETworkManager.Models NETworkManager.Models - net8.0-windows10.0.17763.0 + net8.0-windows10.0.22621.0 win-x64 x64 false diff --git a/Source/NETworkManager.Models/Network/WiFi.cs b/Source/NETworkManager.Models/Network/WiFi.cs index cf669af535..228f118c2b 100644 --- a/Source/NETworkManager.Models/Network/WiFi.cs +++ b/Source/NETworkManager.Models/Network/WiFi.cs @@ -1,26 +1,23 @@ -using System; +using log4net; +using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Windows.Devices.WiFi; using Windows.Networking.Connectivity; using Windows.Security.Credentials; -using log4net; - -//https://docs.microsoft.com/en-us/uwp/api/windows.devices.wifi.wifiadapter.requestaccessasync -//var access = await WiFiAdapter.RequestAccessAsync() == WiFiAccessStatus.Allowed; namespace NETworkManager.Models.Network; /// -/// Class with WiFi related methods. +/// Class with Wi-Fi related methods. /// public static class WiFi { private static readonly ILog Log = LogManager.GetLogger(typeof(WiFi)); /// - /// Get all WiFi adapters async with additional information from . + /// Get all Wi-Fi adapters async with additional information from . /// /// /// with and as @@ -58,7 +55,7 @@ public static async Task> GetAdapterAsync() } /// - /// Get all available WiFi networks for an adapter with additional information's. + /// Get all available Wi-Fi networks for an adapter with additional information's. /// /// WiFi adapter as . /// A report as including a list of . @@ -67,7 +64,7 @@ public static async Task GetNetworksAsync(WiFiAdapter adapt // Scan network adapter async await adapter.ScanAsync(); - // Try to get the current connected wifi network of this network adapter + // Try to get the current connected Wi-Fi network of this network adapter var (_, bssid) = TryGetConnectedNetworkFromWiFiAdapter(adapter.NetworkAdapter.NetworkAdapterId.ToString()); var wifiNetworkInfos = adapter.NetworkReport.AvailableNetworks.Select(availableNetwork => new WiFiNetworkInfo @@ -86,14 +83,14 @@ public static async Task GetNetworksAsync(WiFiAdapter adapt } /// - /// Try to get the current connected wifi network (SSID and BSSID) of a network adapter from + /// Try to get the current connected Wi-Fi network (SSID and BSSID) of a network adapter from /// netsh.exe. /// Calling netsh.exe and parsing the output feels so dirty, but Microsoft's API returns only /// the WLAN profile and the SSID of the connected network. The BSSID is needed to find a /// specific access point among several. /// - /// GUID of the WiFi network adapter. - /// SSID and BSSID of the connected wifi network. Values are null if not detected. + /// GUID of the Wi-Fi network adapter. + /// SSID and BSSID of the connected Wi-Fi network. Values are null if not detected. // ReSharper disable once UnusedTupleComponentInReturnValue private static (string SSID, string BSSID) TryGetConnectedNetworkFromWiFiAdapter(string adapterId) { @@ -151,10 +148,10 @@ private static (string SSID, string BSSID) TryGetConnectedNetworkFromWiFiAdapter } /// - /// Connect to a WiFi network with Pre-shared key, EAP or no security. + /// Connect to a Wi-Fi network with Pre-shared key, EAP or no security. /// - /// WiFi adapter which should be used for the connection. - /// WiFi network to connect to. + /// Wi-Fi adapter which should be used for the connection. + /// Wi-Fi network to connect to. /// Reconnection type to automatically or manuel reconnect. /// Credentials for EAP or PSK. Empty for open networks. /// SSID for hidden networks. @@ -178,10 +175,10 @@ public static async Task ConnectAsync(WiFiAdapter adapter, } /// - /// Connect to a WiFi network with WPS push button. + /// Connect to a Wi-Fi network with WPS push button. /// - /// WiFi adapter which should be used for the connection. - /// WiFi network to connect to. + /// Wi-Fi adapter which should be used for the connection. + /// Wi-Fi network to connect to. /// Reconnection type to automatically or manuel reconnect. /// public static async Task ConnectWpsAsync(WiFiAdapter adapter, WiFiAvailableNetwork network, @@ -199,25 +196,24 @@ public static async Task ConnectWpsAsync(WiFiAdapter adapt } /// - /// Disconnect the wifi adapter from the current wifi network. + /// Disconnect the Wi-Fi adapter from the current Wi-Fi network. /// - /// WiFi adapter from which the wifi network should be disconnected. + /// Wi-Fi adapter from which the Wi-Fi network should be disconnected. public static void Disconnect(WiFiAdapter adapter) { adapter.Disconnect(); } /// - /// Get the connect mode of a wifi network like Open, Eap (WPA2-Enterprise) + /// Get the connect mode of a Wi-Fi network like Open, Eap (WPA2-Enterprise) /// or Psk (WPA2-Personal). /// - /// WiFi network as . + /// Wi-Fi network as . /// Connect mode as . public static WiFiConnectMode GetConnectMode(WiFiAvailableNetwork network) { // Enterprise - if (network.SecuritySettings.NetworkAuthenticationType == NetworkAuthenticationType.Rsna || - network.SecuritySettings.NetworkAuthenticationType == NetworkAuthenticationType.Wpa) + if (network.SecuritySettings.NetworkAuthenticationType is NetworkAuthenticationType.Rsna or NetworkAuthenticationType.Wpa) return WiFiConnectMode.Eap; // Open @@ -230,11 +226,11 @@ public static WiFiConnectMode GetConnectMode(WiFiAvailableNetwork network) } /// - /// Check if WPS is available for a wifi network. + /// Check if WPS is available for a Wi-Fi network. /// /// WiFi adapter as . /// WiFi network as . - /// + /// Ture if WPS is available. public static async Task IsWpsAvailable(WiFiAdapter adapter, WiFiAvailableNetwork network) { var result = await adapter.GetWpsConfigurationAsync(network); @@ -243,7 +239,7 @@ public static async Task IsWpsAvailable(WiFiAdapter adapter, WiFiAvailable } /// - /// Get the WiFi channel from channel frequency. + /// Get the Wi-Fi channel from channel frequency. /// /// Input like 2422000 or 5240000. /// WiFi channel like 3 or 48. @@ -252,7 +248,7 @@ public static int GetChannelFromChannelFrequency(int kilohertz) return ConvertChannelFrequencyToGigahertz(kilohertz) switch { // 2.4 GHz - 2.412 => 1, + 2.412 => 1, 2.417 => 2, 2.422 => 3, 2.427 => 4, @@ -265,32 +261,33 @@ public static int GetChannelFromChannelFrequency(int kilohertz) 2.462 => 11, 2.467 => 12, 2.472 => 13, + 2.484 => 14, // Most countries do not allow this channel // 5 GHz - 5.180 => 36, - 5.200 => 40, - 5.220 => 44, - 5.240 => 48, - 5.260 => 52, - 5.280 => 56, - 5.300 => 60, - 5.320 => 64, - 5.500 => 100, - 5.520 => 104, - 5.540 => 108, - 5.560 => 112, - 5.580 => 116, - 5.600 => 120, - 5.620 => 124, - 5.640 => 128, - 5.660 => 132, - 5.680 => 136, - 5.700 => 140, - 5.720 => 144, - 5.745 => 149, - 5.765 => 153, - 5.785 => 157, - 5.805 => 161, - 5.825 => 165, + 5.180 => 36, // UNII-1 + 5.200 => 40, // UNII-1 + 5.220 => 44, // UNII-1 + 5.240 => 48, // UNII-1 + 5.260 => 52, // UNII-2, DFS + 5.280 => 56, // UNII-2, DFS + 5.300 => 60, // UNII-2, DFS + 5.320 => 64, // UNII-2, DFS + 5.500 => 100, // UNII-2 Extended, DFS + 5.520 => 104, // UNII-2 Extended, DFS + 5.540 => 108, // UNII-2 Extended, DFS + 5.560 => 112, // UNII-2 Extended, DFS + 5.580 => 116, // UNII-2 Extended, DFS + 5.600 => 120, // UNII-2 Extended, DFS + 5.620 => 124, // UNII-2 Extended, DFS + 5.640 => 128, // UNII-2 Extended, DFS + 5.660 => 132, // UNII-2 Extended, DFS + 5.680 => 136, // UNII-2 Extended, DFS + 5.700 => 140, // UNII-2 Extended, DFS + 5.720 => 144, // UNII-2 Extended, DFS + 5.745 => 149, // UNII-3 + 5.765 => 153, // UNII-3 + 5.785 => 157, // UNII-3 + 5.805 => 161, // UNII-3 + 5.825 => 165, // UNII-3 _ => -1 }; } @@ -306,69 +303,82 @@ public static double ConvertChannelFrequencyToGigahertz(int kilohertz) } /// - /// Check if the WiFi network is a 2.4 GHz network. + /// Check if the Wi-Fi network is a 2.4 GHz network. /// /// Frequency in kilohertz like 2422000 or 5240000. - /// True if WiFi network is 2.4 GHz. + /// True if Wi-Fi network is 2.4 GHz. public static bool Is2dot4GHzNetwork(int kilohertz) { var x = ConvertChannelFrequencyToGigahertz(kilohertz); - return x is >= 2.412 and <= 2.472; + return x is >= 2.412 and <= 2.484; } /// - /// Check if the WiFi network is a 5 GHz network. + /// Check if the Wi-Fi network is a 5 GHz network. /// /// Frequency in kilohertz like 2422000 or 5240000. - /// True if WiFi network is 5 GHz. + /// True if Wi-Fi network is 5 GHz. public static bool Is5GHzNetwork(int kilohertz) { var x = ConvertChannelFrequencyToGigahertz(kilohertz); return x is >= 5.180 and <= 5.825; } + + public static bool Is6GHzNetwork(int kilohertz) + { + var x = ConvertChannelFrequencyToGigahertz(kilohertz); + + return x is >= 5.925 and <= 7.125; + } /// - /// Get the human readable network authentication type. + /// Get the human-readable network authentication type. /// - /// WiFi network authentication type as . - /// Human readable authentication type as string like "Open" or "WPA2 Enterprise". + /// Wi-Fi network authentication type as . + /// Human-readable authentication type as string like "Open" or "WPA2 Enterprise". public static string GetHumanReadableNetworkAuthenticationType(NetworkAuthenticationType networkAuthenticationType) { return networkAuthenticationType switch { + NetworkAuthenticationType.None => "-/-", + NetworkAuthenticationType.Unknown => "Unknown", NetworkAuthenticationType.Open80211 => "Open", - NetworkAuthenticationType.Rsna => "WPA2 Enterprise", - NetworkAuthenticationType.RsnaPsk => "WPA2 PSK", + NetworkAuthenticationType.SharedKey80211 => "WEP", NetworkAuthenticationType.Wpa => "WPA Enterprise", - NetworkAuthenticationType.WpaNone => "WPA None", NetworkAuthenticationType.WpaPsk => "WPA PSK", - NetworkAuthenticationType.SharedKey80211 => "WEP", + NetworkAuthenticationType.WpaNone => "WPA None", + NetworkAuthenticationType.Rsna => "WPA2 Enterprise", + NetworkAuthenticationType.RsnaPsk => "WPA2 Personal (PSK)", NetworkAuthenticationType.Ihv => "IHV", - NetworkAuthenticationType.Unknown => "Unknown", - NetworkAuthenticationType.None => "-/-", + NetworkAuthenticationType.Wpa3Enterprise192Bits => "WPA3 Enterprise (192-bit)", // Same as Wpa3 + NetworkAuthenticationType.Wpa3Sae => "WPA3 Personal (SAE)", + NetworkAuthenticationType.Owe => "OWE", + NetworkAuthenticationType.Wpa3Enterprise => "WPA3 Enterprise", _ => "-/-" }; } /// - /// Get the human readable network phy kind. + /// Get the human-readable network phy kind. /// - /// WiFi network phy kind as . - /// Human readable phy kind as string like "802.11g" or "802.11ax". + /// Wi-Fi network phy kind as . + /// Human-readable phy kind as string like "802.11g" or "802.11ax". public static string GetHumanReadablePhyKind(WiFiPhyKind phyKind) { return phyKind switch { + WiFiPhyKind.Unknown => "Unknown", WiFiPhyKind.Dsss or WiFiPhyKind.Fhss => "802.11", WiFiPhyKind.Ofdm => "802.11a", WiFiPhyKind.Hrdsss => "802.11b", WiFiPhyKind.Erp => "802.11g", WiFiPhyKind.HT => "802.11n", - WiFiPhyKind.Dmg => "802.11ad", WiFiPhyKind.Vht => "802.11ac", + WiFiPhyKind.Dmg => "802.11ad", WiFiPhyKind.HE => "802.11ax", + WiFiPhyKind.Eht => "802.11be", _ => "-/-" }; } diff --git a/Source/NETworkManager.Models/Network/WiFiNetworkInfo.cs b/Source/NETworkManager.Models/Network/WiFiNetworkInfo.cs index fd54ceb05c..2be198e2d2 100644 --- a/Source/NETworkManager.Models/Network/WiFiNetworkInfo.cs +++ b/Source/NETworkManager.Models/Network/WiFiNetworkInfo.cs @@ -3,7 +3,7 @@ namespace NETworkManager.Models.Network; /// -/// Class contains information about a WiFi network. +/// Class contains information about a Wi-Fi network. /// public class WiFiNetworkInfo { @@ -17,17 +17,17 @@ public WiFiNetworkInfo() #region Variables /// - /// Information's about an available WiFi network. + /// Information's about an available Wi-Fi network. /// public WiFiAvailableNetwork AvailableNetwork { get; init; } /// - /// Indicates if the WiFi network Ssid is hidden. + /// Indicates if the Wi-Fi network Ssid is hidden. /// public bool IsHidden { get; set; } /// - /// Indicates if the WiFi network is connected to the current WiFi adapter. + /// Indicates if the Wi-Fi network is connected to the current WiFi adapter. /// public bool IsConnected { get; set; } diff --git a/Source/NETworkManager.Models/Network/WiFiRadio.cs b/Source/NETworkManager.Models/Network/WiFiRadio.cs index 2a067f202e..df2ed44c53 100644 --- a/Source/NETworkManager.Models/Network/WiFiRadio.cs +++ b/Source/NETworkManager.Models/Network/WiFiRadio.cs @@ -2,6 +2,7 @@ public enum WiFiRadio { - One, - Two + Radio2dot4GHz, + Radio5GHz, + Radio6GHz } \ No newline at end of file diff --git a/Source/NETworkManager.Profiles/NETworkManager.Profiles.csproj b/Source/NETworkManager.Profiles/NETworkManager.Profiles.csproj index e3f4a0fa4c..b9c05af8ac 100644 --- a/Source/NETworkManager.Profiles/NETworkManager.Profiles.csproj +++ b/Source/NETworkManager.Profiles/NETworkManager.Profiles.csproj @@ -4,7 +4,7 @@ Library NETworkManager.Profiles NETworkManager.Profiles - net8.0-windows10.0.17763.0 + net8.0-windows10.0.22621.0 win-x64 x64 false diff --git a/Source/NETworkManager.Settings/NETworkManager.Settings.csproj b/Source/NETworkManager.Settings/NETworkManager.Settings.csproj index aca5fef161..b0001af478 100644 --- a/Source/NETworkManager.Settings/NETworkManager.Settings.csproj +++ b/Source/NETworkManager.Settings/NETworkManager.Settings.csproj @@ -4,7 +4,7 @@ Library NETworkManager.Settings NETworkManager.Settings - net8.0-windows10.0.17763.0 + net8.0-windows10.0.22621.0 win-x64 x64 false diff --git a/Source/NETworkManager.Update/NETworkManager.Update.csproj b/Source/NETworkManager.Update/NETworkManager.Update.csproj index 48b59ddba1..bfbfd77521 100644 --- a/Source/NETworkManager.Update/NETworkManager.Update.csproj +++ b/Source/NETworkManager.Update/NETworkManager.Update.csproj @@ -5,7 +5,7 @@ Properties NETworkManager.Update NETworkManager.Update - net8.0-windows10.0.17763.0 + net8.0-windows10.0.22621.0 win-x64 x64 false diff --git a/Source/NETworkManager.Utilities.WPF/NETworkManager.Utilities.WPF.csproj b/Source/NETworkManager.Utilities.WPF/NETworkManager.Utilities.WPF.csproj index e096b141d5..9720bd4d1c 100644 --- a/Source/NETworkManager.Utilities.WPF/NETworkManager.Utilities.WPF.csproj +++ b/Source/NETworkManager.Utilities.WPF/NETworkManager.Utilities.WPF.csproj @@ -4,7 +4,7 @@ Library NETworkManager.Utilities.WPF NETworkManager.Utilities.WPF - net8.0-windows10.0.17763.0 + net8.0-windows10.0.22621.0 win-x64 x64 false diff --git a/Source/NETworkManager.Utilities/NETworkManager.Utilities.csproj b/Source/NETworkManager.Utilities/NETworkManager.Utilities.csproj index dea812626f..915aa92efd 100644 --- a/Source/NETworkManager.Utilities/NETworkManager.Utilities.csproj +++ b/Source/NETworkManager.Utilities/NETworkManager.Utilities.csproj @@ -4,7 +4,7 @@ Library NETworkManager.Utilities NETworkManager.Utilities - net8.0-windows10.0.17763.0 + net8.0-windows10.0.22621.0 win-x64 x64 false diff --git a/Source/NETworkManager.Validators/NETworkManager.Validators.csproj b/Source/NETworkManager.Validators/NETworkManager.Validators.csproj index 69c291947c..c352840075 100644 --- a/Source/NETworkManager.Validators/NETworkManager.Validators.csproj +++ b/Source/NETworkManager.Validators/NETworkManager.Validators.csproj @@ -4,7 +4,7 @@ Library NETworkManager.Validators NETworkManager.Validators - net8.0-windows10.0.17763.0 + net8.0-windows10.0.22621.0 win-x64 x64 false diff --git a/Source/NETworkManager/NETworkManager.csproj b/Source/NETworkManager/NETworkManager.csproj index b0ef9b0972..f644a6a558 100644 --- a/Source/NETworkManager/NETworkManager.csproj +++ b/Source/NETworkManager/NETworkManager.csproj @@ -1,7 +1,7 @@ - + WinExe - net8.0-windows10.0.17763.0 + net8.0-windows10.0.22621.0 win-x64 x64 false diff --git a/Source/NETworkManager/ViewModels/WiFiViewModel.cs b/Source/NETworkManager/ViewModels/WiFiViewModel.cs index ada6b68518..8161062c1f 100644 --- a/Source/NETworkManager/ViewModels/WiFiViewModel.cs +++ b/Source/NETworkManager/ViewModels/WiFiViewModel.cs @@ -1,9 +1,20 @@ -using System; +using LiveCharts; +using LiveCharts.Wpf; +using log4net; +using MahApps.Metro.Controls.Dialogs; +using NETworkManager.Localization; +using NETworkManager.Localization.Resources; +using NETworkManager.Models.Export; +using NETworkManager.Models.Lookup; +using NETworkManager.Models.Network; +using NETworkManager.Settings; +using NETworkManager.Utilities; +using NETworkManager.Views; +using System; using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; -using System.Diagnostics; using System.Linq; using System.Threading.Tasks; using System.Windows.Data; @@ -13,18 +24,6 @@ using Windows.Foundation.Metadata; using Windows.Security.Credentials; using Windows.System; -using LiveCharts; -using LiveCharts.Wpf; -using log4net; -using MahApps.Metro.Controls.Dialogs; -using NETworkManager.Localization; -using NETworkManager.Localization.Resources; -using NETworkManager.Models.Export; -using NETworkManager.Models.Lookup; -using NETworkManager.Models.Network; -using NETworkManager.Settings; -using NETworkManager.Utilities; -using NETworkManager.Views; namespace NETworkManager.ViewModels; @@ -302,19 +301,26 @@ public IList SelectedNetworks } } - public SeriesCollection Radio1Series { get; set; } = []; + public SeriesCollection Radio2dot4GHzSeries { get; set; } = []; - public string[] Radio1Labels { get; set; } = - [" ", " ", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", " ", " "]; + public string[] Radio2dot4GHzLabels { get; set; } = + [" ", " ", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", " ", " "]; - public SeriesCollection Radio2Series { get; set; } = []; + public SeriesCollection Radio5GHzSeries { get; set; } = []; - public string[] Radio2Labels { get; set; } = + public string[] Radio5GHzLabels { get; set; } = [ " ", " ", "36", "40", "44", "48", "52", "56", "60", "64", "", "", "", "", "100", "104", "108", "112", "116", "120", "124", "128", "132", "136", "140", "144", "149", "153", "157", "161", "165", " ", " " ]; + public SeriesCollection Radio6GHzSeries { get; set; } = []; + + public string[] Radio6GHzLabels { get; set; } = + [ + + ]; + public Func FormattedDbm { get; set; } = value => $"- {100 - value} dBm"; // Reverse y-axis 0 to -100 @@ -569,7 +575,7 @@ private static bool RequestAccess() private async Task LoadAdaptersAsync(string adapterId = null) { Log.Debug("LoadAdaptersAsync - Trying to get WiFi adapters..."); - + IsAdaptersLoading = true; // Show a loading animation for the user @@ -585,23 +591,23 @@ private async Task LoadAdaptersAsync(string adapterId = null) Adapters.Clear(); } - + // Check if we found any adapters if (Adapters.Count > 0) { Log.Debug("LoadAdaptersAsync - Found " + Adapters.Count + " WiFi adapters."); - + // Check for previous selected adapter if (string.IsNullOrEmpty(adapterId)) { Log.Debug("LoadAdaptersAsync - No previous adapter ID found. Selecting the first adapter."); - + SelectedAdapter = Adapters.FirstOrDefault(); } else { Log.Debug("LoadAdaptersAsync - Previous adapter ID found. Trying to select the adapter with the ID: " + adapterId); - + SelectedAdapter = Adapters.FirstOrDefault(s => s.NetworkInterfaceInfo.Id.ToString() == adapterId) ?? Adapters.FirstOrDefault(); } @@ -611,18 +617,18 @@ private async Task LoadAdaptersAsync(string adapterId = null) } else { - Log.Debug("LoadAdaptersAsync - No WiFi adapters found."); + Log.Debug("LoadAdaptersAsync - No WiFi adapters found."); } IsAdaptersLoading = false; - + Log.Debug("LoadAdaptersAsync - Done."); } - + private async Task ScanAsync(WiFiAdapterInfo adapterInfo, bool refreshing = false, uint delayInMs = 0) { Log.Debug($"ScanAsync - Scanning WiFi adapter \"{adapterInfo.NetworkInterfaceInfo.Name}\" with delay of {delayInMs} ms..."); - + if (refreshing) { StatusMessage = Strings.SearchingForNetworksDots; @@ -644,26 +650,31 @@ private async Task ScanAsync(WiFiAdapterInfo adapterInfo, bool refreshing = fals var wiFiNetworkScanInfo = await WiFi.GetNetworksAsync(adapterInfo.WiFiAdapter); Log.Debug("ScanAsync - Scan completed. Found " + wiFiNetworkScanInfo.WiFiNetworkInfos.Count + " networks."); - + // Clear the values after the scan to make the UI smoother Log.Debug("ScanAsync - Clearing old values..."); Networks.Clear(); - Radio1Series.Clear(); - Radio2Series.Clear(); + Radio2dot4GHzSeries.Clear(); + Radio5GHzSeries.Clear(); Log.Debug("ScanAsync - Adding new values..."); foreach (var network in wiFiNetworkScanInfo.WiFiNetworkInfos) { Log.Debug("ScanAsync - Add network: " + network.AvailableNetwork.Ssid + " with channel frequency: " + network.AvailableNetwork.ChannelCenterFrequencyInKilohertz); - + Networks.Add(network); - if (WiFi.ConvertChannelFrequencyToGigahertz(network.AvailableNetwork - .ChannelCenterFrequencyInKilohertz) < 5) // 2.4 GHz - Radio1Series.Add(GetSeriesCollection(network, WiFiRadio.One)); - else - Radio2Series.Add(GetSeriesCollection(network, WiFiRadio.Two)); + switch (network.AvailableNetwork.ChannelCenterFrequencyInKilohertz) + { + case var frequency when WiFi.Is2dot4GHzNetwork(frequency): + Radio2dot4GHzSeries.Add(GetSeriesCollection(network, WiFiRadio.Radio2dot4GHz)); + break; + + case var frequency when WiFi.Is5GHzNetwork(frequency): + Radio5GHzSeries.Add(GetSeriesCollection(network, WiFiRadio.Radio5GHz)); + break; + } } statusMessage = string.Format(Strings.LastScanAtX, @@ -672,14 +683,14 @@ private async Task ScanAsync(WiFiAdapterInfo adapterInfo, bool refreshing = fals catch (Exception ex) { Log.Error($"Error while scanning WiFi adapter \"{adapterInfo.NetworkInterfaceInfo.Name}\".", ex); - + statusMessage = string.Format(Strings.ErrorWhileScanningWiFiAdapterXXXWithErrorXXX, adapterInfo.NetworkInterfaceInfo.Name, ex.Message); - + // Clear the existing old values if an error occurs Networks.Clear(); - Radio1Series.Clear(); - Radio2Series.Clear(); + Radio2dot4GHzSeries.Clear(); + Radio5GHzSeries.Clear(); } finally { @@ -688,7 +699,7 @@ private async Task ScanAsync(WiFiAdapterInfo adapterInfo, bool refreshing = fals IsBackgroundSearchRunning = false; IsNetworksLoading = false; - + Log.Debug("ScanAsync - Done."); } } @@ -697,7 +708,15 @@ private ChartValues GetDefaultChartValues(WiFiRadio radio) { ChartValues values = []; - for (var i = 0; i < (radio == WiFiRadio.One ? Radio1Labels.Length : Radio2Labels.Length); i++) + var size = radio switch + { + WiFiRadio.Radio2dot4GHz => Radio2dot4GHzLabels.Length, + WiFiRadio.Radio5GHz => Radio5GHzLabels.Length, + WiFiRadio.Radio6GHz => Radio6GHzLabels.Length, + _ => 0 + }; + + for (var i = 0; i < size; i++) values.Add(-1); return values; @@ -709,6 +728,7 @@ private ChartValues GetChartValues(WiFiNetworkInfo network, WiFiRadio ra var reverseMilliwatts = 100 - network.AvailableNetwork.NetworkRssiInDecibelMilliwatts * -1; + // ToDo: Implement channel width (20, 40, 80, 160) values[index - 2] = -1; values[index - 1] = reverseMilliwatts; values[index] = reverseMilliwatts; @@ -720,9 +740,16 @@ private ChartValues GetChartValues(WiFiNetworkInfo network, WiFiRadio ra private LineSeries GetSeriesCollection(WiFiNetworkInfo network, WiFiRadio radio) { - var radioLabels = radio == WiFiRadio.One ? Radio1Labels : Radio2Labels; + var radioLabels = radio switch + { + WiFiRadio.Radio2dot4GHz => Radio2dot4GHzLabels, + WiFiRadio.Radio5GHz => Radio5GHzLabels, + WiFiRadio.Radio6GHz => Radio6GHzLabels, + _ => [] + }; + var channel = WiFi.GetChannelFromChannelFrequency(network.AvailableNetwork.ChannelCenterFrequencyInKilohertz); - + var index = Array.IndexOf(radioLabels, $"{channel}"); return new LineSeries diff --git a/Source/NETworkManager/Views/WiFiView.xaml b/Source/NETworkManager/Views/WiFiView.xaml index e646943a86..cbac28534f 100644 --- a/Source/NETworkManager/Views/WiFiView.xaml +++ b/Source/NETworkManager/Views/WiFiView.xaml @@ -657,7 +657,7 @@ - @@ -665,7 +665,7 @@ + MaxValue="16" Labels="{Binding Path=Radio2dot4GHzLabels}"> @@ -707,7 +707,7 @@ - @@ -715,7 +715,7 @@ + MaxValue="32" Labels="{Binding Path=Radio5GHzLabels}"> diff --git a/Website/docs/changelog/next-release.md b/Website/docs/changelog/next-release.md index e3d9fab888..6bef0360eb 100644 --- a/Website/docs/changelog/next-release.md +++ b/Website/docs/changelog/next-release.md @@ -12,17 +12,26 @@ Release date: **xx.xx.2024** **System requirements** -- Windows 10 / Server x64 (1809 or later) +- Windows 10 / Server x64 (22H2 or later) - [.NET Desktop Runtime 8.0 (LTS) - x64](https://dotnet.microsoft.com/en-us/download/dotnet/8.0/runtime) ## Breaking Changes +- Minimum supported Windows version increased is now `22H2` + ## What's new? ## Improvements +- **WiFi** + - `WPA3 Personal (SAE)`, `WPA3 Enterprise` and `WPA3 Enterprise (192-bit)` are now supported + - `802.11be` (`EHT`) is now supported + ## Bugfixes +- **WiFi** + - Fixed a bug that caused the scan process to crash when a 6 GHz network was found + ## Dependencies, Refactoring & Documentation - Code cleanup & refactoring From 920dc5edff2989b70ef0ad601e57c118ca7d549d Mon Sep 17 00:00:00 2001 From: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com> Date: Sun, 17 Nov 2024 03:52:14 +0100 Subject: [PATCH 2/2] Docs: Fix website layout --- Website/docs/application/wifi.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Website/docs/application/wifi.md b/Website/docs/application/wifi.md index d0b36e940e..0f29129628 100644 --- a/Website/docs/application/wifi.md +++ b/Website/docs/application/wifi.md @@ -32,7 +32,7 @@ Due to limitations of the `Windows.Devices.WiFi` API the channel bandwidth canno Right-click on the result to copy or export the information. -:::note +::: ## Channels @@ -42,6 +42,6 @@ On the **Channels** tab, all wireless networks of the selected wireless network You can move the mouse over the channel to display all wireless networks in a ToolTip that occupy that channel. -:::note +::: ![WiFi - Channel](../img/wifi--channel.png)