37 lines
693 B
C++
37 lines
693 B
C++
#ifndef SDRPI_FPV_CONTROL_GROUND_UDP_DRIVER_H
|
|
#define SDRPI_FPV_CONTROL_GROUND_UDP_DRIVER_H
|
|
|
|
#include <string>
|
|
#include <cstdint>
|
|
#include <vector>
|
|
|
|
#ifdef _WIN32
|
|
#include <winsock2.h>
|
|
#include <ws2tcpip.h>
|
|
#pragma comment(lib, "ws2_32.lib")
|
|
#else
|
|
#include <sys/socket.h>
|
|
#include <netinet/in.h>
|
|
#include <arpa/inet.h>
|
|
#include <unistd.h>
|
|
#endif
|
|
|
|
class UDPSocket {
|
|
public:
|
|
UDPSocket(const std::string& ip, uint16_t port);
|
|
~UDPSocket();
|
|
bool sendFrame(const std::vector<uint16_t>& data);
|
|
|
|
private:
|
|
#ifdef _WIN32
|
|
SOCKET sockfd;
|
|
WSADATA wsaData;
|
|
#else
|
|
int sockfd;
|
|
#endif
|
|
sockaddr_in dest_addr;
|
|
|
|
bool initialize();
|
|
};
|
|
|
|
#endif //SDRPI_FPV_CONTROL_GROUND_UDP_DRIVER_H
|