ClearCore Library
Loading...
Searching...
No Matches
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.
 
void End ()
 Disable the UDP session.
 
bool Connect (IpAddress remoteIp, uint16_t remotePort)
 Setup to send a UDP packet to a specified remote.
 
bool PacketSend ()
 Send the UDP packet set up with Connect().
 
uint32_t PacketWrite (uint8_t c)
 Write data into the outgoing UDP packet.
 
uint32_t PacketWrite (const char *nullTermStr)
 Write data into the outgoing UDP packet.
 
uint32_t PacketWrite (const uint8_t *buffer, uint32_t size)
 PacketWrite data into the outgoing UDP packet.
 
uint16_t PacketParse ()
 Check for the newest incoming UDP packet.
 
uint16_t BytesAvailable ()
 Number of bytes available to read from the current packet.
 
int32_t PacketRead (unsigned char *dataPtr, uint16_t len)
 Reads the current packet received from the UDP session.
 
int16_t Peek ()
 Attempts to get the next available character.
 
void PacketFlush ()
 Flush the current packet.
 
IpAddress RemoteIp ()
 Returns the remote IP address for the current packet.
 
uint16_t RemotePort ()
 Returns the remote port for the current packet.
 

Constructor & Destructor Documentation

◆ EthernetUdp()

ClearCore::EthernetUdp::EthernetUdp ( )

Construct an Ethernet UDP session.

Member Function Documentation

◆ Begin()

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

◆ BytesAvailable()

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.

◆ Connect()

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

◆ PacketParse()

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.

◆ PacketRead()

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.

◆ PacketSend()

bool ClearCore::EthernetUdp::PacketSend ( )

Send the UDP packet set up with Connect().

Returns
success

◆ PacketWrite() [1/3]

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.

◆ PacketWrite() [2/3]

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.

◆ PacketWrite() [3/3]

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.

◆ Peek()

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.

◆ RemoteIp()

IpAddress ClearCore::EthernetUdp::RemoteIp ( )

Returns the remote IP address for the current packet.

Returns
The remote IP address.

◆ RemotePort()

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: