B4A Library MLwifi Library Updated to v4.00

Attached Java Source Code

MLWifi.zip - couldn't attach the entire Android Studio project as even zipped it was too big (900 KB) for the forum limits. If you want the entire project, private message me with your email address & I'll send it to you.

Library updated to v4.40

Added @Events so the callbacks can be auto-generated by the B4A IDE.

Library updated to v4.40

Added WifiBSSID function. Returns a string with the currently connected AP BSSID. Note that Wifi_ConnectionResult & isonline_pingdone don't require the EventName prefix.

Library updated to v4.30

Minor code tweaks & tidy up. Tested saveWifiAP, connectWifiAP, reconnectWifiAP & disconnectWifiAP on Android 4.4.2, 9 & 10.

Library updated to v4.20

Bug Fixes / Improvements:
* Added support for Android Pie.
* Improved connectivity when using saveWifiAP with Android Q+.

Library updated to v4.10

Added:

reconnectWifiAP: (reconnects to a saved Wifi network)

Parameters:
ssid - the name of the Wifi Network
timeout - fail if not connected within timeout (Ms)

Raises Wifi_ConnectionResult event on success or failure

NOTE FOR SDK 29+: Will only work if the network being connected to is not secured.
You can connect to the previously connected network by calling disconnectWifiAP
or a specific network by calling connectWifiAP with the correct parameters.

Example:
B4X:
Private Sub connectToWifi
    Private wifi As MLwifi
    'reconnect to a Wifi network saved on this device
    wifi.reconnectWifiAP("wifissid", 30000)
End Sub

Public Sub Wifi_ConnectionResult(success As Boolean)
    If success then
        'Connected - set up sockets, etc...
    Else
        'Couldn't connect...
    End If
End Sub

Bug Fixes:

isWifiConnected now correctly reports the connection state (true or false).

v4.00

connectWifiAP:
(connects to an existing Wifi Network)

Parameters:
ssid - the name of the Wifi Network
security = 0 = Open (SECURITY_OPEN), 1 = WEP (SECURITY_WEP), 2 = WPA-2/PSK (SECURITY_WPA2PSK)
password - the password or "" if the network is open
timeout - fail if not connected within timeout (Ms)

Raises Wifi_ConnectionResult event on success or failure

Example:
B4X:
Private Sub connectToWifi
    Private wifi As MLwifi

    'To connect to an open network
    wifi.connectWifiAP("wifissid", wifi.SECURITY_OPEN, "", 30000)
    'To connect to a WPA-2 secured network
    wifi.connectWifiAP("wifissid", wifi.SECURITY_WPA2PSK, "password", 30000)
End Sub

Public Sub Wifi_ConnectionResult(success As Boolean)
    If success then
        'Connected - set up sockets, etc...
    Else
        'Couldn't connect...
    End If
End Sub

saveWifiAP: (adds a Wifi network, then optionally connects)

Parameters:
ssid - the name of the Wifi Network
security = 0 = Open (SECURITY_OPEN), 1 = WEP (SECURITY_WEP), 2 = WPA-2/PSK (SECURITY_WPA2PSK)
password - the password or "" if the network is open
connect - ignored for Android Q+ (will always connect)
timeout - fail if not connected within timeout (ms)

Raises Wifi_ConnectionResult event on success or failure

Example:
B4X:
Private Sub connectToWifi
    Private wifi As MLwifi

    'To save & connect to an open network
    wifi.saveWifiAP("wifissid", wifi.SECURITY_OPEN, "", True, 30000)
    'To save & connect to a WPA-2 secured network
    wifi.saveWifiAP("wifissid", wifi.SECURITY_WPA2PSK, "password", True, 30000)
End Sub

Public Sub Wifi_ConnectionResult(success As Boolean)
    If success then
        'Connected - set up sockets, etc...
    Else
        'Couldn't connect...
    End If
End Sub

disconnectWifiAP: (disconnects from a Wifi network)

Usage:
B4X:
    Private disconnected As Boolean = MLwifi.disconnectWifiAP

Note that the connectWifiAP & saveWifiAP functions no longer return a Boolean. They now raise the Wifi_ConnectionResult(success As Boolean) callback event.

I haven't made any changes to any other library functions, nor have I tested them - so if there are functions that aren't working correctly, you'll have to let me know & I'll take a look at them. I also haven't tested the functions I did change/add beyond a couple of use cases (connecting to an ESP8266 Access Point & connecting to my home Wifi), so if there are situations that it doesn't work correctly in, you'll have to let me know.

Also note that there are some Android Q+ Wifi behaviors that are quite different to before, so I suggest you take a look at the android.net.wifi reference to give you a better idea of how the deprecated functions have been re-implemented.

- Colin.
 

Attachments

  • MLwifi400-v4.41.zip
    26 KB · Views: 1,363
  • MLwifi.zip
    8.6 KB · Views: 537
Last edited:

Nitin Joshi

Active Member
Licensed User
Dear Colin,
I have to check my purpose is achieving or not by calling disconnectWiFiAP. However, I have to detect API, if API is 29 then call disconnectWifiAP else i have to call connectWifiAP("ssid", MLwifi.SECURITY_OPEN, "", timeout)), am i right?

I will try after new library will be release by you.
 

Computersmith64

Well-Known Member
Licensed User
Longtime User
Added v4.10 update to first post.

- Colin.
 

hatzisn

Expert
Licensed User
Longtime User

RJB

Active Member
Licensed User
Longtime User
Just to clarify, does " connectWifiAP: (connects to an existing Wifi Network) " mean ' to a previously saved AP' .
thanks
 

Computersmith64

Well-Known Member
Licensed User
Longtime User
Just to clarify, does " connectWifiAP: (connects to an existing Wifi Network) " mean ' to a previously saved AP' .
thanks
Yes it does, but unlike reconnectWifiAP you need to provide credentials for a secure network. It's more intended for Q+ connections to existing secure networks (because reconnectWifiAP won't work for a secure network), but you can also use it for P- devices.

- Colin.
 

RJB

Active Member
Licensed User
Longtime User
Thanks.
I've updated an APP to the V4.10 library but am having problems getting it going. Probably doing something stupid!
I've extracted the code for testing (Zip attached) and below is the logs from running it on Android 4, 9 and 10 (added comments are in [ ] ).
Could I ask you to take a look and see if you can see what I'm doing wrong? XXXXXX was the AP I was trying to connect to connect to. It does exist and can be found on each device. It is an ESP32 with no internet access.
Thanks
B4X:
Android 10
==========
permissions OK
224: WiFi Enabled, WiFi Connected
Online
Ping OK
Data via Mobile            [Not true]
Old SSID: TALKTALKCBE7C4
Connect Saved
[MLwifi] (Q+) Connecting to XXXXXXXX
** Activity (main) Pause event (activity is not paused). **
[MLwifi] XXXXXX not available
** Activity (main) Resume **
[no return from Wait For]

Message on phone screen:
Something came up. The application has cancelled the request to choose a device.


Android 9
=========
224: WiFi Enabled, WiFi Connected
Online
Ping OK
Data via Mobile            [Not true - No SIM]
Old SSID: TALKTALKCBE7C4
Connect Saved
[MLwifi] Connecting to "XXXXXXXXXX"
[MLwifi] Connecting to "XXXXXXXXXX"
[no return from Wait For]


