31 udp.onPacket([&](AsyncUDPPacket packet) {
34 result.
peer.
port = packet.remotePort();
37 result.
data.
copyFrom((
const char*)packet.data(), packet.length());
40 queue.enqueue(result);
47 udp.onPacket([&](AsyncUDPPacket packet) {
50 result.
peer.
port = packet.remotePort();
53 result.
data.
copyFrom((
const char*)packet.data(), packet.length());
56 queue.enqueue(result);
62 bool send(uint8_t* data,
int len) {
return send(
peer, data, len); }
79 queue.dequeue(result);
Abstract Interface for UDP API.
Definition: IUDPService.h:34
void log(DlnaLogLevel current_level, const char *fmt...)
Print log message.
Definition: Logger.h:40
A simple single producer, single consumer lock free queue.
Definition: QueueLockFree.h:14
void copyFrom(const char *source, int len, int maxlen=0)
assigns a memory buffer
Definition: Str.h:94
Access to UDP functionality: sending and receiving of data using the Async API of the ESP32.
Definition: UDPAsyncService.h:18
QueueLockFree< RequestData > queue
Definition: UDPAsyncService.h:87
IPAddressAndPort peer
Definition: UDPAsyncService.h:85
bool begin(IPAddressAndPort addr)
Definition: UDPAsyncService.h:26
AsyncUDP udp
Definition: UDPAsyncService.h:84
bool send(IPAddressAndPort addr, uint8_t *data, int len)
Definition: UDPAsyncService.h:64
RequestData receive()
Definition: UDPAsyncService.h:73
bool begin(int port)
Definition: UDPAsyncService.h:20
bool send(uint8_t *data, int len)
Definition: UDPAsyncService.h:62
Definition: Allocator.h:6
@ DlnaDebug
Definition: Logger.h:16
@ DlnaInfo
Definition: Logger.h:16
@ DlnaError
Definition: Logger.h:16
LoggerClass DlnaLogger
Definition: Logger.cpp:5
IP Adress including Port information.
Definition: IPAddressAndPort.h:20
int port
Definition: IPAddressAndPort.h:24
const char * toString()
Definition: IPAddressAndPort.h:26
IPAddress address
Definition: IPAddressAndPort.h:23
Provides information of the received UDP which consists of the (xml) data and the peer address and po...
Definition: IUDPService.h:23
IPAddressAndPort peer
Definition: IUDPService.h:25
Str data
Definition: IUDPService.h:24