Changes

Jump to navigation Jump to search
→‎Network protocols: Document out some of the Fuji RCD services
Line 150: Line 150:     
Note: The ports determined by the kart ID are actually assigned by the Switch and configured via the "Fuji Control" service. The kart itself will actually use any port it is told to use; shown above are how ''Home Circuit'' calculates the port numbers.
 
Note: The ports determined by the kart ID are actually assigned by the Switch and configured via the "Fuji Control" service. The kart itself will actually use any port it is told to use; shown above are how ''Home Circuit'' calculates the port numbers.
 +
 +
=== Handshaking ===
 +
 +
After the kart connects to the LP2P network and requests an IP address via DHCP, it connects to the RCD handshake service. The port it uses is determined by whether it is in pairing mode (i.e. it learned the network details from a QR code) or not. When pairing, it connects to port 5201, otherwise it uses port 5202. The RCD handshake is the same in either case.
 +
 +
Upon a successful RCD handshake, the handshake channel is left open. The kart will then open ports 5103 and 5107 (or, when pairing, only port 5106) and expect a single connection on each: The listening socket is closed once connection(s) are established to prevent multiple connections, and if connection(s) aren't made within 5 seconds of a completed handshake, the kart will reset its network connection (it closes all TCP connections, releases its IP back to DHCP, disassociates the wireless link, and starts the connection process anew). It will also reset the network connection in this manner if any RCD connection is lost/closed.
 +
 +
=== "Fuji Pairing" RCD service ===
 +
 +
The pairing service implements a single command, and is only available immediately after a handshake and when pairing. A network reset will occur if the connection is idle for 1 second.
 +
 +
==== Command 0x01: SetGroupInfo ====
 +
 +
Accepts a 0x40-byte payload:
 +
{| class="wikitable" border="1"
 +
|-
 +
! Offset
 +
! Size
 +
! Description
 +
|-
 +
| 0x00
 +
| 0x20
 +
| SSID, zero-terminated. ''Home Circuit'' copies this straight from GroupInfo, so uninitialized bytes may follow.
 +
|-
 +
| 0x20
 +
| 0x20
 +
| LP2P PSK
 +
|}
 +
 +
On success, responds with an empty payload. The kart commits these network settings to non-volatile memory immediately, replacing the old settings (if present). A network reset is initiated, and the kart exits pairing mode, using these newly-provided network settings after the reset. The Switch also exits pairing mode to accept the newly-paired kart.
 +
 +
=== "Fuji Control" RCD service ===
 +
 +
This service is used to set up and manage the kart. It is only available when not in pairing mode.
 +
 +
==== Command 0x01: GetSystemInfo ====
 +
 +
Takes no payload as input, returns:
 +
 +
{| class="wikitable" border="1"
 +
|-
 +
! Offset
 +
! Size
 +
! Description
 +
|-
 +
| 0x0
 +
| 0x1
 +
| boot_major_version
 +
|-
 +
| 0x1
 +
| 0x1
 +
| boot_minor_version
 +
|-
 +
| 0x2
 +
| 0x1
 +
| system_major_version
 +
|-
 +
| 0x3
 +
| 0x1
 +
| system_minor_version
 +
|-
 +
| 0x4
 +
| 0x29
 +
| Zero-terminated ASCII string which is a 160-bit value in hexadecimal. Appears to be some kind of SHA1.
 +
|}
 +
 +
==== Command 0x02: SetParam ====
 +
 +
Returns no output (on success) or error code 0x1060e8 if the parameter isn't recognized. Input:
 +
 +
{| class="wikitable" border="1"
 +
|-
 +
! Offset
 +
! Size
 +
! Description
 +
|-
 +
| 0x0
 +
| 0x80
 +
| Parameter name, zero-padded.
 +
|-
 +
| 0x80
 +
| 0x2
 +
| Value length
 +
|-
 +
| 0x82
 +
| 0xE
 +
| Zero padding to align to 0x10-byte boundary
 +
|-
 +
| 0x90
 +
| Varies
 +
| Value to set
 +
|}
 +
 +
Setting the parameter "connection_info" is required to prepare the kart to drive. It can only be set once (trying to set it again gives error 0x1040e8). It expects (all values little-endian):
 +
 +
{| class="wikitable" border="1"
 +
|-
 +
! Offset
 +
! Size
 +
! Description
 +
|-
 +
| 0x0
 +
| 0x2
 +
| Fixed 0x0001; unknown purpose.
 +
|-
 +
| 0x2
 +
| 0x2
 +
| Telemetry (UDP) port on Switch
 +
|-
 +
| 0x4
 +
| 0x2
 +
| "LSP" control (TCP) port on Switch
 +
|-
 +
| 0x6
 +
| 0x2
 +
| "LSP" video (UDP) port on Switch
 +
|-
 +
| 0x8
 +
| 0x8
 +
| Current network time, per nn::time::StandardNetworkSystemClock::GetCurrentTime. (A Unix timestamp with one-second precision.)
 +
|}
 +
 +
==== Command 0x03: GetParam ====
 +
 +
Returns the value of the parameter (on success) or error code 0x1060e8. Expected input:
 +
 +
{| class="wikitable" border="1"
 +
|-
 +
! Offset
 +
! Size
 +
! Description
 +
|-
 +
| 0x00
 +
| 0x80
 +
| Parameter name, zero-padded.
 +
|}
 +
 +
One known parameter is "product_code" which appears to include a string with the value of the white-label barcode on the bottom of the kart. Perhaps this is how ''Home Circuit'' distinguishes between Mario and Luigi.
 +
 +
==== Command 0x04: SetState ====
 +
 +
This sets the kart between drive mode and "parked" mode. "connection_info" must be set first; it will return error 0x1040e8 if not. Returns an empty payload on success. It expects:
 +
 +
{| class="wikitable" border="1"
 +
|-
 +
! Offset
 +
! Size
 +
! Description
 +
|-
 +
| 0x0
 +
| 0x1
 +
| Drive mode. 0x01 enables driving controls (and video), 0x00 puts the kart to "sleep."
 +
|-
 +
| 0x1
 +
| 0xF
 +
| Zero padding.
 +
|}
 +
 +
==== Command 0x12: ReadApplicationData ====
 +
 +
Expects 0x20-byte zero-padded application ID (''Home Circuit'' uses "YVCOQ00000000XFB") and retrieves data stored in the kart unique to the application.
    
= Versions =
 
= Versions =
30

edits

Navigation menu