Android 4
=========
224: WiFi Enabled, WiFi Connected
Online
Ping OK
Data via Mobile
Old SSID: TALKTALKCBE7C4
Connect Saved
[MLwifi] Connecting to "XXXXXXX"
[no return from Wait For]
[Note: Wifi left connected to new AP]
 

Attachments

  • WifiTest.zip
    11.8 KB · Views: 366
Last edited:

Computersmith64

Well-Known Member
Licensed User
Longtime User
Thanks.
I've updated an APP to the V4.10 library but am having problems getting it going. Probably doing something stupid!
I've extracted the code for testing (Zip attached) and below is the logs from running it on Android 4, 9 and 10 (added comments are in [ ] ).
Could I ask you to take a look and see if you can see what I'm doing wrong? XXXXXX was the AP I was trying to connect to connect to. It does exist and can be found on each device. It is an ESP32 with no internet access.
Thanks
You're not using the correct signature for the ConnectionResult callback. Instead of
B4X:
wait for W_ConnectionResult (SAP1 As Boolean)
you need to use
B4X:
Wait For Wifi_ConnectionResult(success As Boolean)

I made that change (& changed the name & password of the AP to match mine) & ran it on a 4.4.2 device & it connected. Oh - I also changed the targetSdkVersion to 29 in the manifest, but I don't think that would necessarily make a difference.

- Colin.
 
Last edited:
  • Like
Reactions: RJB

RJB

Active Member
Licensed User
Longtime User
Colin, Thanks I'd been looking at that all day and never saw it! I guess the 'Wifi' is 'hardwired' in the library as there's no '.initialize(Eventname......'?
I've tried it with the following results:
Android 4, works fine.
Android 10, works but there's a temporary message 'Device to use with B4A example... Cancel/ Connect' which is then replaced by the permanent
'Something came up. The application has cancelled the request to choose a device' message mentioned above. Can these messages be avoided?
Android 9: Crashes with the following message in release or debug mode:
B4X:
Connect Saved
[MLwifi] Connecting to "AdzDisplay"
[MLwifi] Connecting to "AdzDisplay"
[type: WIFI[], state: DISCONNECTED/DISCONNECTED, reason: (unspecified), extra: (none), failover: false, available: true, roaming: false]
[type: WIFI[], state: DISCONNECTED/DISCONNECTED, reason: (unspecified), extra: (none), failover: false, available: true, roaming: false]
[type: WIFI[], state: DISCONNECTED/SCANNING, reason: (unspecified), extra: (none), failover: false, available: true, roaming: false]
[type: WIFI[], state: DISCONNECTED/DISCONNECTED, reason: (unspecified), extra: (none), failover: false, available: true, roaming: false]
[type: WIFI[], state: DISCONNECTED/SCANNING, reason: (unspecified), extra: (none), failover: false, available: true, roaming: false]
[type: WIFI[], state: DISCONNECTED/DISCONNECTED, reason: (unspecified), extra: (none), failover: false, available: true, roaming: false]
[type: WIFI[], state: DISCONNECTED/SCANNING, reason: (unspecified), extra: (none), failover: false, available: true, roaming: false]
[type: WIFI[], state: DISCONNECTED/DISCONNECTED, reason: (unspecified), extra: (none), failover: false, available: true, roaming: false]
[type: WIFI[], state: DISCONNECTED/SCANNING, reason: (unspecified), extra: (none), failover: false, available: true, roaming: false]
[type: WIFI[], state: DISCONNECTED/DISCONNECTED, reason: (unspecified), extra: (none), failover: false, available: true, roaming: false]
[type: WIFI[], state: CONNECTING/CONNECTING, reason: (unspecified), extra: (none), failover: false, available: true, roaming: false]
[type: WIFI[], state: CONNECTING/AUTHENTICATING, reason: (unspecified), extra: (none), failover: false, available: true, roaming: false]
[type: WIFI[], state: CONNECTING/AUTHENTICATING, reason: (unspecified), extra: (none), failover: false, available: true, roaming: false]
[type: WIFI[], state: CONNECTING/CONNECTING, reason: (unspecified), extra: (none), failover: false, available: true, roaming: false]
[type: WIFI[], state: CONNECTING/OBTAINING_IPADDR, reason: (unspecified), extra: (none), failover: false, available: true, roaming: false]
[type: WIFI[], state: CONNECTING/OBTAINING_IPADDR, reason: (unspecified), extra: (none), failover: false, available: true, roaming: false]
[type: WIFI[], state: CONNECTED/CONNECTED, reason: (unspecified), extra: (none), failover: false, available: true, roaming: false]
java.lang.RuntimeException: Error receiving broadcast Intent { act=android.net.wifi.STATE_CHANGE flg=0x4000010 (has extras) } in com.airlinemates.mlwifi.MLwifi$3@5182afa
    at android.app.LoadedApk$ReceiverDispatcher$Args.lambda$getRunnable$0(LoadedApk.java:1401)
    at android.app.-$$Lambda$LoadedApk$ReceiverDispatcher$Args$_BumDX2UKsnxLVrE6UJsJZkotuA.run(Unknown Source:2)
    at android.os.Handler.handleCallback(Handler.java:873)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:193)
    at android.app.ActivityThread.main(ActivityThread.java:6702)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:911)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference
    at com.airlinemates.mlwifi.MLwifi$3.onReceive(MLwifi.java:1041)
    at android.app.LoadedApk$ReceiverDispatcher$Args.lambda$getRunnable$0(LoadedApk.java:1391)
    ... 8 more

Any thoughts?
Thanks
Robin
 

Computersmith64

Well-Known Member
Licensed User
Longtime User
Colin, Thanks I'd been looking at that all day and never saw it! I guess the 'Wifi' is 'hardwired' in the library as there's no '.initialize(Eventname......'?
I've tried it with the following results:
Android 4, works fine.
Android 10, works but there's a temporary message 'Device to use with B4A example... Cancel/ Connect' which is then replaced by the permanent
'Something came up. The application has cancelled the request to choose a device' message mentioned above. Can these messages be avoided?
Android 9: Crashes with the following message in release or debug mode:
B4X:
Connect Saved
[MLwifi] Connecting to "AdzDisplay"
[MLwifi] Connecting to "AdzDisplay"
[type: WIFI[], state: DISCONNECTED/DISCONNECTED, reason: (unspecified), extra: (none), failover: false, available: true, roaming: false]
[type: WIFI[], state: DISCONNECTED/DISCONNECTED, reason: (unspecified), extra: (none), failover: false, available: true, roaming: false]
[type: WIFI[], state: DISCONNECTED/SCANNING, reason: (unspecified), extra: (none), failover: false, available: true, roaming: false]
[type: WIFI[], state: DISCONNECTED/DISCONNECTED, reason: (unspecified), extra: (none), failover: false, available: true, roaming: false]
[type: WIFI[], state: DISCONNECTED/SCANNING, reason: (unspecified), extra: (none), failover: false, available: true, roaming: false]
[type: WIFI[], state: DISCONNECTED/DISCONNECTED, reason: (unspecified), extra: (none), failover: false, available: true, roaming: false]
[type: WIFI[], state: DISCONNECTED/SCANNING, reason: (unspecified), extra: (none), failover: false, available: true, roaming: false]
[type: WIFI[], state: DISCONNECTED/DISCONNECTED, reason: (unspecified), extra: (none), failover: false, available: true, roaming: false]
[type: WIFI[], state: DISCONNECTED/SCANNING, reason: (unspecified), extra: (none), failover: false, available: true, roaming: false]
[type: WIFI[], state: DISCONNECTED/DISCONNECTED, reason: (unspecified), extra: (none), failover: false, available: true, roaming: false]
[type: WIFI[], state: CONNECTING/CONNECTING, reason: (unspecified), extra: (none), failover: false, available: true, roaming: false]
[type: WIFI[], state: CONNECTING/AUTHENTICATING, reason: (unspecified), extra: (none), failover: false, available: true, roaming: false]
[type: WIFI[], state: CONNECTING/AUTHENTICATING, reason: (unspecified), extra: (none), failover: false, available: true, roaming: false]
[type: WIFI[], state: CONNECTING/CONNECTING, reason: (unspecified), extra: (none), failover: false, available: true, roaming: false]
[type: WIFI[], state: CONNECTING/OBTAINING_IPADDR, reason: (unspecified), extra: (none), failover: false, available: true, roaming: false]
[type: WIFI[], state: CONNECTING/OBTAINING_IPADDR, reason: (unspecified), extra: (none), failover: false, available: true, roaming: false]
[type: WIFI[], state: CONNECTED/CONNECTED, reason: (unspecified), extra: (none), failover: false, available: true, roaming: false]
java.lang.RuntimeException: Error receiving broadcast Intent { act=android.net.wifi.STATE_CHANGE flg=0x4000010 (has extras) } in com.airlinemates.mlwifi.MLwifi$3@5182afa
    at android.app.LoadedApk$ReceiverDispatcher$Args.lambda$getRunnable$0(LoadedApk.java:1401)
    at android.app.-$$Lambda$LoadedApk$ReceiverDispatcher$Args$_BumDX2UKsnxLVrE6UJsJZkotuA.run(Unknown Source:2)
    at android.os.Handler.handleCallback(Handler.java:873)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:193)
    at android.app.ActivityThread.main(ActivityThread.java:6702)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:911)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference
    at com.airlinemates.mlwifi.MLwifi$3.onReceive(MLwifi.java:1041)
    at android.app.LoadedApk$ReceiverDispatcher$Args.lambda$getRunnable$0(LoadedApk.java:1391)
    ... 8 more

Any thoughts?
Thanks
Robin
For Q+, try increasing the timeout to at least 30 seconds. 10 seconds isn't enough. I'll have to look at the crash...

- Colin.
 

RJB

Active Member
Licensed User
Longtime User
Hi,
Tried with 30 and 60 seconds - same result.
Set to 60S the first message appears after about 10 seconds and is replaced by the second after about another 30 seconds.
 

Computersmith64

Well-Known Member
Licensed User
Longtime User
Android 10, works but there's a temporary message 'Device to use with B4A example... Cancel/ Connect' which is then replaced by the permanent
'Something came up. The application has cancelled the request to choose a device' message mentioned above. Can these messages be avoided?

Actually it wasn't working, but you aren't checking the success parameter in Wifi_ConnectionResult (see my numbered comments below), so your code is incorrectly reporting that it connected.

The functionality behind the saveWifiAP is a bit flakey in Q (in fact it's already been changed in Android R). What's supposed to happen is a request to connect to the ssid should appear in your device's notifications - however it can take a very long time & a lot of the time it doesn't appear at all. The main reason for using saveWifiAP on Q+ devices is if you're trying to connect to a network that has internet access, because connectWifiAP will only connect to peer-to-peer networks (ie: no internet connectivity) on Q+. Even if you use saveWifiAP on Q+, the network won't be saved to the device's network list (I kept the function name for consistency with previous versions of the library & because it does save the network on pre Q devices) . If you're connecting to an AP you know exists, you're better off using connectWifiAP as you'll get a more consistent experience

If you want to know more about how network connections work in Q+, you can look here for the functionality behind connectWifiAP or here for the functionality behind saveWifiAP.

The message dialogs that come up can't be avoided. They are part of the Q+ connection process.

Android 9: Crashes with the following message in release or debug mode:
Surprise, surprise, functions that work with Android O- devices & functions that work with Android Q+ devices don't work with Android P devices! I have slightly changed the connection implementation & tested that it works on 4.4.2, 9 & 10 devices.

I realize that the test app you posted is just that - however I have a couple of comments about it.

1) You need to check the success parameter in Wifi_ConnectionResult, because it will return false if the connection attempt fails or times out. You can't assume that success will always be true.

2) isSavedWifiAP will always fail in Q+. There's currently no way to get a list of saved networks on Q+ devices. The only thing you can do is call connectWifiAP with the correct parameters for the AP you want to connect to & if the network exists it will show up in the "Device to use with..." dialog.

3) I haven't modified any functions in the library other than those listed in the first post of this thread, so depending on which version of Android the device is running, calling the other functions may or may not work as expected.

I've attached v4.20 of the library to the first post in this thread.

- Colin.
 

RJB

Active Member
Licensed User
Longtime User
Hi, It will take me a while to work through that lot!!! My initial reaction is 'what a crock Android is'! This is the second time this month where I've had to spend days trying to find a workaround for 'improvements' in recent versions. And the workarounds just produce worse user experiences that the previous versions.
I was logging the result of 1) in Button1_click (returned from line 121 in WifiFunctions) and I thought it had worked, but it's not now!
re. 2) if you call connectWifiAP but the AP is not saved then it will presumably fail? Conversely what will happen if you try to save one that is already saved? Do we have to always use saveWifiAP, just in case?
re. 3) who knows what they may have changed, with or without them documenting the changes!! How can you trust anything they do?
I'll try to have a go with v4.20 later today,
Thanks for your help. I seem to remember the library was originally called 'Simple Wifi Library' - not any more!!
 

Computersmith64

Well-Known Member
Licensed User
Longtime User
Hi, It will take me a while to work through that lot!!! My initial reaction is 'what a crock Android is'! This is the second time this month where I've had to spend days trying to find a workaround for 'improvements' in recent versions. And the workarounds just produce worse user experiences that the previous versions.
I guess that's one of the compromises of working with an "open" system like Android - although having said that, Apple have done some things to recent versions of iOS that have made life very hard for developers too. The issues are compounded when you have to rely on libraries to have access to native functionality - especially in cases like this where a lot of the original functionality in the library is deprecated & needs to be updated. Not a criticism of B4X, but a reality we have to live with. Unfortunately we're not all whizz-bang library wrappers, so we have to rely on those who are (this is the first library I've had a serious go at, so I'm struggling a bit too).

I was logging the result of 1) in Button1_click (returned from line 121 in WifiFunctions) and I thought it had worked, but it's not now!
Yeah - you just need to make sure that success = true.

re. 2) if you call connectWifiAP but the AP is not saved then it will presumably fail? Conversely what will happen if you try to save one that is already saved? Do we have to always use saveWifiAP, just in case?
If you call connectWifiAP with the correct parameters, it will work as long as the network you're trying to connect to exists (regardless of whether it's saved or not). If you call reconnectWifiAP on an unsaved network it will fail. If you try to save an already saved network in P- it will overwrite the existing one, but in Q+ the attempt to save will be ignored & the existing one will be connected to (assuming the credentials are correct & the user accepts the connection attempt).

