knx.ts 1.0.2 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/LICENSE +51 -21
  2. package/README.md +274 -61
  3. package/dist/@types/interfaces/connection.d.ts +80 -13
  4. package/dist/@types/interfaces/servers.d.ts +18 -0
  5. package/dist/@types/interfaces/servers.js +2 -0
  6. package/dist/connection/KNXService.d.ts +13 -30
  7. package/dist/connection/KNXService.js +4 -164
  8. package/dist/connection/KNXTunneling.d.ts +4 -4
  9. package/dist/connection/KNXTunneling.js +35 -62
  10. package/dist/connection/KNXUSBConnection.d.ts +20 -0
  11. package/dist/connection/KNXUSBConnection.js +358 -0
  12. package/dist/connection/KNXnetIPServer.d.ts +29 -12
  13. package/dist/connection/KNXnetIPServer.js +261 -83
  14. package/dist/connection/Router.d.ts +52 -32
  15. package/dist/connection/Router.js +225 -153
  16. package/dist/connection/TPUART.d.ts +8 -3
  17. package/dist/connection/TPUART.js +41 -37
  18. package/dist/connection/TunnelConnection.d.ts +3 -1
  19. package/dist/connection/TunnelConnection.js +6 -4
  20. package/dist/core/CEMI.d.ts +7 -2
  21. package/dist/core/CEMI.js +5 -8
  22. package/dist/core/EMI.d.ts +312 -200
  23. package/dist/core/EMI.js +511 -1007
  24. package/dist/core/KNXnetIPStructures.d.ts +10 -1
  25. package/dist/core/KNXnetIPStructures.js +15 -10
  26. package/dist/core/MessageCodeField.d.ts +1 -1
  27. package/dist/core/cache/GroupAddressCache.d.ts +57 -0
  28. package/dist/core/cache/GroupAddressCache.js +227 -0
  29. package/dist/core/data/KNXDataDecode.d.ts +2 -2
  30. package/dist/core/data/KNXDataDecode.js +198 -183
  31. package/dist/core/enum/EnumControlField.d.ts +0 -5
  32. package/dist/core/enum/EnumControlField.js +1 -7
  33. package/dist/core/enum/EnumControlFieldExtended.d.ts +1 -1
  34. package/dist/core/enum/EnumShortACKFrame.d.ts +1 -1
  35. package/dist/core/enum/ErrorCodeSet.js +59 -0
  36. package/dist/core/enum/KNXnetIPEnum.d.ts +2 -2
  37. package/dist/core/enum/KNXnetIPEnum.js +19 -1
  38. package/dist/core/layers/data/NPDU.d.ts +2 -1
  39. package/dist/core/layers/data/NPDU.js +6 -3
  40. package/dist/index.d.ts +19 -2
  41. package/dist/index.js +36 -1
  42. package/dist/server/KNXMQTTGateway.d.ts +13 -0
  43. package/dist/server/KNXMQTTGateway.js +164 -0
  44. package/dist/server/KNXWebSocketServer.d.ts +12 -0
  45. package/dist/server/KNXWebSocketServer.js +118 -0
  46. package/dist/utils/CEMIAdapter.d.ts +4 -3
  47. package/dist/utils/CEMIAdapter.js +26 -30
  48. package/dist/utils/Logger.d.ts +4 -4
  49. package/dist/utils/Logger.js +3 -7
  50. package/package.json +27 -7
package/dist/core/EMI.js CHANGED
@@ -5,15 +5,11 @@ const KNXHelper_1 = require("../utils/KNXHelper");
5
5
  const EnumControlFieldExtended_1 = require("./enum/EnumControlFieldExtended");
6
6
  const ControlField_1 = require("./ControlField");
7
7
  const MessageCodeField_1 = require("./MessageCodeField");
8
- const APCI_1 = require("./layers/interfaces/APCI");
9
- const APCIEnum_1 = require("./enum/APCIEnum");
10
8
  const checksumFrame_1 = require("../utils/checksumFrame");
11
9
  const SystemStatus_1 = require("./SystemStatus");
12
- class InvalidInputObject extends Error {
13
- constructor(className) {
14
- super(`The input object in the ${className} is must be an object with specific properties`);
15
- }
16
- }
10
+ const APCIEnum_1 = require("./enum/APCIEnum");
11
+ const APCI_1 = require("./layers/interfaces/APCI");
12
+ const NPDU_1 = require("./layers/data/NPDU");
17
13
  /**
18
14
  * @alias External_Message_Interface
19
15
  * @description The External Message Interface (EMI) is a standardized interface for communication between external devices and KNX systems. It allows for the integration of various external systems, such as building management systems, into the KNX network.
@@ -39,7 +35,6 @@ class EMI {
39
35
  let serviceName;
40
36
  // Priorizamos EMI2/IMI2, luego CEMI
41
37
  for (const [key, val] of Object.entries(MessageCodeField_1.MESSAGE_CODE_FIELD)) {
42
- // @ts-ignore
43
38
  const codes = val;
44
39
  if (codes["EMI2/IMI2"] && codes["EMI2/IMI2"].value === messageCode) {
45
40
  serviceName = key;
@@ -63,7 +58,6 @@ class EMI {
63
58
  EMI.ApplicationLayerEMI,
64
59
  ];
65
60
  for (const group of groups) {
66
- // @ts-ignore
67
61
  const ServiceClass = group[serviceName];
68
62
  if (ServiceClass && typeof ServiceClass.fromBuffer === "function") {
69
63
  return ServiceClass.fromBuffer(buffer);
@@ -76,127 +70,127 @@ class EMI {
76
70
  */
