Processes an incoming APDU.
byte buffer[] = apdu.getBuffer();
short bytesRead = apdu.setIncomingAndReceive();
short echoOffset = (short)0;
while ( bytesRead > 0 ) {
Util.arrayCopyNonAtomic(buffer, ISO7816.OFFSET_CDATA, echoBytes, echoOffset, bytesRead);
echoOffset += bytesRead;
bytesRead = apdu.receiveBytes(ISO7816.OFFSET_CDATA);
}
apdu.setOutgoing();
apdu.setOutgoingLength( (short) (echoOffset + 5) );
// echo header
apdu.sendBytes( (short)0, (short) 5);
// echo data
apdu.sendBytesLong( echoBytes, (short) 0, echoOffset );