pokeldn

pokeldn is an implementation of Nintendo Switch local wireless (LDN) that speaks to Pokemon games on retail Switch hardware through an ESP32 board as its radio, on USB serial from a computer or an Android phone or over Bluetooth from an iPhone. These pages document the protocols with decompilation citations, disassembly addresses and hardware measurements.

Start with app setup or command-line usage.

Targets

Seven games share the same LDN and Pia layers:

  FRLG LGPE SwSh BDSP PLA SV PLZA
Trade ✓ ✓ ✓ ✓ ✓ ✓ ✓
Mystery Gift ✓ ∅ ✓ ∅ ∅ ∅ ∅
Event Pokemon ✓ ✓ ✓ ✓ ✓ ✓ ✓
Link battle ✓ ✗ ✗ ✗ ∅ ✗ ✗
Code on the console, save read and write ✓ ✗ ✗ ✗ ✗ ✗ ✗

✓ works on a retail console · ✗ not done · ∅ the game has no such feature over local wireless FRLG FireRed/LeafGreen · LGPE Let’s Go Pikachu/Eevee · SwSh Sword/Shield · BDSP Brilliant Diamond/Shining Pearl · PLA Legends Arceus · SV Scarlet/Violet · PLZA Legends Z-A

FireRed and LeafGreen run as the GBA ROM inside the Switch’s emulator, so the ROM’s GBA link protocol sits on LDN and Pia. The six other games put their own code directly on Pia: Unity/IL2CPP in BDSP, C++ with protocol buffers over gflnet3 in SwSh and LGPE, and C++ with Pia statically linked in PLA, SV and PLZA.

Sections

section contents
The wireless layer LDN and Pia: advertisements, association, packet formats by version, session-key derivation.
Reverse-engineering a Switch title Reading a retail game’s own code: NCA/RomFS extraction in place, IL2CPP metadata, C++ RTTI.
FireRed and LeafGreen GBA link, Mystery Gift, code execution, RNG, cartridges.
Brilliant Diamond and Shining Pearl Pia 5.27-5.45, the Union Room, and the trade flow.
Sword and Shield Pia 4, sync framework, trade, Max Raids, Dynamax Adventures, Mystery Gift.
Let’s Go Pikachu and Eevee Pia 3, the link code, and the trade flow.
Legends Arceus Pia header version 11, trade flow, composed record.
Scarlet and Violet Pia header version 11, reliable streams, trade, Tera Raids, Union Circle.
Legends Z-A Pia header version 16 and the twenty trade messages.
Simulated Mystery Gifts Official gift Pokemon traded by the host to titles with no local Mystery Gift.
Command-line usage Source setup and commands for each game.
Desktop app Setup, Bank, controller, builds; Android and iOS.
Code organization Shared modules, Pokémon preparation and verification.
Hardware and setup The ESP32 radio, Switch keys, and legacy Linux Wi-Fi cards.
Code signing policy What the Windows release signs, the team roles, and the privacy policy.

Credits

Built on kinnay’s LDN library and the NintendoClients wiki, and read against pret/pokefirered, the FireRed/LeafGreen decompilation.