public class WifiNetworkManager
extends java.lang.Object
WifiManager
,
NetworkInterfaceManager
Constructor and Description |
---|
WifiNetworkManager()
Instantiates a WifiNetworkManager with a default
AccessPointConfiguration and
SoftAPConfiguration . |
WifiNetworkManager(AccessPointConfiguration configurationAP,
SoftAPConfiguration softAPConfiguration)
Instantiates a WifiNetworkManager.
|
Modifier and Type | Method and Description |
---|---|
AccessPointConfiguration |
getAPConfiguration()
Gets the configurationAP.
|
WifiCapability |
getCapabilities()
Gets the
WifiCapability . |
java.lang.String |
getInterfaceName()
Gets the interfaceName.
|
AccessPoint |
getJoinedAccessPoint()
Gets the joined access.
|
SoftAPConfiguration |
getSoftAPConfiguration()
Gets the softAPConfiguration.
|
java.net.NetworkInterface |
getWifiInterface()
Gets the wifi Interface.
|
WifiManager |
getWifiManager()
Gets the Wi-FI manager used.
|
boolean |
isConnected()
Checks if the Wi-FI is connected to network.
|
boolean |
isInit()
Checks if the Wi-FI Manager is initialized.
|
boolean |
isSoftAPEnabled()
Checks if the Wi-FI is has enabled the softAP.
|
void |
joinAccessPoint(AccessPoint access,
java.lang.String password,
int timeout)
Joins a specific
AccessPoint . |
void |
joinAccessPoint(int timeout)
Joins the access point configuration selected.
|
void |
joinAccessPoint(java.lang.String ssid,
java.lang.String password,
SecurityMode securityMode,
int timeout)
Joins a particular Access Point.
|
void |
leaveAccessPoint()
Leaves the joined Access Point.
|
void |
mountSoftAccessPoint()
Mounts a Soft Access Point.
|
void |
mountSoftAccessPoint(SoftAPConfiguration config)
Mounts a Soft Access Point.
|
AccessPoint[] |
scanAccessPoints()
Scans Access Points.
|
void |
setAPConfiguration(AccessPointConfiguration configurationAP)
Sets the configurationAP.
|
void |
setClientIPConfigure(IPConfiguration ipConfiguration)
Sets the
IPConfiguration for the interface while in client mode. |
void |
setInterfaceName(java.lang.String interfaceName)
Sets the interfaceName.
|
void |
setScanWhileSoftAP(boolean scanWhileSoftAP)
Sets whether it supports scan while mounted.
|
void |
setSoftAPConfiguration(SoftAPConfiguration softAPConfiguration)
Sets the softAPConfiguration.
|
void |
setSoftAPIPConfigure(IPConfiguration softAPIPConfiguration)
Sets the
IPConfiguration for the interface while in softAP. |
boolean |
supportScanWhileSoftAP()
Gets whether it supports scan while in softAP.
|
void |
unmountSoftAccessPoint()
Unmounts a Soft Access Point.
|
public WifiNetworkManager() throws java.io.IOException
AccessPointConfiguration
and
SoftAPConfiguration
.java.io.IOException
- When initialise fail.WifiNetworkManager(AccessPointConfiguration, SoftAPConfiguration)
public WifiNetworkManager(@NonNull AccessPointConfiguration configurationAP, @NonNull SoftAPConfiguration softAPConfiguration) throws java.io.IOException, java.lang.NullPointerException
configurationAP
- the configurationAP to use.softAPConfiguration
- the softAPConfiguration to use.java.io.IOException
- When initialise fail.java.lang.NullPointerException
- if parameters are null
or WifiManager
not found.WifiManager#getInstance()
public boolean isInit()
true
if the Wi-FI manager is initialized.NetworkInterfaceManager#isEnabled(NetworkInterface)
public AccessPoint[] scanAccessPoints() throws java.io.IOException
java.io.IOException
- if an error occurred.WifiManager#scan()
public void joinAccessPoint(int timeout) throws java.io.IOException, java.lang.NullPointerException, java.lang.UnsupportedOperationException, java.lang.IllegalArgumentException
timeout
- the timeout to wait for an IP, 0 for unlimited, cannot be less than 0.java.io.IOException
- if an error occurred.java.lang.NullPointerException
- if AP is not set.java.lang.UnsupportedOperationException
- If the Wi-Fi does not support client mode.java.lang.IllegalArgumentException
- if timeout is less than 0.getAPConfiguration()
,
AccessPointConfiguration.setAccessPoint(AccessPoint)
,
joinAccessPoint(AccessPoint, String, int)
,
joinAccessPoint(AccessPoint, String, int)
,
joinAccessPoint(String, String, SecurityMode, int)
public void joinAccessPoint(@NonNull AccessPoint access, @Nullable java.lang.String password, int timeout) throws java.io.IOException, java.lang.NullPointerException, java.lang.UnsupportedOperationException, java.lang.IllegalArgumentException
AccessPoint
.access
- the AccessPoint
to join.password
- the AccessPoint
password.timeout
- the timeout to wait for an IP, 0 for unlimited, cannot be less than 0.java.io.IOException
- if an error occurred.java.lang.NullPointerException
- if the AP is null
.java.lang.UnsupportedOperationException
- If the Wi-Fi does not support client mode.java.lang.IllegalArgumentException
- if timeout is less than 0.WifiManager#join(AccessPoint, String)
public void joinAccessPoint(@NonNull java.lang.String ssid, @Nullable java.lang.String password, @Nullable SecurityMode securityMode, int timeout) throws java.io.IOException, java.lang.UnsupportedOperationException, java.lang.IllegalArgumentException
ssid
- the AP SSID.password
- the AP password.securityMode
- the security Mode to use.timeout
- the timeout to wait for an IP, 0 for unlimited, cannot be less than 0.java.io.IOException
- if an error occurred.java.lang.UnsupportedOperationException
- If the Wi-Fi does not support client mode.java.lang.IllegalArgumentException
- if timeout is less than 0.WifiManager#join(String, String)
public void leaveAccessPoint() throws java.io.IOException
java.io.IOException
- if an error occurred.WifiManager#leave()
public boolean isConnected() throws java.io.IOException
java.io.IOException
- If an I/O error occurs.WifiManager#getJoined()
public boolean isSoftAPEnabled() throws java.io.IOException
java.io.IOException
- If an I/O error occurs.WifiManager#isSoftAPEnabled()
public AccessPoint getJoinedAccessPoint() throws java.io.IOException
null
if none.java.io.IOException
- If an I/O error occurs.WifiManager#getJoined()
public AccessPointConfiguration getAPConfiguration()
public void setAPConfiguration(@NonNull AccessPointConfiguration configurationAP)
configurationAP
- the configurationAP to set.public SoftAPConfiguration getSoftAPConfiguration()
public void setSoftAPConfiguration(@NonNull SoftAPConfiguration softAPConfiguration) throws java.lang.NullPointerException
softAPConfiguration
- the softAPConfiguration to set, cannot be null
.java.lang.NullPointerException
- if SoftAPConfiguration
is null
.public void mountSoftAccessPoint() throws java.io.IOException
java.io.IOException
- if an error occurred.WifiManager#enableSoftAP(SoftAPConfiguration)
public void mountSoftAccessPoint(@NonNull SoftAPConfiguration config) throws java.io.IOException, java.lang.UnsupportedOperationException
config
- the configuration to use.java.io.IOException
- if an error occurred.java.lang.UnsupportedOperationException
- If the Wi-Fi does not support SoftAP mode.WifiManager#enableSoftAP(SoftAPConfiguration)
public void unmountSoftAccessPoint() throws java.io.IOException
java.io.IOException
- if an error occurred.WifiManager#disableSoftAP()
public boolean supportScanWhileSoftAP()
true
if scan while mounted is supported.public void setScanWhileSoftAP(boolean scanWhileSoftAP)
scanWhileSoftAP
- true
if scan while mounted is supported.public WifiCapability getCapabilities() throws java.io.IOException
WifiCapability
.java.io.IOException
- If an I/O error occurs.WifiManager#getCapability()
public void setClientIPConfigure(@Nullable IPConfiguration ipConfiguration)
IPConfiguration
for the interface while in client mode. This will be taken in account on the
next join.ipConfiguration
- the IPConfiguration
to use, can be null
then it won't be used.public void setSoftAPIPConfigure(@Nullable IPConfiguration softAPIPConfiguration)
IPConfiguration
for the interface while in softAP. This will be taken in account on the next
mountSoftAccessPoint()
.softAPIPConfiguration
- the IPConfiguration
to use when in softAP.public java.lang.String getInterfaceName()
public void setInterfaceName(@Nullable java.lang.String interfaceName)
interfaceName
- the interfaceName to set.public WifiManager getWifiManager()
public java.net.NetworkInterface getWifiInterface()