UPDATE: ABWifi 2.x
Note: ABWifi 2.x is NOT compatible with ABWifi 1.x. ABWifi 1.x was one of the first libraries I wrote for B4A. It was reported that there were some problems with timing etc. It did also some stuff that I needed for a personal project (like location finding), but there are way better libraries for that available now.
So I decided to rewrite ABWifi, now using the correct way to read the wifis around you, and ONLY doing that.
Functions:
Initialize("eventName")
Initialize ABWifi
StartWifi
Start ABWifi. Use GetNewReadingWifi() to get one reading
The event FoundReadings() will be raised containing the current Wifi infos
If WIFI was not enabled on the device, it will be enabled now.
GetNewReadingWifi
Get a new reading. Only one reading will be done, so you have to call it again
in the FoundReadings() event if you want continious readings.
StopWifi
Stop ABWifi
If WIFI was not enabled on the device, it will be disabled now.
Events:
FoundReadings(readings As List)
A list of ABWifiReading objects with the WIFIs around you
Objects:
ABWifiReading
One reading containing:
TimeStamp (Removed in 2.01, still in 2.0)
BSSID
Level
Frequency
SSID
Capabilities
IsConnected
FullString
IsBestSignal
Example:
Is included in the zip file with the library files
---------------------------------------------------------------------------------------------
OLD: Wifi Library 1.2
This library allows you to get Wifi information.
[Version 1.1] ABWifi is no longer an Activity object.
[Version 1.2] Correction in getting the current location
I think (because of my limited knowledge of java then), there was a bug that made it always jump to LastKnown location.
There is now a seperate function to get the LastKnown location from the cache.
One other thing. I thought back then it did GSM triangulation, but it does not. This is not done by Wifi, but by cell tower location and ergo does not belong in this library.
Functions and objects:
ABLoadWifi() as String
Loads the Wifi information.
Example:
ABWifiInfo Object
Returns an ABWifiInfo Object.
Properties:
(Some properties are only filled for the connected Wifi, see ABGetCurrentWifiInfo())
BSSID (String)
MacAddress (String)
NetworkId (Integer)
Rssi (Integer)
SSID (String)
HiddenSSID (Boolean)
FullString (String)
Level (Integer)
IsConnected (Boolean)
Frequency (Integer)
Capabilities (String)
LinkSpeed (Integer)
State (String)
ABGetCurrentWifiInfo() AS ABwifiInfo
Returns the current connected ABWifiInfo after using the ABLoadWifi() function.
See ABLoadWifi() for an example.
ABGetWifiNetwork(Index as integer) As ABWifiInfo
Returns an ABWifiInfo object that are found by using the ABLoadWifi() function.
See ABLoadWifi() for an example.
ABNumberOfAvailableWifiNetworks() as Integer
Returns the number of available Wifi Networks
ABGetLocation(eventName as String) As Boolean
Gets the current location of the device by using the GPS or Wifi signal.
Example:
ABGetLastKnownLocation(eventName as String) As Boolean
Gets the last known location of the device by looking in the cache
Example:
ABGetFoundLocation() AS ABFoundLocation
returns the current ABFoundLocation by using the ABGetLocation() and ABGetLastKnownLocation() function.
see ABGetLocation() for an example.
ABFoundLocation Object
Returns an ABFoundLocation object. This contains the Latitude and Longitude found by using the Wifi signal.
ABWifiLastError() as String
returns the last error message if any
Example:
Note: ABWifi 2.x is NOT compatible with ABWifi 1.x. ABWifi 1.x was one of the first libraries I wrote for B4A. It was reported that there were some problems with timing etc. It did also some stuff that I needed for a personal project (like location finding), but there are way better libraries for that available now.
So I decided to rewrite ABWifi, now using the correct way to read the wifis around you, and ONLY doing that.
Functions:
Initialize("eventName")
Initialize ABWifi
StartWifi
Start ABWifi. Use GetNewReadingWifi() to get one reading
The event FoundReadings() will be raised containing the current Wifi infos
If WIFI was not enabled on the device, it will be enabled now.
GetNewReadingWifi
Get a new reading. Only one reading will be done, so you have to call it again
in the FoundReadings() event if you want continious readings.
StopWifi
Stop ABWifi
If WIFI was not enabled on the device, it will be disabled now.
Events:
FoundReadings(readings As List)
A list of ABWifiReading objects with the WIFIs around you
Objects:
ABWifiReading
One reading containing:
TimeStamp (Removed in 2.01, still in 2.0)
BSSID
Level
Frequency
SSID
Capabilities
IsConnected
FullString
IsBestSignal
Example:
Is included in the zip file with the library files
---------------------------------------------------------------------------------------------
OLD: Wifi Library 1.2
This library allows you to get Wifi information.
[Version 1.1] ABWifi is no longer an Activity object.
[Version 1.2] Correction in getting the current location
I think (because of my limited knowledge of java then), there was a bug that made it always jump to LastKnown location.
There is now a seperate function to get the LastKnown location from the cache.
One other thing. I thought back then it did GSM triangulation, but it does not. This is not done by Wifi, but by cell tower location and ergo does not belong in this library.
Functions and objects:
ABLoadWifi() as String
Loads the Wifi information.
Example:
B4X:
Sub Process_Globals
Dim myWifi As ABWifi
End Sub
Sub Globals
Dim Button1 As Button
End Sub
Sub Button1_Click
Dim r As Boolean
Dim a As Int
r = myWifi.ABLoadWifi()
If r = True Then
Msgbox (myWifi.ABGetCurrentWifiInfo().SSID, "")
For a = 0 To myWifi.ABNumberOfAvailableWifiNetworks - 1
Msgbox (myWifi.ABGetWifiNetwork(a).SSID & " " & myWifi.ABGetWifiNetwork(a).Level, "")
Next
Else
Msgbox(myWifi.ABWifiLastError,"")
End If
End Sub
ABWifiInfo Object
Returns an ABWifiInfo Object.
Properties:
(Some properties are only filled for the connected Wifi, see ABGetCurrentWifiInfo())
BSSID (String)
MacAddress (String)
NetworkId (Integer)
Rssi (Integer)
SSID (String)
HiddenSSID (Boolean)
FullString (String)
Level (Integer)
IsConnected (Boolean)
Frequency (Integer)
Capabilities (String)
LinkSpeed (Integer)
State (String)
ABGetCurrentWifiInfo() AS ABwifiInfo
Returns the current connected ABWifiInfo after using the ABLoadWifi() function.
See ABLoadWifi() for an example.
ABGetWifiNetwork(Index as integer) As ABWifiInfo
Returns an ABWifiInfo object that are found by using the ABLoadWifi() function.
See ABLoadWifi() for an example.
ABNumberOfAvailableWifiNetworks() as Integer
Returns the number of available Wifi Networks
ABGetLocation(eventName as String) As Boolean
Gets the current location of the device by using the GPS or Wifi signal.
Example:
B4X:
Sub Process_Globals
Dim myWifi As ABWifi
End Sub
Sub Globals
Dim Button1 As Button
End Sub
Sub Button1_Click
Dim r As Boolean
r = myWifi.ABGetLocation("myWifi")
If r = False Then
Msgbox (myWifi.ABWifiLastError(), "")
End If
End Sub
Sub myWifi_FoundLocation ()
Dim ResLocation As ABFoundLocation
resLocation = myWifi.ABGetFoundLocation()
Msgbox ("" & ResLocation.Latitude & " - " & ResLocation.Longitude, "")
End Sub
ABGetLastKnownLocation(eventName as String) As Boolean
Gets the last known location of the device by looking in the cache
Example:
B4X:
Sub Process_Globals
Dim myWifi As ABWifi
End Sub
Sub Globals
Dim Button1 As Button
End Sub
Sub Button1_Click
Dim r As Boolean
r = myWifi.ABGetLastKnownLocation("myWifi")
If r = False Then
Msgbox (myWifi.ABWifiLastError(), "")
End If
End Sub
Sub myWifi_FoundLocation ()
Dim ResLocation As ABFoundLocation
resLocation = myWifi.ABGetFoundLocation()
Msgbox ("" & ResLocation.Latitude & " - " & ResLocation.Longitude, "")
End Sub
ABGetFoundLocation() AS ABFoundLocation
returns the current ABFoundLocation by using the ABGetLocation() and ABGetLastKnownLocation() function.
see ABGetLocation() for an example.
ABFoundLocation Object
Returns an ABFoundLocation object. This contains the Latitude and Longitude found by using the Wifi signal.
ABWifiLastError() as String
returns the last error message if any
Example:
B4X:
If myWifi.ABWifiLastError <> "" Then
Msgbox(myWifi.ABWifiLastError,"")
Else
Msgbox("everything ok", "")
End If
Attachments
Last edited: