10#include "../sf/service.h"
11#include "../services/mii.h"
27 NfcState_NonInitialized = 0,
28 NfcState_Initialized = 1,
32 NfpDeviceState_Initialized = 0,
33 NfpDeviceState_SearchingForTag = 1,
34 NfpDeviceState_TagFound = 2,
35 NfpDeviceState_TagRemoved = 3,
36 NfpDeviceState_TagMounted = 4,
37 NfpDeviceState_Unavailable = 5,
41 NfcDeviceState_Initialized = 0,
42 NfcDeviceState_SearchingForTag = 1,
43 NfcDeviceState_TagFound = 2,
44 NfcDeviceState_TagRemoved = 3,
45 NfcDeviceState_TagMounted = 4,
49 NfcMifareDeviceState_Initialized = 0,
50 NfcMifareDeviceState_SearchingForTag = 1,
51 NfcMifareDeviceState_TagFound = 2,
52 NfcMifareDeviceState_TagRemoved = 3,
53 NfcMifareDeviceState_TagMounted = 4,
54 NfcMifareDeviceState_Unavailable = 5,
55} NfcMifareDeviceState;
66 NfpDeviceType_Amiibo = 0,
70 NfpMountTarget_Rom =
BIT(0),
71 NfpMountTarget_Ram =
BIT(1),
72 NfpMountTarget_All = NfpMountTarget_Rom | NfpMountTarget_Ram,
80 NfcProtocol_All = 0xFFFFFFFF,
92 NfcTagType_All = 0xFFFFFFFF,
96 NfcMifareCommand_Read = 0x30,
97 NfcMifareCommand_AuthA = 0x60,
98 NfcMifareCommand_AuthB = 0x61,
99 NfcMifareCommand_Write = 0xA0,
100 NfcMifareCommand_Transfer = 0xB0,
101 NfcMifareCommand_Decrement = 0xC0,
102 NfcMifareCommand_Increment = 0xC1,
103 NfcMifareCommand_Store = 0xC2,
112 NfpBreakType_Flush = 0,
113 NfpBreakType_Break1 = 1,
114 NfpBreakType_Break2 = 2,
147 u32 application_area_size;
155 u16 game_character_id;
156 u8 character_variant;
168 char amiibo_name[(10*4)+1];
176 char amiibo_name[(10*4)+1];
184 u16 crc32_change_counter;
187 u8 application_area_version;
215 u16 settings_crc32_change_counter;
221 u8 application_area[0xD8];
300Result nfpMount(
const NfcDeviceHandle *handle, NfpDeviceType device_type, NfpMountTarget mount_target);
386Result nfpGetState(NfcState *out);
397Result nfcMfGetState(NfcState *out);
Result nfcGetNpadId(const NfcDeviceHandle *handle, u32 *out)
Only available with [4.0.0+].
Result nfpSetRegisterInfoPrivate(const NfcDeviceHandle *handle, const NfpRegisterInfoPrivate *register_info_private)
Not available with NfpServiceType_User.
NfpApplicationAreaVersion
Definition nfc.h:57
@ NfpApplicationAreaVersion_3DS
Application area created by a 3DS game.
Definition nfc.h:58
@ NfpApplicationAreaVersion_3DSv2
Application area created by a (new?) 3DS game.
Definition nfc.h:60
@ NfpApplicationAreaVersion_WiiU
Application area created by a Wii U game.
Definition nfc.h:59
@ NfpApplicationAreaVersion_Invalid
Invalid value (application area not created).
Definition nfc.h:62
@ NfpApplicationAreaVersion_Switch
Application area created by a Switch game.
Definition nfc.h:61
Result nfcAttachActivateEvent(const NfcDeviceHandle *handle, Event *out_event)
Returned event will have autoclear off.
Result nfpFlush(const NfcDeviceHandle *handle)
Requires the amiibo to be mounted with NfpMountTarget_Ram.
Result nfpGetCommonInfo(const NfcDeviceHandle *handle, NfpCommonInfo *out)
Requires the amiibo to be mounted with NfpMountTarget_Ram.
Result nfpAttachActivateEvent(const NfcDeviceHandle *handle, Event *out_event)
Returned event will have autoclear off.
NfcServiceType
NfcServiceType.
Definition nfc.h:21
@ NfcServiceType_System
Initializes nfc:sys.
Definition nfc.h:23
@ NfcServiceType_User
Initializes nfc:user.
Definition nfc.h:22
Result nfpWriteBackupData(const NfcDeviceHandle *handle, const void *buf, size_t buf_size)
Only available with NfpServiceType_Debug.
void nfcExit(void)
Exit nfc:*.
Result nfcAttachAvailabilityChangeEvent(Event *out_event)
Returned event will have autoclear on.
Result nfcMfAttachActivateEvent(const NfcDeviceHandle *handle, Event *out_event)
Returned event will have autoclear off.
Result nfcInitialize(NfcServiceType service_type)
Initialize nfc:*.
Result nfcWriteMifare(const NfcDeviceHandle *handle, const NfcMifareWriteBlockParameter *write_block_parameter, s32 count)
Only available with [4.0.0+].
Result nfpInitialize(NfpServiceType service_type)
Initialize nfp:*.
Result nfpRecreateApplicationArea(const NfcDeviceHandle *handle, u32 app_id, const void *buf, size_t buf_size)
Not available with NfpServiceType_System.
Result nfpSetApplicationArea(const NfcDeviceHandle *handle, const void *buf, size_t buf_size)
Not available with NfpServiceType_System.
Result nfpGetApplicationAreaSize(const NfcDeviceHandle *handle, u32 *out_app_area_size)
Not available with NfpServiceType_System.
Result nfpAttachDeactivateEvent(const NfcDeviceHandle *handle, Event *out_event)
Returned event will have autoclear off.
Result nfpReadBackupData(const NfcDeviceHandle *handle, void *out_buf, size_t buf_size, u32 *out_size)
Only available with NfpServiceType_Debug.
NfcProtocol
Definition nfc.h:75
@ NfcProtocol_TypeA
ISO14443A.
Definition nfc.h:77
@ NfcProtocol_TypeB
ISO14443B.
Definition nfc.h:78
@ NfcProtocol_TypeF
Sony FeliCa.
Definition nfc.h:79
Result nfcStartDetection(const NfcDeviceHandle *handle, NfcProtocol protocol)
Only available with [4.0.0+].
Result nfcMfAttachAvailabilityChangeEvent(Event *out_event)
Returned event will have autoclear on.
Result nfpBreakTag(const NfcDeviceHandle *handle, NfpBreakType break_type)
Only available with NfpServiceType_Debug.
Result nfpWriteNtf(const NfcDeviceHandle *handle, u32 write_type, const void *buf, size_t buf_size)
Only available with NfpServiceType_Debug.
Result nfpAttachAvailabilityChangeEvent(Event *out_event)
Returned event will have autoclear on.
Result nfcGetState(NfcState *out)
Only available with [4.0.0+].
Result nfcGetTagInfo(const NfcDeviceHandle *handle, NfcTagInfo *out)
Only available with [4.0.0+].
Service * nfpGetServiceSession(void)
Gets the Service object for the actual nfp:* service session.
void nfcMfExit(void)
Exit nfc:mf:u.
Result nfpGetRegisterInfoPrivate(const NfcDeviceHandle *handle, NfpRegisterInfoPrivate *out)
Not available with NfpServiceType_User.
Result nfcAttachDeactivateEvent(const NfcDeviceHandle *handle, Event *out_event)
Returned event will have autoclear off.
Result nfpFlushDebug(const NfcDeviceHandle *handle)
Only available with NfpServiceType_Debug.
Result nfpGetAdminInfo(const NfcDeviceHandle *handle, NfpAdminInfo *out)
Not available with NfpServiceType_User.
Result nfcStopDetection(const NfcDeviceHandle *handle)
Only available with [4.0.0+].
Result nfcListDevices(s32 *total_out, NfcDeviceHandle *out, s32 count)
Only available with [4.0.0+].
NfcTagType
Definition nfc.h:83
@ NfcTagType_Type4B
ISO14443B RW/RO. DESFire.
Definition nfc.h:89
@ NfcTagType_Type4A
ISO14443A RW/RO. DESFire.
Definition nfc.h:88
@ NfcTagType_Mifare
Mifare clasic. Skylanders.
Definition nfc.h:91
@ NfcTagType_Type3
ISO14443A RW/RO. Sony FeliCa.
Definition nfc.h:87
@ NfcTagType_Type2
ISO14443A RW. Ultralight, NTAGX, ST25TN.
Definition nfc.h:86
@ NfcTagType_Type1
ISO14443A RW. Topaz.
Definition nfc.h:85
@ NfcTagType_Type5
ISO15693 RW/RO. SLI, SLIX, ST25TV.
Definition nfc.h:90
Result nfcReleasePassThroughSession(const NfcDeviceHandle *handle)
Only available with [4.0.0+].
Result nfcMfInitialize()
Initialize nfc:mf:u.
Result nfpOpenApplicationArea(const NfcDeviceHandle *handle, u32 app_id)
Not available with NfpServiceType_System.
Result nfpGetApplicationArea(const NfcDeviceHandle *handle, void *buf, size_t buf_size, u32 *out_size)
Not available with NfpServiceType_System.
NfpAmiiboFlag
Definition nfc.h:106
@ NfpAmiiboFlag_ApplicationAreaExists
Application area exists.
Definition nfc.h:108
@ NfpAmiiboFlag_Valid
Initialized in system settings.
Definition nfc.h:107
NfpServiceType
NfpServiceType.
Definition nfc.h:14
@ NfpServiceType_User
Initializes nfp:user.
Definition nfc.h:15
@ NfpServiceType_System
Initializes nfp:sys.
Definition nfc.h:17
@ NfpServiceType_Debug
Initializes nfp:dbg.
Definition nfc.h:16
Result nfcMfAttachDeactivateEvent(const NfcDeviceHandle *handle, Event *out_event)
Returned event will have autoclear off.
Result nfcReadMifare(const NfcDeviceHandle *handle, NfcMifareReadBlockData *out_block_data, const NfcMifareReadBlockParameter *read_block_parameter, s32 count)
Only available with [4.0.0+].
Result nfcSendCommandByPassThrough(const NfcDeviceHandle *handle, u64 timeout, const void *cmd_buf, size_t cmd_buf_size, void *reply_buf, size_t reply_buf_size, u64 *out_size)
Only available with [4.0.0+].
Result nfpGetModelInfo(const NfcDeviceHandle *handle, NfpModelInfo *out)
Requires the amiibo to be mounted with NfpMountTarget_Rom.
Result nfpGetRegisterInfo(const NfcDeviceHandle *handle, NfpRegisterInfo *out)
Requires the amiibo to be mounted with NfpMountTarget_Ram.
Result nfpDeleteApplicationArea(const NfcDeviceHandle *handle)
Not available with NfpServiceType_User.
Result nfcKeepPassThroughSession(const NfcDeviceHandle *handle)
Only available with [4.0.0+].
Service * nfpGetServiceSession_Interface(void)
Gets the Service object for the interface from nfp:*.
Service * nfcMfGetServiceSession(void)
Gets the Service object for the actual nfc:mf:u service session.
Result nfpCreateApplicationArea(const NfcDeviceHandle *handle, u32 app_id, const void *buf, size_t buf_size)
Not available with NfpServiceType_System.
Service * nfcGetServiceSession(void)
Gets the Service object for the actual nfc:* service session.
void nfpExit(void)
Exit nfp:*.
Result nfpFormat(const NfcDeviceHandle *handle)
Not available with NfpServiceType_User.
Result nfpDeleteRegisterInfo(const NfcDeviceHandle *handle)
Not available with NfpServiceType_User.
Service * nfcGetServiceSession_Interface(void)
Gets the Service object for the interface from nfc:*.
Result nfpExistsApplicationArea(const NfcDeviceHandle *handle, bool *out)
Not available with NfpServiceType_User.
Result nfcGetDeviceState(const NfcDeviceHandle *handle, NfcDeviceState *out)
Only available with [4.0.0+].
Result nfcIsNfcEnabled(bool *out)
This uses nfc:*.
Result nfpSetAll(const NfcDeviceHandle *handle, const NfpData *nfp_data)
Only available with NfpServiceType_Debug.
Result nfpGetAll(const NfcDeviceHandle *handle, NfpData *out)
Only available with NfpServiceType_Debug.
Service * nfcMfGetServiceSession_Interface(void)
Gets the Service object for the interface from nfc:mf:u.
Kernel-mode event structure.
Definition event.h:13
Nfc/Nfp DeviceHandle.
Definition nfc.h:257
u8 unknown
Usually 1.
Definition nfc.h:226
NfcTagUid uid
UUID.
Definition nfc.h:137
u32 tag_type
NfcTagType
Definition nfc.h:139
u32 protocol
NfcProtocol
Definition nfc.h:138
u8 uid_length
UUID length.
Definition nfc.h:125
u8 application_area_version
NfpApplicationAreaVersion
Definition nfc.h:218
u8 unknown1
Normally zero.
Definition nfc.h:209
u16 mii_v3_crc16
CRC16 of Ver3StoreData.
Definition nfc.h:204
NfpDate first_write_date
Set when the amiibo is first written to.
Definition nfc.h:206
u8 flags
NfpAmiiboFlag
Definition nfc.h:216
u64 application_id
Modified application ID (Application ID & 0xFFFFFFFF0FFFFFFF | 0x30000000)
Definition nfc.h:213
u8 font_region
Font region.
Definition nfc.h:208
u32 crc32_1
CRC32 of some internal 8-byte data.
Definition nfc.h:195
u16 tag_write_counter
Incremented every tag write.
Definition nfc.h:194
NfpDate last_write_date
Updated every write.
Definition nfc.h:197
u32 access_id
Application area access ID.
Definition nfc.h:214
u16 version
Version.
Definition nfc.h:199
u32 application_area_size
Size of the application area.
Definition nfc.h:200
u8 tag_magic
Tag magic (always 0xA5: https://www.3dbrew.org/wiki/Amiibo#Page_layout).
Definition nfc.h:192
u32 crc32_2
CRC32 of Ver3StoreData + application_id_byte + unknown1 + StoreDataExtension + unknown2 (0x7E bytes t...
Definition nfc.h:210
u16 write_counter
Incremented every write, until it maxes out at 0xFFFF.
Definition nfc.h:198
MiiNfpStoreDataExtension mii_store_data_extension
StoreDataExtension.
Definition nfc.h:205
u8 application_id_byte
Application ID byte ((Application ID >> 28) & 0xFF)
Definition nfc.h:219
MiiVer3StoreData mii_v3
Ver3StoreData (Mii format used in 3DS).
Definition nfc.h:202
u8 tag_type
NfcTagType
Definition nfc.h:217
u16 numbering_id
Model number.
Definition nfc.h:160
u8 series_id
Series.
Definition nfc.h:159
u8 nfp_type
Figure type.
Definition nfc.h:161
NfcTagUid uid
UUID.
Definition nfc.h:130
u32 protocol
NfcProtocol
Definition nfc.h:131
u32 tag_type
NfcTagType
Definition nfc.h:132
Service object structure.
Definition service.h:14
#define BIT(n)
Creates a bitmask from a bit number.
Definition types.h:54
uint64_t u64
64-bit unsigned integer.
Definition types.h:22
uint8_t u8
8-bit unsigned integer.
Definition types.h:19
#define NX_PACKED
Packs a struct so that it won't include padding bytes.
Definition types.h:63
uint16_t u16
16-bit unsigned integer.
Definition types.h:20
u32 Result
Function error code result type.
Definition types.h:44
int32_t s32
32-bit signed integer.
Definition types.h:27
uint32_t u32
32-bit unsigned integer.
Definition types.h:21