re. 3) who knows what they may have changed, with or without them documenting the changes!! How can you trust anything they do?
I'll try to have a go with v4.20 later today,
Thanks for your help. I seem to remember the library was originally called 'Simple Wifi Library' - not any more!!
When I get a device with Android R on it (I have one on order) I'm pretty sure I'll have to make more changes...

- Colin.
 
  • Like
Reactions: RJB

RJB

Active Member
Licensed User
Longtime User
Agree with your comments above! I bet you wish you hadn't started to look at it? But thanks for doing so as it needs doing.
I've done some more testing with V4.20 with mixed results and some very long delays as shown in the logs below ( my comments again added in [ ]s):
B4X:
Android 4 AP CLEARED in device settings
---------------------------------------
Connect to New
==============
OldAP = TALKTALKCBE7C4
Old SSID: TALKTALKCBE7C4
Connect Save New
Connect Save New 2
Set AP = true : XXXXXXXX
Reconnect to old
================
Old SSID: AdzDisplay
Connect Saved
Unregistering Receiver
Reset AP = false : TALKTALKCBE7C4
[i.e.worked, but where did the 'Unregistering Receiver' come from? and why does it report Reset AP = false?]
[also some very long delays]

Android 4 AP SAVED in device settings
-------------------------------------
Connect to New
==============
OldAP = TALKTALKCBE7C4
Old SSID: TALKTALKCBE7C4
Connect Saved
Set AP = true : XXXXXXXX
Reconnect to old
================
Old SSID: XXXXXXXX
Connect Saved
[about 20 seconds delay at this point]
Unregistering Receiver
Reset AP = false : TALKTALKCBE7C4
[i.e.worked, but where did the 'Unregistering Receiver' come from? and why does it report Reset AP = false?]


Android 9 AP CLEARED in device settings
---------------------------------------
permissions OK
Connect to New
==============
OldAP = TALKTALKCBE7C4
Old SSID: TALKTALKCBE7C4
Connect Saved        [W.isSavedWifiAP(APName) must be reporting true! It definately isn't stored on the 'settings' list before or after running]
java.io.IOException: sendto failed: ENETUNREACH (Network is unreachable)
    at libcore.io.IoBridge.maybeThrowAfterSendto(IoBridge.java:576)
    at libcore.io.IoBridge.sendto(IoBridge.java:544)
    at java.net.PlainDatagramSocketImpl.send(PlainDatagramSocketImpl.java:125)
    at java.net.DatagramSocket.send(DatagramSocket.java:721)
    at anywheresoftware.b4a.objects.SocketWrapper$UDPSocket$1.run(SocketWrapper.java:479)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:458)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
    at java.lang.Thread.run(Thread.java:764)
Caused by: android.system.ErrnoException: sendto failed: ENETUNREACH (Network is unreachable)
    at libcore.io.Linux.sendtoBytes(Native Method)
    at libcore.io.Linux.sendto(Linux.java:227)
    at libcore.io.BlockGuardOs.sendto(BlockGuardOs.java:307)
    at libcore.io.IoBridge.sendto(IoBridge.java:542)
    ... 8 more
Set AP = false : TALKTALKCBE7C4
Unregistering Receiver [where does this come from?]

Android 9 AP SAVED in device settings
-------------------------------------
permissions OK
Connect to New
==============
OldAP = TALKTALKCBE7C4
Old SSID: TALKTALKCBE7C4
Connect Saved
Set AP = true : XXXXXXXX    [worked OK]
Reconnect to old
================
Old SSID: XXXXXXXX
Connect Saved
Reset AP = false : TALKTALKCBE7C4    [worked OK]
Unregistering Receiver            [but where did this come from and waht does it mean?]
Connect to New
==============
OldAP = TALKTALKCBE7C4
Old SSID: TALKTALKCBE7C4
Connect Saved
Set AP = false : TALKTALKCBE7C4        [failed second time]
Reconnect to old
================
Old SSID: TALKTALKCBE7C4
already Connected            [to be expected as still connected]
Reset AP = true : TALKTALKCBE7C4

Android 10 AP CLEARED in device settings
----------------------------------------
permissions OK
Connect to New
==============
OldAP = TALKTALKCBE7C4
Old SSID: TALKTALKCBE7C4
Android 10 + connect
Set AP = true : TALKTALKCBE7C4
** Activity (main) Pause event (activity is not paused). **
** Activity (main) Resume **
Reconnect to old
================
Reset AP = true : XXXXXXX    [i.e. W.GetSSID is reporting the wrong AP]
[Is actually reset as shown below]
Reconnect to old
================
Reset AP = true : TALKTALKCBE7C4
[XXXXXXX details not stored in 'settings' list, which is correct I think?]

Android 9 AP MANUALLY SAVED in device settings
----------------------------------------------
permissions OK
Connect to New
==============
OldAP = TALKTALKCBE7C4
Old SSID: TALKTALKCBE7C4
Android 10 + connect
Set AP = true : TALKTALKCBE7C4
** Activity (main) Pause event (activity is not paused). **
** Activity (main) Resume **
Reconnect to old
================
Reset AP = true : XXXXXXXX    [as above wrong AP reported]
Reconnect to old
================
Reset AP = true : TALKTALKCBE7C4
 

Computersmith64

Well-Known Member
Licensed User
Longtime User
Agree with your comments above! I bet you wish you hadn't started to look at it? But thanks for doing so as it needs doing.
I've done some more testing with V4.20 with mixed results and some very long delays as shown in the logs below ( my comments again added in [ ]s):
B4X:
Android 4 AP CLEARED in device settings
---------------------------------------
Connect to New
==============
OldAP = TALKTALKCBE7C4
Old SSID: TALKTALKCBE7C4
Connect Save New
Connect Save New 2
Set AP = true : XXXXXXXX
Reconnect to old
================
Old SSID: AdzDisplay
Connect Saved
Unregistering Receiver
Reset AP = false : TALKTALKCBE7C4
[i.e.worked, but where did the 'Unregistering Receiver' come from? and why does it report Reset AP = false?]
[also some very long delays]

Android 4 AP SAVED in device settings
-------------------------------------
Connect to New
==============
OldAP = TALKTALKCBE7C4
Old SSID: TALKTALKCBE7C4
Connect Saved
Set AP = true : XXXXXXXX
Reconnect to old
================
Old SSID: XXXXXXXX
Connect Saved
[about 20 seconds delay at this point]
Unregistering Receiver
Reset AP = false : TALKTALKCBE7C4
[i.e.worked, but where did the 'Unregistering Receiver' come from? and why does it report Reset AP = false?]


Android 9 AP CLEARED in device settings
---------------------------------------
permissions OK
Connect to New
==============
OldAP = TALKTALKCBE7C4
Old SSID: TALKTALKCBE7C4
Connect Saved        [W.isSavedWifiAP(APName) must be reporting true! It definately isn't stored on the 'settings' list before or after running]
java.io.IOException: sendto failed: ENETUNREACH (Network is unreachable)
    at libcore.io.IoBridge.maybeThrowAfterSendto(IoBridge.java:576)
    at libcore.io.IoBridge.sendto(IoBridge.java:544)
    at java.net.PlainDatagramSocketImpl.send(PlainDatagramSocketImpl.java:125)
    at java.net.DatagramSocket.send(DatagramSocket.java:721)
    at anywheresoftware.b4a.objects.SocketWrapper$UDPSocket$1.run(SocketWrapper.java:479)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:458)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
    at java.lang.Thread.run(Thread.java:764)
