# Package amlib.ccid

It provides classes to communicating with Alcorlink smart card reader on Android 3.1 or above.

See: Description

- Class Summary
  Class | Description
  --- | ---
  Reader |
  Reader4428 |
  Reader4442 |
  Reader6636 |
  ReaderAT24C |
  ReaderAT45D041 |
  ReaderAT88SC102 |
  ReaderAT88SC153 |
  ReaderAT88SC1608 |
  SCError |

- Exception Summary
  Exception | Description
  --- | ---
  ReaderException |

## Package amlib.ccid Description

It provides classes to communicating with Alcorlink smart card reader on Android 3.1 or above.
To create Reader object
Object HardwareInterface is needed when constructing a class Reader,
you should create and initial 'HardwareInterface myDev' before create Reader

      Reader myReader

      try {
          mReader = new Reader(myDev);
      }
      catch(ReaderException e){
           e.printStackTrace();
      }

To connect to Reader object

     The connection with SmartCard Reader is handled by package amlib.hw.
     You can directly send commands once Reader is constructed correctly.

To power on/power off ICC

      int status;

      status = mReader.setPower(Reader.CCID_POWERON );

      status = mReader.setPower(Reader.CCID_POWEROFF );

Transmitting APDU

      byte pSendAPDU[] = new byte[] {(byte) 0xA0, (byte) 0xA4, 0x00, 0x00, 0x02, 0x3F, 0x00};
      byte pRxBuff[] = new byte [128];
      int pRxLen[] = new int[1];
      int status;

      status = mReader.transmit(pSendAPDU, pSendAPDU.legnth, pRxBuff, pRxLen);
       if (status != error.READER_SUCCESSFUL){
                //shows error
       }
      else{
            for (int i=0;i <pRxLen[0]; i++){
                          Log.d(TAG, "Received byte["+ i+ "]=0x"+ Integer.toHexString(pRxBuff[i]));
                }
       }

Send Escape

      byte pData[] = new byte[] {CMD_VENDOR_OP_CODE, VENDOR_CMD, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
      byte pRxBuff[] = new byte [128];
      int pRxLen[] = new int[1];
      int status;

       status = mReader.escape(pData, pData.legnth, pRxBuff, pRxLen);
       if (status != error.READER_SUCCESSFUL){
                    //shows error
        }
        else{
                for (int i=0;i <pRxLen[0]; i++){
                    Log.d(TAG, "Received byte["+ i+ "]=0x"+ Integer.toHexString(pRxBuff[i]));
                 }
        }

To get ATR

      String atr;
      byte []atrArray = new byte[64];

          atr = mReader.getAtrString();
          atrArray = mReader.getAtr();

To get Card Status

     byte pCardStatus[] = new byte[1];
     int status;
      status = mReader.getCardStatus(pCardStatus);
      if (status == error.READER_SUCCESSFUL){
           //shows card status
      }

To get current protcol

        byte []proto = new byte[1];

      status = mReader.getProtocol(proto);

      if (status == error.READER_SUCCESSFUL && proto[0] == Reader.CCID_PROTOCOL_T0){
            //do something
      }

To get SN in EEPROM

        byte pLen[] = new byte[1];
        byte []pSN;
        pLen[0] = 32;
        pSN = new byte[pLen[0]];

      status = mReader.getSN(pSN, pLen);

      if (status == error.READER_SUCCESSFUL){
            //shows the SN
      }

To close Reader

            if (myDev.Close()){
                 //shows error
            }