6 #ifndef NET_UDP_SOCKET_HPP_
7 #define NET_UDP_SOCKET_HPP_
10 #include "RtosSemaphore.hpp"
11 #include "LibLinkedList.hpp"
12 #include "RtosMsgBox.hpp"
15 class NetUdpSocket:
public LIB_LINKED_LIST_ITERABLE<NetUdpSocket> {
21 NetDefs::UDP_PORT port;
23 }__attribute__((packed)) PACKET_HEADER;
27 uint8_t data[NetDefs::UDP_MAX_DATA_LEN];
28 }__attribute__((packed)) RX_PACKET;
33 }__attribute__((packed)) TX_PACKET;
36 NetDefs::UDP_PORT mLocalPort;
37 static uint16_t sAutomaticPort;
43 void open(NetDefs::UDP_PORT localPort = 0);
46 TX_PACKET* allocTxPacket(
size_t maxDataLen);
47 void discardTxPacket(TX_PACKET* pkt);
48 bool sendPacket(TX_PACKET& pkt,
size_t dataLen);
50 RX_PACKET* recvPacket(
Rtos::TICK timeout);
51 void discardRxPacket(RX_PACKET* pkt);