Writing AUTH0 with Android

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Writing AUTH0 with Android

Jump to solution
1,093 Views
lucacorsetti
Contributor I

Hi all,

I'm trying to configure a NTAG216 with password protection.

I'm trying to write starting protected address in AUTH0 byte, I've read the entire doc on ntag2x but I can't figure out how to do this.

Can someone help me or indicate me an example?

Thank you in advance

--

Luca

0 Kudos
Reply
1 Solution
877 Views
lucacorsetti
Contributor I

I've solved my problem.

The problem was I've previously inadvertenly set PWD, PACK and AUTH0, so then I can't write anymore on AUTH0 address because that address was locked.

As written in docs, that address is simply writable as a normal memory page.

With android I'm using this code to secure NTAG216

// PWD
if (!ntag.write(0xE5, pwd.getBytes(CHARSET))) {
    showToastMex("ERROR IN WRITING PWD");
    retValue = false;
}

// PACK
if (retValue) {
    if (!ntag.write(0xE6, pack.getBytes(CHARSET))) {
        showToastMex("ERROR IN WRITING PACK");
        retValue = false;
    }
}

// AUTH0 (da pagina 220 = DCh)
if (retValue) {
    byte space = " ".getBytes(CHARSET)[0];
    byte[] toWrite = {space, space, space, MEM_ADDR_TO_LOCK};
    if (!ntag.write(0xE3, toWrite)) {
        showToastMex("ERROR IN WRITING AUTH0");
        retValue = false;
    }
}

where

MEM_ADDR_TO_LOCK = (byte) 0xDC

and

CHARSET = Charset.forName("UTF-8")

View solution in original post

0 Kudos
Reply
1 Reply
878 Views
lucacorsetti
Contributor I

I've solved my problem.

The problem was I've previously inadvertenly set PWD, PACK and AUTH0, so then I can't write anymore on AUTH0 address because that address was locked.

As written in docs, that address is simply writable as a normal memory page.

With android I'm using this code to secure NTAG216

// PWD
if (!ntag.write(0xE5, pwd.getBytes(CHARSET))) {
    showToastMex("ERROR IN WRITING PWD");
    retValue = false;
}

// PACK
if (retValue) {
    if (!ntag.write(0xE6, pack.getBytes(CHARSET))) {
        showToastMex("ERROR IN WRITING PACK");
        retValue = false;
    }
}

// AUTH0 (da pagina 220 = DCh)
if (retValue) {
    byte space = " ".getBytes(CHARSET)[0];
    byte[] toWrite = {space, space, space, MEM_ADDR_TO_LOCK};
    if (!ntag.write(0xE3, toWrite)) {
        showToastMex("ERROR IN WRITING AUTH0");
        retValue = false;
    }
}

where

MEM_ADDR_TO_LOCK = (byte) 0xDC

and

CHARSET = Charset.forName("UTF-8")
0 Kudos
Reply