66 lines
1.6 KiB
C++
66 lines
1.6 KiB
C++
/*
|
||
* eth_udp_client.hpp
|
||
*
|
||
* Created on: 15 <20><><EFBFBD>. 2023 <20>.
|
||
* Author: sychev
|
||
*/
|
||
|
||
#ifndef FREE_RTOS_ETHERNET_IP_ETH_UDP_CLIENT_HPP_
|
||
#define FREE_RTOS_ETHERNET_IP_ETH_UDP_CLIENT_HPP_
|
||
|
||
#include "free_rtos/semaphore/semaphore.hpp"
|
||
#include "free_rtos/mutex/mutex.hpp"
|
||
#include "free_rtos/ethernet/eth_frame.h"
|
||
#include "free_rtos/ethernet_ip/eth_ip_iface.hpp"
|
||
#include "free_rtos/ethernet/eth_types.h"
|
||
|
||
#include <vector>
|
||
#include <cstdint>
|
||
|
||
namespace free_rtos {
|
||
|
||
class EthUpdClient {
|
||
friend class EthUdpServer;
|
||
|
||
public:
|
||
EthUpdClient(EthIpIface& ip_iface, TEthMacPorts port_id,
|
||
uint16_t port_dst_be, uint16_t port_src_be,
|
||
bool use_chksum);
|
||
|
||
int32_t read(uint8_t * p_data, uint32_t len);
|
||
|
||
int32_t read_async(uint8_t * p_data, uint32_t len);
|
||
|
||
int32_t write(uint32_t ip_dst_be, uint8_t * p_data, uint32_t len);
|
||
|
||
void clear(); ///<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
|
||
private:
|
||
void put_data(uint32_t src_ip, uint8_t * p_data, uint32_t len);
|
||
int32_t get_data(uint8_t * p_data, uint32_t len);
|
||
|
||
private:
|
||
const uint32_t max_buf_size = 0x100000; // 1Mb
|
||
|
||
Semaphore rx_sem_;
|
||
Mutex rx_mut_;
|
||
|
||
const uint16_t port_dst_be_; /// big endian
|
||
const uint16_t port_src_be_; /// big endian
|
||
const bool use_checksum_;
|
||
|
||
std::vector<uint8_t> buff_;
|
||
|
||
TEthPkt eth_pkt_;
|
||
|
||
EthIpIface& ip_iface_;
|
||
|
||
const TEthMacPorts port_id_;
|
||
|
||
uint32_t src_ip_; /// Ip <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> UDP
|
||
};
|
||
|
||
}
|
||
|
||
#endif /* FREE_RTOS_ETHERNET_IP_ETH_UDP_CLIENT_HPP_ */
|