Git Product home page Git Product logo

wifiwizard2's Introduction

WiFiWizard2 - 3.1.1

Table of Contents

About

WifiWizard2 enables Wifi management for both Android and iOS applications within Cordova/Phonegap projects.

This project is a fork of the WifiWizard plugin with fixes and updates, as well as patches taken from the Cordova Network Manager plugin.

Version 3.0.0+ has undergone a TON of changes from the original fork (version 2.0), and the majority of method/functions have been changed. You can find the latest release of version 2 on the 2.1.x branch

The recommended version to use is the latest 3+ as that is the version that is actively maintained.

iOS has limited functionality as Apple's WifiManager equivalent is only available as a private API. Any app that used these features would not be allowed on the app store.

If you are an iOS developer, please consider helping us to resolve the open iOS issues

If you are an Android developer, please consider helping us to refactor the current code base

If you're a Cordova developer, please consider helping out this project, open a new issue, a PR, or contact me directly

Basics

This plugin creates the object WifiWizard2 and is accessible after deviceready has been fired, see Cordova deviceready Event Docs

document.addEventListener('deviceready', function () {
    // Call some WifiWizard2.method after deviceready fired
}, false);

This is really only necessary if you plan on immediately invoking one of this plugin's methods/functions, as the majority of the time you would probably just call the method/function on say, a button click to scan for networks, etc. Basically if you are going to call something immediately when a webview is shown, make sure to add the event listener for deviceready before making that call, otherwise you probably don't need to.

Async Handling

Because Cordova exec calls are made asynchronously, all methods/functions return async promises. These functions will return the results, or a JavaScript error. You should use await and try/catch blocks (or .then and .catch). See below for more details, and examples.

Callbacks are not longer supported in this plugin

Promises are handled by the Cordova PromisesPlugin as an ES6 polyfill if your application does not already define window.Promise

Demo Meteor Project

To test this plugin as well as provide some example code for others to work off of, I have created an example Meteor project you can find here:

https://github.com/tripflex/WifiWizard2Demo

This demo has examples of using both async functions (with async/await and try/catch blocks), as well as non async functions with .then and .catch

Android and IOS Permissions and Notes

In order to obtain scan results (to call scan or startScan then getScanResults) your application must have the ACCESS_FINE_LOCATION Android Permission. You can do this by calling the requestPermission method detailed below, or this plugin will automagically do this for you when you call scan or startScan functions.

Newer versions of Android will not allow you to remove, update existing configuration, or disable networks that were not created by your application. If you are having issues using this features, with your device connected to your computer, run adb logcat to view Android Logs for specific error.

IOS Notes

iOS 12 and later, enable the Access WiFi Information capability for your app in Xcode. If you also want to use the iOS specific connection functions the Hotspot Configuration capability. When you enable this capability, Xcode automatically adds the Access WiFi Information entitlement to your entitlements file and App ID.

Ionic/Angular Notes

This plugin does not have @ionic/native typings (yet), in order to use it add this to just below your import list on your service: declare var WifiWizard2: any;

Global Functions

These are functions that can be used by both Android and iOS applications

WifiWizard2.getConnectedSSID()
  • Returns connected network SSID (only if connected) in success callback, otherwise fail callback will be called (if not connected or unable to retrieve)
  • This does NOT return the BSSID if unable to obtain SSID (like original WifiWizard did)
WifiWizard2.getConnectedBSSID()
  • Same as above, except BSSID (mac) is returned
WifiWizard2.timeout(delay)
  • delay should be time in milliseconds to delay
  • Helper async timeout delay, delay is optional, default is 2000ms = 2 seconds
  • This method always returns a resolved promise after the delay, it will never reject or throw an error

Example inside async function

async function example(){
    await WifiWizard2.timeout(4000);
    // do something after 4 seconds
}

Example inside standard non-async function

function example(){
    WifiWizard2.timeout(4000).then( function(){
        // do something after waiting 4 seconds
    }):
}

Thrown Errors

  • TIMEOUT_WAITING_FOR_SCAN on timeout waiting for scan 10 seconds +
  • SCAN_FAILED if unable to start scan

iOS Functions

For functionality, you need to note the following:

  • Connect/Disconnect only works for iOS11+
  • Can not run in the simulator so you need to attach an actual device when building with Xcode
  • Make sure 'HotspotConfiguration' and 'NetworkExtensions' capabilities are added to your Xcode project
  • To connect to open network omit ssidPassword or call with false
WifiWizard2.iOSConnectNetwork(ssid, ssidPassword)
WifiWizard2.iOSDisconnectNetwork(ssid)

Android Functions

  • WifiWizard2 will automagically try to enable WiFi if it's disabled when calling any android related methods that require WiFi to be enabled

Connect vs Enable

When writing Android Java code, there is no connect methods, you basically either enable or disable a network. In the original versions of WifiWizard the connect method would basically just call enable in Android. I have changed the way this works in WifiWizard2 version 3.0.0+, converting it to a helper method to eliminate having to call formatWifiConfig then add and then enable ... the connect method will now automatically call formatWifiConfig, then call add to either add or update the network configuration, and then call enable. If the connect method is unable to update existing network configuration (added by user or other apps), but there is a valid network ID, it will still attempt to enable that network ID.

WifiWizard2.connect(ssid, bindAll, password, algorithm, isHiddenSSID)
  • ssid should be the SSID to connect to required
  • bindAll should be set to true to tell Android to route all connections from your Android app, through the wifi connection (default is false) optional
    • See WifiWizard2.enable for more details regarding bindAll feature
  • algorithm and password is not required if connecting to an open network
  • Currently WPA and WEP are only supported algorithms
  • For WPA2 just pass WPA as the algorithm
  • Set isHiddenSSID to true if the network you're connecting to is hidden
  • These arguments are the same as for formatWifiConfig
  • This method essentially calls formatWifiConfig then add then enable
  • If unable to update network configuration (was added by user or other app), but a valid network ID exists, this method will still attempt to enable the network
  • Promise will not be returned until method has verified that connection to WiFi was in completed state (waits up to 60 seconds)

Thrown Errors

  • CONNECT_FAILED_TIMEOUT unable to verify connection, timed out after 60 seconds
  • INVALID_NETWORK_ID_TO_CONNECT Unable to connect based on generated wifi config
  • INTERPUT_EXCEPT_WHILE_CONNECTING Interupt exception while waiting for connection

Disconnect vs Disable

Same as above for Connect vs Enable, except in this situation, disconnect will first disable the network, and then attempt to remove it (if SSID is passed)

WifiWizard2.disconnect(ssid)
  • ssid can either be an SSID (string) or a network ID (integer)
  • ssid is OPTIONAL .. if not passed, will disconnect current WiFi (almost all Android versions now will just automatically reconnect to last wifi after disconnecting)
  • If ssid is provided, this method will first attempt to disable and then remove the network
  • If you do not want to remove network configuration, use disable instead

Thrown Errors

  • DISCONNECT_NET_REMOVE_ERROR Android returned error when removing wifi configuration
  • DISCONNECT_NET_DISABLE_ERROR Unable to connect based on generated wifi config
  • DISCONNECT_NET_ID_NOT_FOUND Unable to determine network ID to disconnect/remove (from passed SSID)
  • ERROR_DISCONNECT - Android error disconnecting wifi (only when SSID is not passed)
WifiWizard2.formatWifiConfig(ssid, password, algorithm, isHiddenSSID)
  • algorithm and password is not required if connecting to an open network
  • Currently WPA and WEP are only supported algorithms
  • For WPA2 just pass WPA as the algorithm
  • Set isHiddenSSID to true if the network you're connecting to is hidden
WifiWizard2.formatWPAConfig(ssid, password, isHiddenSSID)
  • This is just a helper method that calls WifiWizard2.formatWifiConfig( ssid, password, 'WPA', isHiddenSSID );
WifiWizard2.add(wifi)
  • wifi must be an object formatted by formatWifiConfig, this must be done before calling enable

Thrown Errors

  • AUTH_TYPE_NOT_SUPPORTED - Invalid auth type specified
  • ERROR_ADDING_NETWORK - Android returned -1 specifying error adding network
  • ERROR_UPDATING_NETWORK - Same as above, except an existing network ID was found, and unable to update it
WifiWizard2.remove(ssid)
  • ssid can either be an SSID (string) or a network ID (integer)
  • Please note, most newer versions of Android will only allow wifi to be removed if created by your application

Thrown Errors

  • UNABLE_TO_REMOVE Android returned failure in removing network
  • REMOVE_NETWORK_NOT_FOUND Unable to determine network ID from passed SSID
WifiWizard2.listNetworks()
WifiWizard2.scan([options])
  • Same as calling startScan and then getScanResults, except this method will only resolve the promise after the scan completes and returns the results.
WifiWizard2.startScan()
  • It is recommended to just use the scan method instead of startScan

Thrown Errors

  • STARTSCAN_FAILED Android returned failure in starting scan
WifiWizard2.getScanResults([options])
  • getScanResults should only be called after calling startScan (it is recommended to use scan instead as this starts the scan, then returns the results)
  • [options] is optional, if you do not want to specify, just pass success callback as first parameter, and fail callback as second parameter
  • Retrieves a list of the available networks as an array of objects and passes them to the function listHandler. The format of the array is:
networks = [
    {   "level": signal_level, // raw RSSI value
        "SSID": ssid, // SSID as string, with escaped double quotes: "\"ssid name\""
        "BSSID": bssid // MAC address of WiFi router as string
        "frequency": frequency of the access point channel in MHz
        "capabilities": capabilities // Describes the authentication, key management, and encryption schemes supported by the access point.
        "timestamp": timestamp // timestamp of when the scan was completed
        "channelWidth":
        "centerFreq0":
        "centerFreq1":
    }
]
  • channelWidth centerFreq0 and centerFreq1 are only supported on API > 23 (Marshmallow), any older API will return null for these values

