36#include "EthernetUdp.h"
39IpAddress ip = IpAddress(192, 168, 1, 177);
42uint16_t localPort = 8888;
45#define MAX_PACKET_LENGTH 100
47unsigned char packetReceived[MAX_PACKET_LENGTH];
60 ConnectorUsb.
Mode(Connector::USB_CDC);
61 ConnectorUsb.
Speed(9600);
64 uint32_t timeout = 5000;
66 while (!ConnectorUsb &&
Milliseconds() - startTime < timeout) {
72 ConnectorUsb.
SendLine(
"The Ethernet cable is unplugged...");
105 uint16_t packetSize = Udp.PacketParse();
107 if (packetSize > 0) {
119 int32_t bytesRead = Udp.PacketRead(packetReceived, MAX_PACKET_LENGTH);
128 Udp.Connect(Udp.RemoteIp(), Udp.RemotePort());
129 Udp.PacketWrite(
"Hello, world!");
void Delay_ms(uint32_t ms)
Blocks operations for ms milliseconds.
Definition SysTiming.h:287
uint32_t Milliseconds(void)
Number of milliseconds since the ClearCore was initialized.
volatile const bool & PhyLinkActive()
Check the link status from the PHY.
Definition EthernetManager.h:136
IpAddress LocalIp()
Get the local IP address.
bool DhcpBegin()
Set up DHCP connection to retrieve local IP.
void Setup()
Setup LwIP with the local network interface.
bool SendLine()
Send carriage return and newline characters.
Definition ISerial.h:162
virtual bool Speed(uint32_t bitsPerSecond)=0
Change the baud rate for the port.
bool Send(const char *buffer, size_t bufferSize)
Send the array of characters out the port.
Definition ISerial.h:173
char * StringValue()
Returns a string representation of the IP Address.
Definition IpAddress.h:96
virtual ConnectorModes Mode() override
Get the connector's operational mode.
Definition SerialUsb.h:210
SerialUsb ConnectorUsb
USB connector instance.
EthernetManager & EthernetMgr
Ethernet manager.