BAOS SDK v2  1.2.1
An SDK providing access to IP-BAOS devices through BAOS binary protocol version 2.x
Loading...
Searching...
No Matches
BaosIpv4Device.h
Go to the documentation of this file.
1//
2// Copyright (c) 2002-2026 WEINZIERL ENGINEERING GmbH
3// All rights reserved.
4//
5// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
6// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
7// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
8// SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER LIABILITY,
9// WHETHER IN CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
10// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
11//
12
13#ifndef __BAOSLIB_IPV4INTERFACE_H__
14#define __BAOSLIB_IPV4INTERFACE_H__
15
16
17#include "baos/config.h"
20
22#include <memory>
23#include <optional>
24#include <utility>
26
27
33namespace wz::baos::ip
34{
35/*******************************************
36 * BaosIp4Device
37 *******************************************/
38
55{
56public:
57 virtual ~BaosIp4Device() = default;
58
65 BaosIp4Device(const std::string& ip4Address, std::uint16_t port = 12004);
66
76 void setConnectionData(const std::string& ip4Address, std::uint16_t port = 12004);
77
84
92
98
99protected:
100 std::string ip4Address_;
101 std::uint16_t port_;
104};
105
106
123
140{
141public:
142 virtual ~BaosConOrientedIp4Device() = default;
143
150 BaosConOrientedIp4Device(const std::string& ip4Address, std::uint16_t port = 12004);
151
153};
154
166{
167public:
168 using PasswordHash = std::array<std::uint8_t, 16>;
169 using AuthenticationCode = std::array<std::uint8_t, 16>;
170
171 virtual ~BaosSecureIp4Device() = default;
172
179 BaosSecureIp4Device(const std::string& ip4Address, const PasswordHash& passwordHash,
180 std::uint16_t port = 12004);
181
182 BaosSecureIp4Device(const std::string& ip4Address, const PasswordHash& passwordHash,
183 const AuthenticationCode& authenticationCode, std::uint16_t port = 12004);
184
186
197 void setConnectionData(const std::string& ip4Address, const PasswordHash& passwordHash,
198 std::uint16_t port = 12004);
199
211 void setConnectionData(const std::string& ip4Address, const PasswordHash& passwordHash,
212 const AuthenticationCode& authenticationCode, std::uint16_t port = 12004);
213
214 static PasswordHash calculatePasswordHash(const std::string& password);
215 static AuthenticationCode calculateDeviceAuthenticationCode(const std::string& secret);
216
217private:
218 PasswordHash passwordHash_;
219 std::optional<AuthenticationCode> authenticationCode_;
220};
221
222} // namespace wz::baos::ip
223
224#endif // __BAOSLIB_IPV4INTERFACE_H__
The high level API for BAOS devices.
Global BAOS protocol defines and types.
This class represents a BAOS device.
Definition BaosDevice.h:72
Represents a BAOS IP4 device with an underlying TCP connection (with BAOS unsecure connection-oriente...
Definition BaosIpv4Device.h:140
BaosConnection_UPtr getConnection() override
Pure virtual function to get a BaosConnection to the device.
BaosConOrientedIp4Device(const std::string &ip4Address, std::uint16_t port=12004)
Construct a new Baos Ip 4 Device object from an ip address and a port.
A specialization for (connection oriented) connection to the BAOS device via a TCP connection.
Definition BaosTcpConnection.h:182
Represents a BAOS IP4 device with an underlying TCP connection (with BAOS unsecure connection-less)
Definition BaosIpv4Device.h:55
BaosConnection_UPtr getConnection() override
Get a BaosConnection to the device.
void enableVerifyProtocolVersion(bool enable)
Enables the option for verify the BAOS binary protocol version. The default value is true (enabled).
BaosIp4Device(const std::string &ip4Address, std::uint16_t port=12004)
Construct a new Baos Ip 4 Device object from an ip address and a port.
void setConnectionData(const std::string &ip4Address, std::uint16_t port=12004)
Explicitly sets the connection data for a Baos Ip 4 Device object from an ip address and a port.
void enableEnsureAutoConnect(bool enable)
Enables the option for ensure auto connect in legacy mode (e.g. 774.1 with auto connect mode)....
Represents a BAOS IP4 device with an underlying TCP connection (with BAOS secure)
Definition BaosIpv4Device.h:166
void setConnectionData(const std::string &ip4Address, const PasswordHash &passwordHash, std::uint16_t port=12004)
Explicitly sets the connection data for a secure Baos Ip 4 Device object.
BaosConnection_UPtr getConnection() override
Get a BaosConnection to the device.
BaosSecureIp4Device(const std::string &ip4Address, const PasswordHash &passwordHash, std::uint16_t port=12004)
Construct a new Baos Ip 4 Device object from an ip address and a port.
void setConnectionData(const std::string &ip4Address, const PasswordHash &passwordHash, const AuthenticationCode &authenticationCode, std::uint16_t port=12004)
Explicitly sets the connection data for a secure Baos Ip 4 Device object.
bool verifyProtocolVersion_
Definition BaosTcpConnection.h:123
bool ensureAutoConnect_
Definition BaosTcpConnection.h:122
Global types and configuration for the whole SDK.
std::unique_ptr< BaosConnection > BaosConnection_UPtr
Alias for a std::unique pointer of a BaosConnection.
Definition BaosDevice.h:43