RF24Ethernet - TCP/IP over RF24Network  1.6b
TMRh20 - Pushing the practical limits of RF24 modules
Public Member Functions | Static Public Attributes | Friends | List of all members
RF24Client Class Reference

#include <RF24Client.h>

+ Inheritance diagram for RF24Client:

Public Member Functions

 RF24Client ()
 
int connect (IPAddress ip, uint16_t port)
 
int connect (const char *host, uint16_t port)
 
int read (uint8_t *buf, size_t size)
 
int read ()
 
void stop ()
 
uint8_t connected ()
 
size_t write (uint8_t)
 
size_t write (const uint8_t *buf, size_t size)
 
int available ()
 
int waitAvailable (uint32_t timeout=750)
 
int peek ()
 
void flush ()
 
 operator bool ()
 
virtual bool operator== (const EthernetClient &)
 
virtual bool operator!= (const EthernetClient &rhs)
 

Static Public Attributes

static uip_userdata_t all_data [UIP_CONNS]
 

Friends

class RF24EthernetClass
 
class RF24Server
 
void serialip_appcall (void)
 
void uip_log (char *msg)
 

Detailed Description

Definition at line 60 of file RF24Client.h.

Constructor & Destructor Documentation

RF24Client::RF24Client ( )

Basic constructor

Definition at line 11 of file RF24Client.cpp.

Member Function Documentation

int RF24Client::connect ( IPAddress  ip,
uint16_t  port 
)

Establish a connection to a specified IP address and port

Definition at line 27 of file RF24Client.cpp.

References IF_RF24ETHERNET_DEBUG_CLIENT, and stop().

Referenced by connect().

int RF24Client::connect ( const char *  host,
uint16_t  port 
)

Establish a connection to a given hostname and port

Note
UDP must be enabled in uip-conf.h for DNS lookups to work
Tip: DNS lookups generally require a buffer size of 250-300 bytes or greater. Lookups will generally return responses with a single A record if using hostnames like "www.google.com" instead of "google.com" which works well with the default buffer size

Definition at line 68 of file RF24Client.cpp.

References connect().

int RF24Client::read ( uint8_t *  buf,
size_t  size 
)

Read available data into a buffer

uint8_t buf[size];
client.read(buf,size);

Definition at line 403 of file RF24Client.cpp.

References IF_ETH_DEBUG_L2.

int RF24Client::read ( )

Read data one byte at a time

char c = client.read();

Definition at line 445 of file RF24Client.cpp.

void RF24Client::stop ( )

Disconnects from the current active connection

Definition at line 95 of file RF24Client.cpp.

References IF_RF24ETHERNET_DEBUG_CLIENT.

Referenced by connect().

uint8_t RF24Client::connected ( )

Indicates whether the client is connected or not

Definition at line 21 of file RF24Client.cpp.

size_t RF24Client::write ( uint8_t  c)

Write a single byte of data to the stream

Note
This will write an entire TCP payload with only 1 byte in it

Definition at line 137 of file RF24Client.cpp.

size_t RF24Client::write ( const uint8_t *  buf,
size_t  size 
)

Write a buffer of data, to be sent in a single TCP packet

Definition at line 143 of file RF24Client.cpp.

int RF24Client::available ( )

Indicates whether data is available to be read by the client.

Returns
Returns the number of bytes available to be read
Note
Calling client or server available() keeps the IP stack and RF24Network layer running, so needs to be called regularly, even when disconnected or delaying for extended periods.

Definition at line 385 of file RF24Client.cpp.

Referenced by peek(), and waitAvailable().

int RF24Client::waitAvailable ( uint32_t  timeout = 750)

Wait Available

Helps to ensure all incoming data has been received, prior to writing data back to the client, etc.

Indicates whether data is available to be read by the client, after waiting a maximum period of time.

Returns
Returns the number of bytes available to be read or 0 if timed out
Note
Calling client or server available() keeps the IP stack and RF24Network layer running, so needs to be called regularly, even when disconnected or delaying for extended periods.

Definition at line 371 of file RF24Client.cpp.

References available().

int RF24Client::peek ( )

Read a byte from the incoming buffer without advancing the point of reading

Definition at line 454 of file RF24Client.cpp.

References available().

void RF24Client::flush ( )

Flush all incoming client data from the current connection/buffer

Definition at line 463 of file RF24Client.cpp.

RF24Client::operator bool ( )

Definition at line 130 of file RF24Client.cpp.

bool RF24Client::operator== ( const EthernetClient &  )
virtual

Definition at line 124 of file RF24Client.cpp.

Referenced by operator!=().

virtual bool RF24Client::operator!= ( const EthernetClient &  rhs)
inlinevirtual

Definition at line 157 of file RF24Client.h.

References operator==().

Friends And Related Function Documentation

friend class RF24EthernetClass
friend

Definition at line 172 of file RF24Client.h.

friend class RF24Server
friend

Definition at line 173 of file RF24Client.h.

void serialip_appcall ( void  )
friend

Definition at line 197 of file RF24Client.cpp.

void uip_log ( char *  msg)
friend

Definition at line 189 of file RF24Client.cpp.

Member Data Documentation

uip_userdata_t RF24Client::all_data
static

Definition at line 157 of file RF24Client.h.

Referenced by RF24Server::available(), and RF24Server::write().