Caused by: android.system.ErrnoException: sendto failed: ENETUNREACH (Network is unreachable)
    at libcore.io.Linux.sendtoBytes(Native Method)
    at libcore.io.Linux.sendto(Linux.java:227)
    at libcore.io.BlockGuardOs.sendto(BlockGuardOs.java:307)
    at libcore.io.IoBridge.sendto(IoBridge.java:542)
    ... 8 more
Set AP = false : TALKTALKCBE7C4
Unregistering Receiver [where does this come from?]

Android 9 AP SAVED in device settings
-------------------------------------
permissions OK
Connect to New
==============
OldAP = TALKTALKCBE7C4
Old SSID: TALKTALKCBE7C4
Connect Saved
Set AP = true : XXXXXXXX    [worked OK]
Reconnect to old
================
Old SSID: XXXXXXXX
Connect Saved
Reset AP = false : TALKTALKCBE7C4    [worked OK]
Unregistering Receiver            [but where did this come from and waht does it mean?]
Connect to New
==============
OldAP = TALKTALKCBE7C4
Old SSID: TALKTALKCBE7C4
Connect Saved
Set AP = false : TALKTALKCBE7C4        [failed second time]
Reconnect to old
================
Old SSID: TALKTALKCBE7C4
already Connected            [to be expected as still connected]
Reset AP = true : TALKTALKCBE7C4

Android 10 AP CLEARED in device settings
----------------------------------------
permissions OK
Connect to New
==============
OldAP = TALKTALKCBE7C4
Old SSID: TALKTALKCBE7C4
Android 10 + connect
Set AP = true : TALKTALKCBE7C4
** Activity (main) Pause event (activity is not paused). **
** Activity (main) Resume **
Reconnect to old
================
Reset AP = true : XXXXXXX    [i.e. W.GetSSID is reporting the wrong AP]
[Is actually reset as shown below]
Reconnect to old
================
Reset AP = true : TALKTALKCBE7C4
[XXXXXXX details not stored in 'settings' list, which is correct I think?]

Android 9 AP MANUALLY SAVED in device settings
----------------------------------------------
permissions OK
Connect to New
==============
OldAP = TALKTALKCBE7C4
Old SSID: TALKTALKCBE7C4
Android 10 + connect
Set AP = true : TALKTALKCBE7C4
** Activity (main) Pause event (activity is not paused). **
** Activity (main) Resume **
Reconnect to old
================
Reset AP = true : XXXXXXXX    [as above wrong AP reported]
Reconnect to old
================
Reset AP = true : TALKTALKCBE7C4

The "Unregistering Receiver" is a debugging message I put in while I was working on the library & I forgot to remove it. It doesn't mean anything useful & I'll remove it on the next update.

Are these logs produced from the code you sent me? I don't see a lot of these log statements in the code ("Reset AP", "Connect to New", "Reconnect to old") & I don't see any [Mlwifi] logs - so I don't know what functions you're calling.

- Colin.
 

RJB

Active Member
Licensed User
Longtime User
Yes sorry I should have re-attached the zip file, now done.
I've re-run the tests and added the new results, with debug enabled, after '[with Debug]' . I've left the old results, with my comments, for comparison. Mostly they are the same but not all, in particular in the Android 9 'AP Cleared' case where the 'java.io.IOException' has gone.
Thanks again for your help with this
Robin
B4X:
Android 4 AP CLEARED in device settings
---------------------------------------
Connect to New
==============
OldAP = TALKTALKCBE7C4
Old SSID: TALKTALKCBE7C4
Connect Save New
Connect Save New 2
Set AP = true : XXXXXXXX
Reconnect to old
================
Old SSID: XXXXXXXX
Connect Saved
Unregistering Receiver
Reset AP = false : TALKTALKCBE7C4
[i.e.worked, but where did the 'Unregistering Receiver' come from? and why does it report Reset AP = false?]
[also some very long delays]

[With Debug]
Connect to New
==============
OldAP = TALKTALKCBE7C4
Old SSID: TALKTALKCBE7C4
Connect Save New
[MLwifi] Connecting to "XXXXXXXX"
Connect Save New 2
NetworkInfo: type: WIFI[], state: CONNECTED/CONNECTED, reason: (unspecified), extra: "TALKTALKCBE7C4", roaming: false, failover: false, isAvailable: true, isConnectedToProvisioningNetwork: false, simId: 0
[MLwifi] Connected to "XXXXXXXX"
NetworkInfo: type: WIFI[], state: DISCONNECTED/DISCONNECTED, reason: (unspecified), extra: <unknown ssid>, roaming: false, failover: false, isAvailable: true, isConnectedToProvisioningNetwork: false, simId: 0
NetworkInfo: type: WIFI[], state: DISCONNECTED/DISCONNECTED, reason: (unspecified), extra: <unknown ssid>, roaming: false, failover: false, isAvailable: true, isConnectedToProvisioningNetwork: false, simId: 0
Set AP = true : XXXXXXXX
NetworkInfo: type: WIFI[], state: CONNECTING/OBTAINING_IPADDR, reason: (unspecified), extra: "XXXXXXXX", roaming: false, failover: false, isAvailable: true, isConnectedToProvisioningNetwork: false, simId: 0
NetworkInfo: type: WIFI[], state: CONNECTING/VERIFYING_POOR_LINK, reason: (unspecified), extra: "XXXXXXXX", roaming: false, failover: false, isAvailable: true, isConnectedToProvisioningNetwork: false, simId: 0
NetworkInfo: type: WIFI[], state: CONNECTING/CAPTIVE_PORTAL_CHECK, reason: (unspecified), extra: "XXXXXXXX", roaming: false, failover: false, isAvailable: true, isConnectedToProvisioningNetwork: false, simId: 0
NetworkInfo: type: WIFI[], state: CONNECTED/CONNECTED, reason: (unspecified), extra: "XXXXXXXX", roaming: false, failover: false, isAvailable: true, isConnectedToProvisioningNetwork: false, simId: 0
Reconnect to old
================
Old SSID: XXXXXXXX
Connect Saved
[MLwifi] Connecting to "TALKTALKCBE7C4"
[MLwifi] Connecting to "TALKTALKCBE7C4"
NetworkInfo: type: WIFI[], state: DISCONNECTED/DISCONNECTED, reason: (unspecified), extra: <unknown ssid>, roaming: false, failover: false, isAvailable: true, isConnectedToProvisioningNetwork: false, simId: 0
NetworkInfo: type: WIFI[], state: DISCONNECTED/DISCONNECTED, reason: (unspecified), extra: <unknown ssid>, roaming: false, failover: false, isAvailable: true, isConnectedToProvisioningNetwork: false, simId: 0
NetworkInfo: type: WIFI[], state: CONNECTING/OBTAINING_IPADDR, reason: (unspecified), extra: "TALKTALKCBE7C4", roaming: false, failover: false, isAvailable: true, isConnectedToProvisioningNetwork: false, simId: 0
NetworkInfo: type: WIFI[], state: CONNECTING/VERIFYING_POOR_LINK, reason: (unspecified), extra: "TALKTALKCBE7C4", roaming: false, failover: false, isAvailable: true, isConnectedToProvisioningNetwork: false, simId: 0
NetworkInfo: type: WIFI[], state: CONNECTING/CAPTIVE_PORTAL_CHECK, reason: (unspecified), extra: "TALKTALKCBE7C4", roaming: false, failover: false, isAvailable: true, isConnectedToProvisioningNetwork: false, simId: 0
NetworkInfo: type: WIFI[], state: CONNECTED/CONNECTED, reason: (unspecified), extra: "TALKTALKCBE7C4", roaming: false, failover: false, isAvailable: true, isConnectedToProvisioningNetwork: false, simId: 0
NetworkInfo: type: WIFI[], state: CONNECTING/VERIFYING_POOR_LINK, reason: (unspecified), extra: "TALKTALKCBE7C4", roaming: false, failover: false, isAvailable: true, isConnectedToProvisioningNetwork: false, simId: 0
NetworkInfo: type: WIFI[], state: CONNECTING/CAPTIVE_PORTAL_CHECK, reason: (unspecified), extra: "TALKTALKCBE7C4", roaming: false, failover: false, isAvailable: true, isConnectedToProvisioningNetwork: false, simId: 0
NetworkInfo: type: WIFI[], state: CONNECTED/CONNECTED, reason: (unspecified), extra: "TALKTALKCBE7C4", roaming: false, failover: false, isAvailable: true, isConnectedToProvisioningNetwork: false, simId: 0
Unregistering Receiver
Reset AP = false : TALKTALKCBE7C4


