digiexam / simplewifi Goto Github PK
View Code? Open in Web Editor NEW.NET 4.5 library to manage wifi connections in Windows - written in C#
License: GNU Lesser General Public License v3.0
.NET 4.5 library to manage wifi connections in Windows - written in C#
License: GNU Lesser General Public License v3.0
As the title, I can get the WiFi interface and list the available APs. Also to connect and delete the profile of the AP. I would like to add a switch button to turn on/off the WiFi interface. I know the Managed Native WiFi has this method, but it's wired to implement it just to turn on/off the interface. Can SimpleWiFi support to do this?
I was trying to connect to my WLAN, which got an '&' in its name.... But it simply never worked...
After a while (was already getting my head around the Managed Wifi API) I got the Idea to try it with a SSID Name not containing any special characters... et voila, this worked.
So in order to get the Simple Wifi API to work also with more exotic SSIDs simply add a HttpUtility.HtmlEncode() around the name in ProfileFactory.cs.
string name = HttpUtility.HtmlEncode(Encoding.ASCII.GetString(network.dot11Ssid.SSID, 0, (int)network.dot11Ssid.SSIDLength));
Hope this is usefull to anybody :)
It seems that i cannot find a way to get the BSSID (Mac address) of the access points. I can get only the name and signal instead. Is there a way to get the access point's bssid?
Thanks.
Hello!
As soon as I try to connect to any wifi network I get this exception after entering the correct password.
I use .net 5.0 in this console application.
Any help would be greatly appreciated!
I need to change adapter's ip when a specific Wifi is connected, but I do not find support for this in this framework.
Does framework contain this functionality?
Hello. Thanks for your work. Can I use this code to connect to an AP using the pin code and Wps protocol?
Seems like some computers cause random crashes when it comes to the OnWlanNotification:
Event log:
Tillämpningsprogram: xx.exe
Framework-version: v4.0.30319
Beskrivning: Processen avslutades på grund av ett ohanterat undantag.
Undantagsinformation: System.ArgumentException
Stack:
vid System.Runtime.InteropServices.Marshal.SizeOfHelper(System.Type, Boolean)
vid System.Runtime.InteropServices.Marshal.SizeOf(System.Type)
vid SimpleWifi.Win32.WlanClient.OnWlanNotification(SimpleWifi.Win32.Interop.WlanNotificationData ByRef, IntPtr)
Felet uppstod i programmet med namn: xx.exe, version 1.0.0.0, tidsstämpel 0x51963996
, felet uppstod i modulen med namn: KERNELBASE.dll, version 6.2.9200.16451, tidsstämpel 0x50988950
Undantagskod: 0xe0434352
Felförskjutning: 0x00014b32
Process-ID: 0x518
Programmets starttid: 0x01ce66715458ffd5
Sökväg till program: C:\Program Files (x86)\xx\xx.exe
Sökväg till modul: C:\Windows\SYSTEM32\KERNELBASE.dll
Rapport-ID: 9d212623-d278-11e2-be9b-50465de78708
Fullständigt namn på felaktigt paket:
Program-ID relativt till felaktigt paket:
HI
FIRST OF ALL THX FOR YOUR GRAT WORK ON THIS PROJECT .
I WAS WONRING IF YOU ARE PLANING TO ADD WPS SUPPORT ?
I found it can't support chinese wifi name.
Do you have a solution?
I need install the KB918997 ?
Best regards,
Aismel
Hi.
I'm polling the wifi status every 5s. After a while i don't get any interfaces.
Example:
private IEnumerable<WifiAdapterType> GetActiveWlanInterfacesAndSensors(string filter = "") { var client = new SimpleWifi.Win32.WlanClient(); if (client.Interfaces == null) yield break; foreach (var iface in client.Interfaces.Where(x => !InvalidStates.Contains(x.InterfaceState))) {
I come always into the break.
If i try the same in a new process at the same time (breaking in the debug), it works.
Move the example application from the code branch, either to a separate branch or repository.
把wifi名的编码改为Default是可以连接,但是会是乱码
string SSID=Encoding.Default.GetString(network.dot11Ssid.SSID, 0, (int)network.dot11Ssid.SSIDLength);
In the getTemplate function, when I try to connect to a network:
An unhandled exception of type 'System.ArgumentNullException' occurred in mscorlib.dll
Additional information: Value cannot be null.
For some reason, I added the core SimpleWifi files to the same solution, and I added a different solution, and to no avail. Is there any way to solve this?
I don't see a way to set the connection to automatically reconnect. Is this possible? I believe this is a part of the profile.
It is not possible to reference SimpleWifi.dll by strong-named assemblies.
Hi, is it possible to filter only 2.4 ghz networks while searching access points with GetAccessPoints() method ?
Thanks.
hello
does anyone have the example in vb.net, please?
thanks and regards
We have the requirement to be able to connect to a hidden wireless endpoint, one that is not broadcast. Is this possible right now?
Networks where the user have been connected show up as duplicate entries.
Hide the entry which does not have a profile if one with a profile exists.
If i try to use the library with a second wifi adapter, the process doesn't work although, the profile which i save on the second interface, works with windows (version 10).
I use SimpleWifi.Win32.WlanClient.Interfaces.
First i set the profile on the second interface. This works, and in ConnectSynchronously, i got error code 86: parameter incorrect error.
The library does not currently support WPA2 Enterprise.
Hello.
Does anyone knows if i can make a wifi hot spot with simplewifi?
thanks in advance
Will there be any Ubuntu/Linux support?
If no, Can I fix it somehow?
Greetings, Me.
First of all, thanks for the library!
It works well for me, except for the case when I connect to the hotspot created on my Android device with security set to None. In this case SimpleWifi fails to find connected AccessPoint - IsConnected property on the corresponding AccessPoint instance incorrectly returns 'false'.
I wonder if AccessPoint.IsConnected property implementation should be changed so that it tries to match AccessPoint._interface.CurrentConnection.Name to SSID (accessible via AccessPoint.Name) whenever AccessPoint._network.profileName is an empty string?
In my case that would solve the issue. I can submit pull request if you think the fix makes sense.
Here is a screenshot from VS debugging session, to clarify the issue:
Thanks!
One Windows XP SP3 machine crashed on init.
Stack trace:
System.ComponentModel.Win32Exception (0x80004005): Felaktig parameter
vid SimpleWifi.Win32.Interop.WlanInterop.ThrowIfError(Int32 win32ErrorCode)
vid SimpleWifi.Win32.WlanClient..ctor()
vid SimpleWifi.Wifi..ctor()
vid THEAPP.BLL.ViewModels.Dialogs.SaveOfflineFileDialogViewModel..ctor(ExamReport examReport)
vid THEAPP.BLL.ViewModels.ExamScreenViewModel.InitShutdown()
vid THEAPP.BLL.ViewModels.ExamScreenViewModel.<get_FinishExam>b__0(Object arg)
vid THEAPP.BLL.Helpers.WPF.DelegateCommand.Execute(Object parameter)
vid MS.Internal.Commands.CommandHelpers.CriticalExecuteCommandSource(ICommandSource commandSource, Boolean userInitiated)
vid System.Windows.Controls.Primitives.ButtonBase.OnClick()
vid System.Windows.Controls.Button.OnClick()
vid System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e)
vid System.Windows.UIElement.OnMouseLeftButtonUpThunk(Object sender, MouseButtonEventArgs e)
vid System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
vid System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
vid System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
vid System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
vid System.Windows.UIElement.ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args, RoutedEvent newEvent)
vid System.Windows.UIElement.OnMouseUpThunk(Object sender, MouseButtonEventArgs e)
vid System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
vid System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
vid System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
vid System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
vid System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
vid System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
vid System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
vid System.Windows.Input.InputManager.ProcessStagingArea()
vid System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
vid System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
vid System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
vid System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
vid System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
vid MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
vid MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
vid System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
vid MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
vid System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
vid MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
vid MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
vid System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
vid System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
vid System.Windows.Threading.Dispatcher.Run()
vid System.Windows.Application.RunDispatcher(Object ignore)
vid System.Windows.Application.RunInternal(Window window)
vid System.Windows.Application.Run(Window window)
vid THEAPP.App.Main()
when trying to get the selected access point for the user to connect to I tried using
AccessPoint selectedAP = listBox1.SelectedItem;
and I get the error:
error CS0266: Cannot implicitly convert type 'object' to 'SimpleWifi.AccessPoint'. An explicit conversion exists (are you missing a cast?)
is there any way to fix this??
When I reboot my computer and run the program it only lists the single WiFi that my computer is connected to.
When I open the connection list in Windows (forcing the OS to do an SSID request) it then will list them all.. I imagine there is a call that you are missing that goes "Ok update my list of current visible SSIDs"
When I'm trying to connect to a network with a key like this "1234567890&" I get an error 1206. If the key is 1234567890 on the same network it works just fine. How can I solve this problem?
If I have WIFI turned off in Windows, this is throwing an error when trying to getAplist.
Once we instantiate Wifi client class, prior to running functions, how best to check if radio is enabled or not before running further functions?
Hi, thanks for this, it really works well :)
Just have noticed though, on Windows XP (I know, upgrade right? :P ) when the connection is successful, the OnConnectedComplete event still returns false. I haven't looked into it too much though, currently working around it by listing the connections and ensuring the selected one is connected which works fine. Just thought I'd bring this up.
Again, nice work with this 👍
Creating a nuget package could provide more visibility to the project and allow users to keep their package up-to-date with new release.
Remove the binaries from version control and add them to .gitignore
Hi,
Iv been looking at your wifi library as an alternative to ManagedWifi simply because it offers the disconnect method. However, it doesnt support the use of temporary profiles (i.e. connecting to wifi without storing the profile in the system). This is a "must-have" feature for my App. How much work would it be to add this feature? I am not sure whether it is on a C++/Interop Level, or a managed interface level at the moment!
Thanks.
The return value of WlanClient.WlanInterface.ConnectSynchronously is not reliable, sometimes it returns true even if connecting to a wifi with the wrong security key.
During my test, some wifi SSID will disappear intermittently but then they appear again if I click on the WiFi icon in the Windows status tray. Sometimes I need to click the WiFi icon several times to see the specific SSID.
I think a re-scan begins each time I click the WiFi icon, seem to be this WlanScan
function. In the interop code, it seems to be the Scan
function.
I think it will be useful if we expose this 'Scan' function to 'Wifi' class, so we can call like this:
var wifi = new Wifi();
wifi.Scan(); //the feature request
var apList = wifi.GetAccessPoints();
By the additional call of Scan()
, we can try till we get the specific AP.
Is it possible?
Thanks.
Does simplewifi support Windows 10? Either way, perhaps to avoid this question, it should be explicitly stated one way or another in the readme?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.