NightFox’s Lib
|
Basic functions to initialize WiFi, setup a UDP socket, and send and receive data. More...
Macros | |
#define | NF_MAX_INCOMMING_PENDING 1 |
Maxmimum number of connection requests in the queue. | |
#define | NF_WIFI_BUFFER_SIZE 256 |
Size of communications buffer. | |
Functions | |
bool | NF_WiFiConnectDefaultAp (void) |
Try to connect to the default access point in the DS user configuration. More... | |
void | NF_WiFiDisconnectAp (void) |
Disconnect from the access point and shutdown WiFi. | |
bool | NF_WIFI_CreateUdpSender (const char *address, u16 port) |
Creates a socket in client mode using UDP. More... | |
bool | NF_WIFI_CreateUdpListener (u16 port) |
Creates a socket in server mode using UDP. More... | |
bool | NF_WIFI_UdpSend (const char *data) |
Sends a text string over the currenty open UDP socket. More... | |
s32 | NF_WIFI_UdpListen (u32 timeout) |
Listens to data from the currently open socket. More... | |
Variables | |
struct in_addr | NF_IP |
Current IP address. | |
struct in_addr | NF_GATEWAY |
Current gateway. | |
struct in_addr | NF_MASK |
Current netmask. | |
struct in_addr | NF_DNS1 |
Current DNS 1. | |
struct in_addr | NF_DNS2 |
Current DNS 2. | |
s32 | NF_SOCKET |
Server socket ID. | |
s32 | NF_CONNECTED |
Connection result. | |
int | NF_SINSIZE |
Size of struct .SIN. | |
s32 | NF_BYTES_RECIEVED |
Received bytes. | |
struct sockaddr_in | NF_SA_SERVER |
Server socket address. | |
struct sockaddr_in | NF_SA_CLIENT |
Client socket address. | |
char | NF_SEND_BUFFER [NF_WIFI_BUFFER_SIZE] |
Send buffer. | |
char | NF_RECV_BUFFER [NF_WIFI_BUFFER_SIZE] |
Reception buffer. | |
bool | NF_WIFI_IS_SERVER |
This is set to true if this console is in server mode, false in client mode. | |
s32 | NF_MAXFD |
Maximum number of sockets to examine by select(). | |
fd_set | NF_READFDS |
Struct to save data used by select() sockets. | |
struct timeval | NF_TIMEOUT |
Current timeout in microseconds. | |
Basic functions to initialize WiFi, setup a UDP socket, and send and receive data.
bool NF_WIFI_CreateUdpListener | ( | u16 | port | ) |
Creates a socket in server mode using UDP.
It accepts data from any UP address.
Example:
port | Port. |
bool NF_WIFI_CreateUdpSender | ( | const char * | address, |
u16 | port | ||
) |
Creates a socket in client mode using UDP.
Example:
address | IP address. |
port | Port. |
s32 NF_WIFI_UdpListen | ( | u32 | timeout | ) |
Listens to data from the currently open socket.
If any data is received it is saved in the global variable NF_RECV_BUFFER. It saves the number of received bytes in NF_BYTES_RECIEVED.
The function returns a positive value if any data is received. If there is a timeout (specified in microseconds), it returns a negative value.
Example:
timeout |
bool NF_WIFI_UdpSend | ( | const char * | data | ) |
Sends a text string over the currenty open UDP socket.
A socket must have been opened by NF_WIFI_CreateUdpSender(), which will be used by this function.
Sent data is saved in NF_SEND_BUFFER as well so that you can run a checksum function on it, for example.
Example:
data | Text string to be sent. |
bool NF_WiFiConnectDefaultAp | ( | void | ) |
Try to connect to the default access point in the DS user configuration.