openTRI 0.1
Data Structures | Macros | Typedefs | Functions
Wifi

Data Structures

struct  triNetConfig
 Connection config. More...
 

Macros

#define TRI_SOCKET_TCP   SOCK_STREAM
 Stream socket.
 
#define TRI_SOCKET_UDP   SOCK_DGRAM
 Datagram socket.
 
#define TRI_LOCAL_IP   0
 Local IP ie. More...
 
#define TRI_REAL_IP   1
 'Real' IP
 
#define TRI_MAX_CLIENTS   256
 Maximum clients that can connect to a server.
 

Typedefs

typedef int triSocket
 A socket.
 
typedef fd_set triSocketSet
 A socket set (group)
 

Functions

triBool triNetInit ()
 Initialise the wifi. More...
 
triUInt triNetGetConfigs (triNetConfig *configs, triUInt count)
 Get the connection configs. More...
 
triBool triNetSwitchStatus ()
 Get the status of the wlan switch. More...
 
triBool triNetConnect (triNetConfig *config)
 Connect to an access point. More...
 
triVoid triNetDisconnect ()
 Disconnect from an access point.
 
triBool triNetIsConnected ()
 Check connected to an access point. More...
 
triBool triNetGetLocalIp (char *buffer)
 Get local IP. More...
 
triChar * triNetResolveHost (triChar *hostname)
 Resolve a host name to an IP. More...
 
triSocket triNetSocketCreate (void)
 Create a socket. More...
 
triSocket triNetSocketAccept (triSocket socket)
 Accept a new connection. More...
 
triBool triNetSocketBind (triSocket socket, triU16 port)
 Bind a socket to an address/port. More...
 
triBool triNetSocketListen (triSocket socket, triUInt maxConnections)
 Listen on a socket for incoming connections. More...
 
triBool triNetSocketConnect (triSocket socket, char *ip, triU16 port)
 Connect using a socket. More...
 
triSInt triNetSocketSend (triSocket socket, const char *data, triSInt length)
 Send data using a socket. More...
 
triSInt triNetSocketReceive (triSocket socket, char *data)
 Receive data using a socket. More...
 
triVoid triNetSocketClose (triSocket socket)
 Close a socket. More...
 
triVoid triNetSocketSetClear (triSocketSet *set)
 Clear a socket set. More...
 
triVoid triNetSocketSetAdd (triSocket socket, triSocketSet *set)
 Add a socket to a socket set. More...
 
triVoid triNetSocketSetRemove (triSocket socket, triSocketSet *set)
 Remove a socket from a socket set. More...
 
triBool triNetSocketSetIsMember (triSocket socket, triSocketSet *set)
 Check for socket updates within a set. More...
 
triSInt triNetSocketSelect (triUInt maxSockets, triSocketSet *set)
 Remove a socket from a socket set. More...
 
triVoid triNetGetUrl (triChar *url, triChar *response)
 Save web 'item' (page/file etc) More...
 

Detailed Description

Macro Definition Documentation

◆ TRI_LOCAL_IP

#define TRI_LOCAL_IP   0

Local IP ie.

192.168.x.x

Function Documentation

◆ triNetInit()

triBool triNetInit ( )

Initialise the wifi.

Returns
true on success else an error code.
Note
Requires kernel mode

◆ triNetGetConfigs()

triUInt triNetGetConfigs ( triNetConfig configs,
triUInt  count 
)

Get the connection configs.

Parameters
configs- An array of triNetConfig
count- Size of the array
Returns
Number of configs found

◆ triNetSwitchStatus()

triBool triNetSwitchStatus ( )

Get the status of the wlan switch.

Returns
true if switch is up

◆ triNetConnect()

triBool triNetConnect ( triNetConfig config)

Connect to an access point.

Parameters
config- The connection config to connect to
Returns
true on success else an error code

◆ triNetIsConnected()

triBool triNetIsConnected ( )

Check connected to an access point.

Returns
true on valid connection

◆ triNetGetLocalIp()

triBool triNetGetLocalIp ( char *  buffer)

Get local IP.

Returns
true on success

◆ triNetResolveHost()

triChar * triNetResolveHost ( triChar *  hostname)

Resolve a host name to an IP.

Parameters
hostnameThe host to resolve
Returns
The IP of the host

◆ triNetSocketCreate()

triSocket triNetSocketCreate ( void  )

Create a socket.

Returns
The socket file descripter

◆ triNetSocketAccept()

triSocket triNetSocketAccept ( triSocket  socket)

Accept a new connection.

Parameters
socketThe socket to accept on
Returns
The socket file descripter of the new connection

◆ triNetSocketBind()

triBool triNetSocketBind ( triSocket  socket,
triU16  port 
)

Bind a socket to an address/port.

Parameters
socket- A valid triSocket
port- The port
Returns
true on success

◆ triNetSocketListen()

triBool triNetSocketListen ( triSocket  socket,
triUInt  maxConnections 
)

Listen on a socket for incoming connections.

Parameters
socket- A valid triSocket
maxConnections- Number of connections allowed on the incoming queue
Returns
true on success

◆ triNetSocketConnect()

triBool triNetSocketConnect ( triSocket  socket,
char *  ip,
triU16  port 
)

Connect using a socket.

Parameters
socket- A valid triSocket
Returns
true on success

◆ triNetSocketSend()

triSInt triNetSocketSend ( triSocket  socket,
const char *  data,
triSInt  length 
)

Send data using a socket.

Parameters
socket- A valid triSocket
data- The data to send
Returns
The number of bytes sent or < 0 on error

◆ triNetSocketReceive()

triSInt triNetSocketReceive ( triSocket  socket,
char *  data 
)

Receive data using a socket.

Parameters
socket- A valid triSocket
data- The buffer for the received data to go
Returns
The number of bytes received, 0 if remote closed connection or < 0 on error

◆ triNetSocketClose()

triVoid triNetSocketClose ( triSocket  socket)

Close a socket.

Parameters
socketThe socket to close

◆ triNetSocketSetClear()

triVoid triNetSocketSetClear ( triSocketSet set)

Clear a socket set.

Parameters
setThe socket set to clear

◆ triNetSocketSetAdd()

triVoid triNetSocketSetAdd ( triSocket  socket,
triSocketSet set 
)

Add a socket to a socket set.

Parameters
socketThe socket to add
setThe set to add the socket to

◆ triNetSocketSetRemove()

triVoid triNetSocketSetRemove ( triSocket  socket,
triSocketSet set 
)

Remove a socket from a socket set.

Parameters
socketThe socket to remove
setThe set to remove the socket from

◆ triNetSocketSetIsMember()

triBool triNetSocketSetIsMember ( triSocket  socket,
triSocketSet set 
)

Check for socket updates within a set.

Parameters
socketThe socket to check
setThe set to check within
Returns
true if socket requires receiving

◆ triNetSocketSelect()

triSInt triNetSocketSelect ( triUInt  maxSockets,
triSocketSet set 
)

Remove a socket from a socket set.

Parameters
socketThe socket to remove
setThe set to remove the socket from

◆ triNetGetUrl()

triVoid triNetGetUrl ( triChar *  url,
triChar *  response 
)

Save web 'item' (page/file etc)

Parameters
url- URL to connect to
response- Buffer to save the response to
Note
Requires a full URL, ie. www.myhost.com/index.html, not just www.myhost.com/