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
GetDatapointDescription.cpp

This sample shows how to read datapoint descriptions via the connection API

Usage:

GetDatapointDescription <ip_address>
// e.g.:
GetDatapointDescription 10.0.0.102
Note
Another possibility is via the device API.
See also: Sample 01_BaosDatapointConfiguration.cpp
//
// Copyright (c) 2002-2026 WEINZIERL ENGINEERING GmbH
// All rights reserved.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER LIABILITY,
// WHETHER IN CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
//
#include "Helper.h"
#include <baos/Sdk.h>
#include <wzcpp/features/utils.h>
#include <iostream>
#include <memory>
using namespace wz::baos;
using namespace wz::baos::ip;
using namespace wz::baos::protocol;
/******************************************
** Main
*******************************************/
int main(int argc, char* argv[])
{
try
{
std::cout << "******************************************" << std::endl;
std::cout << "GetDatapointDescription sample" << std::endl;
std::cout << "******************************************" << std::endl;
std::cout << std::endl;
// Reduce log messages
setBaosLogLevel(wz::baos::LogLevel::warn);
// The CommandLineOptions::parse function
// validates the arguments and handles the help command
CommandLineOptions options;
options.parse(argc, argv);
if (options.wasHelpdisplayed())
{
return 0;
}
// Get the ip address from the parsed command line options
const std::string ipAddress = options.getIpAddress();
std::cout << " Connection requested for " << ipAddress << std::endl;
// Create a TPC/IP connection to the remote BAOS device
// Reads some datapoint descriptions from the device (single item per requested)
// Read datapoint description of id 1
std::cout << "Reading description of dp id 1 ... " << std::endl;
if (dpDescription.has_value())
{
std::cout << "DP size: " << dpSizeToString(dpDescription->size) << std::endl;
std::cout << "DP flags: " << dpDescription->flags.toString() << std::endl;
std::cout << "DPT: " << dptToString(dpDescription->dpt) << std::endl;
std::cout << std::endl;
}
// Read datapoint description of id == 10
std::cout << "Reading dp description of id == 10 ... " << std::endl;
if (dpDescription.has_value())
{
std::cout << "DP size: " << dpSizeToString(dpDescription->size) << std::endl;
std::cout << "DP flags: " << dpDescription->flags.toString() << std::endl;
std::cout << "DPT: " << dptToString(dpDescription->dpt) << std::endl;
std::cout << std::endl;
}
// Reads multiple datapoint descriptions (multiple items per requested)
// start = 1; number of = 50
std::cout << "Reading dp descriptions of id == 1 to 50 ... " << std::endl;
// trace the descriptions
for (const auto& item : descriptions)
{
std::cout << "Datapoint id " << item.first << std::endl;
const DatapointDescription& desc = item.second;
std::cout << "DP size: " << dpSizeToString(desc.size) << std::endl;
std::cout << "DP flags: " << desc.flags.toString() << std::endl;
std::cout << "DPT: " << dptToString(desc.dpt) << std::endl;
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.
Definition Helper.h:23
std::optional< protocol::DatapointDescription > getDpDescription(std::uint16_t dpId)
Get the datapoint description for one datapoint.
protocol::DatapointDescriptions getDpDescriptions(std::uint16_t startDpId, std::uint16_t numberOfItems)
Get a list of DatapointDescriptions.
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
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
std::map< std::uint16_t, DatapointDescription > DatapointDescriptions
Definition Defines.h:629
Global BAOS sdk namespace.
Definition config.h:69
BAOSLIB_EXPORT void setBaosLogLevel(wz::baos::LogLevel level)
std::string toString() const
Definition Defines.h:492
Represents the information about a datapoint in the BAOS device.
Definition Defines.h:621
DatapointSize size
The size as an enum value.
Definition Defines.h:622
DPT dpt
The datapoint type (e.G. DPT1 for boolean, see KNX Spec datapoint types for more details)
Definition Defines.h:624
DatapointConfigFlags flags
The communication flags.
Definition Defines.h:623