DSWifi
Loading...
Searching...
No Matches
Macros | Enumerations | Functions
General state of the library.

Macros

#define INIT_ONLY   (0 << 0)
 Init library only, don't try to connect to AP. Used by Wifi_InitDefault().
 
#define WFC_CONNECT   (1 << 0)
 Init library and try to connect to firmware AP. Used by Wifi_InitDefault().
 
#define WIFI_DISABLE_LED   (1 << 1)
 Don't let the library control the LED blinking.
 
#define WIFI_ENABLE_LED   (0 << 1)
 Allow the library to control how the LED blinks (DS and DS Lite only).
 
#define WIFI_INTERNET_AND_LOCAL   (0 << 2)
 Initialize both internet and local multiplayer modes.
 
#define WIFI_LOCAL_ONLY   (1 << 2)
 Only initialize local multiplayer mode.
 

Enumerations

enum  WIFIGETDATA {
  WIFIGETDATA_MACADDRESS ,
  WIFIGETDATA_NUMWFCAPS ,
  WIFIGETDATA_RSSI ,
  MAX_WIFIGETDATA
}
 User code uses members of the WIFIGETDATA structure in calling Wifi_GetData() to retreive miscellaneous odd information. More...
 

Functions

int Wifi_CheckInit (void)
 Used to determine if the library has been initialized.
 
bool Wifi_Deinit (void)
 Stops the WiFi library.
 
void Wifi_DisableWifi (void)
 Instructs the ARM7 to disengage wireless and stop receiving or transmitting.
 
void Wifi_EnableWifi (void)
 Instructs the ARM7 to go into a basic "active" mode.
 
int Wifi_GetData (int datatype, int bufferlen, unsigned char *buffer)
 Retrieve an arbitrary or misc. piece of data from the WiFi hardware.
 
u32 Wifi_GetStats (int statnum)
 Retreive an element of the WiFi statistics gathered.
 
void Wifi_IdleMode (void)
 Sets the WiFI hardware in "active" mode.
 
bool Wifi_InitDefault (unsigned int flags)
 Initializes WiFi library.
 
bool Wifi_LibraryModeReady (void)
 Checks whether a library mode change has finished or not.
 
void Wifi_SetChannel (int channel)
 If the WiFi system is not connected or connecting to an access point, instruct the chipset to change channel.
 
void Wifi_SetPromiscuousMode (int enable)
 Allows the DS to enter or leave a "promsicuous" mode.
 
void Wifi_Timer (int num_ms)
 This function should be called in a periodic interrupt.
 

Detailed Description

Macro Definition Documentation

◆ WIFI_INTERNET_AND_LOCAL

#define WIFI_INTERNET_AND_LOCAL   (0 << 2)

Initialize both internet and local multiplayer modes.

Both internet and local multiplayer modes become available.

◆ WIFI_LOCAL_ONLY

#define WIFI_LOCAL_ONLY   (1 << 2)

Only initialize local multiplayer mode.

DSWiFi is initialized, but Internet mode becomes unavailable. DSWiFi won't need to allocate any memory on the heap for the IP stack (sgIP).

If your game only uses local multiplayer mode, you can use this option to save RAM.

Enumeration Type Documentation

◆ WIFIGETDATA

User code uses members of the WIFIGETDATA structure in calling Wifi_GetData() to retreive miscellaneous odd information.

Enumerator
WIFIGETDATA_MACADDRESS 

MACADDRESS: returns data in the buffer, requires at least 6 bytes.

WIFIGETDATA_NUMWFCAPS 

NUM WFC APS: returns number between 0 and 3, doesn't use buffer.

WIFIGETDATA_RSSI 

RSSI: returns number between 0 and 255, doesn't use buffer.

Function Documentation

◆ Wifi_CheckInit()

int Wifi_CheckInit ( void  )

Used to determine if the library has been initialized.

Returns
1 if the library is ready, 0 otherwise.

◆ Wifi_Deinit()

bool Wifi_Deinit ( void  )

Stops the WiFi library.

It will free all RAM and resources used by the library.

It must be called after calling Wifi_DisableWifi() and waiting for a frame or two.

Returns
True on success, false on error.

◆ Wifi_DisableWifi()

void Wifi_DisableWifi ( void  )

Instructs the ARM7 to disengage wireless and stop receiving or transmitting.

It keeps the library active. If you want to free all resources used by the library, call Wifi_Deinit().

◆ Wifi_EnableWifi()

void Wifi_EnableWifi ( void  )

