BAOS SDK v2  1.0.1
An SDK providing access to IP-BAOS devices through BAOS binary protocol version 2.x
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-2023 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(wzcpp::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<int>(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
Global BAOS sdk namespace.
Definition: config.h:62
void setBaosLogLevel(wzcpp::LogLevel level)