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 ApplicationControlField { GroupValueRead, GroupValueResponse, GroupValueWrite, IndividualAddressWrite, ..., Invalid }
enum EraseCode { Reserved, ConfirmedRestart, FactoryReset, ResetIa, ..., Invalid }
enum ErrorCode { NoError, Error }
enum LinkWriteFlags { AddGroupAddress, AddSendingGroupAddress, AddNotSendingGroupAddress, DeleteGroupAddress }
enum ResetType { BasicRestart, MasterRestart }
enum TransportControlField { DataGroup, DataBroadcast, DataSystemBroadcast, DataTagGroup, ..., Invalid }

Public Functions

QKnxTpdu()
QKnxTpdu(QKnxTpdu::TransportControlField tpci)
QKnxTpdu(QKnxTpdu::TransportControlField tpci, QKnxTpdu::ApplicationControlField apci, const QKnxByteArray &data = {})
QKnxTpdu(QKnxTpdu::TransportControlField tpci, quint8 seqNumber)
QKnxTpdu(QKnxTpdu::TransportControlField tpci, quint8 seqNumber, QKnxTpdu::ApplicationControlField apci, const QKnxByteArray &data = {})
QKnxTpdu(const QKnxTpdu &other)
QKnxTpdu(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
QKnxTpdu &operator=(const QKnxTpdu &other)
QKnxTpdu &operator=(QKnxTpdu &&other)
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

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.

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 QKnxTpdu::ApplicationControlField

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

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

enum QKnxTpdu::EraseCode

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

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

enum QKnxTpdu::ErrorCode

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

ConstantValue
QKnxTpdu::NoError0x00
QKnxTpdu::Error0x01

enum QKnxTpdu::LinkWriteFlags

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

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

enum QKnxTpdu::ResetType

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

ConstantValue
QKnxTpdu::BasicRestart0x00
QKnxTpdu::MasterRestart0x01

enum QKnxTpdu::TransportControlField

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

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

Member Function Documentation

QKnxTpdu::QKnxTpdu()

Creates a TPDU.

QKnxTpdu::QKnxTpdu(QKnxTpdu::TransportControlField tpci)

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

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, 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, 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(const QKnxTpdu &other)

Constructs a copy of other.

QKnxTpdu::QKnxTpdu(QKnxTpdu &&other)

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

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.

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

Assigns the specified other to this object.

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

Move-assigns other to this object instance.

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.

© 2018 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.