77
71
  static LayerAccess = {
78
72
  "PEI_Switch.req": class PEISwitchReq {
79
- constructor(value) {
80
- this.systemStatus = value.systemStatus;
81
- this.LL = value.LL;
82
- this.NL = value.NL;
83
- this.TLG = value.TLG;
84
- this.TLC = value.TLC;
85
- this.TLL = value.TLL;
86
- this.AL = value.AL;
87
- this.MAN = value.MAN;
88
- this.PEI = value.PEI;
89
- this.USR = value.USR;
90
- this.res = value.res;
73
+ constructor(systemStatus, LL, NL, TLG, TLC, TLL, AL, MAN, PEI, USR, res) {
74
+ this.systemStatus = systemStatus;
75
+ this.LL = LL;
76
+ this.NL = NL;
77
+ this.TLG = TLG;
78
+ this.TLC = TLC;
79
+ this.TLL = TLL;
80
+ this.AL = AL;
81
+ this.MAN = MAN;
82
+ this.PEI = PEI;
83
+ this.USR = USR;
84
+ this.res = res;
91
85
  }
92
86
  messageCode = MessageCodeField_1.MESSAGE_CODE_FIELD["PEI_Switch.req"]["EMI2/IMI2"].value;
93
87
  systemStatus;
94
- #LL = 0;
95
- #NL = 0;
96
- #TLG = 0;
97
- #TLC = 0;
98
- #TLL = 0;
99
- #AL = 0;
100
- #MAN = 0;
101
- #PEI = 0;
102
- #USR = 0;
103
- #res = 0;
88
+ _LL = 0;
89
+ _NL = 0;
90
+ _TLG = 0;
91
+ _TLC = 0;
92
+ _TLL = 0;
93
+ _AL = 0;
94
+ _MAN = 0;
95
+ _PEI = 0;
96
+ _USR = 0;
97
+ _res = 0;
104
98
  set LL(value) {
105
99
  if (value < 0 || value > 7)
106
100
  throw new TypeError("The property 'LL' must be 4 bits");
107
- this.#LL = value;
101
+ this._LL = value;
108
102
  }
109
103
  get LL() {
110
- return this.#LL;
104
+ return this._LL;
111
105
  }
112
106
  set NL(value) {
113
107
  if (value < 0 || value > 7)
114
108
  throw new TypeError("The property 'NL' must be 4 bits");
115
- this.#NL = value;
109
+ this._NL = value;
116
110
  }
117
111
  get NL() {
118
- return this.#NL;
112
+ return this._NL;
119
113
  }
120
114
  set TLG(value) {
121
115
  if (value < 0 || value > 7)
122
116
  throw new TypeError("The property 'TLG' must be 4 bits");
123
- this.#TLG = value;
117
+ this._TLG = value;
124
118
  }
125
119
  get TLG() {
126
- return this.#TLG;
120
+ return this._TLG;
127
121
  }
128
122
  set TLC(value) {
129
123
  if (value < 0 || value > 7)
130
124
  throw new TypeError("The property 'TLC' must be 4 bits");
131
- this.#TLC = value;
125
+ this._TLC = value;
132
126
  }
133
127
  get TLC() {
134
- return this.#TLC;
128
+ return this._TLC;
135
129
  }
136
130
  set TLL(value) {
137
131
  if (value < 0 || value > 7)
138
132
  throw new TypeError("The property 'TLL' must be 4 bits");
139
- this.#TLL = value;
133
+ this._TLL = value;
140
134
  }
141
135
  get TLL() {
142
- return this.#TLL;
136
+ return this._TLL;
143
137
  }
144
138
  set AL(value) {
145
139
  if (value < 0 || value > 7)
146
140
  throw new TypeError("The property 'AL' must be 4 bits");
147
- this.#AL = value;
141
+ this._AL = value;
148
142
  }
149
143
  get AL() {
150
- return this.#AL;
144
+ return this._AL;
151
145
  }
152
146
  set MAN(value) {
153
147
  if (value < 0 || value > 7)
154
148
  throw new TypeError("The property 'MAN' must be 4 bits");
155
- this.#MAN = value;
149
+ this._MAN = value;
156
150
  }
157
151
  get MAN() {
158
- return this.#MAN;
152
+ return this._MAN;
159
153
  }
160
154
  set PEI(value) {
161
155
  if (value < 0 || value > 7)
162
156
  throw new TypeError("The property 'PEI' must be 4 bits");
163
- this.#PEI = value;
157
+ this._PEI = value;
164
158
  }
165
159
  get PEI() {
166
- return this.#PEI;
160
+ return this._PEI;
167
161
  }
168
162
  set USR(value) {
169
163
  if (value < 0 || value > 7)
170
164
  throw new TypeError("The property 'USR' must be 4 bits");
171
- this.#USR = value;
165
+ this._USR = value;
172
166
  }
173
167
  get USR() {
174
- return this.#USR;
168
+ return this._USR;
175
169
  }
176
170
  set res(value) {
177
171
  if (value < 0 || value > 7)
178
172
  throw new TypeError("The property 'res' must be 4 bits");
179
- this.#res = value;
173
+ this._res = value;
180
174
  }
181
175
  get res() {
182
- return this.#res;
176
+ return this._res;
183
177
  }
184
178
  toBuffer() {
185
179
  let octet3 = 0;
186
- octet3 = octet3 | (this.#LL << 4);
187
- octet3 = octet3 | this.#NL;
180
+ octet3 = octet3 | (this._LL << 4);
181
+ octet3 = octet3 | this._NL;
188
182
  let octet4 = 0;
189
- octet4 = octet4 | (this.#TLG << 4);
190
- octet4 = octet4 | this.#TLC;
183
+ octet4 = octet4 | (this._TLG << 4);
184
+ octet4 = octet4 | this._TLC;
191
185
  let octet5 = 0;
192
- octet5 = octet5 | (this.#TLL << 4);
193
- octet5 = octet5 | this.#AL;
186
+ octet5 = octet5 | (this._TLL << 4);
187
+ octet5 = octet5 | this._AL;
194
188
  let octet6 = 0;
195
- octet6 = octet6 | (this.#MAN << 4);
196
- octet6 = octet6 | this.#PEI;
189
+ octet6 = octet6 | (this._MAN << 4);
190
+ octet6 = octet6 | this._PEI;
197
191
  let octet7 = 0;
198
- octet7 = octet7 | (this.#USR << 4);
199
- octet7 = octet7 | this.#res;
192
+ octet7 = octet7 | (this._USR << 4);
193
+ octet7 = octet7 | this._res;
200
194
  const buffer = Buffer.alloc(7);
201
195
  buffer.writeUInt8(this.messageCode, 0);
202
196
  buffer.writeUInt8(this.systemStatus.value, 1);
@@ -210,16 +204,16 @@ class EMI {
210
204
  describe() {
211
205
  return {
212
206
  systemStatus: `${this.systemStatus.describe()}`,
213
- LL: this.#LL.toString(),
214
- NL: this.#NL.toString(),
215
- TLG: this.#TLG.toString(),
216
- TLC: this.#TLC.toString(),
217
- TLL: this.#TLL.toString(),
218
- AL: this.#AL.toString(),
219
- MAN: this.#MAN.toString(),
220
- PEI: this.#PEI.toString(),
221
- USR: this.#USR.toString(),
222
- res: this.#res.toString(),
207
+ LL: this._LL.toString(),
208
+ NL: this._NL.toString(),
209
+ TLG: this._TLG.toString(),
210
+ TLC: this._TLC.toString(),
211
+ TLL: this._TLL.toString(),
212
+ AL: this._AL.toString(),
213
+ MAN: this._MAN.toString(),
214
+ PEI: this._PEI.toString(),
215
+ USR: this._USR.toString(),
216
+ res: this._res.toString(),
223
217
  };
224
218
  }
225
219
  },
@@ -232,19 +226,16 @@ class EMI {
232
226
  */
233
227
  static BusmonitorEMI = {
234
228
  "L_Busmon.ind": class LBusmonInd {
235
- constructor(value) {
236
- if (typeof value !== "object" || value === null) {
237
- throw new Error("L_Busmon.ind must be an object with specific properties.");
238
- }
239
- // Initialize properties based on the value provided
240
- this.status = value.status;
241
- this.timeStamp = value.timeStamp;
242
- this.controlField1 = value.controlField1;
243
- this.LPDU = value.LPDU;
229
+ constructor(status, timeStamp, controlField1, LPDU) {
230
+ // Initialize properties based on the values provided
231
+ this.status = status;
232
+ this.timeStamp = timeStamp;
233
+ this.controlField1 = controlField1;
234
+ this.LPDU = LPDU;
244
235
  }
245
236
  messageCode = MessageCodeField_1.MESSAGE_CODE_FIELD["L_Busmon.ind"]["EMI2/IMI2"].value;
246
237
  status;
247
- #timeStamp = 0;
238
+ _timeStamp = 0;
248
239
  controlField1;
249
240
  /**
250
241
  * Data Link Protocol Data Unit (LPDU) - This is the actual data payload of the message.
@@ -254,13 +245,13 @@ class EMI {
254
245
  */
255
246
  LPDU;
256
247
  get timeStamp() {
257
- return this.#timeStamp;
248
+ return this._timeStamp;
258
249
  }
259
250
  set timeStamp(value) {
260
251
  if (typeof value !== "number" || value < 0 || value > 65535) {
261
252
  throw new Error("timeStamp must be a number between 0 and 65535.");
262
253
  }
263
- this.#timeStamp = value;
254
+ this._timeStamp = value;
264
255
  }
265
256
  toBuffer() {
266
257
  const buffer = Buffer.alloc(5 + this.LPDU.length + 1); // bit 5 + lpdu + Checksum
@@ -316,12 +307,7 @@ class EMI {
316
307
  const controlField1 = new ControlField_1.ControlField(controlFieldByte);
317
308
  // LPDU (resto del buffer)
318
309
  const LPDU = buffer.subarray(5);
319
- return new LBusmonInd({
320
- status,
321
- timeStamp,
322
- controlField1,
323
- LPDU,
324
- });
310
+ return new LBusmonInd(status, timeStamp, controlField1, LPDU);
325
311
  }
326
312
  },
327
313
  /**
@@ -332,12 +318,9 @@ class EMI {
332
318
  * running system counter of the sending device equals the value given in “time”.
333
319
  */
334
320
  "L_Plain_Data.req": class LPlainDataReq {
335
- constructor(value) {
336
- if (typeof value !== "object" || value === null) {
337
- throw new Error("L_Plain_Data.req must be an object with specific properties.");
338
- }
339
- this.time = value.time;
340
- this.data = value.data;
321
+ constructor(time, data) {
322
+ this.time = time;
323
+ this.data = data;
341
324
  }
342
325
  time; // Time delay before sending the message
343
326
  data; // Data to be sent
@@ -385,10 +368,7 @@ class EMI {
385
368
  if (data.length > 28) {
386
369
  throw new Error(`Data too long for L_Plain_Data.req: ${data.length} bytes (max 28)`);
387
370
  }
388
- return new LPlainDataReq({
389
- time,
390
- data,
391
- });
371
+ return new LPlainDataReq(time, data);
392
372
  }
393
373
  },
394
374
  };
@@ -398,42 +378,36 @@ class EMI {
398
378
  */
399
379
  static DataLinkLayerEMI = {
400
380
  "L_Data.req": class LDataReq {
401
- constructor(value) {
402
- if (typeof value !== "object" || value === null) {
403
- throw new Error("L_Data.req must be an object with specific properties.");
404
- }
381
+ addressType;
382
+ npci;
383
+ constructor(priority, ackRequest, destinationAddress, addressType, npci, npdu) {
384
+ this.addressType = addressType;
385
+ this.npci = npci;
405
386
  this.controlField1 = new ControlField_1.ControlField(0);
406
- this.controlField1.priority = value.control.priority;
407
- this.controlField1.ackRequest = value.control.ackRequest;
408
- if (KNXHelper_1.KNXHelper.isValidGroupAddress(value.destinationAddress) ||
409
- KNXHelper_1.KNXHelper.isValidIndividualAddress(value.destinationAddress)) {
410
- this.destinationAddress = value.destinationAddress;
387
+ this.controlField1.priority = priority;
388
+ this.controlField1.ackRequest = ackRequest;
389
+ if (KNXHelper_1.KNXHelper.isValidGroupAddress(destinationAddress) ||
390
+ KNXHelper_1.KNXHelper.isValidIndividualAddress(destinationAddress)) {
391
+ this.destinationAddress = destinationAddress;
411
392
  }
412
393
  else {
413
394
  throw new Error("The Destination Address is invalid Group Address or Individual Address");
414
395
  }
415
- this.addressType = value.addressType;
416
- this.NPCI = value.NPCI;
417
- this.npdu = value.NPDU;
396
+ this.addressType = addressType;
397
+ this.npci = npci;
398
+ this.npdu = npdu;
418
399
  }
419
400
  messageCode = MessageCodeField_1.MESSAGE_CODE_FIELD["L_Data.req"]["EMI2/IMI2"].value;
420
401
  controlField1; // Control field 1
421
402
  destinationAddress; // Destination address
422
- addressType;
423
- NPCI;
424
- octNumber = 0;
425
403
  npdu; // Network Protocol Data Unit (NPDU)
426
404
  toBuffer() {
427
- const buffer = Buffer.alloc(7 + this.npdu.length);
405
+ const npduBuffer = this.npdu.toBuffer();
406
+ const buffer = Buffer.alloc(6 + npduBuffer.length);
428
407
  buffer.writeUInt8(this.messageCode, 0);
429
- this.controlField1.buffer.copy(buffer, 1); // Assuming controlField1 is a Buffer
408
+ this.controlField1.buffer.copy(buffer, 1);
430
409
  KNXHelper_1.KNXHelper.GetAddress_(this.destinationAddress).copy(buffer, 4);
431
- buffer[6] =
432
- 0x00 |
433
- ((this.addressType << 7) |
434
- (this.NPCI << 4) |
435
- (this.npdu.length & 0x0f));
436
- this.npdu.copy(buffer, 7);
410
+ npduBuffer.copy(buffer, 6);
437
411
  return buffer;
438
412
  }
439
413
  describe() {
@@ -441,10 +415,7 @@ class EMI {
441
415
  messageCode: `Código de mensaje: ${this.messageCode}`,
442
416
  controlField1: `Campo de control 1: ${this.controlField1.describe()}`,
443
417
  destinationAddress: `Dirección de destino: ${this.destinationAddress}`,
444
- addressType: `AT: ${EnumControlFieldExtended_1.AddressType[this.addressType]}`,
445
- npci: `NPCI: ${this.NPCI}`,
446
- npdu: `NPDU: ${this.npdu.toString("hex")}`,
447
- octNumber: this.npdu.length.toString(),
418
+ npdu: this.npdu.describe(),
448
419
  rawValue: `Valor numérico: ${this.toBuffer().toString("hex")}`,
449
420
  };
450
421
  }
@@ -458,45 +429,31 @@ class EMI {
458
429
  }
459
430
  const controlFieldByte = buffer.readUInt8(1);
460
431
  const controlField1 = new ControlField_1.ControlField(controlFieldByte);
461
- //[cite_start]// Bytes 2 and 3 are unused in Req [cite: 273]
462
432
  const destinationAddressBuf = buffer.subarray(4, 6);
463
- // Nota: Asumimos dirección de grupo por defecto si no podemos distinguir, pero el AT nos dirá
464
433
  const octet6 = buffer.readUInt8(6);
465
434
  const addressType = (octet6 >> 7) & 0x01;
466
- const NPCI = (octet6 >> 4) & 0x07;
467
- const length = octet6 & 0x0f;
435
+ const NPCI_val = (octet6 >> 4) & 0x07;
436
+ // const length = octet6 & 0x0f;
468
437
  const destinationAddress = KNXHelper_1.KNXHelper.GetAddress(destinationAddressBuf, addressType === EnumControlFieldExtended_1.AddressType.GROUP ? "/" : ".");
469
- const npdu = buffer.subarray(7, 7 + length);
470
- return new LDataReq({
471
- control: {
472
- priority: controlField1.priority,
473
- ackRequest: controlField1.ackRequest,
474
- },
475
- destinationAddress: destinationAddress,
476
- addressType: addressType,
477
- NPCI: NPCI,
478
- NPDU: npdu,
479
- });
438
+ const npdu = NPDU_1.NPDU.fromBuffer(buffer.subarray(6));
439
+ return new LDataReq(controlField1.priority, controlField1.ackRequest, destinationAddress, addressType, NPCI_val, npdu);
480
440
  }
481
441
  },
482
442
  "L_Data.con": class LDataCon {
483
- constructor(value) {
484
- if (typeof value !== "object" || value === null) {
485
- throw new Error("L_Data.req must be an object with specific properties.");
486
- }
443
+ constructor(priority, confirm, destinationAddress, addressType, npci, npdu) {
487
444
  this.controlField1 = new ControlField_1.ControlField(0);
488
- this.controlField1.priority = value.control.priority;
489
- this.controlField1.confirm = value.control.confirm;
490
- if (KNXHelper_1.KNXHelper.isValidGroupAddress(value.destinationAddress) ||
491
- KNXHelper_1.KNXHelper.isValidIndividualAddress(value.destinationAddress)) {
492
- this.destinationAddress = value.destinationAddress;
445
+ this.controlField1.priority = priority;
446
+ this.controlField1.confirm = confirm;
447
+ if (KNXHelper_1.KNXHelper.isValidGroupAddress(destinationAddress) ||
448
+ KNXHelper_1.KNXHelper.isValidIndividualAddress(destinationAddress)) {
449
+ this.destinationAddress = destinationAddress;
493
450
  }
494
451
  else {
495
452
  throw new Error("The Destination Address is invalid Group Address or Individual Address");
496
453
  }
497
- this.addressType = value.addressType;
498
- this.NPCI = value.NPCI;
499
- this.npdu = value.NPDU;
454
+ this.addressType = addressType;
455
+ this.NPCI = npci;
456
+ this.npdu = npdu;
500
457
  }
501
458
  messageCode = MessageCodeField_1.MESSAGE_CODE_FIELD["L_Data.con"]["EMI2/IMI2"].value;
502
459
  controlField1; // Control field 1
@@ -510,11 +467,7 @@ class EMI {
510
467
  buffer.writeUInt8(this.messageCode, 0);
511
468
  this.controlField1.buffer.copy(buffer, 1); // Assuming controlField1 is a Buffer
512
469
  KNXHelper_1.KNXHelper.GetAddress_(this.destinationAddress).copy(buffer, 4);
513
- buffer[6] =
514
- 0x00 |
515
- ((this.addressType << 7) |
516
- (this.NPCI << 4) |
517
- (this.npdu.length & 0x0f));
470
+ buffer[6] = 0x00 | ((this.addressType << 7) | (this.NPCI << 4) | (this.npdu.length & 0x0f));
518
471
  this.npdu.copy(buffer, 7);
519
472
  return buffer;
520
473
  }
@@ -542,42 +495,29 @@ class EMI {
542
495
  const controlField1 = new ControlField_1.ControlField(controlFieldByte);
543
496
  const octet6 = buffer.readUInt8(6);
544
497
  const addressType = (octet6 >> 7) & 0x01;
545
- const NPCI = (octet6 >> 4) & 0x07;
498
+ const NPCI_val = (octet6 >> 4) & 0x07;
546
499
  const length = octet6 & 0x0f;
547
- //[cite_start]// Bytes 2 and 3 unused [cite: 282]
548
500
  const destinationAddressBuf = buffer.subarray(4, 6);
549
501
  const destinationAddress = KNXHelper_1.KNXHelper.GetAddress(destinationAddressBuf, addressType === EnumControlFieldExtended_1.AddressType.GROUP ? "/" : ".");
550
502
  const npdu = buffer.subarray(7, 7 + length);
551
- return new LDataCon({
552
- control: {
553
- priority: controlField1.priority,
554
- confirm: controlField1.confirm,
555
- },
556
- destinationAddress: destinationAddress,
557
- addressType: addressType,
558
- NPCI: NPCI,
559
- NPDU: npdu,
560
- });
503
+ return new LDataCon(controlField1.priority, controlField1.confirm, destinationAddress, addressType, NPCI_val, npdu);
561
504
  }
562
505
  },
563
506
  "L_Data.ind": class LDataInd {
564
- constructor(value) {
565
- if (typeof value !== "object" || value === null) {
566
- throw new Error("L_Data.ind must be an object with specific properties.");
567
- }
507
+ constructor(priority, sourceAddress, destinationAddress, addressType, npci, npdu) {
568
508
  this.controlField1 = new ControlField_1.ControlField(0);
569
- this.controlField1.priority = value.control.priority;
570
- if (KNXHelper_1.KNXHelper.isValidGroupAddress(value.destinationAddress) ||
571
- KNXHelper_1.KNXHelper.isValidIndividualAddress(value.destinationAddress)) {
572
- this.destinationAddress = value.destinationAddress;
509
+ this.controlField1.priority = priority;
510
+ if (KNXHelper_1.KNXHelper.isValidGroupAddress(destinationAddress) ||
511
+ KNXHelper_1.KNXHelper.isValidIndividualAddress(destinationAddress)) {
512
+ this.destinationAddress = destinationAddress;
573
513
  }
574
514
  else {
575
515
  throw new Error("The Destination Address is invalid Group Address or Individual Address");
576
516
  }
577
- this.sourceAddress = value.sourceAddress;
578
- this.addressType = value.addressType;
579
- this.NPCI = value.NPCI;
580
- this.npdu = value.NPDU;
517
+ this.sourceAddress = sourceAddress;
518
+ this.addressType = addressType;
519
+ this.NPCI = npci;
520
+ this.npdu = npdu;
581
521
  }
582
522
  messageCode = MessageCodeField_1.MESSAGE_CODE_FIELD["L_Data.ind"]["EMI2/IMI2"].value;
583
523
  controlField1; // Control field 1
@@ -593,11 +533,7 @@ class EMI {
593
533
  this.controlField1.buffer.copy(buffer, 1); // Assuming controlField1 is a Buffer
594
534
  KNXHelper_1.KNXHelper.GetAddress_(this.sourceAddress).copy(buffer, 2);
595
535
  KNXHelper_1.KNXHelper.GetAddress_(this.destinationAddress).copy(buffer, 4);
596
- buffer[6] =
597
- 0x00 |
598
- ((this.addressType << 7) |
599
- (this.NPCI << 4) |
600
- (this.npdu.length & 0x0f));
536
+ buffer[6] = 0x00 | ((this.addressType << 7) | (this.NPCI << 4) | (this.npdu.length & 0x0f));
601
537
  this.npdu.copy(buffer, 7);
602
538
  return buffer;
603
539
  }
@@ -628,58 +564,48 @@ class EMI {
628
564
  const sourceAddress = KNXHelper_1.KNXHelper.GetAddress(sourceAddressBuf, ".");
629
565
  const octet6 = buffer.readUInt8(6);
630
566
  const addressType = (octet6 >> 7) & 0x01;
631
- const NPCI = (octet6 >> 4) & 0x07;
567
+ const NPCI_val = (octet6 >> 4) & 0x07;
632
568
  const length = octet6 & 0x0f;
633
569
  const destinationAddressBuf = buffer.subarray(4, 6);
634
570
  const destinationAddress = KNXHelper_1.KNXHelper.GetAddress(destinationAddressBuf, addressType === EnumControlFieldExtended_1.AddressType.GROUP ? "/" : ".");
635
571
  const npdu = buffer.subarray(7, 7 + length);
636
- return new LDataInd({
637
- control: {
638
- priority: controlField1.priority,
639
- },
640
- sourceAddress: sourceAddress,
641
- destinationAddress: destinationAddress,
642
- addressType: addressType,
643
- NPCI: NPCI,
644
- NPDU: npdu,
645
- });
572
+ return new LDataInd(controlField1.priority, sourceAddress, destinationAddress, addressType, NPCI_val, npdu);
646
573
  }
647
574
  },
648
575
  "L_Poll_Data.req": class LPollDataReq {
649
- constructor(value) {
650
- this.#pollingGroup = value.pollingGroup;
651
- this.#nrOfSlots = value.nrOfSlots;
576
+ constructor(pollingGroup, nrOfSlots) {
577
+ this.pollingGroup = pollingGroup;
578
+ this.nrOfSlots = nrOfSlots;
652
579
  }
653
580
  messageCode = MessageCodeField_1.MESSAGE_CODE_FIELD["L_Poll_Data.req"]["EMI2/IMI2"].value;
654
581
  control = 0xf0;
655
- #pollingGroup = 0;
656
- #nrOfSlots = 0;
582
+ _pollingGroup = 0;
583
+ _nrOfSlots = 0;
657
584
  set pollingGroup(value) {
658
- if (value < 0 || value > 65.535)
585
+ if (value < 0 || value > 65535)
659
586
  throw new Error("The value must be 16 bits");
660
- this.#pollingGroup = value;
587
+ this._pollingGroup = value;
661
588
  }
662
589
  get pollingGroup() {
663
- return this.#pollingGroup;
590
+ return this._pollingGroup;
664
591
  }
665
592
  set nrOfSlots(value) {
666
593
  if (value < 0 || value > 7)
667
594
  throw new Error("The value must be 4 bits");
668
- this.#nrOfSlots = value;
595
+ this._nrOfSlots = value;
669
596
  }
670
597
  get nrOfSlots() {
671
- return this.#nrOfSlots;
598
+ return this._nrOfSlots;
672
599
  }
673
600
  toBuffer() {
674
601
  const buffer = Buffer.alloc(7);
675
602
  let octet7 = 0;
676
- octet7 = octet7 | (this.#nrOfSlots & 0x0f);
603
+ octet7 = octet7 | (this._nrOfSlots & 0x0f);
677
604
  buffer.writeUInt8(this.messageCode, 0);
678
605
  buffer.writeUInt8(this.control, 1);
679
606
  buffer.writeUInt8(0, 2);
680
607
  buffer.writeUInt8(0, 3);
681
- buffer.writeUInt8(this.#pollingGroup & 0xff00, 4);
682
- buffer.writeUInt8(this.#pollingGroup & 0x00ff, 5);
608
+ buffer.writeUInt16BE(this._pollingGroup, 4);
683
609
  buffer.writeUInt8(octet7, 6);
684
610
  return buffer;
685
611
  }
@@ -687,8 +613,8 @@ class EMI {
687
613
  return {
688
614
  messageCode: `Codigo de mensaje: ${this.messageCode}`,
689
615
  control: `Control: ${this.control}`,
690
- pollingGroup: `${this.#pollingGroup}`,
691
- nrOfGroup: `${this.#nrOfSlots}`,
616
+ pollingGroup: `${this._pollingGroup}`,
617
+ nrOfGroup: `${this._nrOfSlots}`,
692
618
  };
693
619
  }
694
620
  static fromBuffer(buffer) {
@@ -701,47 +627,43 @@ class EMI {
701
627
  }
702
628
  const pollingGroup = buffer.readUInt16BE(4);
703
629
  const nrOfSlots = (buffer.readUInt8(6) & 0x0f);
704
- return new LPollDataReq({
705
- pollingGroup,
706
- nrOfSlots,
707
- });
630
+ return new LPollDataReq(pollingGroup, nrOfSlots);
708
631
  }
709
632
  },
710
633
  "L_Poll_Data.con": class LPollDataCon {
711
- constructor(value) {
712
- this.#pollingGroup = value.pollingGroup;
713
- this.#nrOfSlots = value.nrOfSlots;
714
- this.control.confirm = value.control.confirm;
634
+ constructor(pollingGroup, nrOfSlots, confirm) {
635
+ this.pollingGroup = pollingGroup;
636
+ this.nrOfSlots = nrOfSlots;
637
+ this.control.confirm = confirm;
715
638
  }
716
639
  control = new ControlField_1.ControlField(0xf0);
717
- #pollingGroup = 0;
718
- #nrOfSlots = 0;
640
+ _pollingGroup = 0;
641
+ _nrOfSlots = 0;
719
642
  set pollingGroup(value) {
720
- if (value < 0 || value > 65.535)
643
+ if (value < 0 || value > 65535)
721
644
  throw new Error("The value must be 16 bits");
722
- this.#pollingGroup = value;
645
+ this._pollingGroup = value;
723
646
  }
724
647
  get pollingGroup() {
725
- return this.#pollingGroup;
648
+ return this._pollingGroup;
726
649
  }
727
650
  set nrOfSlots(value) {
728
651
  if (value < 0 || value > 7)
729
652
  throw new Error("The value must be 4 bits");
730
- this.#nrOfSlots = value;
653
+ this._nrOfSlots = value;
731
654
  }
732
655
  get nrOfSlots() {
733
- return this.#nrOfSlots;
656
+ return this._nrOfSlots;
734
657
  }
735
658
  toBuffer() {
736
659
  const buffer = Buffer.alloc(7);
737
660
  let octet7 = 0;
738
- octet7 = octet7 | (this.#nrOfSlots & 0x0f);
661
+ octet7 = octet7 | (this._nrOfSlots & 0x0f);
739
662
  buffer.writeUInt8(MessageCodeField_1.MESSAGE_CODE_FIELD["L_Poll_Data.con"]["EMI2/IMI2"].value, 0);
740
663
  this.control.buffer.copy(buffer, 1);
741
664
  buffer.writeUInt8(0, 2);
742
665
  buffer.writeUInt8(0, 3);
743
- buffer.writeUInt8(this.#pollingGroup & 0xff00, 4);
744
- buffer.writeUInt8(this.#pollingGroup & 0x00ff, 5);
666
+ buffer.writeUInt16BE(this._pollingGroup, 4);
745
667
  buffer.writeUInt8(octet7, 6);
746
668
  return buffer;
747
669
  }
@@ -749,8 +671,8 @@ class EMI {
749
671
  return {
750
672
  messageCode: `Codigo de mensaje: ${MessageCodeField_1.MESSAGE_CODE_FIELD["L_Poll_Data.con"]["EMI2/IMI2"].value}`,
751
673
  control: `Control: ${this.control}`,
752
- pollingGroup: `${this.#pollingGroup}`,
753
- nrOfGroup: `${this.#nrOfSlots}`,
674
+ pollingGroup: `${this._pollingGroup}`,
675
+ nrOfGroup: `${this._nrOfSlots}`,
754
676
  };
755
677
  }
756
678
  static fromBuffer(buffer) {
@@ -758,38 +680,29 @@ class EMI {
758
680
  if (buffer.readUInt8(0) !== messageCode) {
759
681
  throw new Error(`Invalid message code for L_Poll_Data.con. Expected ${messageCode}, got ${buffer.readUInt8(0)}`);
760
682
  }
761
- const controlByte = buffer.readInt8(1);
683
+ const controlField = new ControlField_1.ControlField(buffer.readUInt8(1));
762
684
  const pollingGroup = buffer.readUInt16BE(4);
763
685
  const nrOfSlots = (buffer.readUInt8(6) & 0x0f);
764
- return new LPollDataCon({
765
- pollingGroup,
766
- nrOfSlots,
767
- control: {
768
- confirm: controlByte << 7 === 1 ? true : false,
769
- },
770
- });
686
+ return new LPollDataCon(pollingGroup, nrOfSlots, controlField.confirm);
771
687
  }
772
688
  },
773
689
  "L_SystemBroadcast.req": class LSystemBroadcastReq {
774
- constructor(value) {
775
- if (typeof value !== "object" || value === null) {
776
- throw new Error("L_Data.ind must be an object with specific properties.");
777
- }
690
+ constructor(priority, confirm, ackRequest, destinationAddress, addressType, npci, npdu) {
778
691
  this.controlField1 = new ControlField_1.ControlField(0b10000000);
779
- this.controlField1.priority = value.control.priority;
780
- this.controlField1.confirm = value.control.confirm;
781
- this.messageCode =
782
- MessageCodeField_1.MESSAGE_CODE_FIELD["L_SystemBroadcast.req"]["EMI2/IMI2"].value;
783
- if (KNXHelper_1.KNXHelper.isValidGroupAddress(value.destinationAddress) ||
784
- KNXHelper_1.KNXHelper.isValidIndividualAddress(value.destinationAddress)) {
785
- this.destinationAddress = value.destinationAddress;
692
+ this.controlField1.priority = priority;
693
+ this.controlField1.confirm = confirm;
694
+ this.controlField1.ackRequest = ackRequest;
695
+ this.messageCode = MessageCodeField_1.MESSAGE_CODE_FIELD["L_SystemBroadcast.req"]["EMI2/IMI2"].value;
696
+ if (KNXHelper_1.KNXHelper.isValidGroupAddress(destinationAddress) ||
697
+ KNXHelper_1.KNXHelper.isValidIndividualAddress(destinationAddress)) {
698
+ this.destinationAddress = destinationAddress;
786
699
  }
787
700
  else {
788
701
  throw new Error("The Destination Address is invalid Group Address or Individual Address");
789
702
  }
790
- this.addressType = value.addressType;
791
- this.NPCI = value.NPCI;
792
- this.npdu = value.NPDU;
703
+ this.addressType = addressType;
704
+ this.NPCI = npci;
705
+ this.npdu = npdu;
793
706
  }
794
707
  messageCode = MessageCodeField_1.MESSAGE_CODE_FIELD["L_SystemBroadcast.req"]["EMI2/IMI2"].value;
795
708
  controlField1; // Control field 1
@@ -803,11 +716,7 @@ class EMI {
803
716
  buffer.writeUInt8(this.messageCode, 0);
804
717
  this.controlField1.buffer.copy(buffer, 1); // Assuming controlField1 is a Buffer
805
718
  KNXHelper_1.KNXHelper.GetAddress_(this.destinationAddress).copy(buffer, 4);
806
- buffer[6] =
807
- 0x00 |
808
- ((this.addressType << 7) |
809
- (this.NPCI << 4) |
810
- (this.npdu.length & 0x0f));
719
+ buffer[6] = 0x00 | ((this.addressType << 7) | (this.NPCI << 4) | (this.npdu.length & 0x0f));
811
720
  this.npdu.copy(buffer, 7);
812
721
  return buffer;
813
722
  }
@@ -832,46 +741,31 @@ class EMI {
832
741
  const controlField1 = new ControlField_1.ControlField(controlFieldByte);
833
742
  const octet6 = buffer.readUInt8(6);
834
743
  const addressType = (octet6 >> 7) & 0x01;
835
- const NPCI = (octet6 >> 4) & 0x07;
744
+ const NPCI_val = (octet6 >> 4) & 0x07;
836
745
  const length = octet6 & 0x0f;
837
746
  const destinationAddressBuf = buffer.subarray(4, 6);
838
- //[cite_start]// Usually System Broadcast destination is 0/0/0 or specific [cite: 297]
839
747
  const destinationAddress = KNXHelper_1.KNXHelper.GetAddress(destinationAddressBuf, addressType === EnumControlFieldExtended_1.AddressType.GROUP ? "/" : ".");
840
748
  const npdu = buffer.subarray(7, 7 + length);
841
- return new LSystemBroadcastReq({
842
- control: {
843
- priority: controlField1.priority,
844
- confirm: controlField1.confirm,
845
- ackRequest: controlField1.ackRequest,
846
- },
847
- destinationAddress: destinationAddress,
848
- addressType: addressType,
849
- NPCI: NPCI,
850
- NPDU: npdu,
851
- });
749
+ return new LSystemBroadcastReq(controlField1.priority, controlField1.confirm, controlField1.ackRequest, destinationAddress, addressType, NPCI_val, npdu);
852
750
  }
853
751
  },
854
752
  "L_SystemBroadcast.con": class LSystemBroadcastCon {
855
- constructor(value) {
856
- if (typeof value !== "object" || value === null) {
857
- throw new Error("L_Data.ind must be an object with specific properties.");
858
- }
753
+ constructor(notRepeat, priority, confirm, destinationAddress, addressType, npci, npdu) {
859
754
  this.controlField1 = new ControlField_1.ControlField(0);
860
- this.controlField1.repeat = value.control.notRepeat;
861
- this.controlField1.priority = value.control.priority;
862
- this.controlField1.confirm = value.control.confirm;
863
- this.messageCode =
864
- MessageCodeField_1.MESSAGE_CODE_FIELD["L_SystemBroadcast.con"]["EMI2/IMI2"].value;
865
- if (KNXHelper_1.KNXHelper.isValidGroupAddress(value.destinationAddress) ||
866
- KNXHelper_1.KNXHelper.isValidIndividualAddress(value.destinationAddress)) {
867
- this.destinationAddress = value.destinationAddress;
755
+ this.controlField1.repeat = notRepeat;
756
+ this.controlField1.priority = priority;
757
+ this.controlField1.confirm = confirm;
758
+ this.messageCode = MessageCodeField_1.MESSAGE_CODE_FIELD["L_SystemBroadcast.con"]["EMI2/IMI2"].value;
759
+ if (KNXHelper_1.KNXHelper.isValidGroupAddress(destinationAddress) ||
760
+ KNXHelper_1.KNXHelper.isValidIndividualAddress(destinationAddress)) {
761
+ this.destinationAddress = destinationAddress;
868
762
  }
869
763
  else {
870
764
  throw new Error("The Destination Address is invalid Group Address or Individual Address");
871
765
  }
872
- this.addressType = value.addressType;
873
- this.NPCI = value.NPCI;
874
- this.npdu = value.NPDU;
766
+ this.addressType = addressType;
767
+ this.NPCI = npci;
768
+ this.npdu = npdu;
875
769
  }
876
770
  messageCode = MessageCodeField_1.MESSAGE_CODE_FIELD["L_SystemBroadcast.con"]["EMI2/IMI2"].value;
877
771
  controlField1; // Control field 1
@@ -885,11 +779,7 @@ class EMI {
885
779
  buffer.writeUInt8(this.messageCode, 0);
886
780
  this.controlField1.buffer.copy(buffer, 1); // Assuming controlField1 is a Buffer
887
781
  KNXHelper_1.KNXHelper.GetAddress_(this.destinationAddress).copy(buffer, 4);
888
- buffer[6] =
889
- 0x00 |
890
- ((this.addressType << 7) |
891
- (this.NPCI << 4) |
892
- (this.npdu.length & 0x0f));
782
+ buffer[6] = 0x00 | ((this.addressType << 7) | (this.NPCI << 4) | (this.npdu.length & 0x0f));
893
783
  this.npdu.copy(buffer, 7);
894
784
  return buffer;
895
785
  }
@@ -914,48 +804,36 @@ class EMI {
914
804
  const controlField1 = new ControlField_1.ControlField(controlFieldByte);
915
805
  const octet6 = buffer.readUInt8(6);
916
806
  const addressType = (octet6 >> 7) & 0x01;
917
- const NPCI = (octet6 >> 4) & 0x07;
807
+ const NPCI_val = (octet6 >> 4) & 0x07;
918
808
  const length = octet6 & 0x0f;
919
809
  const destinationAddressBuf = buffer.subarray(4, 6);
920
810
  const destinationAddress = KNXHelper_1.KNXHelper.GetAddress(destinationAddressBuf, addressType === EnumControlFieldExtended_1.AddressType.GROUP ? "/" : ".");
921
811
  const npdu = buffer.subarray(7, 7 + length);
922
- return new LSystemBroadcastCon({
923
- control: {
924
- priority: controlField1.priority,
925
- confirm: controlField1.confirm,
926
- notRepeat: controlField1.repeat,
927
- },
928
- destinationAddress: destinationAddress,
929
- addressType: addressType,
930
- NPCI: NPCI,
931
- NPDU: npdu,
932
- });
812
+ return new LSystemBroadcastCon(controlField1.repeat, controlField1.priority, controlField1.confirm, destinationAddress, addressType, NPCI_val, npdu);
933
813
  }
934
814
  },
935
815
  "L_SystemBroadcast.ind": class LSystemBroadcastInd {
936
- constructor(value) {
937
- if (typeof value !== "object" || value === null) {
938
- throw new Error("L_Data.ind must be an object with specific properties.");
939
- }
816
+ constructor(priority, confirm, notRepeat, sourceAddress, destinationAddress, addressType, npci, npdu) {
940
817
  this.controlField1 = new ControlField_1.ControlField(0);
941
- this.controlField1.priority = value.control.priority;
942
- if (KNXHelper_1.KNXHelper.isValidGroupAddress(value.destinationAddress) ||
943
- KNXHelper_1.KNXHelper.isValidIndividualAddress(value.destinationAddress)) {
944
- this.destinationAddress = value.destinationAddress;
818
+ this.controlField1.priority = priority;
819
+ this.controlField1.confirm = confirm;
820
+ this.controlField1.repeat = notRepeat;
821
+ if (KNXHelper_1.KNXHelper.isValidGroupAddress(destinationAddress) ||
822
+ KNXHelper_1.KNXHelper.isValidIndividualAddress(destinationAddress)) {
823
+ this.destinationAddress = destinationAddress;
945
824
  }
946
825
  else {
947
826
  throw new Error("The Destination Address is invalid Group Address or Individual Address");
948
827
  }
949
- if (KNXHelper_1.KNXHelper.isValidGroupAddress(value.sourceAddress) ||
950
- KNXHelper_1.KNXHelper.isValidIndividualAddress(value.sourceAddress)) {
951
- this.sourceAddress = value.sourceAddress;
828
+ if (KNXHelper_1.KNXHelper.isValidGroupAddress(sourceAddress) || KNXHelper_1.KNXHelper.isValidIndividualAddress(sourceAddress)) {
829
+ this.sourceAddress = sourceAddress;
952
830
  }
953
831
  else {
954
832
  throw new Error("The Source Address is invalid Group Address or Individual Address");
955
833
  }
956
- this.addressType = value.addressType;
957
- this.NPCI = value.NPCI;
958
- this.npdu = value.NPDU;
834
+ this.addressType = addressType;
835
+ this.NPCI = npci;
836
+ this.npdu = npdu;
959
837
  }
960
838
  messageCode = MessageCodeField_1.MESSAGE_CODE_FIELD["L_SystemBroadcast.ind"]["EMI2/IMI2"].value;
961
839
  controlField1; // Control field 1
@@ -988,12 +866,7 @@ class EMI {
988
866
  };
989
867
  }
990
868
  static fromBuffer(buffer) {
991
- //[cite_start]// Spec[cite: 147]: L_SystemBroadcast.ind -> 28h
992
- // Note: The class property 'messageCode' above references L_SystemBroadcast.CON (error in original class?),
993
- // I will try to match the code found in the buffer.
994
- // Strict check:
995
- if (buffer.readUInt8(0) !==
996
- MessageCodeField_1.MESSAGE_CODE_FIELD["L_SystemBroadcast.ind"]["EMI2/IMI2"].value) {
869
+ if (buffer.readUInt8(0) !== MessageCodeField_1.MESSAGE_CODE_FIELD["L_SystemBroadcast.ind"]["EMI2/IMI2"].value) {
997
870
  throw new Error("This messageCode is not L_SystemBroadcast.ind");
998
871
  }
999
872
  const controlFieldByte = buffer.readUInt8(1);
@@ -1001,29 +874,13 @@ class EMI {
1001
874
  const sourceAddressBuf = buffer.subarray(2, 4);
1002
875
  const sourceAddress = KNXHelper_1.KNXHelper.GetAddress(sourceAddressBuf, ".");
1003
876
  const octet6 = buffer.readUInt8(6);
1004
- //[cite_start]// Address type not strictly in bit 7 for SystemBroadcast Indication according to [cite: 312] diagram?
1005
- //[cite_start]// Diagram [cite: 313] shows Octet 6 (byte 7 in 1-based, so index 6) has NPCI and LG.
1006
- // Address Type is implicit in System Broadcast?
1007
- // But your constructor demands AddressType.
1008
- // Assuming standard L_Data frame layout for consistency with your class structure.
1009
- const addressType = (octet6 >> 7) & 0x01; // May be always 1 (Group)?
1010
- const NPCI = (octet6 >> 4) & 0x07;
877
+ const addressType = (octet6 >> 7) & 0x01;
878
+ const NPCI_val = (octet6 >> 4) & 0x07;
1011
879
  const length = octet6 & 0x0f;
1012
880
  const destinationAddressBuf = buffer.subarray(4, 6);
1013
881
  const destinationAddress = KNXHelper_1.KNXHelper.GetAddress(destinationAddressBuf, addressType === EnumControlFieldExtended_1.AddressType.GROUP ? "/" : ".");
1014
882
  const npdu = buffer.subarray(7, 7 + length);
1015
- return new LSystemBroadcastInd({
1016
- control: {
1017
- priority: controlField1.priority,
1018
- confirm: controlField1.confirm,
1019
- notRepeat: controlField1.repeat,
1020
- },
1021
- sourceAddress: sourceAddress,
1022
- destinationAddress: destinationAddress,
1023
- addressType: addressType,
1024
- NPCI: NPCI,
1025
- NPDU: npdu,
1026
- });
883
+ return new LSystemBroadcastInd(controlField1.priority, controlField1.confirm, controlField1.repeat, sourceAddress, destinationAddress, addressType, NPCI_val, npdu);
1027
884
  }
1028
885
  },
1029
886
  };
@@ -1039,22 +896,19 @@ class EMI {
1039
896
  controlField;
1040
897
  destinationAddress; // Individual address
1041
898
  TPDU; // Transport Layer Protocol Data Unit
1042
- constructor(value) {
1043
- if (typeof value !== "object" || value === null) {
1044
- throw new Error("N_Data_Individual.req must be an object with specific properties.");
1045
- }
899
+ constructor(frameType, repeat, systemBroadcast, priority, ackRequest, confirm, destinationAddress, tpdu) {
1046
900
  this.controlField = new ControlField_1.ControlField(0);
1047
- this.controlField.frameType = value.control.frameType;
1048
- this.controlField.repeat = value.control.repeat;
1049
- this.controlField.systemBroadcast = value.control.systemBroadcast;
1050
- this.controlField.priority = value.control.priority;
1051
- this.controlField.ackRequest = value.control.ackRequest;
1052
- this.controlField.confirm = value.control.confirm;
1053
- if (!KNXHelper_1.KNXHelper.isValidIndividualAddress(value.destinationAddress)) {
901
+ this.controlField.frameType = frameType;
902
+ this.controlField.repeat = repeat;
903
+ this.controlField.systemBroadcast = systemBroadcast;
904
+ this.controlField.priority = priority;
905
+ this.controlField.ackRequest = ackRequest;
906
+ this.controlField.confirm = confirm;
907
+ if (!KNXHelper_1.KNXHelper.isValidIndividualAddress(destinationAddress)) {
1054
908
  throw new Error("The Destination Address must be a valid Individual Address");
1055
909
  }
1056
- this.destinationAddress = value.destinationAddress;
1057
- this.TPDU = value.TPDU;
910
+ this.destinationAddress = destinationAddress;
911
+ this.TPDU = tpdu;
1058
912
  }
1059
913
  /**
1060
914
  * Converts the N_Data_Individual.req message to a Buffer.
@@ -1097,7 +951,6 @@ class EMI {
1097
951
  }
1098
952
  const controlFieldByte = buffer.readUInt8(1);
1099
953
  const controlField = new ControlField_1.ControlField(controlFieldByte);
1100
- // Octets 3-4 (index 2-3) son 0x0000 (unused) en la Request.
1101
954
  const destinationAddressBuf = buffer.subarray(4, 6);
1102
955
  const destinationAddress = KNXHelper_1.KNXHelper.GetAddress(destinationAddressBuf, ".");
1103
956
  const length = buffer.readUInt8(6) & 0x0f; // Octet 7: LG (lower 4 bits)
@@ -1105,18 +958,7 @@ class EMI {
1105
958
  throw new Error(`Buffer length mismatch. Expected at least ${7 + length} bytes, got ${buffer.length}`);
1106
959
  }
1107
960
  const TPDU = buffer.subarray(7, 7 + length);
1108
- return new NDataIndividualReq({
1109
- control: {
1110
- frameType: controlField.frameType,
1111
- repeat: controlField.repeat,
1112
- systemBroadcast: controlField.systemBroadcast,
1113
- priority: controlField.priority,
1114
- ackRequest: controlField.ackRequest,
1115
- confirm: controlField.confirm,
1116
- },
1117
- destinationAddress: destinationAddress,
1118
- TPDU: TPDU,
1119
- });
961
+ return new NDataIndividualReq(controlField.frameType, controlField.repeat, controlField.systemBroadcast, controlField.priority, controlField.ackRequest, controlField.confirm, destinationAddress, TPDU);
1120
962
  }
1121
963
  },
1122
964
  "N_Data_Individual.con": class NDataIndividualCon {
@@ -1124,19 +966,14 @@ class EMI {
1124
966
  controlField;
1125
967
  destinationAddress; // Destination address
1126
968
  TPDU;
1127
- constructor(value) {
1128
- if (typeof value !== "object" || value === null) {
1129
- throw new Error("N_Data_Individual.con must be an object with specific properties.");
1130
- }
969
+ constructor(confirm, destinationAddress, tpdu) {
1131
970
  this.controlField = new ControlField_1.ControlField(0);
1132
- this.controlField.confirm = value.control.confirm; // Set confirm bit
1133
- // The spec (3.3.5.3) for N_Data_Individual.con control field is "unused c".
1134
- // Therefore, priority should not be set here.
1135
- if (!KNXHelper_1.KNXHelper.isValidIndividualAddress(value.destinationAddress)) {
971
+ this.controlField.confirm = confirm; // Set confirm bit
972
+ if (!KNXHelper_1.KNXHelper.isValidIndividualAddress(destinationAddress)) {
1136
973
  throw new Error("The Destination Address must be a valid Individual Address");
1137
974
  }
1138
- this.destinationAddress = value.destinationAddress;
1139
- this.TPDU = value.TPDU;
975
+ this.destinationAddress = destinationAddress;
976
+ this.TPDU = tpdu;
1140
977
  }
1141
978
  /**
1142
979
  * Converts the N_Data_Individual.con message to a Buffer.
@@ -1179,7 +1016,6 @@ class EMI {
1179
1016
  }
1180
1017
  const controlFieldByte = buffer.readUInt8(1);
1181
1018
  const controlField = new ControlField_1.ControlField(controlFieldByte);
1182
- // Octets 3-4 (index 2-3) son 0x0000 (unused).
1183
1019
  const destinationAddressBuf = buffer.subarray(4, 6);
1184
1020
  const destinationAddress = KNXHelper_1.KNXHelper.GetAddress(destinationAddressBuf, ".");
1185
1021
  const length = buffer.readUInt8(6) & 0x0f; // Octet 7: LG (lower 4 bits)
@@ -1187,13 +1023,7 @@ class EMI {
1187
1023
  throw new Error(`Buffer length mismatch. Expected at least ${7 + length} bytes, got ${buffer.length}`);
1188
1024
  }
1189
1025
  const TPDU = buffer.subarray(7, 7 + length);
1190
- return new NDataIndividualCon({
1191
- control: {
1192
- confirm: controlField.confirm,
1193
- },
1194
- destinationAddress: destinationAddress,
1195
- TPDU: TPDU,
1196
- });
1026
+ return new NDataIndividualCon(controlField.confirm, destinationAddress, TPDU);
1197
1027
  }
1198
1028
  },
1199
1029
  "N_Data_Individual.ind": class NDataIndividualInd {
@@ -1203,22 +1033,19 @@ class EMI {
1203
1033
  destinationAddress; // Individual address
1204
1034
  hopCount; // 4 bits (formerly NPCI)
1205
1035
  TPDU;
1206
- constructor(value) {
1207
- if (typeof value !== "object" || value === null) {
1208
- throw new Error("N_Data_Individual.ind must be an object with specific properties.");
1209
- }
1036
+ constructor(priority, sourceAddress, destinationAddress, hopCount, tpdu) {
1210
1037
  this.controlField = new ControlField_1.ControlField(0);
1211
- this.controlField.priority = value.control.priority;
1212
- if (!KNXHelper_1.KNXHelper.isValidIndividualAddress(value.sourceAddress)) {
1038
+ this.controlField.priority = priority;
1039
+ if (!KNXHelper_1.KNXHelper.isValidIndividualAddress(sourceAddress)) {
1213
1040
  throw new Error("The Source Address must be a valid Individual Address");
1214
1041
  }
1215
- this.sourceAddress = value.sourceAddress;
1216
- if (!KNXHelper_1.KNXHelper.isValidIndividualAddress(value.destinationAddress)) {
1042
+ this.sourceAddress = sourceAddress;
1043
+ if (!KNXHelper_1.KNXHelper.isValidIndividualAddress(destinationAddress)) {
1217
1044
  throw new Error("The Destination Address must be a valid Individual Address");
1218
1045
  }
1219
- this.destinationAddress = value.destinationAddress;
1220
- this.hopCount = value.hopCount;
1221
- this.TPDU = value.TPDU;
1046
+ this.destinationAddress = destinationAddress;
1047
+ this.hopCount = hopCount;
1048
+ this.TPDU = tpdu;
1222
1049
  }
1223
1050
  /**
1224
1051
  * Converts the N_Data_Individual.ind message to a Buffer.
@@ -1235,7 +1062,6 @@ class EMI {
1235
1062
  // Octet 7: hop_count_type (bits 6-4) | octet count (LG) (bits 3-0)
1236
1063
  buffer.writeUInt8(((this.hopCount & 0x0f) << 4) | (this.TPDU.length & 0x0f), 6);
1237
1064
  this.TPDU.copy(buffer, 7); // Octet 8...n: TPDU
1238
- // buffer.writeUInt8(checksum(buffer.subarray(0, buffer.length - 1)), buffer.length - 1); // Calculate FCS
1239
1065
  return buffer;
1240
1066
  }
1241
1067
  /**
@@ -1275,15 +1101,7 @@ class EMI {
1275
1101
  throw new Error(`Buffer length mismatch. Expected at least ${7 + length} bytes, got ${buffer.length}`);
1276
1102
  }
1277
1103
  const TPDU = buffer.subarray(7, 7 + length);
1278
- return new NDataIndividualInd({
1279
- control: {
1280
- priority: controlField.priority,
1281
- },
1282
- sourceAddress: sourceAddress,
1283
- destinationAddress: destinationAddress,
1284
- hopCount: hopCount,
1285
- TPDU: TPDU,
1286
- });
1104
+ return new NDataIndividualInd(controlField.priority, sourceAddress, destinationAddress, hopCount, TPDU);
1287
1105
  }
1288
1106
  },
1289
1107
  "N_Data_Group.req": class NDataGroupReq {
@@ -1291,19 +1109,14 @@ class EMI {
1291
1109
  controlField;
1292
1110
  destinationAddress; // Group address
1293
1111
  APDU;
1294
- constructor(value) {
1295
- if (typeof value !== "object" || value === null) {
1296
- throw new Error("N_Data_Group.req must be an object with specific properties.");
1297
- }
1112
+ constructor(priority, destinationAddress, apdu) {
1298
1113
  this.controlField = new ControlField_1.ControlField(0);
1299
- this.controlField.priority = value.control.priority;
1300
- // The spec (3.3.5.5) for N_Data_Group.req control field is "unused priority unused".
1301
- // Therefore, ackRequest should not be set here.
1302
- if (!KNXHelper_1.KNXHelper.isValidGroupAddress(value.destinationAddress)) {
1114
+ this.controlField.priority = priority;
1115
+ if (!KNXHelper_1.KNXHelper.isValidGroupAddress(destinationAddress)) {
1303
1116
  throw new Error("The Destination Address must be a valid Group Address");
1304
1117
  }
1305
- this.destinationAddress = value.destinationAddress;
1306
- this.APDU = value.APDU;
1118
+ this.destinationAddress = destinationAddress;
1119
+ this.APDU = apdu;
1307
1120
  }
1308
1121
  /**
1309
1122
  * Converts the N_Data_Group.req message to a Buffer.
@@ -1320,7 +1133,6 @@ class EMI {
1320
1133
  // Octet 7: hop_count_type (bits 7-4, default 0) | octet count (LG) (bits 3-0)
1321
1134
  buffer.writeUInt8(this.APDU.length & 0x0f, 6); // Default hop_count_type is 0
1322
1135
  this.APDU.copy(buffer, 7); // Octet 8...n: TPDU
1323
- // buffer.writeUInt8(checksum(buffer.subarray(0, buffer.length - 1)), buffer.length - 1); // Calculate FCS
1324
1136
  return buffer;
1325
1137
  }
1326
1138
  /**
@@ -1347,7 +1159,6 @@ class EMI {
1347
1159
  }
1348
1160
  const controlFieldByte = buffer.readUInt8(1);
1349
1161
  const controlField = new ControlField_1.ControlField(controlFieldByte);
1350
- // Octets 3-4 (index 2-3) son 0x0000 (unused) en la Request.
1351
1162
  const destinationAddressBuf = buffer.subarray(4, 6);
1352
1163
  const destinationAddress = KNXHelper_1.KNXHelper.GetAddress(destinationAddressBuf, "/"); // Dirección de Grupo
1353
1164
  const length = buffer.readUInt8(6) & 0x0f; // Octet 7: LG (lower 4 bits), upper 4 bits unused (hop count = 0)
@@ -1355,13 +1166,7 @@ class EMI {
1355
1166
  throw new Error(`Buffer length mismatch. Expected at least ${7 + length} bytes, got ${buffer.length}`);
1356
1167
  }
1357
1168
  const APDU = buffer.subarray(7, 7 + length);
1358
- return new NDataGroupReq({
1359
- control: {
1360
- priority: controlField.priority,
1361
- },
1362
- destinationAddress: destinationAddress,
1363
- APDU: APDU,
1364
- });
1169
+ return new NDataGroupReq(controlField.priority, destinationAddress, APDU);
1365
1170
  }
1366
1171
  },
1367
1172
  "N_Data_Group.con": class NDataGroupCon {
@@ -1369,19 +1174,14 @@ class EMI {
1369
1174
  controlField;
1370
1175
  destinationAddress; // Group address
1371
1176
  APDU;
1372
- constructor(value) {
1373
- if (typeof value !== "object" || value === null) {
1374
- throw new Error("N_Data_Group.con must be an object with specific properties.");
1375
- }
1177
+ constructor(confirm, destinationAddress, apdu) {
1376
1178
  this.controlField = new ControlField_1.ControlField(0);
1377
- this.controlField.confirm = value.control.confirm;
1378
- // The spec (3.3.5.6) for N_Data_Group.con control field is "unused c".
1379
- // Therefore, priority should not be set here.
1380
- if (!KNXHelper_1.KNXHelper.isValidGroupAddress(value.destinationAddress)) {
1179
+ this.controlField.confirm = confirm;
1180
+ if (!KNXHelper_1.KNXHelper.isValidGroupAddress(destinationAddress)) {
1381
1181
  throw new Error("The Destination Address must be a valid Group Address");
1382
1182
  }
1383
- this.destinationAddress = value.destinationAddress;
1384
- this.APDU = value.APDU;
1183
+ this.destinationAddress = destinationAddress;
1184
+ this.APDU = apdu;
1385
1185
  }
1386
1186
  /**
1387
1187
  * Converts the N_Data_Group.con message to a Buffer.
@@ -1397,7 +1197,6 @@ class EMI {
1397
1197
  KNXHelper_1.KNXHelper.GetAddress_(this.destinationAddress).copy(buffer, 4); // Octets 5-6: Destination Address
1398
1198
  buffer.writeUInt8(this.APDU.length & 0x0f, 6); // Octet 7: LG (octet count), upper 4 bits unused
1399
1199
  this.APDU.copy(buffer, 7); // Octet 8...n: TPDU
1400
- // buffer.writeUInt8(checksum(buffer.subarray(0, buffer.length - 1)), buffer.length - 1); // Calculate FCS
1401
1200
  return buffer;
1402
1201
  }
1403
1202
  /**
@@ -1424,7 +1223,6 @@ class EMI {
1424
1223
  }
1425
1224
  const controlFieldByte = buffer.readUInt8(1);
1426
1225
  const controlField = new ControlField_1.ControlField(controlFieldByte);
1427
- // Octets 3-4 (index 2-3) son 0x0000 (unused) en la Confirmation.
1428
1226
  const destinationAddressBuf = buffer.subarray(4, 6);
1429
1227
  const destinationAddress = KNXHelper_1.KNXHelper.GetAddress(destinationAddressBuf, "/"); // Dirección de Grupo
1430
1228
  const length = buffer.readUInt8(6) & 0x0f; // Octet 7: LG (lower 4 bits), upper 4 bits unused
@@ -1432,13 +1230,7 @@ class EMI {
1432
1230
  throw new Error(`Buffer length mismatch. Expected at least ${7 + length} bytes, got ${buffer.length}`);
1433
1231
  }
1434
1232
  const APDU = buffer.subarray(7, 7 + length);
1435
- return new NDataGroupCon({
1436
- control: {
1437
- confirm: controlField.confirm,
1438
- },
1439
- destinationAddress: destinationAddress,
1440
- APDU: APDU,
1441
- });
1233
+ return new NDataGroupCon(controlField.confirm, destinationAddress, APDU);
1442
1234
  }
1443
1235
  },
1444
1236
  "N_Data_Group.ind": class NDataGroupInd {
@@ -1448,22 +1240,19 @@ class EMI {
1448
1240
  destinationAddress; // Group address
1449
1241
  hopCount; // 4 bits (formerly NPCI)
1450
1242
  APDU;
1451
- constructor(value) {
1452
- if (typeof value !== "object" || value === null) {
1453
- throw new Error("N_Data_Group.ind must be an object with specific properties.");
1454
- }
1243
+ constructor(priority, sourceAddress, destinationAddress, hopCount, apdu) {
1455
1244
  this.controlField = new ControlField_1.ControlField(0);
1456
- this.controlField.priority = value.control.priority;
1457
- if (!KNXHelper_1.KNXHelper.isValidIndividualAddress(value.sourceAddress)) {
1245
+ this.controlField.priority = priority;
1246
+ if (!KNXHelper_1.KNXHelper.isValidIndividualAddress(sourceAddress)) {
1458
1247
  throw new Error("The Source Address must be a valid Individual Address");
1459
1248
  }
1460
- this.sourceAddress = value.sourceAddress;
1461
- if (!KNXHelper_1.KNXHelper.isValidGroupAddress(value.destinationAddress)) {
1249
+ this.sourceAddress = sourceAddress;
1250
+ if (!KNXHelper_1.KNXHelper.isValidGroupAddress(destinationAddress)) {
1462
1251
  throw new Error("The Destination Address must be a valid Group Address");
1463
1252
  }
1464
- this.destinationAddress = value.destinationAddress;
1465
- this.hopCount = value.hopCount;
1466
- this.APDU = value.APDU;
1253
+ this.destinationAddress = destinationAddress;
1254
+ this.hopCount = hopCount;
1255
+ this.APDU = apdu;
1467
1256
  }
1468
1257
  /**
1469
1258
  * Converts the N_Data_Group.ind message to a Buffer.
@@ -1480,7 +1269,6 @@ class EMI {
1480
1269
  // Octet 7: hop_count_type (bits 7-4) | octet count (LG) (bits 3-0)
1481
1270
  buffer.writeUInt8(((this.hopCount & 0x0f) << 4) | (this.APDU.length & 0x0f), 6);
1482
1271
  this.APDU.copy(buffer, 7); // Octet 8...n: TPDU
1483
- // buffer.writeUInt8(checksum(buffer.subarray(0, buffer.length - 1)), buffer.length - 1); // Calculate FCS
1484
1272
  return buffer;
1485
1273
  }
1486
1274
  /**
@@ -1509,9 +1297,6 @@ class EMI {
1509
1297
  }
1510
1298
  const controlFieldByte = buffer.readUInt8(1);
1511
1299
  const controlField = new ControlField_1.ControlField(controlFieldByte);
1512
- // ATENCIÓN: Tu toBuffer para esta clase escribe 0x0000 en el Source Address (índice 2-3).
1513
- // Sin embargo, la especificación KNX (y tu constructor) requiere una Source Address (Individual).
1514
- // Asumiré la estructura CORRECTA del protocolo (Source Address en 2-3) para la lectura.
1515
1300
  const sourceAddressBuf = buffer.subarray(2, 4);
1516
1301
  const sourceAddress = KNXHelper_1.KNXHelper.GetAddress(sourceAddressBuf, "."); // Dirección Individual
1517
1302
  const destinationAddressBuf = buffer.subarray(4, 6);
@@ -1523,15 +1308,7 @@ class EMI {
1523
1308
  throw new Error(`Buffer length mismatch. Expected at least ${7 + length} bytes, got ${buffer.length}`);
1524
1309
  }
1525
1310
  const APDU = buffer.subarray(7, 7 + length);
1526
- return new NDataGroupInd({
1527
- control: {
1528
- priority: controlField.priority,
1529
- },
1530
- sourceAddress: sourceAddress,
1531
- destinationAddress: destinationAddress,
1532
- hopCount: hopCount,
1533
- APDU: APDU,
1534
- });
1311
+ return new NDataGroupInd(controlField.priority, sourceAddress, destinationAddress, hopCount, APDU);
1535
1312
  }
1536
1313
  },
1537
1314
  "N_Data_Broadcast.req": class NDataBroadcastReq {
@@ -1539,16 +1316,13 @@ class EMI {
1539
1316
  controlField;
1540
1317
  hopCount;
1541
1318
  TPDU;
1542
- constructor(value) {
1543
- if (typeof value !== "object" || value === null) {
1544
- throw new Error("N_Data_Broadcast.req must be an object with specific properties.");
1545
- }
1319
+ constructor(priority, hopCountType, tpdu) {
1546
1320
  this.controlField = new ControlField_1.ControlField(0);
1547
- this.controlField.priority = value.control.priority;
1321
+ this.controlField.priority = priority;
1548
1322
  // The spec (3.3.5.8) for N_Data_Broadcast.req control field is "unused priority unused".
1549
1323
  // Therefore, ackRequest should not be set here.
1550
- this.hopCount = value.hopCountType;
1551
- this.TPDU = value.TPDU;
1324
+ this.hopCount = hopCountType;
1325
+ this.TPDU = tpdu;
1552
1326
  }
1553
1327
  /**
1554
1328
  * Converts the N_Data_Broadcast.req message to a Buffer.
@@ -1589,31 +1363,22 @@ class EMI {
1589
1363
  // Broadcast suele asumir destino 0/0/0 implícito o explícito en bytes 4-5
1590
1364
  // const dest = KNXHelper.GetAddress(buffer.subarray(4, 6), "/");
1591
1365
  const octet6 = buffer.readUInt8(6);
1592
- const hopCount = octet6 & 0x70;
1366
+ const hopCount = (octet6 >> 4) & 0x07;
1593
1367
  const length = octet6 & 0x0f;
1594
1368
  const TPDU = buffer.subarray(7, 7 + length);
1595
- return new NDataBroadcastReq({
1596
- control: {
1597
- priority: controlField.priority,
1598
- },
1599
- hopCountType: hopCount,
1600
- TPDU: TPDU,
1601
- });
1369
+ return new NDataBroadcastReq(controlField.priority, hopCount, TPDU);
1602
1370
  }
1603
1371
  },
1604
1372
  "N_Data_Broadcast.con": class NDataBroadcastCon {
1605
1373
  messageCode = MessageCodeField_1.MESSAGE_CODE_FIELD["N_Data_Broadcast.con"]["EMI2/IMI2"].value;
1606
1374
  controlField;
1607
1375
  TPDU;
1608
- constructor(value) {
1609
- if (typeof value !== "object" || value === null) {
1610
- throw new Error("N_Data_Broadcast.con must be an object with specific properties.");
1611
- }
1376
+ constructor(confirm, tpdu) {
1612
1377
  this.controlField = new ControlField_1.ControlField(0);
1613
- this.controlField.confirm = value.control.confirm;
1378
+ this.controlField.confirm = confirm;
1614
1379
  // The spec (3.3.5.9) for N_Data_Broadcast.con control field is "unused unused unused c".
1615
1380
  // Therefore, priority should not be set here.
1616
- this.TPDU = value.TPDU;
1381
+ this.TPDU = tpdu;
1617
1382
  }
1618
1383
  /**
1619
1384
  * Converts the N_Data_Broadcast.con message to a Buffer.
@@ -1673,12 +1438,7 @@ class EMI {
1673
1438
  throw new Error(`Buffer mismatch: Expected ${length} bytes of TPDU, available ${buffer.length - 7}`);
1674
1439
  }
1675
1440
  const TPDU = buffer.subarray(7, 7 + length);
1676
- return new NDataBroadcastCon({
1677
- control: {
1678
- confirm: controlField.confirm,
1679
- },
1680
- TPDU: TPDU,
1681
- });
1441
+ return new NDataBroadcastCon(controlField.confirm, TPDU);
1682
1442
  }
1683
1443
  },
1684
1444
  "N_Data_Broadcast.ind": class NDataBroadcastInd {
@@ -1687,18 +1447,15 @@ class EMI {
1687
1447
  sourceAddress; // Individual address
1688
1448
  hopCount; // 4 bits (formerly NPCI)
1689
1449
  TPDU;
1690
- constructor(value) {
1691
- if (typeof value !== "object" || value === null) {
1692
- throw new Error("N_Data_Broadcast.ind must be an object with specific properties.");
1693
- }
1450
+ constructor(priority, sourceAddress, hopCount, tpdu) {
1694
1451
  this.controlField = new ControlField_1.ControlField(0);
1695
- this.controlField.priority = value.control.priority;
1696
- if (!KNXHelper_1.KNXHelper.isValidIndividualAddress(value.sourceAddress)) {
1452
+ this.controlField.priority = priority;
1453
+ if (!KNXHelper_1.KNXHelper.isValidIndividualAddress(sourceAddress)) {
1697
1454
  throw new Error("The Source Address must be a valid Individual Address");
1698
1455
  }
1699
- this.sourceAddress = value.sourceAddress;
1700
- this.hopCount = value.hopCount;
1701
- this.TPDU = value.TPDU;
1456
+ this.sourceAddress = sourceAddress;
1457
+ this.hopCount = hopCount;
1458
+ this.TPDU = tpdu;
1702
1459
  }
1703
1460
  /**
1704
1461
  * Converts the N_Data_Broadcast.ind message to a Buffer.
@@ -1744,43 +1501,35 @@ class EMI {
1744
1501
  if (typeof sourceAddress !== "string")
1745
1502
  throw new Error("The sourceAddress is not string, this fatal error is from GetAddress, dont be ignore it");
1746
1503
  const octet6 = buffer.readUInt8(6);
1747
- const hopCount = octet6 & 0x70;
1504
+ const hopCount = (octet6 >> 4) & 0x07;
1748
1505
  const length = octet6 & 0x0f;
1749
1506
  const TPDU = buffer.subarray(7, 7 + length);
1750
- return new NDataBroadcastInd({
1751
- control: { priority: controlField.priority },
1752
- sourceAddress: sourceAddress,
1753
- hopCount: hopCount,
1754
- TPDU: TPDU,
1755
- });
1507
+ return new NDataBroadcastInd(controlField.priority, sourceAddress, hopCount, TPDU);
1756
1508
  }
1757
1509
  },
1758
1510
  "N_Poll_Data.req": class NPollDataReq {
1759
1511
  messageCode = MessageCodeField_1.MESSAGE_CODE_FIELD["N_Poll_Data.req"]["EMI2/IMI2"].value;
1760
1512
  control = 0xf0; // Fixed control byte for N_Poll_Data.req (similar to L_Poll_Data)
1761
- #pollingGroup = Buffer.alloc(1, 0);
1762
- #nrOfSlots = 0;
1763
- constructor(value) {
1764
- if (typeof value !== "object" || value === null) {
1765
- throw new Error("N_Poll_Data.req must be an object with specific properties.");
1766
- }
1767
- this.nrOfSlots = value.nrOfSlots;
1768
- this.pollingGroup = value.pollingGroup;
1513
+ _pollingGroup = Buffer.alloc(1, 0);
1514
+ _nrOfSlots = 0;
1515
+ constructor(pollingGroup, nrOfSlots) {
1516
+ this.nrOfSlots = nrOfSlots;
1517
+ this.pollingGroup = pollingGroup;
1769
1518
  }
1770
1519
  set pollingGroup(value) {
1771
1520
  const convertToAddress = KNXHelper_1.KNXHelper.GetAddress_(value);
1772
- this.#pollingGroup = convertToAddress;
1521
+ this._pollingGroup = convertToAddress;
1773
1522
  }
1774
1523
  get pollingGroup() {
1775
- return KNXHelper_1.KNXHelper.GetAddress(this.#pollingGroup, "/", true); // Se supone que es un dirección de grupo;
1524
+ return KNXHelper_1.KNXHelper.GetAddress(this._pollingGroup, "/", true); // Se supone que es un dirección de grupo;
1776
1525
  }
1777
1526
  set nrOfSlots(value) {
1778
1527
  if (value < 0 || value > 7)
1779
1528
  throw new Error("The nrOfSlots value must be 4 bits (0-7)");
1780
- this.#nrOfSlots = value;
1529
+ this._nrOfSlots = value;
1781
1530
  }
1782
1531
  get nrOfSlots() {
1783
- return this.#nrOfSlots;
1532
+ return this._nrOfSlots;
1784
1533
  }
1785
1534
  /**
1786
1535
  * Converts the N_Poll_Data.req message to a Buffer.
@@ -1791,10 +1540,10 @@ class EMI {
1791
1540
  toBuffer() {
1792
1541
  const buffer = Buffer.alloc(7);
1793
1542
  let octet7 = 0;
1794
- octet7 = octet7 | (this.#nrOfSlots & 0x0f); // NrOfSlots in lower 4 bits
1543
+ octet7 = octet7 | (this._nrOfSlots & 0x0f); // NrOfSlots in lower 4 bits
1795
1544
  buffer.writeUInt8(this.messageCode, 0); // Octet 1: m_code
1796
1545
  buffer.writeUInt8(this.control, 1); // Octet 2: Control
1797
- this.#pollingGroup.copy(buffer, 0); // Octets 5-6: Polling Group
1546
+ this._pollingGroup.copy(buffer, 0); // Octets 5-6: Polling Group
1798
1547
  buffer.writeUInt8(octet7, 6); // Octet 7: NrOfSlots (bits 3-0)
1799
1548
  return buffer;
1800
1549
  }
@@ -1806,8 +1555,8 @@ class EMI {
1806
1555
  return {
1807
1556
  messageCode: `Codigo de mensaje: ${this.messageCode}`,
1808
1557
  control: `Control: ${this.control.toString(16).padStart(2, "0")}`,
1809
- pollingGroup: `Grupo de sondeo: ${this.#pollingGroup}`,
1810
- nrOfSlots: `Número de ranuras: ${this.#nrOfSlots}`,
1558
+ pollingGroup: `Grupo de sondeo: ${this._pollingGroup}`,
1559
+ nrOfSlots: `Número de ranuras: ${this._nrOfSlots}`,
1811
1560
  rawValue: `Valor numérico: ${this.toBuffer().toString("hex")}`,
1812
1561
  };
1813
1562
  }
@@ -1826,41 +1575,34 @@ class EMI {
1826
1575
  throw new Error("The pollingGroup is not string, this fatal error is from GetAddress, dont be ignore it");
1827
1576
  const octet6 = buffer.readUInt8(6);
1828
1577
  const nrOfSlots = octet6 & 0x0f; // Ejemplo, ver spec
1829
- return new NPollDataReq({
1830
- // Ajustar propiedades al constructor
1831
- pollingGroup: pollingGroup,
1832
- nrOfSlots: nrOfSlots,
1833
- });
1578
+ return new NPollDataReq(pollingGroup, nrOfSlots);
1834
1579
  }
1835
1580
  },
1836
1581
  "N_Poll_Data.con": class NPollDataCon {
1837
1582
  messageCode = MessageCodeField_1.MESSAGE_CODE_FIELD["N_Poll_Data.con"]["EMI2/IMI2"].value;
1838
1583
  control = 0xf0; // Fixed control byte for N_Poll_Data.con
1839
- #pollingGroup = Buffer.alloc(1, 0);
1840
- #nrOfSlots = 0;
1584
+ _pollingGroup = Buffer.alloc(1, 0);
1585
+ _nrOfSlots = 0;
1841
1586
  pollData; // Polled data
1842
- constructor(value) {
1843
- if (typeof value !== "object" || value === null) {
1844
- throw new Error("N_Poll_Data.con must be an object with specific properties.");
1845
- }
1846
- this.pollingGroup = value.pollingGroup;
1847
- this.nrOfSlots = value.nrOfSlots;
1848
- this.pollData = value.pollData;
1587
+ constructor(pollingGroup, nrOfSlots, pollData) {
1588
+ this.pollingGroup = pollingGroup;
1589
+ this.nrOfSlots = nrOfSlots;
1590
+ this.pollData = pollData;
1849
1591
  }
1850
1592
  set pollingGroup(value) {
1851
1593
  const convertToAddress = KNXHelper_1.KNXHelper.GetAddress_(value);
1852
- this.#pollingGroup = convertToAddress;
1594
+ this._pollingGroup = convertToAddress;
1853
1595
  }
1854
1596
  get pollingGroup() {
1855
- return KNXHelper_1.KNXHelper.GetAddress(this.#pollingGroup, "/", true); // Se supone que es un dirección de grupo;
1597
+ return KNXHelper_1.KNXHelper.GetAddress(this._pollingGroup, "/", true); // Se supone que es un dirección de grupo;
1856
1598
  }
1857
1599
  set nrOfSlots(value) {
1858
1600
  if (value < 0 || value > 7)
1859
1601
  throw new Error("The nrOfSlots value must be 4 bits (0-7)");
1860
- this.#nrOfSlots = value;
1602
+ this._nrOfSlots = value;
1861
1603
  }
1862
1604
  get nrOfSlots() {
1863
- return this.#nrOfSlots;
1605
+ return this._nrOfSlots;
1864
1606
  }
1865
1607
  /**
1866
1608
  * Converts the N_Poll_Data.con message to a Buffer.
@@ -1874,8 +1616,8 @@ class EMI {
1874
1616
  buffer.writeUInt8(this.control, 1); // Octet 2
1875
1617
  // Rellenar Octetos 3-4 (Source) con ceros explícitos si es necesario
1876
1618
  buffer.writeUInt16BE(0x0000, 2);
1877
- this.#pollingGroup.copy(buffer, 4); // Octets 5-6
1878
- const octet7 = this.#nrOfSlots & 0x0f;
1619
+ this._pollingGroup.copy(buffer, 4); // Octets 5-6
1620
+ const octet7 = this._nrOfSlots & 0x0f;
1879
1621
  buffer.writeUInt8(octet7, 6); // Octet 7
1880
1622
  this.pollData.copy(buffer, 7); // Octet 8...
1881
1623
  return buffer;
@@ -1888,8 +1630,8 @@ class EMI {
1888
1630
  return {
1889
1631
  messageCode: `Codigo de mensaje: ${this.messageCode}`,
1890
1632
  control: `Control: ${this.control.toString(16).padStart(2, "0")}`,
1891
- pollingGroup: `Grupo de sondeo: ${this.#pollingGroup}`,
1892
- nrOfSlots: `Número de ranuras: ${this.#nrOfSlots}`,
1633
+ pollingGroup: `Grupo de sondeo: ${this._pollingGroup}`,
1634
+ nrOfSlots: `Número de ranuras: ${this._nrOfSlots}`,
1893
1635
  pollData: `pollData: ${this.pollData.toString("hex")}`,
1894
1636
  pollData_Length: `${this.pollData.length} octets`,
1895
1637
  rawValue: `Valor numérico: ${this.toBuffer().toString("hex")}`,
@@ -1930,11 +1672,8 @@ class EMI {
1930
1672
  // Octet 7...: Poll Data
1931
1673
  // Todo lo que resta del buffer es data
1932
1674
  const pollData = buffer.subarray(7);
1933
- return new NPollDataCon({
1934
- pollingGroup: pollingGroupStr,
1935
- nrOfSlots: nrOfSlots, // Cast a 'bits4' o number según tu tipo
1936
- pollData: pollData,
1937
- });
1675
+ return new NPollDataCon(pollingGroupStr, nrOfSlots, // Cast a 'bits4' o number según tu tipo
1676
+ pollData);
1938
1677
  }
1939
1678
  },
1940
1679
  };
@@ -1943,11 +1682,8 @@ class EMI {
1943
1682
  messageCode = MessageCodeField_1.MESSAGE_CODE_FIELD["T_Connect.req"]["EMI2/IMI2"].value;
1944
1683
  control = 0x00;
1945
1684
  destinationAddress;
1946
- constructor(value) {
1947
- if (typeof value !== "object" || value === null) {
1948
- throw new InvalidInputObject(TConnectReq.name);
1949
- }
1950
- this.destinationAddress = value.destinationAddress;
1685
+ constructor(destinationAddress) {
1686
+ this.destinationAddress = destinationAddress;
1951
1687
  }
1952
1688
  toBuffer() {
1953
1689
  const buffer = Buffer.alloc(6);
@@ -1977,20 +1713,15 @@ class EMI {
1977
1713
  throw new Error("The destinationAddress is undefined or null, this fatal error is from GetAddress, dont be ignore it");
1978
1714
  if (typeof destinationAddress !== "string")
1979
1715
  throw new Error("The destinationAddress is not string, this fatal error is from GetAddress, dont be ignore it");
1980
- return new TConnectReq({
1981
- destinationAddress: destinationAddress,
1982
- });
1716
+ return new TConnectReq(destinationAddress);
1983
1717
  }
1984
1718
  },
1985
1719
  "T_Connect.con": class TConnectCon {
1986
1720
  messageCode = MessageCodeField_1.MESSAGE_CODE_FIELD["T_Connect.con"]["EMI2/IMI2"].value;
1987
1721
  control = 0x00;
1988
1722
  destinationAddress;
1989
- constructor(value) {
1990
- if (typeof value !== "object" || value === null) {
1991
- throw new InvalidInputObject(TConnectCon.name);
1992
- }
1993
- this.destinationAddress = value.destinationAddress;
1723
+ constructor(destinationAddress) {
1724
+ this.destinationAddress = destinationAddress;
1994
1725
  }
1995
1726
  toBuffer() {
1996
1727
  const buffer = Buffer.alloc(6);
@@ -2019,25 +1750,20 @@ class EMI {
2019
1750
  throw new Error("The destinationAddress is undefined or null, this fatal error is from GetAddress, dont be ignore it");
2020
1751
  if (typeof destinationAddress !== "string")
2021
1752
  throw new Error("The destinationAddress is not string, this fatal error is from GetAddress, dont be ignore it");
2022
- return new TConnectCon({
2023
- destinationAddress: destinationAddress,
2024
- });
1753
+ return new TConnectCon(destinationAddress);
2025
1754
  }
2026
1755
  },
2027
1756
  "T_Connect.ind": class TConnectInd {
2028
1757
  messageCode = MessageCodeField_1.MESSAGE_CODE_FIELD["T_Connect.ind"]["EMI2/IMI2"].value;
2029
1758
  control = new ControlField_1.ControlField();
2030
1759
  sourceAddress;
2031
- constructor(value) {
2032
- if (typeof value !== "object" || value === null) {
2033
- throw new InvalidInputObject(TConnectInd.name);
2034
- }
2035
- this.sourceAddress = value.sourceAddress;
2036
- this.control.ackRequest = value.control.ackRequest;
2037
- this.control.frameType = value.control.frameType;
2038
- this.control.repeat = value.control.repeat;
2039
- this.control.systemBroadcast = value.control.systemBroadcast;
2040
- this.control.priority = value.control.priority;
1760
+ constructor(sourceAddress, frameType, repeat, systemBroadcast, priority, ackRequest) {
1761
+ this.sourceAddress = sourceAddress;
1762
+ this.control.ackRequest = ackRequest;
1763
+ this.control.frameType = frameType;
1764
+ this.control.repeat = repeat;
1765
+ this.control.systemBroadcast = systemBroadcast;
1766
+ this.control.priority = priority;
2041
1767
  }
2042
1768
  toBuffer() {
2043
1769
  const buffer = Buffer.alloc(6);
@@ -2067,26 +1793,14 @@ class EMI {
2067
1793
  throw new Error("The sourceAddress is undefined or null, this fatal error is from GetAddress, dont be ignore it");
2068
1794
  if (typeof sourceAddress !== "string")
2069
1795
  throw new Error("The sourceAddress is not string, this fatal error is from GetAddress, dont be ignore it");
2070
- return new TConnectInd({
2071
- control: {
2072
- ackRequest: control.ackRequest,
2073
- frameType: control.frameType,
2074
- repeat: control.repeat,
2075
- systemBroadcast: control.systemBroadcast,
2076
- priority: control.priority,
2077
- confirm: control.confirm,
2078
- },
2079
- sourceAddress: sourceAddress,
2080
- });
1796
+ return new TConnectInd(sourceAddress, control.frameType, control.repeat, control.systemBroadcast, control.priority, control.ackRequest);
2081
1797
  }
2082
1798
  },
2083
1799
  "T_Disconnect.req": class TDisconnectReq {
2084
1800
  messageCode = MessageCodeField_1.MESSAGE_CODE_FIELD["T_Disconnect.req"]["EMI2/IMI2"].value;
2085
1801
  control = 0x00;
2086
- constructor(value) {
2087
- if (typeof value !== "object" || value === null) {
2088
- throw new InvalidInputObject(TDisconnectReq.name);
2089
- }
1802
+ constructor() {
1803
+ // No tiene parámetros
2090
1804
  }
2091
1805
  toBuffer() {
2092
1806
  const buffer = Buffer.alloc(6);
@@ -2096,7 +1810,7 @@ class EMI {
2096
1810
  }
2097
1811
  describe() {
2098
1812
  return {
2099
- messageCode: this.messageCode,
1813
+ messageCode: this.messageCode.toString(),
2100
1814
  };
2101
1815
  }
2102
1816
  static fromBuffer(buffer) {
@@ -2106,21 +1820,19 @@ class EMI {
2106
1820
  if (buffer.length < 6)
2107
1821
  throw new Error("Buffer too short");
2108
1822
  // No hay datos adicionales en req
2109
- return new TDisconnectReq({});
1823
+ return new TDisconnectReq();
2110
1824
  }
2111
1825
  },
2112
1826
  "T_Disconnect.con": class TDisconnectCon {
2113
1827
  messageCode = MessageCodeField_1.MESSAGE_CODE_FIELD["T_Disconnect.con"]["EMI2/IMI2"].value;
2114
1828
  control = new ControlField_1.ControlField();
2115
- constructor(value) {
2116
- if (typeof value !== "object" || value === null) {
2117
- throw new InvalidInputObject(TDisconnectCon.name);
2118
- }
2119
- this.control.ackRequest = value.control.ackRequest;
2120
- this.control.frameType = value.control.frameType;
2121
- this.control.repeat = value.control.repeat;
2122
- this.control.systemBroadcast = value.control.systemBroadcast;
2123
- this.control.priority = value.control.priority;
1829
+ constructor(frameType, repeat, systemBroadcast, priority, ackRequest, confirm) {
1830
+ this.control.ackRequest = ackRequest;
1831
+ this.control.frameType = frameType;
1832
+ this.control.repeat = repeat;
1833
+ this.control.systemBroadcast = systemBroadcast;
1834
+ this.control.priority = priority;
1835
+ this.control.confirm = confirm;
2124
1836
  }
2125
1837
  toBuffer() {
2126
1838
  const buffer = Buffer.alloc(6);
@@ -2131,8 +1843,8 @@ class EMI {
2131
1843
  }
2132
1844
  describe() {
2133
1845
  return {
2134
- messageCode: this.messageCode,
2135
- control: this.control,
1846
+ messageCode: this.messageCode.toString(),
1847
+ control: this.control.describe(),
2136
1848
  };
2137
1849
  }
2138
1850
  static fromBuffer(buffer) {
@@ -2142,30 +1854,19 @@ class EMI {
2142
1854
  if (buffer.length < 6)
2143
1855
  throw new Error("Buffer too short");
2144
1856
  const control = new ControlField_1.ControlField(buffer.readUInt8(1));
2145
- return new TDisconnectCon({
2146
- control: {
2147
- ackRequest: control.ackRequest,
2148
- frameType: control.frameType,
2149
- repeat: control.repeat,
2150
- systemBroadcast: control.systemBroadcast,
2151
- priority: control.priority,
2152
- confirm: control.confirm,
2153
- },
2154
- });
1857
+ return new TDisconnectCon(control.frameType, control.repeat, control.systemBroadcast, control.priority, control.ackRequest, control.confirm);
2155
1858
  }
2156
1859
  },
2157
1860
  "T_Disconnect.ind": class TDisconnectInd {
2158
1861
  messageCode = MessageCodeField_1.MESSAGE_CODE_FIELD["T_Disconnect.ind"]["EMI2/IMI2"].value;
2159
1862
  control = new ControlField_1.ControlField();
2160
- constructor(value) {
2161
- if (typeof value !== "object" || value === null) {
2162
- throw new InvalidInputObject(TDisconnectInd.name);
2163
- }
2164
- this.control.ackRequest = value.control.ackRequest;
2165
- this.control.frameType = value.control.frameType;
2166
- this.control.repeat = value.control.repeat;
2167
- this.control.systemBroadcast = value.control.systemBroadcast;
2168
- this.control.priority = value.control.priority;
1863
+ constructor(frameType, repeat, systemBroadcast, priority, ackRequest, confirm) {
1864
+ this.control.ackRequest = ackRequest;
1865
+ this.control.frameType = frameType;
1866
+ this.control.repeat = repeat;
1867
+ this.control.systemBroadcast = systemBroadcast;
1868
+ this.control.priority = priority;
1869
+ this.control.confirm = confirm;
2169
1870
  }
2170
1871
  toBuffer() {
2171
1872
  const buffer = Buffer.alloc(6);
@@ -2176,8 +1877,8 @@ class EMI {
2176
1877
  }
2177
1878
  describe() {
2178
1879
  return {
2179
- messageCode: this.messageCode,
2180
- control: this.control,
1880
+ messageCode: this.messageCode.toString(),
1881
+ control: this.control.describe(),
2181
1882
  };
2182
1883
  }
2183
1884
  static fromBuffer(buffer) {
@@ -2187,16 +1888,7 @@ class EMI {
2187
1888
  if (buffer.length < 6)
2188
1889
  throw new Error("Buffer too short");
2189
1890
  const control = new ControlField_1.ControlField(buffer.readUInt8(1));
2190
- return new TDisconnectInd({
2191
- control: {
2192
- ackRequest: control.ackRequest,
2193
- frameType: control.frameType,
2194
- repeat: control.repeat,
2195
- systemBroadcast: control.systemBroadcast,
2196
- priority: control.priority,
2197
- confirm: control.confirm,
2198
- },
2199
- });
1891
+ return new TDisconnectInd(control.frameType, control.repeat, control.systemBroadcast, control.priority, control.ackRequest, control.confirm);
2200
1892
  }
2201
1893
  },
2202
1894
  "T_Data_Connected.req": class TDataConnectedReq {
@@ -2204,13 +1896,10 @@ class EMI {
2204
1896
  control = new ControlField_1.ControlField();
2205
1897
  APDU;
2206
1898
  hopCount;
2207
- constructor(value) {
2208
- if (typeof value !== "object" || value === null) {
2209
- throw new InvalidInputObject(TDataConnectedReq.name);
2210
- }
2211
- this.control.priority = value.control.priority;
2212
- this.APDU = value.APDU;
2213
- this.hopCount = value.hopCount;
1899
+ constructor(priority, hopCount, apdu) {
1900
+ this.control.priority = priority;
1901
+ this.APDU = apdu;
1902
+ this.hopCount = hopCount;
2214
1903
  }
2215
1904
  toBuffer() {
2216
1905
  const buffer = Buffer.alloc(8 + this.APDU.length);
@@ -2223,9 +1912,9 @@ class EMI {
2223
1912
  }
2224
1913
  describe() {
2225
1914
  return {
2226
- messageCode: this.messageCode,
2227
- control: this.control,
2228
- hopCount: this.hopCount,
1915
+ messageCode: this.messageCode.toString(),
1916
+ control: this.control.describe(),
1917
+ hopCount: this.hopCount.toString(),
2229
1918
  };
2230
1919
  }
2231
1920
  static fromBuffer(buffer) {
@@ -2243,23 +1932,16 @@ class EMI {
2243
1932
  if (buffer.length < 7 + length)
2244
1933
  throw new Error("Buffer data incomplete");
2245
1934
  const apdu = buffer.subarray(7, 7 + length);
2246
- return new TDataConnectedReq({
2247
- control: { priority: control.priority },
2248
- hopCount: hopCount,
2249
- APDU: apdu,
2250
- });
1935
+ return new TDataConnectedReq(control.priority, hopCount, apdu);
2251
1936
  }
2252
1937
  },
2253
1938
  "T_Data_Connected.con": class TDataConnectedCon {
2254
1939
  messageCode = MessageCodeField_1.MESSAGE_CODE_FIELD["T_Data_Connected.con"]["EMI2/IMI2"].value;
2255
1940
  control = new ControlField_1.ControlField();
2256
1941
  APDU;
2257
- constructor(value) {
2258
- if (typeof value !== "object" || value === null) {
2259
- throw new InvalidInputObject(TDataConnectedCon.name);
2260
- }
2261
- this.control.confirm = value.control.confirm;
2262
- this.APDU = value.APDU;
1942
+ constructor(confirm, apdu) {
1943
+ this.control.confirm = confirm;
1944
+ this.APDU = apdu;
2263
1945
  }
2264
1946
  toBuffer() {
2265
1947
  const buffer = Buffer.alloc(8 + this.APDU.length);
@@ -2273,7 +1955,7 @@ class EMI {
2273
1955
  }
2274
1956
  describe() {
2275
1957
  return {
2276
- messageCode: this.messageCode,
1958
+ messageCode: this.messageCode.toString(),
2277
1959
  control: this.control.describe(),
2278
1960
  APDU: this.APDU.toString("hex"),
2279
1961
  };
@@ -2287,10 +1969,7 @@ class EMI {
2287
1969
  const control = new ControlField_1.ControlField(buffer.readUInt8(1));
2288
1970
  const length = buffer.readUInt8(6) & 0x0f;
2289
1971
  const apdu = buffer.subarray(7, 7 + length);
2290
- return new TDataConnectedCon({
2291
- control: { confirm: control.confirm },
2292
- APDU: apdu,
2293
- });
1972
+ return new TDataConnectedCon(control.confirm, apdu);
2294
1973
  }
2295
1974
  },
2296
1975
  "T_Data_Connected.ind": class TDataConnectedInd {
@@ -2299,14 +1978,11 @@ class EMI {
2299
1978
  sourceAddress;
2300
1979
  APDU;
2301
1980
  hopCount;
2302
- constructor(value) {
2303
- if (typeof value !== "object" || value === null) {
2304
- throw new InvalidInputObject(TDataConnectedInd.name);
2305
- }
2306
- this.control.priority = value.control.priority;
2307
- this.sourceAddress = value.sourceAddress;
2308
- this.APDU = value.APDU;
2309
- this.hopCount = value.hopCount;
1981
+ constructor(priority, sourceAddress, apdu, hopCount) {
1982
+ this.control.priority = priority;
1983
+ this.sourceAddress = sourceAddress;
1984
+ this.APDU = apdu;
1985
+ this.hopCount = hopCount;
2310
1986
  }
2311
1987
  toBuffer() {
2312
1988
  const buffer = Buffer.alloc(8 + this.APDU.length);
@@ -2321,7 +1997,7 @@ class EMI {
2321
1997
  }
2322
1998
  describe() {
2323
1999
  return {
2324
- messageCode: this.messageCode,
2000
+ messageCode: this.messageCode.toString(),
2325
2001
  control: this.control.describe(),
2326
2002
  sourceAddress: this.sourceAddress,
2327
2003
  APDU: this.APDU.toString("hex"),
@@ -2344,12 +2020,7 @@ class EMI {
2344
2020
  const hopCount = (octet6 >> 4) & 0x07;
2345
2021
  const length = octet6 & 0x0f;
2346
2022
  const apdu = buffer.subarray(7, 7 + length);
2347
- return new TDataConnectedInd({
2348
- control: { priority: control.priority },
2349
- sourceAddress: sourceAddress,
2350
- hopCount: hopCount,
2351
- APDU: apdu,
2352
- });
2023
+ return new TDataConnectedInd(control.priority, sourceAddress, apdu, hopCount);
2353
2024
  }
2354
2025
  },
2355
2026
  "T_Data_Group.req": class TDataGroupReq {
@@ -2357,13 +2028,10 @@ class EMI {
2357
2028
  control = new ControlField_1.ControlField();
2358
2029
  APDU;
2359
2030
  hopCount;
2360
- constructor(value) {
2361
- if (typeof value !== "object" || value === null) {
2362
- throw new InvalidInputObject(TDataGroupReq.name);
2363
- }
2364
- this.control.priority = value.control.priority;
2365
- this.APDU = value.APDU;
2366
- this.hopCount = value.hopCount;
2031
+ constructor(priority, hopCount, apdu) {
2032
+ this.control.priority = priority;
2033
+ this.APDU = apdu;
2034
+ this.hopCount = hopCount;
2367
2035
  }
2368
2036
  toBuffer() {
2369
2037
  const buffer = Buffer.alloc(8 + this.APDU.length);
@@ -2377,9 +2045,9 @@ class EMI {
2377
2045
  }
2378
2046
  describe() {
2379
2047
  return {
2380
- messageCode: this.messageCode,
2048
+ messageCode: this.messageCode.toString(),
2381
2049
  control: this.control.describe(),
2382
- hopCount: this.hopCount,
2050
+ hopCount: this.hopCount.toString(),
2383
2051
  APDU: this.APDU.toString("hex"),
2384
2052
  };
2385
2053
  }
@@ -2394,23 +2062,16 @@ class EMI {
2394
2062
  const hopCount = (octet6 >> 4) & 0x07;
2395
2063
  const length = octet6 & 0x0f;
2396
2064
  const apdu = buffer.subarray(7, 7 + length);
2397
- return new TDataGroupReq({
2398
- control: { priority: control.priority },
2399
- hopCount: hopCount,
2400
- APDU: apdu,
2401
- });
2065
+ return new TDataGroupReq(control.priority, hopCount, apdu);
2402
2066
  }
2403
2067
  },
2404
2068
  "T_Data_Group.con": class TDataGroupCon {
2405
2069
  messageCode = MessageCodeField_1.MESSAGE_CODE_FIELD["T_Data_Group.con"]["EMI2/IMI2"].value;
2406
2070
  control = new ControlField_1.ControlField();
2407
2071
  data;
2408
- constructor(value) {
2409
- if (typeof value !== "object" || value === null) {
2410
- throw new InvalidInputObject(TDataGroupCon.name);
2411
- }
2412
- this.control.confirm = value.control.confirm;
2413
- this.data = value.data;
2072
+ constructor(confirm, data) {
2073
+ this.control.confirm = confirm;
2074
+ this.data = data;
2414
2075
  }
2415
2076
  toBuffer() {
2416
2077
  const buffer = Buffer.alloc(8 + this.data.length); // Tamaño mínimo según documento
@@ -2424,7 +2085,7 @@ class EMI {
2424
2085
  }
2425
2086
  describe() {
2426
2087
  return {
2427
- messageCode: this.messageCode,
2088
+ messageCode: this.messageCode.toString(),
2428
2089
  control: this.control.describe(),
2429
2090
  };
2430
2091
  }
@@ -2437,22 +2098,16 @@ class EMI {
2437
2098
  const control = new ControlField_1.ControlField(buffer.readUInt8(1));
2438
2099
  const length = buffer.readUInt8(6) & 0x0f;
2439
2100
  const data = buffer.subarray(7, 7 + length);
2440
- return new TDataGroupCon({
2441
- control: { confirm: control.confirm },
2442
- data: data,
2443
- });
2101
+ return new TDataGroupCon(control.confirm, data);
2444
2102
  }
2445
2103
  },
2446
2104
  "T_Data_Group.ind": class TDataGroupInd {
2447
2105
  messageCode = MessageCodeField_1.MESSAGE_CODE_FIELD["T_Data_Group.ind"]["EMI2/IMI2"].value;
2448
2106
  control = new ControlField_1.ControlField();
2449
2107
  APDU;
2450
- constructor(value) {
2451
- if (typeof value !== "object" || value === null) {
2452
- throw new InvalidInputObject(TDataGroupInd.name);
2453
- }
2454
- this.control.priority = value.control.priority;
2455
- this.APDU = value.APDU;
2108
+ constructor(priority, apdu) {
2109
+ this.control.priority = priority;
2110
+ this.APDU = apdu;
2456
2111
  }
2457
2112
  toBuffer() {
2458
2113
  const buffer = Buffer.alloc(8 + this.APDU.length);
@@ -2466,7 +2121,7 @@ class EMI {
2466
2121
  }
2467
2122
  describe() {
2468
2123
  return {
2469
- messageCode: this.messageCode,
2124
+ messageCode: this.messageCode.toString(),
2470
2125
  control: this.control.describe(),
2471
2126
  APDU: this.APDU.toString("hex"),
2472
2127
  };
@@ -2481,10 +2136,7 @@ class EMI {
2481
2136
  const octet6 = buffer.readUInt8(6);
2482
2137
  const length = octet6 & 0x0f;
2483
2138
  const apdu = buffer.subarray(7, 7 + length);
2484
- return new TDataGroupInd({
2485
- control: { priority: control.priority },
2486
- APDU: apdu,
2487
- });
2139
+ return new TDataGroupInd(control.priority, apdu);
2488
2140
  }
2489
2141
  },
2490
2142
  "T_Data_Individual.req": class TDataIndividualReq {
@@ -2493,14 +2145,11 @@ class EMI {
2493
2145
  destinationAddress;
2494
2146
  APDU;
2495
2147
  hopCount;
2496
- constructor(value) {
2497
- if (typeof value !== "object" || value === null) {
2498
- throw new InvalidInputObject(TDataIndividualReq.name);
2499
- }
2500
- this.control.priority = value.control.priority;
2501
- this.destinationAddress = value.destinationAddress;
2502
- this.APDU = value.APDU;
2503
- this.hopCount = value.hopCount;
2148
+ constructor(priority, destinationAddress, hopCount, apdu) {
2149
+ this.control.priority = priority;
2150
+ this.destinationAddress = destinationAddress;
2151
+ this.APDU = apdu;
2152
+ this.hopCount = hopCount;
2504
2153
  }
2505
2154
  toBuffer() {
2506
2155
  const buffer = Buffer.alloc(8 + this.APDU.length);
@@ -2514,10 +2163,10 @@ class EMI {
2514
2163
  }
2515
2164
  describe() {
2516
2165
  return {
2517
- messageCode: this.messageCode,
2166
+ messageCode: this.messageCode.toString(),
2518
2167
  control: this.control.describe(),
2519
2168
  destinationAddress: this.destinationAddress,
2520
- hopCount: this.hopCount,
2169
+ hopCount: this.hopCount.toString(),
2521
2170
  APDU: this.APDU.toString("hex"),
2522
2171
  };
2523
2172
  }
@@ -2538,12 +2187,7 @@ class EMI {
2538
2187
  const hopCount = (octet6 >> 4) & 0x07;
2539
2188
  const length = octet6 & 0x0f;
2540
2189
  const apdu = buffer.subarray(7, 7 + length);
2541
- return new TDataIndividualReq({
2542
- control: { priority: control.priority },
2543
- destinationAddress: destinationAddress,
2544
- hopCount: hopCount,
2545
- APDU: apdu,
2546
- });
2190
+ return new TDataIndividualReq(control.priority, destinationAddress, hopCount, apdu);
2547
2191
  }
2548
2192
  },
2549
2193
  "T_Data_Individual.con": class TDataIndividualCon {
@@ -2551,13 +2195,10 @@ class EMI {
2551
2195
  control = new ControlField_1.ControlField();
2552
2196
  destinationAddress;
2553
2197
  APDU;
2554
- constructor(value) {
2555
- if (typeof value !== "object" || value === null) {
2556
- throw new InvalidInputObject(TDataIndividualCon.name);
2557
- }
2558
- this.control.confirm = value.control.confirm;
2559
- this.destinationAddress = value.destinationAddress;
2560
- this.APDU = value.APDU;
2198
+ constructor(confirm, destinationAddress, apdu) {
2199
+ this.control.confirm = confirm;
2200
+ this.destinationAddress = destinationAddress;
2201
+ this.APDU = apdu;
2561
2202
  }
2562
2203
  toBuffer() {
2563
2204
  const buffer = Buffer.alloc(8 + this.APDU.length);
@@ -2571,7 +2212,7 @@ class EMI {
2571
2212
  }
2572
2213
  describe() {
2573
2214
  return {
2574
- messageCode: this.messageCode,
2215
+ messageCode: this.messageCode.toString(),
2575
2216
  control: this.control.describe(),
2576
2217
  destinationAddress: this.destinationAddress,
2577
2218
  };
@@ -2591,11 +2232,7 @@ class EMI {
2591
2232
  throw new Error("The destinationAddress is not string, this fatal error is from GetAddress, dont be ignore it");
2592
2233
  const length = buffer.readUInt8(6) & 0x0f;
2593
2234
  const apdu = buffer.subarray(7, 7 + length);
2594
- return new TDataIndividualCon({
2595
- control: { confirm: control.confirm },
2596
- destinationAddress: destinationAddress,
2597
- APDU: apdu,
2598
- });
2235
+ return new TDataIndividualCon(control.confirm, destinationAddress, apdu);
2599
2236
  }
2600
2237
  },
2601
2238
  "T_Data_Individual.ind": class TDataIndividualInd {
@@ -2605,15 +2242,12 @@ class EMI {
2605
2242
  destinationAddress;
2606
2243
  APDU;
2607
2244
  hopCount;
2608
- constructor(value) {
2609
- if (typeof value !== "object" || value === null) {
2610
- throw new InvalidInputObject(TDataIndividualInd.name);
2611
- }
2612
- this.control.priority = value.control.priority;
2613
- this.sourceAddress = value.sourceAddress;
2614
- this.destinationAddress = value.destinationAddress;
2615
- this.APDU = value.APDU;
2616
- this.hopCount = value.hopCount;
2245
+ constructor(priority, sourceAddress, destinationAddress, hopCount, apdu) {
2246
+ this.control.priority = priority;
2247
+ this.sourceAddress = sourceAddress;
2248
+ this.destinationAddress = destinationAddress;
2249
+ this.APDU = apdu;
2250
+ this.hopCount = hopCount;
2617
2251
  }
2618
2252
  toBuffer() {
2619
2253
  const buffer = Buffer.alloc(8 + this.APDU.length);
@@ -2628,7 +2262,7 @@ class EMI {
2628
2262
  }
2629
2263
  describe() {
2630
2264
  return {
2631
- messageCode: this.messageCode,
2265
+ messageCode: this.messageCode.toString(),
2632
2266
  control: this.control.describe(),
2633
2267
  sourceAddress: this.sourceAddress,
2634
2268
  destinationAddress: this.destinationAddress,
@@ -2657,13 +2291,7 @@ class EMI {
2657
2291
  const hopCount = (octet6 >> 4) & 0x07;
2658
2292
  const length = octet6 & 0x0f;
2659
2293
  const apdu = buffer.subarray(7, 7 + length);
2660
- return new TDataIndividualInd({
2661
- control: { priority: control.priority },
2662
- sourceAddress: sourceAddress,
2663
- destinationAddress: destinationAddress,
2664
- hopCount: hopCount,
2665
- APDU: apdu,
2666
- });
2294
+ return new TDataIndividualInd(control.priority, sourceAddress, destinationAddress, hopCount, apdu);
2667
2295
  }
2668
2296
  },
2669
2297
  "T_Data_Broadcast.req": class TDataBroadcastReq {
@@ -2671,13 +2299,10 @@ class EMI {
2671
2299
  control = new ControlField_1.ControlField();
2672
2300
  APDU;
2673
2301
  hopCount;
2674
- constructor(value) {
2675
- if (typeof value !== "object" || value === null) {
2676
- throw new InvalidInputObject(TDataBroadcastReq.name);
2677
- }
2678
- this.control.priority = value.control.priority;
2679
- this.APDU = value.APDU;
2680
- this.hopCount = value.hopCount;
2302
+ constructor(priority, hopCount, apdu) {
2303
+ this.control.priority = priority;
2304
+ this.APDU = apdu;
2305
+ this.hopCount = hopCount;
2681
2306
  }
2682
2307
  toBuffer() {
2683
2308
  const buffer = Buffer.alloc(8 + this.APDU.length);
@@ -2690,9 +2315,9 @@ class EMI {
2690
2315
  }
2691
2316
  describe() {
2692
2317
  return {
2693
- messageCode: this.messageCode,
2318
+ messageCode: this.messageCode.toString(),
2694
2319
  control: this.control.describe(),
2695
- hopCount: this.hopCount,
2320
+ hopCount: this.hopCount.toString(),
2696
2321
  APDU: this.APDU.toString("hex"),
2697
2322
  };
2698
2323
  }
@@ -2707,23 +2332,16 @@ class EMI {
2707
2332
  const hopCount = (octet6 >> 4) & 0x07;
2708
2333
  const length = octet6 & 0x0f;
2709
2334
  const apdu = buffer.subarray(7, 7 + length);
2710
- return new TDataBroadcastReq({
2711
- control: { priority: control.priority },
2712
- hopCount: hopCount,
2713
- APDU: apdu,
2714
- });
2335
+ return new TDataBroadcastReq(control.priority, hopCount, apdu);
2715
2336
  }
2716
2337
  },
2717
2338
  "T_Data_Broadcast.con": class TDataBroadcastCon {
2718
2339
  messageCode = MessageCodeField_1.MESSAGE_CODE_FIELD["T_Data_Broadcast.con"]["EMI2/IMI2"].value;
2719
2340
  control = new ControlField_1.ControlField();
2720
2341
  APDU;
2721
- constructor(value) {
2722
- if (typeof value !== "object" || value === null) {
2723
- throw new InvalidInputObject(TDataBroadcastCon.name);
2724
- }
2725
- this.control.confirm = value.control.confirm;
2726
- this.APDU = value.APDU;
2342
+ constructor(confirm, apdu) {
2343
+ this.control.confirm = confirm;
2344
+ this.APDU = apdu;
2727
2345
  }
2728
2346
  toBuffer() {
2729
2347
  const buffer = Buffer.alloc(8 + this.APDU.length);
@@ -2735,7 +2353,7 @@ class EMI {
2735
2353
  }
2736
2354
  describe() {
2737
2355
  return {
2738
- messageCode: this.messageCode,
2356
+ messageCode: this.messageCode.toString(),
2739
2357
  control: this.control.describe(),
2740
2358
  };
2741
2359
  }
@@ -2748,10 +2366,7 @@ class EMI {
2748
2366
  const control = new ControlField_1.ControlField(buffer.readUInt8(1));
2749
2367
  const length = buffer.readUInt8(6) & 0x0f;
2750
2368
  const apdu = buffer.subarray(7, 7 + length);
2751
- return new TDataBroadcastCon({
2752
- control: { confirm: control.confirm },
2753
- APDU: apdu,
2754
- });
2369
+ return new TDataBroadcastCon(control.confirm, apdu);
2755
2370
  }
2756
2371
  },
2757
2372
  "T_Data_Broadcast.ind": class TDataBroadcastInd {
@@ -2760,14 +2375,11 @@ class EMI {
2760
2375
  sourceAddress;
2761
2376
  APDU;
2762
2377
  hopCount;
2763
- constructor(value) {
2764
- if (typeof value !== "object" || value === null) {
2765
- throw new InvalidInputObject(TDataBroadcastInd.name);
2766
- }
2767
- this.control.priority = value.control.priority;
2768
- this.sourceAddress = value.sourceAddress;
2769
- this.APDU = value.APDU;
2770
- this.hopCount = value.hopCount;
2378
+ constructor(priority, sourceAddress, hopCount, apdu) {
2379
+ this.control.priority = priority;
2380
+ this.sourceAddress = sourceAddress;
2381
+ this.APDU = apdu;
2382
+ this.hopCount = hopCount;
2771
2383
  }
2772
2384
  toBuffer() {
2773
2385
  const buffer = Buffer.alloc(8 + this.APDU.length);
@@ -2781,7 +2393,7 @@ class EMI {
2781
2393
  }
2782
2394
  describe() {
2783
2395
  return {
2784
- messageCode: this.messageCode,
2396
+ messageCode: this.messageCode.toString(),
2785
2397
  control: this.control.describe(),
2786
2398
  sourceAddress: this.sourceAddress,
2787
2399
  APDU: this.APDU.toString("hex"),
@@ -2803,12 +2415,7 @@ class EMI {
2803
2415
  const hopCount = (octet6 >> 4) & 0x07;
2804
2416
  const length = octet6 & 0x0f;
2805
2417
  const apdu = buffer.subarray(7, 7 + length);
2806
- return new TDataBroadcastInd({
2807
- control: { priority: control.priority },
2808
- sourceAddress: sourceAddress,
2809
- hopCount: hopCount,
2810
- APDU: apdu,
2811
- });
2418
+ return new TDataBroadcastInd(control.priority, sourceAddress, hopCount, apdu);
2812
2419
  }
2813
2420
  },
2814
2421
  "T_Poll_Data.req": class TPollDataReq {
@@ -2816,12 +2423,9 @@ class EMI {
2816
2423
  control = new ControlField_1.ControlField(0xf0);
2817
2424
  pollingGroup;
2818
2425
  numberOfSlots;
2819
- constructor(value) {
2820
- if (typeof value !== "object" || value === null) {
2821
- throw new InvalidInputObject(TPollDataReq.name);
2822
- }
2823
- this.pollingGroup = value.pollingGroup;
2824
- this.numberOfSlots = value.numberOfSlots;
2426
+ constructor(pollingGroup, numberOfSlots) {
2427
+ this.pollingGroup = pollingGroup;
2428
+ this.numberOfSlots = numberOfSlots;
2825
2429
  }
2826
2430
  toBuffer() {
2827
2431
  const buffer = Buffer.alloc(7);
@@ -2835,10 +2439,10 @@ class EMI {
2835
2439
  }
2836
2440
  describe() {
2837
2441
  return {
2838
- messageCode: this.messageCode,
2442
+ messageCode: this.messageCode.toString(),
2839
2443
  control: this.control.describe(),
2840
2444
  pollingGroup: this.pollingGroup,
2841
- numberOfSlots: this.numberOfSlots,
2445
+ numberOfSlots: this.numberOfSlots.toString(),
2842
2446
  };
2843
2447
  }
2844
2448
  static fromBuffer(buffer) {
@@ -2849,18 +2453,14 @@ class EMI {
2849
2453
  throw new Error("Buffer too short");
2850
2454
  // Estructura: MC(0) | Ctrl(1) | Unused(2-3) | PollGroup(4-5) | Slots(6)
2851
2455
  // Usamos separador "/" para grupos
2852
- const control = new ControlField_1.ControlField(buffer.readUInt8(1));
2456
+ // const control = new ControlField(buffer.readUInt8(1));
2853
2457
  const pollingGroup = KNXHelper_1.KNXHelper.GetAddress(buffer.subarray(4, 6), "/");
2854
2458
  if (!pollingGroup)
2855
2459
  throw new Error("The pollingGroup is undefined or null, this fatal error is from GetAddress, dont be ignore it");
2856
2460
  if (typeof pollingGroup !== "string")
2857
2461
  throw new Error("The pollingGroup is not string, this fatal error is from GetAddress, dont be ignore it");
2858
2462
  const slots = buffer.readUInt8(6) & 0x0f;
2859
- return new TPollDataReq({
2860
- control,
2861
- pollingGroup: pollingGroup,
2862
- numberOfSlots: slots,
2863
- });
2463
+ return new TPollDataReq(pollingGroup, slots);
2864
2464
  }
2865
2465
  },
2866
2466
  "T_Poll_Data.con": class TPollDataCon {
@@ -2870,14 +2470,11 @@ class EMI {
2870
2470
  pollingGroup;
2871
2471
  pollData;
2872
2472
  nrOfSlots;
2873
- constructor(value) {
2874
- if (typeof value !== "object" || value === null) {
2875
- throw new InvalidInputObject(TPollDataCon.name);
2876
- }
2877
- this.sourceAddress = value.sourceAddress;
2878
- this.pollingGroup = value.pollingGroup;
2879
- this.pollData = value.pollData;
2880
- this.nrOfSlots = value.nrOfSlots;
2473
+ constructor(sourceAddress, pollingGroup, pollData, nrOfSlots) {
2474
+ this.sourceAddress = sourceAddress;
2475
+ this.pollingGroup = pollingGroup;
2476
+ this.pollData = pollData;
2477
+ this.nrOfSlots = nrOfSlots;
2881
2478
  }
2882
2479
  toBuffer() {
2883
2480
  const buffer = Buffer.alloc(7 + this.pollData.length);
@@ -2893,7 +2490,7 @@ class EMI {
2893
2490
  }
2894
2491
  describe() {
2895
2492
  return {
2896
- messageCode: this.messageCode,
2493
+ messageCode: this.messageCode.toString(),
2897
2494
  control: this.control.describe(),
2898
2495
  sourceAddress: this.sourceAddress,
2899
2496
  pollingGroup: this.pollingGroup,
@@ -2906,7 +2503,7 @@ class EMI {
2906
2503
  throw new Error("Invalid Code");
2907
2504
  if (buffer.length < 7)
2908
2505
  throw new Error("Buffer too short");
2909
- const control = new ControlField_1.ControlField(buffer.readUInt8(1));
2506
+ // const control = new ControlField(buffer.readUInt8(1));
2910
2507
  const sourceAddress = KNXHelper_1.KNXHelper.GetAddress(buffer.subarray(2, 4), ".");
2911
2508
  const pollingGroup = KNXHelper_1.KNXHelper.GetAddress(buffer.subarray(4, 6), "/");
2912
2509
  if (!sourceAddress)
@@ -2919,13 +2516,7 @@ class EMI {
2919
2516
  throw new Error("The pollingGroup is not string, this fatal error is from GetAddress, dont be ignore it");
2920
2517
  const slots = buffer.readUInt8(6) & 0x0f;
2921
2518
  const data = buffer.subarray(7);
2922
- return new TPollDataCon({
2923
- control,
2924
- sourceAddress: sourceAddress,
2925
- pollingGroup: pollingGroup,
2926
- nrOfSlots: slots,
2927
- pollData: data,
2928
- });
2519
+ return new TPollDataCon(sourceAddress, pollingGroup, data, slots);
2929
2520
  }
2930
2521
  },
2931
2522
  };
@@ -2941,11 +2532,8 @@ class EMI {
2941
2532
  "M_Connect.ind": class MConnectInd {
2942
2533
  messageCode = MessageCodeField_1.MESSAGE_CODE_FIELD["M_Connect.ind"]["EMI2/IMI2"].value;
2943
2534
  sourceAddress;
2944
- constructor(value) {
2945
- if (typeof value !== "object" || value === null) {
2946
- throw new InvalidInputObject(MConnectInd.name);
2947
- }
2948
- this.sourceAddress = value.sourceAddress;
2535
+ constructor(sourceAddress) {
2536
+ this.sourceAddress = sourceAddress;
2949
2537
  }
2950
2538
  toBuffer() {
2951
2539
  const buffer = Buffer.alloc(6);
@@ -2958,7 +2546,7 @@ class EMI {
2958
2546
  }
2959
2547
  describe() {
2960
2548
  return {
2961
- messageCode: this.messageCode,
2549
+ messageCode: this.messageCode.toString(),
2962
2550
  sourceAddress: this.sourceAddress,
2963
2551
  };
2964
2552
  }
@@ -2974,9 +2562,7 @@ class EMI {
2974
2562
  throw new Error("The sourceAddress is undefined or null, this fatal error is from GetAddress, dont be ignore it");
2975
2563
  if (typeof sourceAddress !== "string")
2976
2564
  throw new Error("The sourceAddress is not string, this fatal error is from GetAddress, dont be ignore it");
2977
- return new MConnectInd({
2978
- sourceAddress: sourceAddress,
2979
- });
2565
+ return new MConnectInd(sourceAddress);
2980
2566
  }
2981
2567
  },
2982
2568
  "M_Disconnect.ind": class MDisconnectInd {
@@ -2993,7 +2579,7 @@ class EMI {
2993
2579
  }
2994
2580
  describe() {
2995
2581
  return {
2996
- messageCode: this.messageCode,
2582
+ messageCode: this.messageCode.toString(),
2997
2583
  };
2998
2584
  }
2999
2585
  static fromBuffer(buffer) {
@@ -3009,13 +2595,10 @@ class EMI {
3009
2595
  control = new ControlField_1.ControlField();
3010
2596
  APDU;
3011
2597
  hopCount;
3012
- constructor(value) {
3013
- if (typeof value !== "object" || value === null) {
3014
- throw new InvalidInputObject(MUserDataConnectedReq.name);
3015
- }
3016
- this.control.priority = value.control.priority;
3017
- this.APDU = value.APDU;
3018
- this.hopCount = value.hopCount;
2598
+ constructor(priority, apdu, hopCount) {
2599
+ this.control.priority = priority;
2600
+ this.APDU = apdu;
2601
+ this.hopCount = hopCount;
3019
2602
  }
3020
2603
  toBuffer() {
3021
2604
  const buffer = Buffer.alloc(8 + this.APDU.length);
@@ -3030,9 +2613,9 @@ class EMI {
3030
2613
  }
3031
2614
  describe() {
3032
2615
  return {
3033
- messageCode: this.messageCode,
2616
+ messageCode: this.messageCode.toString(),
3034
2617
  control: this.control.describe(),
3035
- hopCount: this.hopCount,
2618
+ hopCount: this.hopCount.toString(),
3036
2619
  APDU: this.APDU.toString("hex"),
3037
2620
  };
3038
2621
  }
@@ -3055,23 +2638,16 @@ class EMI {
3055
2638
  // Asumiré para leer que la Data real empieza en 8 dado el conflicto, o leeremos desde 7 si el 0x02 es parte de la data.
3056
2639
  // Estandarizando: Leemos el buffer restante como APDU.
3057
2640
  const apdu = buffer.subarray(7, 7 + length);
3058
- return new MUserDataConnectedReq({
3059
- control: { priority: control.priority },
3060
- hopCount: hopCount,
3061
- APDU: apdu,
3062
- });
2641
+ return new MUserDataConnectedReq(control.priority, apdu, hopCount);
3063
2642
  }
3064
2643
  },
3065
2644
  "M_User_Data_Connected.con": class MUserDataConnectedCon {
3066
2645
  messageCode = MessageCodeField_1.MESSAGE_CODE_FIELD["M_User_Data_Connected.con"]["EMI2/IMI2"].value;
3067
2646
  control = new ControlField_1.ControlField();
3068
2647
  APDU;
3069
- constructor(value) {
3070
- if (typeof value !== "object" || value === null) {
3071
- throw new InvalidInputObject(MUserDataConnectedCon.name);
3072
- }
3073
- this.control.confirm = value.control.confirm;
3074
- this.APDU = value.APDU;
2648
+ constructor(confirm, apdu) {
2649
+ this.control.confirm = confirm;
2650
+ this.APDU = apdu;
3075
2651
  }
3076
2652
  toBuffer() {
3077
2653
  const buffer = Buffer.alloc(8 + this.APDU.length);
@@ -3086,7 +2662,7 @@ class EMI {
3086
2662
  }
3087
2663
  describe() {
3088
2664
  return {
3089
- messageCode: this.messageCode,
2665
+ messageCode: this.messageCode.toString(),
3090
2666
  control: this.control.describe(),
3091
2667
  APDU: this.APDU.toString("hex"),
3092
2668
  };
@@ -3099,10 +2675,7 @@ class EMI {
3099
2675
  const length = buffer.readUInt8(6) & 0x0f;
3100
2676
  // Mismo conflicto del byte 7 (0x02). Leemos length bytes desde 7.
3101
2677
  const apdu = buffer.subarray(7, 7 + length);
3102
- return new MUserDataConnectedCon({
3103
- control: { confirm: control.confirm },
3104
- APDU: apdu,
3105
- });
2678
+ return new MUserDataConnectedCon(control.confirm, apdu);
3106
2679
  }
3107
2680
  },
3108
2681
  "M_User_Data_Connected.ind": class MUserDataConnectedInd {
@@ -3110,13 +2683,10 @@ class EMI {
3110
2683
  control = new ControlField_1.ControlField();
3111
2684
  sourceAddress;
3112
2685
  APDU;
3113
- constructor(value) {
3114
- if (typeof value !== "object" || value === null) {
3115
- throw new InvalidInputObject(MUserDataConnectedInd.name);
3116
- }
3117
- this.control.priority = value.control.priority;
3118
- this.sourceAddress = value.sourceAddress;
3119
- this.APDU = value.APDU;
2686
+ constructor(priority, sourceAddress, apdu) {
2687
+ this.control.priority = priority;
2688
+ this.sourceAddress = sourceAddress;
2689
+ this.APDU = apdu;
3120
2690
  }
3121
2691
  toBuffer() {
3122
2692
  const buffer = Buffer.alloc(8 + this.APDU.length);
@@ -3132,7 +2702,7 @@ class EMI {
3132
2702
  }
3133
2703
  describe() {
3134
2704
  return {
3135
- messageCode: this.messageCode,
2705
+ messageCode: this.messageCode.toString(),
3136
2706
  control: this.control.describe(),
3137
2707
  sourceAddress: this.sourceAddress,
3138
2708
  APDU: this.APDU.toString("hex"),
@@ -3150,11 +2720,7 @@ class EMI {
3150
2720
  throw new Error("The sourceAddress is not string, this fatal error is from GetAddress, dont be ignore it");
3151
2721
  const length = buffer.readUInt8(6) & 0x0f;
3152
2722
  const apdu = buffer.subarray(7, 7 + length);
3153
- return new MUserDataConnectedInd({
3154
- control: { priority: control.priority },
3155
- sourceAddress: sourceAddress,
3156
- APDU: apdu,
3157
- });
2723
+ return new MUserDataConnectedInd(control.priority, sourceAddress, apdu);
3158
2724
  }
3159
2725
  },
3160
2726
  "A_Data_Group.req": class ADataGroupReq {
@@ -3164,15 +2730,12 @@ class EMI {
3164
2730
  apci;
3165
2731
  data;
3166
2732
  hopCount;
3167
- constructor(value) {
3168
- if (typeof value !== "object" || value === null) {
3169
- throw new InvalidInputObject(ADataGroupReq.name);
3170
- }
3171
- this.control.priority = value.control.priority;
3172
- this.sap = value.sap;
3173
- this.apci = value.apci;
3174
- this.data = value.data;
3175
- this.hopCount = value.hopCount;
2733
+ constructor(priority, sap, apci, data, hopCount) {
2734
+ this.control.priority = priority;
2735
+ this.sap = sap;
2736
+ this.apci = apci;
2737
+ this.data = data;
2738
+ this.hopCount = hopCount;
3176
2739
  }
3177
2740
  toBuffer() {
3178
2741
  const buffer = Buffer.alloc(8 + this.data.length);
@@ -3191,10 +2754,10 @@ class EMI {
3191
2754
  }
3192
2755
  describe() {
3193
2756
  return {
3194
- messageCode: this.messageCode,
2757
+ messageCode: this.messageCode.toString(),
3195
2758
  control: this.control.describe(),
3196
- sap: this.sap,
3197
- hopCount: this.hopCount,
2759
+ sap: this.sap.toString(),
2760
+ hopCount: this.hopCount.toString(),
3198
2761
  apci: this.apci.describe(),
3199
2762
  data: this.data.toString("hex"),
3200
2763
  };
@@ -3219,13 +2782,7 @@ class EMI {
3219
2782
  // La data suele empezar en el byte 1 de la APDU (masked) o byte 2, depende de la longitud (<= 6 bits o > 6 bits).
3220
2783
  // Por simplicidad devolvemos el payload crudo, ajusta según tu parser APCI.
3221
2784
  const data = fullAPDU;
3222
- return new ADataGroupReq({
3223
- control: { priority: control.priority },
3224
- sap: sap,
3225
- apci: newAPCI,
3226
- data: data,
3227
- hopCount: hopCount,
3228
- });
2785
+ return new ADataGroupReq(control.priority, sap, newAPCI, data, hopCount);
3229
2786
  }
3230
2787
  },
3231
2788
  "A_Data_Group.con": class ADataGroupCon {
@@ -3234,14 +2791,11 @@ class EMI {
3234
2791
  sap;
3235
2792
  apci;
3236
2793
  data;
3237
- constructor(value) {
3238
- if (typeof value !== "object" || value === null) {
3239
- throw new InvalidInputObject(ADataGroupCon.name);
3240
- }
3241
- this.control.confirm = value.control.confirm;
3242
- this.sap = value.sap;
3243
- this.apci = value.apci;
3244
- this.data = value.data;
2794
+ constructor(confirm, sap, apci, data) {
2795
+ this.control.confirm = confirm;
2796
+ this.sap = sap;
2797
+ this.apci = apci;
2798
+ this.data = data;
3245
2799
  }
3246
2800
  toBuffer() {
3247
2801
  const totalLength = this.data.length;
@@ -3260,9 +2814,9 @@ class EMI {
3260
2814
  }
3261
2815
  describe() {
3262
2816
  return {
3263
- messageCode: this.messageCode,
2817
+ messageCode: this.messageCode.toString(),
3264
2818
  control: this.control.describe(),
3265
- sap: this.sap,
2819
+ sap: this.sap.toString(),
3266
2820
  apci: this.apci.describe(),
3267
2821
  data: this.data.toString("hex"),
3268
2822
  };
@@ -3279,12 +2833,7 @@ class EMI {
3279
2833
  const apci2 = buffer[8] & 0xc0;
3280
2834
  const fullAPCI = apci1 | (apci2 >> 4);
3281
2835
  const apci = new APCI_1.APCI(fullAPCI);
3282
- return new ADataGroupCon({
3283
- control: { confirm: control.confirm },
3284
- sap: sap,
3285
- apci: apci,
3286
- data: fullAPDU,
3287
- });
2836
+ return new ADataGroupCon(control.confirm, sap, apci, fullAPDU);
3288
2837
  }
3289
2838
  },
3290
2839
  "A_Data_Group.ind": class ADataGroupInd {
@@ -3293,14 +2842,11 @@ class EMI {
3293
2842
  sap;
3294
2843
  apci;
3295
2844
  data;
3296
- constructor(value) {
3297
- if (typeof value !== "object" || value === null) {
3298
- throw new InvalidInputObject(ADataGroupInd.name);
3299
- }
3300
- this.control.priority = value.control.priority;
3301
- this.sap = value.sap;
3302
- this.apci = value.apci;
3303
- this.data = value.data;
2845
+ constructor(priority, sap, apci, data) {
2846
+ this.control.priority = priority;
2847
+ this.sap = sap;
2848
+ this.apci = apci;
2849
+ this.data = data;
3304
2850
  }
3305
2851
  toBuffer() {
3306
2852
  const totalLength = this.data.length;
@@ -3319,9 +2865,9 @@ class EMI {
3319
2865
  }
3320
2866
  describe() {
3321
2867
  return {
3322
- messageCode: this.messageCode,
2868
+ messageCode: this.messageCode.toString(),
3323
2869
  control: this.control.describe(),
3324
- sap: this.sap,
2870
+ sap: this.sap.toString(),
3325
2871
  apci: this.apci.describe(),
3326
2872
  data: this.data.toString("hex"),
3327
2873
  };
@@ -3338,12 +2884,7 @@ class EMI {
3338
2884
  const apci2 = buffer[8] & 0xc0;
3339
2885
  const fullAPCI = apci1 | (apci2 >> 4);
3340
2886
  const apci = new APCI_1.APCI(fullAPCI);
3341
- return new ADataGroupInd({
3342
- control: { priority: control.priority },
3343
- sap: sap,
3344
- apci: apci,
3345
- data: fullAPDU,
3346
- });
2887
+ return new ADataGroupInd(control.priority, sap, apci, fullAPDU);
3347
2888
  }
3348
2889
  },
3349
2890
  "M_User_Data_Individual.req": class MUserDataIndividualReq {
@@ -3353,15 +2894,12 @@ class EMI {
3353
2894
  apci = new APCI_1.APCI(APCIEnum_1.APCIEnum.A_UserMemory_Read_Protocol_Data_Unit);
3354
2895
  data;
3355
2896
  hopCount;
3356
- constructor(value) {
3357
- if (typeof value !== "object" || value === null) {
3358
- throw new InvalidInputObject(MUserDataIndividualReq.name);
3359
- }
3360
- this.control.priority = value.control.priority;
3361
- this.destinationAddress = value.destinationAddress;
2897
+ constructor(priority, destinationAddress, data, hopCount) {
2898
+ this.control.priority = priority;
2899
+ this.destinationAddress = destinationAddress;
3362
2900
  this.apci.command = APCIEnum_1.APCIEnum.A_UserMemory_Read_Protocol_Data_Unit; // 2C0
3363
- this.data = value.data;
3364
- this.hopCount = value.hopCount;
2901
+ this.data = data;
2902
+ this.hopCount = hopCount;
3365
2903
  }
3366
2904
  toBuffer() {
3367
2905
  const totalLength = this.data.length;
@@ -3379,10 +2917,10 @@ class EMI {
3379
2917
  }
3380
2918
  describe() {
3381
2919
  return {
3382
- messageCode: this.messageCode,
2920
+ messageCode: this.messageCode.toString(),
3383
2921
  control: this.control.describe(),
3384
2922
  destinationAddress: this.destinationAddress,
3385
- hopCount: this.hopCount,
2923
+ hopCount: this.hopCount.toString(),
3386
2924
  apci: this.apci.describe(),
3387
2925
  data: this.data.toString("hex"),
3388
2926
  };
@@ -3401,12 +2939,7 @@ class EMI {
3401
2939
  const hopCount = (octet6 >> 4) & 0x07;
3402
2940
  const length = octet6 & 0x0f;
3403
2941
  const data = buffer.subarray(7, 7 + length);
3404
- return new MUserDataIndividualReq({
3405
- control: { priority: control.priority },
3406
- destinationAddress: destAddr,
3407
- hopCount: hopCount,
3408
- data: data,
3409
- });
2942
+ return new MUserDataIndividualReq(control.priority, destAddr, data, hopCount);
3410
2943
  }
3411
2944
  },
3412
2945
  "M_User_Data_Individual.con": class MUserDataIndividualCon {
@@ -3415,14 +2948,11 @@ class EMI {
3415
2948
  destinationAddress;
3416
2949
  apci = new APCI_1.APCI(APCIEnum_1.APCIEnum.A_UserMemory_Read_Protocol_Data_Unit);
3417
2950
  data;
3418
- constructor(value) {
3419
- if (typeof value !== "object" || value === null) {
3420
- throw new InvalidInputObject(MUserDataIndividualCon.name);
3421
- }
3422
- this.control.confirm = value.control.confirm;
3423
- this.destinationAddress = value.destinationAddress;
2951
+ constructor(confirm, destinationAddress, data) {
2952
+ this.control.confirm = confirm;
2953
+ this.destinationAddress = destinationAddress;
3424
2954
  this.apci.command = APCIEnum_1.APCIEnum.A_UserMemory_Read_Protocol_Data_Unit; // 2C0
3425
- this.data = value.data;
2955
+ this.data = data;
3426
2956
  }
3427
2957
  toBuffer() {
3428
2958
  const totalLength = this.data.length;
@@ -3440,7 +2970,7 @@ class EMI {
3440
2970
  }
3441
2971
  describe() {
3442
2972
  return {
3443
- messageCode: this.messageCode,
2973
+ messageCode: this.messageCode.toString(),
3444
2974
  control: this.control.describe(),
3445
2975
  destinationAddress: this.destinationAddress,
3446
2976
  apci: this.apci.describe(),
@@ -3459,11 +2989,7 @@ class EMI {
3459
2989
  throw new Error("The destAddr is not string, this fatal error is from GetAddress, dont be ignore it");
3460
2990
  const length = buffer.readUInt8(6) & 0x0f;
3461
2991
  const data = buffer.subarray(7, 7 + length);
3462
- return new MUserDataIndividualCon({
3463
- control: { confirm: control.confirm },
3464
- destinationAddress: destAddr,
3465
- data: data,
3466
- });
2992
+ return new MUserDataIndividualCon(control.confirm, destAddr, data);
3467
2993
  }
3468
2994
  },
3469
2995
  "M_User_Data_Individual.ind": class MUserDataIndividualInd {
@@ -3473,15 +2999,12 @@ class EMI {
3473
2999
  destinationAddress;
3474
3000
  apci = new APCI_1.APCI(APCIEnum_1.APCIEnum.A_UserMemory_Read_Protocol_Data_Unit);
3475
3001
  data;
3476
- constructor(value) {
3477
- if (typeof value !== "object" || value === null) {
3478
- throw new InvalidInputObject(MUserDataIndividualInd.name);
3479
- }
3480
- this.control.priority = value.control.priority;
3481
- this.sourceAddress = value.sourceAddress;
3482
- this.destinationAddress = value.destinationAddress;
3002
+ constructor(priority, sourceAddress, destinationAddress, data) {
3003
+ this.control.priority = priority;
3004
+ this.sourceAddress = sourceAddress;
3005
+ this.destinationAddress = destinationAddress;
3483
3006
  this.apci.command = APCIEnum_1.APCIEnum.A_UserMemory_Read_Protocol_Data_Unit; // 2C0
3484
- this.data = value.data;
3007
+ this.data = data;
3485
3008
  }
3486
3009
  toBuffer() {
3487
3010
  const totalLength = this.data.length;
@@ -3500,7 +3023,7 @@ class EMI {
3500
3023
  }
3501
3024
  describe() {
3502
3025
  return {
3503
- messageCode: this.messageCode,
3026
+ messageCode: this.messageCode.toString(),
3504
3027
  control: this.control.describe(),
3505
3028
  sourceAddress: this.sourceAddress,
3506
3029
  destinationAddress: this.destinationAddress,
@@ -3525,12 +3048,7 @@ class EMI {
3525
3048
  throw new Error("The destAddr is not string, this fatal error is from GetAddress, dont be ignore it");
3526
3049
  const length = buffer.readUInt8(6) & 0x0f;
3527
3050
  const data = buffer.subarray(7, 7 + length);
3528
- return new MUserDataIndividualInd({
3529
- control: { priority: control.priority },
3530
- sourceAddress: sourceAddr,
3531
- destinationAddress: destAddr,
3532
- data: data,
3533
- });
3051
+ return new MUserDataIndividualInd(control.priority, sourceAddr, destAddr, data);
3534
3052
  }
3535
3053
  },
3536
3054
  "A_Poll_Data.req": class APollDataReq {
@@ -3538,12 +3056,9 @@ class EMI {
3538
3056
  pollingGroup;
3539
3057
  numberOfSlots;
3540
3058
  control;
3541
- constructor(value) {
3542
- if (typeof value !== "object" || value === null) {
3543
- throw new InvalidInputObject(APollDataReq.name);
3544
- }
3545
- this.pollingGroup = value.pollingGroup;
3546
- this.numberOfSlots = value.numberOfSlots;
3059
+ constructor(pollingGroup, numberOfSlots) {
3060
+ this.pollingGroup = pollingGroup;
3061
+ this.numberOfSlots = numberOfSlots;
3547
3062
  this.control = new ControlField_1.ControlField(0xf0);
3548
3063
  }
3549
3064
  toBuffer() {
@@ -3558,10 +3073,10 @@ class EMI {
3558
3073
  }
3559
3074
  describe() {
3560
3075
  return {
3561
- messageCode: this.messageCode,
3076
+ messageCode: this.messageCode.toString(),
3562
3077
  control: this.control.describe(),
3563
3078
  pollingGroup: this.pollingGroup,
3564
- numberOfSlots: this.numberOfSlots,
3079
+ numberOfSlots: this.numberOfSlots.toString(),
3565
3080
  };
3566
3081
  }
3567
3082
  static fromBuffer(buffer) {
@@ -3575,10 +3090,7 @@ class EMI {
3575
3090
  if (typeof pollGroup !== "string")
3576
3091
  throw new Error("The pollGroup is not string, this fatal error is from GetAddress, dont be ignore it");
3577
3092
  const slots = buffer.readUInt8(6) & 0x0f;
3578
- return new APollDataReq({
3579
- pollingGroup: pollGroup,
3580
- numberOfSlots: slots,
3581
- });
3093
+ return new APollDataReq(pollGroup, slots);
3582
3094
  }
3583
3095
  },
3584
3096
  "A_Poll_Data.con": class APollDataCon {
@@ -3588,14 +3100,11 @@ class EMI {
3588
3100
  numberOfSlots;
3589
3101
  pollData;
3590
3102
  control;
3591
- constructor(value) {
3592
- if (typeof value !== "object" || value === null) {
3593
- throw new InvalidInputObject(APollDataCon.name);
3594
- }
3595
- this.sourceAddress = value.sourceAddress;
3596
- this.pollingGroup = value.pollingGroup;
3597
- this.numberOfSlots = value.numberOfSlots;
3598
- this.pollData = value.pollData;
3103
+ constructor(sourceAddress, pollingGroup, numberOfSlots, pollData) {
3104
+ this.sourceAddress = sourceAddress;
3105
+ this.pollingGroup = pollingGroup;
3106
+ this.numberOfSlots = numberOfSlots;
3107
+ this.pollData = pollData;
3599
3108
  this.control = new ControlField_1.ControlField(0xf0);
3600
3109
  }
3601
3110
  toBuffer() {
@@ -3611,11 +3120,11 @@ class EMI {
3611
3120
  }
3612
3121
  describe() {
3613
3122
  return {
3614
- messageCode: this.messageCode,
3123
+ messageCode: this.messageCode.toString(),
3615
3124
  control: this.control.describe(),
3616
3125
  sourceAddress: this.sourceAddress,
3617
3126
  pollingGroup: this.pollingGroup,
3618
- numberOfSlots: this.numberOfSlots,
3127
+ numberOfSlots: this.numberOfSlots.toString(),
3619
3128
  pollData: this.pollData.toString("hex"),
3620
3129
  };
3621
3130
  }
@@ -3639,12 +3148,7 @@ class EMI {
3639
3148
  const slots = buffer.readUInt8(6) & 0x0f;
3640
3149
  // Offset 7: Data
3641
3150
  const pollData = buffer.subarray(7);
3642
- return new APollDataCon({
3643
- sourceAddress: sourceAddress,
3644
- pollingGroup: pollingGroup,
3645
- numberOfSlots: slots,
3646
- pollData: pollData,
3647
- });
3151
+ return new APollDataCon(sourceAddress, pollingGroup, slots, pollData);
3648
3152
  }
3649
3153
  },
3650
3154
  };