ClearCore Library
|
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. | |
ClearCore::EthernetUdp::EthernetUdp | ( | ) |
Construct an Ethernet UDP session.
bool ClearCore::EthernetUdp::Begin | ( | uint16_t | localPort | ) |
Initialize the UDP session and begin listening on the specified local port.
[in] | localPort | The local port for the UDP session. |
uint16_t ClearCore::EthernetUdp::BytesAvailable | ( | ) |
Number of bytes available to read from the current packet.
bool ClearCore::EthernetUdp::Connect | ( | IpAddress | remoteIp, |
uint16_t | remotePort | ||
) |
Setup to send a UDP packet to a specified remote.
[in] | remoteIp | The remote IP address. |
[in] | remotePort | The remote port. |
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().
int32_t ClearCore::EthernetUdp::PacketRead | ( | unsigned char * | dataPtr, |
uint16_t | len | ||
) |
Reads the current packet received from the UDP session.
[out] | dataPtr | Where to write the data to. |
[in] | len | Maximum number of bytes to write into dataPtr. |
bool ClearCore::EthernetUdp::PacketSend | ( | ) |
Send the UDP packet set up with Connect().
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().
[in] | nullTermStr | The string to be sent. |
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().
[in] | buffer | A pointer to the beginning of the data to write. |
[in] | size | The maximum number of bytes to write. |
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().
[in] | c | Character to write. |
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.
IpAddress ClearCore::EthernetUdp::RemoteIp | ( | ) |
Returns the remote IP address for the current packet.
uint16_t ClearCore::EthernetUdp::RemotePort | ( | ) |
Returns the remote port for the current packet.