Android Question Key in NFC

Heppy

Active Member
Licensed User
Longtime User
Hi.

I work with NTAG213/215/216 NFC Forum Type 2 Tag compliant IC with 144/504/888 bytes user memory
Rev. 3.0.

Acording to the datashet:
The PWD and PACK are writable even if the CFGLCK bit is set to 1b. Therefore it is
strongly recommended to set AUTH0 to the page where the PWD is located after the
password has been written. This page is 2Bh for NTAG213

How do I address and write that address?


After writing it, how is it authenticated and I think that you can not write the memory completely? Any example of authentication and reading-writing? I have been testing NFCAvanced but it does not include the PWD theme.

Thank you very much and greet the entire community. It had been a long time since I came in to be with very different projects.

Sorry for my english.
 

Heppy

Active Member
Licensed User
Longtime User
Hi Erel.

I found this post for NTAG 203 on stackoverflow.

B4X:
Yes, that's possible. NTAG203 (datasheet) is an ISO/IEC 14443 Type A ("NFC-A") tag and follows the NFC Forum Type 2 Tag Operation specification. In order to activate the physical write protection feature of such a tag, you need to set the lock bits.

On Android, you can access such a tag by obtaining an instance of the NfcA technology connector class for your tag handle:

Tag tag = ...  // I assume you already received the tag handle by means of an NFC discovery intent
NfcA nfcA = NfcA.get(tag);
if (nfcA != null) {
    // this is an NFC-A tag
    ...
The lock bits of NTAG203 are located in page 2 (0x02) bytes 2-3 and in page 40 (0x28) bytes 0-1. Each of the bits of those 4 bytes controls the lock state of certain pages of the NTAG203 memory area. In order to activate locking, you have to set the lock bit to '1' by issuing a write command for the pages containing the lock bits. So for the simplest scenario of locking the whole tag, you could do something like this:

    // connect to the tag
    nfcA.connect();

    byte[] result;
    // write all-ones to the lock bits on page 0x02
    result = nfcA.transceive(new byte[]{
            (byte)0xA2,  // Command: WRITE
            (byte)0x02,  // Address: page 0x02 (2)
            (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0xFF  // Data: set bytes 2-3 to all '1'
    });
    // write all-ones to the lock bits on page 0x28
    result = nfcA.transceive(new byte[]{
            (byte)0xA2,  // Command: WRITE
            (byte)0x02,  // Address: page 0x28 (40)
            (byte)0xFF, (byte)0x11, (byte)0x00, (byte)0x00  // Data: set byte 0 and lock bits in byte 1 to all '1'
    });

    nfcA.close();

What would it be like in B4A? I have the datasheet of NTAG213

There's very little information about it, but I've seen it in the Tagwriter app

https://stackoverflow.com/questions...-ntag203-nfc-chip-programmatically-on-android
 
Last edited:
Upvote 0

Heppy

Active Member
Licensed User
Longtime User
Well.


I am very happy for the service that Erel gives us.
Fast and effective.
I have solved it in another way that I do not know if it will be the best, but it works.
It is using the makereadonly and it works.

TagTech.RunAsync("WriteLock", "makeReadOnly", Null, 0)

Regards an thanks Erel.
 
Upvote 0
Top