QKnxTpdu Class

The QKnxTpdu class represents a TPDU, which is the part of a link layer frame to be read by the network, transport, and application layers. More...

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

Public Types

enum class ApplicationControlField { GroupValueRead, GroupValueResponse, GroupValueWrite, IndividualAddressWrite, IndividualAddressRead, …, Invalid }
enum class EraseCode { Reserved, ConfirmedRestart, FactoryReset, ResetIa, ResetAp, …, Invalid }
enum class ErrorCode { NoError, Error }
enum class LinkWriteFlags { AddGroupAddress, AddSendingGroupAddress, AddNotSendingGroupAddress, DeleteGroupAddress }
enum class ResetType { BasicRestart, MasterRestart }
enum class TransportControlField { DataGroup, DataBroadcast, DataSystemBroadcast, DataTagGroup, DataIndividual, …, Invalid }

Public Functions

QKnxTpdu(QKnxTpdu &&other)
QKnxTpdu(const QKnxTpdu &other)
QKnxTpdu(QKnxTpdu::TransportControlField tpci, quint8 seqNumber, QKnxTpdu::ApplicationControlField apci, const QKnxByteArray &data = {})
QKnxTpdu(QKnxTpdu::TransportControlField tpci, quint8 seqNumber)
QKnxTpdu(QKnxTpdu::TransportControlField tpci, QKnxTpdu::ApplicationControlField apci, const QKnxByteArray &data = {})
QKnxTpdu(QKnxTpdu::TransportControlField tpci)
QKnxTpdu()
QKnxTpdu &operator=(QKnxTpdu &&other)
QKnxTpdu &operator=(const QKnxTpdu &other)
~QKnxTpdu()
QKnxTpdu::ApplicationControlField applicationControlField() const
QKnxByteArray bytes() const
QKnxByteArray data() const
quint16 dataSize() const
bool isValid() const
QKnx::MediumType mediumType() const
quint8 sequenceNumber() const
void setApplicationControlField(QKnxTpdu::ApplicationControlField apci)
void setData(const QKnxByteArray &data)
void setMediumType(QKnx::MediumType mediumType)
void setSequenceNumber(quint8 seqNumber)
void setTransportControlField(QKnxTpdu::TransportControlField tpci)
quint16 size() const
void swap(QKnxTpdu &other)
QKnxTpdu::TransportControlField transportControlField() const
bool operator!=(const QKnxTpdu &other) const
bool operator==(const QKnxTpdu &other) const

Static Public Members

QKnxTpdu::ApplicationControlField apci(const QKnxByteArray &data, quint8 index)
QKnxTpdu fromBytes(const QKnxByteArray &data, quint16 index, quint16 size, QKnx::MediumType mediumType = QKnx::MediumType::NetIP)
quint8 sequenceNumber(const QKnxByteArray &data, quint8 index, bool *ok = nullptr)
QKnxTpdu::TransportControlField tpci(const QKnxByteArray &data, quint8 index)
QDebug operator<<(QDebug debug, const QKnxTpdu &tpdu)

Detailed Description

Reading the bytes from left to right, a transport protocol data unit (TPDU) contains the following information:

The other fields contained by the TPDU depend on the selected service. For example, the T_CONNECT TPDU holds no application layer service.

The sequence number of the TPDU is used when transmitting frames between KNXNet/IP clients and servers to make sure the all packages are received and that they arrive in the correct order.

See also QKnxLinkLayerFrame and Qt KNX Tunneling Classes.

Member Type Documentation

enum class QKnxTpdu::ApplicationControlField

This enum describes the message codes dedicated to the application and representing an application service.

