QKnxAddress Class

The QKnxAddress class represents a 16-bit KNX address value. More...

Header: #include <QKnxAddress>
qmake: QT += knx

Public Types

struct Group
struct Individual
enum class Notation { TwoLevel, ThreeLevel }
enum class Type { Group, Individual }

Public Functions

QKnxAddress(QKnxAddress::Type type, const QKnxByteArray &address)
QKnxAddress(QKnxAddress::Type type, const QString &address)
QKnxAddress(QKnxAddress::Type type, quint16 address)
QKnxAddress()
QKnxByteArray bytes() const
bool isBroadcast() const
bool isCouplerOrRouter() const
bool isUnregistered() const
bool isValid() const
quint8 mainOrAreaSection() const
quint8 middleOrLineSection() const
quint8 size() const
quint16 subOrDeviceSection(QKnxAddress::Notation notation = Notation::ThreeLevel) const
QString toString(QKnxAddress::Notation notation = Notation::ThreeLevel) const
QKnxAddress::Type type() const
bool operator!=(const QKnxAddress &other) const
bool operator==(const QKnxAddress &other) const

Static Public Members

QKnxAddress createGroup(quint8 mainGroup, quint16 subGroup)
QKnxAddress createGroup(quint8 mainGroup, quint16 middleGroup, quint8 subGroup)
QKnxAddress createIndividual(quint8 area, quint16 line, quint8 sequentialNumber)
QDebug operator<<(QDebug debug, const QKnxAddress &address)

Detailed Description

KNX is a fully distributed network, which accommodates up to 65,536 devices in a 16-bit individual address space. Concrete address types are group address and individual address.

Member Type Documentation

enum class QKnxAddress::Notation

This enum describes the supported human-readable representation of KNX addresses.

ConstantValueDescription
QKnxAddress::Notation::TwoLevel0x00The visual representation will be main group and sub group, separated by a forward slash.
QKnxAddress::Notation::ThreeLevel0x01The visual representation for group addresses will be main, middle, and sub group separated by a forward slash, while individual addresses will be formatted as area, line, and sequential number, separated by a dot.

Note: Only group addresses support 2-level notation.

enum class QKnxAddress::Type

This enum describes the supported KNX address types.

ConstantValueDescription
QKnxAddress::Type::Group0x01A group address is a 2-byte value that does not need to be unique. A device may have more than one group address.
QKnxAddress::Type::Individual0x00An individual address is a 2-byte value that needs to be unique within a KNX installation.

Member Function Documentation

QKnxAddress::QKnxAddress(QKnxAddress::Type type, const QKnxByteArray &address)

Creates a KNX address from the first two bytes of the address byte array. The type of the address is specified by type.

Note: The byte array must contain at least two elements.

QKnxAddress::QKnxAddress(QKnxAddress::Type type, const QString &address)

Creates a KNX address from the string address representation. The type of the address is specified by type. Depending on the parsed sections, the formatting is set to 2 or 3-level notation.

A KNX address can be in one of the following formats:

  • 2-level notation, such as 1/2000 for group addresses.
  • 3-level notation, such as 1/1/1 for group addresses or 1.1.1 for individual addresses.
  • Number in the range 0 to 65535 without a separator for group and individual addresses.

Note: For group address 2-level notation, the value of the main group should be in the range 0 to 31 and the sub group value in the range 0 to 2047.

Note: For group address 3-level notation, the value of the main group should be in the range 0 to 31, that of the middle group in the range 0 to 7, and that of the sub group in the range 0 to 255.

Note: For individual address 3-level notation, the value of area should be in the range 0 to 15, the value of line in the range 0 to 15, and the sequential number value in the range 0 to 255.

QKnxAddress::QKnxAddress(QKnxAddress::Type type, quint16 address)

Creates a KNX address from a 16-bit address value. The type of the address is specified by type. The value of address should be in the range 0 to 65535. The formatting is set to 3-level notation.

QKnxAddress::QKnxAddress()

Constructs an new, invalid KNX address object. The formatting is set to 3-level notation.

QKnxByteArray QKnxAddress::bytes() const

Returns a KNX address as a range of bytes if the address is valid; otherwise the return value is empty. Only the first two bytes of the return value are part of the address.

[static] QKnxAddress QKnxAddress::createGroup(quint8 mainGroup, quint16 subGroup)

Creates a KNX group address from the 2-level notation. The value of mainGroup should be in the range 0 to 31 and that of subGroup in the range 0 to 2047.

[static] QKnxAddress QKnxAddress::createGroup(quint8 mainGroup, quint16 middleGroup, quint8 subGroup)

Creates a KNX group address from the 3-level notation. The value of mainGroup should be in the range 0 to 31, that of middleGroup in the range 0 to 7, and that of subGroup in the range 0 to 255.

[static] QKnxAddress QKnxAddress::createIndividual(quint8 area, quint16 line, quint8 sequentialNumber)

Creates a KNX individual address from the 3-level notation. The value of area should be in the range 0 to 15, that of line in the range 0 to 15, and that of sequentialNumber in the range 0 to 255.

bool QKnxAddress::isBroadcast() const

Returns true if this is a valid group address object and the address is set to 0x0000; false otherwise.

bool QKnxAddress::isCouplerOrRouter() const

Returns true if this is a valid individual address object and the device's sequential number is set to 0x00; false otherwise.

Area and line couplers, as well as KNXnet/IP routers (routing) are given the sequential number 0x00.

For example, the individual address 1.5.0 identifies a KNXnet/IP router acting as a line coupler that couples the fifth line with the main line in the first area.

bool QKnxAddress::isUnregistered() const

Returns true if this is a valid individual address object and the device's sequential number is set to 0xff; false otherwise.

bool QKnxAddress::isValid() const

Returns true if this is a valid KNX address object; false otherwise.

quint8 QKnxAddress::mainOrAreaSection() const

Depending on the type of the address, this function returns either the area component or the main component of the address.

This function was introduced in Qt 5.12.

quint8 QKnxAddress::middleOrLineSection() const

Depending on the type of the address, this function returns either the line component or the middle component of the address.

This function was introduced in Qt 5.12.

quint8 QKnxAddress::size() const

Returns the size of a KNX address.

quint16 QKnxAddress::subOrDeviceSection(QKnxAddress::Notation notation = Notation::ThreeLevel) const

Depending on the type and the given notation, this function returns either the device component or the sub component of the address.

Note: Individual addresses support only 3-level notation, whereas group addresses support 2-level or 3-level notation.

This function was introduced in Qt 5.12.

QString QKnxAddress::toString(QKnxAddress::Notation notation = Notation::ThreeLevel) const

Returns the KNX address as a string formatted using the internal stored notation. An address of the type Group is formatted using a forward slash as a separator, while an address of the type Individual is formatted using a dot as separator.

Note: Individual addresses support only 3-level notation, whereas group addresses support 2-level or 3-level notation. If the address is invalid or 2-level notation is requested for individual addresses, an empty string is returned.

QKnxAddress::Type QKnxAddress::type() const

Returns the address type.

bool QKnxAddress::operator!=(const QKnxAddress &other) const

Returns true if this object is not equal with other; otherwise returns false.

bool QKnxAddress::operator==(const QKnxAddress &other) const

Returns true if this object is equal with other; otherwise returns false.

Related Non-Members

QDebug operator<<(QDebug debug, const QKnxAddress &address)

Writes the KNX address address to the debug stream.

© 2024 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.