knx.ts 1.0.8 → 1.0.11
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.
- package/dist/@types/interfaces/DPTs.d.ts +14 -14
- package/dist/@types/interfaces/ServiceMessage.d.ts +4 -1
- package/dist/@types/interfaces/connection.d.ts +40 -5
- package/dist/@types/interfaces/servers.d.ts +4 -2
- package/dist/connection/KNXTunneling.js +1 -0
- package/dist/connection/KNXnetIPServer.js +5 -3
- package/dist/connection/Router.js +7 -6
- package/dist/core/CEMI.d.ts +291 -53
- package/dist/core/CEMI.js +38 -13
- package/dist/core/ControlField.d.ts +9 -7
- package/dist/core/ControlField.js +16 -14
- package/dist/core/ControlFieldExtended.d.ts +2 -2
- package/dist/core/ControlFieldExtended.js +10 -10
- package/dist/core/EMI.d.ts +548 -87
- package/dist/core/EMI.js +66 -0
- package/dist/core/KNXAddInfoTypes.d.ts +93 -1
- package/dist/core/KNXAddInfoTypes.js +103 -0
- package/dist/core/MessageCodeField.js +89 -89
- package/dist/core/SystemStatus.d.ts +16 -14
- package/dist/core/SystemStatus.js +18 -16
- package/dist/core/cache/GroupAddressCache.d.ts +2 -1
- package/dist/core/cache/GroupAddressCache.js +33 -7
- package/dist/core/data/KNXDataDecode.js +0 -3
- package/dist/core/data/KNXDataEncode.d.ts +46 -46
- package/dist/core/data/KNXDataEncode.js +227 -233
- package/dist/core/layers/data/APDU.d.ts +2 -0
- package/dist/core/layers/data/APDU.js +1 -0
- package/dist/core/layers/data/NPDU.d.ts +5 -0
- package/dist/core/layers/data/NPDU.js +1 -0
- package/dist/core/layers/data/TPDU.d.ts +4 -0
- package/dist/core/layers/data/TPDU.js +1 -0
- package/dist/core/layers/interfaces/TPCI.d.ts +1 -0
- package/dist/core/layers/interfaces/TPCI.js +5 -3
- package/dist/index.d.ts +1 -0
- package/dist/server/KNXMQTTGateway.js +18 -7
- package/dist/server/KNXWebSocketServer.js +55 -23
- package/dist/utils/KNXHelper.js +8 -7
- package/package.json +5 -4
|
@@ -3,7 +3,7 @@ export interface DPT1 {
|
|
|
3
3
|
}
|
|
4
4
|
export interface DPT2 {
|
|
5
5
|
control: 0 | 1;
|
|
6
|
-
|
|
6
|
+
value: 0 | 1;
|
|
7
7
|
}
|
|
8
8
|
export interface DPT3 {
|
|
9
9
|
control: 0 | 1;
|
|
@@ -13,29 +13,29 @@ export interface DPT4 {
|
|
|
13
13
|
char: string;
|
|
14
14
|
}
|
|
15
15
|
export interface DPT5 {
|
|
16
|
-
|
|
16
|
+
value: number;
|
|
17
17
|
}
|
|
18
18
|
export interface DPT5001 {
|
|
19
|
-
|
|
19
|
+
value: number;
|
|
20
20
|
}
|
|
21
21
|
export interface DPT5002 {
|
|
22
|
-
|
|
22
|
+
value: number;
|
|
23
23
|
}
|
|
24
24
|
export interface DPT6 {
|
|
25
|
-
|
|
25
|
+
value: number;
|
|
26
26
|
}
|
|
27
27
|
export interface DPT6020 {
|
|
28
28
|
status: 0 | 1;
|
|
29
29
|
mode: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7;
|
|
30
30
|
}
|
|
31
31
|
export interface DPT7 {
|
|
32
|
-
|
|
32
|
+
value: number;
|
|
33
33
|
}
|
|
34
34
|
export interface DPT8 {
|
|
35
|
-
|
|
35
|
+
value: number;
|
|
36
36
|
}
|
|
37
37
|
export interface DPT9 {
|
|
38
|
-
|
|
38
|
+
value: number;
|
|
39
39
|
}
|
|
40
40
|
export interface DPT10001 {
|
|
41
41
|
day: number;
|
|
@@ -49,13 +49,13 @@ export interface DPT11001 {
|
|
|
49
49
|
year: number;
|
|
50
50
|
}
|
|
51
51
|
export interface DPT12001 {
|
|
52
|
-
|
|
52
|
+
value: number;
|
|
53
53
|
}
|
|
54
54
|
export interface DPT13001 {
|
|
55
|
-
|
|
55
|
+
value: number;
|
|
56
56
|
}
|
|
57
57
|
export interface DPT14 {
|
|
58
|
-
|
|
58
|
+
value: number;
|
|
59
59
|
}
|
|
60
60
|
export interface DPT15 {
|
|
61
61
|
D6: number;
|
|
@@ -77,17 +77,17 @@ export interface DPT16002 {
|
|
|
77
77
|
hex: string;
|
|
78
78
|
}
|
|
79
79
|
export interface DPT20 {
|
|
80
|
-
|
|
80
|
+
value: number;
|
|
81
81
|
}
|
|
82
82
|
export interface DPT27001 {
|
|
83
83
|
mask: number;
|
|
84
84
|
status: number;
|
|
85
85
|
}
|
|
86
86
|
export interface DPT28001 {
|
|
87
|
-
|
|
87
|
+
value: string;
|
|
88
88
|
}
|
|
89
89
|
export interface DPT29 {
|
|
90
|
-
|
|
90
|
+
value: bigint;
|
|
91
91
|
}
|
|
92
92
|
export interface DPT238600 {
|
|
93
93
|
BF: 0 | 1;
|
|
@@ -3,7 +3,10 @@ export interface DescribeEstructure {
|
|
|
3
3
|
* Proporciona una descripción legible del estado actual de las propiedades del sistema.
|
|
4
4
|
* @returns Un objeto que describe el estado de cada propiedad.
|
|
5
5
|
*/
|
|
6
|
-
describe():
|
|
6
|
+
describe(): {
|
|
7
|
+
obj: string;
|
|
8
|
+
[key: string]: string | number | Buffer | boolean | Record<string, any>;
|
|
9
|
+
};
|
|
7
10
|
}
|
|
8
11
|
export interface ServiceMessage extends DescribeEstructure {
|
|
9
12
|
/** Write the service to the buffer */
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import pino from "pino";
|
|
2
2
|
import { ConnectionType } from "../../core/enum/KNXnetIPEnum";
|
|
3
|
+
import { CEMIInstance } from "../../core/CEMI";
|
|
3
4
|
/**
|
|
4
5
|
* Options for configuring a KNX Tunneling connection.
|
|
5
6
|
*/
|
|
@@ -29,12 +30,30 @@ export interface KNXTunnelingOptions extends KNXnetIPOptions {
|
|
|
29
30
|
*/
|
|
30
31
|
maxQueueSize?: number;
|
|
31
32
|
}
|
|
32
|
-
export interface KNXnetIPServerOptions extends Omit<KNXnetIPOptions, "ip"
|
|
33
|
+
export interface KNXnetIPServerOptions extends Omit<KNXnetIPOptions, "ip"> {
|
|
34
|
+
/**
|
|
35
|
+
* IP for Multicast
|
|
36
|
+
*/
|
|
33
37
|
ip?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Port for listening to Tunneling clients
|
|
40
|
+
*/
|
|
34
41
|
port?: number;
|
|
42
|
+
/**
|
|
43
|
+
* Individual address for KNXnetIpServer
|
|
44
|
+
*/
|
|
35
45
|
individualAddress?: string;
|
|
46
|
+
/**
|
|
47
|
+
* MAC address for the KNXnetIP
|
|
48
|
+
*/
|
|
36
49
|
serialNumber?: Buffer;
|
|
50
|
+
/**
|
|
51
|
+
* The name displayed to other KNXnetIP devices or applications such as ETS.
|
|
52
|
+
*/
|
|
37
53
|
friendlyName?: string;
|
|
54
|
+
/**
|
|
55
|
+
* MAC address for the KNXnetIP
|
|
56
|
+
*/
|
|
38
57
|
macAddress?: string;
|
|
39
58
|
/**
|
|
40
59
|
* Defines the client address pool for KNXnet/IP Tunneling connections (e.g. "15.15.10:10" or "1.1.1:5").
|
|
@@ -67,15 +86,21 @@ export interface ExternalManagerOptions {
|
|
|
67
86
|
/**
|
|
68
87
|
* Optional configuration for a physical TPUART connection.
|
|
69
88
|
*/
|
|
70
|
-
tpuart?:
|
|
89
|
+
tpuart?: {
|
|
90
|
+
individualAddress?: string;
|
|
91
|
+
} & Omit<TPUARTOptions, "individualAddress">;
|
|
71
92
|
/**
|
|
72
93
|
* Optional list of outbound KNX IP Tunneling client connections.
|
|
73
94
|
*/
|
|
74
|
-
tunneling?:
|
|
95
|
+
tunneling?: {
|
|
96
|
+
individualAddress?: string;
|
|
97
|
+
} & Omit<KNXTunnelingOptions, "individualAddress">[];
|
|
75
98
|
/**
|
|
76
99
|
* Optional configuration for a physical KNX USB connection.
|
|
77
100
|
*/
|
|
78
|
-
usb?:
|
|
101
|
+
usb?: {
|
|
102
|
+
individualAddress?: string;
|
|
103
|
+
} & Omit<KNXUSBOptions, "individualAddress">;
|
|
79
104
|
/**
|
|
80
105
|
* Pino logger configuration for the Router bridge.
|
|
81
106
|
*/
|
|
@@ -116,8 +141,14 @@ export interface KNXLoggerOptions extends pino.LoggerOptions {
|
|
|
116
141
|
logKeepCount?: number;
|
|
117
142
|
}
|
|
118
143
|
export interface KNXnetIPOptions {
|
|
144
|
+
/**
|
|
145
|
+
* IP address of the KNXnetIP server
|
|
146
|
+
*/
|
|
119
147
|
ip: string;
|
|
120
|
-
|
|
148
|
+
/**
|
|
149
|
+
* Port of the KNXnetIP server
|
|
150
|
+
*/
|
|
151
|
+
port?: number;
|
|
121
152
|
localIp?: string;
|
|
122
153
|
localPort?: number;
|
|
123
154
|
/**
|
|
@@ -204,3 +235,7 @@ export interface KNXDiscoveredDevice {
|
|
|
204
235
|
macAddress: string;
|
|
205
236
|
friendlyName: string;
|
|
206
237
|
}
|
|
238
|
+
export interface IndicationRouterLink {
|
|
239
|
+
src: string;
|
|
240
|
+
msg: CEMIInstance;
|
|
241
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { KNXService } from "../../connection/KNXService";
|
|
2
|
+
import { Router } from "../../connection/Router";
|
|
2
3
|
export interface MQTTGatewayOptions {
|
|
3
|
-
knxContext: KNXService;
|
|
4
|
+
knxContext: KNXService | Router;
|
|
4
5
|
embeddedBroker?: {
|
|
5
6
|
port: number;
|
|
6
7
|
host?: string;
|
|
@@ -11,8 +12,9 @@ export interface MQTTGatewayOptions {
|
|
|
11
12
|
topicPrefix?: string;
|
|
12
13
|
}
|
|
13
14
|
export interface WebSocketGatewayOptions {
|
|
15
|
+
host: string;
|
|
14
16
|
port: number;
|
|
15
|
-
knxContext: KNXService;
|
|
17
|
+
knxContext: KNXService | Router;
|
|
16
18
|
}
|
|
17
19
|
export interface WSClientPayload {
|
|
18
20
|
action: "read" | "query" | "write" | "config_dpt" | "subscribe" | "unsubscribe";
|
|
@@ -43,6 +43,7 @@ class KNXTunneling extends KNXService_1.KNXService {
|
|
|
43
43
|
if (!this.options.connectionType) {
|
|
44
44
|
this.options.connectionType = KNXnetIPEnum_1.ConnectionType.TUNNEL_CONNECTION;
|
|
45
45
|
}
|
|
46
|
+
this.options.port = options.port || 3671;
|
|
46
47
|
this.MAX_QUEUE_SIZE = options.maxQueueSize || 100;
|
|
47
48
|
this.logger = this.logger.child({ module: "TunnelClient" });
|
|
48
49
|
}
|
|
@@ -50,6 +50,8 @@ class KNXnetIPServer extends KNXService_1.KNXService {
|
|
|
50
50
|
// Set defaults for discovery if not provided
|
|
51
51
|
const routingOptions = this.options;
|
|
52
52
|
const netInfo = (0, localIp_1.getNetworkInfo)();
|
|
53
|
+
this.options.ip = options.ip || "224.0.23.12";
|
|
54
|
+
this.options.port = options.port || 3671;
|
|
53
55
|
this.options.localIp = options.localIp || netInfo.address;
|
|
54
56
|
routingOptions.individualAddress = options.individualAddress || "15.15.0";
|
|
55
57
|
this.individualAddress = routingOptions.individualAddress;
|
|
@@ -62,7 +64,7 @@ class KNXnetIPServer extends KNXService_1.KNXService {
|
|
|
62
64
|
if (!options.serialNumber) {
|
|
63
65
|
// eslint-disable-next-line no-useless-escape
|
|
64
66
|
const macBuf = Buffer.from(netInfo.mac.replace(/[:\-]/g, ""), "hex");
|
|
65
|
-
const port = options.port
|
|
67
|
+
const port = this.options.port;
|
|
66
68
|
const serial = Buffer.from(macBuf);
|
|
67
69
|
serial[0] ^= (port >> 8) & 0xff;
|
|
68
70
|
serial[1] ^= port & 0xff;
|
|
@@ -76,7 +78,7 @@ class KNXnetIPServer extends KNXService_1.KNXService {
|
|
|
76
78
|
routingOptions.routingDelay = options.routingDelay ?? 20;
|
|
77
79
|
if (routingOptions.MAX_PENDING_REQUESTS_PER_CLIENT)
|
|
78
80
|
this.MAX_PENDING_REQUESTS_PER_CLIENT = routingOptions.MAX_PENDING_REQUESTS_PER_CLIENT;
|
|
79
|
-
this.logger.info(`Initialized on ${this.options.localIp}:${options.port
|
|
81
|
+
this.logger.info(`Initialized on ${this.options.localIp}:${this.options.port}`);
|
|
80
82
|
this.logger.info(`Serial Number: ${routingOptions.serialNumber.toString("hex").toUpperCase()}`);
|
|
81
83
|
const serverIA = KNXHelper_1.KNXHelper.GetAddress(routingOptions.individualAddress, ".").readUInt16BE();
|
|
82
84
|
this.serverIAInt = serverIA;
|
|
@@ -123,7 +125,7 @@ class KNXnetIPServer extends KNXService_1.KNXService {
|
|
|
123
125
|
try {
|
|
124
126
|
socket.addMembership(this.options.ip, this.options.localIp);
|
|
125
127
|
joinedInterfaces.add(this.options.localIp);
|
|
126
|
-
this.logger.info(`Joined multicast on primary interface (${this.options.
|
|
128
|
+
this.logger.info(`Joined multicast on primary interface (${this.options.ip})`);
|
|
127
129
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
128
130
|
}
|
|
129
131
|
catch (e) {
|
|
@@ -61,7 +61,8 @@ class Router extends events_1.EventEmitter {
|
|
|
61
61
|
options.tunneling.forEach((c) => {
|
|
62
62
|
// * Tunneling doesn't support individualAddress, is assigned by the tunnel connection
|
|
63
63
|
// c.individualAddress = this.routerAddress;
|
|
64
|
-
|
|
64
|
+
const client = new KNXTunneling_1.KNXTunneling(c);
|
|
65
|
+
this.registerLink(`IP Tunneling: ${client.options.ip}:${client.options.port}`, client);
|
|
65
66
|
});
|
|
66
67
|
}
|
|
67
68
|
if (options.usb) {
|
|
@@ -175,7 +176,7 @@ class Router extends events_1.EventEmitter {
|
|
|
175
176
|
// If packet is destined for the router itself, consume it and don't route
|
|
176
177
|
if (!isGroup && dest === this.routerAddress) {
|
|
177
178
|
this.logger.debug({ src: data.sourceAddress }, "Packet consumed by router local address");
|
|
178
|
-
this.emit("indication_link", { src:
|
|
179
|
+
this.emit("indication_link", { src: keySource, msg: data });
|
|
179
180
|
return;
|
|
180
181
|
}
|
|
181
182
|
// Selective Routing (IA)
|
|
@@ -188,7 +189,7 @@ class Router extends events_1.EventEmitter {
|
|
|
188
189
|
});
|
|
189
190
|
}
|
|
190
191
|
// Send to upper layers (KNXnet/IP server core)
|
|
191
|
-
this.emit("indication_link", { src:
|
|
192
|
+
this.emit("indication_link", { src: keySource, msg: data });
|
|
192
193
|
return; // Do not flood
|
|
193
194
|
}
|
|
194
195
|
// If target is unknown, knxd broadcasts it to all interfaces
|
|
@@ -209,7 +210,7 @@ class Router extends events_1.EventEmitter {
|
|
|
209
210
|
this.sendToLink(link, data);
|
|
210
211
|
}
|
|
211
212
|
// Notify upper layers
|
|
212
|
-
this.emit("indication_link", { src:
|
|
213
|
+
this.emit("indication_link", { src: keySource, msg: data });
|
|
213
214
|
}
|
|
214
215
|
/**
|
|
215
216
|
* Evaluates if a message should be sent to a link based on configured filters.
|
|
@@ -281,8 +282,8 @@ class Router extends events_1.EventEmitter {
|
|
|
281
282
|
async read(destination) {
|
|
282
283
|
const cf1 = new ControlField_1.ControlField(0xbc);
|
|
283
284
|
const cf2 = new ControlFieldExtended_1.ExtendedControlField(0xe0);
|
|
284
|
-
const tpdu = new TPDU_1.TPDU(new TPCI_1.TPCI(TPCI_1.TPCIType.T_DATA_GROUP_PDU), new APDU_1.APDU(new TPCI_1.TPCI(TPCI_1.TPCIType.T_DATA_GROUP_PDU), new APCI_1.APCI(APCIEnum_1.APCIEnum.A_GroupValue_Read_Protocol_Data_Unit), Buffer.alloc(
|
|
285
|
-
const cemi = new CEMI_1.CEMI.DataLinkLayerCEMI["L_Data.req"](null, cf1, cf2,
|
|
285
|
+
const tpdu = new TPDU_1.TPDU(new TPCI_1.TPCI(TPCI_1.TPCIType.T_DATA_GROUP_PDU), new APDU_1.APDU(new TPCI_1.TPCI(TPCI_1.TPCIType.T_DATA_GROUP_PDU), new APCI_1.APCI(APCIEnum_1.APCIEnum.A_GroupValue_Read_Protocol_Data_Unit), Buffer.alloc(1), true), Buffer.alloc(1));
|
|
286
|
+
const cemi = new CEMI_1.CEMI.DataLinkLayerCEMI["L_Data.req"](null, cf1, cf2, "0.0.0", destination, tpdu);
|
|
286
287
|
this.logger.debug({ service: cemi.constructor.name }, "Sending GroupValue_Read");
|
|
287
288
|
return this.send(cemi);
|
|
288
289
|
}
|