55 lines
1.6 KiB
C++
55 lines
1.6 KiB
C++
#pragma once
|
|
#if defined(IDF_VER)
|
|
|
|
#include "Participants/ParticipantUDP.h"
|
|
|
|
#include "lwip/sockets.h"
|
|
|
|
namespace RoboidControl {
|
|
|
|
class ParticipantUDP : public ParticipantUDPGeneric {
|
|
public:
|
|
/// @brief Create a participant without connecting to a site
|
|
/// @param port The port on which the participant communicates
|
|
/// These participant typically broadcast Participant messages to let site
|
|
/// servers on the local network know their presence. Alternatively they can
|
|
/// broadcast information which can be used directly by other participants.
|
|
ParticipantUDP(int port = 7681);
|
|
/// @brief Create a participant which will try to connect to a site.
|
|
/// @param ipAddress The IP address of the site
|
|
/// @param port The port used by the site
|
|
/// @param localPort The port used by the local participant
|
|
ParticipantUDP(const char* ipAddress, int port = 7681, int localPort = 7681);
|
|
|
|
void Setup(int localPort, const char* remoteIpAddress, int remotePort);
|
|
void Receive();
|
|
bool SendTo(RemoteParticipantUDP* remoteParticipant, int bufferSize);
|
|
bool Publish(IMessage* msg);
|
|
|
|
// bool SendTest();
|
|
|
|
/// @brief Sens a message to the remote site (if set)
|
|
/// @param msg The message to send
|
|
/// @return True if a message could be sent.
|
|
bool Send(IMessage* msg) override;
|
|
void SetupUDP(int localPort,
|
|
const char* remoteIpAddress,
|
|
int remotePort) override;
|
|
void ReceiveUDP() override;
|
|
|
|
protected:
|
|
#if defined(IDF_VER)
|
|
char broadcastIpAddress[INET_ADDRSTRLEN];
|
|
|
|
int sock;
|
|
struct sockaddr_in dest_addr;
|
|
// struct sockaddr_in src_addr;
|
|
#endif
|
|
|
|
void GetBroadcastAddress();
|
|
};
|
|
|
|
} // namespace RoboidControl
|
|
|
|
#endif
|