Socket
Socket
Sign inDemoInstall

cordova-plugin-hotspot

Package Overview
Dependencies
Maintainers
1
Versions
75
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cordova-plugin-hotspot - npm Package Compare versions

Comparing version 0.7.7 to 0.8.0

jsdoc.json

13

package.json
{
"name": "cordova-plugin-hotspot",
"version": "0.7.7",
"version": "0.8.0",
"description": "Cordova WiFi Hotspot Plugin",

@@ -21,4 +21,13 @@ "cordova": {

],
"scripts": {
"pretest": "rm -rf tmp && mkdir -p tmp && cd tmp && git clone https://github.com/simpligility/maven-android-sdk-deployer.git && cd maven-android-sdk-deployer/ && mvn install -P 5.0",
"test": "cd tmp && git clone https://github.com/apache/cordova-app-hello-world.git && cd cordova-app-hello-world && cordova platform add android@4 && cordova build && cd ../../test/android && gradle build",
"posttest": "jsdoc -c jsdoc.json && jsdoc2md www/HotSpotPlugin.js | sed s/hotSpotPlugin/cordova.plugins.hotspot/g | sed s/HotSpotPlugin/cordova.plugins.hotspot/g > PLUGIN_USAGE.MD"
},
"author": "Martin Reinhardt",
"license": "MIT"
"license": "MIT",
"devDependencies": {
"jsdoc": "3.4.0",
"jsdoc-to-markdown": "1.3.3"
}
}

355

README.md

@@ -24,357 +24,4 @@ # Cordova HotSpot Plugin

### Check if Plugin is available
See [here](./PLUGIN_USAGE.MD) for complete reference.
```javascript
cordova.plugins.hotspot.isAvailable(
function (isAvailable) {
// alert('Service is not available') unless isAvailable;
}
);
```
### Check if device is connected to internet
```javascript
cordova.plugins.hotspot.isConnectedToInternet(
function () {
// is connected
},function () {
// is not connected
}
);
```
### Get connection configuration
```javascript
cordova.plugins.hotspot.getConnectionInfo(
function (result) {
// SSID
// BSSID
// linkSpeed
// IPAddress
},function () {
// error
}
);
```
### Get network configuration
```javascript
cordova.plugins.hotspot.getNetConfig(
function (result) {
// deviceIPAddress
// deviceMacAddress
// gatewayIPAddress
// gatewayMacAddress
},function () {
// error
}
);
```
### Ping a host
```javascript
cordova.plugins.hotspot.pingHost(ip,
function (result) {
if(result){
// host is up
} else {
// host is not responsing
}
},function () {
// error
}
);
```
### Get MAC address of host
```javascript
cordova.plugins.hotspot.getMacAddressOfHost(ip,
function (result) {
if(result){
// MAC address of host
} else {
// host is not responsing
}
},function () {
// error
}
);
```
### Check DNS is alive
```javascript
cordova.plugins.hotspot.isDnsLive(ip,
function (live) {
if(live){
// DNS is live
} else {
// DNS is not live
}
},function () {
// error
}
);
```
### Check port is alive
```javascript
cordova.plugins.hotspot.isPortLive(ip,
function (live) {
if(live){
// DNS is live
} else {
// DNS is not live
}
},function () {
// error
}
);
```
### Check if device is rooted
```javascript
cordova.plugins.hotspot.isRooted(
function (rooted) {
if(rooted){
// device is rooted
} else {
// device is not rooted
}
},function () {
// error
}
);
```
### Hotspot functionality
#### Create Hotspot
```javascript
cordova.plugins.hotspot.createHotspot(ssid, mode, password,
function () {
// Hotspot is created
},function () {
// Error
}
);
```
#### Start Hotspot
```javascript
cordova.plugins.hotspot.startHotspot(
function () {
// Hotspot is started
},function () {
// Error
}
);
```
#### Configure Hotspot
```javascript
cordova.plugins.hotspot.configureHotspot(ssid, mode, password,
function () {
// Hotspot is configured
},function () {
// Error
}
);
```
#### Stop Hotspot
```javascript
cordova.plugins.hotspot.stopHotspot(
function () {
// Hotspot is disabled
},function () {
// Error
}
);
```
#### Check if Hotspot is enabled
```javascript
cordova.plugins.hotspot.isHotspotEnabled(
function () {
// Hotspot is on
},function () {
// Hotspot is off
}
);
```
#### Get all connected devices
```javascript
cordova.plugins.hotspot.getAllHotspotDevices(
function (devices) {
// array of JSON objects:
// -> ip
// -> mac
},function (err) {
// error
}
);
```
### Wifi
### Check if Wifi is supported
```javascript
cordova.plugins.hotspot.isWifiSupported(
function () {
// wifi is on
},function () {
// wifi is off
}
);
```
#### Check if Wifi is enabled
```javascript
cordova.plugins.hotspot.isWifiOn(
function () {
// wifi is on
},function () {
// wifi is off
}
);
```
#### Toggle Wifi
```javascript
cordova.plugins.hotspot.toggleWifi(
function (isActive) {
// wifi is on
},function (err) {
// error
}
);
```
#### Connect to Wifi
```javascript
cordova.plugins.hotspot.connectToHotspot(ssid, password,
function () {
// connected
},function () {
// not connected
}
);
```
### Check if device is connected to internet via Wifi
```javascript
cordova.plugins.hotspot.isConnectedToInternetViaWifi(
function () {
// is connected
},function () {
// is not connected
}
);
```
### Check if Wifi Direct is supported
```javascript
cordova.plugins.hotspot.isWifiDirectSupported(
function () {
// wifi is on
},function () {
// wifi is off
}
);
```
#### Add a network config
```javascript
cordova.plugins.hotspot.addWifiNetwork(ssid, mode, password,
function () {
// wifi is added
},function (err) {
// error
}
);
```
#### Delete a network config
```javascript
cordova.plugins.hotspot.removeWifiNetwork(ssid,
function () {
// wifi is deleted
},function (err) {
// error
}
);
```
#### Start a periodically scan
```javascript
cordova.plugins.hotspot.startPeriodicallyScan(interval, duration,
function () {
// success
},function (err) {
// error
}
);
```
#### Scan network
```javascript
cordova.plugins.hotspot.scanWifi(
function (listOfNetworks) {
// array of results
},function (err) {
// error
}
);
```
#### Scan network by level
```javascript
cordova.plugins.hotspot.scanWifiByLevel(
function (listOfNetworks) {
// array of results
},function (err) {
// error
}
);
```
#### Stop a periodically scan
```javascript
cordova.plugins.hotspot.stopPeriodicallyScan(
function () {
// success
},function (err) {
// error
}
);
```
## Dev

