diff options
| author | 2010-12-16 16:04:47 -0800 | |
|---|---|---|
| committer | 2010-12-16 16:04:47 -0800 | |
| commit | 12e5c1a21ee0dad786e8e5e7f7ca18e8ffdd53e5 (patch) | |
| tree | 29550c5e39d0027604dc1555bc066ff22e41a939 | |
| parent | bf76b52f05384feddb073ee6aa18091f701d069b (diff) | |
| parent | c58c3f1ae27c0c7f560bd381180397d7f6a2ebed (diff) | |
am c58c3f1a: Implement additional Mifare Ultralight convenience methods.
* commit 'c58c3f1ae27c0c7f560bd381180397d7f6a2ebed':
Implement additional Mifare Ultralight convenience methods.
| -rw-r--r-- | core/java/android/nfc/technology/MifareUltralight.java | 39 |
1 files changed, 31 insertions, 8 deletions
diff --git a/core/java/android/nfc/technology/MifareUltralight.java b/core/java/android/nfc/technology/MifareUltralight.java index 35f561b73f3d..7103b4d85e50 100644 --- a/core/java/android/nfc/technology/MifareUltralight.java +++ b/core/java/android/nfc/technology/MifareUltralight.java @@ -73,6 +73,37 @@ public final class MifareUltralight extends BasicTagTechnology { } /** + * @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. * <p> * This method will block until the response is received. It can be canceled @@ -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); - */ } |