tripflex / WifiWizard2

A Cordova plugin for managing Wifi networks (new version of WiFiWizard) - Latest is version 3+

Home Page:https://www.npmjs.com/package/cordova-plugin-wifiwizard2

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Version 3.3.0 for Android 10+

matscav opened this issue · comments

Hi all,

I just forked this pull request from @klich3: Pull Request

I made some fixes and I did create another function (suggestConnection) for the new API. You can read more here

If you want to test my code or you need to have this working, here is my repo: 3.3.0
Run cordova plugin add https://github.com/matscav/WifiWizard2#dev

In Android 10+ all you have to do is call WifiWizard2.suggestConnection(SSID, password, algorithm, isHiddenSSID) instead of WifiWizard2.connect(SSID, bindAll, password, algorithm, isHiddenSSID)

Hope this can help anyone!

commented

I made some fixes and I did create another function (suggestConnection) for the new API. You can read more here

If you want to test my code or you need to have this working, here is my repo: 3.3.0 Run cordova plugin add https://github.com/matscav/WifiWizard2#dev

In Android 10+ all you have to do is call WifiWizard2.suggestConnection(SSID, password, algorithm, isHiddenSSID) instead of WifiWizard2.connect(SSID, bindAll, password, algorithm, isHiddenSSID)

Hope this can help anyone!

Hello @matscav,

I have an Ionic project. It works with capacitor. I was able to install your plugin and to call the suggestConnection() method. My hope was that it would connect my test device (Samsung A50, Android 11) to the chosen SSID. This is the code:

WifiWizard2.suggestConnection(SSID, pw, algorithm, isHidden).then( res => { console.log(res); }, err => { console.log(err); } );

I get back as res in the console:

STATUS_NETWORK_SUGGESTIONS_ADDED

This is no error, which is great! However, the test device did not connect to the SSID. Is this the expected behaviour? What would I need to do to connect to the SSID?

Btw, are you still a freelancer? The company in which I work is looking for a plugin developer. Drop me a note if you are interested.

Regards, Rolf

commented

This is no error, which is great! However, the test device did not connect to the SSID. Is this the expected behaviour? What would I need to do to connect to the SSID?

Ok, I assumed that suggestConnection() is a replacement for connect() which has to be used if Android >= 10. That was wrong. The connection works using a Samsung A50 / Android 11 when using the method specifierConnection().

commented

Now I want to restore the original connection. My idea is that I use disconnect(). And then the Smartphone maybe reconnects to the original network. Using disconnect():

If I use no SSID then I get this answer: ERROR_DISCONNECT.
If I use the SSID of the currently connected network then I get this answer: DISCONNECT_NET_ID_NOT_FOUND

So I guess this DISCONNECT_NET_ID_NOT_FOUND is the problem.

The documentation explains:
"Unable to determine network ID to disconnect/remove (from passed SSID)"

So I tried getConnectedNetworkId(), which however gives me a result (e.g. 4)

I tried the disable(). I first got the networkId by using getConnectedNetworkId(), then I call disable() using this networkId. The result is:

UNABLE_TO_DISABLE

Documentation: "Android returned failure in disabling network". And I read: "Please note that most newer versions of Android will only allow you to disable networks created by your application"

So what does it mean: "networks created by your application"?

Does this mean that the app is able to connect to a network, but is not able to disconnect?

Hi all,

I just forked this pull request from @klich3: Pull Request

I made some fixes and I did create another function (suggestConnection) for the new API. You can read more here

If you want to test my code or you need to have this working, here is my repo: 3.3.0 Run cordova plugin add https://github.com/matscav/WifiWizard2#dev

In Android 10+ all you have to do is call WifiWizard2.suggestConnection(SSID, password, algorithm, isHiddenSSID) instead of WifiWizard2.connect(SSID, bindAll, password, algorithm, isHiddenSSID)

Hope this can help anyone!

Thanks, but I can't seem to enable WiFi (turn WiFi on) if it's off on Android 10 devices (or where I target SDK>=30 (I've tried your fork too).
(I get the message: Uncaught ReferenceError: enabled is not defined) or VERIFY_ERROR_ENABLE_WIFI
Does the function WifiWizard2.setWifiEnabled(enabled); work with devices running Android 10? Or is this currently impossible as per: https://issuetracker.google.com/issues/128554616?pli=1

Thanks!

Hello,

I only added this function "suggestConnection". Maybe you can put some work on those functions that are not working and give it back to community.

Regards!

Hi "matscav" and "f18nfz", in my branch you have both connections one for oldes versions connect directly, and new one with suggest. The Suggest is for new gen Androids oldest one its not working properly because you need authorizations of user.

I thing this project is died and not supported by creator....

commented

Now I want to restore the original connection. My idea is that I use disconnect(). And then the Smartphone maybe reconnects to the original network. Using disconnect():

If I use no SSID then I get this answer: ERROR_DISCONNECT. If I use the SSID of the currently connected network then I get this answer: DISCONNECT_NET_ID_NOT_FOUND

So I guess this DISCONNECT_NET_ID_NOT_FOUND is the problem.

The documentation explains: "Unable to determine network ID to disconnect/remove (from passed SSID)"

So I tried getConnectedNetworkId(), which however gives me a result (e.g. 4)

I tried the disable(). I first got the networkId by using getConnectedNetworkId(), then I call disable() using this networkId. The result is:

UNABLE_TO_DISABLE

Documentation: "Android returned failure in disabling network". And I read: "Please note that most newer versions of Android will only allow you to disable networks created by your application"

So what does it mean: "networks created by your application"?

Does this mean that the app is able to connect to a network, but is not able to disconnect?

still a problem in 2023

commented

@klich3 @f18nfz @matscav @RolfDohrmann
some of the issues have been fixed in my forked repo:
https://github.com/EYALIN/community-cordova-plugin-wifi-wizard

you can install it as an npm package:
cordova plugin add community-cordova-plugin-wifi-wizard --save

@EYALIN
Hello! I'm trying to use your implementation with capacitor and ionic/react. Can yo uhelp with installing your library?
Trying to import your library to use functions from it: import { WifiWizard2 } from 'community-cordova-plugin-wifi-wizard'. Hovewer, i'm getting error: Cannot find module 'community-cordova-plugin-wifi-wizard' or its corresponding type declarations.

commented

@EduardSat you cannot import it directly.
or you can use the ionic wrapper, or you can use windows.wifiwizard2 (not sure if it's there or inside window.plugins)

hope that in the future I will be able to make it strongly typed.

@EduardSat you cannot import it directly. or you can use the ionic wrapper, or you can use windows.wifiwizard2 (not sure if it's there or inside window.plugins)

hope that in the future I will be able to make it strongly typed.

@EYALIN . i found the way to use your edited version. However, when i'm trying to connect to wifi using WifiWizard2.suggestConnection(), i'm always getting STATUS_NETWORK_SUGGESTIONS_ERROR. Can you suggest the way to solve that problem? And also i'm getting the error: DISABLE_NETWORK_NOT_FOUND, when i'm calling WifiWizard2.disable('ssid')

commented

@EduardSat i'm using it like this:

  if (+this.device.version > 10) {
                result = await (window as any).WifiWizard2.specifierConnection(wifiNetwork,wifiPassword, networkType, false);
            } else {
                result = await (window as any).WifiWizard2.connect(wifiNetwork, true,wifiPassword, networkType);
            }

regarding the disable, i think it's deprecated from Android 12.