Inconsistant results from ABWifi (sometimes)

Gary Miyakawa

Active Member
Licensed User
Longtime User
I'm using the example code provided on the ABWifi page to determine the number and names (SSID) of all the networks that are visible. When I run the demo code on my Atrix, I "sometimes" see multiple networks (and there are always multiple networks in the air at my location)... About 1 out of 5 times, I'll see more than the network I'm currently connected to...

I then changed the msgboxes in the example to log statements. After doing that, I NEVER get anything back but the main network I'm connected to.

I am using the 1.1 version of the library...

Does anyone have any suggestions as to what I might be doing wrong ?

Thanks,

Gary M
 

Kevin

Well-Known Member
Licensed User
Longtime User
I haven't used that library very extensively at all so I'm afraid I can't help much, but I can tell you that posting some sample code, particularly where you made changes, may shed some light on others who may have more knowledge on it. Just a thought. :)

Also, have you tried undoing your changes to see if you can get it working again, then add it back in? Or adding some Log (VariableHere) statements in key areas that may tell you if something is going wonky at runtime?
 
Upvote 0

NJDude

Expert
Licensed User
Longtime User
As far as I can tell, the library needs a "pause" to get the networks, that's why if you use MsgBoxes you get results and none if you change it to log entries.

I wrote a simple app using that library a little while ago and I use a timer to delay getting the results and I always get some.
 
Upvote 0

Gary Miyakawa

Active Member
Licensed User
Longtime User
NJDude,

Thanks.... That is exactly what I'm seeing (with the logs and no msgbox)... How long did you wait ?? and what did you use to "Pause" ?

Thanks !

Gary M
 
Upvote 0

Gary Miyakawa

Active Member
Licensed User
Longtime User
A little follow up information.. I setup a timer and found that, on my Atrix, I have to wait 2500 ms for me to reliably get the Wifi information. I have a "no name" tablet and it works at 1500 ms... Very strange... but at least I've solved my issue.

Thanks, NJDude !

Gary M
 
Upvote 0

NJDude

Expert
Licensed User
Longtime User
You might want to increase that pause a little, some devices might be a little slow which might cause your code to fail, it's just trial and error but to be safe add a second or two, my opinion.
 
Upvote 0

foakgul

Member
Licensed User
Longtime User
Hello!

I've been experimenting with ABWifi as well and that's also what I noticed: The code needs pause for number of available networks to be populated but I don't think it's scalable to enter a hardcoded pause value ie 1000ms because for some networks (devices) it might take more. Is there a way to get around this using an event based trigger ie wait until number of available networks is at least 1? Native Java code achieves this without specifying any pause but I don't know how I can use this as a library in my B4A code.

Here's java code for scanning networks:
android - Wifi Scanning code - Stack Overflow

Thanks!
 
Upvote 0

DonRacz

Member
Licensed User
Longtime User
This is what I used to get around it.

Do While Wifi.ABNumberOfAvailableWifiNetworks < 1
DoEvents
Loop
 
Upvote 0
Top