@@ -49,23 +49,31 @@ public class NFCReader implements SCReader {
|
|||||||
private static int TIMEOUT = 10000;
|
private static int TIMEOUT = 10000;
|
||||||
@Override
|
@Override
|
||||||
public void powerOn() throws IOException {
|
public void powerOn() throws IOException {
|
||||||
|
if (!card.isConnected()) {
|
||||||
card.connect();
|
card.connect();
|
||||||
card.setTimeout(TIMEOUT);
|
card.setTimeout(TIMEOUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void powerOff() throws IOException {
|
|
||||||
card.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static byte[] SELECT_MF = {(byte) 0x00, (byte) 0xa4, (byte) 0x00, (byte) 0x0C};
|
private static byte[] SELECT_MF = {(byte) 0x00, (byte) 0xa4, (byte) 0x00, (byte) 0x0C};
|
||||||
@Override
|
private void selectMFifConnected() throws IOException {
|
||||||
public void reset() throws IOException {
|
if (card != null && card.isConnected()) {
|
||||||
byte[] response = card.transceive(SELECT_MF);
|
byte[] response = card.transceive(SELECT_MF);
|
||||||
if (response.length == 2 && response[0] == 0x90 && response[1] == 0x00) {
|
if (response.length == 2 && response[0] == 0x90 && response[1] == 0x00) {
|
||||||
Log.d(this.getClass().getName(), "Resetting the card by selecting the MF results in " + Hex.getHexString(response));
|
Log.d(this.getClass().getName(), "Resetting the card by selecting the MF results in " + Hex.getHexString(response));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void powerOff() throws IOException {
|
||||||
|
selectMFifConnected();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void reset() throws IOException {
|
||||||
|
selectMFifConnected();
|
||||||
|
}
|
||||||
|
|
||||||
/* calculation based on https://code.google.com/p/ifdnfc/source/browse/src/atr.c */
|
/* calculation based on https://code.google.com/p/ifdnfc/source/browse/src/atr.c */
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user