Skip to content

Latest commit

 

History

History
386 lines (318 loc) · 7.09 KB

README.md

File metadata and controls

386 lines (318 loc) · 7.09 KB

Cordova HotSpot Plugin

Build Status npm version Dependency Status devDependency Status

A Cordova plugin for managing HotSpot networks on Android with Cordova 3.4.0 / API Level 19

NPM

Feel free to donate

Click here to lend your support to: Owncloud Apps and make a donation at www.pledgie.com !

Installation

$ cordova plugin add cordova-plugin-hotspot

Usage

Check if Plugin is available

cordova.plugins.hotspot.isAvailable(
    function (isAvailable) {
        // alert('Service is not available') unless isAvailable;
    }
);

Check if device is connected to internet

cordova.plugins.hotspot.isConnectedToInternet(
   function () {
       // is connected
   },function () {
       // is not connected
   }
);

Get connection configuration

cordova.plugins.hotspot.getConnectionInfo(
   function (result) {
       // SSID
       // BSSID
       // linkSpeed
       // IPAddress
   },function () {
       // error
   }
);

Get network configuration

cordova.plugins.hotspot.getNetConfig(
   function (result) {
       // deviceIPAddress
       // deviceMacAddress
       // gatewayIPAddress
       // gatewayMacAddress
   },function () {
       // error
   }
);

Ping a host

cordova.plugins.hotspot.pingHost(ip,
  function (result) {
      if(result){
        // host is up
      } else {
        // host is not responsing
      }
  },function () {
      // error
  }
);

Get MAC address of host

cordova.plugins.hotspot.getMacAddressOfHost(ip,
  function (result) {
      if(result){
        // MAC address of host
      } else {
        // host is not responsing
      }
  },function () {
      // error
  }
);

Check DNS is alive

cordova.plugins.hotspot.isDnsLive(ip,
  function (live) {
      if(live){
        // DNS is live
      } else {
        // DNS is not live
      }
  },function () {
      // error
  }
);

Check port is alive

cordova.plugins.hotspot.isPortLive(ip,
  function (live) {
      if(live){
        // DNS is live
      } else {
        // DNS is not live
      }
  },function () {
      // error
  }
);

Check if device is rooted

cordova.plugins.hotspot.isRooted(
  function (rooted) {
      if(rooted){
        // device is rooted
      } else {
        // device is not rooted
      }
  },function () {
      // error
  }
);

Hotspot functionality

Create Hotspot

cordova.plugins.hotspot.createHotspot(ssid, mode, password, 
    function () {
        // Hotspot is created
    },function () {
        // Error
    }
);

Start Hotspot

cordova.plugins.hotspot.startHotspot(
    function () {
        // Hotspot is started
    },function () {
        // Error
    }
);

Configure Hotspot

   cordova.plugins.hotspot.configureHotspot(ssid, mode, password, 
       function () {
           // Hotspot is configured
       },function () {
           // Error
       }
   );

Stop Hotspot

cordova.plugins.hotspot.stopHotspot(
    function () {
        // Hotspot is disabled
    },function () {
        // Error
    }
);

Check if Hotspot is enabled

cordova.plugins.hotspot.isHotspotEnabled(
    function () {
        // Hotspot is on
    },function () {
        // Hotspot is off
    }
);

Get all connected devices

cordova.plugins.hotspot.getAllHotspotDevices(
    function (devices) {
        // array of JSON objects:
        // -> ip
        // -> mac
    },function (err) {
        // error
    }
);

Wifi

Check if Wifi is supported

cordova.plugins.hotspot.isWifiSupported(
   function () {
       // wifi is on
   },function () {
       // wifi is off
   }
);

Check if Wifi is enabled

cordova.plugins.hotspot.isWifiOn(
   function () {
       // wifi is on
   },function () {
       // wifi is off
   }
);

Toggle Wifi

cordova.plugins.hotspot.toggleWifi(
   function (isActive) {
       // wifi is on
   },function (err) {
       // error
   }
);

Connect to Wifi

cordova.plugins.hotspot.connectToHotspot(ssid, password, 
   function () {
       // connected
   },function () {
       // not connected
   }
);

Check if device is connected to internet via Wifi

cordova.plugins.hotspot.isConnectedToInternetViaWifi(
   function () {
       // is connected
   },function () {
       // is not connected
   }
);

Check if Wifi Direct is supported

cordova.plugins.hotspot.isWifiDirectSupported(
    function () {
        // wifi is on
    },function () {
        // wifi is off
    }
);

Add a network config

cordova.plugins.hotspot.addWifiNetwork(ssid, mode, password,
   function () {
       // wifi is added
   },function (err) {
       // error
   }
);

Delete a network config

cordova.plugins.hotspot.removeWifiNetwork(ssid, 
   function () {
       // wifi is deleted
   },function (err) {
       // error
   }
);

Start a periodically scan

cordova.plugins.hotspot.startPeriodicallyScan(interval, duration,
   function () {
       // success
   },function (err) {
       // error
   }
);

Scan network

cordova.plugins.hotspot.scanWifi( 
   function (listOfNetworks) {
       // array of results
   },function (err) {
       // error
   }
);

Scan network by level

cordova.plugins.hotspot.scanWifiByLevel(
   function (listOfNetworks) {
       // array of results
   },function (err) {
       // error
   }
);

Stop a periodically scan

cordova.plugins.hotspot.stopPeriodicallyScan( 
   function () {
       // success
   },function (err) {
       // error
   }
);

Dev

To run the integration tests before

export PLATFORM="android" 
./runIntegrationTests.sh