public class SoftAPConnector extends Object
Constructor and Description |
---|
SoftAPConnector()
Instantiates a
SoftAPConnector with a DefaultConfigurationManager as default implementation for
managing access points configuration. |
SoftAPConnector(ConfigurationManager configurationManager)
Instantiates a
SoftAPConnector with a given ConfigurationManager . |
SoftAPConnector(ConfigurationManager configurationManager,
WifiNetworkManager wifiNetworkManager)
Instantiates a
SoftAPConnector with a given ConfigurationManager . |
Modifier and Type | Method and Description |
---|---|
void |
addListener(ConnectorListener connectorListener)
Adds a
ConnectorListener . |
ConfigurationManager |
getConfigurationManager()
Gets the configuration manager.
|
WifiNetworkManager |
getManager()
Gets the Wi-Fi manager.
|
boolean |
join(AccessPointConfiguration apConfiguration)
Joins an
AccessPoint , if the join fail, mount a SoftAP. |
protected void |
mountSoftAP()
Mounts the SoftAp.
|
protected void |
onJoin(AccessPointConfiguration apConfiguration)
Called before a join.
|
protected void |
onMount(SoftAPConfiguration softAPConfiguration)
Called when the softAP has been mounted.
|
protected void |
onScan(AccessPoint[] accessPoints)
Called when a scan is done.
|
protected void |
onSuccessfulJoin(AccessPointConfiguration apConfiguration)
Called when a successful join is done.
|
protected void |
onUnmount()
Called when the softAP has been unmounted.
|
void |
removeListener(ConnectorListener connectorListener)
Removes a
ConnectorListener . |
AccessPoint[] |
scan()
Scans the available
AccessPoint . |
void |
setConfigurationManager(ConfigurationManager configurationManager)
Sets the configuration manager, can not be
null . |
void |
setIPConfiguration(IPConfiguration configuration,
IPConfiguration softAPConfiguration)
Sets the IP configuration.
|
void |
start()
Starts the
SoftAPConnector :
Sets the Wi-Fi network manager configuration.
Tries to join the ConfigurationManager
If the ConfigurationManager does not provide one or if the join fails, mounts the SoftAP.
|
void |
stop()
Stops the
SoftAPConnector . |
protected void |
unmountSoftAP()
Unmounts the softAp.
|
public SoftAPConnector() throws IOException
SoftAPConnector
with a DefaultConfigurationManager
as default implementation for
managing access points configuration.IOException
- When initialisation fails.public SoftAPConnector(@NonNull ConfigurationManager configurationManager) throws IOException, NullPointerException
SoftAPConnector
with a given ConfigurationManager
.configurationManager
- the ConfigurationManager
to use to get the softAp and AP parameters.IOException
- When initialization fails.NullPointerException
- If configurationManager or WifiNetworkManager
is null
.public SoftAPConnector(@NonNull ConfigurationManager configurationManager, @NonNull WifiNetworkManager wifiNetworkManager) throws IOException, NullPointerException
SoftAPConnector
with a given ConfigurationManager
.configurationManager
- the ConfigurationManager
to use to get the softAp and AP parameters.wifiNetworkManager
- the WifiNetworkManager
, cannot be null
IOException
- When initialization fails.NullPointerException
- If configurationManager or WifiNetworkManager
is null
.public void addListener(ConnectorListener connectorListener)
ConnectorListener
.connectorListener
- the listener, cannot be null
.public ConfigurationManager getConfigurationManager()
public WifiNetworkManager getManager()
WifiNetworkManager
.public boolean join(AccessPointConfiguration apConfiguration)
AccessPoint
, if the join fail, mount a SoftAP.apConfiguration
- the AccessPointConfiguration
to use.WifiNetworkManager.joinAccessPoint(int)
,
WifiNetworkManager.mountSoftAccessPoint()
protected void mountSoftAP() throws IOException
IOException
- if an IOException occured during the mount.protected void onJoin(AccessPointConfiguration apConfiguration)
apConfiguration
- the apConfiguration joined.protected void onMount(SoftAPConfiguration softAPConfiguration)
softAPConfiguration
- the configuration used, not null
.protected void onScan(AccessPoint[] accessPoints)
accessPoints
- the accesspoints.protected void onSuccessfulJoin(AccessPointConfiguration apConfiguration)
apConfiguration
- the apConfiguration joined.protected void onUnmount()
public void removeListener(ConnectorListener connectorListener)
ConnectorListener
.connectorListener
- the listener, cannot be null
.public AccessPoint[] scan() throws IOException
AccessPoint
.AccessPoint
.IOException
- if an IOException
occurs.WifiNetworkManager.scanAccessPoints()
public void setConfigurationManager(ConfigurationManager configurationManager)
null
.configurationManager
- The ConfigurationManager
to use for managing access points configuration.NullPointerException
- If configurationManager is null
.public void setIPConfiguration(IPConfiguration configuration, IPConfiguration softAPConfiguration)
start()
.configuration
- the IPConfiguration
to use for the client mode, can be null
.softAPConfiguration
- IPConfiguration
to use for the softAP, can be null
.public void start() throws IOException
SoftAPConnector
:
ConfigurationManager
ConfigurationManager
does not provide one or if the join fails, mounts the SoftAP.IOException
- if an IOException
occurs.join(AccessPointConfiguration)
,
ConfigurationManager.loadAPConfiguration()
public void stop()
SoftAPConnector
.protected void unmountSoftAP() throws IOException
IOException
- if an IOException
occurs during unmount.