Android MIFARE NFCA Source parsing

Source: Internet
Author: User
Tags nfca

Android MIFARE NFCA Source parsing
Tagtechnology defines a common interface class for all tags
Basictagtechnology implements some of the interfaces of the Tagtechnology


Then there is the specific label protocol inheritance Basictagtechnology
Nfc-a complies with the ISO 14443-3a protocol.


Key words
Atqa Answer to Request acc. to ISO/IEC 14443-4
ATS Answer to Select acc. to ISO/IEC 14443-4
DIF Dual Interface (cards)
COS Card Operating System
CL Cascade level Acc. to ISO/IEC 14443-3
CT Cascade Tag, Type A
N.a. Not applicable
NFC near Field Communication
PCD Proximity Coupling Device ("contactless Reader")
PICC Proximity Integrated Circuit ("contactless Card")
PKE public Key encryption (like RSA or ECC)
Reqa Request Command, Type A
SAK Select acknowledge, Type A
Select Select Command, Type A
RID Random ID, typically dynamically generated at power-on Reset
RFU Reserved
UID Unique Identifier, Type A
nuID Non-unique Identifier


When the reader detects the card will send the REQA request command, in the sensing area of the card received REQA, will be feedback ATQA message.
Sak's sixth position indicates whether the PICC card complies with the ISO/IEC14443-4 standard.













The bit numbering in the ISO/IEC 14443 starts with lsbit = bit 1 and not lsbit =bit 0. So one byte counts bit 1...8 instead of bit 0...7.
The ISO/IEC 14443 transfers Lsbyte first. so e.g. 0x (Atqa of the mful) is often received as 0x 44 00.


ATQA ISO/IEC 14443-3 protocol Standard






Atqa Coding of NXP contactless Card ICs






SAK coding of NXP contactless Card ICs














If you can judge the type of manufacturer and product according to Atqa,sak,ats


Example
<string name= "tag_000409" >mifare Mini, nxp</string>
<string name= "tag_000408" >mifare Classic 1k, nxp</string>
<string name= "tag_000218" >mifare Classic 4k, nxp</string>
<string name= "tag_004218" >mifare Classic 4k, nxp</string>
<string name= "tag_004400" >mifare Ultralight, nxp</string>
<string name= "tag_000488" >mifare Classic 1K, infineon</string>
Getresources (). Getidentifier (prefix + atqa + sak + ATS, "string", Getpackagename ())





NFCA get (Tag tag)
Get an instance of NFCA and first judge
Tag.hastech (tagtechnology.nfc_a)
Whether this tag is nfc_a tag.
Then the NFC A tag instance is generated
GETATQA ()
The reader calls the card in the magnetic field and the card responds to the call. After receiving the card call command, the card will respond to the command (Answer to REQUEST,ATQA),
Tell the reader whether to obey the bit-oriented anti-collision mechanism,
Atqa/sens_res
This gets the message of the card answer.


Example: Used to determine if the Mifare Classic tag
NFCA NFCA = nfca.get (tag);
byte[] Atqa = Nfca.getatqa ();
if (atqa[1] = = 0 && (atqa[0] = = 4 | | atqa[0] = = (byte) 0x44 | | Atqa[0] = = 2 | | Atqa[0] = = (byte) 0x42))


Getsak ()
Sak/sel_res
Returns information about the selection command
Example:
Byte Sak = (byte) Nfca.getsak ();
if (Sak = = 8 | | sak = = 9 | | sak = = (byte) 0x18 | | Sak = = (byte) 0x88)




Transceive ()
Send Raw nfc-a commands to the tag and receive the response.
Sends a command to the tag and receives the return value.
Attention:
1: Do not increase the CRC when sending commands because the system will automatically add.
2: The Send command is the full byte. SENS_REQ3: Because it is an I/O operation, blocking occurs without calling this function on the main thread.


Getmaxtransceivelength ()
Gets the maximum send byte length


  
  
Reference documents
Nfca.java
Http://www.nxp.com/documents/application_note/AN10833.pdf
Http://nfc-tools.org/index.php?title=ISO14443A
  
Time
Drafted with the 2015-10-15
  

Android MIFARE NFCA Source parsing

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.