Implement additional Mifare Ultralight convenience methods.
Change-Id: I8d9dfadb5911b2d11d1ba6dcf1381decbb8386ef
This commit is contained in:
committed by
Jeff Hamilton
parent
0d27f999f4
commit
c58c3f1ae2
@ -72,6 +72,37 @@ public final class MifareUltralight extends BasicTagTechnology {
|
|||||||
return transceive(blockread_cmd);
|
return transceive(blockread_cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws IOException
|
||||||
|
*/
|
||||||
|
public byte[] readOTP() throws IOException {
|
||||||
|
checkConnected();
|
||||||
|
|
||||||
|
return readBlock(3); // OTP is at page 3
|
||||||
|
}
|
||||||
|
|
||||||
|
public void writePage(int block, byte[] data) throws IOException {
|
||||||
|
checkConnected();
|
||||||
|
|
||||||
|
byte[] pagewrite_cmd = new byte[data.length + 2];
|
||||||
|
pagewrite_cmd[0] = (byte) 0xA2;
|
||||||
|
pagewrite_cmd[1] = (byte) block;
|
||||||
|
System.arraycopy(data, 0, pagewrite_cmd, 2, data.length);
|
||||||
|
|
||||||
|
transceive(pagewrite_cmd);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void writeBlock(int block, byte[] data) throws IOException {
|
||||||
|
checkConnected();
|
||||||
|
|
||||||
|
byte[] blockwrite_cmd = new byte[data.length + 2];
|
||||||
|
blockwrite_cmd[0] = (byte) 0xA0;
|
||||||
|
blockwrite_cmd[1] = (byte) block;
|
||||||
|
System.arraycopy(data, 0, blockwrite_cmd, 2, data.length);
|
||||||
|
|
||||||
|
transceive(blockwrite_cmd);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send data to a tag and receive the response.
|
* Send data to a tag and receive the response.
|
||||||
* <p>
|
* <p>
|
||||||
@ -99,12 +130,4 @@ public final class MifareUltralight extends BasicTagTechnology {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @throws IOException
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
public byte[] readOTP();
|
|
||||||
public void writePage(int block, byte[] data);
|
|
||||||
public void writeBlock(int block, byte[] data);
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user