libctru
v2.4.1
|
NFC service. More...
Go to the source code of this file.
Data Structures | |
struct | NFC_TagInfo |
struct | NFC_AmiiboSettings |
AmiiboSettings structure, see also here: https://3dbrew.org/wiki/NFC:GetAmiiboSettings. More... | |
struct | NFC_AmiiboConfig |
AmiiboConfig structure, see also here: https://3dbrew.org/wiki/NFC:GetAmiiboConfig. More... | |
struct | NFC_AppDataInitStruct |
Used by nfcInitializeWriteAppData() internally, see also here: https://3dbrew.org/wiki/NFC:GetAppDataInitStruct. More... | |
struct | NFC_AppDataWriteStruct |
Used by nfcWriteAppData() internally, see also: https://3dbrew.org/wiki/NFC:WriteAppData. More... | |
Macros | |
#define | NFC_ERR_INVALID_STATE 0xC8A17600 |
This is returned when the current state is invalid for this command. | |
#define | NFC_ERR_APPDATA_UNINITIALIZED 0xC8A17620 |
This is returned by nfcOpenAppData() when the appdata is uninitialized since nfcInitializeWriteAppData() wasn't used previously. | |
#define | NFC_ERR_AMIIBO_NOTSETUP 0xC8A17628 |
This is returned by nfcGetAmiiboSettings() when the amiibo wasn't setup by the amiibo Settings applet. | |
#define | NFC_ERR_APPID_MISMATCH 0xC8A17638 |
This is returned by nfcOpenAppData() when the input AppID doesn't match the actual amiibo AppID. | |
#define | NFC_ERR_DATACORRUPTION0 0xC8C1760C |
"Returned for HMAC-hash mismatch(data corruption), with HMAC-calculation input_buffer_size=0x34." | |
#define | NFC_ERR_DATACORRUPTION1 0xC8A17618 |
HMAC-hash mismatch with input_buffer_size=0x1DF, see here: https://www.3dbrew.org/wiki/Amiibo. | |
#define | NFC_STARTSCAN_DEFAULTINPUT 0 |
This can be used for nfcStartScanning(). | |
Enumerations | |
enum | NFC_OpType { NFC_OpType_1 = 1 , NFC_OpType_NFCTag = 2 , NFC_OpType_RawNFC = 3 } |
NFC operation type. More... | |
enum | NFC_TagState { NFC_TagState_Uninitialized = 0 , NFC_TagState_ScanningStopped = 1 , NFC_TagState_Scanning = 2 , NFC_TagState_InRange = 3 , NFC_TagState_OutOfRange = 4 , NFC_TagState_DataReady = 5 } |
enum | { NFC_amiiboFlag_Setup = BIT(4) , NFC_amiiboFlag_AppDataSetup = BIT(5) } |
Bit4-7 are always clear with nfcGetAmiiboSettings() due to "& 0xF". More... | |
Functions | |
Result | nfcInit (NFC_OpType type) |
Initializes NFC. More... | |
void | nfcExit (void) |
Shuts down NFC. | |
Handle | nfcGetSessionHandle (void) |
Gets the NFC service handle. More... | |
Result | nfcStartScanning (u16 inval) |
Starts scanning for NFC tags. More... | |
void | nfcStopScanning (void) |
Stops scanning for NFC tags. | |
Result | nfcLoadAmiiboData (void) |
Read amiibo NFC data and load in memory. | |
Result | nfcResetTagScanState (void) |
If the tagstate is valid(NFC_TagState_DataReady or 6), it then sets the current tagstate to NFC_TagState_InRange. | |
Result | nfcUpdateStoredAmiiboData (void) |
This writes the amiibo data stored in memory to the actual amiibo data storage(which is normally the NFC data pages). More... | |
Result | nfcGetTagState (NFC_TagState *state) |
Returns the current NFC tag state. More... | |
Result | nfcGetTagInfo (NFC_TagInfo *out) |
Returns the current TagInfo. More... | |
Result | nfcOpenAppData (u32 amiibo_appid) |
Opens the appdata, when the amiibo appdata was previously initialized. More... | |
Result | nfcInitializeWriteAppData (u32 amiibo_appid, const void *buf, size_t size) |
This initializes the appdata using the specified input, when the appdata previously wasn't initialized. More... | |
Result | nfcReadAppData (void *buf, size_t size) |
Reads the appdata. More... | |
Result | nfcWriteAppData (const void *buf, size_t size, NFC_TagInfo *taginfo) |
Writes the appdata, after nfcOpenAppData() was used successfully. More... | |
Result | nfcGetAmiiboSettings (NFC_AmiiboSettings *out) |
Returns the current AmiiboSettings. More... | |
Result | nfcGetAmiiboConfig (NFC_AmiiboConfig *out) |
Returns the current AmiiboConfig. More... | |
Result | nfcStartOtherTagScanning (u16 unk0, u32 unk1) |
Starts scanning for NFC tags when initialized with NFC_OpType_RawNFC. More... | |
Result | nfcSendTagCommand (const void *inbuf, size_t insize, void *outbuf, size_t outsize, size_t *actual_transfer_size, u64 microseconds) |
This sends a raw NFC command to the tag. More... | |
Result | nfcCmd21 (void) |
Unknown. More... | |
Result | nfcCmd22 (void) |
Unknown. More... | |
NFC service.
This can only be used with system-version >=9.3.0-X.
anonymous enum |
Bit4-7 are always clear with nfcGetAmiiboSettings() due to "& 0xF".
Enumerator | |
---|---|
NFC_amiiboFlag_AppDataSetup | This indicates that the amiibo was setup with amiibo Settings. nfcGetAmiiboSettings() will return an all-zero struct when this is not set. |
enum NFC_OpType |
enum NFC_TagState |
Enumerator | |
---|---|
NFC_TagState_ScanningStopped | nfcInit() was not used yet. |
NFC_TagState_Scanning | Not currently scanning for NFC tags. Set by nfcStopScanning() and nfcInit(), when successful. |
NFC_TagState_InRange | Currently scanning for NFC tags. Set by nfcStartScanning() when successful. |
NFC_TagState_OutOfRange | NFC tag is in range. The state automatically changes to this when the state was previously value 2, without using any NFC service commands. |
NFC_TagState_DataReady | NFC tag is now out of range, where the NFC tag was previously in range. This occurs automatically without using any NFC service commands. Once this state is entered, it won't automatically change to anything else when the tag is moved in range again. Hence, if you want to keep doing tag scanning after this, you must stop+start scanning. |
Result nfcCmd21 | ( | void | ) |
Unknown.
This can only be used when initialized with NFC_OpType_RawNFC, and when the TagState is NFC_TagState_InRange.
Result nfcCmd22 | ( | void | ) |
Unknown.
This can only be used when initialized with NFC_OpType_RawNFC, and when the TagState is NFC_TagState_InRange.
Result nfcGetAmiiboConfig | ( | NFC_AmiiboConfig * | out | ) |
Returns the current AmiiboConfig.
out | Pointer to write the output AmiiboConfig. |
Result nfcGetAmiiboSettings | ( | NFC_AmiiboSettings * | out | ) |
Returns the current AmiiboSettings.
out | Pointer to write the output AmiiboSettings. |
Handle nfcGetSessionHandle | ( | void | ) |
Gets the NFC service handle.
Result nfcGetTagInfo | ( | NFC_TagInfo * | out | ) |
Returns the current TagInfo.
out | Pointer to write the output TagInfo. |
Result nfcGetTagState | ( | NFC_TagState * | state | ) |
Returns the current NFC tag state.
state | Pointer to write NFC tag state. |
Result nfcInit | ( | NFC_OpType | type | ) |
This initializes the appdata using the specified input, when the appdata previously wasn't initialized.
If the appdata is already initialized, you must first use the amiibo Settings applet menu option labeled "Delete amiibo Game Data". This automatically writes the amiibo data into the actual data storage(normally NFC data pages). See also nfcWriteAppData().
amiibo_appid | amiibo AppID. See also nfcOpenAppData(). |
buf | Input buffer. |
size | Buffer size. |
Opens the appdata, when the amiibo appdata was previously initialized.
This must be used before reading/writing the appdata. See also: https://3dbrew.org/wiki/NFC:OpenAppData
amiibo_appid | Amiibo AppID. See here: https://www.3dbrew.org/wiki/Amiibo |
Result nfcReadAppData | ( | void * | buf, |
size_t | size | ||
) |
Reads the appdata.
The size must be >=0xD8-bytes, but the actual used size is hard-coded to 0xD8. Note that areas of appdata which were never written to by applications are uninitialized in this output buffer.
buf | Output buffer. |
size | Buffer size. |
Result nfcSendTagCommand | ( | const void * | inbuf, |
size_t | insize, | ||
void * | outbuf, | ||
size_t | outsize, | ||
size_t * | actual_transfer_size, | ||
u64 | microseconds | ||
) |
This sends a raw NFC command to the tag.
This can only be used when initialized with NFC_OpType_RawNFC, and when the TagState is NFC_TagState_InRange. See also: https://www.3dbrew.org/wiki/NFC:SendTagCommand
inbuf | Input buffer. |
insize | Size of the input buffer. |
outbuf | Output buffer. |
outsize | Size of the output buffer. |
actual_transfer_size | Optional output ptr to write the actual output-size to, can be NULL. |
microseconds | Timing-related field in microseconds. |
Starts scanning for NFC tags when initialized with NFC_OpType_RawNFC.
See also: https://www.3dbrew.org/wiki/NFC:StartOtherTagScanning
unk0 | Same as nfcStartScanning() input. |
unk1 | Unknown. |
Starts scanning for NFC tags.
inval | Unknown. See NFC_STARTSCAN_DEFAULTINPUT. |
Result nfcUpdateStoredAmiiboData | ( | void | ) |
This writes the amiibo data stored in memory to the actual amiibo data storage(which is normally the NFC data pages).
This can only be used if NFC_LoadAmiiboData() was used previously.
Result nfcWriteAppData | ( | const void * | buf, |
size_t | size, | ||
NFC_TagInfo * | taginfo | ||
) |
Writes the appdata, after nfcOpenAppData() was used successfully.
The size should be <=0xD8-bytes. See also: https://3dbrew.org/wiki/NFC:WriteAppData
buf | Input buffer. |
size | Buffer size. |
taginfo | TagInfo from nfcGetTagInfo(). |