public class MifareClassicTag extends TagManager
MifareClassic tags and obtain the tag information.
This class inherits from TagManager and provides interfaces to create
MifareClassic tags and obtain the block and sector information of the
MifareClassic tags.
| 限定符和类型 | 字段 | 说明 |
|---|---|---|
static int |
BLOCK_BYTES |
Indicates the size of each block of the
MifareClassic tag in bytes. |
static int |
MIFARE_CLASSIC |
Indicates the Mifare classic tag.
|
static int |
MIFARE_PLUS |
Indicates the Mifare Plus tag.
|
static int |
MIFARE_PRO |
Indicates the Mifare Pro tag.
|
static int |
MIFARE_UNKNOWN |
Indicates the Mifare tag of an unknown type.
|
static int |
TAG_ROM_1K |
Indicates a
MifareClassic tag with 16 sectors, each having 4 blocks. |
static int |
TAG_ROM_2K |
Indicates a
MifareClassic tag with 32 sectors, each having 4 blocks. |
static int |
TAG_ROM_4K |
Indicates a
MifareClassic tag with 40 sectors, with the first 32 sectors each having
4 blocks and the remaining 8 sectors each having 16 blocks. |
static int |
TAG_ROM_MINI |
Indicates a
MifareClassic tag with 5 sectors, each having 4 blocks. |
static byte |
USE_KEY_A |
Indicates the Mifare authentication key of type A.
|
static byte |
USE_KEY_B |
Indicates the Mifare authentication key of type B.
|
ISO_DEP, MIFARE_ULTRALIGHT, NDEF, NFC_A, NFC_B, NFC_F, NFC_V| 限定符和类型 | 方法 | 说明 |
|---|---|---|
boolean |
authenSectorUseKey(int sectorId,
byte[] key,
byte keyType) |
Authenticates a specified sector of this
MifareClassic tag with a key. |
void |
decBlock(int blockId,
int value) |
Deducts a value from the content of a specified block of this
MifareClassic tag. |
int |
getBlocksNum() |
Obtains the number of blocks of this
MifareClassic tag. |
int |
getBlocksNumForSector(int sectorId) |
Obtains the number of blocks in a specified sector of this
MifareClassic tag. |
int |
getFirstBlockId(int sectorId) |
Obtains the ID of the first block of a
MifareClassic tag in a specified sector. |
static MifareClassicTag |
getInstance(TagInfo tagInfo) |
Obtains a
MifareClassic tag based on the given tag information. |
int |
getMifareType() |
Obtains the Mifare type of this
MifareClassic tag. |
int |
getSectorId(int blockId) |
Obtains the sector ID of a Mifare Classic tag based on the block ID of the Mifare tag.
|
int |
getSectorsNum() |
Obtains the number of sectors of this
MifareClassic tag base on the size of tag. |
int |
getTagSize() |
Obtains the size of this
MifareClassic tag. |
void |
incBlock(int blockId,
int value) |
Adds a value to the content of a specified block of this
MifareClassic tag. |
byte[] |
readBlock(int blockId) |
Reads content of a specified block of this
MifareClassic tag based on the block id. |
void |
restoreBlock(int blockId) |
Migrates the content of a specified block of this
MifareClassic tag to an internal buffer. |
void |
writeBlock(int blockId,
byte[] data) |
Writes data to a specified block of this
MifareClassic tag. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcheckConnected, connectTag, getMaxSendLength, getSendDataTimeout, getTagInfo, isTagConnected, reset, sendData, setSendDataTimeoutpublic static final int BLOCK_BYTES
MifareClassic tag in bytes.public static final int MIFARE_CLASSIC
public static final int MIFARE_PLUS
public static final int MIFARE_PRO
public static final int MIFARE_UNKNOWN
public static final int TAG_ROM_1K
MifareClassic tag with 16 sectors, each having 4 blocks.public static final int TAG_ROM_2K
MifareClassic tag with 32 sectors, each having 4 blocks.public static final int TAG_ROM_4K
MifareClassic tag with 40 sectors, with the first 32 sectors each having
4 blocks and the remaining 8 sectors each having 16 blocks.public static final int TAG_ROM_MINI
MifareClassic tag with 5 sectors, each having 4 blocks.public static final byte USE_KEY_A
public static final byte USE_KEY_B
public static MifareClassicTag getInstance(TagInfo tagInfo)
MifareClassic tag based on the given tag information.
During tag reading, if the tag supports the NFC-A technology, a MifareClassic
object will be created based on the given tag information.
tagInfo - Indicates the given tag information.MifareClassic tag.public int getMifareType()
MifareClassic tag.MifareClassic tag, such as
MIFARE_CLASSIC and MIFARE_PLUS.public int getTagSize()
MifareClassic tag.MifareClassic tag, such as TAG_ROM_1K
and TAG_ROM_2K.public int getSectorsNum()
MifareClassic tag base on the size of tag.MifareClassic tag. For example,
a MifareClassic tag that is TAG_ROM_1K in size has 16 sectors.public int getBlocksNum()
MifareClassic tag.MifareClassic tag.public int getBlocksNumForSector(int sectorId)
MifareClassic tag.sectorId - Indicates the ID of the specified sector.MifareClassic tag.public int getSectorId(int blockId)
blockId - Indicates the block ID.public int getFirstBlockId(int sectorId)
MifareClassic tag in a specified sector.sectorId - Indicates the ID of the specified sector.public boolean authenSectorUseKey(int sectorId,
byte[] key,
byte keyType)
MifareClassic tag with a key.public byte[] readBlock(int blockId)
MifareClassic tag based on the block id.blockId - Indicates the ID of the block to read.MifareClassic tag.public void writeBlock(int blockId,
byte[] data)
MifareClassic tag.blockId - Indicates the ID of the specified block to which the data will be written.data - Indicates the data to write to the specified block.public void incBlock(int blockId,
int value)
MifareClassic tag.blockId - Indicates the ID of block to increment.value - Indicates the non-negative value to increment.public void decBlock(int blockId,
int value)
MifareClassic tag.blockId - Indicates the ID of block to decrement.value - Indicates the non-negative value to decrement.public void restoreBlock(int blockId)
MifareClassic tag to an internal buffer.blockId - Indicates the ID of the specified value block.