Android 4 AP SAVED in device settings
-------------------------------------
Connect to New
==============
OldAP = TALKTALKCBE7C4
Old SSID: TALKTALKCBE7C4
Connect Saved
Set AP = true : XXXXXXXX
Reconnect to old
================
Old SSID: XXXXXXXX
Connect Saved
[about 20 seconds delay at this point]
Unregistering Receiver
Reset AP = false : TALKTALKCBE7C4
[i.e.worked, but where did the 'Unregistering Receiver' come from? and why does it report Reset AP = false?]

[with debug]
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
Connect to New
==============
OldAP = TALKTALKCBE7C4
Old SSID: TALKTALKCBE7C4
Connect Saved
[MLwifi] Connecting to "XXXXXXXX"
NetworkInfo: type: WIFI[], state: CONNECTED/CONNECTED, reason: (unspecified), extra: "TALKTALKCBE7C4", roaming: false, failover: false, isAvailable: true, isConnectedToProvisioningNetwork: false, simId: 0
NetworkInfo: type: WIFI[], state: DISCONNECTED/DISCONNECTED, reason: (unspecified), extra: <unknown ssid>, roaming: false, failover: false, isAvailable: true, isConnectedToProvisioningNetwork: false, simId: 0
NetworkInfo: type: WIFI[], state: DISCONNECTED/DISCONNECTED, reason: (unspecified), extra: <unknown ssid>, roaming: false, failover: false, isAvailable: true, isConnectedToProvisioningNetwork: false, simId: 0
NetworkInfo: type: WIFI[], state: CONNECTING/OBTAINING_IPADDR, reason: (unspecified), extra: "XXXXXXXX", roaming: false, failover: false, isAvailable: true, isConnectedToProvisioningNetwork: false, simId: 0
NetworkInfo: type: WIFI[], state: CONNECTING/VERIFYING_POOR_LINK, reason: (unspecified), extra: "XXXXXXXX", roaming: false, failover: false, isAvailable: true, isConnectedToProvisioningNetwork: false, simId: 0
NetworkInfo: type: WIFI[], state: CONNECTING/CAPTIVE_PORTAL_CHECK, reason: (unspecified), extra: "XXXXXXXX", roaming: false, failover: false, isAvailable: true, isConnectedToProvisioningNetwork: false, simId: 0
NetworkInfo: type: WIFI[], state: CONNECTED/CONNECTED, reason: (unspecified), extra: "XXXXXXXX", roaming: false, failover: false, isAvailable: true, isConnectedToProvisioningNetwork: false, simId: 0
[MLwifi] Connected to "XXXXXXXX"
Set AP = true : XXXXXXXX
Reconnect to old
================
Old SSID: XXXXXXXX
Connect Saved
[MLwifi] Connecting to "TALKTALKCBE7C4"
[MLwifi] Connecting to "TALKTALKCBE7C4"
NetworkInfo: type: WIFI[], state: DISCONNECTED/DISCONNECTED, reason: (unspecified), extra: <unknown ssid>, roaming: false, failover: false, isAvailable: true, isConnectedToProvisioningNetwork: false, simId: 0
NetworkInfo: type: WIFI[], state: DISCONNECTED/DISCONNECTED, reason: (unspecified), extra: <unknown ssid>, roaming: false, failover: false, isAvailable: true, isConnectedToProvisioningNetwork: false, simId: 0
NetworkInfo: type: WIFI[], state: CONNECTING/OBTAINING_IPADDR, reason: (unspecified), extra: "TALKTALKCBE7C4", roaming: false, failover: false, isAvailable: true, isConnectedToProvisioningNetwork: false, simId: 0
NetworkInfo: type: WIFI[], state: CONNECTING/VERIFYING_POOR_LINK, reason: (unspecified), extra: "TALKTALKCBE7C4", roaming: false, failover: false, isAvailable: true, isConnectedToProvisioningNetwork: false, simId: 0
NetworkInfo: type: WIFI[], state: CONNECTING/CAPTIVE_PORTAL_CHECK, reason: (unspecified), extra: "TALKTALKCBE7C4", roaming: false, failover: false, isAvailable: true, isConnectedToProvisioningNetwork: false, simId: 0
NetworkInfo: type: WIFI[], state: CONNECTED/CONNECTED, reason: (unspecified), extra: "TALKTALKCBE7C4", roaming: false, failover: false, isAvailable: true, isConnectedToProvisioningNetwork: false, simId: 0
NetworkInfo: type: WIFI[], state: CONNECTING/VERIFYING_POOR_LINK, reason: (unspecified), extra: "TALKTALKCBE7C4", roaming: false, failover: false, isAvailable: true, isConnectedToProvisioningNetwork: false, simId: 0
NetworkInfo: type: WIFI[], state: CONNECTING/CAPTIVE_PORTAL_CHECK, reason: (unspecified), extra: "TALKTALKCBE7C4", roaming: false, failover: false, isAvailable: true, isConnectedToProvisioningNetwork: false, simId: 0
NetworkInfo: type: WIFI[], state: CONNECTED/CONNECTED, reason: (unspecified), extra: "TALKTALKCBE7C4", roaming: false, failover: false, isAvailable: true, isConnectedToProvisioningNetwork: false, simId: 0
Unregistering Receiver
Reset AP = false : TALKTALKCBE7C4


