Comments (19)
hi
hope this helps.
Public Class Wifi
Public Shared Event ConnectionStatusChanged(isConnected As Boolean)
Public Shared ReadOnly Property IsConnected() As Boolean
Get
Return _wifi.ConnectionStatus = SimpleWifi.WifiStatus.Connected
End Get
End Property
Public Shared Function GetAccessPoints() As List(Of SimpleWifi.AccessPoint)
Return _wifi.GetAccessPoints().
OrderByDescending(Function(ap) ap.SignalStrength).
ToList()
End Function
Public Shared Function Connect()
If IsConnected Then Return True
For Each ap In GetAccessPoints().Where(Function(x) x.HasProfile)
If Connect(ap, New SimpleWifi.AuthRequest(ap)) Then Return True
Next
Return False
End Function
Public Shared Function Connect(ap As SimpleWifi.AccessPoint, ar As SimpleWifi.AuthRequest)
Disconnect()
AddHandler _wifi.ConnectionStatusChanged, AddressOf Wifi_ConnectionStatusChanged
Return ap.Connect(ar)
End Function
Public Shared Sub Disconnect()
_wifi.Disconnect()
RemoveHandler _wifi.ConnectionStatusChanged, AddressOf Wifi_ConnectionStatusChanged
End Sub
Private Shared _wifi As SimpleWifi.Wifi =
New SimpleWifi.Wifi()
Private Shared Sub Wifi_ConnectionStatusChanged(sender As Object, e As SimpleWifi.WifiStatusEventArgs)
RaiseEvent ConnectionStatusChanged(e.NewStatus = SimpleWifi.WifiStatus.Connected)
End Sub
End Class
from simplewifi.
thanks a lot.
but... how to use it?
why 2 connect funcions?
thanks and regards
from simplewifi.
no problem
you can catch some ideas from here
Sub Main()
'try to connect to a known network
Wifi.Connect()
'get all avaliable networks to choose witch one you will connect
Dim access_points = Wifi.GetAccessPoints()
'imagine you choose the first one
Dim access_point = access_points.First()
Dim auth_access = New SimpleWifi.AuthRequest(access_point)
If auth_access.IsPasswordRequired Then
If Not access_point.HasProfile Then
'TODO: request password, then
auth_access.Password = "typed password"
End If
End If
'try connect with given password
If Not Wifi.Connect(access_point, auth_access) Then
'if not, delete profile to request new attempt
access_point.DeleteProfile()
End If
End Sub
from simplewifi.
Thanks
I got errors...
"ConnectionStatus" is not a member of Wifi...
Any suggestion?
Thanks and regards
from simplewifi.
Could you paste the exception?
from simplewifi.
The error is while compiling.
from simplewifi.
Send me an example or attach your project.
from simplewifi.
i attach the project
rename from ".png" to ."zip".
i don't know why i can't send the ".zip". sorry for that.
thanks and regards
from simplewifi.
vb is not case sensitive, so you have to change your project name.
in c# "simpleWifi" and "SimpleWifi" are two namespaces, but in vb is one.
try not create projects with the same name as the libraries you use.
from simplewifi.
hi
thanks, but the name is not involved in the problem... i think the problem is from declarations...
from simplewifi.
change your assembly name and root namespace in project properties and the problem is fixed.
from simplewifi.
Yes! ;-)
Fixed. I will try now to play with.
Thanks a lot.
from simplewifi.
Another question:
How can i know if i have internet connection?
If i can reach, by example, www.google.com?
thanks in advance.
from simplewifi.
glad to be helpful, but try to not run from the main subject, if so, go to forums or ask google. :)
Dim isNetworkAvailable = My.Computer.Network.IsAvailable
Dim isInternetAvailable = My.Computer.Network.Ping("http://google.com")
from simplewifi.
ok.
thanks a lot!
Regards
from simplewifi.
Hi all.
When the Wifi.Connect(access_point, auth_access) is called with wrong password, the app hangs completly while the timeout is reached.
Is there any way to avoid app hangs while wait for the timeout?
Or any way to set the timeout?
Thanks
from simplewifi.
hi, i didn't test it, but try it:
...
access_point.ConnectAsync(auth_access, onConnectComplete:=AddressOf OnConnectComplete)
...
Private Sub OnConnectComplete(isConnected As Boolean)
End Sub
from simplewifi.
Yes!
Thanks!
from simplewifi.
Hi, I already populate the wifi list into combo box, but how to connect the network.
Below load the list of wifi
` Private Sub loadWifi()
listWifi.Items.Clear()
Dim accessPoints As IEnumerable(Of AccessPoint) = Wifi.GetAccessPoints()
For Each ap As AccessPoint In accessPoints
listWifi.Items.Add(ap.Name)
Next
Dim selectedAP As AccessPoint = listWifi.SelectedItem
End Sub`
And below I try to connect but not working
` Private Sub connectTo()
Dim selectedAP As AccessPoint = listWifi.SelectedItem
Dim authRequest As AuthRequest = New AuthRequest(selectedAP)
Wifi.Connect(selectedAP, authRequest)
End Sub`
Thanks you @marcosdvpereira
from simplewifi.
Related Issues (20)
- Not able to connect to a WLAN in case the SSID contains a '&' in its name HOT 2
- Temporary profiles HOT 1
- hot spot with simplewifi? HOT 1
- Feature request: Add Scan() function to Wifi class HOT 4
- Getting Selected Access Point from windows forms listbox HOT 1
- This framework doens't manage IPs?
- Wifi Proteceted Setup(WPS)
- Not getting interfaces
- Multiple wifi interfaces HOT 1
- Still the problem with Windows Xp SP3 don't detect the real status of connection !!
- Windows 10 GetAccessPoints doesnt list wifi points after reboot HOT 1
- 在win10 中不支持中文wifi名 HOT 3
- Error When Radio turned off - Windows 10 HOT 2
- It can't support chinese wifi name HOT 2
- Auto reconnect HOT 1
- Is there any method to turn on/off the WiFi interface by using SimpleWiFi?
- Filter only 2.4 ghz networks
- ArgumentNullException: 'Value cannot be null. Arg_ParamName_Name" HOT 1
- Method To Return Interfaces
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from simplewifi.