An options object may be passed. Currently, the only supported option is numLevels, and it has the following behavior:

  • if (n == true || n < 2), *.getScanResults({numLevels: n}) will return data as before, split in 5 levels;
  • if (n > 1), *.getScanResults({numLevels: n}) will calculate the signal level, split in n levels;
  • if (n == false), *.getScanResults({numLevels: n}) will use the raw signal level;
WifiWizard2.isWifiEnabled()
  • Returns boolean value of whether Wifi is enabled or not
WifiWizard2.setWifiEnabled(enabled)
  • Pass true for enabled parameter to set Wifi enabled
  • You do not need to call this function to set WiFi enabled to call other methods that require wifi enabled. This plugin will automagically enable WiFi if a method is called that requires WiFi to be enabled.

Thrown Errors

  • ERROR_SETWIFIENABLED wifi state does not match call (enable or disable)
WifiWizard2.getConnectedNetworkID()
  • Returns currently connected network ID in success callback (only if connected), otherwise fail callback will be called

Thrown Errors

  • GET_CONNECTED_NET_ID_ERROR Unable to determine currently connected network ID (may not be connected)

New to 3.1.1+

WifiWizard2.resetBindAll()
  • Disable bindAll to WiFi network without disconnecting from WiFi
WifiWizard2.setBindAll()
  • Enable bindAll to WiFi network without disconnecting from WiFi
WifiWizard2.canConnectToInternet()
  • Returns boolean, true or false, if device is able to connect to https://www.google.com via HTTP connection (since ping is unreliable)
  • Unknown errors will still be thrown like all other async functions
  • If you called connect or enable and passed true for bindAll, your application will force the ping through wifi connection.
  • If you did not pass true (or passed false) for bindAll, and the wifi does not have internet connection, Android Lollipop+ (API 21+) will use cell connection to ping (due to Android using cell connection when wifi does not have internet) More Details
