QtKNX updates for 5.11

It has been a while since our last KNX development blog post, so we would like to give you a quick glance into some of the updates in QtKNX that are coming with the 5.11 release.

API improvements

One of the main improvements in this update was making Qt KNX's object introspection and construction more intuitive. To deal with the high number of specializations needed for the KNXnet/IP frame, we've included the proxy pattern. For example, the information carried by a KNXnet/IP connection request frame can be accessed by the QKnxNetIpConnectRequestProxy class.

Here is an example of how to use it while implementing the KNXnet/IP server side receiving a connection request frame:

QKnxNetIpFrame frame = //...;
QKnxNetIpConnectRequestProxy request(frame);
if (!request.isValid())
  return;

auto ctrlEndpoint = request.controlEndpoint(); auto dataEndpoint = request.dataEndpoint(); auto cri = request.requestInformation();

Because the frame is a structure that has many fields, having to know the exact order of parameters that can be passed to the constructor makes it difficult to use correctly. To make this easier, we have introduced the builder pattern. It allows us to encapsulate the construction and thus provide a more flexible solution.

Here is an example demonstrating the benefits of using the QKnxNetIpConnectRequestProxy::builder() instead of the constructor call to the QKnxNetIpConnectRequestProxy:

auto frame = QKnxNetIpConnectRequestProxy::builder()
             .setControlEndpoint(hpai)
             .setDataEndpoint(hpai)
             .create();

The proxy and builder patterns have been included in most of the QtKNX classes.

ETS KNX project file parsing

Another interesting functionality that we will now support is the ability to extract information from an ETS KNX project file, specifically the group addresses and its associated data point types (DPT). For those not so familiarized with the KNX world, ETS stands for Engineering Tool Software, it's a tool for the design and the commissioning of KNX installations.

Here is an example of how to use the functionality and request the parsing of an ETS KNX project file:

QKnxGroupAddressInfos infos(projFilePath);
infos.parse();

After that we check if there were any errors found through the parsing process:

if (infos.status() != QKnxGroupAddressInfos::Status::NoError)
	return;

Finally, we can extract the information that was parsed:

for (const auto &projId: infos.projectIds()) {
        auto installations = infos.installations(projId);
        // ...
        for (const QString &installation: installations) {
            for (const QKnxGroupAddressInfo &addInfo: groupAddresses) {
                if (!addInfo.isValid())
                    return;
                //...
            }
	}
}

Other important updates

  • Added new patterns for building and introspecting KNXnet/IP frames and structures.
  • Included new data point types (DPTs) up until DPT-30 and sub number less than 100.
  • Introduced new factory (QKnxDatapointTypeFactory), that simplifies the access to the DTPs and allows registering custom ones.
  • Enabled network address translation (NAT) support for KNXnet/IP device management and tunnel connections.
  • Added experimental API for building transport layer protocol data units (TPDUs).

We’ve also made important improvements on the documentation and many other updates. We encourage you to check it all out in the coming QtKNX 5.11 release. We look forward to your feedback!


Blog Topics:

Comments