RF24Ethernet - TCP/IP over RF24Network v1.6.17
TMRh20 - Pushing the practical limits of RF24 modules
Loading...
Searching...
No Matches
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 75 of file RF24Client.h.

Constructor & Destructor Documentation

◆ RF24Client()

RF24Client::RF24Client ( )

Basic constructor

Definition at line 25 of file RF24Client.cpp.

Member Function Documentation

◆ connect() [1/2]

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

Establish a connection to a specified IP address and port

Definition at line 40 of file RF24Client.cpp.

References IF_RF24ETHERNET_DEBUG_CLIENT, stop(), UIP_CONNECTION_TIMEOUT, and uip_ip_addr.

Referenced by connect().

◆ connect() [2/2]

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 88 of file RF24Client.cpp.

References connect().

◆ read() [1/2]

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 483 of file RF24Client.cpp.

References IF_ETH_DEBUG_L2, UIP_CLIENT_CLOSE, UIP_CLIENT_REMOTECLOSED, UIP_CLIENT_RESTART, and UIP_CLIENT_SOCKETS.

◆ read() [2/2]

int RF24Client::read ( )

Read data one byte at a time

char c = client.read();

Definition at line 532 of file RF24Client.cpp.

References read().

Referenced by read().

◆ stop()

void RF24Client::stop ( )

Disconnects from the current active connection

Definition at line 124 of file RF24Client.cpp.

References IF_RF24ETHERNET_DEBUG_CLIENT, RF24Ethernet, UIP_CLIENT_CLOSE, and UIP_CLIENT_REMOTECLOSED.

Referenced by connect().

◆ connected()

uint8_t RF24Client::connected ( )

Indicates whether the client is connected or not

Definition at line 33 of file RF24Client.cpp.

References UIP_CLIENT_CONNECTED.

◆ write() [1/2]

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 173 of file RF24Client.cpp.

◆ write() [2/2]

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 180 of file RF24Client.cpp.

◆ available()

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 462 of file RF24Client.cpp.

References RF24Ethernet.

Referenced by peek(), and waitAvailable().

◆ 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 446 of file RF24Client.cpp.

References available(), and RF24Ethernet.

◆ peek()

int RF24Client::peek ( )

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

Definition at line 542 of file RF24Client.cpp.

References available().

◆ flush()

void RF24Client::flush ( )

Flush all incoming client data from the current connection/buffer

Definition at line 553 of file RF24Client.cpp.

◆ operator bool()

RF24Client::operator bool ( )

Definition at line 165 of file RF24Client.cpp.

References Ethernet, and UIP_CLIENT_REMOTECLOSED.

◆ operator==()

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

Definition at line 158 of file RF24Client.cpp.

Referenced by operator!=().

◆ operator!=()

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

Definition at line 157 of file RF24Client.h.

References operator==().

Friends And Related Symbol Documentation

◆ RF24EthernetClass

friend class RF24EthernetClass
friend

Definition at line 175 of file RF24Client.h.

◆ RF24Server

friend class RF24Server
friend

Definition at line 176 of file RF24Client.h.

◆ serialip_appcall

void serialip_appcall ( void )
friend

Definition at line 241 of file RF24Client.cpp.

◆ uip_log

void uip_log ( char * msg)
friend

Definition at line 229 of file RF24Client.cpp.

Member Data Documentation

◆ all_data

uip_userdata_t RF24Client::all_data
static

Definition at line 162 of file RF24Client.h.

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