com.eloview.homesdk.networkManager

## Class Network

- java.lang.Object
- - com.eloview.homesdk.consts.Consts
  - - com.eloview.homesdk.accountManager.AccountManager
    - - com.eloview.homesdk.networkManager.Network

- All Implemented Interfaces:
    java.lang.Cloneable

      public class Network
      extends AccountManager

  Network class provides the following functions.

  - A method called `setNetwork` which is used to connect to a user-defined network configuration
  - A method called `getNetwork` which returns the information about the current network the device is connected to, such as the network name, network type, IpAddress and MacAddress
  - A method called `getWiFiMac` which returns the WiFi Mac Address
  - A method called `getEthernetMac` which returns the Ethernet Mac Address
  - A method called `installCertificate` This method is used to send the EST Certificate configuration request. It will generate EST user and ca_certificate.
  - A method called `removeCertificate` This method is used to send the EST Certificate configuration request. It will remove EST user and ca_certificate.
  - A method called `installLocalCertificate` This method is used to install the local wifi certificates even when device is offline.
  - A method to power on/off the ethernet port. `setEthState`
  - A method to obtain the DHCP server host name `getDHCPServerHostName`
  - A method to unregister the broadcast receiver registered while using any of the Network APIs `unregisterNetworkAPIListener`
  - A method to unregister the broadcast receiver when the `removeCertificate` API is used in your App `unregisterRemoveCertificateAPIListener`
  - A method to unregister the broadcast receiver registered when the `getDHCPServerHostName(Context, String, Handler)` is used in your application `unregisterDHCPRecordsAPIListener`
  - A method to unregister the broadcast receiver registered when the `installCertificate(Context, String, ESTConfig, Handler)` API is used in your application `unregisterCertificatesListener`

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `DHCP_SERVER_NAME` Response code for DHCP 230 Records
    `static int` | `GET_ETH_MAC_ADDRESS_CODE` Response code which indicates that ethernet mac address is available.
    `static int` | `GET_NETWORK_RESPONSE_CODE` Response code which indicates that info about current connected network is available.
    `static int` | `GET_WIFI_MAC_ADDRESS_CODE` Response code which indicates that wifi mac address is available
    `static int` | `INSTALL_CERTIFICATE_CODE` Response code of Certificate Installation process.
    `static Network` | `instance`
    `static int` | `REMOVE_EST_CERTIFICATE_CODE` Response code of ESTServer Certificate Remove.
    `static int` | `SET_EST_CERTIFICATE_CODE` Response code of ESTServer Certificate Install.
    `static int` | `SET_ETH_STATE_RESULT_CODE` Response code for ethernet configuration
    `static int` | `SET_NETWORK_RESPONSE_CODE` Response code which indicates whether network configuration was applied successfully or not

    - ### Fields inherited from class com.eloview.homesdk.accountManager.AccountManager

      `ACCESS_TOKEN_INVALID, ACCESS_TOKEN_VALID, API_ACCESS_TOKEN_INVALID, API_ACCESS_TOKEN_VALID, IS_USER_LOGIN_OAUTH, isPolaris, KEY_SERVER_ELO_POLARIS_DEV, KEY_SERVER_PRODUCTION_POLARIS, KEY_SERVER_QA_POLARIS, KEY_SERVER_STAGING_POLARIS, OAUTH_TOKEN_INVALID, OAUTH_TOKEN_VALID, REQUEST_AUTH_LOGIN, REQUEST_AUTH_LOGOUT, SETUP_OAUTH_ERROR, SETUP_OAUTH_SUCCESS, TOKEN_VERIFY_FAIL, TOKEN_VERIFY_SUCCESS`

    - ### Fields inherited from class com.eloview.homesdk.consts.Consts

      `ELO_FOLDER, ELO_NETWORK_CONF_CSV_FILE, GENERIC_ERROR, isFROM, OAUTH_PATH_TOKEN, OAUTH_PATH_VERIFY, REQUEST_TOKEN, STR_CUSTOM_ANIM_IMAGE_FILE, STR_CUSTOM_ANIM_VIDEO_FILE, STR_CUSTOM_BRAND_LOGO_FILE, STR_CUSTOM_BRAND_NAME_FILE, STR_CUSTOM_BRAND_POWERED_BY_LOGO_FILE, STR_CUSTOM_LOCALE_NAME_FILE, STR_CUSTOM_WALLPAPER, STR_ELO_PATH_FOR_CUSTOM_ANIMATION, STR_SDCARD_ELO_DIR_PATH, VERIFY_TOKEN`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Network()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `getDHCPServerHostName(android.content.Context context, java.lang.String accessToken, android.os.Handler handler)` This method is used to obtain the DHCP server host name
    `void` | `getEthernetMac(android.content.Context context, java.lang.String accessToken, android.os.Handler handler)` This method is used to obtain Ethernet MacAddress
    `void` | `getNetwork(android.content.Context context, java.lang.String accessToken, android.os.Handler handler)` This method is used to provide information about the network the device is currently connected to.
    `void` | `getWiFiMac(android.content.Context context, java.lang.String accessToken, android.os.Handler handler)` /** This method is used to obtain Wifi MacAddress
    `void` | `installCertificate(android.content.Context context, java.lang.String accessToken, ESTConfig estConfig, android.os.Handler handler)` This method is used to send the EST Certificate configuration request.
    `void` | `installLocalCertificate(android.content.Context context, java.lang.String accessToken, CertificateConfig certificateConfig, android.os.Handler handler)` This method is used to install the local wifi certificates even when device is offline.
    `void` | `removeCertificate(android.content.Context context, java.lang.String accessToken, java.lang.String alias, android.os.Handler handler)` This method is used to send the EST Certificate configuration request.
    `void` | `setEthState(android.content.Context context, java.lang.String accessToken, boolean state, android.os.Handler handler)` This method is used to power on/off the ethernet port.
    `java.lang.String` | `setNetmask(NetworkConfig networkConfig, java.lang.String netmask)`
    `void` | `setNetwork(android.content.Context context, java.lang.String accessToken, NetworkConfig networkConfig, android.os.Handler handler)` This method is used to set a network configuration using the parameters described in NetworkConfig class and connect to the network with the given configuration.
    `void` | `setNetwork(android.content.Context context, java.lang.String accessToken, NetworkConfig networkConfig, android.os.Handler handler, java.lang.Boolean disableEthernet)` This method is used to set a network configuration using the parameters described in NetworkConfig class and connect to the network with the given configuration.
    `void` | `unregisterCertificatesListener(android.content.Context context)` This method is used to unregister the broadcast receiver registered when the `installCertificate(Context, String, ESTConfig, Handler)` API. is used in your application.
    `void` | `unregisterDHCPRecordsAPIListener(android.content.Context context)` This method is used to unregister the broadcast receiver registered when the `getDHCPServerHostName(Context, String, Handler)` API. is used in your application.
    `void` | `unregisterNetworkAPIListener(android.content.Context context)` This method is used to unregister the broadcast receiver registered while using any of the Network APIs. Please make sure to call this in the "onPause" and "onDestroy" methods in your activity Lifecycle if you made use of any of the Network APIs.
    `void` | `unregisterRemoveCertificateAPIListener(android.content.Context context)` This method is used to unregister the broadcast receiver registered when the `removeCertificate(Context, String, String, Handler)` API is used in your App Please make sure to call this in the "onPause" and "onDestroy" methods in your activity Lifecycle if you made use of `removeCertificate(Context, String, String, Handler)` API.

    - ### Methods inherited from class com.eloview.homesdk.accountManager.AccountManager

      `configureOAuthHostedUI, destroyOAuth, getBaseUri, getClientId, getEloAccessToken, getEloOAuthToken, getEnvironment, getProperty, isPolaris, isPolarisLocked, logoutOAuth, onOAuthActivityResult, selectEnvironment, setDefaultEnvironment, setProperty, stopOAuth, unregisterAccountManagerListener, verifyEloToken`

    - ### Methods inherited from class com.eloview.homesdk.consts.Consts

      `clone, getEloIntentWithFlag, getMigrate, isDevice7Inch, isDeviceM100`

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### SET_NETWORK_RESPONSE_CODE

          public static final int SET_NETWORK_RESPONSE_CODE

      Response code which indicates whether network configuration was applied successfully or not
      See Also:
        Constant Field Values

    - #### GET_NETWORK_RESPONSE_CODE

          public static final int GET_NETWORK_RESPONSE_CODE

      Response code which indicates that info about current connected network is available.
      See Also:
        Constant Field Values

    - #### GET_WIFI_MAC_ADDRESS_CODE

          public static final int GET_WIFI_MAC_ADDRESS_CODE

      Response code which indicates that wifi mac address is available
      See Also:
        Constant Field Values

    - #### GET_ETH_MAC_ADDRESS_CODE

          public static final int GET_ETH_MAC_ADDRESS_CODE

      Response code which indicates that ethernet mac address is available.
      See Also:
        Constant Field Values

    - #### SET_EST_CERTIFICATE_CODE

          public static final int SET_EST_CERTIFICATE_CODE

      Response code of ESTServer Certificate Install.
      See Also:
        Constant Field Values

    - #### REMOVE_EST_CERTIFICATE_CODE

          public static final int REMOVE_EST_CERTIFICATE_CODE

      Response code of ESTServer Certificate Remove.
      See Also:
        Constant Field Values

    - #### INSTALL_CERTIFICATE_CODE

          public static final int INSTALL_CERTIFICATE_CODE

      Response code of Certificate Installation process.
      See Also:
        Constant Field Values

    - #### DHCP_SERVER_NAME

          public static final int DHCP_SERVER_NAME

      Response code for DHCP 230 Records
      See Also:
        Constant Field Values

    - #### SET_ETH_STATE_RESULT_CODE

          public static final int SET_ETH_STATE_RESULT_CODE

      Response code for ethernet configuration
      See Also:
        Constant Field Values

    - #### instance

          public static Network instance

  - ### Constructor Detail

    - #### Network

          public Network()

  - ### Method Detail

    - #### setNetwork

          public void setNetwork(android.content.Context context,
                                 java.lang.String accessToken,
                                 NetworkConfig networkConfig,
                                 android.os.Handler handler)

      This method is used to set a network configuration using the parameters described in NetworkConfig class and connect to the network with the given configuration.
      Parameters:
        `context` - Context
        `accessToken` - An authentication token received from the Elo servers.
        `networkConfig` - NetworkConfig to set up the user data
        `handler` - A handler to receive one or more of the following callback messages:

        `AccountManager.TOKEN_VERIFY_FAIL`
        `Consts.GENERIC_ERROR`
        `SET_NETWORK_RESPONSE_CODE`

    - #### setNetwork

          public void setNetwork(android.content.Context context,
                                 java.lang.String accessToken,
                                 NetworkConfig networkConfig,
                                 android.os.Handler handler,
                                 java.lang.Boolean disableEthernet)

      This method is used to set a network configuration using the parameters described in NetworkConfig class and connect to the network with the given configuration.
      Parameters:
        `context` - Context
        `accessToken` - An authentication token received from the Elo servers.
        `networkConfig` - NetworkConfig to set up the user data
        `handler` - A handler to receive one or more of the following callback messages:

        `AccountManager.TOKEN_VERIFY_FAIL`
        `Consts.GENERIC_ERROR`
        `SET_NETWORK_RESPONSE_CODE`

        `disableEthernet` - Boolean : to decide if we want to disable ethernet or not

    - #### getNetwork

          public void getNetwork(android.content.Context context,
                                 java.lang.String accessToken,
                                 android.os.Handler handler)

      This method is used to provide information about the network the device is currently connected to. This method does not necessarily return all the parameters defined
      in the NetworkConfig class. The parameters returned for each interface are mentioned below.
      Parameters:
        `context` - Context
        `accessToken` - An authentication token received from the Elo servers.
        `handler` - A handler to receive one or more of the following callback messages:

        `AccountManager.TOKEN_VERIFY_FAIL`
        `Consts.GENERIC_ERROR`
        `GET_NETWORK_RESPONSE_CODE`

        If the device is connected to Ethernet: The following parameters will be returned:
        "active", "networkType", "macAddress", "ipAddress", "networkPrefixLength", “interface”, “proxyPort”, “ipAssignmentState”,
        "proxyHost", “gateway”, “networkPrefix”, “dnsServers”, “proxyExclusion”

        If the device is connected to Wifi: The following parameters will be returned:
        "active", "networkType", "ssid_name", "macAddress", "ipAddress", "networkPrefixLength", “interface”, “proxyPort”, “ipAssignmentState”,
        "speed", "rssi", "proxyHost", “gateway”, “networkPrefix”, “dnsServers”, “proxyExclusion”

    - #### setEthState

          public void setEthState(android.content.Context context,
                                  java.lang.String accessToken,
                                  boolean state,
                                  android.os.Handler handler)

      This method is used to power on/off the ethernet port.
      Parameters:
        `context` - Context
        `accessToken` - An authentication token received from the Elo servers.
        `state` - ethernet power state (on/off)
        `handler` - A handler to receive one or more of the following callback messages:

        `AccountManager.TOKEN_VERIFY_FAIL`
        `Consts.GENERIC_ERROR`
        `SET_NETWORK_RESPONSE_CODE`

    - #### unregisterNetworkAPIListener

          public void unregisterNetworkAPIListener(android.content.Context context)

      This method is used to unregister the broadcast receiver registered while using any of the Network APIs.
      Please make sure to call this in the "onPause" and "onDestroy" methods in your activity Lifecycle if you made use of any of the Network APIs. This ensures the receiver is not leaked.
      Parameters:
        `context` - Context in which the Network APIs were used

    - #### unregisterRemoveCertificateAPIListener

          public void unregisterRemoveCertificateAPIListener(android.content.Context context)

      This method is used to unregister the broadcast receiver registered when the `removeCertificate(Context, String, String, Handler)` API
      is used in your App Please make sure to call this in the "onPause" and "onDestroy" methods in your activity Lifecycle if you made use of `removeCertificate(Context, String, String, Handler)` API. This ensures the receiver is not leaked.
      Parameters:
        `context` - Context in which the Network APIs were used

    - #### unregisterDHCPRecordsAPIListener

          public void unregisterDHCPRecordsAPIListener(android.content.Context context)

      This method is used to unregister the broadcast receiver registered when the `getDHCPServerHostName(Context, String, Handler)` API.
      is used in your application. Please make sure to call this in the "onPause" and "onDestroy" methods in your activity Lifecycle if you made use of `getDHCPServerHostName(Context, String, Handler)` API. This ensures the receiver is not leaked.
      Parameters:
        `context` - Context in which the Network APIs were used

    - #### unregisterCertificatesListener

          public void unregisterCertificatesListener(android.content.Context context)

      This method is used to unregister the broadcast receiver registered when the `installCertificate(Context, String, ESTConfig, Handler)` API.
      is used in your application. Please make sure to call this in the "onPause" and "onDestroy" methods in your activity Lifecycle if you made use of `installCertificate(Context, String, ESTConfig, Handler)` API. This ensures the receiver is not leaked.
      Parameters:
        `context` - Context in which the Network APIs were used

    - #### getWiFiMac

          public void getWiFiMac(android.content.Context context,
                                 java.lang.String accessToken,
                                 android.os.Handler handler)

      /** This method is used to obtain Wifi MacAddress
      Parameters:
        `context` - Context
        `accessToken` - An authentication token received from the Elo servers.
        `handler` - A handler to receive one or more of the following callback messages:

        `AccountManager.TOKEN_VERIFY_FAIL`
        `Consts.GENERIC_ERROR`
        `GET_WIFI_MAC_ADDRESS_CODE`

    - #### getEthernetMac

          public void getEthernetMac(android.content.Context context,
                                     java.lang.String accessToken,
                                     android.os.Handler handler)

      This method is used to obtain Ethernet MacAddress
      Parameters:
        `context` - Context
        `accessToken` - An authentication token received from the Elo servers.
        `handler` - A handler to receive one or more of the following callback messages:

        `AccountManager.TOKEN_VERIFY_FAIL`
        `Consts.GENERIC_ERROR`
        `GET_ETH_MAC_ADDRESS_CODE`

    - #### getDHCPServerHostName

          public void getDHCPServerHostName(android.content.Context context,
                                            java.lang.String accessToken,
                                            android.os.Handler handler)

      This method is used to obtain the DHCP server host name
      Parameters:
        `context` - Context
        `accessToken` - An authentication token received from the Elo servers.
        `handler` - A handler to receive one or more of the following callback messages:

        `AccountManager.TOKEN_VERIFY_FAIL`
        `Consts.GENERIC_ERROR`

    - #### setNetmask

          public java.lang.String setNetmask(NetworkConfig networkConfig,
                                             java.lang.String netmask)

    - #### installCertificate

          public void installCertificate(android.content.Context context,
                                         java.lang.String accessToken,
                                         ESTConfig estConfig,
                                         android.os.Handler handler)

      This method is used to send the EST Certificate configuration request. It will generate EST user and ca_certificate.
      Parameters:
        `context` - Context it must be Activity or Application context
        `accessToken` - An Offline authentication token.
        `estConfig` - ESTConfig having certificate details.
        `handler` - A handler to receive one or more of the following callback messages:

        `AccountManager.TOKEN_VERIFY_FAIL`
        `Consts.GENERIC_ERROR`
        `SET_EST_CERTIFICATE_CODE`

    - #### removeCertificate

          public void removeCertificate(android.content.Context context,
                                        java.lang.String accessToken,
                                        java.lang.String alias,
                                        android.os.Handler handler)

      This method is used to send the EST Certificate configuration request. It will remove EST user and ca_certificate.
      Parameters:
        `context` - Context it must be Activity or Application context
        `accessToken` - An Offline authentication token.
        `alias` - String having certificate alias details.
        `handler` - A handler to receive one or more of the following callback messages:

        `AccountManager.TOKEN_VERIFY_FAIL`
        `Consts.GENERIC_ERROR`
        `REMOVE_EST_CERTIFICATE_CODE`

    - #### installLocalCertificate

          public void installLocalCertificate(android.content.Context context,
                                              java.lang.String accessToken,
                                              CertificateConfig certificateConfig,
                                              android.os.Handler handler)

      This method is used to install the local wifi certificates even when device is offline. Provide CA or USER certificate file path, name and CERTIFICATE_TYPE. User certificates are generally in ".p12" format and require a valid password to be installed.
      Parameters:
        `context` - Context it must be Activity or Application context
        `accessToken` - An Offline authentication token.
        `certificateConfig` - `CertificateConfig` Configuration of the local certificate files having local certificate file path, name, type. user_certificate_password if CERTIFICATE_TYPE is USER_CERTIFICATE.
        `handler` - A handler to receive one or more of the following callback messages:

        `AccountManager.TOKEN_VERIFY_FAIL`
        `Consts.GENERIC_ERROR`
        `INSTALL_CERTIFICATE_CODE`