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

Refactor and Rebuild Entire Plugin - Move to all Async Functions

tripflex opened this issue · comments

So after forking this repo and updating it, adding async methods, and testing on older devices (Android only so far), specifically Lollipop and Marshmello, I think the best way to move forward is to go ahead and refactor the majority of code base to fix issues found along the way.

  • Rename and switch to async promise based methods/functions
    It's 2018, if you're still using callbacks, maybe it's time to update your code base. To keep cleaner code base and easier for handling updates, and docs, going to move away from callbacks and only use promise async based functions

Refactoring

  • Refactor connect to automatically add network and then enable
    Because Android doesn't actually "connect" to networks, you just add the network config and then enable the wifi, i'm going to convert the connect method to automatically add/update the wifi configuration (without throwing errors if unable to update, or add), and as long as there's a valid network ID for the SSID, enable the network .. only throwing errors when connection fails, or no net id was able to be obtained

Oreo issues for modifying existing networks, enabling/disabling/removing networks now only allow the UID that created/added the network to remove/modify, etc.

Because of this, if you want to connect to a network (which code wise is done with enableNetwork), it must be done after adding the network configuration, as only the UID that created the configuration, and modify the state

Current Known Issues

  • Ping on bindall network does not work (assumption is due to using Runtime.getRuntime() but honestly not sure, don't know enough about Android to fix it at this time
    - The only reason I know this was while testing trying to ping router that does not have internet, and was unable to ... but running a standard HTTP GET request from JS worked fine ...

iOS

  • Test existing methods to make sure they still work
  • Update or remove any methods that no longer work

New Features

Connecting your App to a Wi-Fi Device
AnyDevice Example Code

cordova-plugin-network-information

  • Create separate classes and files to better organize all methods and classes
    After my initial fork of this plugin, things have been constantly growing and being added, resulting in a large single file with ~2k lines of code. Need to clean up code base, and move methods/functions/classes to separate files to keep clean codebase.

This is great! I'd love to contribute to the project after I add Java and Xcode to list of technologies I know.

Anyway, may I suggest adding root support as a polyfill for whenever Android may disallow reading/changing system properties? I know it might be a bit of increased development time, but I think would come quite handy for dealing with embedded devices.

Also, it might be a longshot, but while you are planning to implement httpOverWifi, it would be awesome to also have a variation of nanoHTTPD (as an extension, really) in the codebase. (Again, it may be off the subject of WifiWizard2, but I just feel it would be right to do so.)

On the testing matter, I have a collection of Android devices which I'd be glad to be of service using/testing them with WifiWizard2.

Last but not least, thanks for all the work you do rewriting the codebase, it's much appreciated. :)

@DRSDavidSoft no problem! I doubt i'll add the nanohttpd, but in regards to the root polyfill, do you mean like this:
https://github.com/N0ps32/cordova-plugin-root

@tripflex about root polyfill, yes, exactly like that. Although I'm noy sure if for iOS something similar would be applicable, but still in Android it would be useful once root permissions is granted to the host app.

Should this be a separate issue?

@DRSDavidSoft nope it's fine here, i'll try and add it in as well with the update to 3.0.0, keep an eye on this issue, the 3.0.0 branch, and the PR for 3.0.0 for updates

https://github.com/tripflex/WifiWizard2/tree/3.0.0

#8