Wifi Wizard API

turnOnWifi()

Enables the Device Wifi

WifiWizard.turnOnWifi();

REQUIRED PERMISSIONS

Make sure your AndroidManifest.xml file has the following permissions.

   <uses-permission
          android:required="true"
          android:name="android.permission.CHANGE_WIFI_STATE"/>

turnOffWifi()

Disables the Device Wifi

WifiWizard.turnOffWifi();

REQUIRED PERMISSIONS

Make sure your AndroidManifest.xml file has the following permissions.

   <uses-permission
          android:required="true"
          android:name="android.permission.CHANGE_WIFI_STATE"/>

isWifiEnabled()

Checks the state of the Wifi and Returns the status

WifiWizard.isWifiEnabled().then(status=>{
  console.log(status)
});

OUTPUT

Return type : Boolean

>>> true 

getNearbyNetworks()

Scans for nearby networks and returns a JavaScript array of networks.

WifiWizard.getNearbyNetworks().then(networks=>{
  console.log(devices);
});

REQUIRED PERMISSIONS

Make sure your AndroidManifest.xml file has the following permissions.

<uses-permission
    android:required="true"
    android:name="android.permission.CHANGE_WIFI_STATE"/>
<uses-permission
    android:required="true"
    android:name="android.permission.ACCESS_COARSE_LOCATION"/>

v1.0.3 Implementation (Deprecated)

Scans for nearby networks and returns a JSON stringified list of the results.

WifiWizard.getNearbyNetworks().then(data=>{
  let devices = JSON.parse(data);
  console.log(devices);
});

REQUIRED PERMISSIONS

Make sure your AndroidManifest.xml file has the following permissions.

<uses-permission
    android:required="true"
    android:name="android.permission.CHANGE_WIFI_STATE"/>
<uses-permission
    android:required="true"
    android:name="android.permission.ACCESS_COARSE_LOCATION"/>

connectToNetwork()

Connect to a Wifi Network in range

INPUT

Network - A Network Object

SSID - Name of the network you wish to connect to.

Password - Secret Key.

OUTPUT

A Javascript Object

{
  message: "success/failed"
}

USAGE

WifiWizard.getNearbyNetworks().then(networks=>{
  let network = jsonNetworks.filter((Network)=>{
    return Network.SSID=="Your Network Name";
  })
  if(network){
    WifiWizard.connectToNetwork(network, SSID, password).then((data)=>{
    if(data.status=="connected"){
      // Further Tasks
    }
    }).catch(err => console.log(err))
  }
})  

v1.0.3 Implementation (Deprecated)

INPUT

Network - A JSON Stringified Network Scan Result

SSID - Name of the network you wish to connect to.

Password - Secret Key.

USAGE

WifiWizard.getNearbyNetworks().then(networks=>{
  let jsonNetworks = JSON.parse(networks);
  let network = jsonNetworks.filter((Network)=>{
    return Network.SSID=="Your Network Name";
  })
  if(network){
    let stringified_network = JSON.stringify(network);
    WifiWizard.connectToNetwork(stringified_network, SSID, password).then((status)=>{
    if(status=="connected"){
      // Further Tasks
    }
    }).catch(err => console.log(err))
  }
})  

v1.0.2 and below Implementation (Deprecated)

INPUT

SSID - Name of the network you wish to connect to.

Password - Secret Key.

USAGE

WifiWizard.connectToNetwork(SSID,password).then((status)=>{
  if(status=="connected"){
    // Further Tasks
  }
}).catch(err => console.log(err))

disconnectFromNetwork()

Disconnect from existing network

USAGE

WifiWizard.disconnectFromNetwork().then(status=>{
  if(status==true){
    // Disconnected succesfully.
  }
  else
  {
    // Failed to disconnect.
  }
})

isReadyForCommunication()

Added In v1.0.4-stable

Checks if you are ready to communicate with the connected network.

USAGE

WifiWizard.isReadyForCommunication().then(status=>{
  if(status==true){
    // Proceed to communication
  }
  else
  {
    // Not yet ready for communication
  }
})