Android 9 AP CLEARED in device settings
---------------------------------------
permissions OK
Connect to New
==============
OldAP = TALKTALKCBE7C4
Old SSID: TALKTALKCBE7C4
Connect Saved        [W.isSavedWifiAP(APName) must be reporting true! It definately isn't stored on the 'settings' list before or after running]
java.io.IOException: sendto failed: ENETUNREACH (Network is unreachable)
    at libcore.io.IoBridge.maybeThrowAfterSendto(IoBridge.java:576)
    at libcore.io.IoBridge.sendto(IoBridge.java:544)
    at java.net.PlainDatagramSocketImpl.send(PlainDatagramSocketImpl.java:125)
    at java.net.DatagramSocket.send(DatagramSocket.java:721)
    at anywheresoftware.b4a.objects.SocketWrapper$UDPSocket$1.run(SocketWrapper.java:479)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:458)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
    at java.lang.Thread.run(Thread.java:764)
Caused by: android.system.ErrnoException: sendto failed: ENETUNREACH (Network is unreachable)
    at libcore.io.Linux.sendtoBytes(Native Method)
    at libcore.io.Linux.sendto(Linux.java:227)
    at libcore.io.BlockGuardOs.sendto(BlockGuardOs.java:307)
    at libcore.io.IoBridge.sendto(IoBridge.java:542)
    ... 8 more
Set AP = false : TALKTALKCBE7C4
Unregistering Receiver [where does this come from?]

[with Debug]
permissions OK
Connect to New
==============
OldAP = TALKTALKCBE7C4
Old SSID: TALKTALKCBE7C4
Connect Saved
[MLwifi] Connecting to "XXXXXXXX"
[type: WIFI[], state: CONNECTED/CONNECTED, reason: (unspecified), extra: (none), failover: false, available: true, roaming: false]
[type: WIFI[], state: DISCONNECTED/DISCONNECTED, reason: (unspecified), extra: (none), failover: false, available: true, roaming: false]
[type: WIFI[], state: DISCONNECTED/DISCONNECTED, reason: (unspecified), extra: (none), failover: false, available: true, roaming: false]
[type: WIFI[], state: DISCONNECTED/DISCONNECTED, reason: (unspecified), extra: (none), failover: false, available: true, roaming: false]
[type: WIFI[], state: DISCONNECTED/SCANNING, reason: (unspecified), extra: (none), failover: false, available: true, roaming: false]
[type: WIFI[], state: DISCONNECTED/DISCONNECTED, reason: (unspecified), extra: (none), failover: false, available: true, roaming: false]
[type: WIFI[], state: CONNECTING/CONNECTING, reason: (unspecified), extra: (none), failover: false, available: true, roaming: false]
[type: WIFI[], state: CONNECTING/AUTHENTICATING, reason: (unspecified), extra: (none), failover: false, available: true, roaming: false]
[type: WIFI[], state: CONNECTING/AUTHENTICATING, reason: (unspecified), extra: (none), failover: false, available: true, roaming: false]
[type: WIFI[], state: CONNECTING/CONNECTING, reason: (unspecified), extra: (none), failover: false, available: true, roaming: false]
[type: WIFI[], state: CONNECTING/OBTAINING_IPADDR, reason: (unspecified), extra: (none), failover: false, available: true, roaming: false]
[type: WIFI[], state: CONNECTING/OBTAINING_IPADDR, reason: (unspecified), extra: (none), failover: false, available: true, roaming: false]
[type: WIFI[], state: CONNECTED/CONNECTED, reason: (unspecified), extra: (none), failover: false, available: true, roaming: false]
[type: WIFI[], state: CONNECTED/CONNECTED, reason: (unspecified), extra: (none), failover: false, available: true, roaming: false]
Set AP = false : TALKTALKCBE7C4
Unregistering Receiver
[Error above not logged but Connect has failed - reconnect tried this time]
Reconnect to old
================
Old SSID: TALKTALKCBE7C4
already Connected
Reset AP = true : TALKTALKCBE7C4    [Correct as Connect failed]


Android 9 AP SAVED in device settings
-------------------------------------
permissions OK
Connect to New
==============
OldAP = TALKTALKCBE7C4
Old SSID: TALKTALKCBE7C4
Connect Saved
Set AP = true : XXXXXXXX    [worked OK]
Reconnect to old
================
Old SSID: XXXXXXXX
Connect Saved
Reset AP = false : TALKTALKCBE7C4    [worked OK]
Unregistering Receiver            [but where did this come from and waht does it mean?]
Connect to New
==============
OldAP = TALKTALKCBE7C4
Old SSID: TALKTALKCBE7C4
Connect Saved
Set AP = false : TALKTALKCBE7C4        [failed second time]
Reconnect to old
================
Old SSID: TALKTALKCBE7C4
already Connected            [to be expected as still connected]
Reset AP = true : TALKTALKCBE7C4

[With Debug]
permissions OK
Connect to New
==============
OldAP = TALKTALKCBE7C4
Old SSID: TALKTALKCBE7C4
Connect Saved
[MLwifi] Connecting to "XXXXXXXX"
[MLwifi] Connecting to "XXXXXXXX"
[type: WIFI[], state: CONNECTED/CONNECTED, reason: (unspecified), extra: (none), failover: false, available: true, roaming: false]
[type: WIFI[], state: DISCONNECTED/DISCONNECTED, reason: (unspecified), extra: (none), failover: false, available: true, roaming: false]
[type: WIFI[], state: DISCONNECTED/DISCONNECTED, reason: (unspecified), extra: (none), failover: false, available: true, roaming: false]
[type: WIFI[], state: DISCONNECTED/DISCONNECTED, reason: (unspecified), extra: (none), failover: false, available: true, roaming: false]
[type: WIFI[], state: DISCONNECTED/SCANNING, reason: (unspecified), extra: (none), failover: false, available: true, roaming: false]
[type: WIFI[], state: DISCONNECTED/DISCONNECTED, reason: (unspecified), extra: (none), failover: false, available: true, roaming: false]
[type: WIFI[], state: CONNECTING/CONNECTING, reason: (unspecified), extra: (none), failover: false, available: true, roaming: false]
[type: WIFI[], state: CONNECTING/AUTHENTICATING, reason: (unspecified), extra: (none), failover: false, available: true, roaming: false]
[type: WIFI[], state: CONNECTING/AUTHENTICATING, reason: (unspecified), extra: (none), failover: false, available: true, roaming: false]
[type: WIFI[], state: CONNECTING/CONNECTING, reason: (unspecified), extra: (none), failover: false, available: true, roaming: false]
[type: WIFI[], state: CONNECTING/OBTAINING_IPADDR, reason: (unspecified), extra: (none), failover: false, available: true, roaming: false]
[type: WIFI[], state: CONNECTING/OBTAINING_IPADDR, reason: (unspecified), extra: (none), failover: false, available: true, roaming: false]
[type: WIFI[], state: CONNECTED/CONNECTED, reason: (unspecified), extra: (none), failover: false, available: true, roaming: false]
[MLwifi] Connected to "XXXXXXXX"
Set AP = true : XXXXXXXX
[type: WIFI[], state: CONNECTED/CONNECTED, reason: (unspecified), extra: (none), failover: false, available: true, roaming: false]
Reconnect to old
================
Old SSID: XXXXXXXX
Connect Saved
[MLwifi] Connecting to "TALKTALKCBE7C4"
[MLwifi] Connecting to "TALKTALKCBE7C4"
[type: WIFI[], state: DISCONNECTED/DISCONNECTED, reason: (unspecified), extra: (none), failover: false, available: true, roaming: false]
[type: WIFI[], state: DISCONNECTED/DISCONNECTED, reason: (unspecified), extra: (none), failover: false, available: true, roaming: false]
[type: WIFI[], state: DISCONNECTED/DISCONNECTED, reason: (unspecified), extra: (none), failover: false, available: true, roaming: false]
[type: WIFI[], state: DISCONNECTED/SCANNING, reason: (unspecified), extra: (none), failover: false, available: true, roaming: false]
[type: WIFI[], state: DISCONNECTED/DISCONNECTED, reason: (unspecified), extra: (none), failover: false, available: true, roaming: false]
[type: WIFI[], state: DISCONNECTED/SCANNING, reason: (unspecified), extra: (none), failover: false, available: true, roaming: false]
[type: WIFI[], state: DISCONNECTED/DISCONNECTED, reason: (unspecified), extra: (none), failover: false, available: true, roaming: false]
[type: WIFI[], state: DISCONNECTED/SCANNING, reason: (unspecified), extra: (none), failover: false, available: true, roaming: false]
[type: WIFI[], state: DISCONNECTED/DISCONNECTED, reason: (unspecified), extra: (none), failover: false, available: true, roaming: false]
[type: WIFI[], state: DISCONNECTED/SCANNING, reason: (unspecified), extra: (none), failover: false, available: true, roaming: false]
[type: WIFI[], state: DISCONNECTED/DISCONNECTED, reason: (unspecified), extra: (none), failover: false, available: true, roaming: false]
[type: WIFI[], state: DISCONNECTED/SCANNING, reason: (unspecified), extra: (none), failover: false, available: true, roaming: false]
[type: WIFI[], state: DISCONNECTED/DISCONNECTED, reason: (unspecified), extra: (none), failover: false, available: true, roaming: false]
[type: WIFI[], state: CONNECTING/CONNECTING, reason: (unspecified), extra: (none), failover: false, available: true, roaming: false]
[type: WIFI[], state: CONNECTING/AUTHENTICATING, reason: (unspecified), extra: (none), failover: false, available: true, roaming: false]
[type: WIFI[], state: CONNECTING/AUTHENTICATING, reason: (unspecified), extra: (none), failover: false, available: true, roaming: false]
[type: WIFI[], state: CONNECTING/CONNECTING, reason: (unspecified), extra: (none), failover: false, available: true, roaming: false]
[type: WIFI[], state: CONNECTING/OBTAINING_IPADDR, reason: (unspecified), extra: (none), failover: false, available: true, roaming: false]
[type: WIFI[], state: CONNECTING/OBTAINING_IPADDR, reason: (unspecified), extra: (none), failover: false, available: true, roaming: false]
[type: WIFI[], state: CONNECTED/CONNECTED, reason: (unspecified), extra: (none), failover: false, available: true, roaming: false]
[type: WIFI[], state: CONNECTED/CONNECTED, reason: (unspecified), extra: (none), failover: false, available: true, roaming: false]
Reset AP = false : TALKTALKCBE7C4
Unregistering Receiver



