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
01_BaosDeviceInformation.cpp

This demo shows how to read all ServerItems via the device API.

Usage:

01_BaosDeviceInformation <ip_address>
// e.g.:
01_BaosDeviceInformation 10.0.0.102
Note
Another possibility is via the connection API.
See also: Sample GetServerItem.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 <iostream>
#include <memory>
using namespace wz::baos;
int main(int argc, char* argv[])
{
try
{
std::cout << "******************************************" << std::endl;
std::cout << "01_BaosDeviceInformation 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
ip::BaosIp4Device baosDevice(ipAddress);
// read server items with static infos
const DeviceStaticInfo staticInfo = baosDevice.getStaticInfo();
std::cout << "Serial number: " << staticInfo.serialNumber.toString() << std::endl;
std::cout << "Manufacture code device: " << staticInfo.manufactureCodeDevice << std::endl;
std::cout << "MAC address: " << staticInfo.macAddress.toString() << std::endl;
std::cout << "Max datapoints: " << staticInfo.maxDatapoints << std::endl;
std::cout << "Max parameter bytes: " << staticInfo.maxParameterBytes << std::endl;
// read server items with config infos
const DeviceConfigInfo configInfo = baosDevice.getConfigInfo();
std::cout << "Manufacture code app: " << configInfo.manufactureCodeApp << std::endl;
std::cout << "Application ID: " << configInfo.applicationId << std::endl;
std::cout << "Application version: " << static_cast<std::int32_t>(configInfo.applicationVersion) << std::endl;
// read server items with runtime infos
// everything that may change during the runtime of the device
const DeviceRuntimeInfo runtimeInfo = baosDevice.getRuntimeInfo();
std::cout << "KNX bus connected: " << std::boolalpha << runtimeInfo.busConnected << std::endl;
std::cout << "Programming mode: " << std::boolalpha << runtimeInfo.programmingMode << std::endl;
}
catch (const wzcpp::error::WzBaseException& e)
{
std::cout << "Wz Exception in main: " << e.msg() << 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 SDK function and options.
Definition Helper.h:23
DeviceStaticInfo getStaticInfo(bool reload=false)
Get the information about a connected BAOS device that is never changed. Like serial number.
DeviceConfigInfo getConfigInfo(bool reload=false)
Get the information about a connected BAOS device that is typically only changed during configuration...
DeviceRuntimeInfo getRuntimeInfo(bool reload=false)
Get the information about a connected BAOS device that may change during runtime.
Represents a BAOS IP4 device with an underlying TCP connection (with BAOS unsecure connection-less)
Definition BaosIpv4Device.h:55
Global BAOS sdk namespace.
Definition config.h:69
BAOSLIB_EXPORT void setBaosLogLevel(wz::baos::LogLevel level)
A collection of fields representing those serveritems which may change if the configuration of the de...
Definition BaosDeviceDataTypes.h:94
std::uint8_t applicationVersion
Definition BaosDeviceDataTypes.h:98
std::uint16_t applicationId
Definition BaosDeviceDataTypes.h:96
std::uint16_t manufactureCodeApp
The manufacturer code of the ETS application e.g. 0x00C5 for Weinzierl.
Definition BaosDeviceDataTypes.h:95
A collection of fields representing those serveritems which may change during "normal" operation of t...
Definition BaosDeviceDataTypes.h:174
bool busConnected
The TP KNX bus connection state.
Definition BaosDeviceDataTypes.h:176
A collection of fields representing those serveritems which won't ever change in a device.
Definition BaosDeviceDataTypes.h:49
std::uint16_t maxDatapoints
The maximum amount of datapoint supported by this firmware.
Definition BaosDeviceDataTypes.h:64
std::uint16_t maxParameterBytes
The maximum amount of parameter bytes supported by this firmware.
Definition BaosDeviceDataTypes.h:65
wzcpp::SixByteArray macAddress
The MAC address.
Definition BaosDeviceDataTypes.h:59
wzcpp::SixByteArray serialNumber
manufacturer specific serial number
Definition BaosDeviceDataTypes.h:54
std::uint16_t manufactureCodeDevice
The manufacturer code of the device.
Definition BaosDeviceDataTypes.h:53