最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

nfc - write secured NTAG215 with pn532 on arduino - Stack Overflow

programmeradmin4浏览0评论

I have a problem with my ntag215. I use the Adafruit_PN532 library and I wrote down the password on pages 130-133 according to the nfc tool application, the nfc tag is then protected by a password, but how can I get back to it to write new data on it, or change the password. I have not found a clear answer on the internet

I tried to overwrite the password, but unfortunately I have no idea how to perform authorization.

the code I used to save the password on the tag

#include <Wire.h>
#include <Adafruit_PN532.h>

#define SDA_PIN 21
#define SCL_PIN 22

Adafruit_PN532 nfc(SDA_PIN, SCL_PIN);

uint8_t password[4] = {0x11, 0x22, 0x33, 0x44};
uint8_t pack[2] = {0xDE, 0xAD};
uint8_t protect_start_page = 4;

void setup() {
    Serial.begin(115200);
    Serial.println("Initializing NFC module...");

    nfc.begin();
    uint32_t versiondata = nfc.getFirmwareVersion();
    if (!versiondata) {
        Serial.println("Didn't find PN53x board");
        while (1);
    }

    Serial.println("Found PN532!");
    nfc.SAMConfig();
}

void loop() {
    Serial.println("Place your NTAG215 tag on the reader...");

    uint8_t success;
    uint8_t uid[7];
    uint8_t uidLength;
    
    success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &uidLength);
    if (success) {
        Serial.println("Tag detected!");

        Serial.println("Writing password...");
        if (!nfc.ntag2xx_WritePage(130, password)) {
            Serial.println("ERROR: Could not write password!");
            return;
        }
        Serial.println("Password written successfully.");
    }
    else {
        Serial.println("No tag detected.");
    }
    
    delay(3000);
}

I have a problem with my ntag215. I use the Adafruit_PN532 library and I wrote down the password on pages 130-133 according to the nfc tool application, the nfc tag is then protected by a password, but how can I get back to it to write new data on it, or change the password. I have not found a clear answer on the internet

I tried to overwrite the password, but unfortunately I have no idea how to perform authorization.

the code I used to save the password on the tag

#include <Wire.h>
#include <Adafruit_PN532.h>

#define SDA_PIN 21
#define SCL_PIN 22

Adafruit_PN532 nfc(SDA_PIN, SCL_PIN);

uint8_t password[4] = {0x11, 0x22, 0x33, 0x44};
uint8_t pack[2] = {0xDE, 0xAD};
uint8_t protect_start_page = 4;

void setup() {
    Serial.begin(115200);
    Serial.println("Initializing NFC module...");

    nfc.begin();
    uint32_t versiondata = nfc.getFirmwareVersion();
    if (!versiondata) {
        Serial.println("Didn't find PN53x board");
        while (1);
    }

    Serial.println("Found PN532!");
    nfc.SAMConfig();
}

void loop() {
    Serial.println("Place your NTAG215 tag on the reader...");

    uint8_t success;
    uint8_t uid[7];
    uint8_t uidLength;
    
    success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &uidLength);
    if (success) {
        Serial.println("Tag detected!");

        Serial.println("Writing password...");
        if (!nfc.ntag2xx_WritePage(130, password)) {
            Serial.println("ERROR: Could not write password!");
            return;
        }
        Serial.println("Password written successfully.");
    }
    else {
        Serial.println("No tag detected.");
    }
    
    delay(3000);
}
Share Improve this question asked Mar 11 at 12:55 taktak 111 silver badge2 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

I suggest that you read the datasheet for the NTAG this shows you what the NTAG 215 is capable of doing and what the correct commands you need to send it to do what you want.

There is a PWD_AUTH command that 0x1B that allow you send it the 4 bytes of a password you set by writing to the correct pages on the Tag.

At the moment you have set a password but you have not applied that password to any of the data pages, for that you need to change the AUTH0 byte on on the correct configuration page.

Your code should always check the response of any command you send to the TAG for a NAK response, details of what that is in the datasheet.

The commands you need to send to the TAG are not language specific, there a number of answers that show the correct series of commands to do all password type operations e.g. One for iOS on NTAG216 adjust the data pages for the small NTAG215 and ignore the how and look at what data is sent to the TAG.

I would also not use NFC Tools for setting passwords as there are reports of it doing funny encoding of text to bytes, which cause problems.

发布评论

评论列表(0)

  1. 暂无评论