@@ -33,7 +33,7 @@ void print_hex(void *buf, size_t size) {
33
33
consoleUpdate (NULL );
34
34
}
35
35
36
- Result process_amiibo (u32 app_id ) {
36
+ Result process_amiibo () {
37
37
Result rc = 0 ;
38
38
39
39
// Get the handle of the first controller with NFC capabilities.
@@ -94,15 +94,34 @@ Result process_amiibo(u32 app_id) {
94
94
rc = eventWaitLoop (& activate_event );
95
95
96
96
if (R_SUCCEEDED (rc )) {
97
- printf ("A tag was detected, please do not remove it from the NFC spot.\n" );
97
+ printf ("A tag was detected, please do not remove it from the NFC spot.\n\n " );
98
98
consoleUpdate (NULL );
99
99
}
100
100
}
101
101
102
+ // Retrieve the tag info data, which contains the protocol, type and uuid.
103
+ if (R_SUCCEEDED (rc )) {
104
+ NfpTagInfo tag_info = {0 };
105
+ rc = nfpGetTagInfo (& handle , & tag_info );
106
+
107
+ if (R_SUCCEEDED (rc )) {
108
+ printf ("Tag protocol: 0x%02x, type: 0x%02x, UUID: " , tag_info .protocol , tag_info .tag_type );
109
+ print_hex (tag_info .uuid , tag_info .uuid_length );
110
+ printf ("\n" );
111
+ }
112
+ }
113
+
102
114
// If a tag was successfully detected, load it into memory.
103
- if (R_SUCCEEDED (rc ))
115
+ if (R_SUCCEEDED (rc )) {
104
116
rc = nfpMount (& handle , NfpDeviceType_Amiibo , NfpMountTarget_All );
105
117
118
+ if (rc == 0x11073 ) // 2115-0136
119
+ printf ("This tag is corrupted and has a backup in system.\n" );
120
+
121
+ if (rc == 0x12073 ) // 2115-0144
122
+ printf ("This tag is corrupted.\n" );
123
+ }
124
+
106
125
// Retrieve the model info data, which contains the amiibo id.
107
126
if (R_SUCCEEDED (rc )) {
108
127
NfpModelInfo model_info = {0 };
@@ -111,6 +130,7 @@ Result process_amiibo(u32 app_id) {
111
130
if (R_SUCCEEDED (rc )) {
112
131
printf ("Amiibo ID: " );
113
132
print_hex (model_info .amiibo_id , 8 );
133
+ printf ("\n" );
114
134
}
115
135
}
116
136
@@ -120,8 +140,43 @@ Result process_amiibo(u32 app_id) {
120
140
NfpCommonInfo common_info = {0 };
121
141
rc = nfpGetCommonInfo (& handle , & common_info );
122
142
123
- if (R_SUCCEEDED (rc ))
143
+ if (R_SUCCEEDED (rc )) {
124
144
app_area_size = common_info .application_area_size ;
145
+ printf ("Write counter: %d, last write date %d/%d/%d\n\n" , common_info .write_counter , common_info .last_write_day , common_info .last_write_month , common_info .last_write_year );
146
+ }
147
+ }
148
+
149
+ u32 app_id = 0 ;
150
+ // Retrieve the admin info data, which contains the app id.
151
+ if (R_SUCCEEDED (rc )) {
152
+ NfpAdminInfo admin_info = {0 };
153
+ rc = nfpGetAdminInfo (& handle , & admin_info );
154
+
155
+ if (R_SUCCEEDED (rc )) {
156
+ app_id = admin_info .application_area_id ;
157
+ printf ("App area: 0x%x, game ID: 0x%lx, console: " , app_id , admin_info .application_id );
158
+ switch (admin_info .application_area_version ) {
159
+ case NfpApplicationAreaVersion_3DS :
160
+ printf ("Old 3ds" );
161
+ break ;
162
+ case NfpApplicationAreaVersion_WiiU :
163
+ printf ("Wii U" );
164
+ break ;
165
+ case NfpApplicationAreaVersion_3DSv2 :
166
+ printf ("New 3ds" );
167
+ break ;
168
+ case NfpApplicationAreaVersion_Switch :
169
+ printf ("Switch" );
170
+ break ;
171
+ case NfpApplicationAreaVersion_NotSet :
172
+ printf ("Not set" );
173
+ break ;
174
+ default :
175
+ printf ("0x%x" , admin_info .application_area_version );
176
+ break ;
177
+ }
178
+ printf ("\n" );
179
+ }
125
180
}
126
181
127
182
if (R_SUCCEEDED (rc )) {
@@ -134,13 +189,15 @@ Result process_amiibo(u32 app_id) {
134
189
}
135
190
136
191
u8 app_area [0xd8 ] = {0 }; // Maximum size of the application area.
192
+ u32 app_area_read_size = 0 ; // Actual number of bytes set by nfpGetApplicationArea.
137
193
if (app_area_size > sizeof (app_area )) app_area_size = sizeof (app_area );
138
194
if (R_SUCCEEDED (rc )) {
139
- rc = nfpGetApplicationArea (& handle , app_area , app_area_size );
195
+ rc = nfpGetApplicationArea (& handle , app_area , app_area_size , & app_area_read_size );
140
196
141
197
if (R_SUCCEEDED (rc )) {
142
- printf ("App area:\n" );
143
- print_hex (app_area , app_area_size );
198
+ printf ("App data:\n" );
199
+ print_hex (app_area , app_area_read_size );
200
+ printf ("\n" );
144
201
}
145
202
}
146
203
@@ -171,11 +228,7 @@ Result process_amiibo(u32 app_id) {
171
228
int main (int argc , char * argv [])
172
229
{
173
230
Result rc = 0 ;
174
-
175
- // Hardcoded for Super Smash Bros. Ultimate.
176
- // See also: https://switchbrew.org/wiki/NFC_services#Application_IDs
177
- u32 app_id = 0x34f80200 ;
178
-
231
+
179
232
// This example uses a text console, as a simple way to output text to the screen.
180
233
// If you want to write a software-rendered graphics application,
181
234
// take a look at the graphics/simplegfx example, which uses the libnx Framebuffer API instead.
@@ -194,7 +247,9 @@ int main(int argc, char* argv[])
194
247
consoleUpdate (NULL );
195
248
196
249
// Initialize the nfp:* service.
197
- rc = nfpInitialize (NfpServiceType_User );
250
+ // Use the NfpServiceType as required by your app, only use Debug if actually needed.
251
+ // This example uses nfpGetAdminInfo which is only available on the debug interface.
252
+ rc = nfpInitialize (NfpServiceType_Debug );
198
253
199
254
// Check if NFC is enabled. If not, wait until it is.
200
255
// Note that various official games don't use nfc*().
@@ -237,7 +292,7 @@ int main(int argc, char* argv[])
237
292
// padGetButtonsDown returns the set of buttons that have been
238
293
// newly pressed in this frame compared to the previous one
239
294
if (padGetButtonsDown (& pad ) & HidNpadButton_A ) {
240
- rc = process_amiibo (app_id );
295
+ rc = process_amiibo ();
241
296
242
297
// If an error happened, print it.
243
298
if (R_FAILED (rc ))
0 commit comments