DSWifi
|
ARM9 header of DSWifi. More...
#include "dswifi_version.h"
Data Structures | |
struct | WIFI_ACCESSPOINT |
Structure that defines how to connect to an access point. More... | |
Macros | |
#define | INIT_ONLY false |
Initi library only, don't try to connect to AP. Used by Wifi_InitDefault(). | |
#define | WFC_CONNECT true |
Init library and try to connect to firmware AP. Used by Wifi_InitDefault(). | |
Typedefs | |
typedef struct WIFI_ACCESSPOINT | Wifi_AccessPoint |
Structure that defines how to connect to an access point. | |
typedef void(* | WifiPacketHandler) (int, int) |
Wifi Packet Handler function. | |
typedef void(* | WifiSyncHandler) (void) |
Wifi Sync Handler function. | |
Enumerations | |
enum | WEPMODES { WEPMODE_NONE = 0 , WEPMODE_40BIT = 1 , WEPMODE_128BIT = 2 } |
Supported WEP modes. More... | |
enum | WIFI_ASSOCSTATUS { ASSOCSTATUS_DISCONNECTED , ASSOCSTATUS_SEARCHING , ASSOCSTATUS_AUTHENTICATING , ASSOCSTATUS_ASSOCIATING , ASSOCSTATUS_ACQUIRINGDHCP , ASSOCSTATUS_ASSOCIATED , ASSOCSTATUS_CANNOTCONNECT } |
Returned by Wifi_AssocStatus() after calling Wifi_ConnectAPk. More... | |
enum | WIFI_RETURN { WIFI_RETURN_OK = 0 , WIFI_RETURN_LOCKFAILED = 1 , WIFI_RETURN_ERROR = 2 , WIFI_RETURN_PARAMERROR = 3 } |
Error codes for Wifi_GetAPData() More... | |
enum | WIFI_STATS { WSTAT_RXQUEUEDPACKETS , WSTAT_TXQUEUEDPACKETS , WSTAT_RXQUEUEDBYTES , WSTAT_TXQUEUEDBYTES , WSTAT_RXQUEUEDLOST , WSTAT_TXQUEUEDREJECTED , WSTAT_RXPACKETS , WSTAT_RXBYTES , WSTAT_RXDATABYTES , WSTAT_TXPACKETS , WSTAT_TXBYTES , WSTAT_TXDATABYTES , WSTAT_ARM7_UPDATES , WSTAT_DEBUG , WSTAT_HW_1B0 , WSTAT_HW_1B1 , WSTAT_HW_1B2 , WSTAT_HW_1B3 , WSTAT_HW_1B4 , WSTAT_HW_1B5 , WSTAT_HW_1B6 , WSTAT_HW_1B7 , WSTAT_HW_1B8 , WSTAT_HW_1B9 , WSTAT_HW_1BA , WSTAT_HW_1BB , WSTAT_HW_1BC , WSTAT_HW_1BD , WSTAT_HW_1BE , WSTAT_HW_1BF , WSTAT_HW_1C0 , WSTAT_HW_1C1 , WSTAT_HW_1C4 , WSTAT_HW_1C5 , WSTAT_HW_1D0 , WSTAT_HW_1D1 , WSTAT_HW_1D2 , WSTAT_HW_1D3 , WSTAT_HW_1D4 , WSTAT_HW_1D5 , WSTAT_HW_1D6 , WSTAT_HW_1D7 , WSTAT_HW_1D8 , WSTAT_HW_1D9 , WSTAT_HW_1DA , WSTAT_HW_1DB , WSTAT_HW_1DC , WSTAT_HW_1DD , WSTAT_HW_1DE , WSTAT_HW_1DF , NUM_WIFI_STATS } |
List of available WiFi statistics. More... | |
enum | WIFIGETDATA { WIFIGETDATA_MACADDRESS , WIFIGETDATA_NUMWFCAPS , MAX_WIFIGETDATA } |
User code uses members of the WIFIGETDATA structure in calling Wifi_GetData to retreive miscellaneous odd information. More... | |
Functions | |
int | Wifi_AssocStatus (void) |
Returns information about the status of connection to an AP. | |
void | Wifi_AutoConnect (void) |
Connect to an Access Point specified by the WFC data in the firmware. | |
int | Wifi_CheckInit (void) |
Verifies when the ARM7 has been successfully initialized. | |
int | Wifi_ConnectAP (Wifi_AccessPoint *apdata, int wepmode, int wepkeyid, unsigned char *wepkey) |
Connect to an Access Point. | |
void | Wifi_DisableWifi (void) |
Instructs the ARM7 to disengage wireless and stop receiving or transmitting. | |
int | Wifi_DisconnectAP (void) |
Disassociate from the Access Point. | |
void | Wifi_EnableWifi (void) |
Instructs the ARM7 to go into a basic "active" mode, not actually associated to an AP, but actively receiving and potentially transmitting. | |
int | Wifi_FindMatchingAP (int numaps, Wifi_AccessPoint *apdata, Wifi_AccessPoint *match_dest) |
Determines whether various APs exist in the local area. | |
int | Wifi_GetAPData (int apnum, Wifi_AccessPoint *apdata) |
Grabs data from internal structures for user code (always succeeds). | |
int | Wifi_GetData (int datatype, int bufferlen, unsigned char *buffer) |
Retrieve an arbitrary or misc. piece of data from the WiFi hardware. | |
unsigned long | Wifi_GetIP (void) |
It returns the current IP address of the DS. | |
struct in_addr | Wifi_GetIPInfo (struct in_addr *pGateway, struct in_addr *pSnmask, struct in_addr *pDns1, struct in_addr *pDns2) |
Returns IP information. | |
int | Wifi_GetNumAP (void) |
Returns the current number of APs that are known and tracked internally. | |
u32 | Wifi_GetStats (int statnum) |
Retreive an element of the WiFi statistics gathered. | |
unsigned long | Wifi_Init (int initflags) |
Initializes the WiFi library (ARM9 side) and the sgIP library. | |
bool | Wifi_InitDefault (bool useFirmwareSettings) |
Initializes WiFi library. | |
void | Wifi_RawSetPacketHandler (WifiPacketHandler wphfunc) |
Set a handler to process all raw incoming packets. | |
int | Wifi_RawTxFrame (unsigned short datalen, unsigned short rate, unsigned short *data) |
Send a raw 802.11 frame at a specified rate. | |
int | Wifi_RxRawReadPacket (long packetID, long readlength, unsigned short *data) |
Allows user code to read a packet from within the WifiPacketHandler function. | |
void | Wifi_ScanMode (void) |
Instructs the ARM7 to periodically rotate through the channels to pick up and record information from beacons given off by APs. | |
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_SetIP (unsigned long IPaddr, unsigned long gateway, unsigned long subnetmask, unsigned long dns1, unsigned long dns2) |
Set the DS's IP address and other IP configuration information. | |
void | Wifi_SetPromiscuousMode (int enable) |
Allows the DS to enter or leave a "promsicuous" mode. | |
void | Wifi_SetSyncHandler (WifiSyncHandler sh) |
Call this function to request notification of when the ARM7-side Wifi_Sync() function should be called. | |
void | Wifi_Sync (void) |
Call this function when requested to sync by the ARM7 side of the WiFi lib. | |
void | Wifi_Timer (int num_ms) |
This function should be called in a periodic interrupt. | |
void | Wifi_Update (void) |
Checks for new data from the ARM7 and initiates routing if data is available. | |
ARM9 header of DSWifi.
typedef struct WIFI_ACCESSPOINT Wifi_AccessPoint |
Structure that defines how to connect to an access point.
If a field is not necessary for Wifi_ConnectAP it is marked as such. only 4 fields are absolutely required to be filled in correctly for the connection to work, they are: SSID, ssid_len, bssid, and channel. All others can be ignored (though flags should be set to 0).
typedef void(* WifiPacketHandler) (int, int) |
Wifi Packet Handler function.
The first parameter is the packetID. It is only valid while the called function is executing. The second parameter is packetlength.
Call Wifi_RxRawReadPacket() while in the packet handler function, to retreive the data to a local buffer.
typedef void(* WifiSyncHandler) (void) |
Wifi Sync Handler function.
Callback function that is called when the ARM7 needs to be told to synchronize with new fifo data. If this callback is used (see Wifi_SetSyncHandler()), it should send a message via the fifo to the ARM7, which will call Wifi_Sync() on ARM7.
enum WEPMODES |
enum WIFI_ASSOCSTATUS |
Returned by Wifi_AssocStatus() after calling Wifi_ConnectAPk.
enum WIFI_RETURN |
Error codes for Wifi_GetAPData()
enum WIFI_STATS |
List of available WiFi statistics.
enum 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. |
int Wifi_AssocStatus | ( | void | ) |
Returns information about the status of connection to an AP.
Continue polling this function until you receive ASSOCSTATUS_CONNECTED or ASSOCSTATUS_CANNOTCONNECT.
int Wifi_CheckInit | ( | void | ) |
Verifies when the ARM7 has been successfully initialized.
int Wifi_ConnectAP | ( | Wifi_AccessPoint * | apdata, |
int | wepmode, | ||
int | wepkeyid, | ||
unsigned char * | wepkey | ||
) |
Connect to an Access Point.
apdata | Basic data on the AP. |
wepmode | Indicates whether WEP is used, and what kind (WEPMODES). |
wepkeyid | Indicates which WEP key ID to use for transmitting. |
wepkey | The WEP key, to be used in all 4 key slots (should make this more flexible in the future). |
int Wifi_DisconnectAP | ( | void | ) |
Disassociate from the Access Point.
int Wifi_FindMatchingAP | ( | int | numaps, |
Wifi_AccessPoint * | apdata, | ||
Wifi_AccessPoint * | match_dest | ||
) |
Determines whether various APs exist in the local area.
You provide a list of APs, and it will return the index of the first one in the list that can be found in the internal list of APs that are being tracked.
numaps | Number of records in the list. |
apdata | Pointer to an array of structures with information about the APs to find. |
match_dest | OPTIONAL pointer to a record to receive the matching AP record. |
int Wifi_GetAPData | ( | int | apnum, |
Wifi_AccessPoint * | apdata | ||
) |
Grabs data from internal structures for user code (always succeeds).
apnum | The 0-based index of the access point record to fetch. |
apdata | Pointer to the location to store the retrieved data. |
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.
datatype | Element from the WIFIGETDATA enum specifing what kind of data to get. |
bufferlen | Length of the buffer to copy data to (not always used) |
buffer | Buffer to copy element data to (not always used) |
unsigned long Wifi_GetIP | ( | void | ) |
It returns the current IP address of the DS.
The IP may not be valid before connecting to an AP, or setting the IP manually.
struct in_addr Wifi_GetIPInfo | ( | struct in_addr * | pGateway, |
struct in_addr * | pSnmask, | ||
struct in_addr * | pDns1, | ||
struct in_addr * | pDns2 | ||
) |
Returns IP information.
The values may not be valid before connecting to an AP, or setting the IP manually.
pGateway | Pointer to receive the currently configured gateway IP. |
pSnmask | Pointer to receive the currently configured subnet mask. |
pDns1 | Pointer to receive the currently configured primary DNS server IP. |
pDns2 | Pointer to receive the currently configured secondary DNS server IP. |
int Wifi_GetNumAP | ( | void | ) |
Returns the current number of APs that are known and tracked internally.
u32 Wifi_GetStats | ( | int | statnum | ) |
Retreive an element of the WiFi statistics gathered.
statnum | Element from the WIFI_STATS enum, indicating what statistic to return. |
unsigned long Wifi_Init | ( | int | initflags | ) |
Initializes the WiFi library (ARM9 side) and the sgIP library.
initflags | Set up some optional things, like controlling the LED blinking. |
bool Wifi_InitDefault | ( | bool | useFirmwareSettings | ) |
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 the DSWifi.
useFirmwareSettings | If true, this function will initialize the hardware and try to connect to the Access Points stored in the firmware. If false, it will only initialize the library. You can use WFC_CONNECT and INIT_ONLY. |
void Wifi_RawSetPacketHandler | ( | WifiPacketHandler | wphfunc | ) |
Set a handler to process all raw incoming packets.
wphfunc | Pointer to packet handler (see WifiPacketHandler for info). |
int Wifi_RawTxFrame | ( | unsigned short | datalen, |
unsigned short | rate, | ||
unsigned short * | data | ||
) |
Send a raw 802.11 frame at a specified rate.
datalen | The length in bytes of the frame to send |
rate | The rate to transmit at (Specified as mbits/10, 1mbit=0x000A, 2mbit=0x0014) |
data | Pointer to the data to send (should be halfword-aligned) |
int Wifi_RxRawReadPacket | ( | long | packetID, |
long | readlength, | ||
unsigned short * | data | ||
) |
Allows user code to read a packet from within the WifiPacketHandler function.
packetID | A non-unique identifier which locates the packet specified in the internal buffer. |
readlength | Number of bytes to read. It actually reads ((number + 1) & ~1) bytes |
data | Location for the data to be read into |
void Wifi_SetChannel | ( | int | channel | ) |
If the WiFi system is not connected or connecting to an access point, instruct the chipset to change channel.
channel | The channel to change to, in the range of 1-13. |
void Wifi_SetIP | ( | unsigned long | IPaddr, |
unsigned long | gateway, | ||
unsigned long | subnetmask, | ||
unsigned long | dns1, | ||
unsigned long | dns2 | ||
) |
Set the DS's IP address and other IP configuration information.
IPaddr | The new IP address. If this value is zero, the IP, the gateway, and the subnet mask will be allocated via DHCP. |
gateway | The new gateway (example: 192.168.1.1 is 0xC0A80101) |
subnetmask | The new subnet mask (example: 255.255.255.0 is 0xFFFFFF00) |
dns1 | The new primary dns server (NOTE! if this value is zero AND the IPaddr value is zero, dns1 and dns2 will be allocated via DHCP). |
dns2 | The new secondary dns server |
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.)
enable | 0 to disable promiscuous mode, nonzero to engage. |
void Wifi_SetSyncHandler | ( | WifiSyncHandler | sh | ) |
Call this function to request notification of when the ARM7-side Wifi_Sync() function should be called.
sh | Pointer to the function to be called for notification. |
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.
num_ms | The number of milliseconds since the last time this function was called. |