public class

EthernetManager

extends Object
java.lang.Object
   ↳ com.digi.android.ethernet.EthernetManager

Class Overview

Class that handles the Ethernet connection and configuration.

Note that only one interface is supported.

Unless noted, all API methods require the android.permission.ACCESS_NETWORK_STATE and/or android.permission.CHANGE_NETWORK_STATE permissions, depending on whether you are accessing or changing the Ethernet configuration. If your application does not have these permissions it will not have access to any Ethernet service feature.

Summary

Constants
String TAG
Public Constructors
EthernetManager(Context context)
Class constructor.
Public Methods
void configureInterface(EthernetConfiguration info)
Configures the interface with the given configuration.
EthernetConnectionMode getConnectionMode()
Returns the configured connection mode of the interface.
InetAddress getDns1()
Returns the configured DNS1 address of the interface.
InetAddress getDns2()
Returns the configured DNS2 address of the interface.
InetAddress getGateway()
Returns the configured gateway address of the interface.
String getInterfaceName()
Returns the Ethernet interface name.
InetAddress getIp()
Returns the configured IP address of the interface.
String getMacAddress()
Reads the MAC address of the Ethernet interface.
InetAddress getNetmask()
Returns the configured netmask of the interface.
boolean isConnected()
Returns whether the Ethernet interface is connected or not.
boolean isEnabled()
Returns whether the interface is enabled or not.
void resetInterface()
Resets the Ethernet interface.
void setEnabled(boolean enable)
Enables or disables the interface.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final String TAG

Constant Value: "EthernetManager"

Public Constructors

public EthernetManager (Context context)

Class constructor. Creates a new instance of the EthernetManager.

Parameters
context Context: Application context.
Throws
NullPointerException If context == null.

Public Methods

public void configureInterface (EthernetConfiguration info)

Configures the interface with the given configuration.

This method resets the interface to apply the new configuration.

Parameters
info EthernetConfiguration: Interface configuration.
Throws
IllegalArgumentException If the interface name is invalid or the connection mode is unknown.
NullPointerException If info == null or in a static configuration the IP, netmask, gateway or DNS 1 addresses are null.
UnknownHostException If the given IP addresses cannot be resolved.

public EthernetConnectionMode getConnectionMode ()

Returns the configured connection mode of the interface.

Returns
EthernetConnectionMode The configured connection mode.

public InetAddress getDns1 ()

Returns the configured DNS1 address of the interface.

Returns
InetAddress The configured DNS1 address or null if could not be read.

public InetAddress getDns2 ()

Returns the configured DNS2 address of the interface.

Returns
InetAddress The configured DNS2 address or null if could not be read.

public InetAddress getGateway ()

Returns the configured gateway address of the interface.

Returns
InetAddress The configured gateway address or null if could not be read.

public String getInterfaceName ()

Returns the Ethernet interface name.

Returns
String The Ethernet interface name, null if there is not any interface.

public InetAddress getIp ()

Returns the configured IP address of the interface.

Returns
InetAddress The configured IP address or null if could not be read.

public String getMacAddress ()

Reads the MAC address of the Ethernet interface.

Returns
String The MAC address or null if could not be read.
Throws
NullPointerException If the configured interface is null.

public InetAddress getNetmask ()

Returns the configured netmask of the interface.

Returns
InetAddress The configured netmask or null if could not be read.

public boolean isConnected ()

Returns whether the Ethernet interface is connected or not.

Returns
boolean true if connected, false otherwise.

public boolean isEnabled ()

Returns whether the interface is enabled or not.

Returns
boolean true if the interface is enabled, false otherwise.

public void resetInterface ()

Resets the Ethernet interface.

public void setEnabled (boolean enable)

Enables or disables the interface.

Parameters
enable boolean: true to enable, false to disable.

See also: