amlib.hw
Class HardwareInterface

java.lang.Object
  extended by amlib.hw.HardwareInterface

public class HardwareInterface
extends java.lang.Object


Field Summary
static int DBG_BUFFER
           
static int DBG_DBG
           
static int DBG_ERROR
           
static int DBG_INFO
           
static int DBG_NONE
           
static int DBG_WARN
           
 
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
 void setLog(android.content.Context ctx, boolean enable, int level)
          To setup configurations of Hardware debug message
 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
 

Field Detail

DBG_NONE

public static final int DBG_NONE
See Also:
Constant Field Values

DBG_ERROR

public static final int DBG_ERROR
See Also:
Constant Field Values

DBG_WARN

public static final int DBG_WARN
See Also:
Constant Field Values

DBG_INFO

public static final int DBG_INFO
See Also:
Constant Field Values

DBG_DBG

public static final int DBG_DBG
See Also:
Constant Field Values

DBG_BUFFER

public static final int DBG_BUFFER
See Also:
Constant Field Values
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.

setLog

public void setLog(android.content.Context ctx,
                   boolean enable,
                   int level)
To setup configurations of Hardware debug message

Parameters:
ctx - application context. It is required when manipulating over Class File.
enable - set to 'true' to save log into external storage.
level - debug level