WifiWizard2.canConnectToRouter()
  • As canPingWifiRouter is notoriously unreliable, this method uses HTTP connection to test if able to connect to router (as most routers should have web server running on port 80)
  • Unknown errors will still be thrown like all other async functions
  • This is useful for testing to make sure that your Android app is able to connect to the private network after connecting to WiFi
  • This was added for testing the bindAll feature to support issues with Android Lollipop+ (API 21+) not routing calls through WiFi if WiFi does not have internet connection See Android Blog
  • Attempts to connect router IP HTTP server on port 80 (example: http://192.168.0.1/ where 192.168.0.1 is the automatically detected IP address)

New to 3.0.0+

WifiWizard2.isConnectedToInternet()
  • Returns boolean, true or false, if device is able to ping 8.8.8.8
  • Unknown errors will still be thrown like all other async functions
  • If you called connect or enable and passed true for bindAll, your application will force the ping through wifi connection.
  • If you did not pass true (or passed false) for bindAll, and the wifi does not have internet connection, Android Lollipop+ (API 21+) will use cell connection to ping (due to Android using cell connection when wifi does not have internet) More Details
WifiWizard2.canPingWifiRouter()
  • Returns boolean, true or false, if device is able to ping the connected WiFi router IP (obtained from DHCP info)
  • Version 3.1.1+ uses HTTP connection to test if able to connect to router (as ping previous did not work)
  • Unknown errors will still be thrown like all other async functions
  • This is useful for testing to make sure that your Android app is able to connect to the private network after connecting to WiFi
  • This was added for testing the bindAll feature to support issues with Android Lollipop+ (API 21+) not routing calls through WiFi if WiFi does not have internet connection See Android Blog
WifiWizard2.enableWifi()
WifiWizard2.disableWifi()
WifiWizard2.getWifiIP()
  • Returns IPv4 address of currently connected WiFi, or rejects promise if IP not found or wifi not connected
WifiWizard2.getWifiRouterIP()
  • Returns IPv4 WiFi router IP from currently connected WiFi, or rejects promise if unable to determine, or wifi not connected

Thrown Errors

  • NO_VALID_IP_IDENTIFIED if unable to determine a valid IP (ip returned from device is 0.0.0.0)
WifiWizard2.getWifiIPInfo()
  • Returns a JSON object with IPv4 address and subnet {"ip": "192.168.1.2", "subnet": "255.255.255.0" } or rejected promise if not found or not connected Thrown Errors

  • NO_VALID_IP_IDENTIFIED if unable to determine a valid IP (ip returned from device is 0.0.0.0)

WifiWizard2.reconnect()
  • Reconnect to the currently active access point, if we are currently disconnected.

Thrown Errors

  • ERROR_RECONNECT Android returned error when reconnecting
WifiWizard2.reassociate()
  • Reconnect to the currently active access point, even if we are already connected.

Thrown Errors

  • ERROR_REASSOCIATE Android returned error when reassociating
WifiWizard2.getSSIDNetworkID(ssid)
  • Get Android Network ID from passed SSID
WifiWizard2.disable(ssid)
  • ssid can either be an SSID (string) or a network ID (integer)
  • Disable the passed SSID network
  • Please note that most newer versions of Android will only allow you to disable networks created by your application

Thrown Errors

  • UNABLE_TO_DISABLE Android returned failure in disabling network
  • DISABLE_NETWORK_NOT_FOUND Unable to determine network ID from passed SSID to disable
WifiWizard2.requestPermission()
  • Request ACCESS_FINE_LOCATION permssion
  • This Android permission is required to run scan, startStart and getScanResults
  • You can request permission by running this function manually, or WifiWizard2 will automagically request permission when one of the functions above is called

Thrown Errors

  • PERMISSION_DENIED user denied permission on device
WifiWizard2.enable(ssid, bindAll, waitForConnection)
  • ssid can either be an SSID (string) or a network ID (integer)
  • bindAll should be set to true to tell Android to route all connections from your Android app, through the wifi connection
    • Android Lollipop+ (API 21+) will not route connections to the WiFi device if it does not have internet connection. Passing true to bindAll will force Android to route connections from your Android app through Wifi, regardless of internet connection.
    • If you are having problems connecting to a local IP through WiFi because it does not have internet, try enabling bindAll and this should fix the problem.
    • During my testing, some versions of Android (5.0 - 7.1.2) would still route connections through WiFi without internet, but it was random that some versions would and would not work.
    • Testing Android Oreo+ (8.0.0+) if wifi does not have internet, 100% of the time it would NOT route connections through WiFi, so you must enable this for Oreo or newer to route connections from your application through wifi without internet.
    • When bindAll is enabled, ALL connections from your app will be routed through WiFi, until you call disconnect or disable
    • See the Google Android Blog for More Details
    • This feature ONLY works for Android Lollipop+ (API 21+), if device is running API older than 21, bindall will be ignored (as API older than 21 does this by default)
  • Enable the passed SSID network
  • You MUST call WifiWizard2.add(wifi) before calling enable as the wifi configuration must exist before you can enable it (or previously used connect without calling disconnect)
  • This method does NOT wait or verify connection to wifi network, pass true to waitForConnection to only return promise once connection is verified in COMPLETED state to specific ssid

Thrown Errors

UNABLE_TO_ENABLE - Android returned -1 signifying failure enabling

Installation

Master

Run cordova plugin add https://github.com/tripflex/wifiwizard2

To install from the master branch (latest on GitHub)

To install a specific branch (add #tag replacing tag with tag from this repo, example: cordova plugin add https://github.com/tripflex/wifiwizard2#v3.1.1

Find available tags here: https://github.com/tripflex/WifiWizard2/tags

If you are wanting to have the latest and greatest stable version, then run the 'Releases' command below.

Releases

Run cordova plugin add cordova-plugin-wifiwizard2

Meteor

To install and use this plugin in a Meteor project, you have to specify the exact version from NPM repository: https://www.npmjs.com/package/cordova-plugin-wifiwizard2

As of April 4th 2019, the latest version is 3.1.1:

meteor add cordova:[email protected]

Errors/Rejections

Methods now return formatted string errors as detailed below, instead of returning generic error messages. This allows you to check yourself what specific error was returned, and customize the error message. In an upcoming release I may add easy ways to override generic messages, or set your own, but for now, errors returned can be found below each method/function.

Generic Thrown Errors

WIFI_NOT_ENABLED

Examples

Please see demo Meteor project for code examples: https://github.com/tripflex/WifiWizard2Demo

Ionic/Angular Example (User Provided)

Props @13546777510 (Angelo Fan) has provided a basic Ionic/Angluar demo app: https://github.com/13546777510/WifiWizard2-Demo See issue #69 regarding this

I recommend using ES6 arrow functions to maintain this reference. This is especially useful if you're using Blaze and Meteor.

this.FirstName = 'John';

wifiConnection.then( result => {
   // Do something after connecting!
   // Using arrow functions, you still have access to `this`
   console.log( this.FirstName + ' connected to wifi!' );
});

#License Apache 2.0

Changelog:

3.1.1 - April 4, 2019

  • Fixed/Added location services check for Android 9+ for any method that utilises the getConnectionInfo method. Issue #71 (@arsenal942)
  • Move verifyWifiEnabled() to after methods that do not require wifi to be enabled. Issue #54 (@props seanyang1984)
  • Added canConnectToRouter() and canConnectToInternet() to use HTTP to test connection (since ping is notoriously unreliable)
  • Added canConnectToRouter(), canConnectToInternet(), canPingWifiRouter(), isConnectedToInternet() to iOS fn return not supported
  • Added resetBindAll() and setBindAll() for Android (props @saoron PR #74)
  • Use JSONObject.NULL instead of just null when scan results Android older than Marshmallow (props @seanyang1984) Issue #51

3.1.0 - August 28, 2018

  • Fixed/Added compatibility with iOS to connect to open network
  • Fixed Uncaught SyntaxError in JavaScript from using let (changed to var)
  • Fixed main thread blocked while connecting to a network by connecting asynchronously (props @jack828)
  • Add isHiddenSSID config for connecting Android devices to hidden networks (props @jack828)
  • Update iOSConnectNetwork to return real response in promise (props @saoron)
  • Correct iOS SSID comparison (props @saoron)
  • iOS Add HotspotConfiguration & NetworkExtension capabilities automatically (props @saoron)
  • Removed jdk.nashorn.internal.codegen.CompilerConstants import (props @jack828)
  • Reduce connection retry count from 60 -> 15 (props @jack828)
  • Fixed Object cannot be converted to int in Android code (props @xLarry)
  • Props to @arsenal942 @jack828 @xLarry @saoron for contributions

3.0.0 - April 12, 2018

  • Completely refactored JS methods, all now return Promises
  • Added getWifiIP and getWifiIPInfo functions
  • Added getWifiRouterIP function
  • Changed method names to be more generalized (connect instead of androidConnectNetwork, etc)
  • Added requestPermission and automatic request permission when call method that requires them
  • Added isConnectedToInternet to ping 8.8.8.8 and verify if wifi has internet connection
  • Added canPingWifiRouter to ping wifi router IP obtained through DHCP information
  • Added bindAll feature to use bindProcessToNetwork for Marshmallow (API 23+) and setProcessDefaultNetwork for Lollipop (API 21-22) More Details
  • Converted connect to helper method that calls formatWifiConfig then add then enable
  • Converted disconnect to helper method that calls disable then remove
  • Updated add method to set priority of added wifi to highest priority (locates max priority on existing networks and sets to +1)
  • Completely refactored and updated all documentation and examples
  • Added ping Android Java code for possible new methods to ping custom IP/URL (in upcoming releases)
  • Updated all error callbacks to use detectable strings (for custom error messages, instead of generic ones)
  • DO NOT upgrade from version 2.x.x without reading ENTIRE README! Method/Function names have all been changed!

2.1.1 - 1/9/2018

  • Added Async Promise based methods
  • Fix issue with thread running before wifi is fully enabled
  • Added thread sleep for up to 10 seconds waiting for wifi to enable

2.1.0 - 1/8/2018

  • Added Async Promise based methods
  • Fixed incorrect Android Cordova exec methods incorrectly being called and returned (fixes INVALID ACTION errors/warnings)
  • Updated javascript code to call fail callback when error detected in JS (before calling Cordova)
  • Moved automagically enabling WiFi to exec actions (before actions called that require wifi enabled)
  • Added es6-promise-plugin cordova dependency to plugin.xml
  • Only return false in Cordova Android execute when invalid action is called Issue #1
  • Added JS doc blocks to JS methods
  • Added Async example code

2.0.0 - 1/5/2018

  • Added automatic disable of currently connected network on connect call (to prevent reconnect to previous wifi ssid)
  • Added initial disconnect() before and reconnect() after disable/enable network on connect call
  • Added getConnectedNetworkID to return currently connected network ID
  • Added verifyWiFiEnabled to automatically enable WiFi for methods that require WiFi to be enabled
  • Strip enclosing double quotes returned on getSSID (android) @props lianghuiyuan
  • Fixed Android memory leak @props Maikell84
  • Add new ScanResult fields to results (centerFreq0,centerFreq1,channelWidth) @props essboyer
  • Added getConnectedBSSID to Android platform @props caiocruz
  • Added isWiFiEnabled implementation for ios @props caiocruz
  • Android Marshmallow Location Permissions Request @props jimcortez
  • Only return connected SSID if supplicantState is COMPLETED @props admund1
  • Added support for WEP @props adamtegen
  • Fix null issues with getConnectedSSID @props jeffcharles
  • Added scan method to return networks in callback @props jeffcharles
  • Call success callback after checking connection (on connect to network) @props jeffcharles

Changelog below this line, is from original WifiWizard

v0.2.9

isWifiEnabled bug fixed. level in getScanResults object now refers to raw RSSI value. The function now accepts an options object, and by specifiying { numLevels: value } you can get the old behavior.

v0.2.8

getScanResults now returns the BSSID along with the SSID and strength of the network.

v0.2.7

  • Clobber WifiWizard.js automatically via Cordova plugin architecture

v0.2.6

  • Added isWifiEnabled, setWifiEnabled

v0.2.5

  • Fixes getConnectedSSID error handlers

v0.2.4

  • Added getConnectedSSID method

v0.2.3

  • Added disconnect that does disconnection on current WiFi

v0.2.2

  • Added startScan and getScanResults

v0.2.1

  • Fixed reference problem in formatWPAConfig

v0.2.0

  • Changed format of wifiConfiguration object to allow more extensibility.

v0.1.1

  • addNetwork will now update the network if the SSID already exists.

v0.1.0

  • All functions now work!

v0.0.3

  • Fixed errors in native implementation. Currently, Add and Remove networks aren't working, but others are working as expected.

v0.0.2

  • Changed plugin.xml and WifiWizard.js to attach WifiWizard directly to the HTML.

v0.0.1

  • Initial commit

wifiwizard2's People

Contributors

arsenal942 avatar jack828 avatar machinaexphilip avatar maxcodefaster avatar saoron avatar sarpherviz avatar surajrao avatar tripflex avatar xlarry avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

wifiwizard2's Issues

Android Cordova exec handled all wrong ... should not be returning booleans or false

The ONLY time we should be returning FALSE is when it's an invalid action, otherwise

Any other action returns false and results in an INVALID_ACTION error, which translates to an error callback invoked on the JavaScript side

So that's why I was getting all these Invalid Action errors and error not handled in promises ... due to incorrect Android codebase returning FALSE when it should always return TRUE ... even at that ... almost all functions should be void not boolean bc there's no reason to return true/false as true should always be returned to exec because the callback handles the error! GAWRR!

package org.apache.cordova.plugin;

import org.apache.cordova.CordovaPlugin;
import org.apache.cordova.CallbackContext;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

/**
* This class echoes a string called from JavaScript.
*/
public class Echo extends CordovaPlugin {

@Override
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
    if (action.equals("echo")) {
        String message = args.getString(0);
        this.echo(message, callbackContext);
        return true;
    }
    return false;
}

private void echo(String message, CallbackContext callbackContext) {
    if (message != null && message.length() > 0) {
        callbackContext.success(message);
    } else {
        callbackContext.error("Expected one non-empty string argument.");
    }
}
}

The necessary imports at the top of the file extends the class from CordovaPlugin, whose execute() method it overrides to receive messages from exec(). The execute() method first tests the value of action, for which in this case there is only one valid echo value. Any other action returns false and results in an INVALID_ACTION error, which translates to an error callback invoked on the JavaScript side.

Next, the method retrieves the echo string using the args object's getString method, specifying the first parameter passed to the method. After the value is passed to a private echo method, it is parameter-checked to make sure it is not null or an empty string, in which case callbackContext.error() invokes JavaScript's error callback. If the various checks pass, the callbackContext.success() passes the original message string back to JavaScript's success callback as a parameter.

https://cordova.apache.org/docs/en/latest/guide/platforms/android/plugin.html

Check if Location is enabled otherwise scan returns no results

Issue type

Select all that apply

  • Bug
  • Enhancement
  • Task
  • Question
  • Other

Description

When using the Scan method I get symbol true and value is an empty array. If I try startScan and getScanResults I get the same problem. If I use listNetworks and I connected manually I can see it in the list. I have tried the permissions method and I get "PERMISSION_GRANTED"

Expected behavior:

Return a list of about 15 WiFi Networks

Actual behavior:

No networks

Reproduces how often:

Happens every time

Versions

Ionic - 3.20.0
NPM - 3.10.8
Android 6

ionic cordova build ios ERROR

wifiwizard2 2.1.0 "WifiWizard2"

ld: warning: directory not found for option '-L/Users/bhumin/Library/Developer/Xcode/DerivedData/RTI-aqtvytpqvcxbkaepcfkfyqitbgqv/Build/Products/Debug-iphonesimulator/nanopb'
Undefined symbols for architecture x86_64:
  "_OBJC_CLASS_$_NEHotspotConfigurationManager", referenced from:
      objc-class-ref in WifiWizard2.o
  "_OBJC_CLASS_$_NEHotspotConfiguration", referenced from:
      objc-class-ref in WifiWizard2.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

** BUILD FAILED **

also remove command Not working

cordova plugin remove wifiwizard2 --save
(node:79689) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Cannot find module '../node_modules/xml2js'
(node:79689) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

ionic 3

Select all that apply

  • Bug
  • Enhancement
  • Task
  • [ x] Question
  • Other

Description

Is there a sample prj for ionic 3 using WifiWizard2 to get ssid only ?

t I can not connect to open wifis networks. Install version 3.

Hi, I have version 2.1.1 in my project, it works fine, but I can not connect to open wifis networks, that is, without a password. Since I have no error information, I want to install version 3.0 but I do not know how to do it.

Can you help me?

Thank you

3.0.0 fail to add network if you try a second time

I am trying your 3.0.0 d1b8cde commit. Using android 7.1.1

I have included my code that I am testing with. The issue I am running into is if I run the code after a fresh reboot of the system, I can successfully do a WifiWizard2.add (I have not tried doConnect yet).
then...
if I just try and run the same code again, it fails (I put my function on a button to run my code).
I also added my own log.d with the tag TAO to help me track down stuff that is happening.

I have not made a guess of why that is yet, just pointing it out. But it feels like something with the network ID's when it is trying to update it. something around this line of code in WifiWizard2.java
int updatedNetID = wifiManager.updateNetwork(wifi);

MY CODE

//MY CODE

class ExampleWiFi {
    
    constructor( SSID,password ){
        this.SSID = SSID;
        this.password = password;
        this.delay = 2000; // delay in ms for timeout
    }

	async turnOn(){
		console.log('turning on wifi');
		await this.timeout();
        try {
        	WifiWizard2.setWifiEnabled(true);
        	await this.timeout();
        	await this.connect();
            return true;

        } catch( e ) {

            throw new Error( "Failed to turn on wifi" );

        }		

	}


    async connect(){

        try {

            //SUIBlock.block( 'Attempting to connect...' ); // Example is using my Semantic UI Blocker Meteor plugin ( https://github.com/tripflex/meteor-suiblocker )
            console.log('Attempting to connect...');
            await this.timeout(); // Timeouts are just used to simulate better UI experience when showing messages on screen

            this.config  = WifiWizard2.formatWPAConfig(this.SSID,this.password);
			await this.timeout();
            await this.add();
            //await this.doConnect();

            //SUIBlock.unblock();

            return true;

        } catch( error ){

            console.log( 'Wifi connect catch error: ', error );
            throw new Error( error.message ); // Throw new error to allow async handling calling this method
        }
    }

    

    async add(){

        //SUIBlock.block( 'Adding ' + this.SSID + ' to mobile device...' );
        console.log('Adding ' + this.SSID + ' to mobile device...');
        await this.timeout();

        try {

            //addNetworkAsync is not a function so it errors out, going to try add
            //await WifiWizard2.addNetworkAsync( this.config );
            await WifiWizard2.add( this.config );
            //SUIBlock.block( "Successfully added " + this.SSID );
            console.log("Successfully added " + this.SSID );
            return true;

        } catch( e ) {

            throw new Error( "Failed to add device WiFi network to your mobile device! Please try again, or manually connect to the device, disconnect, and then return here and try again.  Here is the error " + e );

        }
    }

    async doConnect(){

        //SUIBlock.block('Attempting connection to ' + this.SSID + ' ...' );
        console.log('Attempting connection to ' + this.SSID + ' ...');

        await this.timeout();

        try {

            await WifiWizard2.androidConnectNetworkAsync( this.SSID );
            //SUIBlock.block( "Successfully connected to " + this.SSID );
            console.log("Successfully connected to " + this.SSID);
            return true;

        } catch( e ){

            throw new Error( "Failed to connect to device WiFi SSID " + this.SSID );

        }
    }


    /**
     * Synchronous Sleep/Timeout `await this.timeout()`
     */
    timeout() {
        let delay = parseInt( this.delay );
        return new Promise(function(resolve, reject) {
            setTimeout(resolve, delay);
        });
    }
}

module.exports = ExampleWiFi; // Not needed if using Meteor




async function TAOconnectToWifi2()
	{
		    try {
		        let wifi = new ExampleWiFi('myssid','1234567890');
		        //await wifi.connect();
		        await wifi.turnOn();

		        // Do something after WiFi has connected!

		    } catch ( error ){

		        console.log( 'Error connecting to WiFi!', error.message );

		    }
	
		

	}

FRESH REBOOT - 1st time running

//FRESH REBOOT OF SYSTEM

//CONSOLE
turning on wifi
Attempting to connect...
Adding myssid to mobile device...
Successfully added myssid


//logcat

01-29 15:45:33.026  3682  3682 D SystemWebChromeClient:  : turning on wifi
01-29 15:45:33.027  3682  3682 I chromium: [INFO:CONSOLE(576)] "turning on wifi", source: (576)
01-29 15:45:35.029  3682  3851 D WifiWizard2: WifiWizard2: verifyWifiEnabled entered.
01-29 15:45:35.030  3682  3851 I WifiWizard2: Enabling wi-fi...
01-29 15:45:35.035  2685  3047 D WifiService: Trying to set WiFi to: true
01-29 15:45:35.061  3682  3851 I WifiWizard2: Wi-fi enabled
01-29 15:45:35.063  3682  3851 I WifiWizard2: Still waiting for wi-fi to enable...
01-29 15:45:35.072  2685  2698 D WifiService: wifiEnabled: 1 -> 3
01-29 15:45:36.064  2685  2696 D WifiService: Trying to set WiFi to: true
01-29 15:45:36.068  3682  3851 W PluginManager: THREAD WARNING: exec() call to WifiWizard2.setWifiEnabled blocked the main thread for 1038ms. Plugin should use CordovaInterface.getThreadPool().
01-29 15:45:36.436  4097  4097 I CAR.SERVICE: Skip, no clients bound.
01-29 15:45:36.992  3142  3142 I WearableService: Wearable Services stopping
01-29 15:45:38.087  3682  3682 D SystemWebChromeClient:  Attempting to connect...
01-29 15:45:38.087  3682  3682 I chromium: [INFO:CONSOLE(598)] "Attempting to connect...", source:  (598)
01-29 15:45:38.133  2685  2698 D WifiService: Scan Completed
01-29 15:45:38.787  3309  3314 I art     : Do partial code cache collection, code=19KB, data=30KB
01-29 15:45:38.788  3309  3314 I art     : After code cache collection, code=16KB, data=28KB
01-29 15:45:38.788  3309  3314 I art     : Increasing code cache capacity to 128KB
01-29 15:45:42.103  3682  3682 D SystemWebChromeClient: dding myssid to mobile device...
01-29 15:45:42.104  3682  3682 I chromium: [INFO:CONSOLE(622)] "Adding myssid to mobile device...", source:  (622)
01-29 15:45:44.120  3682  3851 D WifiWizard2: WifiWizard2: verifyWifiEnabled entered.
01-29 15:45:44.123  3682  3851 D WifiWizard2: WifiWizard2: add entered.
01-29 15:45:44.140  3682  3851 D TAO     : WifiWizard2: inside authType = WPA
01-29 15:45:44.140  3682  3851 D TAO     : WifiWizard2: newSSID = "myssid"
01-29 15:45:44.140  3682  3851 D TAO     : WifiWizard2: newPass = "1234567890"
01-29 15:45:44.141  3682  3851 D TAO     : WifiWizard2: ssidToNetworkId getconfigured Networks print out = []
01-29 15:45:44.142  3682  3851 D TAO     : WifiWizard2:  getMaxWifiPriority getconfigured Networks print out = []
01-29 15:45:44.142  3682  3851 D WifiWizard2: WifiWizard: Found max WiFi priority of 0
01-29 15:45:44.143  3682  3851 D TAO     : inside wifi.networkid = -1  the wifi var = ID: -1 SSID: "myssid" PROVIDER-NAME: null BSSID: null FQDN: null PRIO: 1 HIDDEN: false
01-29 15:45:44.143  3682  3851 D TAO     :  NetworkSelectionStatus NETWORK_SELECTION_ENABLED
01-29 15:45:44.143  3682  3851 D TAO     :  hasEverConnected: false
01-29 15:45:44.143  3682  3851 D TAO     :  KeyMgmt: WPA_PSK Protocols: WPA RSN
01-29 15:45:44.143  3682  3851 D TAO     :  AuthAlgorithms:
01-29 15:45:44.143  3682  3851 D TAO     :  PairwiseCiphers: TKIP CCMP
01-29 15:45:44.143  3682  3851 D TAO     :  GroupCiphers: TKIP CCMP
01-29 15:45:44.143  3682  3851 D TAO     :  PSK: *
01-29 15:45:44.143  3682  3851 D TAO     : Enterprise config:
01-29 15:45:44.143  3682  3851 D TAO     : IP config:
01-29 15:45:44.143  3682  3851 D TAO     : IP assignment: UNASSIGNED
01-29 15:45:44.143  3682  3851 D TAO     : Proxy settings: UNASSIGNED
01-29 15:45:44.143  3682  3851 D TAO     :  cuid=-1 luid=-1 lcuid=0 userApproved=USER_UNSPECIFIED noInternetAccessExpected=false roamingFailureBlackListTimeMilli: 1000
01-29 15:45:44.143  3682  3851 D TAO     : triggeredLow: 0 triggeredBad: 0 triggeredNotHigh: 0
01-29 15:45:44.143  3682  3851 D TAO     : ticksLow: 0 ticksBad: 0 ticksNotHigh: 0
01-29 15:45:44.143  3682  3851 D TAO     : triggeredJoin: 0
01-29 15:45:44.150  2685  3018 D WifiService: SSID: "myssid" StrippedSSID: myssid
01-29 15:45:44.202  2685  3018 D WifiService: Host returned Guid: 2b34cf58-cea8-4dd8-bc37-5cb68a442157 for Ssid: "myssid"
01-29 15:45:44.203  3682  3851 W PluginManager: THREAD WARNING: exec() call to WifiWizard2.add blocked the main thread for 84ms. Plugin should use CordovaInterface.getThreadPool().
01-29 15:45:44.207  3682  3682 D SystemWebChromeClient: : Successfully added myssid
01-29 15:45:44.208  3682  3682 I chromium: [INFO:CONSOLE(631)] "Successfully added myssid", source: 

running same code a 2nd time

//////////////
///////////////
////////////////
//running the same code a second time right after
//////////////
///////////////
////////////////

//CONSOLE
turning on wifi
Attempting to connect...
Adding myssid to mobile device...
Wifi connect catch error:  Error: Failed to add device WiFi network to your mobile device! Please try again, or manually connect to the device, disconnect, and then return here and try again.  Here is the error ERROR_UPDATING_NETWORK
    at ExampleWiFi.add (
    at <anonymous>
Error connecting to WiFi! Failed to turn on wifi



//logcat
01-29 15:49:18.539  3682  3682 D SystemWebChromeClient:  turning on wifi
01-29 15:49:18.540  3682  3682 I chromium: [INFO:CONSOLE(576)] "turning on wifi",  (576)
01-29 15:49:20.543  3682  3851 D WifiWizard2: WifiWizard2: verifyWifiEnabled entered.
01-29 15:49:20.549  2685  3047 D WifiService: Trying to set WiFi to: true
01-29 15:49:20.566  3682  3851 W PluginManager: THREAD WARNING: exec() call to WifiWizard2.setWifiEnabled blocked the main thread for 21ms. Plugin should use CordovaInterface.getThreadPool().
01-29 15:49:22.574  3682  3682 D SystemWebChromeClient:  Attempting to connect...
01-29 15:49:22.575  3682  3682 I chromium: [INFO:CONSOLE(598)] "Attempting to connect...", source: 
01-29 15:49:25.391  2685  2698 D WifiService: Scan Completed
01-29 15:49:26.588  3682  3682 D SystemWebChromeClient: Adding myssid to mobile device...
01-29 15:49:26.589  3682  3682 I chromium: [INFO:CONSOLE(622)] "Adding myssid to mobile device...", 
01-29 15:49:28.603  3682  3851 D WifiWizard2: WifiWizard2: verifyWifiEnabled entered.
01-29 15:49:28.608  3682  3851 D WifiWizard2: WifiWizard2: add entered.
01-29 15:49:28.608  3682  3851 D TAO     : WifiWizard2: inside authType = WPA
01-29 15:49:28.610  3682  3851 D TAO     : WifiWizard2: newSSID = "myssid"
01-29 15:49:28.612  3682  3851 D TAO     : WifiWizard2: newPass = "1234567890"
01-29 15:49:28.626  3682  3851 D TAO     : WifiWizard2: ssidToNetworkId getconfigured Networks print out = [ID: 0 SSID: "myssid" PROVIDER-NAME: null BSSID: null FQDN: null PRIO: 1 HIDDEN: false
01-29 15:49:28.626  3682  3851 D TAO     :  NetworkSelectionStatus NETWORK_SELECTION_ENABLED
01-29 15:49:28.626  3682  3851 D TAO     :  hasEverConnected: false
01-29 15:49:28.626  3682  3851 D TAO     :  KeyMgmt: WPA_PSK Protocols: WPA RSN
01-29 15:49:28.626  3682  3851 D TAO     :  AuthAlgorithms:
01-29 15:49:28.626  3682  3851 D TAO     :  PairwiseCiphers: TKIP CCMP
01-29 15:49:28.626  3682  3851 D TAO     :  GroupCiphers: TKIP CCMP
01-29 15:49:28.626  3682  3851 D TAO     :  PSK: *
01-29 15:49:28.626  3682  3851 D TAO     : Enterprise config:
01-29 15:49:28.626  3682  3851 D TAO     : IP config:
01-29 15:49:28.626  3682  3851 D TAO     : IP assignment: UNASSIGNED
01-29 15:49:28.626  3682  3851 D TAO     : Proxy settings: UNASSIGNED
01-29 15:49:28.626  3682  3851 D TAO     :  cuid=-1 luid=-1 lcuid=0 userApproved=USER_UNSPECIFIED noInternetAccessExpected=false roamingFailureBlackListTimeMilli: 1000
01-29 15:49:28.626  3682  3851 D TAO     : triggeredLow: 0 triggeredBad: 0 triggeredNotHigh: 0
01-29 15:49:28.626  3682  3851 D TAO     : ticksLow: 0 ticksBad: 0 ticksNotHigh: 0
01-29 15:49:28.626  3682  3851 D TAO     : triggeredJoin: 0
01-29 15:49:28.626  3682  3851 D TAO     : ]
01-29 15:49:28.627  3682  3851 D TAO     : WifiWizard2:  getMaxWifiPriority getconfigured Networks print out = [ID: 0 SSID: "myssid" PROVIDER-NAME: null BSSID: null FQDN: null PRIO: 1 HIDDEN: false
01-29 15:49:28.627  3682  3851 D TAO     :  NetworkSelectionStatus NETWORK_SELECTION_ENABLED
01-29 15:49:28.627  3682  3851 D TAO     :  hasEverConnected: false
01-29 15:49:28.627  3682  3851 D TAO     :  KeyMgmt: WPA_PSK Protocols: WPA RSN
01-29 15:49:28.627  3682  3851 D TAO     :  AuthAlgorithms:
01-29 15:49:28.627  3682  3851 D TAO     :  PairwiseCiphers: TKIP CCMP
01-29 15:49:28.627  3682  3851 D TAO     :  GroupCiphers: TKIP CCMP
01-29 15:49:28.627  3682  3851 D TAO     :  PSK: *
01-29 15:49:28.627  3682  3851 D TAO     : Enterprise config:
01-29 15:49:28.627  3682  3851 D TAO     : IP config:
01-29 15:49:28.627  3682  3851 D TAO     : IP assignment: UNASSIGNED
01-29 15:49:28.627  3682  3851 D TAO     : Proxy settings: UNASSIGNED
01-29 15:49:28.627  3682  3851 D TAO     :  cuid=-1 luid=-1 lcuid=0 userApproved=USER_UNSPECIFIED noInternetAccessExpected=false roamingFailureBlackListTimeMilli: 1000
01-29 15:49:28.627  3682  3851 D TAO     : triggeredLow: 0 triggeredBad: 0 triggeredNotHigh: 0
01-29 15:49:28.627  3682  3851 D TAO     : ticksLow: 0 ticksBad: 0 ticksNotHigh: 0
01-29 15:49:28.627  3682  3851 D TAO     : triggeredJoin: 0
01-29 15:49:28.627  3682  3851 D TAO     : ]
01-29 15:49:28.627  3682  3851 D WifiWizard2: WifiWizard: Found max WiFi priority of 1
01-29 15:49:28.628  3682  3851 D TAO     : WifiWizard2: getting ready to update network with wifi var, here is the wifi var =  ID: 0 SSID: "myssid" PROVIDER-NAME: null BSSID: null FQDN: null PRIO: 2 HIDDEN: false
01-29 15:49:28.628  3682  3851 D TAO     :  NetworkSelectionStatus NETWORK_SELECTION_ENABLED
01-29 15:49:28.628  3682  3851 D TAO     :  hasEverConnected: false
01-29 15:49:28.628  3682  3851 D TAO     :  KeyMgmt: WPA_PSK Protocols: WPA RSN
01-29 15:49:28.628  3682  3851 D TAO     :  AuthAlgorithms:
01-29 15:49:28.628  3682  3851 D TAO     :  PairwiseCiphers: TKIP CCMP
01-29 15:49:28.628  3682  3851 D TAO     :  GroupCiphers: TKIP CCMP
01-29 15:49:28.628  3682  3851 D TAO     :  PSK: *
01-29 15:49:28.628  3682  3851 D TAO     : Enterprise config:
01-29 15:49:28.628  3682  3851 D TAO     : IP config:
01-29 15:49:28.628  3682  3851 D TAO     : IP assignment: UNASSIGNED
01-29 15:49:28.628  3682  3851 D TAO     : Proxy settings: UNASSIGNED
01-29 15:49:28.628  3682  3851 D TAO     :  cuid=-1 luid=-1 lcuid=0 userApproved=USER_UNSPECIFIED noInternetAccessExpected=false roamingFailureBlackListTimeMilli: 1000
01-29 15:49:28.628  3682  3851 D TAO     : triggeredLow: 0 triggeredBad: 0 triggeredNotHigh: 0
01-29 15:49:28.628  3682  3851 D TAO     : ticksLow: 0 ticksBad: 0 ticksNotHigh: 0
01-29 15:49:28.628  3682  3851 D TAO     : triggeredJoin: 0
01-29 15:49:28.628  2685  3049 D WifiService: Updating Id:Guid 0:2b34cf58-cea8-4dd8-bc37-5cb68a442157
01-29 15:49:28.628  2685  3049 D WifiService: SSID: "myssid" StrippedSSID: myssid
01-29 15:49:28.652  2685  3049 D WifiService: Host returned Guid: 68ce0f8d-2414-4136-a9ec-a507bfab820c for Ssid: "myssid"
01-29 15:49:28.652  2685  3049 D WifiService: Trying to remove network with Id: 0
01-29 15:49:28.657  2685  3049 E WifiService: Error removing configured network in the Host 2b34cf58-cea8-4dd8-bc37-5cb68a442157
01-29 15:49:28.657  2685  3049 D WifiService: Remove network failed for Guid: 2b34cf58-cea8-4dd8-bc37-5cb68a442157
01-29 15:49:28.657  2685  3049 E WifiService: Removing old configuration failed while updating Guid: 2b34cf58-cea8-4dd8-bc37-5cb68a442157
01-29 15:49:28.658  2685  3049 D WifiService: Trying to remove network with Id: 1
01-29 15:49:28.683  2685  3049 I ArcNetworkIdMap: Removed GUID:Id 68ce0f8d-2414-4136-a9ec-a507bfab820c:1
01-29 15:49:28.685  3682  3851 W PluginManager: THREAD WARNING: exec() call to WifiWizard2.add blocked the main thread for 82ms. Plugin should use CordovaInterface.getThreadPool().
01-29 15:49:28.690  3682  3682 D SystemWebChromeClient: Wifi connect catch error:
01-29 15:49:28.690  3682  3682 I chromium: [INFO:CONSOLE(612)] "Wifi connect catch error: ", source: 
01-29 15:49:28.700  3682  3682 D SystemWebChromeClient: : Error connecting to WiFi!
01-29 15:49:28.700  3682  3682 I chromium: [INFO:CONSOLE(782)] "Error connecting to WiFi!", source: 

getConnectedSSID() Not returning SSID when building IPA for distribution

Description

When I debug my Ionic App I can get my SSID when I call getConnectedSSID() but in the IPA for release it never returns a value. Always fires the catch() and returns Not Available.

Steps to Reproduce

Build for prod thru CLI or Archive in xCode and export IPA and install on connected device via device window.

Expected behavior:
Get Connected SSID like it does when debugging app

Actual behavior:
Returns Not Available

Reproduces how often:
100%

Versions

iOS 12

WifiWizard2.getCurrentSSID returns unknown on Android 8.1

So first, thank you for extending the work of WifiWizard. It was a major pain that the development of that plugin was stopped.

Android 8.1 seems to have changed things for Wi-Fi and getCurrentSSID returns unknown. I was seeing this problem with WifiWizard. I googled, found and upgraded to WifiWizard2. But I still see the same issue.

Note that it's working on Android 8.0.1.

The bug seems very similar to this problem:
http://piunikaweb.com/2017/12/21/google-fixes-android-8-1-wifivpn-issue/
though it has nothing to do with VPN in my case.

Do you have a device running Android 8.1 somewhere?

Connect open wifi

Hello everyone, I'm programming an app and I need to connect to a free wifi, without a password, but with the wizard I can not get it. Can you help me?

Be more precise in README file

Issue type

Select all that apply

  • Bug
  • Enhancement
  • Task
  • Question
  • Other

Description

I'm trying to get the list of available wifi networks but I'm not getting anything. This is the code I'm using:

WifiWizard2.scan(function (data) {
    alert(JSON.stringify(data));
});

Expected behavior: Should alert a JSON string of networks

Actual behavior: Nothing

Versions

  • Android 8.0
  • WifiWizard2 3.0.0

Additional Information

I'm running this on body load.

EDIT

Please check my last comment

Wifi is enabled after call isWifiEnable

Issue type

Select all that apply

  • Bug
  • Enhancement
  • Task
  • Question
  • Other

Description

I call isWifiEnabled to check whether wifi is enable, but after call it the wifi will be enabled.

public boolean execute(String action, JSONArray data, CallbackContext callbackContext)
throws JSONException {

boolean wifiIsEnabled = verifyWifiEnabled();

The function verifyWifiEnabled enable wifi.

I think this may be not suitable, because I just want check wifi status, but not change it

Steps to Reproduce

call isWifiEnabled when wifi is disable

Expected behavior: [What you expect to happen]

Actual behavior: [What actually happens]

Reproduces how often: [What percentage of the time does it reproduce?]

Versions

Please include the plugin version that you are using and also include the OS, version and device you are using.

Additional Information

Any additional information, configuration or data that might be necessary to reproduce the issue.

how to change device wifi network?

--> I have connected my laptop to open wifi network(either adhoc or hotspot).

--> I have connected my mobile to open wifi network of my laptop.

--> Was able to change the network of my mobile to required locally available wifi network using
this method - "WifiWizard2.connect(ssid, bindAll, password, algorithm, isHiddenSSID)".

--> What my requirement is - will I be able to change the network of my laptop from open network
to required locally available wifi networks?
which is as done in ring door bell application "https://www.youtube.com/watch?v=9yTg-iWPy28".

Rename npm package from wifiwizard2 to cordova-plugin-wifiwizard2

Already pushed to npmjs, may want to look at adding a deprecated notice for original wifiwizard2 plugin, or just keep pushing to both repos

from https://www.npmjs.com/package/wifiwizard2
to https://www.npmjs.com/package/cordova-plugin-wifiwizard2

https://stackoverflow.com/questions/28371669/renaming-a-published-npm-module

Not sure why I went with just wifiwizard2 but should be cordova-plugin-wifiwizard2 ... bad myles you know better than that 😝

Right now both have the same exact release, 3.1.0 released today

not getting connected wifi : (android)

ionViewDidLoad() {
    console.log("ionViewDidLoad AdvanceMeetingBookingPage");
    this.platform.ready().then(() => {
      this.startScan();
      console.log('networks',this.networks);
  });
  
    this.getFacilityList();
  }
  startScan() {
    if (typeof WifiWizard2 !== 'undefined') {
            console.log("WifiWizard loaded: ");
            console.log(WifiWizard2);
    } else {
        console.warn('WifiWizard not loaded.');
    }              

    let successNetwork = (e: any) => {
      console.log('e',e);
      WifiWizard2.getConnectedSSID(listHandler, failNetwork);
    }

    let failNetwork = (e: any) => {
        console.log("fail : " + e);
    }

    let listHandler = (a: any) => {
        this.networks = [];
        console.log('a',a);
        for (let x in a) {
          console.log('ssid',a[x].SSID);                    
            console.log(a[x].SSID + ", " + a[x].BSSID + ", " + a[x].level);  
            this.networks.push({
                ssid: a[x].SSID,
                bssid: a[x].BSSID,
                level: a[x].level});                
        } 
        console.log('listHandler networks',this.networks);
    }
    WifiWizard2.startScan(successNetwork, failNetwork);
}

result in console :
WifiWizard loaded:
Object {getCurrentSSID: function, getCurrentBSSID: function, iOSConnectNetwork: function, iOSDisconnectNetwork: function, formatWifiConfig: function…}
networks []
e OK
a []
listHandler networks []

Request for merging other discontinued libraries into WifiWizard2

Issue type

  • Bug
  • Enhancement
  • Task
  • Question
  • Other

Description

Great project! Thanks for taking over the original WifiWizard, and keeping it under active development.

Would you be interested to also integrate cordova-hotspot-plugin's features (such as creating a hotspot) into WifiWizard2?

I'm developing an app which should be able to a) scan Wifi networks, b) connect to specified SSIDs & c) switch between Wifi and hotspot mode.

Since that project is no longer maintained and the author has abandoned it, I was wondering if you could merge its codebase into WifiWizard2, so I can switch to your codebase.

Another feature that I'd really like to see in WifiWizard2 is an ability to get the current IP address of the device, as seen here: cordova-plugin-networkinterface networkinterface.getWiFiIPAddress().

Of course, as a developer myself I understand if you have limited time, or no interest in adding hotspot support at all. But it would be much appreciate if you could put it into your TODO plans, at least.

This is just for the sake of having a unified codebase for the library. The Java/www source are already out there. Just needs integration and a bit of testing.

I do hope you consider these proposals :)
Thanks for your time

Thread.sleep not is a try - catch

on that android side of WifiWizard2.java on line 165 I get the following error

platforms\android\src\android\wifiwizard2\WifiWizard2.java:164: error: unreported exception InterruptedException; must be caught or declared to be thrown
            Thread.sleep(1000L);
                        ^
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

my quick fix was to put it in a try - catch like you have it on line 174

           try {
                Thread.sleep(1000L);
            } catch (InterruptedException ie) {
                // continue
            }

after that, it compiled for me.

Broken compatibility with older versions of Android

Prerequisites

Check all boxes if you have done the following:

Issue type

Select all that apply

  • Bug
  • Enhancement
  • Task
  • Question
  • Other

Description

The instruction at line 56 of the file WifiWizard2/www/WifiWizard2.js (let networkInformation = [];) is not supported by older webviews with older versions of javascript and is currently breaking the compatibily of the plugin with older versions of Android.
Possible fixes:

  • change it to var networkInformation = [];

Steps to Reproduce

  1. Start the app
  2. An error in javascript blocks the application

Expected behavior: Plugin should work on Android SDK versions <= 21 (Android Kitkat and older).

Actual behavior: I receive an error related to the interpretation of Javascript at runtime that prevents the application from working correctly.

Reproduces how often: 100% of the times.

Versions

Plugin version: 3.0.0
OS version: Android Kitkat 4.4.2
Phone: Samsung Galaxy S4 Mini

IOS app breaks when WIFI password is shorter than 8 characters

Prerequisites

Check all boxes if you have done the following:

Issue type

Select all that apply

  • Bug
  • Enhancement
  • Task
  • Question
  • Other

Description

First of all: Great plugin! Very handy and useful!

The IOS call to connect() breaks the IOS app whenever the user inserts a WIFI password shorter than 8 characters.

It's well know that the WPA/WPA2 password length should be at least 8 character long and the app developer can easily prohibit the user for attempting such a connection.

But it would be nice to have a fail callback so the app won't break in case the developer forgets to verify the password length.

Steps to Reproduce

On an IOS device try to connect on an WIFI network with a password shorter than 8 characters.

Expected behavior: [What you expect to happen]
Connect to a WIFI network.

Actual behavior: [What actually happens]
2018-04-23 17:18:31.209909-0300 EasyKey[3954:1944346] [] -[NEHotspotConfiguration valid:726 NEHotspotConfiguration invalid WPA/WPA2 passphrase length.
(lldb)

Reproduces how often: [What percentage of the time does it reproduce?]

Everytime.

Versions

Test were made on IONIC built app running on an iPhone (IOS 11).

some phone show error:Module wifiwizard2.WifiWizard2 does not exist.

Prerequisites

Check all boxes if you have done the following:

Issue type

Select all that apply

  • Bug
  • Enhancement
  • Task
  • Question
  • Other

Description

i have 5 phones,only one show error:
[INFO:CONSOLE(57)] "Uncaught SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode", source: file:///android_asset/www/plugins/wifiwizard2/www/WifiWizard2.js (57)
I/chromium: [INFO:CONSOLE(1461)] "Uncaught Error: Module wifiwizard2.WifiWizard2 does not exist.", source: file:///android_asset/www/cordova.js (1461)

Versions

android 5.1
ionic 3

force check key

Hello, I have the following problem, if I try to connect with a wifi that I was previously connected to and for that the smartphone already has the password, it always connects despite putting the wrong password.

I do not know what I have to do to force not to connect if the key is wrong.

Plugin does not support Webview versions prior to 49.0.2623.105

Prerequisites

Check all boxes if you have done the following:

Issue type

Select all that apply

  • [ X] Bug
  • Enhancement
  • Task
  • Question
  • Other

Description

Plugin does not support Webview version before 49.0.2623.105.

Steps to Reproduce

  1. Get a phone with an OLD Android System Webview (any version before 49.0.2623.105)
  2. Create an Ionic project
  3. Add the plugin to your project
  4. Package to apk, install and run

Expected behavior:
App opens, no errors in console.

Actual behavior:
A syntax error is logged to console:
"Uncaught SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode", source: file:///android_asset/www/plugins/wifiwizard2/www/WifiWizard2.js

Reproduces how often:
100% of the time

Versions

WifiWizard2: 3.0.0
Android: 6.0.1
Device: Samsung S7
Webview: 48.0.2564.106

Additional Information

Refactor Android/iOS/Cordova Code Base

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 ... looking for any Android and Cordova developers out there who would be willing to help with this.

Let's get this thing cleaned up and organized! Unfortunately my time is limited as I do not have any projects using Cordova that bring in any kind of income, this was specifically for personal and other open source projects, so looking for others who may be willing to help!

Refactor and Rebuild Entire Plugin - Move to all Async Functions

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.

UWP support?

Issue type

Select all that apply

  • Bug
  • Enhancement
  • Task
  • Question
  • Other

Description

Any chance to support Windows UWP? I guess it should be possible...

Error alert when use getConnectedBSSID getConnectedSSID functions

Prerequisites

Check all boxes if you have done the following:

Issue type

Select all that apply

  • Bug

Description

We use beta version for 3.0 from March. All works fine

Now, we need to recompile the app (ionic) and when we try to use WifiWizard functions ( getConnectedBSSID and getConnectedSSID) the app show an alert:

{"__zone_symbol__currentTask":{"type":"microTask","state":"notScheduled","source":"Promise.then","zone":"<root>","cancelFn":null,"runCount":0},"line":1233,"column":40,"sourceURL":"http://localhost:8080/var/containers/Bundle/Application/2FB59314-9A63-46F0-9F2C-7996AEBC19E2/Name.app/www/build/main.js"}

We start the project from zero (npm install, platform add, ...)

Versions

From node_modules / wifiwizard2 / package.json:
[email protected]
iOS

Uncaught (in promise): TypeError: WifiWizard2.getConnectedSSID is not a function

Prerequisites

Check all boxes if you have done the following:

Issue type

Select all that apply

  • Bug
  • Enhancement
  • Task
  • Question
  • Other

Description

Error in global functions

Steps to Reproduce

  1. Install plugin in Ionic 3 project
  2. Use WifiWizard2.getConnectedSSID(success, fail)
    Or
    WifiWizard2.getConnectedSSIDAsync()

Expected behavior:

Get success or fail error based on connection according to Docs.

Actual behavior:

ERROR Error: Uncaught (in promise): TypeError: WifiWizard2.getConnectedSSID is not a function
TypeError: WifiWizard2.getConnectedSSID is not a function
at 8.js:76
at t.invoke (polyfills.js:3)
at Object.onInvoke (vendor.js:4982)
at t.invoke (polyfills.js:3)
at r.run (polyfills.js:3)
at polyfills.js:3
at t.invokeTask (polyfills.js:3)
at Object.onInvokeTask (vendor.js:4973)
at t.invokeTask (polyfills.js:3)
at r.runTask (polyfills.js:3)
at 8.js:76
at t.invoke (polyfills.js:3)
at Object.onInvoke (vendor.js:4982)
at t.invoke (polyfills.js:3)
at r.run (polyfills.js:3)
at polyfills.js:3
at t.invokeTask (polyfills.js:3)
at Object.onInvokeTask (vendor.js:4973)
at t.invokeTask (polyfills.js:3)
at r.runTask (polyfills.js:3)
at c (polyfills.js:3)
at polyfills.js:3
at t.invokeTask (polyfills.js:3)
at Object.onInvokeTask (vendor.js:4973)
at t.invokeTask (polyfills.js:3)
at r.runTask (polyfills.js:3)
at o (polyfills.js:3)
at

Reproduces how often:
Everytime.

Additional Information

According to the code it probably needs to be getCurrentSSID etc. Either the docs or the js file needs to be updated depending on how you want to keep it.

Getting duplicates from scanAsync in version 2.1.0

Hi,

I'm getting duplicate SSIDs from scanAsync. Has anyone else had this issue? It is an outstanding issue in WifiWizard 1. Just doing:

WifiWizard2.scanAsync().then(result => {
for (let x in result) {
console.log(result[x].SSID);
console.log(result[x].level);
console.log(result[x].BSSID);
console.log(result[x].frequency);
console.log(result[x].capabilities);
}
});

[20:36:16] console.log: BTWifi-with-FON
[20:36:16] console.log: -43
[20:36:16] console.log: a2:8e:78:2b:9f:8c
[20:36:16] console.log: 5180
[20:36:16] console.log: [ESS]
[20:36:16] console.log: BTWifi-with-FON
[20:36:16] console.log: -41
[20:36:16] console.log: a2:8e:78:2b:a0:8f
[20:36:16] console.log: 2462
[20:36:16] console.log: [ESS]
[20:36:16] console.log: BTWifi-with-FON
[20:36:16] console.log: -78
[20:36:16] console.log: 1a:62:2c:35:ba:e3
[20:36:16] console.log: 2462
[20:36:16] console.log: [ESS]

It's other SSIDs as well. Interesting that they have different frequencies. Any ideas?

All scan functions can not run well in android and ios

In android that called fail and got nothing;
In ios that called fail and got "Not supported".

And this is my testing code in my project.
let WifiWizard2 = require('WifiWizard2') WifiWizard2.getConnectedBSSID((data) => { console.log('getConnectedBSSID 1', data) }, (data) => { console.log('getConnectedBSSID 0', data) }) WifiWizard2.getConnectedBSSIDAsync().then((data) => { console.log('getConnectedSSIDAsync 1', data) }).catch((data) => { console.log('getConnectedSSIDAsync 0', data) }) WifiWizard2.scan((data) => { console.log('scan 1', data) }, (data) => { console.log('scan 0', data) }); (async () => { try { let data = await WifiWizard2.scanAsync() console.log('scanAsync 1', data) } catch (e) { console.log('scanAsync 0', 0) } })() WifiWizard2.listNetworks((data) => { console.log('listNetworks 1', data) }, (data) => { console.log('listNetworks 0', data) }) WifiWizard2.startScan((data) => { console.log('startScan 1', data, WifiWizard2.startScanAsync(), WifiWizard2.getScanResults((data2) => { console.log('getScanResults 1', data2) }, (data2) => { console.log('getScanResults 0', data2) })) }, (data) => { console.log('startScan 0', data) })

Is it possible to connect to a hidden ssid?

Issue type

Select all that apply

  • Bug
  • Enhancement
  • Task
  • Question
  • Other

Description

Can I connect to a hidden ssid via the WifiWizard2.connect() or WifiWizard2.enable() functions?

Connect to wifi without internet programmatically

Prerequisites

Check all boxes if you have done the following:

Issue type

Select all that apply

  • Bug
  • Enhancement
  • Task
  • Question
  • Other

Description

Cannot communicate with the IOT appliance after a successful WiFi connection via Cordova app due to non availability of internet on the appliance.

Steps to Reproduce

  1. Connect to any WiFi router or IOT appliance which doesn't have internet connection.
  2. Try to communicate with appliance/router's web server.
  3. Android OS blocks all the API calls going through this connection.
  4. There is no prompt as well asking for "This network has no internet access. Stay connected? NO/YES".

Expected behavior: [What you expect to happen]

  1. Either the OS should let through the API calls to communicate with appliance/router.
  2. Or there should be a prompt asking the user to Stay connected or not.

Actual behavior: [What actually happens]

  1. I am able to connect to appliance's WiFi (soft AP) using your plugin.
  2. But I am not able to communicate with the appliance web server as the Android OS blocks all API calls and connections. This happens due to there is no internet connection on the appliance and the user has to be shown a prompt asking him whether to stay connected(YES/NO).
  3. This prompt doesn't show up as we are connecting to the WiFI via Cordova app.

Reproduces how often: [What percentage of the time does it reproduce?]
All the time it can be reproduced but only on Android OS version 8.1 and 7.1.2.

Versions

Plugin version: [email protected]
Android OS version: [email protected] and [email protected]

Please include the plugin version that you are using and also include the OS, version and device you are using.

Additional Information

If we connect to the appliance WiFi (without internet) via WiFi settings of the Android OS, the prompt shows up. But when we connect to it from Cordova app the prompt doesn't show up.
Until we click on YES on the prompt (shown in the screenshot) the OS doesn't allow any communication to go through.

I am copy pasting a link where this issue has been solved in native code layer. Could you please look at it and include a fix for this.
https://stackoverflow.com/questions/40752991/connect-to-wifi-without-internet-programmatically

Any additional information, configuration or data that might be necessary to reproduce the issue.
1
2

.scan() not working on Android 9

Possibly related to #44

Prerequisites

Check all boxes if you have done the following:

Issue type

Select all that apply

  • Bug
  • Enhancement
  • Task
  • Question
  • Other

Description

Have been using WifiWizard previously, and now WifiWizard2 (version 3.1.0) in an Ionic app publishing to Android. We're really only using it for the .scan() and .getConnectedSSID() methods. Both work well on Android 8.1 and below. But on our tests on Android 9 (via the Google Pixel 2 XL), they always fail via timeout. Here are the logs for one attempt at .scan():

09-06 11:18:36.995 6301-6423/com.x.y.z D/WifiWizard2: WifiWizard2: verifyWifiEnabled entered.
09-06 11:18:36.995 6301-6423/com.x.y.z V/WifiWizard2: Entering startScan
09-06 11:18:36.997 6301-6423/com.x.y.z V/WifiWizard2: Submitting timeout to threadpool
09-06 11:18:36.998 6301-6423/com.x.y.z V/WifiWizard2: Registering broadcastReceiver
09-06 11:18:36.998 6301-6424/com.x.y.z V/WifiWizard2: Entering timeout
09-06 11:18:36.999 6301-6423/com.x.y.z V/WifiWizard2: Scan failed
09-06 11:18:47.000 6301-6424/com.x.y.z V/WifiWizard2: Thread sleep done
09-06 11:18:47.005 6301-6424/com.x.y.z V/WifiWizard2: In timeout, error

The thing that sticks out to me is that "Scan failed" gets logged .005 seconds after the request starts. That would seem to be triggered by these lines in the plugin (326-330):

if (!wifiManager.startScan()) {
      Log.v(TAG, "Scan failed");
      callbackContext.error("SCAN_FAILED");
      return false;
    }

Android 9 has deprecated this method in WifiManager, it's true, and introduced some new wifi scanning throttling, detailed here:
https://developer.android.com/guide/topics/connectivity/wifi-scan#wifi-scan-restrictions

However I don't think it's been removed entirely. And I'm not getting throttling behavior, I'm getting immediate failure, as if that method doesn't even exist.

Any thoughts or assistance appreciated. I'll keep working on it.

WifiWizard2.iOSConnectNetwork wifi free

Is it possible to connect to a wifi without a password? , when I try it in IOS the app stops working

My code

WifiWizard2.iOSConnectNetwork(mired, mipass,
//success
function () {
navigator.notification.alert("Connect to SSID = " + mired + " is ok", alertDismissed(), 'title', 'Ok');
},
//fail
function () {
navigator.notification.alert(ins_error + mired, alertDismissed(), 'title', 'Ok');
}

);

getConnectedSSID() return unknown ssid in some mobile devices

Prerequisites

Check all boxes if you have done the following:

Issue type

Select all that apply

  • Bug
  • Enhancement
  • Task
  • Question
  • [] Other

Description

My customer reported that his android shows in app but I can't reproduce it in my devices and emulator whatever android versions. Coincidently, I found some one post a blog that a similar issue for some mobile device - vivo x21iA / vivo x20.

I've tested in these two devices and the issue surely could be reproduced.
It's undoubtedly not the bug of plugin. It should be a bug of some firmwares or else, but I can't tell my customers to contact the mobile manufacturer to solve this problem.

Thus, I have modified the code(WifiWizard2.java) as below(get SSID by another API):

      serviceInfo = info.getSSID();

      if(serviceInfo != null && serviceInfo.contains("unknown ssid")) {
          NetworkInfo wifiInfo = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
          String wifiName = wifiInfo.getExtraInfo();
          if (wifiName.startsWith("\"")) {
              wifiName = wifiName.substring(1, wifiName.length());
          }
          if (wifiName.endsWith("\"")) {
              wifiName = wifiName.substring(0, wifiName.length() - 1);
          }
          serviceInfo = wifiName;
      }

And it works now. Hope this would help someone.

Versions

vivo x21iA / vivo x20 and maybe more
Android 8.1
WifiWizard2 3.x

Set null values in Android using JSONObject.NULL instead of just null

Description

[Description of the issue]

Steps to Reproduce

when I run my app on android device:
ionic cordova run android

BUILD FAILED in 3s
(node:14344) UnhandledPromiseRejectionWarning: Error: cmd: Command failed with exit code 1 Error output:
H:\git_work\MWMobileController\platforms\android\app\src\main\java\android\wifiwizard2\WifiWizard2.java:990: ����: ��put�����ò���ȷ
lvl.put("channelWidth", null);
^
JSONObject �еķ��� put(String,Collection) �� JSONObject �еķ��� put(String,Map) ��ƥ��
H:\git_work\MWMobileController\platforms\android\app\src\main\java\android\wifiwizard2\WifiWizard2.java:991: ����: ��put�����ò���ȷ
lvl.put("centerFreq0", null);
^
JSONObject �еķ��� put(String,Collection) �� JSONObject �еķ��� put(String,Map) ��ƥ��
H:\git_work\MWMobileController\platforms\android\app\src\main\java\android\wifiwizard2\WifiWizard2.java:992: ����: ��put�����ò���ȷ
lvl.put("centerFreq1", null);
^
JSONObject �еķ��� put(String,Collection) �� JSONObject �еķ��� put(String,Map) ��ƥ��
ע: ijЩ�����ļ�ʹ�û�����ѹ�ʱ�� API��
ע: �й���ϸ��Ϣ, ��ʹ�� -Xlint:deprecation ���±��롣
3 ������

I change lvl.put("centerFreq1", null); => lvl.put("centerFreq1", 0);

will be ok.

Expected behavior: [What you expect to happen]

Actual behavior: [What actually happens]

Reproduces how often: [What percentage of the time does it reproduce?]

Versions

Please include the plugin version that you are using and also include the OS, version and device you are using.

Additional Information

Any additional information, configuration or data that might be necessary to reproduce the issue.

Collaboration - Cordova Network Manager

Hi @tripflex,

I'm glad to see you credited my plugin so thank you for that.

I am wanting to expand onto my plugin and we should talk about possibly merging/becoming the sole contributors for both.

My discord is: Nomm#0176

iOS 12+ getConnectedSSID() and getConnectedBSSID() not working

Prerequisites

Check all boxes if you have done the following:

Issue type

Select all that apply

  • Bug
  • Enhancement
  • Task
  • Question
  • Other

Description

Everything is fine on iOS11 but when I open the same .ipa in iOS12 device getConnectedSSID() and getConnectedBSSID() are not working. And also everything is fine on Android.

Steps to Reproduce

Expected behavior: It should returns connected wi-fi's ssid and bssid

Actual behavior: It returns undefined on iOS12

Versions

iOS12+

wifiwizard2 2.1.0 getting error

PLUGIN version :
wifiwizard2 2.1.0 "WifiWizard2"

iOS version : ios12

.ts code

 if (typeof WifiWizard2 !== 'undefined') {
      console.log("WifiWizard loaded: ");
      this.selectBuildingOption = false;
      this.isNotconnectwithWifi = false;
      WifiWizard2.getCurrentBSSID(this.successNetwork, this.failNetwork); //always go to failNetwork
    } 

Error log in xcode

2018-10-08 16:57:59.043091+0530 @RTI[3797:356306] WifiWizard loaded:
2018-10-08 16:57:59.046592+0530 @RTI[3797:356306] Supported interfaces: (
    en0
)
2018-10-08 16:57:59.046830+0530 @RTI[3797:356306] en0 => (null)
2018-10-08 16:57:59.061072+0530 @RTI[3797:356306] fail : Not available

Main thread blocked while connecting to a network

I have been testing the plugin for the past 3 days and I must say - it is a huge step up in comparison to the previous version:) Good job @tripflex !
However, I am experiencing main thread blockage whenever I run connect() method. After connect() completes everything goes back to normal.
I am not able to debug the app as everything hangs and CPU goes crazy.

Did anybody notice that as well?

HTC 10
Android 8.0
Cordova 7.0

Same thing happens on Android emulator.

iOSConnectNetwork connects network but gets into fail callback - iOS 12+

Prerequisites

Check all boxes if you have done the following:

Issue type

Select all that apply

  • Bug

Description

When connecting a network, open or protected, with a DISTRIBUTION PROFILE on iOS 12+, it connects correctly, but then it gets into the fail callback and a native dialog of connection failure is shown, although the net stays connected. This doesn't happen with a development profile.

Steps to Reproduce

  1. Pass to function the params of an open or protected network
  2. Build with a Distribution profile
  3. Connect network

Expected behavior: Connect network and go on OR get a failure dialog and don't connect

Actual behavior: The network is connected and a failure dialog is shown

Reproduces how often: 100% of times

Versions

WifiWizard 3.1.0;
iPhone 6s;
iOS 12+;
Distribution profile

Error in getWifiRouterIP on iOS

Prerequisites

Check all boxes if you have done the following:

Issue type

Select all that apply

  • Bug
  • Enhancement
  • Task
  • Question
  • Other

Description

ERROR: Method 'getWifiRouterIP:' not defined in Plugin 'WifiWizard2'

Steps to Reproduce

  1. Add plugin
  2. Add code
  3. Compile
  4. Test ;)

Expected behavior: [What you expect to happen]

The Gateway IP

Actual behavior: [What actually happens]

Error (method not exist)

min version of Android supported

Prerequisites

Check all boxes if you have done the following:

Issue type

Select all that apply

  • Bug
  • Enhancement
  • Task
  • Question
  • Other

Description

I have a small question, what is the min version of Android supporting this plugin ?
On Android 5.0 the plugin doesn't work, that means i don't have the automagic demand to activate the wifi, so my application do not launch (because it's testing at the launch on which wifi i am connected)

Steps to Reproduce

Versions

wifizard2: 3.1.0
Android: 5.0

Additional Information

Anyone getting a disconnect within about a minute of connection?

Hi,

3.1.0 version is great, especially now that the UI doesn't hang on connect. Thanks guys!

My problem now is that I am getting a connection, but for some reason the wifi decides to drop within one minute of connection. Does anyone know why this might be happening?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.