Closed tripflex closed 6 years ago
Right now this is what I have to do to get this to work correctly, which seems kinda overkill:
let ssid = "some-ssid";
cordovaNetworkManager.getCurrentSSID( function( currentSSID ){
console.log( 'GET CURRENT SSID', currentSSID );
cordovaNetworkManager.androidConnectNetwork(ssid, currentSSID, function(s){
console.log('Connected to device WiFi...', s );
}, function(f){
console.log( 'Failed to connect to ', ssid );
});
}, function( f ){
console.log( 'FAILURE GET CURRENT SSID', f );
});
But that only works when connected to existing network, if not connected to existing network, it's not even possible to connect ....
Here's something i found on parent repo regarding wifi enabled: https://github.com/hoerresb/WifiWizard/issues/6
Like I've said before, I made this particular part for my personal application/use. It probably wasn't the best for a global solution and therefore was an oversight on my behalf. I need to parse in a very specific network to disable/enable and it isn't always the current network that's connected.
That being said, for a global solution, it would be best to do what you have described above. I am going away next week for 3 weeks however I will look to implement these changes before I go.
Yeah completely understandable, I think I may actually just fork the main WiFiManager plugin and update that one, unless you want me to just submit a PR to you?
I do not mind you submitting a PR. Simply follow the PR template and I'll review it all accordingly. :D
If you want to become a contributor to this plugin, let me know. I will be rewriting the Android platform since the OG WifiWizard is a bit trash and therefore the code in this is trash as well.
Contact me on Discord and we can talk about it more: Nomm#0176
Also see the open issue: https://github.com/arsenal942/Cordova-Network-Manager/issues/8
Fixed as of release v2.2.0.
You can now just give it an empty string or a null object and it will still work.
If you notice the issue again, just create a new issue referencing this.
Regarding the
androidConnectToNetwork
though, it looks like an SSID to disconnect from MUST be passed otherwise it will error out, so from what I can tell, that's not an "optional" argument, which shouldn't it be?My thought on this would be to check if WiFi is already connected, and if so, get the current SSID, and use that for the
currentNetworkId
... right?