com.eloview.homesdk.peripheralManager

## Class Peripheral

- java.lang.Object
- - com.eloview.homesdk.consts.Consts
  - - com.eloview.homesdk.accountManager.AccountManager
    - - com.eloview.homesdk.peripheralManager.Peripheral

- All Implemented Interfaces:
    java.lang.Cloneable

      public class Peripheral
      extends AccountManager

  PeripheralManager class provides below operations.
  - Get an auth token using `getEloAccessToken`.
  - Enable/Disable device ports using JSON string. Currently only USB ports can be turned ON/OFF using `setUSBPorts(Context, String, String, Handler)`
  - Get device port status in JSON String format. Currently only USB ports status can be read. using `getUSBPorts(Context, String, Handler)`
  - Get maximum number of USB ports on the device based on the device model using `getMaxUSBPort()`
  - Start USB monitoring which will reset USB Debug mode to host mode from device mode and enable the USB ports.`startUsbMonitoring(Context, String, Handler)`
  - Stop USB monitoring. `stopUsbMonitoring(Context, String, Handler)`

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `GET_HUB_TYPE_RESULT_CODE`
    `static int` | `GET_USB_PORTS_RESULT_CODE` Response code to get the status of the USB ports
    `static Peripheral` | `instance`
    `static int` | `MAX_USB_PORTS`
    `static int` | `SET_USB_PORTS_RESULT_CODE` Response code to indicate whether USB ports were set successfully or not
    `static int` | `START_USB_MONITOR_RESULT_CODE` Response code provide status of the start usb monitor service.
    `static int` | `STOP_USB_MONITOR_RESULT_CODE` Response code provide status of the stop usb monitor service.

    - ### 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

      `ACTION_SET_EST_REQUEST, ELO_FOLDER, ELO_NETWORK_CONF_CSV_FILE, ELO_WIFI_CONFIG_FOLDER, 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
    `Peripheral()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `getMaxExtUSBPort(android.content.Context ctx)`
    `int` | `getMaxUSBPort()` This method is used to get the maximum number of USB ports on the device.
    `void` | `getUSBPorts(android.content.Context context, java.lang.String accessToken, android.os.Handler handler)` This method is used to get status of the USB ports on the device.
    `void` | `setUSBPorts(android.content.Context context, java.lang.String accessToken, java.lang.String json, android.os.Handler handler)` This method is used to enable/disable the USB ports on the device.
    `void` | `startUsbMonitoring(android.content.Context context, java.lang.String accessToken, android.os.Handler handler)` This method is used to start USB Monitoring.
    `void` | `stopUsbMonitoring(android.content.Context context, java.lang.String accessToken, android.os.Handler handler)` This method is used to stop USB Monitoring.
    `void` | `unregisterPeripheralAPIListener(android.content.Context context)` This method is used to unregister the broadcast receiver registered while using any of the Peripheral 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 Peripheral APIs.

    - ### 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_USB_PORTS_RESULT_CODE

          public static final int SET_USB_PORTS_RESULT_CODE

      Response code to indicate whether USB ports were set successfully or not
      See Also:
        Constant Field Values

    - #### GET_USB_PORTS_RESULT_CODE

          public static final int GET_USB_PORTS_RESULT_CODE

      Response code to get the status of the USB ports
      See Also:
        Constant Field Values

    - #### START_USB_MONITOR_RESULT_CODE

          public static final int START_USB_MONITOR_RESULT_CODE

      Response code provide status of the start usb monitor service.
      See Also:
        Constant Field Values

    - #### GET_HUB_TYPE_RESULT_CODE

          public static final int GET_HUB_TYPE_RESULT_CODE

      See Also:
        Constant Field Values

    - #### STOP_USB_MONITOR_RESULT_CODE

          public static final int STOP_USB_MONITOR_RESULT_CODE

      Response code provide status of the stop usb monitor service.
      See Also:
        Constant Field Values

    - #### MAX_USB_PORTS

          public static final int MAX_USB_PORTS

      See Also:
        Constant Field Values

    - #### instance

          public static Peripheral instance

  - ### Constructor Detail

    - #### Peripheral

          public Peripheral()

  - ### Method Detail

    - #### setUSBPorts

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

      This method is used to enable/disable the USB ports on the device.
      Parameters:
        `context` - A context object of the calling Class (Activity/Service).
        `accessToken` - An authentication token received from the Elo servers.
        `json` - A json string containing configuration of USB ports to be set
        `handler` - A handler to receive one of the following callback messages:

        `AccountManager.TOKEN_VERIFY_FAIL`
        `Consts.GENERIC_ERROR`
        `SET_USB_PORTS_RESULT_CODE`

    - #### getUSBPorts

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

      This method is used to get status of the USB ports on the device.
      Parameters:
        `context` - Context
        `accessToken` - An authentication token received from the Elo servers.
        `handler` - A handler to receive one of the following callback messages:

        `AccountManager.TOKEN_VERIFY_FAIL`
        `Consts.GENERIC_ERROR`
        `GET_USB_PORTS_RESULT_CODE`

    - #### getMaxUSBPort

          public int getMaxUSBPort()

      This method is used to get the maximum number of USB ports on the device.

    - #### getMaxExtUSBPort

          public int getMaxExtUSBPort(android.content.Context ctx)

    - #### startUsbMonitoring

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

      This method is used to start USB Monitoring. It will reset USB Debug mode to host mode from device mode. It will enable the USB ports.
      Parameters:
        `context` - A context object of the calling Class (Activity/Service).
        `accessToken` - An authentication offline token
        `handler` - A handler to receive one of the following callback messages:

        `START_USB_MONITOR_RESULT_CODE`
        `AccountManager.TOKEN_VERIFY_FAIL`
        `Consts.GENERIC_ERROR`

    - #### stopUsbMonitoring

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

      This method is used to stop USB Monitoring.
      Parameters:
        `context` - A context object of the calling Class (Activity/Service).
        `accessToken` - An authentication offline token
        `handler` - A handler to receive one of the following callback messages:

        `STOP_USB_MONITOR_RESULT_CODE`
        `AccountManager.TOKEN_VERIFY_FAIL`
        `Consts.GENERIC_ERROR`

    - #### unregisterPeripheralAPIListener

          public void unregisterPeripheralAPIListener(android.content.Context context)

      This method is used to unregister the broadcast receiver registered while using any of the Peripheral 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 Peripheral APIs. This ensures the receiver is not leaked.
      Parameters:
        `context` - Context in which the system APIs were used