ConstantValue
QKnxTpdu::ApplicationControlField::GroupValueRead0x0000
QKnxTpdu::ApplicationControlField::GroupValueResponse0x0040
QKnxTpdu::ApplicationControlField::GroupValueWrite0x0080
QKnxTpdu::ApplicationControlField::IndividualAddressWrite0x00c0
QKnxTpdu::ApplicationControlField::IndividualAddressRead0x0100
QKnxTpdu::ApplicationControlField::IndividualAddressResponse0x0140
QKnxTpdu::ApplicationControlField::AdcRead0x0180
QKnxTpdu::ApplicationControlField::AdcResponse0x01c0
QKnxTpdu::ApplicationControlField::SystemNetworkParameterRead0x01c8
QKnxTpdu::ApplicationControlField::SystemNetworkParameterResponse0x01c9
QKnxTpdu::ApplicationControlField::SystemNetworkParameterWrite0x01ca
QKnxTpdu::ApplicationControlField::MemoryRead0x0200
QKnxTpdu::ApplicationControlField::MemoryResponse0x0240
QKnxTpdu::ApplicationControlField::MemoryWrite0x0280
QKnxTpdu::ApplicationControlField::UserMemoryRead0x02c0
QKnxTpdu::ApplicationControlField::UserMemoryResponse0x02c1
QKnxTpdu::ApplicationControlField::UserMemoryWrite0x02c2
QKnxTpdu::ApplicationControlField::UserManufacturerInfoRead0x02c5
QKnxTpdu::ApplicationControlField::UserManufacturerInfoResponse0x02c6
QKnxTpdu::ApplicationControlField::FunctionPropertyCommand0x02c7
QKnxTpdu::ApplicationControlField::FunctionPropertyStateRead0x02c8
QKnxTpdu::ApplicationControlField::FunctionPropertyStateResponse0x02c9
QKnxTpdu::ApplicationControlField::DeviceDescriptorRead0x0300
QKnxTpdu::ApplicationControlField::DeviceDescriptorResponse0x0340
QKnxTpdu::ApplicationControlField::Restart0x0380
QKnxTpdu::ApplicationControlField::AuthorizeRequest0x03d1
QKnxTpdu::ApplicationControlField::AuthorizeResponse0x03d2
QKnxTpdu::ApplicationControlField::KeyWrite0x03d3
QKnxTpdu::ApplicationControlField::KeyResponse0x03d4
QKnxTpdu::ApplicationControlField::PropertyValueRead0x03d5
QKnxTpdu::ApplicationControlField::PropertyValueResponse0x03d6
QKnxTpdu::ApplicationControlField::PropertyValueWrite0x03d7
QKnxTpdu::ApplicationControlField::PropertyDescriptionRead0x03d8
QKnxTpdu::ApplicationControlField::PropertyDescriptionResponse0x03d9
QKnxTpdu::ApplicationControlField::NetworkParameterRead0x03da
QKnxTpdu::ApplicationControlField::NetworkParameterResponse0x03db
QKnxTpdu::ApplicationControlField::IndividualAddressSerialNumberRead0x03dc
QKnxTpdu::ApplicationControlField::IndividualAddressSerialNumberResponse0x03dd
QKnxTpdu::ApplicationControlField::IndividualAddressSerialNumberWrite0x03de
QKnxTpdu::ApplicationControlField::DomainAddressWrite0x03e0
QKnxTpdu::ApplicationControlField::DomainAddressRead0x03e1
QKnxTpdu::ApplicationControlField::DomainAddressResponse0x03e2
QKnxTpdu::ApplicationControlField::DomainAddressSelectiveRead0x03e3
QKnxTpdu::ApplicationControlField::NetworkParameterWrite0x03e4
QKnxTpdu::ApplicationControlField::NetworkParameterInfoReport0x03db
QKnxTpdu::ApplicationControlField::LinkRead0x03e5
QKnxTpdu::ApplicationControlField::LinkResponse0x03e6
QKnxTpdu::ApplicationControlField::LinkWrite0x03e7
QKnxTpdu::ApplicationControlField::GroupPropValueRead0x03e8
QKnxTpdu::ApplicationControlField::GroupPropValueResponse0x03e9
QKnxTpdu::ApplicationControlField::GroupPropValueWrite0x03ea
QKnxTpdu::ApplicationControlField::GroupPropValueInfoReport0x03eb
QKnxTpdu::ApplicationControlField::DomainAddressSerialNumberRead0x03ec
QKnxTpdu::ApplicationControlField::DomainAddressSerialNumberResponse0x03ed
QKnxTpdu::ApplicationControlField::DomainAddressSerialNumberWrite0x03ee
QKnxTpdu::ApplicationControlField::FileStreamInfoReport0x03f0
QKnxTpdu::ApplicationControlField::Invalid0x00ff

