Module ctr.uds

The uds module.

Used for 3DS-to-3DS wireless communication. The default wlancommID is 0x637472c2.

Usage:

    local uds = require("ctr.uds")

Functions

init ([context=0x3000[, username=3DS username]]) Initialize the UDS module.
shutdown () Disable the UDS module.
scan ([commID=0x637472c2[, id8=0[, hostMAC=all]]]) Scan for network beacons.
available () Check for data in the receive buffer.
receive ([size=maximum]) Return a packet from the receive buffer.
send (data[, nodeID=BROADCAST]) Send a packet to a node.
getNodesInfo () Return information about nodes in the networks
getAppData ([maxSize=0x4000]) Return the application data of the current network.

Constants

BROADCAST
HOST
CLIENT
SPECTATOR

Client part

connect (beacon[, passphrase=""[, conType=CLIENT[, nodeID=BROADCAST[, recvBuffSize=default[, dataChannel=1]]]]]) Connect to a network.
disconnect () Disconnect from the network.

Server part

createNetwork ([passphrase=""[, maxNodes=16[, commID=0x637472c2[, recvBuffSize=default[, dataChannel=1]]]]]) Create a network.
setAppData (appData) Set the application data of the created network.
destroyNetwork () Destroy the network.
ejectSpectators ([reallow=false]) Eject all the spectators connected to the network.
ejectClient ([nodeID=BROADCAST]) Eject a client connected to the network.

beaconScan

channel
mac
nodes
id8
networkID
allowSpectators
allowClients
:getAppData ([maxSize=0x4000]) Return the application data of the beacon


Functions

init ([context=0x3000[, username=3DS username]])
Initialize the UDS module.

Parameters:

  • context number size in bytes, must be a multiple of 0x1000 (default 0x3000)
  • username string UTF-8 username on the network (default 3DS username)

Returns:

    boolean true on success

Or

  1. boolean false on error
  2. number error code
shutdown ()
Disable the UDS module.
scan ([commID=0x637472c2[, id8=0[, hostMAC=all]]])
Scan for network beacons.

Parameters:

  • commID number application local-WLAN unique ID (default 0x637472c2)
  • id8 number additional ID to use different network types (default 0)
  • hostMAC string if set, only scan networks from this MAC address (format: XX:XX:XX:XX:XX:XX, with hexadecimal values) (default all)

Returns:

    table a table containing beacons objects

Or

  1. nil
  2. number/string error code
available ()
Check for data in the receive buffer.

Returns:

    boolean true if there is data to receive, false if not
receive ([size=maximum])
Return a packet from the receive buffer.

Parameters:

  • size number maximum size of the data to receive (default maximum)

Returns:

  1. string data, can be an empty string
  2. number source node, 0 if nothing has been received
send (data[, nodeID=BROADCAST])
Send a packet to a node.

Parameters:

  • data string data to send
  • nodeID number nodeID to send the packet to (default BROADCAST)
getNodesInfo ()
Return information about nodes in the networks

Returns:

    tablea table containing nodes informations, as tables (not userdatas). A node table is like: { username = "azerty", nodeID = 12 }
getAppData ([maxSize=0x4000])
Return the application data of the current network.

Parameters:

  • maxSize number maximum application data size to return (default 0x4000)

Returns:

    string application data

Constants

BROADCAST
  • BROADCAST broadcast node ID
HOST
  • HOST host node ID
CLIENT
  • CLIENT used to specify a connection as a client
SPECTATOR
  • SPECTATOR used to specify a connection as a spectator

Client part

connect (beacon[, passphrase=""[, conType=CLIENT[, nodeID=BROADCAST[, recvBuffSize=default[, dataChannel=1]]]]])
Connect to a network.

Parameters:

  • beacon beaconScan beacon to connect to
  • passphrase string passphrase for the network (default "")
  • conType number type of connection, can be CONTYPE_CLIENT or CONTYPE_SPECTATOR (default CLIENT)
  • nodeID number nodeID to receive data from (default BROADCAST)
  • recvBuffSize number size of the buffer that receives data (default default)
  • dataChannel number data channel of the network; this should be 1 (default 1)

Returns:

    boolean true on success

Or

  1. boolean false on error
  2. number error code
disconnect ()
Disconnect from the network.

Server part

createNetwork ([passphrase=""[, maxNodes=16[, commID=0x637472c2[, recvBuffSize=default[, dataChannel=1]]]]])
Create a network.

Parameters:

  • passphrase string passphrase of the network (default "")
  • maxNodes number maximum number of nodes that can be connected to the network, including the host (max 16) (default 16)
  • commID number application local-WLAN unique ID (default 0x637472c2)
  • recvBuffSize number size of the buffer that receives data (default default)
  • dataChannel number data channel of the network; this should be 1 (default 1)

Returns:

    boolean true on success

Or

  1. boolean false on error
  2. number error code
setAppData (appData)
Set the application data of the created network.

Parameters:

  • appData string application data

Returns:

    boolean true on success

Or

  1. boolean false on error
  2. number error code
destroyNetwork ()
Destroy the network.
ejectSpectators ([reallow=false])
Eject all the spectators connected to the network.

Parameters:

  • reallow boolean set to true to still allow the spectators to connect (default false)
ejectClient ([nodeID=BROADCAST])
Eject a client connected to the network.

Parameters:

  • nodeID number node ID of the client to eject, or BROADCAST for all the clients (default BROADCAST)

beaconScan

channel
  • channel integer Wifi channel of the beacon
mac
  • mac string MAC address of the beacon (mac for lowercase, MAC for uppercase)

Usage:

    beacon.mac -> ab:cd:ef:ab:cd:ef
    beacon.MAC -> AB:CD:EF:AB:CD:EF
nodes
  • nodes table a table containing nodes informations, as tables (not userdatas). A node table is like: { username = "azerty", nodeID = 12 }
id8
  • id8 number id8 of the beacon's network
networkID
  • networkID number random ID of the network
allowSpectators
  • allowSpectators boolean true if new spectators are allowed on the network
allowClients
  • allowClients boolean true if new clients are allowed on the network
:getAppData ([maxSize=0x4000])
Return the application data of the beacon

Parameters:

  • maxSize number maximum application data size to return (default 0x4000)

Returns:

    string application data

Or

  1. nil
  2. error code
generated by LDoc 1.4.3 Last updated 2017-06-05 14:35:27