Android Question NFC Questions

bartj

Member
I have several NFC related questions. I am a beginner user.

Have successfully loaded and run the NFC Advanced demo program using version 10.0 of B4A which uses version 2.01 of the NFC library. Yea! Am able to read/write Ndef mifare ultra-light and 1k classic.

It took me a while to figure out that in order for Ndef to work the card needed to be formatted for Ndef. I used a NXP play-store app to accomplish formatting.

1) It appears that I can only store ASCII data with Ndef. Is this correct?

2) In an effort to read/write at a lower level, I find that if I change the tech from:
"android.nfc.tech.Ndef"
to:
"android.nfc.tech.MifareClassic"
(using a Ndef formatted card)

I am then able to use the following from post 105409 with no compile errors or exceptions.

Note that the passed bytes are not likely to be correct. I changed them from the example.

Taken from post 105409:
' example in post 105409 is talking to a non mifare card
    TagTech.RunAsync("TT", "transceive", Array(Array As Byte(0x30, 0x00, 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5,0)), 0)
    Wait For TT_RunAsync (Flag As Int, Success As Boolean, Result As Object)
    Log("Exception Check: " & LastException)
    If Success Then
        Dim rawId() As Byte = Result
        Dim bc As ByteConverter
        Log("Info: " & (bc.HexFromBytes(rawId)))
    End If

This code returns:
Info: B200000000007F078840000000000000

The middle bytes show the permissions for sector 1. See the end of this message for a screen shot from a play-store app showing sector data.

Looking at the mifate classic 1k data sheet, I see that the read command is "0x30", followed by a 1 byte address followed by a CRC. If I am reading the data sheet correctly it appears that there are 3 stages of both read and writes (termed authentication) that need to be successfully competed before I can actually access that card data.


So my first question in that area is: Does the NFC library, when talking to Ndef cards, handle the authentication "behind the scenes", or is Ndef setup in such a way that authentication is not required (such as setting up the permissions so this is not required)?

Its likely that I will want to implement authentication in the long term. Can anyone recommend a good, concise reference for implementing authentication on Mifare classic(EV-1) 1k cards? There is an overwhelming amount of information out there. Or, has someone in the community developed code to support authentication of mifare classic 1k cards?

Thanks!


Screenshot_20201023-104536.png
 

bartj

Member
Thanks for the response!

I ask my question about "ASCII data only" for Ndef because I see that the last byte of any Ndef record is defined to be 0xFE. Although in the Ndef "header" there is a length parameter, I am going to assume that I can have any number of occurrences of 0xFE in the payload without it causing framing errors.
 
Upvote 0
Top