Instructs the ARM7 to go into a basic "active" mode.

The hardware is powered on, but not associated or doing anything useful. It can still receive and transmit packets.

◆ Wifi_GetData()

int Wifi_GetData ( int  datatype,
int  bufferlen,
unsigned char *  buffer 
)

Retrieve an arbitrary or misc. piece of data from the WiFi hardware.

See the WIFIGETDATA enum.

Parameters
datatypeElement from the WIFIGETDATA enum specifing what kind of data to get.
bufferlenLength of the buffer to copy data to (not always used)
bufferBuffer to copy element data to (not always used)
Returns
-1 for failure, the number of bytes written to the buffer, or the value requested if the buffer isn't used.

◆ Wifi_GetStats()

u32 Wifi_GetStats ( int  statnum)

Retreive an element of the WiFi statistics gathered.

Parameters
statnumElement from the WIFI_STATS enum, indicating what statistic to return.
Returns
The requested stat, or 0 for failure.

◆ Wifi_IdleMode()

void Wifi_IdleMode ( void  )

Sets the WiFI hardware in "active" mode.

The hardware is powered on, but not associated or doing anything useful. It can still receive and transmit packets.

◆ Wifi_InitDefault()

bool Wifi_InitDefault ( unsigned int  flags)

Initializes WiFi library.

It initializes the WiFi hardware, sets up a FIFO handler to communicate with the ARM7 side of the library, and it sets up timer 3 to be used by DSWiFi.

You can pass a few options depending on your needs:

  • If INIT_ONLY is passed, the library will be initialized but it won't try to connect to any AP yet. When using local multiplayer you should start with this flag.

    If WFC_CONNECT is used, this function will initialize the hardware and try to connect to the Access Points stored in the firmware. Wifi_InitDefault() will refuse to initiailize the library if you use this flag at the same time as WIFI_LOCAL_ONLY.

  • WIFI_DISABLE_LED and WIFI_ENABLE_LED can be used to let DSWiFi control the LED or not. By default, DSWiFi makes the LED blink at different speeds depending on the current state of the library.
  • By default, DSWiFi is initialized in a way that both Internet and local multiplayer mode are available. You can decide if Internet mode is available or not by using the defines WIFI_INTERNET_AND_LOCAL and WIFI_LOCAL_ONLY.

    The function starts the library in Internet mode if it's available. If it is initialized with WIFI_LOCAL_ONLY it starts in multiplayer client mode. The developer needs to be switch to other modes if required. Remember that there are two local multiplayer modes: client and host.

Note
WFC_CONNECT is generally discouraged outside of simple demos because Wifi_InitDefault() can't return for a few seconds until the connection has succeeded or failed. Also, it doesn't let the user select an AP, or change the password. It relies on official games setting up an AP in the firmware settings.

Check the examples of DSWiFi to see how to connect to an AP in a more manual way that allows your application to do other things while waiting for the function to return.

Parameters
flagsThis is a combination of OR'ed flags.
Returns
It returns true on success, false on failure.

◆ Wifi_LibraryModeReady()

bool Wifi_LibraryModeReady ( void  )

Checks whether a library mode change has finished or not.

Use this function after calling Wifi_MultiplayerHostMode(), Wifi_MultiplayerClientMode() or Wifi_InternetMode() to verify that the library is ready.

Returns
It returns true if the mode change has finished, false otherwise.

◆ Wifi_SetChannel()

void Wifi_SetChannel ( int  channel)

If the WiFi system is not connected or connecting to an access point, instruct the chipset to change channel.

The WiFi system must be in "active" mode for this to work as expected. If it is in scanning mode, it will change channel automatically every second or so.

Parameters
channelThe channel to change to, in the range of 1-13.

◆ Wifi_SetPromiscuousMode()

void Wifi_SetPromiscuousMode ( int  enable)

Allows the DS to enter or leave a "promsicuous" mode.

In this mode all data that can be received is forwarded to the ARM9 for user processing. Best used with Wifi_RawSetPacketHandler, to allow user code to use the data (well, the lib won't use 'em, so they're just wasting CPU otherwise.)

Parameters
enable0 to disable promiscuous mode, nonzero to engage.

◆ Wifi_Timer()

void Wifi_Timer ( int  num_ms)

This function should be called in a periodic interrupt.

It serves as the basis for all updating in the sgIP library, all retransmits, timeouts, and etc are based on this function being called. It's not timing critical but it is rather essential.

Parameters
num_msThe number of milliseconds since the last time this function was called.