This sample shows how to register callback functions for server item and datapoint value indications via the device API.
#include "Helper.h"
#include <iostream>
#include <memory>
#include <thread>
using namespace wz::baos::ip;
namespace
{
{
std::cout.fill('0');
std::cout << std::hex << std::uppercase;
{
std::cout << std::setw(2) << static_cast<std::int32_t>(
item) <<
" ";
}
std::cout << std::nouppercase << std::dec;
}
}
{
try
{
std::cout << "******************************************" << std::endl;
std::cout << "05_BaosIndications sample" << std::endl;
std::cout << "******************************************" << std::endl;
std::cout << std::endl;
setBaosLogLevel(wz::baos::LogLevel::warn);
options.setDurationOptionSupported(
true);
{
return 0;
}
std::cout <<
" Connection requested for " <<
ipAddress << std::endl;
{
{
std::cout <<
"Received server item indication for id " <<
static_cast<std::uint32_t
>(
serverItem.id) <<
": ";
std::cout << ", data: ";
std::cout.fill('0');
std::cout << std::hex << std::uppercase;
{
std::cout << std::setw(2) << static_cast<std::int32_t>(value) << " ";
}
std::cout << std::nouppercase << std::dec << std::endl;
}
});
{
{
std::uint16_t
id =
item.first;
std::cout << "Received datapoint value indication for id " << id << ": ";
std::cout << std::endl;
}
});
{
std::cout << "Press [Enter] to exit the application ..." << std::endl;
std::getchar();
}
else
{
std::cout <<
"Listening for indications for " <<
durationSeconds <<
" seconds ..." << std::endl;
}
}
catch (
const std::exception&
e)
{
std::cerr <<
"Failed: " <<
e.what() << std::endl;
return -1;
}
return 0;
}
Specialization for a IP v4 BAOSDevice.
Specialization for a TCP IP v4 BAOSConnection.
Global BAOS protocol defines and types.
Global BAOS SDK function and options.
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
Groups BAOS binary protocol specific types , defines and classes for Indications, Responses etc.
Definition Defines.h:33
std::map< std::uint16_t, DatapointValue > DatapointValues
A map with datapoint ids as keys and DatapointValue as values.
Definition Defines.h:36
BAOSLIB_EXPORT std::string serverItemIdToString(ServerItemId sid)
Convert the enum value to a human readable string.
wz::baos::Buffer DatapointValue
An type for the DatapointValues.
Definition Defines.h:34
std::vector< ServerItem > ServerItems
Type for a list of ServerItems.
Definition Defines.h:440
Global BAOS sdk namespace.
Definition config.h:69
BAOSLIB_EXPORT void setBaosLogLevel(wz::baos::LogLevel level)
A collection of fields representing those serveritems which won't ever change in a device.
Definition BaosDeviceDataTypes.h:49