read-page

xod-dev/pn532-nfc/read-page

Reads one page of a Mifare Ultralight NFC tag. To read data from a tag it should be paired first (use `pair-tag`) Possible errors: — Can't read the value
read-page
@/read-page
Reads one page of a Mifare Ultralight NFC tag. To read data from a tag it should be paired first (use `pair-tag`) Possible errors: — Can't read the value
DEV@/pn532-device
PAGEnumber
A page number to read data from in range [0, 16]. Notice that first pages contains UID
READpulse
Trigger reading from an NFC tag
read-page
OUT1
OUT2
OUT3
OUT4
OK
DEV
PAGE
READ
OKpulse
Fires on successful reading
OUT4byte
OUT3byte
OUT2byte
OUT1byte
To use the node in your project you should have the xod-dev/pn532-nfc library installed. Use the “File → Add Library” menu item in XOD IDE if you don’t have it yet. See Using libraries for more info.

C++ implementation

#pragma XOD evaluate_on_pin disable
#pragma XOD evaluate_on_pin enable input_READ
#pragma XOD error_raise enable

node {
    void evaluate(Context ctx) {
        if (!isInputDirty<input_READ>(ctx))
            return;

        auto nfc = getValue<input_DEV>(ctx);
        uint8_t page = (uint8_t)getValue<input_PAGE>(ctx);

        uint8_t data[4];
        uint8_t success = nfc->mifareultralight_ReadPage(page, data);

        if (success) {
            emitValue<output_OUT1>(ctx, data[0]);
            emitValue<output_OUT2>(ctx, data[1]);
            emitValue<output_OUT3>(ctx, data[2]);
            emitValue<output_OUT4>(ctx, data[3]);
            emitValue<output_OK>(ctx, 1);
        } else {
            raiseError(ctx);
        }
    }
}