Package ej.ecom.wifi

Class WifiManager


  • public class WifiManager
    extends Object
    Manages the Wi-Fi capabilities.
    • Constructor Detail

      • WifiManager

        public WifiManager()
    • Method Detail

      • disableSoftAP

        public void disableSoftAP()
                           throws IOException
        Disables the Software enabled Access Point (SoftAP). This method has no effect if the SoftAP is not started.
        Throws:
        IOException - if an I/O error occurs
      • enableSoftAP

        public void enableSoftAP​(SoftAPConfiguration configuration)
                          throws IOException
        Enables the SoftAP with a given configuration.
        Parameters:
        configuration - SoftAP configuration.
        Throws:
        IOException - if SoftAP mode is not supported, an access point is currently joined and the platform does support simultaneous mode (leave() must be called before this method) or an I/O error occurs.
      • getCapability

        public WifiCapability getCapability()
                                     throws IOException
        Gets the Wi-Fi capability of the platform.
        Returns:
        Wi-Fi capability.
        Throws:
        IOException - If an I/O error occurs.
      • getJoined

        @Nullable
        public AccessPoint getJoined()
                              throws IOException
        Gets the currently joined Wi-Fi access point.
        Returns:
        currently joined Wi-Fi access point or null if no Wi-Fi access point has been joined yet.
        Throws:
        IOException - If an I/O error occurs.
      • isSoftAPEnabled

        public boolean isSoftAPEnabled()
                                throws IOException
        Tells whether if SoftAP is currently enabled.
        Returns:
        true if enabled, false otherwise.
        Throws:
        IOException - If an I/O error occurs.
      • join

        public void join​(AccessPoint accessPoint,
                         String passphrase,
                         SecurityMode securityMode)
                  throws IOException
        Joins a Wi-Fi network using a Wi-Fi access point, a passphrase and a security mode.
        Parameters:
        accessPoint - Wi-Fi access point.
        passphrase - Wi-Fi access point passphrase. The passphrase must be a sequence of between 8 and 64 ASCII-encoded characters.
        securityMode - Wi-Fi access point security mode.
        Throws:
        IOException - if client mode is not supported, the SoftAP is currently enabled and the platform does support simultaneous mode ( disableSoftAP() must be called before this method), or an I/O error occurs.
        IllegalArgumentException - if the accessPoint or the passphrase is null.
      • join

        public void join​(String SSID,
                         String passphrase)
                  throws IOException
        Joins a Wi-Fi network using a SSID and a passphrase.
        Parameters:
        SSID - Wi-Fi access point Service Set Identifier (SSID).
        passphrase - Wi-Fi access point passphrase. The passphrase must be a sequence of between 8 and 64 ASCII-encoded characters.
        Throws:
        IOException - if client mode is not supported, the SoftAP is currently enabled and the platform does support simultaneous mode ( disableSoftAP() must be called before this method), or an I/O error occurs.
        IllegalArgumentException - if the SSID or the passphrase is null.
      • join

        public void join​(String SSID,
                         String passphrase,
                         SecurityMode securityMode)
                  throws IOException
        Joins a wireless network using an SSID and a passphrase.
        Parameters:
        SSID - Wi-Fi access point Service Set Identifier (SSID).
        passphrase - Wi-Fi access point passphrase. The passphrase must be a sequence of between 8 and 64 ASCII-encoded characters.
        securityMode - Wi-Fi access point security mode.
        Throws:
        IOException - if client mode is not supported, the SoftAP is currently enabled and the platform does support simultaneous mode ( disableSoftAP() must be called before this method), or an I/O error occurs.
        IllegalArgumentException - if the SSID or the passphrase is null.
      • leave

        public void leave()
                   throws IOException
        Leaves the currently joined Wi-Fi access point. If no Wi-Fi access point has been joined yet, this method has no effect.
        Throws:
        IOException - If an I/O error occurs.
      • scan

        public AccessPoint[] scan()
                           throws IOException
        Performs an active scan of available Wi-Fi access points. This is equivalent to scan(true).
        Returns:
        the list of available Wi-Fi access points or an empty list if there is no available Wi-Fi access point.
        Throws:
        IOException - if the underlying Wi-Fi network interface is currently stopped, scanning is not possible at the moment, or an I/O error occurs.
      • scan

        public AccessPoint[] scan​(boolean active)
                           throws IOException
        Performs a scan of available access points.
        Parameters:
        active - true for an active scan, false for a passive scan.
        Returns:
        the list of available access points or an empty list if there is no available Wi-Fi access point.
        Throws:
        IOException - if the underlying network interface is currently stopped, scanning is not possible at the moment, or an I/O error occurs.