NTAGWrite

Syntax

#include <cafe/ntag.h>

typedef void (*NTAGResultCheckCallback)(s32 chan, NTAGError error_code, void* userData); 

NTAGError NTAGWrite ( s32 chan ,u16 time_out, const u8* uid, u16 write_size, const u8* data, 
                      NTAGResultCheckCallback callback, void* userData );

Parameters

chan Controller number 0.
time_out Timeout intervals.
0: Infinite
1 through 65535 : ms
uid ID of the target tag (7 bytes).
Must always be specified. (Tags that do not match cannot be written to.)
When NULL is specified, it is handled as a UID of All0, and tag writing fails.
write_size Size of the write data.
Must be equal to or less than the size of the RAM region for the tag.
data Pointer to the data to write.
callback Callback called when data writing finishes.
userData Data to pass to the callback function.

Return Values

NTAG_ERR_NONEThe command was issued normally.
NTAG_ERR_NOT_INITThe initialization of the NFC module is not finished.
NTAG_ERR_INVALID_COMMANDInvalid command.

Callback Notification Details

When tags are detected, the following registered callbacks send notifications with the following details.

chanController number.
error_code Error code:
  • NTAG_ERR_NONE : The process finished normally.
  • NTAG_ERR_TIMEOUT : Timeout occurred.
  • NTAG_ERR_INVALID_UID : The configured UID did not match the UID of the detected tag.
  • NTAG_ERR_INVALID_TAG : An unsupported tag was detected.
  • NTAG_ERR_INVALID_FORMAT : A tag with an invalid format was detected.
  • NTAG_ERR_NEED_FORMAT : A tag that needs a format was detected.
  • NTAG_ERR_READ : An error occurred in the reading prior to writing.
  • NTAG_ERR_WRITE : An error occurred during writing.
  • NTAG_ERR_WRITE_READ_ONLY: Cannot write because a read-only flag is raised.
  • NTAG_ERR_ABORT : The process was ended partway by the system.
    (When the HOME Menu is called or the TV control button is pressed.)
userDataUser data.

Description

Writes data to tags. When the writing is complete, specify the UID for the target tag. The write data specified in this function must be of a size equal to or less than the RAM region for the tag that handles the writing. If the size provided in the arguments does not fill the RAM region, the remaining data is filled in with random values on the system side when the tag is written. (Writing to tags is performed for the entire region, not just part of it.) Accordingly, if you want to rewrite only some of the tag data, first read it, create changed data for only the relevant regions, and then specify it in this function.
You can also determine whether the writing succeeded from the callback that was set.

NOTE:
Tag formatting could be corrupted if the tag is removed from the GamePad while data is being written to the tag. If the tag formatting becomes corrupted, it is no longer possible to read or write data from that point. Use the NTAGFormat function to redo the formatting, and then write the data again.

Do Not Call From

Background Do not call this function from the background.
Multiple threads This function is not thread-safe.
Multiple Cores Do not call this function from more than one Core.

Revision History

2013/05/08 Automated cleanup pass.
2012/12/11 Initial version.


CONFIDENTIAL