2016-07-18 01:51:30 +08:00
|
|
|
import { Cordova, Plugin } from './plugin';
|
2016-03-14 01:29:59 +08:00
|
|
|
|
2016-12-06 22:14:28 +08:00
|
|
|
export interface HotspotConnectionInfo {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The service set identifier (SSID) of the current 802.11 network.
|
|
|
|
*/
|
|
|
|
SSID: string;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The basic service set identifier (BSSID) of the current access point.
|
|
|
|
*/
|
|
|
|
BSSID: string;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The current link speed in Mbps
|
|
|
|
*/
|
|
|
|
linkSpeed: string;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The IP Address
|
|
|
|
*/
|
|
|
|
IPAddress: string;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Each configured network has a unique small integer ID, used to identify the network when performing operations on the supplicant.
|
|
|
|
*/
|
|
|
|
networkID: string;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface HotspotNetwork {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Human readable network name
|
|
|
|
*/
|
|
|
|
SSID: string;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* MAC Address of the access point
|
|
|
|
*/
|
|
|
|
BSSID: string;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The primary 20 MHz frequency (in MHz) of the channel over which the client is communicating with the access point.
|
|
|
|
*/
|
|
|
|
frequency: number;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The detected signal level in dBm, also known as the RSSI.
|
|
|
|
*/
|
|
|
|
level: number;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Timestamp in microseconds (since boot) when this result was last seen.
|
|
|
|
*/
|
|
|
|
timestamp: number;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Describes the authentication, key management, and encryption schemes supported by the access point.
|
|
|
|
*/
|
|
|
|
capabilities: string;
|
|
|
|
|
|
|
|
}
|
|
|
|
export interface HotspotNetworkConfig {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Device IP Address
|
|
|
|
*/
|
|
|
|
deviceIPAddress: string;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Device MAC Address
|
|
|
|
*/
|
|
|
|
deviceMacAddress: string;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gateway IP Address
|
|
|
|
*/
|
|
|
|
gatewayIPAddress: string;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gateway MAC Address
|
|
|
|
*/
|
|
|
|
gatewayMacAddress: string;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface HotspotDevice {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ip
|
|
|
|
* Hotspot IP Address
|
|
|
|
*/
|
|
|
|
ip: string;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* mac
|
|
|
|
* Hotspot MAC Address
|
|
|
|
*/
|
|
|
|
mac: string;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-03-14 01:29:59 +08:00
|
|
|
/**
|
|
|
|
* @name Hotspot
|
|
|
|
* @description
|
|
|
|
* @usage
|
2016-07-20 23:17:09 +08:00
|
|
|
* ```typescript
|
|
|
|
* import { Hotspot, Network } from 'ionic-native';
|
2016-03-25 01:00:18 +08:00
|
|
|
*
|
2016-07-20 23:17:09 +08:00
|
|
|
*
|
|
|
|
* Hotspot.scanWifi().then((networks: Array<Network>) => {
|
|
|
|
* console.log(networks);
|
|
|
|
* });
|
2016-03-25 01:00:18 +08:00
|
|
|
*
|
|
|
|
* ```
|
2016-12-06 22:14:28 +08:00
|
|
|
* @interfaces
|
|
|
|
* HotspotConnectionInfo
|
|
|
|
* HotspotNetwork
|
|
|
|
* HotspotNetworkConfig
|
|
|
|
* HotspotDevice
|
2016-03-14 01:29:59 +08:00
|
|
|
*/
|
|
|
|
@Plugin({
|
2016-10-28 01:48:50 +08:00
|
|
|
pluginName: 'Hotspot',
|
2016-03-14 01:29:59 +08:00
|
|
|
plugin: 'cordova-plugin-hotspot',
|
2016-03-25 00:34:02 +08:00
|
|
|
pluginRef: 'cordova.plugins.hotspot',
|
2016-03-26 06:05:13 +08:00
|
|
|
repo: 'https://github.com/hypery2k/cordova-hotspot-plugin',
|
|
|
|
platforms: ['Android']
|
2016-03-14 01:29:59 +08:00
|
|
|
})
|
|
|
|
export class Hotspot {
|
|
|
|
|
2016-11-30 06:40:50 +08:00
|
|
|
/**
|
|
|
|
* @returns {Promise<boolean>}
|
|
|
|
*/
|
2016-03-14 01:29:59 +08:00
|
|
|
@Cordova()
|
2016-07-18 01:51:30 +08:00
|
|
|
static isAvailable(): Promise<boolean> { return; }
|
2016-03-14 01:29:59 +08:00
|
|
|
|
2016-11-30 06:40:50 +08:00
|
|
|
/**
|
|
|
|
* @returns {Promise<boolean>}
|
|
|
|
*/
|
2016-03-14 01:29:59 +08:00
|
|
|
@Cordova()
|
2016-07-18 01:51:30 +08:00
|
|
|
static toggleWifi(): Promise<boolean> { return; }
|
2016-05-06 08:57:49 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Configures and starts hotspot with SSID and Password
|
|
|
|
*
|
|
|
|
* @param {string} SSID - SSID of your new Access Point
|
|
|
|
* @param {string} mode - encryption mode (Open, WEP, WPA, WPA_PSK)
|
|
|
|
* @param {string} password - password for your new Access Point
|
|
|
|
*
|
2016-11-30 06:40:50 +08:00
|
|
|
* @returns {Promise<void>} - Promise to call once hotspot is started, or reject upon failure
|
2016-05-06 08:57:49 +08:00
|
|
|
*/
|
|
|
|
@Cordova()
|
2016-07-18 01:51:30 +08:00
|
|
|
static createHotspot(ssid: string, mode: string, password: string): Promise<void> { return; }
|
2016-05-06 08:57:49 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Turns on Access Point
|
|
|
|
*
|
2016-11-30 06:40:50 +08:00
|
|
|
* @returns {Promise<boolean>} - true if AP is started
|
2016-05-06 08:57:49 +08:00
|
|
|
*/
|
|
|
|
@Cordova()
|
2016-07-18 01:51:30 +08:00
|
|
|
static startHotspot(): Promise<boolean> { return; }
|
2016-05-06 08:57:49 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Configures hotspot with SSID and Password
|
|
|
|
*
|
|
|
|
* @param {string} SSID - SSID of your new Access Point
|
|
|
|
* @param {string} mode - encryption mode (Open, WEP, WPA, WPA_PSK)
|
|
|
|
* @param {string} password - password for your new Access Point
|
|
|
|
*
|
2016-11-30 06:40:50 +08:00
|
|
|
* @returns {Promise<void>} - Promise to call when hotspot is configured, or reject upon failure
|
2016-05-06 08:57:49 +08:00
|
|
|
*/
|
2016-03-14 01:29:59 +08:00
|
|
|
@Cordova()
|
2016-07-18 01:51:30 +08:00
|
|
|
static configureHotspot(ssid: string, mode: string, password: string): Promise<void> { return; }
|
2016-03-14 01:29:59 +08:00
|
|
|
|
2016-05-06 08:57:49 +08:00
|
|
|
/**
|
|
|
|
* Turns off Access Point
|
|
|
|
*
|
2016-11-30 06:40:50 +08:00
|
|
|
* @returns {Promise<boolean>} - Promise to turn off the hotspot, true on success, false on failure
|
2016-05-06 08:57:49 +08:00
|
|
|
*/
|
2016-03-14 01:29:59 +08:00
|
|
|
@Cordova()
|
2016-07-18 01:51:30 +08:00
|
|
|
static stopHotspot(): Promise<boolean> { return; }
|
2016-03-14 01:29:59 +08:00
|
|
|
|
2016-05-06 08:57:49 +08:00
|
|
|
/**
|
|
|
|
* Checks if hotspot is enabled
|
|
|
|
*
|
2016-11-30 06:40:50 +08:00
|
|
|
* @returns {Promise<void>} - Promise that hotspot is enabled, rejected if it is not enabled
|
2016-05-06 08:57:49 +08:00
|
|
|
*/
|
2016-03-14 01:29:59 +08:00
|
|
|
@Cordova()
|
2016-07-18 01:51:30 +08:00
|
|
|
static isHotspotEnabled(): Promise<void> { return; }
|
2016-03-14 01:29:59 +08:00
|
|
|
|
2016-11-30 06:40:50 +08:00
|
|
|
/**
|
|
|
|
* @returns {Promise<Array<HotspotDevice>>}
|
|
|
|
*/
|
2016-03-14 01:29:59 +08:00
|
|
|
@Cordova()
|
2016-07-18 01:51:30 +08:00
|
|
|
static getAllHotspotDevices(): Promise<Array<HotspotDevice>> { return; }
|
2016-03-14 01:29:59 +08:00
|
|
|
|
2016-05-06 08:57:49 +08:00
|
|
|
/**
|
|
|
|
* Connect to a WiFi network
|
|
|
|
*
|
|
|
|
* @param {string} ssid
|
|
|
|
* SSID to connect
|
|
|
|
* @param {string} password
|
|
|
|
* password to use
|
|
|
|
*
|
2016-11-30 06:40:50 +08:00
|
|
|
* @returns {Promise<void>}
|
2016-05-06 08:57:49 +08:00
|
|
|
* Promise that connection to the WiFi network was successfull, rejected if unsuccessful
|
|
|
|
*/
|
2016-03-14 01:29:59 +08:00
|
|
|
@Cordova()
|
2016-07-18 01:51:30 +08:00
|
|
|
static connectToWifi(ssid: string, password: string): Promise<void> { return; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Connect to a WiFi network
|
|
|
|
*
|
|
|
|
* @param {string} ssid
|
|
|
|
* SSID to connect
|
|
|
|
* @param {string} password
|
|
|
|
* Password to use
|
|
|
|
* @param {string} authentication
|
|
|
|
* Authentication modes to use (LEAP, SHARED, OPEN)
|
|
|
|
* @param {string[]} encryption
|
|
|
|
* Encryption modes to use (CCMP, TKIP, WEP104, WEP40)
|
|
|
|
*
|
2016-11-30 06:40:50 +08:00
|
|
|
* @returns {Promise<void>}
|
2016-07-18 01:51:30 +08:00
|
|
|
* Promise that connection to the WiFi network was successfull, rejected if unsuccessful
|
|
|
|
*/
|
|
|
|
@Cordova()
|
|
|
|
static connectToWifiAuthEncrypt(ssid: string, password: string, authentication: string, encryption: Array<string>): Promise<void> { return; }
|
2016-03-14 01:29:59 +08:00
|
|
|
|
2016-05-06 08:57:49 +08:00
|
|
|
/**
|
|
|
|
* Add a WiFi network
|
|
|
|
*
|
|
|
|
* @param {string} ssid
|
|
|
|
* SSID of network
|
|
|
|
* @param {string} mode
|
|
|
|
* Authentication mode of (Open, WEP, WPA, WPA_PSK)
|
|
|
|
* @param {string} password
|
|
|
|
* Password for network
|
|
|
|
*
|
2016-11-30 06:40:50 +08:00
|
|
|
* @returns {Promise<void>}
|
2016-05-06 08:57:49 +08:00
|
|
|
* Promise that adding the WiFi network was successfull, rejected if unsuccessful
|
|
|
|
*/
|
2016-03-14 01:29:59 +08:00
|
|
|
@Cordova()
|
2016-07-18 01:51:30 +08:00
|
|
|
static addWifiNetwork(ssid: string, mode: string, password: string): Promise<void> { return; }
|
2016-03-14 01:29:59 +08:00
|
|
|
|
2016-05-06 08:57:49 +08:00
|
|
|
/**
|
|
|
|
* Remove a WiFi network
|
|
|
|
*
|
|
|
|
* @param {string} ssid
|
|
|
|
* SSID of network
|
|
|
|
*
|
2016-11-30 06:40:50 +08:00
|
|
|
* @returns {Promise<void>}
|
2016-05-06 08:57:49 +08:00
|
|
|
* Promise that removing the WiFi network was successfull, rejected if unsuccessful
|
|
|
|
*/
|
2016-03-14 01:29:59 +08:00
|
|
|
@Cordova()
|
2016-07-18 01:51:30 +08:00
|
|
|
static removeWifiNetwork(ssid: string): Promise<void> { return; }
|
2016-03-14 01:29:59 +08:00
|
|
|
|
2016-11-30 06:40:50 +08:00
|
|
|
/**
|
|
|
|
* @returns {Promise<boolean>}
|
|
|
|
*/
|
2016-03-14 01:29:59 +08:00
|
|
|
@Cordova()
|
2016-07-18 01:51:30 +08:00
|
|
|
static isConnectedToInternet(): Promise<boolean> { return; }
|
2016-03-14 01:29:59 +08:00
|
|
|
|
2016-11-30 06:40:50 +08:00
|
|
|
/**
|
|
|
|
* @returns {Promise<boolean>}
|
|
|
|
*/
|
2016-03-14 01:29:59 +08:00
|
|
|
@Cordova()
|
2016-07-18 01:51:30 +08:00
|
|
|
static isConnectedToInternetViaWifi(): Promise<boolean> { return; }
|
2016-03-14 01:29:59 +08:00
|
|
|
|
2016-11-30 06:40:50 +08:00
|
|
|
/**
|
|
|
|
* @returns {Promise<boolean>}
|
|
|
|
*/
|
2016-03-14 01:29:59 +08:00
|
|
|
@Cordova()
|
2016-07-18 01:51:30 +08:00
|
|
|
static isWifiOn(): Promise<boolean> { return; }
|
2016-03-14 01:29:59 +08:00
|
|
|
|
2016-11-30 06:40:50 +08:00
|
|
|
/**
|
|
|
|
* @returns {Promise<boolean>}
|
|
|
|
*/
|
2016-03-14 01:29:59 +08:00
|
|
|
@Cordova()
|
2016-07-18 01:51:30 +08:00
|
|
|
static isWifiSupported(): Promise<boolean> { return; }
|
2016-03-14 01:29:59 +08:00
|
|
|
|
2016-11-30 06:40:50 +08:00
|
|
|
/**
|
|
|
|
* @returns {Promise<boolean>}
|
|
|
|
*/
|
2016-03-14 01:29:59 +08:00
|
|
|
@Cordova()
|
2016-07-18 01:51:30 +08:00
|
|
|
static isWifiDirectSupported(): Promise<boolean> { return; }
|
2016-03-14 01:29:59 +08:00
|
|
|
|
2016-11-30 06:40:50 +08:00
|
|
|
/**
|
|
|
|
* @returns {Promise<Array<HotspotNetwork>>}
|
|
|
|
*/
|
2016-03-14 01:29:59 +08:00
|
|
|
@Cordova()
|
2016-10-06 08:29:40 +08:00
|
|
|
static scanWifi(): Promise<Array<HotspotNetwork>> { return; }
|
2016-03-14 01:29:59 +08:00
|
|
|
|
2016-11-30 06:40:50 +08:00
|
|
|
/**
|
|
|
|
* @returns {Promise<Array<HotspotNetwork>>}
|
|
|
|
*/
|
2016-03-14 01:29:59 +08:00
|
|
|
@Cordova()
|
2016-10-06 08:29:40 +08:00
|
|
|
static scanWifiByLevel(): Promise<Array<HotspotNetwork>> { return; }
|
2016-03-14 01:29:59 +08:00
|
|
|
|
2016-11-30 06:40:50 +08:00
|
|
|
/**
|
|
|
|
* @returns {Promise<any>}
|
|
|
|
*/
|
2016-03-14 01:29:59 +08:00
|
|
|
@Cordova()
|
2016-07-18 01:51:30 +08:00
|
|
|
static startWifiPeriodicallyScan(interval: number, duration: number): Promise<any> { return; }
|
2016-03-14 01:29:59 +08:00
|
|
|
|
2016-11-30 06:40:50 +08:00
|
|
|
/**
|
|
|
|
* @returns {Promise<any>}
|
|
|
|
*/
|
2016-03-14 01:29:59 +08:00
|
|
|
@Cordova()
|
2016-07-18 01:51:30 +08:00
|
|
|
static stopWifiPeriodicallyScan(): Promise<any> { return; }
|
2016-03-14 01:29:59 +08:00
|
|
|
|
2016-11-30 06:40:50 +08:00
|
|
|
/**
|
|
|
|
* @returns {Promise<HotspotNetworkConfig>}
|
|
|
|
*/
|
2016-03-14 01:29:59 +08:00
|
|
|
@Cordova()
|
2016-10-06 08:29:40 +08:00
|
|
|
static getNetConfig(): Promise<HotspotNetworkConfig> { return; }
|
2016-03-14 01:29:59 +08:00
|
|
|
|
2016-11-30 06:40:50 +08:00
|
|
|
/**
|
2016-12-06 22:14:28 +08:00
|
|
|
* @returns {Promise<HotspotConnectionInfo>}
|
2016-11-30 06:40:50 +08:00
|
|
|
*/
|
2016-03-14 01:29:59 +08:00
|
|
|
@Cordova()
|
2016-12-06 22:14:28 +08:00
|
|
|
static getConnectionInfo(): Promise<HotspotConnectionInfo> { return; }
|
2016-03-14 01:29:59 +08:00
|
|
|
|
2016-11-30 06:40:50 +08:00
|
|
|
/**
|
|
|
|
* @returns {Promise<string>}
|
|
|
|
*/
|
2016-03-14 01:29:59 +08:00
|
|
|
@Cordova()
|
2016-07-18 01:51:30 +08:00
|
|
|
static pingHost(ip: string): Promise<string> { return; }
|
2016-03-14 01:29:59 +08:00
|
|
|
|
2016-05-06 08:57:49 +08:00
|
|
|
/**
|
|
|
|
* Gets MAC Address associated with IP Address from ARP File
|
|
|
|
*
|
|
|
|
* @param {string} ip - IP Address that you want the MAC Address of
|
|
|
|
*
|
2016-11-30 06:40:50 +08:00
|
|
|
* @returns {Promise<string>} - A Promise for the MAC Address
|
2016-05-06 08:57:49 +08:00
|
|
|
*/
|
2016-03-14 01:29:59 +08:00
|
|
|
@Cordova()
|
2016-07-18 01:51:30 +08:00
|
|
|
static getMacAddressOfHost(ip: string): Promise<string> { return; }
|
2016-03-14 01:29:59 +08:00
|
|
|
|
2016-05-06 08:57:49 +08:00
|
|
|
/**
|
|
|
|
* Checks if IP is live using DNS
|
|
|
|
*
|
|
|
|
* @param {string} ip - IP Address you want to test
|
|
|
|
*
|
2016-11-30 06:40:50 +08:00
|
|
|
* @returns {Promise<boolean>} - A Promise for whether the IP Address is reachable
|
2016-05-06 08:57:49 +08:00
|
|
|
*/
|
2016-03-14 01:29:59 +08:00
|
|
|
@Cordova()
|
2016-07-18 01:51:30 +08:00
|
|
|
static isDnsLive(ip: string): Promise<boolean> { return; }
|
2016-03-14 01:29:59 +08:00
|
|
|
|
2016-05-06 08:57:49 +08:00
|
|
|
/**
|
|
|
|
* Checks if IP is live using socket And PORT
|
|
|
|
*
|
|
|
|
* @param {string} ip - IP Address you want to test
|
|
|
|
*
|
2016-11-30 06:40:50 +08:00
|
|
|
* @returns {Promise<boolean>} - A Promise for whether the IP Address is reachable
|
2016-05-06 08:57:49 +08:00
|
|
|
*/
|
2016-03-14 01:29:59 +08:00
|
|
|
@Cordova()
|
2016-07-18 01:51:30 +08:00
|
|
|
static isPortLive(ip: string): Promise<boolean> { return; }
|
2016-03-14 01:29:59 +08:00
|
|
|
|
2016-05-06 08:57:49 +08:00
|
|
|
/**
|
|
|
|
* Checks if device is rooted
|
|
|
|
*
|
2016-11-30 06:40:50 +08:00
|
|
|
* @returns {Promise<boolean>} - A Promise for whether the device is rooted
|
2016-05-06 08:57:49 +08:00
|
|
|
*/
|
2016-03-14 01:29:59 +08:00
|
|
|
@Cordova()
|
2016-07-18 01:51:30 +08:00
|
|
|
static isRooted(): Promise<boolean> { return; }
|
2016-03-14 01:29:59 +08:00
|
|
|
|
2016-03-25 00:34:02 +08:00
|
|
|
}
|