@@ -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,40 @@ 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
+ }
175
+ printf ("\n" );
176
+ }
125
177
}
126
178
127
179
if (R_SUCCEEDED (rc )) {
@@ -134,13 +186,15 @@ Result process_amiibo(u32 app_id) {
134
186
}
135
187
136
188
u8 app_area [0xd8 ] = {0 }; // Maximum size of the application area.
189
+ u32 app_area_read_size = 0 ; // Actual number of bytes set by nfpGetApplicationArea.
137
190
if (app_area_size > sizeof (app_area )) app_area_size = sizeof (app_area );
138
191
if (R_SUCCEEDED (rc )) {
139
- rc = nfpGetApplicationArea (& handle , app_area , app_area_size );
192
+ rc = nfpGetApplicationArea (& handle , app_area , app_area_size , & app_area_read_size );
140
193
141
194
if (R_SUCCEEDED (rc )) {
142
- printf ("App area:\n" );
143
- print_hex (app_area , app_area_size );
195
+ printf ("App data:\n" );
196
+ print_hex (app_area , app_area_read_size );
197
+ printf ("\n" );
144
198
}
145
199
}
146
200
@@ -171,11 +225,7 @@ Result process_amiibo(u32 app_id) {
171
225
int main (int argc , char * argv [])
172
226
{
173
227
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
-
228
+
179
229
// This example uses a text console, as a simple way to output text to the screen.
180
230
// If you want to write a software-rendered graphics application,
181
231
// take a look at the graphics/simplegfx example, which uses the libnx Framebuffer API instead.
@@ -194,7 +244,7 @@ int main(int argc, char* argv[])
194
244
consoleUpdate (NULL );
195
245
196
246
// Initialize the nfp:* service.
197
- rc = nfpInitialize (NfpServiceType_User );
247
+ rc = nfpInitialize (NfpServiceType_Debug );
198
248
199
249
// Check if NFC is enabled. If not, wait until it is.
200
250
// Note that various official games don't use nfc*().
@@ -237,7 +287,7 @@ int main(int argc, char* argv[])
237
287
// padGetButtonsDown returns the set of buttons that have been
238
288
// newly pressed in this frame compared to the previous one
239
289
if (padGetButtonsDown (& pad ) & HidNpadButton_A ) {
240
- rc = process_amiibo (app_id );
290
+ rc = process_amiibo ();
241
291
242
292
// If an error happened, print it.
243
293
if (R_FAILED (rc ))
0 commit comments