Writing AUTH0 with Android

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Writing AUTH0 with Android

跳至解决方案
1,289 次查看
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 项奖励
回复
1 解答
1,073 次查看
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 项奖励
回复
1 回复
1,074 次查看
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 项奖励
回复