## amlib.hw
Class HardwareInterface

    java.lang.Object
      amlib.hw.HardwareInterface

    public class HardwareInterface

extends java.lang.Object

Constructor Summary
`HardwareInterface(HWType Type)` Constructor

Method Summary
`boolean` `Close()` To close hardware interface
`HWType` `getHWType()` To get the Hardware type
`int` `getMaxRxPkLength()` To get maximum data length for each Rx packet.
`int` `getMaxTxPkLength()` To get maximum data length for each Tx packet.
`java.lang.Object` `getmDevObj()` To get the casted hardware interface instance (UsbDevice for instance)which has been stored
`boolean` `getSerialNumber(byte[] pBuff, byte[] Len)`
`boolean` `Init(android.hardware.usb.UsbManager Manager, android.hardware.usb.UsbDevice Device)` To initial the hardware for communication
`boolean` `IsDevSet()`
`boolean` `Rx(byte[] pBuff, int[] Len)` To receive data from hardware interface
`boolean` `Tx(byte[] pBuff, int Len)` To transfer data to hardware interface
`boolean` `usbGetDesc(byte[] pDesc, int requestType, int request, int value, int index, byte[] pBuffer, int[] pLength)`

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### HardwareInterface

    public HardwareInterface(HWType Type)

  Constructor

  Parameters:
    `Type` - Type of hardware, eUSB is the only option currently.
  See Also:
    `HWType`

Method Detail

### Init

    public boolean Init(android.hardware.usb.UsbManager Manager,
                        android.hardware.usb.UsbDevice Device)
                 throws java.lang.IllegalArgumentException

  To initial the hardware for communication

  Parameters:
    `Manager` - UsbManager
    `Device` - UsbDevice which smart card belong to
  Returns:
    true for successful.
  Throws:
    `java.lang.IllegalArgumentException`
  See Also:
    `UsbManager`, `UsbDevice`

### Close

    public boolean Close()

  To close hardware interface

  Returns:
    true for successful.

### Tx

    public boolean Tx(byte[] pBuff,
                      int Len)
               throws java.io.IOException,
                      java.lang.IllegalArgumentException

  To transfer data to hardware interface

  Parameters:
    `pBuff` - data to transfer, the length of pBuffer is specified in parameter 'Len'
    `Len` - length of data to transfer
  Returns:
    true for successful.
  Throws:
    `java.io.IOException`
    `java.lang.IllegalArgumentException`

### Rx

    public boolean Rx(byte[] pBuff,
                      int[] Len)
               throws java.io.IOException,
                      java.lang.IllegalArgumentException

  To receive data from hardware interface

  Parameters:
    `pBuff` - data to receive. Be aware that providing a buffer with enough size.
    `Len` - length of received data
  Returns:
    true for successful.
  Throws:
    `java.io.IOException`
    `java.lang.IllegalArgumentException`

### getSerialNumber

    public boolean getSerialNumber(byte[] pBuff,
                                   byte[] Len)
                            throws java.io.IOException,
                                   java.lang.IllegalArgumentException

  Throws:
    `java.io.IOException`
    `java.lang.IllegalArgumentException`

### usbGetDesc

    public boolean usbGetDesc(byte[] pDesc,
                              int requestType,
                              int request,
                              int value,
                              int index,
                              byte[] pBuffer,
                              int[] pLength)

### getmDevObj

    public java.lang.Object getmDevObj()

  To get the casted hardware interface instance (UsbDevice for instance)which has been stored

  Returns:
    Object
  See Also:
    `Object`

### IsDevSet

    public boolean IsDevSet()

### getHWType

    public HWType getHWType()

  To get the Hardware type

  Returns:
    HWType
  See Also:
    `HWType`

### getMaxTxPkLength

    public int getMaxTxPkLength()

  To get maximum data length for each Tx packet.

  Returns:
    length of maximum data length for each Tx packet.

### getMaxRxPkLength

    public int getMaxRxPkLength()

  To get maximum data length for each Rx packet.

  Returns:
    length of maximum data length for each Rx packet.