-
Notifications
You must be signed in to change notification settings - Fork 194
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NFC #49
Comments
Hey, The problem here is that IR and NFC are a bit unexplored waters. Now that we have better homebrew, experimenting with IR and NFC natively will be a thing. But for now, that's most of the info we have. |
In the process of trying to reproduce what the joycon normally receives when using NFC, I've been working through some of the commands sent. I found something odd: the acknowledgement packet for the 0x04 and 0x21 subcommands doesn't use the byte 12 (byte 12 based on this table} of subcommand + 0x80, but is one less (0xa0 to ack 0x21, 0x83 to ack 0x04)? |
Well I should had clarified that.. So lets say switch sent a x01 output report with a cmd.
So as you understand from the above, because most of the times, the AC_ has_data portion of byte[12] is the same with the subcmd, we misunderstood it at first. But this portion says what type of data the reply has |
Created a PR to explain the ACK byte. |
That is awesome, thanks! |
I've made progress with NFC. I have swift code in the aforementioned expecimal project, but the series of commands is something like
Next up: token auth, reading, and writing. |
Probably worth also noting that the amiibo use 7 byte UIDs, and the UID in the input data has a 0x07 prefix to indicate that, and MIFARE classic tokens with 4 byte UIDs are also supported (prefixed 0x04). This is not surprising since Skylanders Imaginators for Nintendo Switch uses the joycon to read the figures, and these figures are effectively MIFARE classic 1k tokens (their SAK is non-standard, so most readers won't read them). This also means that both NTAG PWD (4 bytes) based authentication as well as MIFARE classic keyA (6 bytes) must be supported within these commands somehow. |
Great job! we now know way more. I'll comment your bullets with the info I learned from poking in IR config:
The header for IR data is simple. And it's similar with NFC in a certain point. Now in IR, you request the packets specifically. You want the first 1st? you just send x11 id x3 subcmd. x11 output report, subcmd x03: So, you need to send When the controller stards sending the same packet again again you send the simple x11cmd x03 subcmd to start a new series of fragments request. |
Some info on the mcu registers: Another theory is that the 0x01 at the register is the size of the register. These probably correlate to NFC registers write also. EDIT: |
@bettse Additionally, I didn't saw anything else changing. Maybe because I tried an empty tag? Did you figure out anything else? |
I got distracted by another project, so I haven't done anything new with this, but interesting finds. |
I played with it a bit more this evening and found that the command that starts I think the In my case, the token(amiibo) has UID 04d4b142544980, so the command to the controller was In the response to this (the 0x3a that contains the token data), it does repeat the same |
I tried with a second amiibo and got its data back, and then remembered that the amiibo PWD, as I recall, is only necessary for /writing/, no auth is required for reading. |
I played with skylanders imaginators a bit in case it might provide another perspective. the skylanders tokens use a 4 byte uid. the game sent 4 commands that provide the controller with the "Key A"s (like the PWD, but for Mifare Classic) for some of the sectors. the ordering was a little weird to me.
I added the spacing to make a few pieces clear. the hypen is because the last byte ( so the command is 0x60 is the command for mifare authentication with the "A" key [1], and So my theory is that the data is [0x60] [Key] [block #]. For example, sector 1's key a is The ordering is mixed up, going for blocks 0, 1, 7, 2, 3, etc, but I think that's based on what initial data the game wants out of the token (for example, to determine what generation of token it is since skylanders has published something like 6 editions of the game). Dunno what [1] https://github.com/adafruit/Adafruit-PN532/blob/master/Adafruit_PN532.h#L100 |
Great findings.
Also about the reply (here's an x2a example, I don't know if it is the same with 3a): More about cmds: Also about your findings for mifare: About the d00736: |
So d0 07 36: I'm still trying to find the xd007. I'll update this comment if I have more info |
@bettse Can you sent some samples? (remove uid with |
I dumped a scan of an amiibo before I realized it was the wrong one to answer your question: https://gist.github.com/bettse/dbbe62ec853a2a5111a61a4869d17753 I haven't messed with this stuff for a few weeks, but I don't think I ever got to the point where my application would make the mifare classic read requests to the controller. |
@bettse (it also includes an answer to my question, but for ntags.) |
@bettse Many bytes are already known. So the communication was probably interrupted. If you ever find some time, please send me a full log of:
Thank you a lot! |
Hello People, I am piggy bagging on to this discussion I was checking the NFC communication and Thanks for the ideas / help |
I'm interested in how the joycon does NFC. I've written my own code[1] to do the basics (set player LED, vibrate, change input remote mode), but I've been struggling to get NFC data. When setting the input report mode to 0x31, it still get all 0’s for the data after the standard HID data. There is a note on the docs about this, "31 input report has all zeroes for IR/NFC data if a 11 ouput report with subcmd 03 00 or 03 01 or 03 02 was not sent before.”, but I’ve tried variations of a 0x11 command with a 0x03 subcommand and still seen any progress (both trying it before changing the input mode, and after). It is also unclear from the notes of the 0x11 command has the same format as the 0x01 command, so its possible I’m putting the subcommand byte in the wrong location.
Do I have the format of the 0x11 command wrong, or does anyone happen to know a minimal sequence of commands to get NFC data to start flowing? I've worked with NFC before[2], so I'm confident that I can work with the data once it starts flowing.
[1]
https://github.com/bettse/expecimal(https://gitlab.com/bettse/expecimal)[2] https://github.com/bettse/FS13_nfc_tag_reader/blob/master/device.nut#L226-L253
The text was updated successfully, but these errors were encountered: