Skip to content
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

Add NFC functionality (for amiibos mainly) #82

Open
choss opened this issue Sep 13, 2020 · 16 comments · May be fixed by #110
Open

Add NFC functionality (for amiibos mainly) #82

choss opened this issue Sep 13, 2020 · 16 comments · May be fixed by #110

Comments

@choss
Copy link

choss commented Sep 13, 2020

Since we needed to do remove nfc in context of #80 we should implement it again.

For this we need to implement MCU emulation in joycontrol.
The relevant reading materials are

The second link describes the the subcommands somewhat. Also the crc8 at the end of each response is mentioned in the thread.

A proposed design would be doing the MCU as a state machine and perhaps hardcoding the relevant initialization responses, read an arbitraty length tag (also a state in the machine) and also be able to change the state back to init/etc based on the subcomands.

Is somebody working on this already?
I am no python expert but would like to help.

@Kagenokami
Copy link

Any news on this? I downloaded this application solely for the NFC amiibo support, without this functionality the the time I spent getting it to work on my device was essentially wasted. :/

@Poohl
Copy link

Poohl commented Nov 5, 2020

Hi, yes I'm working on it.
My current implementation is still rather hacky but is capable of simulating the tag good enough to have the switch read it successfully and afterwards return to regular input.
See https://github.com/Poohl/joycontrol/tree/amiibo_edits for the implementation.
The implementation doesn't really use a state-automata yet, since I haven't figured out enough transitions and is also barely tested.
I tested only using Splatoon2, the PRO_CONTROLLER setting, my laptop's (acer spin 5) builtin bluetooth, bluez5.53 (5.55 seemed to not work) and an Amiibo-dump I found online. This means I haven't yet verified that Amiibos with registered owners work, since I didn't yet manage to get mine dumped.
So if anyone wants to help, testing would be greatly appreciated and/or figuring out how writing to amiibos works.

Another great resource I found:
https://github.com/CTCaer/jc_toolkit/blob/5.2.0/jctool/jctool.cpp at c.a. line 2523

@edwardsaunders7
Copy link

Any updates on NFC Support?

@Poohl
Copy link

Poohl commented Dec 9, 2020

I just created a pull request. I got it working simulation a Pro controller. But since only read works I cannot yet verify it actually working in game (it just asks me to register a user)

@choss
Copy link
Author

choss commented Dec 9, 2020

Cool stuff! Let me grab your branch soon(tm) and test this out with some good ACNH

@JobSoltero
Copy link

Ill be testing this weekend too, on skyrim.

@corndog2000
Copy link

corndog2000 commented Jan 31, 2021

How do you load an NFC file with your fork of the code?

@Poohl
Copy link

Poohl commented Jan 31, 2021

@JobSoltero How do you load an NFC file with your fork of the code?

either at startup add the --nfc <path_to_the_bin_dump> option or in the terminal use nfc <path_to_the_bin_dump> command.

@Poohl
Copy link

Poohl commented Jan 31, 2021

Ok, general update: I tested BOTW, and since you don't have to register an owner there for some reason, it just works.

I also started on supporting writing amiibos and wrote a wireshark plugin to dissect them. If anyone wants to help dissecting captures from the proxys that write to amiibos: NXBT wireshark Plugin

The "write too amiibo" command seems to be nxbt.mcu.subc == 0x08

EDIT: Here is what I think I got right with the protocoll by now: https://gist.github.com/Poohl/e0f254b3e02051b18c7e9f4f032883be

@corndog2000
Copy link

@Poohl Those commands don't seem to work. I get errors that send me back to github #80. Using the argument I get a bunch of errors saying:
[14:30:44] joycontrol.protocol input_report_mode_full::172 WARNING - NFC communictation is not implemented.

@Poohl
Copy link

Poohl commented Jan 31, 2021

which branch are you on? the changes are on amiibo_edits

@NaomiGt
Copy link

NaomiGt commented Feb 5, 2021

Hey, is it possible to register the amiibo? for example in splatoon 2? I am using a random bin file i found right now and i was hoping you knew what to do.

@Poohl
Copy link

Poohl commented Feb 5, 2021

I'm working on that. Not yet, sadly. For registering an Amiibo writing to them needs to be supported but whilst I am confident the core part works as I posted above in the gist, I assume that there is a lot more subtle stuff we havent't figured out. Also I didn't have time to test this yet.

@NaomiGt
Copy link

NaomiGt commented Feb 5, 2021

I got it working after hours of messing around with different branches. But for me its working perfectly now, really quick and the nfc is great on acnh and works on botw & age of calamity too. Thanks for the work you put in :)

@Poohl
Copy link

Poohl commented Feb 20, 2021

Update on writing: I can get the switch to transfer the entire write-request, but since I have no capture of what should happen next the transaction dies after that. I'm trying to get a capture of that using the proxy, but I had no luck yet.

@Poohl
Copy link

Poohl commented Mar 21, 2021

Amazing news: It kinda works. I figured out how to edit the dump to make it be valid despite the filed write. The edits are on another branch: amiibo_writing (Use git checkout amiibo_writing after you have cloned the repo to get there)

I opened another Pull request as WIP for this, see #102 for instructions on how to use it.

@Poohl Poohl linked a pull request May 11, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants