summaryrefslogtreecommitdiffstats
path: root/src/knx/qknxtpdufactory_p.h
blob: 870ca4ab4bd4a1743d0318cfd146823fb9145ed9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
/******************************************************************************
**
** Copyright (C) 2017 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtKnx module.
**
** $QT_BEGIN_LICENSE:GPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 or (at your option) any later version
** approved by the KDE Free Qt Foundation. The licenses are as published by
** the Free Software Foundation and appearing in the file LICENSE.GPL3
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
******************************************************************************/

#ifndef QKNXTPDUFACTORY_P_H
#define QKNXTPDUFACTORY_P_H

//
//  W A R N I N G
//  -------------
//
// This file is not part of the Qt KNX API.  It exists for the convenience
// of the Qt KNX implementation.  This header file may change from version
// to version without notice, or even be removed.
//
// We mean it.
//

#include <QtKnx/qknxaddress.h>
#include <QtKnx/qtknxglobal.h>
#include <QtKnx/qknxinterfaceobjectproperty.h>
#include <QtKnx/qknxinterfaceobjectpropertydatatype.h>
#include <QtKnx/qknxinterfaceobjecttype.h>
#include <QtKnx/qknxtpdu.h>

QT_BEGIN_NAMESPACE

class Q_KNX_EXPORT QKnxTpduFactory final
{
public:
    QKnxTpduFactory() = delete;

    struct Q_KNX_EXPORT Multicast
    {
        Multicast() = delete;

        static QKnxTpdu createGroupValueReadTpdu();
        static QKnxTpdu createGroupValueResponseTpdu(const QKnxByteArray &data);
        static QKnxTpdu createGroupValueWriteTpdu(const QKnxByteArray &data);

        static QKnxTpdu createGroupPropertyValueReadTpdu(QKnxInterfaceObjectType object,
                                                     quint8 objectInstance,
                                                     QKnxInterfaceObjectProperty property);
        static QKnxTpdu createGroupPropertyValueResponseTpdu(QKnxInterfaceObjectType object,
                                                     quint8 objectInstance,
                                                     QKnxInterfaceObjectProperty property,
                                                     const QKnxByteArray &data);
        static QKnxTpdu createGroupPropertyValueWriteTpdu(QKnxInterfaceObjectType object,
                                                     quint8 objectInstance,
                                                     QKnxInterfaceObjectProperty property,
                                                     const QKnxByteArray &data);
        static QKnxTpdu createGroupPropertyValueInfoReportTpdu(QKnxInterfaceObjectType object,
                                                     quint8 objectInstance,
                                                     QKnxInterfaceObjectProperty property,
                                                     const QKnxByteArray &data);
    };

    struct Q_KNX_EXPORT Broadcast
    {
        Broadcast() = delete;

        static QKnxTpdu createNetworkParameterReadTpdu(QKnxInterfaceObjectType object,
                                                     QKnxInterfaceObjectProperty property,
                                                     const QKnxByteArray &testInfo);
        static QKnxTpdu createNetworkParameterResponseTpdu(QKnxInterfaceObjectType object,
                                                     QKnxInterfaceObjectProperty property,
                                                     const QKnxByteArray &testInfo,
                                                     const QKnxByteArray &testResult);
        static QKnxTpdu createNetworkParameterWriteTpdu(QKnxInterfaceObjectType object,
                                                     QKnxInterfaceObjectProperty property,
                                                     const QKnxByteArray &value);
        static QKnxTpdu createNetworkParameterInfoReportTpdu(QKnxInterfaceObjectType object,
                                                     QKnxInterfaceObjectProperty property,
                                                     const QKnxByteArray &testInfo,
                                                     const QKnxByteArray &testResult);

        static QKnxTpdu createSystemNetworkParameterReadTpdu(QKnxInterfaceObjectType object,
                                                     quint16 property,
                                                     const QKnxByteArray &testInfo);
        static QKnxTpdu createSystemNetworkParameterResponseTpdu(QKnxInterfaceObjectType object,
                                                     quint16 property,
                                                     const QKnxByteArray &testInfo,
                                                     const QKnxByteArray &testResult);
        static QKnxTpdu createSystemNetworkParameterWriteTpdu(QKnxInterfaceObjectType object,
                                                     quint16 property,
                                                     const QKnxByteArray &value);

        static QKnxTpdu createIndividualAddressReadTpdu();
        static QKnxTpdu createIndividualAddressResponseTpdu();
        static QKnxTpdu createIndividualAddressWriteTpdu(const QKnxAddress &newAddress);

        static QKnxTpdu createIndividualAddressSerialNumberReadTpdu(const QKnxByteArray &sn);
        static QKnxTpdu createIndividualAddressSerialNumberResponseTpdu(const QKnxByteArray &sn,
                                                     const QKnxAddress &domainAddress);
        static QKnxTpdu createIndividualAddressSerialNumberWriteTpdu(const QKnxByteArray &sn,
                                                     const QKnxAddress &newAddress);

        static QKnxTpdu createDomainAddressReadTpdu();
        static QKnxTpdu createDomainAddressResponseTpdu(const QKnxByteArray &domainAddress);
        static QKnxTpdu createDomainAddressWriteTpdu(const QKnxByteArray &domainAddress);

        static QKnxTpdu createDomainAddressSerialNumberReadTpdu(const QKnxByteArray &serialNumber);
        static QKnxTpdu createDomainAddressSerialNumberResponseTpdu(const QKnxByteArray &serialNumber,
                                                     const QKnxByteArray &domainAddress);
        static QKnxTpdu createDomainAddressSerialNumberWriteTpdu(const QKnxByteArray &serialNumber,
                                                     const QKnxByteArray &domainAddress);

        static QKnxTpdu createPll110DomainAddressSelectiveReadTpdu(quint8 domainAddress,
                                                     const QKnxAddress &startAddress,
                                                     quint8 range);
        static QKnxTpdu createRfDomainAddressSelectiveReadTpdu(const QKnxByteArray &startAddress,
                                                     const QKnxByteArray &endAddress);

        static QKnxTpdu createFeDomainAddressSelectiveReadTpdu(quint16 manufacturerId,
                                                     QKnxInterfaceObjectType object,
                                                     QKnxInterfaceObjectProperty property,
                                                     quint16 parameters);
    };

    struct Q_KNX_EXPORT PointToPoint
    {
        PointToPoint() = delete;

        enum Mode
        {
            Connectionless,
            ConnectionOriented
        };

        static QKnxTpdu createFunctionPropertyCommandTpdu(Mode mode, quint8 objectIndex,
                                                     QKnxInterfaceObjectProperty property,
                                                     const QKnxByteArray &data, quint8 seqNumber = 0);
        static QKnxTpdu createFunctionPropertyStateReadTpdu(Mode mode, quint8 objectIndex,
                                                     QKnxInterfaceObjectProperty property,
                                                     const QKnxByteArray &data, quint8 seqNumber = 0);
        static QKnxTpdu createFunctionPropertyStateResponseTpdu(Mode mode, quint8 objectIndex,
                                                     QKnxInterfaceObjectProperty property,
                                                     QKnxTpdu::ErrorCode code,
                                                     const QKnxByteArray &data, quint8 seqNumber = 0);

        static QKnxTpdu createDeviceDescriptorReadTpdu(Mode mode, quint8 descriptorType,
                                                     quint8 seqNumber = 0);
        static QKnxTpdu createDeviceDescriptorResponseTpdu(Mode mode, quint8 descriptorType,
                                                     const QKnxByteArray &deviceDescriptor,
                                                     quint8 seqNumber = 0);

        static QKnxTpdu createRestartTpdu(Mode mode, QKnxTpdu::ResetType type,
                                  QKnxTpdu::EraseCode code = QKnxTpdu::EraseCode::Reserved,
                                  quint8 channelNumber = 0, quint8 seqNumber = 0);
        static QKnxTpdu createRestartResponseTpdu(Mode mode, QKnxTpdu::ResetType type,
                                                     QKnxTpdu::ErrorCode code,
                                                     quint16 processTime, quint8 seqNumber = 0);

        static QKnxTpdu createPropertyValueReadTpdu(Mode mode, quint8 objectIndex,
                                                     QKnxInterfaceObjectProperty property,
                                                     quint8 nbElement, quint16 startIndex,
                                                     quint8 seqNumber = 0);
        static QKnxTpdu createPropertyValueResponseTpdu(Mode mode, quint8 objectIndex,
                                                     QKnxInterfaceObjectProperty property,
                                                     quint8 nbElement, quint16 startIndex,
                                                     const QKnxByteArray &data, quint8 seqNumber = 0);
        static QKnxTpdu createPropertyValueWriteTpdu(Mode mode, quint8 objectIndex,
                                                     QKnxInterfaceObjectProperty property,
                                                     quint8 nbElement, quint16 startIndex,
                                                     const QKnxByteArray &data, quint8 seqNumber = 0);

        static QKnxTpdu createPropertyDescriptionReadTpdu(Mode mode, quint8 objectIndex,
                                                     QKnxInterfaceObjectProperty property,
                                                     quint8 propertyIndex, quint8 seqNumber = 0);
        static QKnxTpdu createPropertyDescriptionResponseTpdu(Mode mode, quint8 objectIndex,
                                                     QKnxInterfaceObjectProperty property,
                                                     quint8 propertyIndex, bool writeable,
                                                     QKnxInterfaceObjectPropertyDataType::Id type,
                                                     quint16 maxSize, quint8 readLevel,
                                                     quint8 writeLevel, quint8 seqNumber = 0);

        static QKnxTpdu createLinkReadTpdu(Mode mode, quint8 groupObjectNumber, quint8 startIndex,
                                                     quint8 seqNumber = 0);
        static QKnxTpdu createLinkResponseTpdu(Mode mode, quint8 groupObjectNumber,
                                                     quint8 sendingAddress, quint8 startAddress,
                                                     const QVector<QKnxAddress> &addresses,
                                                     quint8 seqNumber = 0);
        static QKnxTpdu createLinkWriteTpdu(Mode mode, quint8 groupObjectNumber,
                                                     QKnxTpdu::LinkWriteFlags flags,
                                                     const QKnxAddress &groupAddress,
                                                     quint8 seqNumber = 0);

        static QKnxTpdu createFileStreamInfoReportTpdu(Mode mode, quint8 fileHandle,
                                                     quint8 fileBlockSeqNumber,
                                                     const QKnxByteArray &data, quint8 seqNumber = 0);
    };

    struct Q_KNX_EXPORT PointToPointConnectionless
    {
        PointToPointConnectionless() = delete;

        static QKnxTpdu createNetworkParameterResponseTpdu(QKnxInterfaceObjectType object,
                                                     QKnxInterfaceObjectProperty property,
                                                     const QKnxByteArray &testInfo,
                                                     const QKnxByteArray &testResult);
        static QKnxTpdu createNetworkParameterWriteTpdu(QKnxInterfaceObjectType objectType,
                                                     QKnxInterfaceObjectProperty property,
                                                     const QKnxByteArray &value);
    };

    struct Q_KNX_EXPORT PointToPointConnectionOriented
    {
        PointToPointConnectionOriented() = delete;

        static QKnxTpdu createAdcReadTpdu(quint8 channel, quint8 readCount, quint8 seqNumber);
        static QKnxTpdu createAdcResponseTpdu(quint8 channel, quint8 readCount, quint16 sumOfAdc,
                                                     quint8 seqNumber);

        static QKnxTpdu createMemoryReadTpdu(quint8 number, quint16 address, quint8 seqNumber = 0);
        static QKnxTpdu createMemoryResponseTpdu(quint8 number, quint16 address,
                                                     const QKnxByteArray &data, quint8 seqNumber = 0);
        static QKnxTpdu createMemoryWriteTpdu(quint8 number, quint16 address,
                                                     const QKnxByteArray &data, quint8 seqNumber = 0);

        static QKnxTpdu createUserMemoryReadTpdu(quint8 addressExtention, quint8 number,
                                                     quint16 address, quint8 seqNumber);
        static QKnxTpdu createUserMemoryResponseTpdu(quint8 addressExtention, quint8 number,
                                                     quint16 address, const QKnxByteArray &data,
                                                     quint8 seqNumber);
        static QKnxTpdu createUserMemoryWriteTpdu(quint8 addressExtention, quint8 number,
                                                     quint16 address,
                                                     const QKnxByteArray &data, quint8 seqNumber);

        static QKnxTpdu createUserManufacturerInfoReadTpdu(quint8 seqNumber);
        static QKnxTpdu createUserManufacturerInfoResponseTpdu(quint8 manufacturerId,
                                                     quint16 manufacturerSpecific, quint8 seqNumber);

        static QKnxTpdu createAuthorizeRequestTpdu(quint32 key, quint8 seqNumber);
        static QKnxTpdu createAuthorizeResponseTpdu(quint8 level, quint8 seqNumber);

        static QKnxTpdu createKeyWriteTpdu(quint8 level, quint32 key, quint8 seqNumber);
        static QKnxTpdu createKeyResponseTpdu(quint8 level, quint8 seqNumber);
    };
};

QT_END_NAMESPACE

#endif // QKNXTPDUFACTORY_H