enum class QKnxTpdu::EraseCode

This enum describes the erase codes needed when building a TPDU with the Restart service.

ConstantValue
QKnxTpdu::EraseCode::Reserved0
QKnxTpdu::EraseCode::ConfirmedRestart1
QKnxTpdu::EraseCode::FactoryReset2
QKnxTpdu::EraseCode::ResetIa3
QKnxTpdu::EraseCode::ResetAp4
QKnxTpdu::EraseCode::ResetParam5
QKnxTpdu::EraseCode::ResetLinks6
QKnxTpdu::EraseCode::ResetWithoutIa7
QKnxTpdu::EraseCode::Invalid8

enum class QKnxTpdu::ErrorCode

This enum describes the error codes needed when building a TPDU with the FunctionPropertyStateResponse or Restart service.

ConstantValue
QKnxTpdu::ErrorCode::NoError0x00
QKnxTpdu::ErrorCode::Error0x01

enum class QKnxTpdu::LinkWriteFlags

This enum describes the link write flags needed when building a TPDU with the LinkWrite service.

ConstantValue
QKnxTpdu::LinkWriteFlags::AddGroupAddress0x00
QKnxTpdu::LinkWriteFlags::AddSendingGroupAddress0x01
QKnxTpdu::LinkWriteFlags::AddNotSendingGroupAddress0x00
QKnxTpdu::LinkWriteFlags::DeleteGroupAddress0x02

enum class QKnxTpdu::ResetType

This enum describes the reset types needed when building a TPDU with the Restart service.

ConstantValue
QKnxTpdu::ResetType::BasicRestart0x00
QKnxTpdu::ResetType::MasterRestart0x01

enum class QKnxTpdu::TransportControlField

This enum describes the message codes dedicated to the transport layer.

ConstantValue
QKnxTpdu::TransportControlField::DataGroup0x00
QKnxTpdu::TransportControlField::DataBroadcast0x00
QKnxTpdu::TransportControlField::DataSystemBroadcast0x00
QKnxTpdu::TransportControlField::DataTagGroup0x04
QKnxTpdu::TransportControlField::DataIndividual0x00
QKnxTpdu::TransportControlField::DataConnected0x40
QKnxTpdu::TransportControlField::Connect0x80
QKnxTpdu::TransportControlField::Disconnect0x81
QKnxTpdu::TransportControlField::Acknowledge0xc2
QKnxTpdu::TransportControlField::NoAcknowledge0xc3
QKnxTpdu::TransportControlField::Invalid0xfc

Member Function Documentation

QKnxTpdu::QKnxTpdu(QKnxTpdu &&other)

Move-constructs an object instance, making it point to the same object that other was pointing to.

QKnxTpdu::QKnxTpdu(const QKnxTpdu &other)

Constructs a copy of other.

QKnxTpdu::QKnxTpdu(QKnxTpdu::TransportControlField tpci, quint8 seqNumber, QKnxTpdu::ApplicationControlField apci, const QKnxByteArray &data = {})

Creates a TPDU with the transport layer code indication set to tpci, sequence number set to seqNumber, application layer code indication set to apci, and the data set to data.

QKnxTpdu::QKnxTpdu(QKnxTpdu::TransportControlField tpci, quint8 seqNumber)

Creates a TPDU with the transport layer code indication set to tpci and the sequence number set to seqNumber.

QKnxTpdu::QKnxTpdu(QKnxTpdu::TransportControlField tpci, QKnxTpdu::ApplicationControlField apci, const QKnxByteArray &data = {})

Creates a TPDU with the transport layer code indication set to tpci, the application layer code indication set to apci, and the data set to data.

QKnxTpdu::QKnxTpdu(QKnxTpdu::TransportControlField tpci)

Creates a TPDU with the transport layer code indication set to tpci.

QKnxTpdu::QKnxTpdu()

Creates a TPDU.

QKnxTpdu &QKnxTpdu::operator=(QKnxTpdu &&other)

Move-assigns other to this object instance.

QKnxTpdu &QKnxTpdu::operator=(const QKnxTpdu &other)

