2016年8月29日 星期一

Android NFC sample code

1. Read Tag ID
http://www.java2s.com/Open-Source/Android_Free_Code/Development/data/com_nathansizemore_nfcvreaderMainActivity_java.htm

transceive()

TI -
NFC Type 5 Tag Platform After pressing the R/W button, present a NFC tag (doesn't have to be formatted). in this example we are presenting an unformatted NFC Type 5 (ISO15693, TI HF-I) tag. Note that the tab automatically flips to R/W: Legacy and the type of card is displayed graphically along with the Unique ID (in this case, E007000017F4E0E4). Press the Format NDEF button to make the tag NFC-V type. This puts a Capability Container with empty NDEF in the user memory.
http://www.ti.com/lit/ug/slou386/slou386.pdf

https://e2e.ti.com/support/wireless_connectivity/nfc_rfid/f/667/p/427665/1755155
https://e2e.ti.com/support/wireless_connectivity/nfc_rfid/f/667/t/427665

source code
http://blog.chinaunix.net/uid-87897-id-4652300.html
http://stackoverflow.com/questions/15689582/reading-a-nxp-icode-sli-l-tag-with-android
http://stackoverflow.com/questions/35235284/ti-nfc-write-single-block-with-android-nfcv-iso-15693


read multiple blocks command
Use Read Multiple Blocks to get value, it's ISO15693 standard command
Read Multiple Blocks (Addressed) otherwise will get 0x02 response. I don't know why.
The blue background bytes will be generated by byte[] transceive (byte[] data).

buf[0] = 0x8f; /* Reset FIFO command */ 
buf[1] = 0x91; /* Send with CRC */ 
buf[2] = 0x3d; /* Write continuous from register 1D */ 
buf[3] = (char) (size >> 8); /* Data for register 1D */ 
buf[4] = (char) (size << 4); /* Data for register 1E */
buf[5] = 0x00; /* ISO15693 flag with option flag not set*/ 
buf[6] = 0x23; /* Read multiple blocks command code */ 
buf[7] to buf[14] contains UID 
buf[15] = First block number 
buf[16] = Number of blocks
http://www.ti.com/lit/an/sloa138/sloa138.pdf
code example and also refer to the attached.
http://www.itstrike.cn/Question/d024832d-a8ed-446c-95d8-cbafb1b01724.html
Send raw NFC-V commands to the tag and receive the response.
Applications must not append the CRC to the payload, it will be automatically calculated. The application does provide FLAGS, CMD and PARAMETER bytes.
https://developer.android.com/reference/android/nfc/tech/NfcV.html

沒有留言:

張貼留言