13 #ifndef __BAOSLIB_TCPCONNECTION_H__
14 #define __BAOSLIB_TCPCONNECTION_H__
24 namespace wz::baos::transport
29 namespace wz::baos::ip
44 using UPtr = std::unique_ptr<BaosTcpConnection>;
81 void open(
const std::string& ip4Address, std::uint16_t port = 12004);
114 void resolveMsgQPromises(std::exception_ptr eptr) noexcept;
121 std::uint64_t msgId_{0};
122 bool ensureAutoConnect_{
true};
123 bool verifyProtocolVersion_{
true};
147 using UPtr = std::unique_ptr<BaosConLessTcpConnection>;
184 using UPtr = std::unique_ptr<BaosConOrientedTcpConnection>;
207 using UPtr = std::unique_ptr<BaosSecureTcpConnection>;
208 using PasswordHash = std::array<std::uint8_t, 16>;
209 using AuthenticationCode = std::array<std::uint8_t, 16>;
216 void open(
const std::string& ip4Address,
217 const PasswordHash& passwordHash,
218 std::uint16_t port = 12004);
220 void open(
const std::string& ip4Address,
221 const PasswordHash& passwordHash,
const AuthenticationCode& authenticationCode,
222 std::uint16_t port = 12004);
224 static PasswordHash calculatePasswordHash(
const std::string& password);
225 static AuthenticationCode calculateDeviceAuthenticationCode(
const std::string& secret);
231 PasswordHash passwordHash_;
232 std::optional<AuthenticationCode> authenticationCode_;
Code regarding a connection to a physical BAOS device.
Base class for the transport protocol io used by BaosConnections.
Represents a connection to a BAOS device.
Definition: BaosConnection.h:67
State
Represents the internal state of this connection.
Definition: BaosConnection.h:355
std::unique_ptr< BaosConnection > UPtr
An alias for an unqiue pointer to this class.
Definition: BaosConnection.h:72
Buffer BaosFrame
An alias for the container type to store frame/packets/telegrams in.
Definition: BaosConnection.h:70
Represents an IOEvent.
Definition: IOEvent.h:44
A specialization for (connection-less) connection to the BAOS device via a TCP connection.
Definition: BaosTcpConnection.h:145
A specialization for (connection oriented) connection to the BAOS device via a TCP connection.
Definition: BaosTcpConnection.h:182
A specialization for secure connection to the BAOS device via a TCP connection.
Definition: BaosTcpConnection.h:205
Base class for connections to the BAOS device via a TCP connection.
Definition: BaosTcpConnection.h:42
void eventHandler()
Handles the incoming IOEvents.
Buffer TcpTransportFrame
Alias on how a TcpTransportFrame is represented.
Definition: BaosTcpConnection.h:45
void onStateChange(State oldState, State newState) override
Invoked if the internal connection state should be changed.
void enableVerifyProtocolVersion(bool enable)
Enables the option for verify the BAOS binary protocol version. The default value is true (enabled).
protocol::ResponseFuture closeImplAsync() override
The implementation function for closing a connection.
void reopen() override
Reopens the underlying connection, has to be implemented by derived classes.
bool isOpenImpl() override
The implementation function for getting the opened state of the connection.
void enableEnsureAutoConnect(bool enable)
Enables the option for ensure auto connect in legacy mode (e.g. 774.1 with auto connect mode)....
protocol::ResponseFuture sendImpl(BaosFrame &&frame) override
The implementation function for sending bytes to the connected device.
void open(const std::string &ip4Address, std::uint16_t port=12004)
Open a connection to physical BAOS device.
void handleTxTcp(IOEvent &&event)
Called for every Tx IOEvent (outgoing, send, transmit)
void handleRxTcp(IOEvent &&event)
Called for every Rx IOEvent (incoming, received)
void startImpl() override
The implementation function for starting the connection class.
Base class for a Transport input output connection.
Definition: TransportTcpIO.h:54
std::unique_ptr< TransportTcpIO > UPtr
Alias for a std::unique_ptr to this class.
Definition: TransportTcpIO.h:56
Global types and configuration for the whole SDK.
std::promise< BaseResponse::SPtr > ResponsePromise
Definition: Response.h:95
std::future< BaseResponse::SPtr > ResponseFuture
Definition: Response.h:97
std::vector< std::uint8_t > Buffer
An alias type for a byte buffer.
Definition: config.h:71
Represent the pair of IP address as string in the form "10.0.0.1020" and a port.
Definition: IpGeneral.h:34