ClearCore Library
List of all members | Public Member Functions
ClearCore::EthernetUdp Class Reference

Detailed Description

ClearCore UDP session class.

This class manages a single local UDP session.

For more detailed information on the ClearCore Ethernet system, check out the ClearCore Ethernet informational page.

ClearCore UDP session class. More...

#include <EthernetUdp.h>

Public Member Functions

 EthernetUdp ()
 
bool Begin (uint16_t localPort)
 Initialize the UDP session and begin listening on the specified local port. More...
 
void End ()
 Disable the UDP session.
 
bool Connect (IpAddress remoteIp, uint16_t remotePort)
 Setup to send a UDP packet to a specified remote. More...
 
bool PacketSend ()
 Send the UDP packet set up with Connect(). More...
 
uint32_t PacketWrite (uint8_t c)
 Write data into the outgoing UDP packet. More...
 
uint32_t PacketWrite (const char *nullTermStr)
 Write data into the outgoing UDP packet. More...
 
uint32_t PacketWrite (const uint8_t *buffer, uint32_t size)
 PacketWrite data into the outgoing UDP packet. More...
 
uint16_t PacketParse ()
 Check for the newest incoming UDP packet. More...
 
uint16_t BytesAvailable ()
 Number of bytes available to read from the current packet. More...
 
int32_t PacketRead (unsigned char *dataPtr, uint16_t len)
 Reads the current packet received from the UDP session. More...
 
int16_t Peek ()
 Attempts to get the next available character. More...
 
void PacketFlush ()
 Flush the current packet.
 
IpAddress RemoteIp ()
 Returns the remote IP address for the current packet. More...
 
uint16_t RemotePort ()
 Returns the remote port for the current packet. More...
 

Constructor & Destructor Documentation

ClearCore::EthernetUdp::EthernetUdp ( )

Construct an Ethernet UDP session.

Member Function Documentation

bool ClearCore::EthernetUdp::Begin ( uint16_t  localPort)

Initialize the UDP session and begin listening on the specified local port.

Parameters
[in]localPortThe local port for the UDP session.
Returns
success
uint16_t ClearCore::EthernetUdp::BytesAvailable ( )

Number of bytes available to read from the current packet.

Note
PacketParse() must be called first to read an incoming packet.
bool ClearCore::EthernetUdp::Connect ( IpAddress  remoteIp,
uint16_t  remotePort 
)

Setup to send a UDP packet to a specified remote.

Parameters
[in]remoteIpThe remote IP address.
[in]remotePortThe remote port.
Returns
success
uint16_t ClearCore::EthernetUdp::PacketParse ( )

Check for the newest incoming UDP packet.

Checks for the newest incoming UDP packet received by the listening UDP session. Moves the packet to be read from by following calls to PacketRead().

Returns
The size of the incoming packet in bytes.
int32_t ClearCore::EthernetUdp::PacketRead ( unsigned char *  dataPtr,
uint16_t  len 
)

Reads the current packet received from the UDP session.

Parameters
[out]dataPtrWhere to write the data to.
[in]lenMaximum number of bytes to write into dataPtr.
Returns
The number of bytes read.
Note
PacketParse() must be called first to read an incoming packet.
bool ClearCore::EthernetUdp::PacketSend ( )

Send the UDP packet set up with Connect().

Returns
success
uint32_t ClearCore::EthernetUdp::PacketWrite ( uint8_t  c)

Write data into the outgoing UDP packet.

Write data into the outgoing UDP packet set up with Connect().

Parameters
[in]cCharacter to write.
Returns
The number of bytes written into the outgoing UDP packet.
uint32_t ClearCore::EthernetUdp::PacketWrite ( const char *  nullTermStr)

Write data into the outgoing UDP packet.

Write a string of characters to the UDP packet set up with Connect().

Parameters
[in]nullTermStrThe string to be sent.
Returns
The number of bytes written into the outgoing UDP packet.
uint32_t ClearCore::EthernetUdp::PacketWrite ( const uint8_t *  buffer,
uint32_t  size 
)

PacketWrite data into the outgoing UDP packet.

Write data into the outgoing UDP packet set up with Connect().

Parameters
[in]bufferA pointer to the beginning of the data to write.
[in]sizeThe maximum number of bytes to write.
Returns
The number of bytes written into the outgoing UDP packet.
int16_t ClearCore::EthernetUdp::Peek ( )

Attempts to get the next available character.

Attempts to get the next available character without pulling the character out of the incoming packet.

Returns
The first character in the incoming packet, or -1 if no data is available.
Note
PacketParse() must be called first to read an incoming packet.
IpAddress ClearCore::EthernetUdp::RemoteIp ( )

Returns the remote IP address for the current packet.

Returns
The remote IP address.
uint16_t ClearCore::EthernetUdp::RemotePort ( )

Returns the remote port for the current packet.

Returns
The remote port.

The documentation for this class was generated from the following file: