The WiFi API provides an interface to find available WiFi networks and handle connecting and disconnecting the device from those networks.
Wifi.getConnectedSSID()
.then(function(result) {
console.log( result);
})
.catch(function(e) {
console.error('Unable to get current SSID');
});
...
Wifi.getWifiIPInfo()
.then(function(result) {
console.log(result.ip);
console.log(result.subnet);
})
.catch(function(e) {
console.error('Unable to get current IP Info');
});
window.Wifi.getConnectedSSID()
.then(function (result) {
console.log(result);
})
.catch(function (e) {
console.error("Unable to get current SSID");
});
...
window.Wifi.getWifiIPInfo()
.then(function (result) {
console.log(result.ip);
console.log(result.subnet);
})
.catch(function (e) {
console.error("Unable to get current IP Info");
});
window.Wifi.getConnectedSSID()
.then(function (result) {
console.log(result);
})
.catch(function (e) {
console.error("Unable to get current SSID");
});
...
window.Wifi.getWifiIPInfo()
.then(function (result) {
console.log(result.ip);
console.log(result.subnet);
})
.catch(function (e) {
console.error("Unable to get current IP Info");
});
(<any>window).Wifi.getConnectedSSID()
.then(function (result) {
console.log(result);
})
.catch(function (e) {
console.error("Unable to get current SSID");
});
...
(<any>window).Wifi.getWifiIPInfo()
.then(function (result) {
console.log(result.ip);
console.log(result.subnet);
})
.catch(function (e) {
console.error("Unable to get current IP Info");
});
window.Wifi.getConnectedSSID()
.then(function (result) {
console.log(result);
})
.catch(function (e) {
console.error("Unable to get current SSID");
});
...
window.Wifi.getWifiIPInfo()
.then(function (result) {
console.log(result.ip);
console.log(result.subnet);
})
.catch(function (e) {
console.error("Unable to get current IP Info");
});
getConnectedSSID(): Promise<string>
Returns connected network SSID.
getConnectedBSSID(): Promise<string>
Same as above, except BSSID (mac) is returned.
connect(ssid: string, bindAll: boolean, password: string, algorithm: string, isHiddenSSID: boolean): Promise<any>
Connect network with specified SSID.
This method will first add the wifi configuration, then enable the network, returning promise when connection is verified.
disconnect(ssid: string): Promise<any>
Disconnect (current if SSID not supplied)
This method, if passed an SSID, will first disable the network, and then remove it from the device. To only "disconnect", call Wifi.disable() instead of disconnect.
formatWifiConfig(ssid: string, bindAll: boolean, password: string, algorithm: string, isHiddenSSID: boolean): Promise<any>
Same as above for Connect, except in this situation, disconnect will first disable the network, and then attempt to remove it (if SSID is passed).
formatWPAConfig(ssid: string, password: string, isHiddenSSID: boolean): Promise<any>
A helper method that calls formatWifiConfig
remove(ssid: string): Promise<any>
Remove wifi network configuration.
scan(options?): Promise<any>
getScanResults(options?): Promise<ScanResult>
setWifiEnabled(option: boolean): Promise<any>
getWifiIPInfo(): Promise<GetWifiInfoResult>
getSSIDNetworkID(ssid: string): Promise<string>
disable(ssid: string): Promise<string>
enable(ssid: string, bindAll: boolean, waitForConnection: boolean): Promise<any>
timeout(delay? : int): Promise<any>
Helper async timeout delay, delay is optional, default is 2000ms = 2 seconds
interface WifiOptions { ssid: string, isHiddenSSID: boolean, auth:{ password: string, algorithm: string } }
interface ScanResult { // Raw RSSI value "level": int, // SSID as string, with escaped double quotes: "\"ssid name\"" "SSID": string, // MAC address of WiFi router as string "BSSID": string, "frequency": int, // // Describes the authentication, key management, and encryption schemes supported by the access point "capabilities": string, // Timestamp of when the scan was completed "timestamp": int "channelWidth": int, "centerFreq0": int, "centerFreq1": int }
interface GetWifiInfoResult { "ip": string, "subnet": string }