write-page

xod-dev/pn532-nfc/write-page

Writes data to the specified page of a Mifare Ultralight NFC tag. To write data to a tag it should be paired first (use `pair-tag`) Possible errors: — Can't write the value
write-page
@/write-page
Writes data to the specified page of a Mifare Ultralight NFC tag. To write data to a tag it should be paired first (use `pair-tag`) Possible errors: — Can't write the value
DEV@/pn532-device
PAGEnumber
A page number to write data to in range [0, 16]. Notice that first pages contains UID
IN1byte
IN2byte
IN3byte
IN4byte
UPDpulse
Trigger writing to an NFC tag
write-page
IN1
IN2
IN3
IN4
DEV
PAGE
UPD
OK
OKpulse
Fires on successful writing
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_UPD
#pragma XOD error_raise enable

struct State {
};

// clang-format off
{{ GENERATED_CODE }}
// clang-format on

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

    auto nfc = getValue<input_DEV>(ctx);
    uint8_t page = (uint8_t)getValue<input_PAGE>(ctx);
    uint8_t data[4] = {
        getValue<input_IN1>(ctx),
        getValue<input_IN2>(ctx),
        getValue<input_IN3>(ctx),
        getValue<input_IN4>(ctx)
    };
    uint8_t success = nfc->mifareultralight_WritePage(page, data);

    if (success) {
        emitValue<output_OK>(ctx, 1);
    } else {
        raiseError(ctx);
    }
}