Seeedstudio NFC屏蔽Ultralight写

时间:2014-07-31 04:33:10

标签: arduino nfc mifare

我试图修改NFC屏蔽中的示例代码,以便能够写入Ultralight标签。

我修改了PN532.cpp库文件中的代码以包含以下函数:

uint8_t PN532::mifareultralight_WriteDataBlock (uint8_t page, uint8_t * data) {
    if (page >= 64) {
        Console.println("Page value out of range");

        // Return Failed Signal
        return 0;
    }

    /* Prepare the first command */
    pn532_packetbuffer[0] = PN532_COMMAND_INDATAEXCHANGE;
    pn532_packetbuffer[1] = 1;                      /* Card number */
    pn532_packetbuffer[2] = MIFARE_CMD_UL_WRITE;       /* Mifare Ultralight Write command = 0xA2 */
    pn532_packetbuffer[3] = page;            /* Page Number (0..63 for most cases) */
    memcpy (pn532_packetbuffer+4, data, 4);          /* Data Payload */

    /* Send the command */
    if ( HAL(writeCommand)(pn532_packetbuffer, 8) < 0) {
         Console.println("Failed to receive ACK for write command");

         // Return Failed Signal
         return 0;
    }
    delay(10);

    /* Read the response packet */
    HAL(readResponse)(pn532_packetbuffer, sizeof(pn532_packetbuffer));

    Console.print(sizeof(pn532_packetbuffer));

    // Return OK Signal
    return 1;
}

控制台告诉我我已成功写入标签,但是当我使用带有NXP Taginfo的Android手机读取标签时,标签上没有数据显示。

0 个答案:

没有答案