B4A Library Simple WIFI library

Cableguy

Expert
Licensed User
Longtime User
I have one question, how do you test internet connection?
 

HotShoe

Well-Known Member
Licensed User
Longtime User
isOnline will test if you are connected to the internet and isWifiConnected tests to see if you are connected to a router or other access point.

--- Jem
 
D

Deleted member 103

Guest
Thank you for this library, it is exactly what I was looking for.
 

ivanomonti

Expert
Licensed User
Longtime User
There is something to learn even the signal line gsm, 3g, 4g.

thanks
 

Geritt Schlag

Member
Licensed User
Longtime User
Thank you for this library. Works great!
I am search only an important point: How can i make the connection to the desired WLAN?
 

HotShoe

Well-Known Member
Licensed User
Longtime User
I am search only an important point: How can i make the connection to the desired WLAN?

This library is for collecting information about your wireless connection and AP's around you. It is not a wifi manager that actually makes or manages those connections.

--- Jem
 

Brad

Active Member
Licensed User
Longtime User
Awesome and simple library! One question. Is there a way during the scan to determine what type of security of the AP? WEP/WPA/WPA2?
 

HotShoe

Well-Known Member
Licensed User
Longtime User
Awesome and simple library! One question. Is there a way during the scan to determine what type of security of the AP? WEP/WPA/WPA2?

There is, it just isn't exposed. I'll add that in since it probably should have already been there.

--- Jem
 

HotShoe

Well-Known Member
Licensed User
Longtime User
Added a new version to the first post. This is version 2.01 and adds the wificap method to get capabilities of any scanned network. I also added the new wifitest example app source that I forgot to add to the 2.00 package. Sorry for the quick update, but I want this to be complete and useable.

In the new test app, clicking on any AP in the scanned list will allow you to see it's capabilities, and to connect to it.

--- Jem
 

HotShoe

Well-Known Member
Licensed User
Longtime User
Version 2.10 is linked in the first post. This version adds 3 new methods and changes the way several methods must be called. I know this will break some code, but this way of calling the methods just makes much more sense than using the SSID which can be an empty string or a duplicate entry. See the included example for a demonstration of how easy and how much less code this now takes. It also increases the speed of the library very slightly.

The new methods are :

Disconnect - to disconnect from an AP
isStored(EntryNumber) - to determine if this entry is already saved on the device
LinnkSpeed - to get the speed of the current connection

Also I have renamed 3 methods because they no longer use the SSID. Those methods are:

addSSID is now addAP
connectToSSID is now connectToAP
forgetSSID is now forgetAP

by the way, the entries returned in the wifis() array or a call to wifiList should be sorted by signal strength now.

--- Jem
 

FrankBerra

Active Member
Licensed User
Longtime User
Hi there i am using the following code to perform a scan:

B4X:
Sub Button1_Click

   wiffo.startScan
   Timer1.Initialize("Timer1", 2000) ' 1000 = 1 second
   Timer1.Enabled = True

End Sub


Sub Timer1_Tick
   If wiffo.wifis <> Null Then
    Timer1.Enabled = False
    Log (wiffo.WifiList)
    Log(wiffo.wifis)
   End If
End Sub

After few seconds the log says something like: "[Ljava.lang.String;@1107b928"

Where i am wrong?
 

HotShoe

Well-Known Member
Licensed User
Longtime User
That's the address of the array object returned by the call to WifiList and wifis. To get the entries use a method like in the sample project or put it into a List object.

--- Jem
 

FrankBerra

Active Member
Licensed User
Longtime User
Perfect, it works! thank you!
I have another question, just a curiosity...
The OS scans the surrounding wifis in background constantly (if it is not disabled by user in the wifi settings).
Is it possible to retrieve infos about last OS scan without performing an additional scan?
If yes what the pro/cons?
 

HotShoe

Well-Known Member
Licensed User
Longtime User
Is it possible to retrieve infos about last OS scan without performing an additional scan?

Not that I know of since I would not have access to the data. To my knowledge a new scan has to be done to get all of the features and data on each AP found.

--- Jem
 

FrankBerra

Active Member
Licensed User
Longtime User
Well this code returns data of the last OS scan, even if i haven't done a scan intentionally
B4X:
Dim R As Reflector
R.Target = R.GetContext
R.Target = R.RunMethod2("getSystemService", "wifi", "java.lang.String")
R.Target = R.RunMethod("getScanResults")
String_InfoWIFI= R.RunMethod("toString")
I get data of surrounding enviroment periodically (about every 10 min) and this code seem draining less battery than using ABWifi library. (This is why i asked you if there are PROs abaout getting wifi info without an explicit scan)
The problem is that the code above returns empty SSID/BSSID on Samsung devices.
MLwifi returns correct WIFI values, and in the following days i will analyze the battery consumption
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…