DSWifi
|
Typedefs | |
typedef void(* | WifiFromClientPacketHandler) (Wifi_MPPacketType, int, int, int) |
Handler of WiFI packets received on the host from a client. | |
typedef void(* | WifiFromHostPacketHandler) (Wifi_MPPacketType, int, int) |
Handler of WiFI packets received on a client from the host. | |
Enumerations | |
enum | Wifi_MPPacketType { WIFI_MPTYPE_INVALID = -1 , WIFI_MPTYPE_CMD = 0 , WIFI_MPTYPE_REPLY = 1 , WIFI_MPTYPE_DATA = 2 } |
Possible types of packets received by multiplayer handlers. More... | |
Functions | |
int | Wifi_BeaconStart (const char *ssid, u32 game_id) |
Sends a beacon frame to the ARM7 to be used in multiplayer host mode. | |
void | Wifi_MultiplayerAllowNewClients (bool allow) |
Allows or disallows new clients to connect to this console acting as host. | |
int | Wifi_MultiplayerClientMode (size_t client_packet_size) |
Sets the WiFI hardware in mulitplayer client mode. | |
int | Wifi_MultiplayerClientReplyTxFrame (const void *data, u16 datalen) |
Prepares a multiplayer client reply frame to be sent. | |
int | Wifi_MultiplayerClientToHostDataTxFrame (const void *data, u16 datalen) |
Sends a data frame to the host. | |
void | Wifi_MultiplayerFromClientSetPacketHandler (WifiFromClientPacketHandler func) |
Set a handler on a host console for packets received from clients. | |
void | Wifi_MultiplayerFromHostSetPacketHandler (WifiFromHostPacketHandler func) |
Set a handler on a client console for packets received from the host. | |
u16 | Wifi_MultiplayerGetClientMask (void) |
Returns a mask where each bit represents an connected client. | |
int | Wifi_MultiplayerGetClients (int max_clients, Wifi_ConnectedClient *client_data) |
Get information of clients connected to a multiplayer host. | |
int | Wifi_MultiplayerGetNumClients (void) |
Get the number of clients connected to this DS acting as a multiplayer host. | |
int | Wifi_MultiplayerHostCmdTxFrame (const void *data, u16 datalen) |
Sends a multiplayer host frame. | |
int | Wifi_MultiplayerHostMode (int max_clients, size_t host_packet_size, size_t client_packet_size) |
Sets the WiFI hardware in mulitplayer host mode. | |
void | Wifi_MultiplayerHostName (const void *buffer, u8 len) |
Set the name and name length fields in beacon packets. | |
int | Wifi_MultiplayerHostToClientDataTxFrame (int aid, const void *data, u16 datalen) |
Sends a data frame to the client with the specified association ID. | |
void | Wifi_MultiplayerKickClientByAID (int association_id) |
Kick the client with the provided AID from the host. | |
typedef void(* WifiFromClientPacketHandler) (Wifi_MPPacketType, int, int, int) |
Handler of WiFI packets received on the host from a client.
The first argument is the packet type.
The second argument is the association ID of the client that sent this packet. The third argument is the packet address. It is only valid while the called function is executing. The fourth argument is packet length.
Call Wifi_RxRawReadPacket(adddress, length, buffer) while in the packet handler function to retreive the data to a local buffer.
Only user data of packets can be read from this handler, not the IEEE 802.11 header.
typedef void(* WifiFromHostPacketHandler) (Wifi_MPPacketType, int, int) |
Handler of WiFI packets received on a client from the host.
The first argument is the packet type.
The second argument is the packet address. It is only valid while the called function is executing. The third argument is the packet length.
Call Wifi_RxRawReadPacket(adddress, length, buffer) while in the packet handler function to retreive the data to a local buffer.
Only user data of packets can be read from this handler, not the IEEE 802.11 header.
enum Wifi_MPPacketType |
int Wifi_BeaconStart | ( | const char * | ssid, |
u32 | game_id | ||
) |
Sends a beacon frame to the ARM7 to be used in multiplayer host mode.
This beacon frame announces that this console is acting as an access point (for example, to act as a host of a multiplayer group). Beacon frames are be sent periodically by the hardware, you only need to call this function once. If you call Wifi_SetChannel(), the beacon will start announcing the presence of the AP in the new channel.
Beacon packets need to be sent regularly while in AP mode. When leaving AP mode, DSWifi will stop sending them automatically.
ssid | SSID to use for the access point. |
game_id | A 32-bit game ID included in beacon frames. It is used to identify which access points belong to Nintendo DS devices acting as multiplayer hosts of a game. Official games use IDs of the form 0x0040yyyy (except for Nintendo Zone: 0x00000857). |
void Wifi_MultiplayerAllowNewClients | ( | bool | allow | ) |
Allows or disallows new clients to connect to this console acting as host.
By default, clients can connect to the host when in host mode. You should disable new connections once you have enough players connected to you, and you aren't expecting new connections.
Disabling new connections will kick all clients that are in the process of associating to this host but haven't finished the process.
allow | If true, allow new connections. If false, reject them. |
int Wifi_MultiplayerClientMode | ( | size_t | client_packet_size | ) |
Sets the WiFI hardware in mulitplayer client mode.
Use Wifi_LibraryModeReady() to check when the mode change is finished.
The size used in this function is only the size of the custom data sent by the application. The size of the headers is added internally by the library.
client_packet_size | Size of the user data sent in packets from the client to the host. |
int Wifi_MultiplayerClientReplyTxFrame | ( | const void * | data, |
u16 | datalen | ||
) |
Prepares a multiplayer client reply frame to be sent.
This frame will be sent to the host as soon as a CMD frame is received.
Hosts can use Wifi_MultiplayerFromClientSetPacketHandler() to register a packet handler for packets sent with Wifi_MultiplayerClientReplyTxFrame(). They will be received with type WIFI_MPTYPE_REPLY.
data | Pointer to the data to be sent. |
datalen | Size of the data in bytes. It can go up to the size defined when calling Wifi_MultiplayerHostMode() and Wifi_MultiplayerClientMode(). |
int Wifi_MultiplayerClientToHostDataTxFrame | ( | const void * | data, |
u16 | datalen | ||
) |
Sends a data frame to the host.
This function sends an arbitrary data packet without waiting for any packet sent by the host.
Hosts can use Wifi_MultiplayerFromClientSetPacketHandler() to register a packet handler for packets sent with Wifi_MultiplayerClientToHostDataTxFrame(). They will be received with type WIFI_MPTYPE_DATA.
data | Pointer to the data to be sent. |
datalen | Size of the data in bytes. |
void Wifi_MultiplayerFromClientSetPacketHandler | ( | WifiFromClientPacketHandler | func | ) |
Set a handler on a host console for packets received from clients.
func | Pointer to packet handler (see WifiFromClientPacketHandler for info). |
void Wifi_MultiplayerFromHostSetPacketHandler | ( | WifiFromHostPacketHandler | func | ) |
Set a handler on a client console for packets received from the host.
func | Pointer to packet handler (see WifiFromHostPacketHandler for info). |
u16 Wifi_MultiplayerGetClientMask | ( | void | ) |
Returns a mask where each bit represents an connected client.
Bit 0 is always set to 1 as it represents the host. Bits 1 to 15 represent all possible clients.
The bits are set to 1 when the client is authenticated and associated.
This function must be used while in multiplayer host mode.
int Wifi_MultiplayerGetClients | ( | int | max_clients, |
Wifi_ConnectedClient * | client_data | ||
) |
Get information of clients connected to a multiplayer host.
This function must be used while in multiplayer host mode.
This function expects you to pass an empty array of clients in client_data with a length of max_clients. It will check the current list of clients connected to this host and save them to the array, up to max_clients. It returns the actual number of clients saved to the struct.
max_clients | Maximum number of clients that can be stored in client_data. |
client_data | Pointer to an array type Wifi_ConnectedClient that has a length of at least max_clients. |
int Wifi_MultiplayerGetNumClients | ( | void | ) |
Get the number of clients connected to this DS acting as a multiplayer host.
Clients are considered connected when they are authenticated and associated.
This function must be used while in multiplayer host mode.
int Wifi_MultiplayerHostCmdTxFrame | ( | const void * | data, |
u16 | datalen | ||
) |
Sends a multiplayer host frame.
This frame will be sent to all clients, and clients will reply automatically if they have prepared any reply frame.
Clients can use Wifi_MultiplayerFromHostSetPacketHandler() to register a packet handler for packets sent with Wifi_MultiplayerHostCmdTxFrame(). They will be received with type WIFI_MPTYPE_CMD.
data | Pointer to the data to be sent. |
datalen | Size of the data in bytes. It can go up to the size defined when calling Wifi_MultiplayerHostMode(). |
int Wifi_MultiplayerHostMode | ( | int | max_clients, |
size_t | host_packet_size, | ||
size_t | client_packet_size | ||
) |
Sets the WiFI hardware in mulitplayer host mode.
While in host mode, call Wifi_BeaconStart() to start announcing that this DS is acting as an access point. This will allow other consoles to connect discover it and connect to it.
Use Wifi_LibraryModeReady() to check when the mode change is finished.
The sizes used in this function are only the size of the custom data sent by the application. The size of the headers is added internally by the library.
max_clients | Maximum number of allowed clients connected to the console. The minimum is 1, the maximum is 15. |
host_packet_size | Size of the user data sent in packets from the host to the client. |
client_packet_size | Size of the user data sent in packets from the client to the host. |
void Wifi_MultiplayerHostName | ( | const void * | buffer, |
u8 | len | ||
) |
Set the name and name length fields in beacon packets.
This information can be obtained from clients from the "name" and "name_len" fields of the "nintendo" struct in a Wifi_AccessPoint. DSWifi doesn't use this information in any way, so you are free to store any information you want here. Normally, a client would use this field to display the name of each DS that is in multiplayer host mode.
If you use this function to overwrite the default values of DSWifi, you need to do it before calling Wifi_BeaconStart().
This function will copy exactly DSWIFI_BEACON_NAME_SIZE bytes from "buffer". By default, DSWifi uses the player name stored in the DS firmware, so the format is UTF-16LE.
The "len" argument is copied directly to the beacon information, it isn't used by this function to determine how much data to copy.
buffer | Source buffer to be copied to the "name" field of the beacon packet. It must be DSWIFI_BEACON_NAME_SIZE bytes in size. |
len | Value to be copied to the "name_len" field of the beacon packet. |
int Wifi_MultiplayerHostToClientDataTxFrame | ( | int | aid, |
const void * | data, | ||
u16 | datalen | ||
) |
Sends a data frame to the client with the specified association ID.
This function sends an arbitrary data packet that doesn't trigger any response.
Clients can use Wifi_MultiplayerFromHostSetPacketHandler() to register a packet handler for packets sent with Wifi_MultiplayerHostToClientDataTxFrame(). They will be received with type WIFI_MPTYPE_DATA.
aid | Association ID of the client that will receive the packet. |
data | Pointer to the data to be sent. |
datalen | Size of the data in bytes. |
void Wifi_MultiplayerKickClientByAID | ( | int | association_id | ) |
Kick the client with the provided AID from the host.
association_id | The AID of the client to kick. |