public class WifiNetworkManager extends 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 . |
String |
getInterfaceName()
Gets the interfaceName.
|
AccessPoint |
getJoinedAccessPoint()
Gets the joined access.
|
SoftAPConfiguration |
getSoftAPConfiguration()
Gets the softAPConfiguration.
|
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,
String password,
int timeout)
Joins a specific
AccessPoint . |
void |
joinAccessPoint(int timeout)
Joins the access point configuration selected.
|
void |
joinAccessPoint(String ssid,
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(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 IOException
AccessPointConfiguration
and
SoftAPConfiguration
.IOException
- When initialise fail.WifiNetworkManager(AccessPointConfiguration, SoftAPConfiguration)
public WifiNetworkManager(@NonNull AccessPointConfiguration configurationAP, @NonNull SoftAPConfiguration softAPConfiguration) throws IOException, NullPointerException
configurationAP
- the configurationAP to use.softAPConfiguration
- the softAPConfiguration to use.IOException
- When initialise fail.NullPointerException
- if parameters are null
or WifiManager
not found.WifiManager.getInstance()
public AccessPointConfiguration getAPConfiguration()
public WifiCapability getCapabilities() throws IOException
WifiCapability
.IOException
- If an I/O error occurs.WifiManager.getCapability()
public String getInterfaceName()
public AccessPoint getJoinedAccessPoint() throws IOException
null
if none.IOException
- If an I/O error occurs.WifiManager.getJoined()
public SoftAPConfiguration getSoftAPConfiguration()
public NetworkInterface getWifiInterface()
public WifiManager getWifiManager()
public boolean isConnected() throws IOException
IOException
- If an I/O error occurs.WifiManager.getJoined()
public boolean isInit()
true
if the Wi-FI manager is initialized.NetworkInterfaceManager.isEnabled(NetworkInterface)
public boolean isSoftAPEnabled() throws IOException
IOException
- If an I/O error occurs.WifiManager.isSoftAPEnabled()
public void joinAccessPoint(@NonNull AccessPoint access, @Nullable String password, int timeout) throws IOException, NullPointerException, UnsupportedOperationException, 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.IOException
- if an error occurred.NullPointerException
- if the AP is null
.UnsupportedOperationException
- If the Wi-Fi does not support client mode.IllegalArgumentException
- if timeout is less than 0.WifiManager.join(AccessPoint, String)
public void joinAccessPoint(int timeout) throws IOException, NullPointerException, UnsupportedOperationException, IllegalArgumentException
timeout
- the timeout to wait for an IP, 0 for unlimited, cannot be less than 0.IOException
- if an error occurred.NullPointerException
- if AP is not set.UnsupportedOperationException
- If the Wi-Fi does not support client mode.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 String ssid, @Nullable String password, @Nullable SecurityMode securityMode, int timeout) throws IOException, UnsupportedOperationException, 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.IOException
- if an error occurred.UnsupportedOperationException
- If the Wi-Fi does not support client mode.IllegalArgumentException
- if timeout is less than 0.WifiManager.join(String, String)
public void leaveAccessPoint() throws IOException
IOException
- if an error occurred.WifiManager.leave()
public void mountSoftAccessPoint() throws IOException
IOException
- if an error occurred.WifiManager.enableSoftAP(SoftAPConfiguration)
public void mountSoftAccessPoint(@NonNull SoftAPConfiguration config) throws IOException, UnsupportedOperationException
config
- the configuration to use.IOException
- if an error occurred.UnsupportedOperationException
- If the Wi-Fi does not support SoftAP mode.WifiManager.enableSoftAP(SoftAPConfiguration)
public AccessPoint[] scanAccessPoints() throws IOException
IOException
- if an error occurred.WifiManager.scan()
public void setAPConfiguration(@NonNull AccessPointConfiguration configurationAP)
configurationAP
- the configurationAP to set.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 setInterfaceName(@Nullable String interfaceName)
interfaceName
- the interfaceName to set.public void setScanWhileSoftAP(boolean scanWhileSoftAP)
scanWhileSoftAP
- true
if scan while mounted is supported.public void setSoftAPConfiguration(@NonNull SoftAPConfiguration softAPConfiguration) throws NullPointerException
softAPConfiguration
- the softAPConfiguration to set, cannot be null
.NullPointerException
- if SoftAPConfiguration
is null
.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 boolean supportScanWhileSoftAP()
true
if scan while mounted is supported.public void unmountSoftAccessPoint() throws IOException
IOException
- if an error occurred.WifiManager.disableSoftAP()