B4A Library Simple WIFI library Updated V. 3.07 09-05-2018

Paulo Rosa

Member
Licensed User

Hi, @bgsoft, any chances?

Best,
 

bgsoft

Well-Known Member
Licensed User
Longtime User
Hi Paulo:

Sorry I have not answered you before, but these last months I am very busy.

What you ask is already done. Just make another updateWiFiList call again.

In the initialization already contains that parameter, I put it in version 3.01 :

V-3.01
UPDATED
startScan(EventName As String, NoEventOnSystemScan As Boolean)

Initializes all objects and scans for WIFI networks. Builds a string array of results (wifis) that can be accessed directly or with a call to updateWifiList.
EventName: Name of the Event to launch when Scan finish (EventName_ScanDone)
NoEventOnSystemScan: Launches events only on requested scans (true) or on all scans (false), including system background scans.
THIS METHOD SHOULD ONLY BE CALLED ONCE!


Regarding your question of the difference between WiFiSignalPct and WiFiStrength, it is already in version 3.0, they are the same:

WifiStrength As Int
Returns the WIFI signal strength in percentage as an integer (0 to 100)
Returns 0 on error
This method fails in some devices. Use WifiSignalPct() instead

Regards
 

danebn11

Member
Licensed User
Hello,
I am using this Library since 1,5 years and it works very well.
Now I have a new Smartphone and if it is connected to wifi, "wifi.WifiSSID" returns <unknown ssid>.
Has anyone else the same problem?
 

JMB

Active Member
Licensed User
Longtime User
Hello,
I am using this Library since 1,5 years and it works very well.
Now I have a new Smartphone and if it is connected to wifi, "wifi.WifiSSID" returns <unknown ssid>.
Has anyone else the same problem?


Others may be able to provide a better answer, but I seemed to get this when I wasn't connected to Wifi, but to the cellular network.
 

Computersmith64

Well-Known Member
Licensed User
Longtime User
At the risk of being accused of double-posting a question, I'm going to post here because my post in the Bugs & wishlist forum has so far been unanswered. I won't repeat the entire post (Simple Wifi (MLWifi) not working correctly with Android 9) - however the upshot is that on Android 9 devices, the library is reporting isWifiConnected as false, even when an app is connected to an access point.

From another post, it seems that this might only happen if the AP doesn't have internet access - however I haven't looked into this because in my case I'm seeing the issue when a B4A app is trying to connect to a B4R app that's creating an access point that isn't connected to the internet anyway. In my other post (referred to above) there is a B4A app & a B4R app that when run together will reproduce the issue.

- Colin.
 

bgsoft

Well-Known Member
Licensed User
Longtime User

Hi, I tested with a samsung galaxy s8 + with android 9 and isWifiConnected works correctly.
Even if the mobile data is stopped or the location.
I already answered in the other post (Bugs & wishlist)

regards
 

bgsoft

Well-Known Member
Licensed User
Longtime User
Hi, I have tested your project on a Samsung Galaxy 8+ with Android 9 and is WIFIConnected works correctly.
Even if the mobile data is stopped or the location.

I have placed at the beginning of Public Sub ConnectToAP

B4X:
  LogColor ("testWiFi.isWifiConnected" & testWiFi.isWifiConnected, Colors.Blue)

And it returns TRUE


regards
 

Computersmith64

Well-Known Member
Licensed User
Longtime User
[
Hi, I tested with a samsung galaxy s8 + with android 9 and isWifiConnected works correctly.
Even if the mobile data is stopped or the location.
I already answered in the other post (Bugs & wishlist)

regards
Per my reply in our PMs, I tested the updates you sent me & they do not work on an Android 9 device if the connected AP is not also connected to the internet.

- Colin.
 

Philip Prins

Active Member
Licensed User
Longtime User
 

Myr0n

Active Member
Licensed User
Longtime User

rosippc64a

Active Member
Licensed User
Longtime User
Hi All!
I use the mlwifi 3.07 lib in the demo program. My android version is 7.1.2. The demo use only libs core and mlwifi. the demo works like a charm.

If I use the mlwifi lib in a complex program what use 36 other libs also (only b4a official libs), I think the mlwifi should works the same, isn't it?
I think it should. And the MLwifi works too, but the MLScan doesn't. :-(
B4X:
Dim wifi As MLwifi '<- works good
Dim scan As MLScan '<-works bad
MLWifi doing its job perfectly, but the MLScan reports 0 wifi network on the same device where the demo worked well.
No error, only reports 0. I use the same code, the same activity as in demo.
Can you imagine, that some other library prevents its work?
 
Last edited:

rosippc64a

Active Member
Licensed User
Longtime User
SOLVED!!!!
Though there was no clue in demo program (nor in manifest) about adding any extra permission, but I found in forum that I have to ask permission:
B4X:
        If Not(rp.Check(rp.PERMISSION_ACCESS_FINE_LOCATION)) Then
            rp.CheckAndRequest(rp.PERMISSION_ACCESS_FINE_LOCATION)
            Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
            Log($"${Permission} status: ${rp.Check(rp.PERMISSION_ACCESS_FINE_LOCATION)}"$)
            pDoEvents
        End If
so everithing is working!
 

RickKik

New Member
Hi. Is there any simple example how to use this lib?
for example, so that my phone could connect to some network
 

sorex

Expert
Licensed User
Longtime User
you can use it like this

B4X:
If wifi.WifiSSID.Contains(MyLocationWifiSSID)=False Then
LogColor($"Connected to wrong SSID (${wifi.WifiSSID}) > Switching to ${MyLocationWifiSSID}/${MyLocationWifiPassword}"$,Colors.Red)
wifi.disconnectWifiAP
wifi.saveWifiAP(MyLocationWifiSSID,2,MyLocationWifiPassword,True)
End If

which switches to the correct access point if not connected or connected to a wrong one. you can put that in a timer and check every minute or so.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…