Assigns the specified other to this object.

QKnxTpdu::~QKnxTpdu()

Deletes a TPDU.

[static] QKnxTpdu::ApplicationControlField QKnxTpdu::apci(const QKnxByteArray &data, quint8 index)

Returns the APCI field extracted out of the data byte array at the position index; otherwise returns Invalid.

Note: The given byte array is not further validated, so you need to be sure to pass data that is a TPDU.

QKnxTpdu::ApplicationControlField QKnxTpdu::applicationControlField() const

Returns the application layer control indication field of the TPDU.

See also setApplicationControlField().

QKnxByteArray QKnxTpdu::bytes() const

Returns the TPDU as an array of bytes.

QKnxByteArray QKnxTpdu::data() const

Returns the data part of the TPDU as an array of bytes.

Note: TPCI and APCI are not part of the returned byte array.

See also setData().

quint16 QKnxTpdu::dataSize() const

Returns the number of bytes of the TPDU data.

Note: The data part of a TPDU may contain the low byte of the application layer control indication (APCI), but excludes the byte for the transport layer control indication (TPCI) field.

[static] QKnxTpdu QKnxTpdu::fromBytes(const QKnxByteArray &data, quint16 index, quint16 size, QKnx::MediumType mediumType = QKnx::MediumType::NetIP)

Creates a TPDU with the medium type mediumType from the byte array data starting at the position index inside the array with the size size.

bool QKnxTpdu::isValid() const

Returns true if the TPDU is valid.

Note: This function is not implemented for all services and medium types. At the time of this writing, only KNXnet/IP is supported.

QKnx::MediumType QKnxTpdu::mediumType() const

Returns the medium type of the TPDU.

See also setMediumType().

quint8 QKnxTpdu::sequenceNumber() const

Returns the sequence number if the frame is connection oriented; otherwise returns 0.

See also setSequenceNumber().

[static] quint8 QKnxTpdu::sequenceNumber(const QKnxByteArray &data, quint8 index, bool *ok = nullptr)

Returns the sequence number extracted from the data byte array if the byte at position index can be verified as a valid TPCI field.

If an error occurs, ok is set to false and this function returns a negative value.

Note: The given byte array is not further validated, so you need to be sure to pass data that is a TPDU.

void QKnxTpdu::setApplicationControlField(QKnxTpdu::ApplicationControlField apci)

Sets the application layer control indication field to apci.

See also applicationControlField().

void QKnxTpdu::setData(const QKnxByteArray &data)

Sets the data part of the TPDU to data.

Note: The TPCI and APCI may not be a part of the passed argument.

See also data().

void QKnxTpdu::setMediumType(QKnx::MediumType mediumType)

Sets the medium type of the TPDU to mediumType.

See also mediumType().

void QKnxTpdu::setSequenceNumber(quint8 seqNumber)

Sets the sequence number to seqNumber if the frame is connection oriented; otherwise does nothing.

See also sequenceNumber().

void QKnxTpdu::setTransportControlField(QKnxTpdu::TransportControlField tpci)

Sets the transport layer control indication field to tpci.

See also transportControlField().

quint16 QKnxTpdu::size() const

Returns the number of bytes of the TPDU.

void QKnxTpdu::swap(QKnxTpdu &other)

Swaps other with this object. This operation is very fast and never fails.

[static] QKnxTpdu::TransportControlField QKnxTpdu::tpci(const QKnxByteArray &data, quint8 index)

Returns the TPCI field extracted from the data byte array at the position index; otherwise returns Invalid.

Note: If the TPCI field carries a sequence number, the value is removed from the return value.

Note: The given byte array is not further validated, so you need to be sure to pass data that is a TPDU.

QKnxTpdu::TransportControlField QKnxTpdu::transportControlField() const

Returns the transport layer code indication field of the TPDU.

See also setTransportControlField().

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

Returns true if this object and the given other are not equal; otherwise returns false.

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

Returns true if this object and the given other are equal; otherwise returns false.

Related Non-Members

QDebug operator<<(QDebug debug, const QKnxTpdu &tpdu)

Writes the KNX TPDU tpdu 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.