don't disconnect from tag on reset or poweroff

fixes #21
This commit is contained in:
Frank Morgner
2014-09-25 09:09:48 +02:00
parent 6b5b1a0c29
commit 2721cd3afb

View File

@@ -49,23 +49,31 @@ public class NFCReader implements SCReader {
private static int TIMEOUT = 10000;
@Override
public void powerOn() throws IOException {
if (!card.isConnected()) {
card.connect();
card.setTimeout(TIMEOUT);
}
@Override
public void powerOff() throws IOException {
card.close();
}
private static byte[] SELECT_MF = {(byte) 0x00, (byte) 0xa4, (byte) 0x00, (byte) 0x0C};
@Override
public void reset() throws IOException {
private void selectMFifConnected() throws IOException {
if (card != null && card.isConnected()) {
byte[] response = card.transceive(SELECT_MF);
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));
}
}
}
@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 */
@Override