Hotspotβ
This plugin is still in beta stage and may not work as expected. Please submit any issues to the plugin repo.
A Cordova plugin for managing Hotspot networks on Android.
Requires Cordova plugin: cordova-plugin-hotspot. For more info, please see the Hotspot plugin docs.
Repo: https://github.com/hypery2k/cordova-hotspot-plugin
Installation
- Install the Cordova and Ionic Native plugins:
$ ionic cordova plugin add cordova-plugin-hotspot $ npm install --save @ionic-native/hotspot@4 - Add this plugin to your app's module
Supported platforms
- Android
Usage
import { Hotspot, HotspotNetwork } from '@ionic-native/hotspot';
constructor(private hotspot: Hotspot) { }
...
this.hotspot.scanWifi().then((networks: Array<HotspotNetwork>) => {
console.log(networks);
});
Instance Members
isAvailable()
Returns: Promise<boolean>
toggleWifi()
Returns: Promise<boolean>
createHotspot(SSID, mode, password)
Configures and starts hotspot with SSID and Password
| Param | Type | Details |
|---|---|---|
| SSID |
string
|
SSID of your new Access Point |
| mode |
string
|
encryption mode (Open, WEP, WPA, WPA_PSK) |
| password |
string
|
password for your new Access Point |
Returns: Promise<void> - Promise to call once hotspot is started, or reject upon failure
startHotspot()
Turns on Access Point
Returns: Promise<boolean> - true if AP is started
configureHotspot(SSID, mode, password)
Configures hotspot with SSID and Password
| Param | Type | Details |
|---|---|---|
| SSID |
string
|
SSID of your new Access Point |
| mode |
string
|
encryption mode (Open, WEP, WPA, WPA_PSK) |
| password |
string
|
password for your new Access Point |
Returns: Promise<void> - Promise to call when hotspot is configured, or reject upon failure
stopHotspot()
Turns off Access Point
Returns: Promise<boolean> - Promise to turn off the hotspot, true on success, false on failure
isHotspotEnabled()
Checks if hotspot is enabled
Returns: Promise<void> - Promise that hotspot is enabled, rejected if it is not enabled
getAllHotspotDevices()
Returns: Promise<Array<HotspotDevice>>
connectToWifi(ssid, password)
Connect to a WiFi network
| Param | Type | Details |
|---|---|---|
| ssid |
string
|
SSID to connect |
| password |
string
|
password to use |
Returns: Promise<void> Promise that connection to the WiFi network was successfull, rejected if unsuccessful
connectToWifiAuthEncrypt(ssid, password, authentication, encryption)
Connect to a WiFi network
| Param | Type | Details |
|---|---|---|
| ssid |
string
|
SSID to connect |
| password |
string
|
Password to use |
| authentication |
string
|
Authentication modes to use (LEAP, SHARED, OPEN) |
| encryption |
string[]
|
Encryption modes to use (CCMP, TKIP, WEP104, WEP40) |
Returns: Promise<void> Promise that connection to the WiFi network was successfull, rejected if unsuccessful
addWifiNetwork(ssid, mode, password)
Add a WiFi network
| Param | Type | Details |
|---|---|---|
| ssid |
string
|
SSID of network |
| mode |
string
|
Authentication mode of (Open, WEP, WPA, WPA_PSK) |
| password |
string
|
Password for network |
Returns: Promise<void> Promise that adding the WiFi network was successfull, rejected if unsuccessful
removeWifiNetwork(ssid)
Remove a WiFi network
| Param | Type | Details |
|---|---|---|
| ssid |
string
|
SSID of network |
Returns: Promise<void> Promise that removing the WiFi network was successfull, rejected if unsuccessful
isConnectedToInternet()
Returns: Promise<boolean>
isConnectedToInternetViaWifi()
Returns: Promise<boolean>
isWifiOn()
Returns: Promise<boolean>
isWifiSupported()
Returns: Promise<boolean>
isWifiDirectSupported()
Returns: Promise<boolean>
scanWifi()
Returns: Promise<Array<HotspotNetwork>>
scanWifiByLevel()
Returns: Promise<Array<HotspotNetwork>>
startWifiPeriodicallyScan()
Returns: Promise<any>
stopWifiPeriodicallyScan()
Returns: Promise<any>
getNetConfig()
Returns: Promise<HotspotNetworkConfig>
getConnectionInfo()
Returns: Promise<HotspotConnectionInfo>
pingHost()
Returns: Promise<string>
getMacAddressOfHost(ip)
Gets MAC Address associated with IP Address from ARP File
| Param | Type | Details |
|---|---|---|
| ip |
string
|
IP Address that you want the MAC Address of |
Returns: Promise<string> - A Promise for the MAC Address
isDnsLive(ip)
Checks if IP is live using DNS
| Param | Type | Details |
|---|---|---|
| ip |
string
|
IP Address you want to test |
Returns: Promise<boolean> - A Promise for whether the IP Address is reachable
isPortLive(ip)
Checks if IP is live using socket And PORT
| Param | Type | Details |
|---|---|---|
| ip |
string
|
IP Address you want to test |
Returns: Promise<boolean> - A Promise for whether the IP Address is reachable
isRooted()
Checks if device is rooted
Returns: Promise<boolean> - A Promise for whether the device is rooted
HotspotConnectionInfo
| Param | Type | Details |
|---|---|---|
| SSID |
string
|
The service set identifier (SSID) of the current 802.11 network. |
| BSSID |
string
|
The basic service set identifier (BSSID) of the current access point. |
| linkSpeed |
string
|
The current link speed in Mbps |
| IPAddress |
string
|
The IP Address |
| networkID |
string
|
Each configured network has a unique small integer ID, used to identify the network when performing operations on the supplicant. |
HotspotNetwork
| Param | Type | Details |
|---|---|---|
| SSID |
string
|
Human readable network name |
| BSSID |
string
|
MAC Address of the access point |
| frequency |
number
|
The primary 20 MHz frequency (in MHz) of the channel over which the client is communicating with the access point. |
| level |
number
|
The detected signal level in dBm, also known as the RSSI. |
| timestamp |
number
|
Timestamp in microseconds (since boot) when this result was last seen. |
| capabilities |
string
|
Describes the authentication, key management, and encryption schemes supported by the access point. |
HotspotNetworkConfig
| Param | Type | Details |
|---|---|---|
| deviceIPAddress |
string
|
Device IP Address |
| deviceMacAddress |
string
|
Device MAC Address |
| gatewayIPAddress |
string
|
Gateway IP Address |
| gatewayMacAddress |
string
|
Gateway MAC Address |
HotspotDevice
| Param | Type | Details |
|---|---|---|
| ip |
string
|
Hotspot IP Address |
| mac |
string
|
Hotspot MAC Address |