@@ -381,0 +28,0 @@

@@ -27,3 +27,5 @@ /*

/**
* @namespace
*/
var HotSpotPlugin = function () {

@@ -37,3 +39,2 @@

* Check if plugin is available
*
* @param {Function} callback

@@ -55,9 +56,11 @@ * A callback function with true or false as response

* A callback function with true or false as response,true if wifi ON and false if wifi OFF
* @param {Object} errorCB
* A callback function to be called when errors occurr
*/
toggleWifi: function (callback) {
toggleWifi: function (callback, errorCB) {
cordova.exec(function (code) {
if (code === 1) {
successCB(true);
callback(true);
} else {
successCB(false);
callback(false);
}

@@ -164,3 +167,25 @@ }, function (err) {

},
/**
* configure current WiFi Hotspot
*
* @param {String} ssid
* SSID to connect
* @param {String} password
* password to use
* @param {String} authentication
* mode use (LEAP, SHARED, OPEN)
* @param {string[]} encryption
* mode use (Open, WEP, WPA, WPA_PSK)
* @param {Function} successCB
* A callback function to be called when connected successful
* @param {Object} errorCB
* A callback function to be called when connection was not successful
*/
connectToWifiAuthEncrypt: function (ssid, password, authentication, successCB, errorCB) {
cordova.exec(successCB, function (err) {
errorCB(err);
}, "HotSpotPlugin", "connectToWifiAuthEncrypt", [ssid, password, mode]);
},
/**

@@ -379,4 +404,32 @@ * configure current WiFi Hotspot

pingHost: function (ip, successCB, errorCB) {
cordova.exec(successCB, function (err) {
errorCB(err);
var statsPattern = /\s=\s(\d+\.\d+)\/(\d+\.\d+)\/(\d+\.\d+)\/(\d+\.\d+)/;
function parseResponse(response) {
var stats = response.substring(response.indexOf('min/avg/max/mdev') + 'min/avg/max/mdev'.length);
var result = {
requestTimeout: response.indexOf('Request timeout') !== -1
};
result.stat = {
packetLoss: response.match(/\sreceived,\s(\d+(\.\d+)?)%\spacket\sloss/)[1],
time: response.match(/,\stime\s(\d+)ms/)[1]
};
if (stats.match(statsPattern)) {
result.stat.min = stats.match(statsPattern)[1];
result.stat.max = stats.match(statsPattern)[3];
result.stat.avg = stats.match(statsPattern)[2];
result.stat.stddev = stats.match(statsPattern)[4];
}
return result;
}
cordova.exec(function (response) {
if (response && response.length > 0) {
successCB(parseResponse(response));
} else {
errorCB(parseResponse(response));
}
}, function (err) {
errorCB(parseResponse(err));
}, 'HotSpotPlugin', 'pingHost', [ip]);

@@ -456,5 +509,3 @@ },

}
}
;
};
module.exports = new HotSpotPlugin();

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc