This sample shows how to read server items via the connection API over a BAOS secure TCP connection
This connection is supported by devices with protcol version >= 2.2. e.g. BAOS 774.1 or BAOS 777.1.
NOTE: The password is passed as second positional command line argument.
#include "Helper.h"
#include <wzcpp/features/utils.h>
#include <iostream>
using namespace wz::baos::ip;
namespace
{
{
}
}
{
try
{
std::cout << "******************************************" << std::endl;
std::cout << "BaosSecureTcpConnection sample" << std::endl;
std::cout << "******************************************" << std::endl;
std::cout << std::endl;
setBaosLogLevel(wz::baos::LogLevel::debug);
options.setSecureSampleOptionSupported(
true);
{
return 0;
}
std::cout <<
" Connection requested for " <<
ipAddress << std::endl;
{
}
else
{
std::cerr << "Unable to get serveritem ServerItemId::DeviceFriendlyName" << std::endl;
}
for (std::uint32_t index = 0; index < 100; ++index)
{
std::cout << "Reading datapoint value id 2:" << std::endl;
{
std::cout << "Id: 2, value: ";
std::cout << std::endl;
}
}
}
catch (
const std::exception&
e)
{
std::cerr <<
"Failed: " <<
e.what() << std::endl;
return -1;
}
return 0;
}
Specialization for a TCP IP v4 BAOSConnection.
Global BAOS protocol defines and types.
Global BAOS SDK function and options.
std::optional< protocol::ServerItem > getServerItem(protocol::ServerItemId id)
Get a single the ServerItem.
std::optional< protocol::DatapointValueState > getDpValue(std::uint16_t dpId)
Get a single datapoint value with its associated state.
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
void open(const std::string &ip4Address, std::uint16_t port=12004)
Open a connection to physical BAOS device.
Groups BAOS binary protocol specific types , defines and classes for Indications, Responses etc.
Definition Defines.h:33
Global BAOS sdk namespace.
Definition config.h:69
BAOSLIB_EXPORT void setBaosLogLevel(wz::baos::LogLevel level)
Structure to hold information about a serveritem.
Definition Defines.h:404