Android 10 AP CLEARED in device settings
----------------------------------------
permissions OK
Connect to New
==============
OldAP = TALKTALKCBE7C4
Old SSID: TALKTALKCBE7C4
Android 10 + connect
Set AP = true : TALKTALKCBE7C4    [true but W.GetSSID is reporting wrong AP
** Activity (main) Pause event (activity is not paused). **
** Activity (main) Resume **
Reconnect to old
================
Reset AP = true : XXXXXXX    [i.e. W.GetSSID is reporting the wrong AP]
[Is actually reset as shown below]
Reconnect to old
================
Reset AP = true : TALKTALKCBE7C4
[XXXXXXX details not stored in 'settings' list, which is correct?]


[with debug]
permissions OK
Connect to New
==============
OldAP = TALKTALKCBE7C4
Old SSID: TALKTALKCBE7C4
Android 10 + connect
SDK: 29
[MLwifi] (Q+) Connecting to XXXXXXXX
Set AP = true : TALKTALKCBE7C4
** Activity (main) Pause event (activity is not paused). **
** Activity (main) Resume **
[MLwifi] Connected to XXXXXXXX


Android 9 AP MANUALLY SAVED in device settings
----------------------------------------------
permissions OK
Connect to New
==============
OldAP = TALKTALKCBE7C4
Old SSID: TALKTALKCBE7C4
Android 10 + connect
Set AP = true : TALKTALKCBE7C4  [reporting true but old AP]
** Activity (main) Pause event (activity is not paused). **
** Activity (main) Resume **
Reconnect to old
================
Reset AP = true : XXXXXXXX    [as above wrong AP reported]
Reconnect to old
================
Reset AP = true : TALKTALKCBE7C4 [retry, now correct AP]

[with Debug]
PackageAdded: package:b4a.example
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
permissions OK
Connect to New
==============
OldAP = TALKTALKCBE7C4
Old SSID: TALKTALKCBE7C4
Android 10 + connect
SDK: 29
[MLwifi] (Q+) Connecting to XXXXXXXX
Set AP = true : TALKTALKCBE7C4    [reporting true but old AP - this comes up before the on-screen message is OK'd]
** Activity (main) Pause event (activity is not paused). **
** Activity (main) Resume **
[MLwifi] Connected to XXXXXXXX
Reconnect to old
================
Reset AP = true : XXXXXXXX
 

Attachments

  • WifiTest.zip
    12 KB · Views: 283

RJB

Active Member
Licensed User
Longtime User
I've just noticed that I left out the 'wait for Wifi_ConnectionResult (SAP1 As Boolean)' in the Android 29+ case so that would account for some problems.
I'll rerun those tests
 

RJB

Active Member
Licensed User
Longtime User
Android29+ results (please ignore the ones above):
B4X:
Android 10 AP CLEARED in device settings
----------------------------------------
permissions OK
Connect to New
==============
OldAP = TALKTALKCBE7C4
Old SSID: TALKTALKCBE7C4
Android 10 + connect
SDK: 29
[MLwifi] (Q+) Connecting to XXXXXXXX
** Activity (main) Pause event (activity is not paused). **
** Activity (main) Resume **
[MLwifi] Connected to XXXXXXXX
Set AP = true : XXXXXXXX
Reconnect to old
================
Reset AP = true : XXXXXXXX    [Reporting true but wrong AP - Second run below shows correct AP]
Reconnect to old
================
Reset AP = true : TALKTALKCBE7C4

[Those on-screen messages make it look like the most un-professional software ever!!! Thanks Google!]


Android 10 AP MANUALLY SAVED in device settings
----------------------------------------------
permissions OK
Connect to New
==============
OldAP = TALKTALKCBE7C4
Old SSID: TALKTALKCBE7C4
Android 10 + connect
SDK: 29
[MLwifi] (Q+) Connecting to XXXXXXXX
** Activity (main) Pause event (activity is not paused). **
** Activity (main) Resume **
[MLwifi] Connected to XXXXXXXX
Set AP = true : XXXXXXXX
Reconnect to old
================
Reset AP = true : XXXXXXXX
Reconnect to old
================
Reset AP = true : TALKTALKCBE7C4

[as above]
 

RJB

Active Member
Licensed User
Longtime User
I'm working on some changes and simplifications in the test APP, so probably worth waiting for them.
 

RJB

Active Member
Licensed User
Longtime User
Forget that - it fell apart. I don't think you can reset Android 9 without knowing the original password.
(is that the reason for some of the failures???)
 
Top