From 3c26d2bff573709568ed76cff6242f4f258fcc4b Mon Sep 17 00:00:00 2001 From: Nyoto Date: Wed, 5 Aug 2020 18:21:09 +0800 Subject: [PATCH 1/4] add bindSocketPort and unit test --- src/KNXClient.ts | 8 ++++++++ src/KNXTunnelSocket.ts | 17 ++++++++++++++++- test/bindSocketPort.test.ts | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 test/bindSocketPort.test.ts diff --git a/src/KNXClient.ts b/src/KNXClient.ts index f5becaa..fa63131 100755 --- a/src/KNXClient.ts +++ b/src/KNXClient.ts @@ -98,6 +98,14 @@ export class KNXClient extends EventEmitter { this._clientSocket.on('message', this._processInboundMessage); } + bindSocketPort(port: number): void { + try { + this._clientSocket.bind(port, '0.0.0.0'); + } catch (err) { + this.emit(KNXClient.KNXClientEvents.error, err); + } + } + send(knxPacket: KNXPacket, host?: string, port?: number): void { const peerHost = host == null ? this._peerHost : host; const peerPort = port == null ? this._peerPort : port; diff --git a/src/KNXTunnelSocket.ts b/src/KNXTunnelSocket.ts index 47966e2..1cb6d97 100755 --- a/src/KNXTunnelSocket.ts +++ b/src/KNXTunnelSocket.ts @@ -25,9 +25,12 @@ export class KNXTunnelSocket extends EventEmitter { private _srcAddress: KNXAddress|null; private _host: string; private _port: number; - constructor(srcAddress: string = null) { + constructor(srcAddress: string = null, socketPort?: number) { super(); this._knxClient = new KNXClient(); + if (socketPort != null) { + this._knxClient.bindSocketPort(socketPort); + } this._connectionCB = null; this._disconnectCB = null; this._monitoringBus = false; @@ -37,6 +40,18 @@ export class KNXTunnelSocket extends EventEmitter { this._init(); } + bindSocketPort(port: number): Promise { + if (this._knxClient.isConnected() === true) { return Promise.reject('Socket already connected'); } + return new Promise((resolve, reject) => { + try { + this._knxClient.bindSocketPort(port); + resolve(); + } catch (err) { + reject(err); + } + }); + } + close(): void { this._knxClient.close(); } diff --git a/test/bindSocketPort.test.ts b/test/bindSocketPort.test.ts new file mode 100644 index 0000000..469040a --- /dev/null +++ b/test/bindSocketPort.test.ts @@ -0,0 +1,36 @@ +import {KNXTunnelSocket} from '../src/KNXTunnelSocket'; +import {KNXAddress, KNXAddressType} from '../src/protocol/KNXAddress'; + +// add firewall rule first to allow udp port 52345-52348 +describe('bindSocketPort', (): void => { + it('should able to bind on construction', async (): Promise => { + const a = new KNXTunnelSocket('3.3.3', 52345); + expect(a).toBeDefined(); + await a.connectAsync('192.168.11.36', 3671); + const dpa = KNXAddress.createFromString('1/0/0', KNXAddressType.TYPE_GROUP); + const readResult = await a.readAsync(dpa); + expect(readResult).toBeDefined(); + expect(readResult).toBeInstanceOf(Buffer); + }); + it('should be able to bind with bindSocketPort', async (): Promise => { + const a = new KNXTunnelSocket('3.3.4'); + a.bindSocketPort(52346); + expect(a).toBeDefined(); + await a.connectAsync('192.168.11.36', 3671); + const dpa = KNXAddress.createFromString('1/0/0', KNXAddressType.TYPE_GROUP); + const readResult = await a.readAsync(dpa); + expect(readResult).toBeDefined(); + expect(readResult).toBeInstanceOf(Buffer); + }); + it('should be fail to bind after connected', async (): Promise => { + const a = new KNXTunnelSocket('3.3.4'); + a.bindSocketPort(52347); + expect(a).toBeDefined(); + await a.connectAsync('192.168.11.36', 3671); + const dpa = KNXAddress.createFromString('1/0/0', KNXAddressType.TYPE_GROUP); + const readResult = await a.readAsync(dpa); + expect(readResult).toBeDefined(); + expect(readResult).toBeInstanceOf(Buffer); + expect(a.bindSocketPort(52348)).rejects.toMatch('Socket already connected'); + }); +}); From e359fd83729e522ac17bb82edd100e7b53f88d97 Mon Sep 17 00:00:00 2001 From: Nyoto Date: Mon, 10 Aug 2020 11:10:50 +0800 Subject: [PATCH 2/4] add build result --- lib/DataPointTypes/DPT1.d.ts | 2 + lib/DataPointTypes/DPT1.js | 73 ++++ lib/DataPointTypes/DPT1.js.map | 1 + lib/DataPointTypes/DPT10.d.ts | 8 + lib/DataPointTypes/DPT10.js | 32 ++ lib/DataPointTypes/DPT10.js.map | 1 + lib/DataPointTypes/DPT11.d.ts | 7 + lib/DataPointTypes/DPT11.js | 42 ++ lib/DataPointTypes/DPT11.js.map | 1 + lib/DataPointTypes/DPT14.d.ts | 2 + lib/DataPointTypes/DPT14.js | 63 +++ lib/DataPointTypes/DPT14.js.map | 1 + lib/DataPointTypes/DPT18.d.ts | 6 + lib/DataPointTypes/DPT18.js | 31 ++ lib/DataPointTypes/DPT18.js.map | 1 + lib/DataPointTypes/DPT2.d.ts | 2 + lib/DataPointTypes/DPT2.js | 41 ++ lib/DataPointTypes/DPT2.js.map | 1 + lib/DataPointTypes/DPT3.d.ts | 7 + lib/DataPointTypes/DPT3.js | 34 ++ lib/DataPointTypes/DPT3.js.map | 1 + lib/DataPointTypes/DPT5.d.ts | 2 + lib/DataPointTypes/DPT5.js | 38 ++ lib/DataPointTypes/DPT5.js.map | 1 + lib/DataPointTypes/DPT9.d.ts | 2 + lib/DataPointTypes/DPT9.js | 99 +++++ lib/DataPointTypes/DPT9.js.map | 1 + lib/DataPointTypes/DPTAlarm.d.ts | 19 + lib/DataPointTypes/DPTAlarm.js | 8 + lib/DataPointTypes/DPTAlarm.js.map | 1 + lib/DataPointTypes/DPTAngle.d.ts | 19 + lib/DataPointTypes/DPTAngle.js | 8 + lib/DataPointTypes/DPTAngle.js.map | 1 + lib/DataPointTypes/DPTBinary.d.ts | 19 + lib/DataPointTypes/DPTBinary.js | 8 + lib/DataPointTypes/DPTBinary.js.map | 1 + lib/DataPointTypes/DPTDate.d.ts | 19 + lib/DataPointTypes/DPTDate.js | 8 + lib/DataPointTypes/DPTDate.js.map | 1 + lib/DataPointTypes/DPTDimmingcontrol.d.ts | 19 + lib/DataPointTypes/DPTDimmingcontrol.js | 8 + lib/DataPointTypes/DPTDimmingcontrol.js.map | 1 + lib/DataPointTypes/DPTEnable.d.ts | 19 + lib/DataPointTypes/DPTEnable.js | 8 + lib/DataPointTypes/DPTEnable.js.map | 1 + lib/DataPointTypes/DPTLux.d.ts | 19 + lib/DataPointTypes/DPTLux.js | 8 + lib/DataPointTypes/DPTLux.js.map | 1 + lib/DataPointTypes/DPTPercentage.d.ts | 19 + lib/DataPointTypes/DPTPercentage.js | 8 + lib/DataPointTypes/DPTPercentage.js.map | 1 + lib/DataPointTypes/DPTPercentagescaling.d.ts | 19 + lib/DataPointTypes/DPTPercentagescaling.js | 8 + .../DPTPercentagescaling.js.map | 1 + lib/DataPointTypes/DPTScene.d.ts | 19 + lib/DataPointTypes/DPTScene.js | 8 + lib/DataPointTypes/DPTScene.js.map | 1 + lib/DataPointTypes/DPTScenecontrol.d.ts | 19 + lib/DataPointTypes/DPTScenecontrol.js | 8 + lib/DataPointTypes/DPTScenecontrol.js.map | 1 + lib/DataPointTypes/DPTSpeed.d.ts | 19 + lib/DataPointTypes/DPTSpeed.js | 8 + lib/DataPointTypes/DPTSpeed.js.map | 1 + lib/DataPointTypes/DPTStartstop.d.ts | 19 + lib/DataPointTypes/DPTStartstop.js | 8 + lib/DataPointTypes/DPTStartstop.js.map | 1 + lib/DataPointTypes/DPTStep.d.ts | 19 + lib/DataPointTypes/DPTStep.js | 8 + lib/DataPointTypes/DPTStep.js.map | 1 + lib/DataPointTypes/DPTSwitch.d.ts | 19 + lib/DataPointTypes/DPTSwitch.js | 8 + lib/DataPointTypes/DPTSwitch.js.map | 1 + lib/DataPointTypes/DPTTemperature.d.ts | 19 + lib/DataPointTypes/DPTTemperature.js | 8 + lib/DataPointTypes/DPTTemperature.js.map | 1 + lib/DataPointTypes/DPTTime.d.ts | 19 + lib/DataPointTypes/DPTTime.js | 8 + lib/DataPointTypes/DPTTime.js.map | 1 + lib/DataPointTypes/DPTTrigger.d.ts | 19 + lib/DataPointTypes/DPTTrigger.js | 8 + lib/DataPointTypes/DPTTrigger.js.map | 1 + lib/DataPointTypes/DPTUpdown.d.ts | 19 + lib/DataPointTypes/DPTUpdown.js | 8 + lib/DataPointTypes/DPTUpdown.js.map | 1 + lib/DataPointTypes/DataPointType.d.ts | 18 + lib/DataPointTypes/DataPointType.js | 65 +++ lib/DataPointTypes/DataPointType.js.map | 1 + lib/DataPointTypes/DataPointTypeFactory.d.ts | 4 + lib/DataPointTypes/DataPointTypeFactory.js | 47 +++ .../DataPointTypeFactory.js.map | 1 + lib/DataPointTypes/definitions.d.ts | 19 + lib/DataPointTypes/definitions.js | 3 + lib/DataPointTypes/definitions.js.map | 1 + lib/DataPoints/Alarm.d.ts | 18 + lib/DataPoints/Alarm.js | 9 + lib/DataPoints/Alarm.js.map | 1 + lib/DataPoints/Angle.d.ts | 18 + lib/DataPoints/Angle.js | 9 + lib/DataPoints/Angle.js.map | 1 + lib/DataPoints/Binary.d.ts | 18 + lib/DataPoints/Binary.js | 9 + lib/DataPoints/Binary.js.map | 1 + lib/DataPoints/DataPoint.d.ts | 23 ++ lib/DataPoints/DataPoint.js | 59 +++ lib/DataPoints/DataPoint.js.map | 1 + lib/DataPoints/DataPointFactory.d.ts | 4 + lib/DataPoints/DataPointFactory.js | 71 ++++ lib/DataPoints/DataPointFactory.js.map | 1 + lib/DataPoints/DataPointInterface.d.ts | 13 + lib/DataPoints/DataPointInterface.js | 3 + lib/DataPoints/DataPointInterface.js.map | 1 + lib/DataPoints/Date.d.ts | 18 + lib/DataPoints/Date.js | 9 + lib/DataPoints/Date.js.map | 1 + lib/DataPoints/Dimmingcontrol.d.ts | 18 + lib/DataPoints/Dimmingcontrol.js | 9 + lib/DataPoints/Dimmingcontrol.js.map | 1 + lib/DataPoints/Enable.d.ts | 18 + lib/DataPoints/Enable.js | 9 + lib/DataPoints/Enable.js.map | 1 + lib/DataPoints/Lux.d.ts | 18 + lib/DataPoints/Lux.js | 9 + lib/DataPoints/Lux.js.map | 1 + lib/DataPoints/Percentage.d.ts | 21 + lib/DataPoints/Percentage.js | 32 ++ lib/DataPoints/Percentage.js.map | 1 + lib/DataPoints/Percentagescaling.d.ts | 19 + lib/DataPoints/Percentagescaling.js | 28 ++ lib/DataPoints/Percentagescaling.js.map | 1 + lib/DataPoints/Scene.d.ts | 18 + lib/DataPoints/Scene.js | 9 + lib/DataPoints/Scene.js.map | 1 + lib/DataPoints/Scenecontrol.d.ts | 18 + lib/DataPoints/Scenecontrol.js | 9 + lib/DataPoints/Scenecontrol.js.map | 1 + lib/DataPoints/Speed.d.ts | 18 + lib/DataPoints/Speed.js | 9 + lib/DataPoints/Speed.js.map | 1 + lib/DataPoints/Startstop.d.ts | 18 + lib/DataPoints/Startstop.js | 9 + lib/DataPoints/Startstop.js.map | 1 + lib/DataPoints/Step.d.ts | 18 + lib/DataPoints/Step.js | 9 + lib/DataPoints/Step.js.map | 1 + lib/DataPoints/Switch.d.ts | 20 + lib/DataPoints/Switch.js | 19 + lib/DataPoints/Switch.js.map | 1 + lib/DataPoints/Temperature.d.ts | 18 + lib/DataPoints/Temperature.js | 9 + lib/DataPoints/Temperature.js.map | 1 + lib/DataPoints/Time.d.ts | 18 + lib/DataPoints/Time.js | 9 + lib/DataPoints/Time.js.map | 1 + lib/DataPoints/Trigger.d.ts | 18 + lib/DataPoints/Trigger.js | 9 + lib/DataPoints/Trigger.js.map | 1 + lib/DataPoints/Updown.d.ts | 18 + lib/DataPoints/Updown.js | 9 + lib/DataPoints/Updown.js.map | 1 + lib/DataPoints/index.d.ts | 21 + lib/DataPoints/index.js | 46 +++ lib/DataPoints/index.js.map | 1 + lib/KNXClient.d.ts | 60 +++ lib/KNXClient.js | 380 ++++++++++++++++++ lib/KNXClient.js.map | 1 + lib/KNXTunnelSocket.d.ts | 32 ++ lib/KNXTunnelSocket.js | 157 ++++++++ lib/KNXTunnelSocket.js.map | 1 + lib/index.d.ts | 31 ++ lib/index.js | 66 +++ lib/index.js.map | 1 + lib/protocol/CRD.d.ts | 21 + lib/protocol/CRD.js | 58 +++ lib/protocol/CRD.js.map | 1 + lib/protocol/CRI.d.ts | 16 + lib/protocol/CRI.js | 31 ++ lib/protocol/CRI.js.map | 1 + lib/protocol/CRIFactory.d.ts | 7 + lib/protocol/CRIFactory.js | 21 + lib/protocol/CRIFactory.js.map | 1 + lib/protocol/DIB.d.ts | 3 + lib/protocol/DIB.js | 3 + lib/protocol/DIB.js.map | 1 + lib/protocol/DeviceInfo.d.ts | 44 ++ lib/protocol/DeviceInfo.js | 211 ++++++++++ lib/protocol/DeviceInfo.js.map | 1 + lib/protocol/HPAI.d.ts | 25 ++ lib/protocol/HPAI.js | 92 +++++ lib/protocol/HPAI.js.map | 1 + lib/protocol/IPConfig.d.ts | 32 ++ lib/protocol/IPConfig.js | 86 ++++ lib/protocol/IPConfig.js.map | 1 + lib/protocol/IPCurrentConfig.d.ts | 34 ++ lib/protocol/IPCurrentConfig.js | 99 +++++ lib/protocol/IPCurrentConfig.js.map | 1 + lib/protocol/KNXAddress.d.ts | 24 ++ lib/protocol/KNXAddress.js | 85 ++++ lib/protocol/KNXAddress.js.map | 1 + lib/protocol/KNXAddresses.d.ts | 12 + lib/protocol/KNXAddresses.js | 53 +++ lib/protocol/KNXAddresses.js.map | 1 + lib/protocol/KNXConnectRequest.d.ts | 12 + lib/protocol/KNXConnectRequest.js | 39 ++ lib/protocol/KNXConnectRequest.js.map | 1 + lib/protocol/KNXConnectResponse.d.ts | 14 + lib/protocol/KNXConnectResponse.js | 61 +++ lib/protocol/KNXConnectResponse.js.map | 1 + lib/protocol/KNXConnectionStateRequest.d.ts | 10 + lib/protocol/KNXConnectionStateRequest.js | 36 ++ lib/protocol/KNXConnectionStateRequest.js.map | 1 + lib/protocol/KNXConnectionStateResponse.d.ts | 10 + lib/protocol/KNXConnectionStateResponse.js | 28 ++ .../KNXConnectionStateResponse.js.map | 1 + lib/protocol/KNXConstants.d.ts | 66 +++ lib/protocol/KNXConstants.js | 71 ++++ lib/protocol/KNXConstants.js.map | 1 + lib/protocol/KNXDataBuffer.d.ts | 11 + lib/protocol/KNXDataBuffer.js | 26 ++ lib/protocol/KNXDataBuffer.js.map | 1 + lib/protocol/KNXDescriptionRequest.d.ts | 9 + lib/protocol/KNXDescriptionRequest.js | 24 ++ lib/protocol/KNXDescriptionRequest.js.map | 1 + lib/protocol/KNXDescriptionResponse.d.ts | 11 + lib/protocol/KNXDescriptionResponse.js | 35 ++ lib/protocol/KNXDescriptionResponse.js.map | 1 + lib/protocol/KNXDisconnectRequest.d.ts | 10 + lib/protocol/KNXDisconnectRequest.js | 34 ++ lib/protocol/KNXDisconnectRequest.js.map | 1 + lib/protocol/KNXDisconnectResponse.d.ts | 10 + lib/protocol/KNXDisconnectResponse.js | 28 ++ lib/protocol/KNXDisconnectResponse.js.map | 1 + lib/protocol/KNXHeader.d.ts | 12 + lib/protocol/KNXHeader.js | 54 +++ lib/protocol/KNXHeader.js.map | 1 + lib/protocol/KNXPacket.d.ts | 10 + lib/protocol/KNXPacket.js | 21 + lib/protocol/KNXPacket.js.map | 1 + lib/protocol/KNXProtocol.d.ts | 31 ++ lib/protocol/KNXProtocol.js | 90 +++++ lib/protocol/KNXProtocol.js.map | 1 + lib/protocol/KNXSearchRequest.d.ts | 9 + lib/protocol/KNXSearchRequest.js | 24 ++ lib/protocol/KNXSearchRequest.js.map | 1 + lib/protocol/KNXSearchResponse.d.ts | 13 + lib/protocol/KNXSearchResponse.js | 37 ++ lib/protocol/KNXSearchResponse.js.map | 1 + lib/protocol/KNXTunnelingAck.d.ts | 10 + lib/protocol/KNXTunnelingAck.js | 37 ++ lib/protocol/KNXTunnelingAck.js.map | 1 + lib/protocol/KNXTunnelingRequest.d.ts | 12 + lib/protocol/KNXTunnelingRequest.js | 46 +++ lib/protocol/KNXTunnelingRequest.js.map | 1 + lib/protocol/KNXUtils.d.ts | 2 + lib/protocol/KNXUtils.js | 52 +++ lib/protocol/KNXUtils.js.map | 1 + lib/protocol/ServiceFamilies.d.ts | 24 ++ lib/protocol/ServiceFamilies.js | 63 +++ lib/protocol/ServiceFamilies.js.map | 1 + lib/protocol/TunnelCRI.d.ts | 14 + lib/protocol/TunnelCRI.js | 37 ++ lib/protocol/TunnelCRI.js.map | 1 + lib/protocol/cEMI/AdditionalInfo.d.ts | 10 + lib/protocol/cEMI/AdditionalInfo.js | 34 ++ lib/protocol/cEMI/AdditionalInfo.js.map | 1 + lib/protocol/cEMI/CEMIConstants.d.ts | 24 ++ lib/protocol/cEMI/CEMIConstants.js | 28 ++ lib/protocol/cEMI/CEMIConstants.js.map | 1 + lib/protocol/cEMI/CEMIFactory.d.ts | 12 + lib/protocol/cEMI/CEMIFactory.js | 55 +++ lib/protocol/cEMI/CEMIFactory.js.map | 1 + lib/protocol/cEMI/CEMIMessage.d.ts | 17 + lib/protocol/cEMI/CEMIMessage.js | 31 ++ lib/protocol/cEMI/CEMIMessage.js.map | 1 + lib/protocol/cEMI/ControlField.d.ts | 44 ++ lib/protocol/cEMI/ControlField.js | 112 ++++++ lib/protocol/cEMI/ControlField.js.map | 1 + lib/protocol/cEMI/LDataCon.d.ts | 11 + lib/protocol/cEMI/LDataCon.js | 53 +++ lib/protocol/cEMI/LDataCon.js.map | 1 + lib/protocol/cEMI/LDataInd.d.ts | 11 + lib/protocol/cEMI/LDataInd.js | 53 +++ lib/protocol/cEMI/LDataInd.js.map | 1 + lib/protocol/cEMI/LDataReq.d.ts | 11 + lib/protocol/cEMI/LDataReq.js | 53 +++ lib/protocol/cEMI/LDataReq.js.map | 1 + lib/protocol/cEMI/NPDU.d.ts | 30 ++ lib/protocol/cEMI/NPDU.js | 126 ++++++ lib/protocol/cEMI/NPDU.js.map | 1 + lib/protocol/cEMI/TLVInfo.d.ts | 9 + lib/protocol/cEMI/TLVInfo.js | 27 ++ lib/protocol/cEMI/TLVInfo.js.map | 1 + lib/protocol/index.d.ts | 7 + lib/protocol/index.js | 17 + lib/protocol/index.js.map | 1 + 294 files changed, 5670 insertions(+) create mode 100644 lib/DataPointTypes/DPT1.d.ts create mode 100644 lib/DataPointTypes/DPT1.js create mode 100644 lib/DataPointTypes/DPT1.js.map create mode 100644 lib/DataPointTypes/DPT10.d.ts create mode 100644 lib/DataPointTypes/DPT10.js create mode 100644 lib/DataPointTypes/DPT10.js.map create mode 100644 lib/DataPointTypes/DPT11.d.ts create mode 100644 lib/DataPointTypes/DPT11.js create mode 100644 lib/DataPointTypes/DPT11.js.map create mode 100644 lib/DataPointTypes/DPT14.d.ts create mode 100644 lib/DataPointTypes/DPT14.js create mode 100644 lib/DataPointTypes/DPT14.js.map create mode 100644 lib/DataPointTypes/DPT18.d.ts create mode 100644 lib/DataPointTypes/DPT18.js create mode 100644 lib/DataPointTypes/DPT18.js.map create mode 100644 lib/DataPointTypes/DPT2.d.ts create mode 100644 lib/DataPointTypes/DPT2.js create mode 100644 lib/DataPointTypes/DPT2.js.map create mode 100644 lib/DataPointTypes/DPT3.d.ts create mode 100644 lib/DataPointTypes/DPT3.js create mode 100644 lib/DataPointTypes/DPT3.js.map create mode 100644 lib/DataPointTypes/DPT5.d.ts create mode 100644 lib/DataPointTypes/DPT5.js create mode 100644 lib/DataPointTypes/DPT5.js.map create mode 100644 lib/DataPointTypes/DPT9.d.ts create mode 100644 lib/DataPointTypes/DPT9.js create mode 100644 lib/DataPointTypes/DPT9.js.map create mode 100644 lib/DataPointTypes/DPTAlarm.d.ts create mode 100644 lib/DataPointTypes/DPTAlarm.js create mode 100644 lib/DataPointTypes/DPTAlarm.js.map create mode 100644 lib/DataPointTypes/DPTAngle.d.ts create mode 100644 lib/DataPointTypes/DPTAngle.js create mode 100644 lib/DataPointTypes/DPTAngle.js.map create mode 100644 lib/DataPointTypes/DPTBinary.d.ts create mode 100644 lib/DataPointTypes/DPTBinary.js create mode 100644 lib/DataPointTypes/DPTBinary.js.map create mode 100644 lib/DataPointTypes/DPTDate.d.ts create mode 100644 lib/DataPointTypes/DPTDate.js create mode 100644 lib/DataPointTypes/DPTDate.js.map create mode 100644 lib/DataPointTypes/DPTDimmingcontrol.d.ts create mode 100644 lib/DataPointTypes/DPTDimmingcontrol.js create mode 100644 lib/DataPointTypes/DPTDimmingcontrol.js.map create mode 100644 lib/DataPointTypes/DPTEnable.d.ts create mode 100644 lib/DataPointTypes/DPTEnable.js create mode 100644 lib/DataPointTypes/DPTEnable.js.map create mode 100644 lib/DataPointTypes/DPTLux.d.ts create mode 100644 lib/DataPointTypes/DPTLux.js create mode 100644 lib/DataPointTypes/DPTLux.js.map create mode 100644 lib/DataPointTypes/DPTPercentage.d.ts create mode 100644 lib/DataPointTypes/DPTPercentage.js create mode 100644 lib/DataPointTypes/DPTPercentage.js.map create mode 100644 lib/DataPointTypes/DPTPercentagescaling.d.ts create mode 100644 lib/DataPointTypes/DPTPercentagescaling.js create mode 100644 lib/DataPointTypes/DPTPercentagescaling.js.map create mode 100644 lib/DataPointTypes/DPTScene.d.ts create mode 100644 lib/DataPointTypes/DPTScene.js create mode 100644 lib/DataPointTypes/DPTScene.js.map create mode 100644 lib/DataPointTypes/DPTScenecontrol.d.ts create mode 100644 lib/DataPointTypes/DPTScenecontrol.js create mode 100644 lib/DataPointTypes/DPTScenecontrol.js.map create mode 100644 lib/DataPointTypes/DPTSpeed.d.ts create mode 100644 lib/DataPointTypes/DPTSpeed.js create mode 100644 lib/DataPointTypes/DPTSpeed.js.map create mode 100644 lib/DataPointTypes/DPTStartstop.d.ts create mode 100644 lib/DataPointTypes/DPTStartstop.js create mode 100644 lib/DataPointTypes/DPTStartstop.js.map create mode 100644 lib/DataPointTypes/DPTStep.d.ts create mode 100644 lib/DataPointTypes/DPTStep.js create mode 100644 lib/DataPointTypes/DPTStep.js.map create mode 100644 lib/DataPointTypes/DPTSwitch.d.ts create mode 100644 lib/DataPointTypes/DPTSwitch.js create mode 100644 lib/DataPointTypes/DPTSwitch.js.map create mode 100644 lib/DataPointTypes/DPTTemperature.d.ts create mode 100644 lib/DataPointTypes/DPTTemperature.js create mode 100644 lib/DataPointTypes/DPTTemperature.js.map create mode 100644 lib/DataPointTypes/DPTTime.d.ts create mode 100644 lib/DataPointTypes/DPTTime.js create mode 100644 lib/DataPointTypes/DPTTime.js.map create mode 100644 lib/DataPointTypes/DPTTrigger.d.ts create mode 100644 lib/DataPointTypes/DPTTrigger.js create mode 100644 lib/DataPointTypes/DPTTrigger.js.map create mode 100644 lib/DataPointTypes/DPTUpdown.d.ts create mode 100644 lib/DataPointTypes/DPTUpdown.js create mode 100644 lib/DataPointTypes/DPTUpdown.js.map create mode 100644 lib/DataPointTypes/DataPointType.d.ts create mode 100644 lib/DataPointTypes/DataPointType.js create mode 100644 lib/DataPointTypes/DataPointType.js.map create mode 100644 lib/DataPointTypes/DataPointTypeFactory.d.ts create mode 100644 lib/DataPointTypes/DataPointTypeFactory.js create mode 100644 lib/DataPointTypes/DataPointTypeFactory.js.map create mode 100644 lib/DataPointTypes/definitions.d.ts create mode 100644 lib/DataPointTypes/definitions.js create mode 100644 lib/DataPointTypes/definitions.js.map create mode 100644 lib/DataPoints/Alarm.d.ts create mode 100644 lib/DataPoints/Alarm.js create mode 100644 lib/DataPoints/Alarm.js.map create mode 100644 lib/DataPoints/Angle.d.ts create mode 100644 lib/DataPoints/Angle.js create mode 100644 lib/DataPoints/Angle.js.map create mode 100644 lib/DataPoints/Binary.d.ts create mode 100644 lib/DataPoints/Binary.js create mode 100644 lib/DataPoints/Binary.js.map create mode 100644 lib/DataPoints/DataPoint.d.ts create mode 100644 lib/DataPoints/DataPoint.js create mode 100644 lib/DataPoints/DataPoint.js.map create mode 100644 lib/DataPoints/DataPointFactory.d.ts create mode 100644 lib/DataPoints/DataPointFactory.js create mode 100644 lib/DataPoints/DataPointFactory.js.map create mode 100644 lib/DataPoints/DataPointInterface.d.ts create mode 100644 lib/DataPoints/DataPointInterface.js create mode 100644 lib/DataPoints/DataPointInterface.js.map create mode 100644 lib/DataPoints/Date.d.ts create mode 100644 lib/DataPoints/Date.js create mode 100644 lib/DataPoints/Date.js.map create mode 100644 lib/DataPoints/Dimmingcontrol.d.ts create mode 100644 lib/DataPoints/Dimmingcontrol.js create mode 100644 lib/DataPoints/Dimmingcontrol.js.map create mode 100644 lib/DataPoints/Enable.d.ts create mode 100644 lib/DataPoints/Enable.js create mode 100644 lib/DataPoints/Enable.js.map create mode 100644 lib/DataPoints/Lux.d.ts create mode 100644 lib/DataPoints/Lux.js create mode 100644 lib/DataPoints/Lux.js.map create mode 100644 lib/DataPoints/Percentage.d.ts create mode 100644 lib/DataPoints/Percentage.js create mode 100644 lib/DataPoints/Percentage.js.map create mode 100644 lib/DataPoints/Percentagescaling.d.ts create mode 100644 lib/DataPoints/Percentagescaling.js create mode 100644 lib/DataPoints/Percentagescaling.js.map create mode 100644 lib/DataPoints/Scene.d.ts create mode 100644 lib/DataPoints/Scene.js create mode 100644 lib/DataPoints/Scene.js.map create mode 100644 lib/DataPoints/Scenecontrol.d.ts create mode 100644 lib/DataPoints/Scenecontrol.js create mode 100644 lib/DataPoints/Scenecontrol.js.map create mode 100644 lib/DataPoints/Speed.d.ts create mode 100644 lib/DataPoints/Speed.js create mode 100644 lib/DataPoints/Speed.js.map create mode 100644 lib/DataPoints/Startstop.d.ts create mode 100644 lib/DataPoints/Startstop.js create mode 100644 lib/DataPoints/Startstop.js.map create mode 100644 lib/DataPoints/Step.d.ts create mode 100644 lib/DataPoints/Step.js create mode 100644 lib/DataPoints/Step.js.map create mode 100644 lib/DataPoints/Switch.d.ts create mode 100644 lib/DataPoints/Switch.js create mode 100644 lib/DataPoints/Switch.js.map create mode 100644 lib/DataPoints/Temperature.d.ts create mode 100644 lib/DataPoints/Temperature.js create mode 100644 lib/DataPoints/Temperature.js.map create mode 100644 lib/DataPoints/Time.d.ts create mode 100644 lib/DataPoints/Time.js create mode 100644 lib/DataPoints/Time.js.map create mode 100644 lib/DataPoints/Trigger.d.ts create mode 100644 lib/DataPoints/Trigger.js create mode 100644 lib/DataPoints/Trigger.js.map create mode 100644 lib/DataPoints/Updown.d.ts create mode 100644 lib/DataPoints/Updown.js create mode 100644 lib/DataPoints/Updown.js.map create mode 100644 lib/DataPoints/index.d.ts create mode 100644 lib/DataPoints/index.js create mode 100644 lib/DataPoints/index.js.map create mode 100644 lib/KNXClient.d.ts create mode 100644 lib/KNXClient.js create mode 100644 lib/KNXClient.js.map create mode 100644 lib/KNXTunnelSocket.d.ts create mode 100644 lib/KNXTunnelSocket.js create mode 100644 lib/KNXTunnelSocket.js.map create mode 100644 lib/index.d.ts create mode 100644 lib/index.js create mode 100644 lib/index.js.map create mode 100644 lib/protocol/CRD.d.ts create mode 100644 lib/protocol/CRD.js create mode 100644 lib/protocol/CRD.js.map create mode 100644 lib/protocol/CRI.d.ts create mode 100644 lib/protocol/CRI.js create mode 100644 lib/protocol/CRI.js.map create mode 100644 lib/protocol/CRIFactory.d.ts create mode 100644 lib/protocol/CRIFactory.js create mode 100644 lib/protocol/CRIFactory.js.map create mode 100644 lib/protocol/DIB.d.ts create mode 100644 lib/protocol/DIB.js create mode 100644 lib/protocol/DIB.js.map create mode 100644 lib/protocol/DeviceInfo.d.ts create mode 100644 lib/protocol/DeviceInfo.js create mode 100644 lib/protocol/DeviceInfo.js.map create mode 100644 lib/protocol/HPAI.d.ts create mode 100644 lib/protocol/HPAI.js create mode 100644 lib/protocol/HPAI.js.map create mode 100644 lib/protocol/IPConfig.d.ts create mode 100644 lib/protocol/IPConfig.js create mode 100644 lib/protocol/IPConfig.js.map create mode 100644 lib/protocol/IPCurrentConfig.d.ts create mode 100644 lib/protocol/IPCurrentConfig.js create mode 100644 lib/protocol/IPCurrentConfig.js.map create mode 100644 lib/protocol/KNXAddress.d.ts create mode 100644 lib/protocol/KNXAddress.js create mode 100644 lib/protocol/KNXAddress.js.map create mode 100644 lib/protocol/KNXAddresses.d.ts create mode 100644 lib/protocol/KNXAddresses.js create mode 100644 lib/protocol/KNXAddresses.js.map create mode 100644 lib/protocol/KNXConnectRequest.d.ts create mode 100644 lib/protocol/KNXConnectRequest.js create mode 100644 lib/protocol/KNXConnectRequest.js.map create mode 100644 lib/protocol/KNXConnectResponse.d.ts create mode 100644 lib/protocol/KNXConnectResponse.js create mode 100644 lib/protocol/KNXConnectResponse.js.map create mode 100644 lib/protocol/KNXConnectionStateRequest.d.ts create mode 100644 lib/protocol/KNXConnectionStateRequest.js create mode 100644 lib/protocol/KNXConnectionStateRequest.js.map create mode 100644 lib/protocol/KNXConnectionStateResponse.d.ts create mode 100644 lib/protocol/KNXConnectionStateResponse.js create mode 100644 lib/protocol/KNXConnectionStateResponse.js.map create mode 100644 lib/protocol/KNXConstants.d.ts create mode 100644 lib/protocol/KNXConstants.js create mode 100644 lib/protocol/KNXConstants.js.map create mode 100644 lib/protocol/KNXDataBuffer.d.ts create mode 100644 lib/protocol/KNXDataBuffer.js create mode 100644 lib/protocol/KNXDataBuffer.js.map create mode 100644 lib/protocol/KNXDescriptionRequest.d.ts create mode 100644 lib/protocol/KNXDescriptionRequest.js create mode 100644 lib/protocol/KNXDescriptionRequest.js.map create mode 100644 lib/protocol/KNXDescriptionResponse.d.ts create mode 100644 lib/protocol/KNXDescriptionResponse.js create mode 100644 lib/protocol/KNXDescriptionResponse.js.map create mode 100644 lib/protocol/KNXDisconnectRequest.d.ts create mode 100644 lib/protocol/KNXDisconnectRequest.js create mode 100644 lib/protocol/KNXDisconnectRequest.js.map create mode 100644 lib/protocol/KNXDisconnectResponse.d.ts create mode 100644 lib/protocol/KNXDisconnectResponse.js create mode 100644 lib/protocol/KNXDisconnectResponse.js.map create mode 100644 lib/protocol/KNXHeader.d.ts create mode 100644 lib/protocol/KNXHeader.js create mode 100644 lib/protocol/KNXHeader.js.map create mode 100644 lib/protocol/KNXPacket.d.ts create mode 100644 lib/protocol/KNXPacket.js create mode 100644 lib/protocol/KNXPacket.js.map create mode 100644 lib/protocol/KNXProtocol.d.ts create mode 100644 lib/protocol/KNXProtocol.js create mode 100644 lib/protocol/KNXProtocol.js.map create mode 100644 lib/protocol/KNXSearchRequest.d.ts create mode 100644 lib/protocol/KNXSearchRequest.js create mode 100644 lib/protocol/KNXSearchRequest.js.map create mode 100644 lib/protocol/KNXSearchResponse.d.ts create mode 100644 lib/protocol/KNXSearchResponse.js create mode 100644 lib/protocol/KNXSearchResponse.js.map create mode 100644 lib/protocol/KNXTunnelingAck.d.ts create mode 100644 lib/protocol/KNXTunnelingAck.js create mode 100644 lib/protocol/KNXTunnelingAck.js.map create mode 100644 lib/protocol/KNXTunnelingRequest.d.ts create mode 100644 lib/protocol/KNXTunnelingRequest.js create mode 100644 lib/protocol/KNXTunnelingRequest.js.map create mode 100644 lib/protocol/KNXUtils.d.ts create mode 100644 lib/protocol/KNXUtils.js create mode 100644 lib/protocol/KNXUtils.js.map create mode 100644 lib/protocol/ServiceFamilies.d.ts create mode 100644 lib/protocol/ServiceFamilies.js create mode 100644 lib/protocol/ServiceFamilies.js.map create mode 100644 lib/protocol/TunnelCRI.d.ts create mode 100644 lib/protocol/TunnelCRI.js create mode 100644 lib/protocol/TunnelCRI.js.map create mode 100644 lib/protocol/cEMI/AdditionalInfo.d.ts create mode 100644 lib/protocol/cEMI/AdditionalInfo.js create mode 100644 lib/protocol/cEMI/AdditionalInfo.js.map create mode 100644 lib/protocol/cEMI/CEMIConstants.d.ts create mode 100644 lib/protocol/cEMI/CEMIConstants.js create mode 100644 lib/protocol/cEMI/CEMIConstants.js.map create mode 100644 lib/protocol/cEMI/CEMIFactory.d.ts create mode 100644 lib/protocol/cEMI/CEMIFactory.js create mode 100644 lib/protocol/cEMI/CEMIFactory.js.map create mode 100644 lib/protocol/cEMI/CEMIMessage.d.ts create mode 100644 lib/protocol/cEMI/CEMIMessage.js create mode 100644 lib/protocol/cEMI/CEMIMessage.js.map create mode 100644 lib/protocol/cEMI/ControlField.d.ts create mode 100644 lib/protocol/cEMI/ControlField.js create mode 100644 lib/protocol/cEMI/ControlField.js.map create mode 100644 lib/protocol/cEMI/LDataCon.d.ts create mode 100644 lib/protocol/cEMI/LDataCon.js create mode 100644 lib/protocol/cEMI/LDataCon.js.map create mode 100644 lib/protocol/cEMI/LDataInd.d.ts create mode 100644 lib/protocol/cEMI/LDataInd.js create mode 100644 lib/protocol/cEMI/LDataInd.js.map create mode 100644 lib/protocol/cEMI/LDataReq.d.ts create mode 100644 lib/protocol/cEMI/LDataReq.js create mode 100644 lib/protocol/cEMI/LDataReq.js.map create mode 100644 lib/protocol/cEMI/NPDU.d.ts create mode 100644 lib/protocol/cEMI/NPDU.js create mode 100644 lib/protocol/cEMI/NPDU.js.map create mode 100644 lib/protocol/cEMI/TLVInfo.d.ts create mode 100644 lib/protocol/cEMI/TLVInfo.js create mode 100644 lib/protocol/cEMI/TLVInfo.js.map create mode 100644 lib/protocol/index.d.ts create mode 100644 lib/protocol/index.js create mode 100644 lib/protocol/index.js.map diff --git a/lib/DataPointTypes/DPT1.d.ts b/lib/DataPointTypes/DPT1.d.ts new file mode 100644 index 0000000..af5cf69 --- /dev/null +++ b/lib/DataPointTypes/DPT1.d.ts @@ -0,0 +1,2 @@ +import { DPT } from './definitions'; +export declare const DPT1: DPT; diff --git a/lib/DataPointTypes/DPT1.js b/lib/DataPointTypes/DPT1.js new file mode 100644 index 0000000..f38471c --- /dev/null +++ b/lib/DataPointTypes/DPT1.js @@ -0,0 +1,73 @@ +'use strict'; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.DPT1 = void 0; +exports.DPT1 = { + id: '1', + subtypes: { + ids: { + '001': 'switch', + '002': 'boolean', + '003': 'enable', + '004': 'ramp', + '005': 'alarm', + '006': 'binary', + '007': 'step', + '008': 'updown', + '009': 'openclose', + '010': 'startstop', + '011': 'state', + '012': 'invert', + '013': 'dimsend', + '014': 'input', + '015': 'reset', + '016': 'acknowledge', + '017': 'trigger', + '018': 'occupied', + '019': 'opendoor', + '021': 'andor', + '022': 'scene', + '023': 'shutter' + }, + 'switch': '001', + 'boolean': '002', + 'enable': '003', + 'ramp': '004', + 'alarm': '005', + 'binary': '006', + 'step': '007', + 'updown': '008', + 'openclose': '009', + 'startstop': '010', + 'state': '011', + 'invert': '012', + 'dimsend': '013', + 'input': '014', + 'reset': '015', + 'acknowledge': '016', + 'trigger': '017', + 'occupied': '018', + 'opendoor': '019', + 'andor': '021', + 'scene': '022', + 'shutter': '023' + }, + decoder: (buffer) => { + if (buffer.length !== 1) { + throw new Error(`Invalid buffer length ${buffer.length}/${buffer} for DPT1. Expected 1.`); + } + const val = buffer.readUInt8(0); + if (val !== 0 && val !== 1) { + throw new Error(`Invalid binary value ${val} for DPT1. Expected 1 or 0`); + } + return val; + }, + encoder: (value) => { + if (value !== 0 && value !== 1) { + throw new Error(`Invalid value ${value} for a DPT1. Should be 0 or 1.`); + } + const buf = Buffer.alloc(1); + buf.writeUInt8(value, 0); + return buf; + } +}; +//# sourceMappingURL=DPT1.js.map \ No newline at end of file diff --git a/lib/DataPointTypes/DPT1.js.map b/lib/DataPointTypes/DPT1.js.map new file mode 100644 index 0000000..24a3c62 --- /dev/null +++ b/lib/DataPointTypes/DPT1.js.map @@ -0,0 +1 @@ +{"version":3,"file":"DPT1.js","sourceRoot":"","sources":["../../src/DataPointTypes/DPT1.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AA6BA,QAAA,IAAI,GAAQ;IACrB,EAAE,EAAE,GAAG;IACP,QAAQ,EAAE;QACN,GAAG,EAAE;YACD,KAAK,EAAE,QAAQ;YACf,KAAK,EAAE,SAAS;YAChB,KAAK,EAAE,QAAQ;YACf,KAAK,EAAE,MAAM;YACb,KAAK,EAAE,OAAO;YACd,KAAK,EAAE,QAAQ;YACf,KAAK,EAAE,MAAM;YACb,KAAK,EAAE,QAAQ;YACf,KAAK,EAAE,WAAW;YAClB,KAAK,EAAE,WAAW;YAClB,KAAK,EAAE,OAAO;YACd,KAAK,EAAE,QAAQ;YACf,KAAK,EAAE,SAAS;YAChB,KAAK,EAAE,OAAO;YACd,KAAK,EAAE,OAAO;YACd,KAAK,EAAE,aAAa;YACpB,KAAK,EAAE,SAAS;YAChB,KAAK,EAAE,UAAU;YACjB,KAAK,EAAE,UAAU;YACjB,KAAK,EAAE,OAAO;YACd,KAAK,EAAE,OAAO;YACd,KAAK,EAAE,SAAS;SACnB;QACD,QAAQ,EAAE,KAAK;QACf,SAAS,EAAE,KAAK;QAChB,QAAQ,EAAE,KAAK;QACf,MAAM,EAAE,KAAK;QACb,OAAO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lib/DataPointTypes/DPT10.d.ts new file mode 100644 index 0000000..be0c9a5 --- /dev/null +++ b/lib/DataPointTypes/DPT10.d.ts @@ -0,0 +1,8 @@ +import { DPT } from './definitions'; +export interface DPT10Value { + day: number; + hours: number; + minutes: number; + seconds: number; +} +export declare const DPT10: DPT; diff --git a/lib/DataPointTypes/DPT10.js b/lib/DataPointTypes/DPT10.js new file mode 100644 index 0000000..b9a8ef2 --- /dev/null +++ b/lib/DataPointTypes/DPT10.js @@ -0,0 +1,32 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.DPT10 = void 0; +exports.DPT10 = { + id: '10', + subtypes: { + ids: { + '001': 'time' + }, + 'time': '001' + }, + decoder: (buffer) => { + if (buffer.length !== 3) { + throw new Error(`Invalid buffer length ${buffer.length} for DPT10. Expected 3.`); + } + const val = buffer.readUInt8(0); + const day = (val >> 5) & 0x07; + const hours = val & 0x1F; + const minutes = buffer.readUInt8(1) & 0x3F; + const seconds = buffer.readUInt8(2) & 0x3F; + return { day, hours, minutes, seconds }; + }, + encoder: (value) => { + if (value == null || value.day == null || value.hours == null || value.minutes == null || value.seconds == null) { + throw new Error(`Invalid value ${value} for DPT10. Should be object with keys day, hours, minutes and seconds`); + } + const buf = Buffer.alloc(3); + buf.writeUInt8((value.hours & 0x1F) | (value.day << 5), 0); + return buf; + } +}; +//# sourceMappingURL=DPT10.js.map \ No newline at end of file diff --git a/lib/DataPointTypes/DPT10.js.map b/lib/DataPointTypes/DPT10.js.map new file mode 100644 index 0000000..9cbe627 --- /dev/null +++ b/lib/DataPointTypes/DPT10.js.map @@ -0,0 +1 @@ +{"version":3,"file":"DPT10.js","sourceRoot":"","sources":["../../src/DataPointTypes/DPT10.ts"],"names":[],"mappings":";;;AASa,QAAA,KAAK,GAAQ;IACtB,EAAE,EAAE,IAAI;IACR,QAAQ,EAAE;QACN,GAAG,EAAE;YACD,KAAK,EAAE,MAAM;SAChB;QACD,MAAM,EAAE,KAAK;KAChB;IACD,OA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000000..8b5458e --- /dev/null +++ b/lib/DataPointTypes/DPT11.d.ts @@ -0,0 +1,7 @@ +import { DPT } from './definitions'; +export interface DPT11Value { + year: number; + month: number; + day: number; +} +export declare const DPT11: DPT; diff --git a/lib/DataPointTypes/DPT11.js b/lib/DataPointTypes/DPT11.js new file mode 100644 index 0000000..01875e3 --- /dev/null +++ b/lib/DataPointTypes/DPT11.js @@ -0,0 +1,42 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.DPT11 = void 0; +exports.DPT11 = { + id: '11', + subtypes: { + ids: { + '001': 'date' + }, + 'date': '001' + }, + decoder: (buffer) => { + if (buffer.length !== 3) { + throw new Error(`Invalid buffer length ${buffer.length} for DPT11. Expected 3.`); + } + const day = buffer.readUInt8(0) & 0x1F; + const month = buffer.readUInt8(1) & 0x0F; + const year = 2000 + (buffer.readUInt8(2) & 0x7F); + if (day < 1 || day > 31) { + throw new Error(`Invalid day ${day}`); + } + if (month < 1 || month > 12) { + throw new Error(`Invalid month ${month}`); + } + if (year > 2089) { + throw new Error(`Invalid year ${year}`); + } + return { year, month, day }; + }, + encoder: (value) => { + if (!(value instanceof Date)) { + throw new Error(`Unexpected Date format - ${value}`); + } + const buf = Buffer.alloc(3); + buf.writeUInt8(value.getDay(), 0); + buf.writeUInt8(value.getMonth() + 1, 1); + const year = value.getFullYear(); + buf.writeUInt8(year - (year > 2000 ? 2000 : 1900), 2); + return buf; + } +}; +//# sourceMappingURL=DPT11.js.map \ No newline at end of file diff --git a/lib/DataPointTypes/DPT11.js.map b/lib/DataPointTypes/DPT11.js.map new file mode 100644 index 0000000..fe2f01d --- /dev/null +++ b/lib/DataPointTypes/DPT11.js.map @@ -0,0 +1 @@ +{"version":3,"file":"DPT11.js","sourceRoot":"","sources":["../../src/DataPointTypes/DPT11.ts"],"names":[],"mappings":";;;AAGa,QAAA,KAAK,GAAQ;IACtB,EAAE,EAAE,IAAI;IACR,QAAQ,EAAE;QACN,GAAG,EAAE;YACD,KAAK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AAC,UAAU,CAAC,KAAK,CAAC,QAAQ,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;QACxC,MAAM,IAAI,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC;QACjC,GAAG,CAAC,UAAU,CAAC,IAAI,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;QACtD,OAAO,GAAG,CAAC;IACf,CAAC;CACJ,CAAC"} \ No newline at end of file diff --git a/lib/DataPointTypes/DPT14.d.ts b/lib/DataPointTypes/DPT14.d.ts new file mode 100644 index 0000000..ae57cfc --- /dev/null +++ b/lib/DataPointTypes/DPT14.d.ts @@ -0,0 +1,2 @@ +import { DPT } from './definitions'; +export declare const DPT14: DPT; diff --git a/lib/DataPointTypes/DPT14.js b/lib/DataPointTypes/DPT14.js new file mode 100644 index 0000000..8002f27 --- /dev/null +++ b/lib/DataPointTypes/DPT14.js @@ -0,0 +1,63 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.DPT14 = void 0; +exports.DPT14 = { + id: '14', + subtypes: { + ids: { + '007': 'angle', + '019': 'current', + '027': 'potential', + '028': 'potentialdifference', + '031': 'energy', + '032': 'force', + '033': 'frequency', + '037': 'heat', + '038': 'impedance', + '039': 'length', + '051': 'mass', + '056': 'power', + '065': 'speed', + '066': 'stress', + '067': 'tension', + '068': 'temperature', + '069': 'absolutetemperature', + '070': 'ktemperature', + '078': 'weight', + '079': 'work' + }, + 'angle': '007', + 'current': '019', + 'potential': '027', + 'potentialdifference': '028', + 'energy': '031', + 'force': '032', + 'frequency': '033', + 'heat': '037', + 'impedance': '038', + 'length': '039', + 'mass': '051', + 'power': '056', + 'speed': '065', + 'stress': '066', + 'tension': '067', + 'temperature': '068', + 'absolutetemperature': '069', + 'ktemperature': '070', + 'weight': '078', + 'work': '079' + }, + encoder: (value) => { + const buf = Buffer.alloc(4); + buf.writeFloatBE(value, 0); + return buf; + }, + decoder: (buffer) => { + if (buffer.length !== 4) { + throw new Error(`Invalid buffer length ${buffer.length} for DPT14. Expected 4.`); + } + const val = buffer.readFloatBE(0); + return val; + } +}; +//# sourceMappingURL=DPT14.js.map \ No newline at end of file diff --git a/lib/DataPointTypes/DPT14.js.map b/lib/DataPointTypes/DPT14.js.map new file mode 100644 index 0000000..3579b63 --- /dev/null +++ b/lib/DataPointTypes/DPT14.js.map @@ -0,0 +1 @@ +{"version":3,"file":"DPT14.js","sourceRoot":"","sources":["../../src/DataPointTypes/DPT14.ts"],"names":[],"mappings":";;;AA2Ba,QAAA,KAAK,GAAQ;IACtB,EAAE,EAAE,IAAI;IACR,QAAQ,EAAE;QACN,GAAG,EAAE;YACD,KAAK,EAAE,OAAO;YACd,KAAK,EAAE,SAAS;YAChB,KAAK,EAAE,WAAW;YAClB,KAAK,EAAE,qBAAqB;YAC5B,KAAK,EAAE,QAAQ;YACf,KAAK,EAAE,OAAO;YACd,KAAK,EAAE,WAAW;YAClB,KAAK,EAAE,MAAM;YACb,KAAK,EAAE,WAAW;YAClB,KAAK,EAAE,QAAQ;YACf,KAAK,EAAE,MAAM;YACb,KAAK,EAAE,OAAO;YACd,KAAK,EAAE,OAAO;YACd,KAAK,EAAE,QAAQ;YACf,KAAK,EAAE,SAAS;YAChB,KAAK,EAAE,aAAa;YACpB,KAAK,EAAE,qBAAqB;YAC5B,KAAK,EAAE,cAAc;YACrB,KAAK,EAAE,QAAQ;YACf,KAAK,EAAE,MAAM;SAEhB;QACD,OAAO,EAAE,KAAK;QACd,SAAS,EAAE,KAAK;QAChB,WAAW,EAAE,KAAK;QAClB,qBAAqB,EAAE,KAAK;QAC5B,QAAQ,EAAE,KAAK;QACf,OAAO,EAAE,KAAK;QACd,WAAW,EAAE,KAAK;QAClB,MAAM,EAAE,KAAK;QACb,WAAW,EAAE,KAAK;QAClB,QAAQ,EAAE,KAAK;QACf,MAAM,EAAE,KAAK;QACb,OAAO,EAAE,KAAK;QACd,OAAO,EAAE,KAAK;QACd,QAAQ,EAAE,KAAK;QACf,SAAS,EAAE,KAAK;QAChB,aAAa,EAAE,KAAK;QACpB,qBAAqB,EAAE,KAAK;QAC5B,cAAc,EAAE,KAAK;QACrB,QAAQ,EAAE,KAAK;QACf,MAAM,EAAE,KAAK;KAChB;IACD,OAAO,EAAE,CAAC,KAAa,EAAU,EAAE;QAC/B,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAC5B,GAAG,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QAC3B,OAAO,GAAG,CAAC;IACf,CAAC;IACD,OAAO,EAAE,CAAC,MAAc,EAAU,EAAE;QAChC,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE;YACrB,MAAM,IAAI,KAAK,CAAC,yBAAyB,MAAM,CAAC,MAAM,0BAA0B,CAAC,CAAC;SACrF;QACD,MAAM,GAAG,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;QAClC,OAAO,GAAG,CAAC;IACf,CAAC;CACJ,CAAC"} \ No newline at end of file diff --git a/lib/DataPointTypes/DPT18.d.ts b/lib/DataPointTypes/DPT18.d.ts new file mode 100644 index 0000000..c993e73 --- /dev/null +++ b/lib/DataPointTypes/DPT18.d.ts @@ -0,0 +1,6 @@ +import { DPT } from './definitions'; +export interface DPT18Value { + isLearning: number; + sceneNumber: number; +} +export declare const DPT18: DPT; diff --git a/lib/DataPointTypes/DPT18.js b/lib/DataPointTypes/DPT18.js new file mode 100644 index 0000000..035099d --- /dev/null +++ b/lib/DataPointTypes/DPT18.js @@ -0,0 +1,31 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.DPT18 = void 0; +exports.DPT18 = { + id: '18', + subtypes: { + ids: { + '001': 'scenecontrol' + }, + 'scenecontrol': '001' + }, + decoder: (buffer) => { + if (buffer.length !== 1) { + throw new Error(`Invalid buffer length ${buffer.length} for DPT18. Expected 1.`); + } + const val = buffer.readUInt8(0); + return { + isLearning: (val & 0x80) >> 7, + sceneNumber: val & 0x3F + }; + }, + encoder: (value) => { + if (value == null || value.isLearning == null || value.sceneNumber == null) { + throw new Error(`Invalid value ${value} for DPT18. Expected object with keys isLearning and sceneNumber`); + } + const buf = Buffer.alloc(1); + buf.writeUInt8(value.sceneNumber | (value.isLearning << 7), 0); + return buf; + } +}; +//# sourceMappingURL=DPT18.js.map \ No newline at end of file diff --git a/lib/DataPointTypes/DPT18.js.map b/lib/DataPointTypes/DPT18.js.map new file mode 100644 index 0000000..951aadc --- /dev/null +++ b/lib/DataPointTypes/DPT18.js.map @@ -0,0 +1 @@ +{"version":3,"file":"DPT18.js","sourceRoot":"","sources":["../../src/DataPointTypes/DPT18.ts"],"names":[],"mappings":";;;AAOa,QAAA,KAAK,GAAQ;IACtB,EAAE,EAAE,IAAI;IACR,QAAQ,EAAE;QACN,GAAG,EAAE;YACD,KAAK,EAAE,cAAc;SACxB;QACD,cAAc,EAAE,KAAK;KACxB;IACD,OAAO,EAAE,CAAC,MAAc,EAAc,EAAE;QACpC,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE;YACrB,MAAM,IAAI,KAAK,CAAC,yBAAyB,MAAM,CAAC,MAAM,0BAA0B,CAAC,CAAC;SACrF;QACD,MAAM,GAAG,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;QAChC,OAAO;YACH,UAAU,EAAE,CAAC,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC;YAC7B,WAAW,EAAE,GAAG,GAAG,IAAI;SAC1B,CAAC;IACN,CAAC;IACD,OAAO,EAAE,CAAC,KAAiB,EAAU,EAAE;QACnC,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,CAAC,UAAU,IAAI,IAAI,IAAI,KAAK,CAAC,WAAW,IAAI,IAAI,EAAE;YACxE,MAAM,IAAI,KAAK,CAAC,iBAAiB,KAAK,mEAAmE,CAAC,CAAC;SAC9G;QACD,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAC5B,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,WAAW,GAAG,CAAC,KAAK,CAAC,UAAU,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QAC/D,OAAO,GAAG,CAAC;IACf,CAAC;CACJ,CAAC"} \ No newline at end of file diff --git a/lib/DataPointTypes/DPT2.d.ts b/lib/DataPointTypes/DPT2.d.ts new file mode 100644 index 0000000..2c8ea32 --- /dev/null +++ b/lib/DataPointTypes/DPT2.d.ts @@ -0,0 +1,2 @@ +import { DPT } from './definitions'; +export declare const DPT2: DPT; diff --git a/lib/DataPointTypes/DPT2.js b/lib/DataPointTypes/DPT2.js new file mode 100644 index 0000000..3807b09 --- /dev/null +++ b/lib/DataPointTypes/DPT2.js @@ -0,0 +1,41 @@ +'use strict'; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.DPT2 = void 0; +exports.DPT2 = { + id: '2', + subtypes: { + ids: { + '001': 'switchcontrol', + '002': 'booleancontrol', + '003': 'enablecontrol', + '004': 'rampcontrol', + '005': 'alarmcontrol', + '006': 'binarycontrol', + '007': 'stepcontrol', + '008': 'direction1control', + '009': 'direction2control', + '010': 'startcontrol', + '011': 'statecontrol', + '012': 'invertcontrol' + }, + 'switchcontrol': '001', + 'booleancontrol': '002', + 'enablecontrol': '003', + 'rampcontrol': '004', + 'alarmcontrol': '005', + 'binarycontrol': '006', + 'stepcontrol': '007', + 'direction1control': '008', + 'direction2control': '009', + 'startcontrol': '010', + 'statecontrol': '011', + 'invertcontrol': '012' + }, + decoder: (buffer) => { + throw new Error('Not yet implemented'); + }, + encoder: (value) => { + throw new Error('Not yet implemented'); + } +}; +//# sourceMappingURL=DPT2.js.map \ No newline at end of file diff --git a/lib/DataPointTypes/DPT2.js.map b/lib/DataPointTypes/DPT2.js.map new file mode 100644 index 0000000..1e4d456 --- /dev/null +++ b/lib/DataPointTypes/DPT2.js.map @@ -0,0 +1 @@ +{"version":3,"file":"DPT2.js","sourceRoot":"","sources":["../../src/DataPointTypes/DPT2.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAmBA,QAAA,IAAI,GAAQ;IACrB,EAAE,EAAE,GAAG;IACP,QAAQ,EAAE;QACN,GAAG,EAAE;YACD,KAAK,EAAE,eAAe;YACtB,KAAK,EAAE,gBAAgB;YACvB,KAAK,EAAE,eAAe;YACtB,KAAK,EAAE,aAAa;YACpB,KAAK,EAAE,cAAc;YACrB,KAAK,EAAE,eAAe;YACtB,KAAK,EAAE,aAAa;YACpB,KAAK,EAAE,mBAAmB;YAC1B,KAAK,EAAE,mBAAmB;YAC1B,KAAK,EAAE,cAAc;YACrB,KAAK,EAAE,cAAc;YACrB,KAAK,EAAE,eAAe;SACzB;QACD,eAAe,EAAE,KAAK;QACtB,gBAAgB,EAAE,KAAK;QACvB,eAAe,EAAE,KAAK;QACtB,aAAa,EAAE,KAAK;QACpB,cAAc,EAAE,KAAK;QACrB,eAAe,EAAE,KAAK;QACtB,aAAa,EAAE,KAAK;QACpB,mBAAmB,EAAE,KAAK;QAC1B,mBAAmB,EAAE,KAAK;QAC1B,cAAc,EAAE,KAAK;QACrB,cAAc,EAAE,KAAK;QACrB,eAAe,EAAE,KAAK;KACzB;IACD,OAAO,EAAE,CAAC,MAAc,EAAiB,EAAE;QACvC,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;IAC3C,CAAC;IACD,OAAO,EAAE,CAAC,KAAqB,EAAU,EAAE;QACvC,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;IAC3C,CAAC;CACJ,CAAC"} \ No newline at end of file diff --git a/lib/DataPointTypes/DPT3.d.ts b/lib/DataPointTypes/DPT3.d.ts new file mode 100644 index 0000000..4b9688c --- /dev/null +++ b/lib/DataPointTypes/DPT3.d.ts @@ -0,0 +1,7 @@ +import { DPT } from './definitions'; +export interface DPT3Value { + isIncrease: number; + isUP: number; + stepCode: number; +} +export declare const DPT3: DPT; diff --git a/lib/DataPointTypes/DPT3.js b/lib/DataPointTypes/DPT3.js new file mode 100644 index 0000000..0720f4e --- /dev/null +++ b/lib/DataPointTypes/DPT3.js @@ -0,0 +1,34 @@ +'use strict'; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.DPT3 = void 0; +exports.DPT3 = { + id: '3', + subtypes: { + ids: { + '007': 'dimmingcontrol', + '008': 'blindcontrol' + }, + 'dimmingcontrol': '007', + 'blindcontrol': '008' + }, + decoder: (buffer) => { + if (buffer.length !== 1) { + throw new Error(`Invalid buffer length ${buffer.length} for DPT3. Expected 1.`); + } + const val = buffer.readUInt8(0); + return { + isIncrease: (val & 0x08) >> 3, + isUP: (val & 0x08) >> 3, + stepCode: val & 0x07 + }; + }, + encoder: (value) => { + if (value == null || value.stepCode == null || (value.isUP == null && value.isIncrease == null)) { + throw new Error(`Invalid value ${value} for DPT3. Should be object with keys: stepCode and isUP or isIncrease`); + } + const buf = Buffer.alloc(1); + buf.writeUInt8((value.stepCode & 0x07) | (value.isUP == null ? value.isIncrease << 3 : value.isUP << 3), 0); + return buf; + } +}; +//# sourceMappingURL=DPT3.js.map \ No newline at end of file diff --git a/lib/DataPointTypes/DPT3.js.map b/lib/DataPointTypes/DPT3.js.map new file mode 100644 index 0000000..26be079 --- /dev/null +++ b/lib/DataPointTypes/DPT3.js.map @@ -0,0 +1 @@ +{"version":3,"file":"DPT3.js","sourceRoot":"","sources":["../../src/DataPointTypes/DPT3.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAcA,QAAA,IAAI,GAAQ;IACrB,EAAE,EAAE,GAAG;IACP,QAAQ,EAAE;QACN,GAAG,EAAE;YACD,KAAK,EAAE,gBAAgB;YACvB,KAAK,EAAE,cAAc;SACxB;QACD,gBAAgB,EAAE,KAAK;QACvB,cAAc,EAAE,KAAK;KACxB;IACD,OAAO,EAAE,CAAC,MAAc,EAAa,EAAE;QACnC,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE;YACrB,MAAM,IAAI,KAAK,CAAC,yBAAyB,MAAM,CAAC,MAAM,yBAAyB,CAAC,CAAC;SACpF;QACD,MAAM,GAAG,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;QAChC,OAAO;YACH,UAAU,EAAE,CAAC,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC;YAC7B,IAAI,EAAE,CAAC,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC;YACvB,QAAQ,EAAE,GAAG,GAAG,IAAI;SACvB,CAAC;IACN,CAAC;IACD,OAAO,EAAE,CAAC,KAAgB,EAAE,EAAE;QAC1B,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,CAAC,QAAQ,IAAI,IAAI,IAAK,CAAC,KAAK,CAAC,IAAI,IAAI,IAAI,IAAI,KAAK,CAAC,UAAU,IAAI,IAAI,CAAC,EAAE;YAC9F,MAAM,IAAI,KAAK,CAAC,iBAAiB,KAAK,yEAAyE,CAAC,CAAC;SACpH;QACD,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAC5B,GAAG,CAAC,UAAU,CAAC,CAAC,KAAK,CAAC,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,UAAU,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QAC5G,OAAO,GAAG,CAAC;IACf,CAAC;CACJ,CAAC"} \ No newline at end of file diff --git a/lib/DataPointTypes/DPT5.d.ts b/lib/DataPointTypes/DPT5.d.ts new file mode 100644 index 0000000..11a05bf --- /dev/null +++ b/lib/DataPointTypes/DPT5.d.ts @@ -0,0 +1,2 @@ +import { DPT } from './definitions'; +export declare const DPT5: DPT; diff --git a/lib/DataPointTypes/DPT5.js b/lib/DataPointTypes/DPT5.js new file mode 100644 index 0000000..8df925d --- /dev/null +++ b/lib/DataPointTypes/DPT5.js @@ -0,0 +1,38 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.DPT5 = void 0; +exports.DPT5 = { + id: '5', + subtypes: { + ids: { + '001': 'percentage', + '003': 'angle', + '004': 'percentagescaling', + '005': 'ratio', + '006': 'tariff', + '010': 'pulsecounter' + }, + 'percentage': '001', + 'angle': '003', + 'percentagescaling': '004', + 'ratio': '005', + 'tariff': '006', + 'pulsecounter': '010' + }, + decoder: (buffer) => { + if (buffer.length !== 1) { + throw new Error(`Invalid buffer length ${buffer.length} for DPT5. Expected 1.`); + } + const val = buffer.readUInt8(0); + return val; + }, + encoder: (value) => { + if (value < 0 || value > 0xFF) { + throw new Error(`Invalid value ${value} for DPT5.`); + } + const buf = Buffer.alloc(1); + buf.writeUInt8(value, 0); + return buf; + } +}; +//# sourceMappingURL=DPT5.js.map \ No newline at end of file diff --git a/lib/DataPointTypes/DPT5.js.map b/lib/DataPointTypes/DPT5.js.map new file mode 100644 index 0000000..a9b41f0 --- /dev/null +++ b/lib/DataPointTypes/DPT5.js.map @@ -0,0 +1 @@ +{"version":3,"file":"DPT5.js","sourceRoot":"","sources":["../../src/DataPointTypes/DPT5.ts"],"names":[],"mappings":";;;AAWa,QAAA,IAAI,GAAQ;IACrB,EAAE,EAAE,GAAG;IACP,QAAQ,EAAE;QACN,GAAG,EAAE;YACD,KAAK,EAAE,YAAY;YACnB,KAAK,EAAE,OAAO;YACd,KAAK,EAAE,mBAAmB;YAC1B,KAAK,EAAE,OAAO;YACd,KAAK,EAAE,QAAQ;YACf,KAAK,EAAE,cAAc;SACxB;QACD,YAAY,EAAE,KAAK;QACnB,OAAO,EAAE,KAAK;QACd,mBAAmB,EAAE,KAAK;QAC1B,OAAO,EAAE,KAAK;QACd,QAAQ,EAAE,KAAK;QACf,cAAc,EAAE,KAAK;KACxB;IACD,OAAO,EAAE,CAAC,MAAc,EAAU,EAAE;QAChC,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE;YACrB,MAAM,IAAI,KAAK,CAAC,yBAAyB,MAAM,CAAC,MAAM,yBAAyB,CAAC,CAAC;SACpF;QACD,MAAM,GAAG,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;QAChC,OAAO,GAAG,CAAC;IACf,CAAC;IACD,OAAO,EAAE,CAAC,KAAa,EAAU,EAAE;QAC/B,IAAI,KAAK,GAAG,CAAC,IAAI,KAAK,GAAG,IAAI,EAAE;YAC3B,MAAM,IAAI,KAAK,CAAC,iBAAiB,KAAK,YAAY,CAAC,CAAC;SACvD;QACD,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAC5B,GAAG,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QACzB,OAAO,GAAG,CAAC;IACf,CAAC;CACJ,CAAC"} \ No newline at end of file diff --git a/lib/DataPointTypes/DPT9.d.ts b/lib/DataPointTypes/DPT9.d.ts new file mode 100644 index 0000000..4722b4e --- /dev/null +++ b/lib/DataPointTypes/DPT9.d.ts @@ -0,0 +1,2 @@ +import { DPT } from './definitions'; +export declare const DPT9: DPT; diff --git a/lib/DataPointTypes/DPT9.js b/lib/DataPointTypes/DPT9.js new file mode 100644 index 0000000..c98975b --- /dev/null +++ b/lib/DataPointTypes/DPT9.js @@ -0,0 +1,99 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.DPT9 = void 0; +function ldexp(mantissa, exponent) { + return exponent > 1023 + ? mantissa * Math.pow(2, 1023) * Math.pow(2, exponent - 1023) + : exponent < -1074 + ? mantissa * Math.pow(2, -1074) * Math.pow(2, exponent + 1074) + : mantissa * Math.pow(2, exponent); +} +function frexp(value) { + if (value === 0) { + return [value, 0]; + } + const data = new DataView(new ArrayBuffer(8)); + data.setFloat64(0, value); + let bits = (data.getUint32(0) >>> 20) & 0x7FF; + if (bits === 0) { + data.setFloat64(0, value * Math.pow(2, 64)); + bits = ((data.getUint32(0) >>> 20) & 0x7FF) - 64; + } + const exponent = bits - 1022, mantissa = ldexp(value, -exponent); + return [mantissa, exponent]; +} +exports.DPT9 = { + id: '9', + subtypes: { + ids: { + '001': 'temperature', + '002': 'temperaturedifference', + '003': 'kelvin', + '004': 'lux', + '005': 'speed', + '006': 'pressure', + '007': 'humidity', + '008': 'airquality', + '010': 'time1', + '011': 'time2', + '020': 'voltage', + '021': 'current', + '022': 'powerdensity', + '023': 'kelvinpercent', + '024': 'power', + '025': 'volumeflow', + '026': 'rainamount', + '027': 'ftemperature', + '028': 'windspeed' + }, + 'temperature': '001', + 'temperaturedifference': '002', + 'kelvin': '003', + 'lux': '004', + 'speed': '005', + 'pressure': '006', + 'humidity': '007', + 'airquality': '008', + 'time1': '010', + 'time2': '011', + 'voltage': '020', + 'current': '021', + 'powerdensity': '022', + 'kelvinpercent': '023', + 'power': '024', + 'volumeflow': '025', + 'rainamount': '026', + 'ftemperature': '027', + 'windspeed': '028' + }, + decoder: (buffer) => { + if (buffer.length !== 2) { + throw new Error(`Invalid buffer length ${buffer.length} for DPT9. Expected 2.`); + } + const val = buffer.readUInt8(0); + const sign = val >> 7; + const exp = (val & 0b01111000) >> 3; + const mant = ((val & 0x07) << 8) + buffer.readUInt8(1); + const signedMant = sign === 1 ? ~(mant ^ 2047) : mant; + return ldexp((0.01 * signedMant), exp); + }, + encoder: (value) => { + const buf = Buffer.alloc(2); + let [mant, exp] = frexp(value); + const sign = mant < 0 ? 1 : 0; + let max_mantissa = 0; + let e; + for (e = exp; e >= -15; e--) { + max_mantissa = ldexp(100 * mant, e); + if (max_mantissa > -2048 && max_mantissa < 2047) { + break; + } + } + mant = (mant < 0) ? ~(max_mantissa ^ 2047) : max_mantissa; + exp = exp - e; + buf.writeUInt8((sign << 7) + (exp << 3) + (mant >> 8), 0); + buf.writeUInt8(mant % 256, 1); + return buf; + } +}; +//# sourceMappingURL=DPT9.js.map \ No newline at end of file diff --git a/lib/DataPointTypes/DPT9.js.map b/lib/DataPointTypes/DPT9.js.map new file mode 100644 index 0000000..52c7597 --- /dev/null +++ b/lib/DataPointTypes/DPT9.js.map @@ -0,0 +1 @@ +{"version":3,"file":"DPT9.js","sourceRoot":"","sources":["../../src/DataPointTypes/DPT9.ts"],"names":[],"mappings":";;;AAGA,SAAS,KAAK,CAAC,QAAgB,EAAE,QAAgB;IAC7C,OAAO,QAAQ,GAAG,IAAI;QAClB,CAAC,CAAC,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAC;QAC7D,CAAC,CAAC,QAAQ,GAAG,CAAC,IAAI;YACd,CAAC,CAAC,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAC;YAC9D,CAAC,CAAC,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC;AAC/C,CAAC;AAED,SAAS,KAAK,CAAC,KAAa;IACxB,IAAI,KAAK,KAAK,CAAC,EAAE;QAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;KAAE;IACvC,MAAM,IAAI,GAAG,IAAI,QAAQ,CAAC,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9C,IAAI,CAAC,UAAU,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;IAC1B,IAAI,IAAI,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,GAAG,KAAK,CAAC;IAC9C,IAAI,IAAI,KAAK,CAAC,EAAE;QACZ,IAAI,CAAC,UAAU,CAAC,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,CA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Y,GAAG,KAAK,CAAC,GAAG,GAAG,IAAI,EAAE,CAAC,CAAC,CAAC;YACpC,IAAI,YAAY,GAAG,CAAC,IAAI,IAAI,YAAY,GAAG,IAAI,EAAE;gBAC7C,MAAM;aACT;SACJ;QACD,IAAI,GAAG,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,CAAE,CAAC,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC;QAC3D,GAAG,GAAG,GAAG,GAAG,CAAC,CAAC;QACd,GAAG,CAAC,UAAU,CAAE,CAAC,IAAI,IAAI,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QAC3D,GAAG,CAAC,UAAU,CAAC,IAAI,GAAG,GAAG,EAAE,CAAC,CAAC,CAAC;QAC9B,OAAO,GAAG,CAAC;IACf,CAAC;CACJ,CAAC"} \ No newline at end of file diff --git a/lib/DataPointTypes/DPTAlarm.d.ts b/lib/DataPointTypes/DPTAlarm.d.ts new file mode 100644 index 0000000..5eab2d4 --- /dev/null +++ b/lib/DataPointTypes/DPTAlarm.d.ts @@ -0,0 +1,19 @@ +/// +declare const _default: { + new (): { + readonly type: string; + readonly subtype: string; + _type: string; + _subtype: string; + _encoder: import("./definitions").Encoder; + _decoder: import("./definitions").Decoder; + toString(): string; + decode(buffer: Buffer): string | number; + encode(value: string | number): Buffer; + }; + readonly TYPES: { + [index: string]: import("./definitions").DPT; + }; + validType(text: string): boolean; +}; +export = _default; diff --git a/lib/DataPointTypes/DPTAlarm.js b/lib/DataPointTypes/DPTAlarm.js new file mode 100644 index 0000000..1cedc7c --- /dev/null +++ b/lib/DataPointTypes/DPTAlarm.js @@ -0,0 +1,8 @@ +'use strict'; +const DataPointType_1 = require("./DataPointType"); +module.exports = class DPTAlarm extends DataPointType_1.DataPointType { + constructor() { + super(DataPointType_1.DataPointType.TYPES.DPT1.id, DataPointType_1.DataPointType.TYPES.DPT1.subtypes.alarm, DataPointType_1.DataPointType.TYPES.DPT1.encoder, DataPointType_1.DataPointType.TYPES.DPT1.decoder); + } +}; +//# sourceMappingURL=DPTAlarm.js.map \ No newline at end of file diff --git a/lib/DataPointTypes/DPTAlarm.js.map b/lib/DataPointTypes/DPTAlarm.js.map new file mode 100644 index 0000000..5058cee --- /dev/null +++ b/lib/DataPointTypes/DPTAlarm.js.map @@ -0,0 +1 @@ +{"version":3,"file":"DPTAlarm.js","sourceRoot":"","sources":["../../src/DataPointTypes/DPTAlarm.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,mDAA8C;AAE9C,iBAAS,MAAM,QAAS,SAAQ,6BAAa;IACzC;QACI,KAAK,CACD,6BAAa,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,EAC3B,6BAAa,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,EACvC,6BAAa,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAChC,6BAAa,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CACnC,CAAC;IACN,CAAC;CACJ,CAAC"} \ No newline at end of file diff --git a/lib/DataPointTypes/DPTAngle.d.ts b/lib/DataPointTypes/DPTAngle.d.ts new file mode 100644 index 0000000..5eab2d4 --- /dev/null +++ b/lib/DataPointTypes/DPTAngle.d.ts @@ -0,0 +1,19 @@ +/// +declare const _default: { + new (): { + readonly type: string; + readonly subtype: string; + _type: string; + _subtype: string; + _encoder: import("./definitions").Encoder; + _decoder: import("./definitions").Decoder; + toString(): string; + decode(buffer: Buffer): string | number; + encode(value: string | number): Buffer; + }; + readonly TYPES: { + [index: string]: import("./definitions").DPT; + }; + validType(text: string): boolean; +}; +export = _default; diff --git a/lib/DataPointTypes/DPTAngle.js b/lib/DataPointTypes/DPTAngle.js new file mode 100644 index 0000000..ae7062d --- /dev/null +++ b/lib/DataPointTypes/DPTAngle.js @@ -0,0 +1,8 @@ +'use strict'; +const DataPointType_1 = require("./DataPointType"); +module.exports = class DPTAngle extends DataPointType_1.DataPointType { + constructor() { + super(DataPointType_1.DataPointType.TYPES.DPT14.id, DataPointType_1.DataPointType.TYPES.DPT14.subtypes.angle, DataPointType_1.DataPointType.TYPES.DPT14.encoder, DataPointType_1.DataPointType.TYPES.DPT14.decoder); + } +}; +//# sourceMappingURL=DPTAngle.js.map \ No newline at end of file diff --git a/lib/DataPointTypes/DPTAngle.js.map b/lib/DataPointTypes/DPTAngle.js.map new file mode 100644 index 0000000..7585217 --- /dev/null +++ b/lib/DataPointTypes/DPTAngle.js.map @@ -0,0 +1 @@ +{"version":3,"file":"DPTAngle.js","sourceRoot":"","sources":["../../src/DataPointTypes/DPTAngle.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,mDAA8C;AAE9C,iBAAS,MAAM,QAAS,SAAQ,6BAAa;IACzC;QACI,KAAK,CAAC,6BAAa,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,EAAE,6BAAa,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,EACxE,6BAAa,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,EAAE,6BAAa,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAC9E,CAAC;CACJ,CAAC"} \ No newline at end of file diff --git a/lib/DataPointTypes/DPTBinary.d.ts b/lib/DataPointTypes/DPTBinary.d.ts new file mode 100644 index 0000000..5eab2d4 --- /dev/null +++ b/lib/DataPointTypes/DPTBinary.d.ts @@ -0,0 +1,19 @@ +/// +declare const _default: { + new (): { + readonly type: string; + readonly subtype: string; + _type: string; + _subtype: string; + _encoder: import("./definitions").Encoder; + _decoder: import("./definitions").Decoder; + toString(): string; + decode(buffer: Buffer): string | number; + encode(value: string | number): Buffer; + }; + readonly TYPES: { + [index: string]: import("./definitions").DPT; + }; + validType(text: string): boolean; +}; +export = _default; diff --git a/lib/DataPointTypes/DPTBinary.js b/lib/DataPointTypes/DPTBinary.js new file mode 100644 index 0000000..69e6c32 --- /dev/null +++ b/lib/DataPointTypes/DPTBinary.js @@ -0,0 +1,8 @@ +'use strict'; +const DataPointType_1 = require("./DataPointType"); +module.exports = class DPTBinary extends DataPointType_1.DataPointType { + constructor() { + super(DataPointType_1.DataPointType.TYPES.DPT1.id, DataPointType_1.DataPointType.TYPES.DPT1.subtypes.binary, DataPointType_1.DataPointType.TYPES.DPT1.encoder, DataPointType_1.DataPointType.TYPES.DPT1.decoder); + } +}; +//# sourceMappingURL=DPTBinary.js.map \ No newline at end of file diff --git a/lib/DataPointTypes/DPTBinary.js.map b/lib/DataPointTypes/DPTBinary.js.map new file mode 100644 index 0000000..a1e8928 --- /dev/null +++ b/lib/DataPointTypes/DPTBinary.js.map @@ -0,0 +1 @@ +{"version":3,"file":"DPTBinary.js","sourceRoot":"","sources":["../../src/DataPointTypes/DPTBinary.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,mDAA8C;AAE9C,iBAAS,MAAM,SAAU,SAAQ,6BAAa;IAC1C;QACI,KAAK,CAAC,6BAAa,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,6BAAa,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EACvE,6BAAa,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAChC,6BAAa,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC1C,CAAC;CACJ,CAAC"} \ No newline at end of file diff --git a/lib/DataPointTypes/DPTDate.d.ts b/lib/DataPointTypes/DPTDate.d.ts new file mode 100644 index 0000000..5eab2d4 --- /dev/null +++ b/lib/DataPointTypes/DPTDate.d.ts @@ -0,0 +1,19 @@ +/// +declare const _default: { + new (): { + readonly type: string; + readonly subtype: string; + _type: string; + _subtype: string; + _encoder: import("./definitions").Encoder; + _decoder: import("./definitions").Decoder; + toString(): string; + decode(buffer: Buffer): string | number; + encode(value: string | number): Buffer; + }; + readonly TYPES: { + [index: string]: import("./definitions").DPT; + }; + validType(text: string): boolean; +}; +export = _default; diff --git a/lib/DataPointTypes/DPTDate.js b/lib/DataPointTypes/DPTDate.js new file mode 100644 index 0000000..c8eed78 --- /dev/null +++ b/lib/DataPointTypes/DPTDate.js @@ -0,0 +1,8 @@ +'use strict'; +const DataPointType_1 = require("./DataPointType"); +module.exports = class DPTDate extends DataPointType_1.DataPointType { + constructor() { + super(DataPointType_1.DataPointType.TYPES.DPT11.id, DataPointType_1.DataPointType.TYPES.DPT11.subtypes.date, DataPointType_1.DataPointType.TYPES.DPT11.encoder, DataPointType_1.DataPointType.TYPES.DPT11.decoder); + } +}; +//# sourceMappingURL=DPTDate.js.map \ No newline at end of file diff --git a/lib/DataPointTypes/DPTDate.js.map b/lib/DataPointTypes/DPTDate.js.map new file mode 100644 index 0000000..c2f7572 --- /dev/null +++ b/lib/DataPointTypes/DPTDate.js.map @@ -0,0 +1 @@ +{"version":3,"file":"DPTDate.js","sourceRoot":"","sources":["../../src/DataPointTypes/DPTDate.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,mDAA8C;AAE9C,iBAAS,MAAM,OAAQ,SAAQ,6BAAa;IACxC;QACI,KAAK,CAAC,6BAAa,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,EAAE,6BAAa,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,EACvE,6BAAa,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,EAAE,6BAAa,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAC9E,CAAC;CACJ,CAAC"} \ No newline at end of file diff --git a/lib/DataPointTypes/DPTDimmingcontrol.d.ts b/lib/DataPointTypes/DPTDimmingcontrol.d.ts new file mode 100644 index 0000000..5eab2d4 --- /dev/null +++ b/lib/DataPointTypes/DPTDimmingcontrol.d.ts @@ -0,0 +1,19 @@ +/// +declare const _default: { + new (): { + readonly type: string; + readonly subtype: string; + _type: string; + _subtype: string; + _encoder: import("./definitions").Encoder; + _decoder: import("./definitions").Decoder; + toString(): string; + decode(buffer: Buffer): string | number; + encode(value: string | number): Buffer; + }; + readonly TYPES: { + [index: string]: import("./definitions").DPT; + }; + validType(text: string): boolean; +}; +export = _default; diff --git a/lib/DataPointTypes/DPTDimmingcontrol.js b/lib/DataPointTypes/DPTDimmingcontrol.js new file mode 100644 index 0000000..b72120d --- /dev/null +++ b/lib/DataPointTypes/DPTDimmingcontrol.js @@ -0,0 +1,8 @@ +"use strict"; +const DataPointType_1 = require("./DataPointType"); +module.exports = class DPTDimmingcontrol extends DataPointType_1.DataPointType { + constructor() { + super(DataPointType_1.DataPointType.TYPES.DPT3.id, DataPointType_1.DataPointType.TYPES.DPT3.subtypes.dimmingcontrol, DataPointType_1.DataPointType.TYPES.DPT3.encoder, DataPointType_1.DataPointType.TYPES.DPT3.decoder); + } +}; +//# sourceMappingURL=DPTDimmingcontrol.js.map \ No newline at end of file diff --git a/lib/DataPointTypes/DPTDimmingcontrol.js.map b/lib/DataPointTypes/DPTDimmingcontrol.js.map new file mode 100644 index 0000000..2662e24 --- /dev/null +++ b/lib/DataPointTypes/DPTDimmingcontrol.js.map @@ -0,0 +1 @@ +{"version":3,"file":"DPTDimmingcontrol.js","sourceRoot":"","sources":["../../src/DataPointTypes/DPTDimmingcontrol.ts"],"names":[],"mappings":";AAAA,mDAA8C;AAE9C,iBAAS,MAAM,iBAAkB,SAAQ,6BAAa;IAClD;QACI,KAAK,CAAC,6BAAa,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,6BAAa,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,EAC/E,6BAAa,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,6BAAa,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC5E,CAAC;CACJ,CAAC"} \ No newline at end of file diff --git a/lib/DataPointTypes/DPTEnable.d.ts b/lib/DataPointTypes/DPTEnable.d.ts new file mode 100644 index 0000000..5eab2d4 --- /dev/null +++ b/lib/DataPointTypes/DPTEnable.d.ts @@ -0,0 +1,19 @@ +/// +declare const _default: { + new (): { + readonly type: string; + readonly subtype: string; + _type: string; + _subtype: string; + _encoder: import("./definitions").Encoder; + _decoder: import("./definitions").Decoder; + toString(): string; + decode(buffer: Buffer): string | number; + encode(value: string | number): Buffer; + }; + readonly TYPES: { + [index: string]: import("./definitions").DPT; + }; + validType(text: string): boolean; +}; +export = _default; diff --git a/lib/DataPointTypes/DPTEnable.js b/lib/DataPointTypes/DPTEnable.js new file mode 100644 index 0000000..07ccbc0 --- /dev/null +++ b/lib/DataPointTypes/DPTEnable.js @@ -0,0 +1,8 @@ +'use strict'; +const DataPointType_1 = require("./DataPointType"); +module.exports = class DPTEnable extends DataPointType_1.DataPointType { + constructor() { + super(DataPointType_1.DataPointType.TYPES.DPT1.id, DataPointType_1.DataPointType.TYPES.DPT1.subtypes.enable, DataPointType_1.DataPointType.TYPES.DPT1.encoder, DataPointType_1.DataPointType.TYPES.DPT1.decoder); + } +}; +//# sourceMappingURL=DPTEnable.js.map \ No newline at end of file diff --git a/lib/DataPointTypes/DPTEnable.js.map b/lib/DataPointTypes/DPTEnable.js.map new file mode 100644 index 0000000..9b671ad --- /dev/null +++ b/lib/DataPointTypes/DPTEnable.js.map @@ -0,0 +1 @@ +{"version":3,"file":"DPTEnable.js","sourceRoot":"","sources":["../../src/DataPointTypes/DPTEnable.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,mDAA8C;AAE9C,iBAAS,MAAM,SAAU,SAAQ,6BAAa;IAC1C;QACI,KAAK,CAAC,6BAAa,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,6BAAa,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EACvE,6BAAa,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAChC,6BAAa,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC1C,CAAC;CACJ,CAAC"} \ No newline at end of file diff --git a/lib/DataPointTypes/DPTLux.d.ts b/lib/DataPointTypes/DPTLux.d.ts new file mode 100644 index 0000000..5eab2d4 --- /dev/null +++ b/lib/DataPointTypes/DPTLux.d.ts @@ -0,0 +1,19 @@ +/// +declare const _default: { + new (): { + readonly type: string; + readonly subtype: string; + _type: string; + _subtype: string; + _encoder: import("./definitions").Encoder; + _decoder: import("./definitions").Decoder; + toString(): string; + decode(buffer: Buffer): string | number; + encode(value: string | number): Buffer; + }; + readonly TYPES: { + [index: string]: import("./definitions").DPT; + }; + validType(text: string): boolean; +}; +export = _default; diff --git a/lib/DataPointTypes/DPTLux.js b/lib/DataPointTypes/DPTLux.js new file mode 100644 index 0000000..e196f64 --- /dev/null +++ b/lib/DataPointTypes/DPTLux.js @@ -0,0 +1,8 @@ +'use strict'; +const DataPointType_1 = require("./DataPointType"); +module.exports = class DPTLux extends DataPointType_1.DataPointType { + constructor() { + super(DataPointType_1.DataPointType.TYPES.DPT9.id, DataPointType_1.DataPointType.TYPES.DPT9.subtypes.lux, DataPointType_1.DataPointType.TYPES.DPT9.encoder, DataPointType_1.DataPointType.TYPES.DPT9.decoder); + } +}; +//# sourceMappingURL=DPTLux.js.map \ No newline at end of file diff --git a/lib/DataPointTypes/DPTLux.js.map b/lib/DataPointTypes/DPTLux.js.map new file mode 100644 index 0000000..e40840b --- /dev/null +++ b/lib/DataPointTypes/DPTLux.js.map @@ -0,0 +1 @@ +{"version":3,"file":"DPTLux.js","sourceRoot":"","sources":["../../src/DataPointTypes/DPTLux.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,mDAA8C;AAE9C,iBAAS,MAAM,MAAO,SAAQ,6BAAa;IACvC;QACI,KAAK,CAAC,6BAAa,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,6BAAa,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,EACpE,6BAAa,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,6BAAa,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC5E,CAAC;CACJ,CAAC"} \ No newline at end of file diff --git a/lib/DataPointTypes/DPTPercentage.d.ts b/lib/DataPointTypes/DPTPercentage.d.ts new file mode 100644 index 0000000..5eab2d4 --- /dev/null +++ b/lib/DataPointTypes/DPTPercentage.d.ts @@ -0,0 +1,19 @@ +/// +declare const _default: { + new (): { + readonly type: string; + readonly subtype: string; + _type: string; + _subtype: string; + _encoder: import("./definitions").Encoder; + _decoder: import("./definitions").Decoder; + toString(): string; + decode(buffer: Buffer): string | number; + encode(value: string | number): Buffer; + }; + readonly TYPES: { + [index: string]: import("./definitions").DPT; + }; + validType(text: string): boolean; +}; +export = _default; diff --git a/lib/DataPointTypes/DPTPercentage.js b/lib/DataPointTypes/DPTPercentage.js new file mode 100644 index 0000000..f42d6e6 --- /dev/null +++ b/lib/DataPointTypes/DPTPercentage.js @@ -0,0 +1,8 @@ +'use strict'; +const DataPointType_1 = require("./DataPointType"); +module.exports = class DPTPercentage extends DataPointType_1.DataPointType { + constructor() { + super(DataPointType_1.DataPointType.TYPES.DPT5.id, DataPointType_1.DataPointType.TYPES.DPT5.subtypes.percentage, DataPointType_1.DataPointType.TYPES.DPT5.encoder, (buffer) => DataPointType_1.DataPointType.TYPES.DPT5.decoder(buffer) / 2.55); + } +}; +//# sourceMappingURL=DPTPercentage.js.map \ No newline at end of file diff --git a/lib/DataPointTypes/DPTPercentage.js.map b/lib/DataPointTypes/DPTPercentage.js.map new file mode 100644 index 0000000..20971fc --- /dev/null +++ b/lib/DataPointTypes/DPTPercentage.js.map @@ -0,0 +1 @@ +{"version":3,"file":"DPTPercentage.js","sourceRoot":"","sources":["../../src/DataPointTypes/DPTPercentage.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,mDAA8C;AAE9C,iBAAS,MAAM,aAAc,SAAQ,6BAAa;IAC9C;QACI,KAAK,CAAC,6BAAa,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,6BAAa,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,EAC3E,6BAAa,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,MAAc,EAAU,EAAE,CAAC,6BAAa,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC;IACvH,CAAC;CACJ,CAAC"} \ No newline at end of file diff --git a/lib/DataPointTypes/DPTPercentagescaling.d.ts b/lib/DataPointTypes/DPTPercentagescaling.d.ts new file mode 100644 index 0000000..5eab2d4 --- /dev/null +++ b/lib/DataPointTypes/DPTPercentagescaling.d.ts @@ -0,0 +1,19 @@ +/// +declare const _default: { + new (): { + readonly type: string; + readonly subtype: string; + _type: string; + _subtype: string; + _encoder: import("./definitions").Encoder; + _decoder: import("./definitions").Decoder; + toString(): string; + decode(buffer: Buffer): string | number; + encode(value: string | number): Buffer; + }; + readonly TYPES: { + [index: string]: import("./definitions").DPT; + }; + validType(text: string): boolean; +}; +export = _default; diff --git a/lib/DataPointTypes/DPTPercentagescaling.js b/lib/DataPointTypes/DPTPercentagescaling.js new file mode 100644 index 0000000..569ab07 --- /dev/null +++ b/lib/DataPointTypes/DPTPercentagescaling.js @@ -0,0 +1,8 @@ +'use strict'; +const DataPointType_1 = require("./DataPointType"); +module.exports = class DPTPercentagescaling extends DataPointType_1.DataPointType { + constructor() { + super(DataPointType_1.DataPointType.TYPES.DPT5.id, DataPointType_1.DataPointType.TYPES.DPT5.subtypes.percentagescaling, DataPointType_1.DataPointType.TYPES.DPT5.encoder, DataPointType_1.DataPointType.TYPES.DPT5.decoder); + } +}; +//# sourceMappingURL=DPTPercentagescaling.js.map \ No newline at end of file diff --git a/lib/DataPointTypes/DPTPercentagescaling.js.map b/lib/DataPointTypes/DPTPercentagescaling.js.map new file mode 100644 index 0000000..7fe8129 --- /dev/null +++ b/lib/DataPointTypes/DPTPercentagescaling.js.map @@ -0,0 +1 @@ +{"version":3,"file":"DPTPercentagescaling.js","sourceRoot":"","sources":["../../src/DataPointTypes/DPTPercentagescaling.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,mDAA8C;AAE9C,iBAAS,MAAM,oBAAqB,SAAQ,6BAAa;IACrD;QACI,KAAK,CAAC,6BAAa,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,6BAAa,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,iBAAiB,EAClF,6BAAa,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,6BAAa,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC5E,CAAC;CACJ,CAAC"} \ No newline at end of file diff --git a/lib/DataPointTypes/DPTScene.d.ts b/lib/DataPointTypes/DPTScene.d.ts new file mode 100644 index 0000000..5eab2d4 --- /dev/null +++ b/lib/DataPointTypes/DPTScene.d.ts @@ -0,0 +1,19 @@ +/// +declare const _default: { + new (): { + readonly type: string; + readonly subtype: string; + _type: string; + _subtype: string; + _encoder: import("./definitions").Encoder; + _decoder: import("./definitions").Decoder; + toString(): string; + decode(buffer: Buffer): string | number; + encode(value: string | number): Buffer; + }; + readonly TYPES: { + [index: string]: import("./definitions").DPT; + }; + validType(text: string): boolean; +}; +export = _default; diff --git a/lib/DataPointTypes/DPTScene.js b/lib/DataPointTypes/DPTScene.js new file mode 100644 index 0000000..2e3ae54 --- /dev/null +++ b/lib/DataPointTypes/DPTScene.js @@ -0,0 +1,8 @@ +'use strict'; +const DataPointType_1 = require("./DataPointType"); +module.exports = class DPTScene extends DataPointType_1.DataPointType { + constructor() { + super(DataPointType_1.DataPointType.TYPES.DPT1.id, DataPointType_1.DataPointType.TYPES.DPT1.subtypes.scene, DataPointType_1.DataPointType.TYPES.DPT1.encoder, DataPointType_1.DataPointType.TYPES.DPT1.decoder); + } +}; +//# sourceMappingURL=DPTScene.js.map \ No newline at end of file diff --git a/lib/DataPointTypes/DPTScene.js.map b/lib/DataPointTypes/DPTScene.js.map new file mode 100644 index 0000000..dca672c --- /dev/null +++ b/lib/DataPointTypes/DPTScene.js.map @@ -0,0 +1 @@ +{"version":3,"file":"DPTScene.js","sourceRoot":"","sources":["../../src/DataPointTypes/DPTScene.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,mDAA8C;AAE9C,iBAAS,MAAM,QAAS,SAAQ,6BAAa;IACzC;QACI,KAAK,CAAC,6BAAa,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,6BAAa,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,EACtE,6BAAa,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAChC,6BAAa,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC1C,CAAC;CACJ,CAAC"} \ No newline at end of file diff --git a/lib/DataPointTypes/DPTScenecontrol.d.ts b/lib/DataPointTypes/DPTScenecontrol.d.ts new file mode 100644 index 0000000..5eab2d4 --- /dev/null +++ b/lib/DataPointTypes/DPTScenecontrol.d.ts @@ -0,0 +1,19 @@ +/// +declare const _default: { + new (): { + readonly type: string; + readonly subtype: string; + _type: string; + _subtype: string; + _encoder: import("./definitions").Encoder; + _decoder: import("./definitions").Decoder; + toString(): string; + decode(buffer: Buffer): string | number; + encode(value: string | number): Buffer; + }; + readonly TYPES: { + [index: string]: import("./definitions").DPT; + }; + validType(text: string): boolean; +}; +export = _default; diff --git a/lib/DataPointTypes/DPTScenecontrol.js b/lib/DataPointTypes/DPTScenecontrol.js new file mode 100644 index 0000000..19c8fc3 --- /dev/null +++ b/lib/DataPointTypes/DPTScenecontrol.js @@ -0,0 +1,8 @@ +'use strict'; +const DataPointType_1 = require("./DataPointType"); +module.exports = class DPTScenecontrol extends DataPointType_1.DataPointType { + constructor() { + super(DataPointType_1.DataPointType.TYPES.DPT18.id, DataPointType_1.DataPointType.TYPES.DPT18.subtypes.scenecontrol, DataPointType_1.DataPointType.TYPES.DPT18.encoder, DataPointType_1.DataPointType.TYPES.DPT18.decoder); + } +}; +//# sourceMappingURL=DPTScenecontrol.js.map \ No newline at end of file diff --git a/lib/DataPointTypes/DPTScenecontrol.js.map b/lib/DataPointTypes/DPTScenecontrol.js.map new file mode 100644 index 0000000..636cecc --- /dev/null +++ b/lib/DataPointTypes/DPTScenecontrol.js.map @@ -0,0 +1 @@ +{"version":3,"file":"DPTScenecontrol.js","sourceRoot":"","sources":["../../src/DataPointTypes/DPTScenecontrol.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,mDAA8C;AAE9C,iBAAS,MAAM,eAAgB,SAAQ,6BAAa;IAChD;QACI,KAAK,CAAC,6BAAa,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,EAAE,6BAAa,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,YAAY,EAC/E,6BAAa,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,EAAE,6BAAa,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAC9E,CAAC;CACJ,CAAC"} \ No newline at end of file diff --git a/lib/DataPointTypes/DPTSpeed.d.ts b/lib/DataPointTypes/DPTSpeed.d.ts new file mode 100644 index 0000000..5eab2d4 --- /dev/null +++ b/lib/DataPointTypes/DPTSpeed.d.ts @@ -0,0 +1,19 @@ +/// +declare const _default: { + new (): { + readonly type: string; + readonly subtype: string; + _type: string; + _subtype: string; + _encoder: import("./definitions").Encoder; + _decoder: import("./definitions").Decoder; + toString(): string; + decode(buffer: Buffer): string | number; + encode(value: string | number): Buffer; + }; + readonly TYPES: { + [index: string]: import("./definitions").DPT; + }; + validType(text: string): boolean; +}; +export = _default; diff --git a/lib/DataPointTypes/DPTSpeed.js b/lib/DataPointTypes/DPTSpeed.js new file mode 100644 index 0000000..6788916 --- /dev/null +++ b/lib/DataPointTypes/DPTSpeed.js @@ -0,0 +1,8 @@ +'use strict'; +const DataPointType_1 = require("./DataPointType"); +module.exports = class DPTSpeed extends DataPointType_1.DataPointType { + constructor() { + super(DataPointType_1.DataPointType.TYPES.DPT9.id, DataPointType_1.DataPointType.TYPES.DPT9.subtypes.speed, DataPointType_1.DataPointType.TYPES.DPT9.encoder, DataPointType_1.DataPointType.TYPES.DPT9.decoder); + } +}; +//# sourceMappingURL=DPTSpeed.js.map \ No newline at end of file diff --git a/lib/DataPointTypes/DPTSpeed.js.map b/lib/DataPointTypes/DPTSpeed.js.map new file mode 100644 index 0000000..cda2116 --- /dev/null +++ b/lib/DataPointTypes/DPTSpeed.js.map @@ -0,0 +1 @@ +{"version":3,"file":"DPTSpeed.js","sourceRoot":"","sources":["../../src/DataPointTypes/DPTSpeed.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,mDAA8C;AAE9C,iBAAS,MAAM,QAAS,SAAQ,6BAAa;IACzC;QACI,KAAK,CAAC,6BAAa,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,6BAAa,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,EACtE,6BAAa,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,6BAAa,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC5E,CAAC;CACJ,CAAC"} \ No newline at end of file diff --git a/lib/DataPointTypes/DPTStartstop.d.ts b/lib/DataPointTypes/DPTStartstop.d.ts new file mode 100644 index 0000000..5eab2d4 --- /dev/null +++ b/lib/DataPointTypes/DPTStartstop.d.ts @@ -0,0 +1,19 @@ +/// +declare const _default: { + new (): { + readonly type: string; + readonly subtype: string; + _type: string; + _subtype: string; + _encoder: import("./definitions").Encoder; + _decoder: import("./definitions").Decoder; + toString(): string; + decode(buffer: Buffer): string | number; + encode(value: string | number): Buffer; + }; + readonly TYPES: { + [index: string]: import("./definitions").DPT; + }; + validType(text: string): boolean; +}; +export = _default; diff --git a/lib/DataPointTypes/DPTStartstop.js b/lib/DataPointTypes/DPTStartstop.js new file mode 100644 index 0000000..dc834f4 --- /dev/null +++ b/lib/DataPointTypes/DPTStartstop.js @@ -0,0 +1,8 @@ +'use strict'; +const DataPointType_1 = require("./DataPointType"); +module.exports = class DPTStartstop extends DataPointType_1.DataPointType { + constructor() { + super(DataPointType_1.DataPointType.TYPES.DPT1.id, DataPointType_1.DataPointType.TYPES.DPT1.subtypes.startstop, DataPointType_1.DataPointType.TYPES.DPT1.encoder, DataPointType_1.DataPointType.TYPES.DPT1.decoder); + } +}; +//# sourceMappingURL=DPTStartstop.js.map \ No newline at end of file diff --git a/lib/DataPointTypes/DPTStartstop.js.map b/lib/DataPointTypes/DPTStartstop.js.map new file mode 100644 index 0000000..b9756bb --- /dev/null +++ b/lib/DataPointTypes/DPTStartstop.js.map @@ -0,0 +1 @@ +{"version":3,"file":"DPTStartstop.js","sourceRoot":"","sources":["../../src/DataPointTypes/DPTStartstop.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,mDAA8C;AAE9C,iBAAS,MAAM,YAAa,SAAQ,6BAAa;IAC7C;QACI,KAAK,CAAC,6BAAa,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,6BAAa,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,EAC1E,6BAAa,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,6BAAa,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC5E,CAAC;CACJ,CAAC"} \ No newline at end of file diff --git a/lib/DataPointTypes/DPTStep.d.ts b/lib/DataPointTypes/DPTStep.d.ts new file mode 100644 index 0000000..5eab2d4 --- /dev/null +++ b/lib/DataPointTypes/DPTStep.d.ts @@ -0,0 +1,19 @@ +/// +declare const _default: { + new (): { + readonly type: string; + readonly subtype: string; + _type: string; + _subtype: string; + _encoder: import("./definitions").Encoder; + _decoder: import("./definitions").Decoder; + toString(): string; + decode(buffer: Buffer): string | number; + encode(value: string | number): Buffer; + }; + readonly TYPES: { + [index: string]: import("./definitions").DPT; + }; + validType(text: string): boolean; +}; +export = _default; diff --git a/lib/DataPointTypes/DPTStep.js b/lib/DataPointTypes/DPTStep.js new file mode 100644 index 0000000..0669ee5 --- /dev/null +++ b/lib/DataPointTypes/DPTStep.js @@ -0,0 +1,8 @@ +'use strict'; +const DataPointType_1 = require("./DataPointType"); +module.exports = class DPTStep extends DataPointType_1.DataPointType { + constructor() { + super(DataPointType_1.DataPointType.TYPES.DPT1.id, DataPointType_1.DataPointType.TYPES.DPT1.subtypes.step, DataPointType_1.DataPointType.TYPES.DPT1.encoder, DataPointType_1.DataPointType.TYPES.DPT1.decoder); + } +}; +//# sourceMappingURL=DPTStep.js.map \ No newline at end of file diff --git a/lib/DataPointTypes/DPTStep.js.map b/lib/DataPointTypes/DPTStep.js.map new file mode 100644 index 0000000..3226644 --- /dev/null +++ b/lib/DataPointTypes/DPTStep.js.map @@ -0,0 +1 @@ +{"version":3,"file":"DPTStep.js","sourceRoot":"","sources":["../../src/DataPointTypes/DPTStep.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,mDAA8C;AAE9C,iBAAS,MAAM,OAAQ,SAAQ,6BAAa;IACxC;QACI,KAAK,CAAC,6BAAa,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,6BAAa,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,EACrE,6BAAa,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,6BAAa,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC5E,CAAC;CACJ,CAAC"} \ No newline at end of file diff --git a/lib/DataPointTypes/DPTSwitch.d.ts b/lib/DataPointTypes/DPTSwitch.d.ts new file mode 100644 index 0000000..5eab2d4 --- /dev/null +++ b/lib/DataPointTypes/DPTSwitch.d.ts @@ -0,0 +1,19 @@ +/// +declare const _default: { + new (): { + readonly type: string; + readonly subtype: string; + _type: string; + _subtype: string; + _encoder: import("./definitions").Encoder; + _decoder: import("./definitions").Decoder; + toString(): string; + decode(buffer: Buffer): string | number; + encode(value: string | number): Buffer; + }; + readonly TYPES: { + [index: string]: import("./definitions").DPT; + }; + validType(text: string): boolean; +}; +export = _default; diff --git a/lib/DataPointTypes/DPTSwitch.js b/lib/DataPointTypes/DPTSwitch.js new file mode 100644 index 0000000..aedd2f9 --- /dev/null +++ b/lib/DataPointTypes/DPTSwitch.js @@ -0,0 +1,8 @@ +'use strict'; +const DataPointType_1 = require("./DataPointType"); +module.exports = class DPTSwitch extends DataPointType_1.DataPointType { + constructor() { + super(DataPointType_1.DataPointType.TYPES.DPT1.id, DataPointType_1.DataPointType.TYPES.DPT1.subtypes.switch, DataPointType_1.DataPointType.TYPES.DPT1.encoder, DataPointType_1.DataPointType.TYPES.DPT1.decoder); + } +}; +//# sourceMappingURL=DPTSwitch.js.map \ No newline at end of file diff --git a/lib/DataPointTypes/DPTSwitch.js.map b/lib/DataPointTypes/DPTSwitch.js.map new file mode 100644 index 0000000..a858afb --- /dev/null +++ b/lib/DataPointTypes/DPTSwitch.js.map @@ -0,0 +1 @@ +{"version":3,"file":"DPTSwitch.js","sourceRoot":"","sources":["../../src/DataPointTypes/DPTSwitch.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,mDAA8C;AAE9C,iBAAS,MAAM,SAAU,SAAQ,6BAAa;IAC1C;QACI,KAAK,CAAC,6BAAa,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,6BAAa,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EACvE,6BAAa,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAChC,6BAAa,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC1C,CAAC;CACJ,CAAC"} \ No newline at end of file diff --git a/lib/DataPointTypes/DPTTemperature.d.ts b/lib/DataPointTypes/DPTTemperature.d.ts new file mode 100644 index 0000000..5eab2d4 --- /dev/null +++ b/lib/DataPointTypes/DPTTemperature.d.ts @@ -0,0 +1,19 @@ +/// +declare const _default: { + new (): { + readonly type: string; + readonly subtype: string; + _type: string; + _subtype: string; + _encoder: import("./definitions").Encoder; + _decoder: import("./definitions").Decoder; + toString(): string; + decode(buffer: Buffer): string | number; + encode(value: string | number): Buffer; + }; + readonly TYPES: { + [index: string]: import("./definitions").DPT; + }; + validType(text: string): boolean; +}; +export = _default; diff --git a/lib/DataPointTypes/DPTTemperature.js b/lib/DataPointTypes/DPTTemperature.js new file mode 100644 index 0000000..7730ea4 --- /dev/null +++ b/lib/DataPointTypes/DPTTemperature.js @@ -0,0 +1,8 @@ +'use strict'; +const DataPointType_1 = require("./DataPointType"); +module.exports = class DPTTemperature extends DataPointType_1.DataPointType { + constructor() { + super(DataPointType_1.DataPointType.TYPES.DPT9.id, DataPointType_1.DataPointType.TYPES.DPT9.subtypes.temperature, DataPointType_1.DataPointType.TYPES.DPT9.encoder, DataPointType_1.DataPointType.TYPES.DPT9.decoder); + } +}; +//# sourceMappingURL=DPTTemperature.js.map \ No newline at end of file diff --git a/lib/DataPointTypes/DPTTemperature.js.map b/lib/DataPointTypes/DPTTemperature.js.map new file mode 100644 index 0000000..211c9fb --- /dev/null +++ b/lib/DataPointTypes/DPTTemperature.js.map @@ -0,0 +1 @@ +{"version":3,"file":"DPTTemperature.js","sourceRoot":"","sources":["../../src/DataPointTypes/DPTTemperature.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,mDAA8C;AAE9C,iBAAS,MAAM,cAAe,SAAQ,6BAAa;IAC/C;QACI,KAAK,CAAC,6BAAa,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,6BAAa,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,WAAW,EAC5E,6BAAa,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,6BAAa,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC5E,CAAC;CACJ,CAAC"} \ No newline at end of file diff --git a/lib/DataPointTypes/DPTTime.d.ts b/lib/DataPointTypes/DPTTime.d.ts new file mode 100644 index 0000000..5eab2d4 --- /dev/null +++ b/lib/DataPointTypes/DPTTime.d.ts @@ -0,0 +1,19 @@ +/// +declare const _default: { + new (): { + readonly type: string; + readonly subtype: string; + _type: string; + _subtype: string; + _encoder: import("./definitions").Encoder; + _decoder: import("./definitions").Decoder; + toString(): string; + decode(buffer: Buffer): string | number; + encode(value: string | number): Buffer; + }; + readonly TYPES: { + [index: string]: import("./definitions").DPT; + }; + validType(text: string): boolean; +}; +export = _default; diff --git a/lib/DataPointTypes/DPTTime.js b/lib/DataPointTypes/DPTTime.js new file mode 100644 index 0000000..8ba7b1a --- /dev/null +++ b/lib/DataPointTypes/DPTTime.js @@ -0,0 +1,8 @@ +'use strict'; +const DataPointType_1 = require("./DataPointType"); +module.exports = class DPTTime extends DataPointType_1.DataPointType { + constructor() { + super(DataPointType_1.DataPointType.TYPES.DPT10.id, DataPointType_1.DataPointType.TYPES.DPT10.subtypes.time, DataPointType_1.DataPointType.TYPES.DPT10.encoder, DataPointType_1.DataPointType.TYPES.DPT10.decoder); + } +}; +//# sourceMappingURL=DPTTime.js.map \ No newline at end of file diff --git a/lib/DataPointTypes/DPTTime.js.map b/lib/DataPointTypes/DPTTime.js.map new file mode 100644 index 0000000..0b8683d --- /dev/null +++ b/lib/DataPointTypes/DPTTime.js.map @@ -0,0 +1 @@ +{"version":3,"file":"DPTTime.js","sourceRoot":"","sources":["../../src/DataPointTypes/DPTTime.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,mDAA8C;AAE9C,iBAAS,MAAM,OAAQ,SAAQ,6BAAa;IACxC;QACI,KAAK,CAAC,6BAAa,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,EAAE,6BAAa,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,EACvE,6BAAa,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,EAAE,6BAAa,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAC9E,CAAC;CACJ,CAAC"} \ No newline at end of file diff --git a/lib/DataPointTypes/DPTTrigger.d.ts b/lib/DataPointTypes/DPTTrigger.d.ts new file mode 100644 index 0000000..5eab2d4 --- /dev/null +++ b/lib/DataPointTypes/DPTTrigger.d.ts @@ -0,0 +1,19 @@ +/// +declare const _default: { + new (): { + readonly type: string; + readonly subtype: string; + _type: string; + _subtype: string; + _encoder: import("./definitions").Encoder; + _decoder: import("./definitions").Decoder; + toString(): string; + decode(buffer: Buffer): string | number; + encode(value: string | number): Buffer; + }; + readonly TYPES: { + [index: string]: import("./definitions").DPT; + }; + validType(text: string): boolean; +}; +export = _default; diff --git a/lib/DataPointTypes/DPTTrigger.js b/lib/DataPointTypes/DPTTrigger.js new file mode 100644 index 0000000..ef95825 --- /dev/null +++ b/lib/DataPointTypes/DPTTrigger.js @@ -0,0 +1,8 @@ +'use strict'; +const DataPointType_1 = require("./DataPointType"); +module.exports = class DPTTrigger extends DataPointType_1.DataPointType { + constructor() { + super(DataPointType_1.DataPointType.TYPES.DPT1.id, DataPointType_1.DataPointType.TYPES.DPT1.subtypes.trigger, DataPointType_1.DataPointType.TYPES.DPT1.encoder, DataPointType_1.DataPointType.TYPES.DPT1.decoder); + } +}; +//# sourceMappingURL=DPTTrigger.js.map \ No newline at end of file diff --git a/lib/DataPointTypes/DPTTrigger.js.map b/lib/DataPointTypes/DPTTrigger.js.map new file mode 100644 index 0000000..02072ba --- /dev/null +++ b/lib/DataPointTypes/DPTTrigger.js.map @@ -0,0 +1 @@ +{"version":3,"file":"DPTTrigger.js","sourceRoot":"","sources":["../../src/DataPointTypes/DPTTrigger.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,mDAA8C;AAE9C,iBAAS,MAAM,UAAW,SAAQ,6BAAa;IAC3C;QACI,KAAK,CAAC,6BAAa,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,6BAAa,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,EACxE,6BAAa,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAChC,6BAAa,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC1C,CAAC;CACJ,CAAC"} \ No newline at end of file diff --git a/lib/DataPointTypes/DPTUpdown.d.ts b/lib/DataPointTypes/DPTUpdown.d.ts new file mode 100644 index 0000000..5eab2d4 --- /dev/null +++ b/lib/DataPointTypes/DPTUpdown.d.ts @@ -0,0 +1,19 @@ +/// +declare const _default: { + new (): { + readonly type: string; + readonly subtype: string; + _type: string; + _subtype: string; + _encoder: import("./definitions").Encoder; + _decoder: import("./definitions").Decoder; + toString(): string; + decode(buffer: Buffer): string | number; + encode(value: string | number): Buffer; + }; + readonly TYPES: { + [index: string]: import("./definitions").DPT; + }; + validType(text: string): boolean; +}; +export = _default; diff --git a/lib/DataPointTypes/DPTUpdown.js b/lib/DataPointTypes/DPTUpdown.js new file mode 100644 index 0000000..e780d7d --- /dev/null +++ b/lib/DataPointTypes/DPTUpdown.js @@ -0,0 +1,8 @@ +'use strict'; +const DataPointType_1 = require("./DataPointType"); +module.exports = class DPTUpdown extends DataPointType_1.DataPointType { + constructor() { + super(DataPointType_1.DataPointType.TYPES.DPT1.id, DataPointType_1.DataPointType.TYPES.DPT1.subtypes.updown, DataPointType_1.DataPointType.TYPES.DPT1.encoder, DataPointType_1.DataPointType.TYPES.DPT1.decoder); + } +}; +//# sourceMappingURL=DPTUpdown.js.map \ No newline at end of file diff --git a/lib/DataPointTypes/DPTUpdown.js.map b/lib/DataPointTypes/DPTUpdown.js.map new file mode 100644 index 0000000..70216ba --- /dev/null +++ b/lib/DataPointTypes/DPTUpdown.js.map @@ -0,0 +1 @@ +{"version":3,"file":"DPTUpdown.js","sourceRoot":"","sources":["../../src/DataPointTypes/DPTUpdown.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,mDAA8C;AAE9C,iBAAS,MAAM,SAAU,SAAQ,6BAAa;IAC1C;QACI,KAAK,CAAC,6BAAa,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,6BAAa,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EACvE,6BAAa,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAChC,6BAAa,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC1C,CAAC;CACJ,CAAC"} \ No newline at end of file diff --git a/lib/DataPointTypes/DataPointType.d.ts b/lib/DataPointTypes/DataPointType.d.ts new file mode 100644 index 0000000..45f0c81 --- /dev/null +++ b/lib/DataPointTypes/DataPointType.d.ts @@ -0,0 +1,18 @@ +/// +import { Encoder, Decoder, DPT } from './definitions'; +export declare class DataPointType { + private _type; + private _subtype; + private _encoder; + private _decoder; + get type(): string; + get subtype(): string; + static get TYPES(): { + [index: string]: DPT | null; + }; + constructor(_type: string, _subtype: string, _encoder: Encoder, _decoder: Decoder); + static validType(text: string): boolean; + toString(): string; + decode(buffer: Buffer): string | number; + encode(value: string | number): Buffer; +} diff --git a/lib/DataPointTypes/DataPointType.js b/lib/DataPointTypes/DataPointType.js new file mode 100644 index 0000000..2030d1a --- /dev/null +++ b/lib/DataPointTypes/DataPointType.js @@ -0,0 +1,65 @@ +'use strict'; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.DataPointType = void 0; +const DPT1_1 = require("./DPT1"); +const DPT2_1 = require("./DPT2"); +const DPT3_1 = require("./DPT3"); +const DPT5_1 = require("./DPT5"); +const DPT9_1 = require("./DPT9"); +const DPT10_1 = require("./DPT10"); +const DPT11_1 = require("./DPT11"); +const DPT14_1 = require("./DPT14"); +const DPT18_1 = require("./DPT18"); +class DataPointType { + constructor(_type, _subtype, _encoder, _decoder) { + this._type = _type; + this._subtype = _subtype; + this._encoder = _encoder; + this._decoder = _decoder; + } + get type() { + return this._type; + } + get subtype() { + return this._subtype; + } + static get TYPES() { + return { + DPT1: DPT1_1.DPT1, + DPT2: DPT2_1.DPT2, + DPT3: DPT3_1.DPT3, + DPT4: null, + DPT5: DPT5_1.DPT5, + DPT6: null, + DPT7: null, + DPT8: null, + DPT9: DPT9_1.DPT9, + DPT10: DPT10_1.DPT10, + DPT11: DPT11_1.DPT11, + DPT12: null, + DPT13: null, + DPT14: DPT14_1.DPT14, + DPT15: null, + DPT16: null, + DPT17: null, + DPT18: DPT18_1.DPT18, + DPT19: null, + DPT20: null + }; + } + static validType(text) { + const m = text.toUpperCase().match(/(?:DPT)?(\d+)(\.(\d+))?/); + return m != null; + } + toString() { + return `${this.type}.${this.subtype}`; + } + decode(buffer) { + return this._decoder(buffer); + } + encode(value) { + return this._encoder(value); + } +} +exports.DataPointType = DataPointType; +//# sourceMappingURL=DataPointType.js.map \ No newline at end of file diff --git a/lib/DataPointTypes/DataPointType.js.map b/lib/DataPointTypes/DataPointType.js.map new file mode 100644 index 0000000..15b7330 --- /dev/null +++ b/lib/DataPointTypes/DataPointType.js.map @@ -0,0 +1 @@ +{"version":3,"file":"DataPointType.js","sourceRoot":"","sources":["../../src/DataPointTypes/DataPointType.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAIb,iCAA4B;AAC5B,iCAA4B;AAC5B,iCAA4B;AAC5B,iCAA4B;AAC5B,iCAA4B;AAC5B,mCAA8B;AAC9B,mCAA8B;AAC9B,mCAA8B;AAC9B,mCAA8B;AAK9B,MAAa,aAAa;IAyDtB,YAAoB,KAAa,EAAU,QAAgB,EAAU,QAAiB,EAAU,QAAiB;QAA7F,UAAK,GAAL,KAAK,CAAQ;QAAU,aAAQ,GAAR,QAAQ,CAAQ;QAAU,aAAQ,GAAR,QAAQ,CAAS;QAAU,aAAQ,GAAR,QAAQ,CAAS;IACjH,CAAC;IAxDD,IAAI,IAAI;QACJ,OAAO,IAAI,CAAC,KAAK,CAAC;IACtB,CAAC;IAED,IAAI,OAAO;QACP,OAAO,IAAI,CAAC,QAAQ,CAAC;IACzB,CAAC;IAwBD,MAAM,KAAK,KAAK;QACZ,OAAO;YACH,IAAI,EAAJ,WAAI;YACJ,IAAI,EAAJ,WAAI;YACJ,IAAI,EAAJ,WAAI;YACJ,IAAI,EAAE,IAAI;YACV,IAAI,EAAJ,WAAI;YACJ,IAAI,EAAE,IAAI;YACV,IAAI,EAAE,IAAI;YACV,IAAI,EAAE,IAAI;YACV,IAAI,EAAJ,WAAI;YACJ,KAAK,EAAL,aAAK;YACL,KAAK,EAAL,aAAK;YACL,KAAK,EAAE,IAAI;YACX,KAAK,EAAE,IAAI;YACX,KAAK,EAAL,aAAK;YACL,KAAK,EAAE,IAAI;YACX,KAAK,EAAE,IAAI;YACX,KAAK,EAAE,IAAI;YACX,KAAK,EAAL,aAAK;YACL,KAAK,EAAE,IAAI;YACX,KAAK,EAAE,IAAI;SACd,CAAC;IACN,CAAC;IAKD,MAAM,CAAC,SAAS,CAAC,IAAY;QACzB,MAAM,CAAC,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAC;QAC9D,OAAO,CAAC,IAAI,IAAI,CAAC;IACrB,CAAC;IAED,QAAQ;QACJ,OAAO,GAAG,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;IAC1C,CAAC;IAED,MAAM,CAAC,MAAc;QACjB,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACjC,CAAC;IAED,MAAM,CAAC,KAAoB;QACvB,OAAO,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAChC,CAAC;CACJ;AA5ED,sCA4EC"} \ No newline at end of file diff --git a/lib/DataPointTypes/DataPointTypeFactory.d.ts b/lib/DataPointTypes/DataPointTypeFactory.d.ts new file mode 100644 index 0000000..982932e --- /dev/null +++ b/lib/DataPointTypes/DataPointTypeFactory.d.ts @@ -0,0 +1,4 @@ +import { DataPointType } from './DataPointType'; +export declare const DPTS: { + [index: string]: DataPointType; +}; diff --git a/lib/DataPointTypes/DataPointTypeFactory.js b/lib/DataPointTypes/DataPointTypeFactory.js new file mode 100644 index 0000000..dcf7e4f --- /dev/null +++ b/lib/DataPointTypes/DataPointTypeFactory.js @@ -0,0 +1,47 @@ +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.DPTS = void 0; +const DPTAlarm_1 = __importDefault(require("../DataPointTypes/DPTAlarm")); +const DPTAngle_1 = __importDefault(require("../DataPointTypes/DPTAngle")); +const DPTBinary_1 = __importDefault(require("../DataPointTypes/DPTBinary")); +const DPTDate_1 = __importDefault(require("../DataPointTypes/DPTDate")); +const DPTDimmingcontrol_1 = __importDefault(require("../DataPointTypes/DPTDimmingcontrol")); +const DPTEnable_1 = __importDefault(require("../DataPointTypes/DPTEnable")); +const DPTLux_1 = __importDefault(require("../DataPointTypes/DPTLux")); +const DPTPercentage_1 = __importDefault(require("../DataPointTypes/DPTPercentage")); +const DPTPercentagescaling_1 = __importDefault(require("../DataPointTypes/DPTPercentagescaling")); +const DPTScene_1 = __importDefault(require("../DataPointTypes/DPTScene")); +const DPTScenecontrol_1 = __importDefault(require("../DataPointTypes/DPTScenecontrol")); +const DPTSpeed_1 = __importDefault(require("../DataPointTypes/DPTSpeed")); +const DPTStartstop_1 = __importDefault(require("../DataPointTypes/DPTStartstop")); +const DPTStep_1 = __importDefault(require("../DataPointTypes/DPTStep")); +const DPTSwitch_1 = __importDefault(require("../DataPointTypes/DPTSwitch")); +const DPTTemperature_1 = __importDefault(require("../DataPointTypes/DPTTemperature")); +const DPTTime_1 = __importDefault(require("../DataPointTypes/DPTTime")); +const DPTTrigger_1 = __importDefault(require("../DataPointTypes/DPTTrigger")); +const DPTUpdown_1 = __importDefault(require("../DataPointTypes/DPTUpdown")); +exports.DPTS = { + DPTAlarm: new DPTAlarm_1.default(), + DPTAngle: new DPTAngle_1.default(), + DPTBinary: new DPTBinary_1.default(), + DPTDate: new DPTDate_1.default(), + DPTDimmingcontrol: new DPTDimmingcontrol_1.default(), + DPTEnable: new DPTEnable_1.default(), + DPTLux: new DPTLux_1.default(), + DPTPercentage: new DPTPercentage_1.default(), + DPTPercentagescaling: new DPTPercentagescaling_1.default(), + DPTScene: new DPTScene_1.default(), + DPTScenecontrol: new DPTScenecontrol_1.default(), + DPTSpeed: new DPTSpeed_1.default(), + DPTStartstop: new DPTStartstop_1.default(), + DPTStep: new DPTStep_1.default(), + DPTSwitch: new DPTSwitch_1.default(), + DPTTemperature: new DPTTemperature_1.default(), + DPTTime: new DPTTime_1.default(), + DPTTrigger: new DPTTrigger_1.default(), + DPTUpdown: new DPTUpdown_1.default() +}; +//# sourceMappingURL=DataPointTypeFactory.js.map \ No newline at end of file diff --git a/lib/DataPointTypes/DataPointTypeFactory.js.map b/lib/DataPointTypes/DataPointTypeFactory.js.map new file mode 100644 index 0000000..9f4dcc5 --- /dev/null +++ b/lib/DataPointTypes/DataPointTypeFactory.js.map @@ -0,0 +1 @@ +{"version":3,"file":"DataPointTypeFactory.js","sourceRoot":"","sources":["../../src/DataPointTypes/DataPointTypeFactory.ts"],"names":[],"mappings":";;;;;;AACA,0EAAkD;AAClD,0EAAkD;AAClD,4EAAoD;AACpD,wEAAgD;AAChD,4FAAoE;AACpE,4EAAoD;AACpD,sEAA8C;AAC9C,oFAA4D;AAC5D,kGAA0E;AAC1E,0EAAkD;AAClD,wFAAgE;AAChE,0EAAkD;AAClD,kFAA0D;AAC1D,wEAAgD;AAChD,4EAAoD;AACpD,sFAA8D;AAC9D,wEAAgD;AAChD,8EAAsD;AACtD,4EAAoD;AAGvC,QAAA,IAAI,GAAqC;IAClD,QAAQ,EAAE,IAAI,kBAAQ,EAAE;IACxB,QAAQ,EAAE,IAAI,kBAAQ,EAAE;IACxB,SAAS,EAAE,IAAI,mBAAS,EAAE;IAC1B,OAAO,EAAE,IAAI,iBAAO,EAAE;IACtB,iBAAiB,EAAE,IAAI,2BAAiB,EAAE;IAC1C,SAAS,EAAE,IAAI,mBAAS,EAAE;IAC1B,MAAM,EAAE,IAAI,gBAAM,EAAE;IACpB,aAAa,EAAE,IAAI,uBAAa,EAAE;IAClC,oBAAoB,EAAE,IAAI,8BAAoB,EAAE;IAChD,QAAQ,EAAE,IAAI,kBAAQ,EAAE;IACxB,eAAe,EAAE,IAAI,yBAAe,EAAE;IACtC,QAAQ,EAAE,IAAI,kBAAQ,EAAE;IACxB,YAAY,EAAE,IAAI,sBAAY,EAAE;IAChC,OAAO,EAAE,IAAI,iBAAO,EAAE;IACtB,SAAS,EAAE,IAAI,mBAAS,EAAE;IAC1B,cAAc,EAAE,IAAI,wBAAc,EAAE;IACpC,OAAO,EAAE,IAAI,iBAAO,EAAE;IACtB,UAAU,EAAE,IAAI,oBAAU,EAAE;IAC5B,SAAS,EAAE,IAAI,mBAAS,EAAE;CAC7B,CAAC"} \ No newline at end of file diff --git a/lib/DataPointTypes/definitions.d.ts b/lib/DataPointTypes/definitions.d.ts new file mode 100644 index 0000000..f7072f1 --- /dev/null +++ b/lib/DataPointTypes/definitions.d.ts @@ -0,0 +1,19 @@ +/// +export declare type Encoder = (value: any) => Buffer; +export declare type Decoder = (buffer: Buffer) => any; +export interface DPT { + decoder: Decoder; + encoder: Encoder; + id: string; + subtypes: { + [index: string]: any; + }; +} +export interface DPTActions { + [index: string]: { + func: (x?: any) => void; + parameterType: { + [index: string]: any; + }; + }; +} diff --git a/lib/DataPointTypes/definitions.js b/lib/DataPointTypes/definitions.js new file mode 100644 index 0000000..c3252fe --- /dev/null +++ b/lib/DataPointTypes/definitions.js @@ -0,0 +1,3 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//# sourceMappingURL=definitions.js.map \ No newline at end of file diff --git a/lib/DataPointTypes/definitions.js.map b/lib/DataPointTypes/definitions.js.map new file mode 100644 index 0000000..dd6664b --- /dev/null +++ b/lib/DataPointTypes/definitions.js.map @@ -0,0 +1 @@ +{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/DataPointTypes/definitions.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/lib/DataPoints/Alarm.d.ts b/lib/DataPoints/Alarm.d.ts new file mode 100644 index 0000000..488c43a --- /dev/null +++ b/lib/DataPoints/Alarm.d.ts @@ -0,0 +1,18 @@ +import { KNXAddress } from '../protocol/KNXAddress'; +declare const _default: { + new (ga: KNXAddress): { + _knxTunnelSocket: import("..").KNXTunnelSocket; + _value: any; + _actions: import("../DataPointTypes/definitions").DPTActions; + _ga: KNXAddress; + _type: import("../DataPointTypes/DataPointType").DataPointType; + readonly id: string; + readonly value: any; + readonly type: import("../DataPointTypes/DataPointType").DataPointType; + bind(knxTunnelSocket: import("..").KNXTunnelSocket): void; + read(): Promise; + write(val?: string | number | Date | import("../DataPointTypes/DPT3").DPT3Value | import("../DataPointTypes/DPT10").DPT10Value | import("../DataPointTypes/DPT18").DPT18Value): Promise; + }; + readonly UNKOWN_VALUE: string; +}; +export = _default; diff --git a/lib/DataPoints/Alarm.js b/lib/DataPoints/Alarm.js new file mode 100644 index 0000000..1296b22 --- /dev/null +++ b/lib/DataPoints/Alarm.js @@ -0,0 +1,9 @@ +'use strict'; +const DataPoint_1 = require("./DataPoint"); +const DataPointTypeFactory_1 = require("../DataPointTypes/DataPointTypeFactory"); +module.exports = class Alarm extends DataPoint_1.DataPoint { + constructor(ga) { + super(ga, DataPointTypeFactory_1.DPTS.DPTAlarm); + } +}; +//# sourceMappingURL=Alarm.js.map \ No newline at end of file diff --git a/lib/DataPoints/Alarm.js.map b/lib/DataPoints/Alarm.js.map new file mode 100644 index 0000000..6c2c765 --- /dev/null +++ b/lib/DataPoints/Alarm.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Alarm.js","sourceRoot":"","sources":["../../src/DataPoints/Alarm.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAUb,2CAAsC;AACtC,iFAA4D;AAG5D,iBAAS,MAAM,KAAM,SAAQ,qBAAS;IAClC,YAAY,EAAc;QACtB,KAAK,CAAC,EAAE,EAAE,2BAAI,CAAC,QAAQ,CAAC,CAAC;IAC7B,CAAC;CACJ,CAAC"} \ No newline at end of file diff --git a/lib/DataPoints/Angle.d.ts b/lib/DataPoints/Angle.d.ts new file mode 100644 index 0000000..488c43a --- /dev/null +++ b/lib/DataPoints/Angle.d.ts @@ -0,0 +1,18 @@ +import { KNXAddress } from '../protocol/KNXAddress'; +declare const _default: { + new (ga: KNXAddress): { + _knxTunnelSocket: import("..").KNXTunnelSocket; + _value: any; + _actions: import("../DataPointTypes/definitions").DPTActions; + _ga: KNXAddress; + _type: import("../DataPointTypes/DataPointType").DataPointType; + readonly id: string; + readonly value: any; + readonly type: import("../DataPointTypes/DataPointType").DataPointType; + bind(knxTunnelSocket: import("..").KNXTunnelSocket): void; + read(): Promise; + write(val?: string | number | Date | import("../DataPointTypes/DPT3").DPT3Value | import("../DataPointTypes/DPT10").DPT10Value | import("../DataPointTypes/DPT18").DPT18Value): Promise; + }; + readonly UNKOWN_VALUE: string; +}; +export = _default; diff --git a/lib/DataPoints/Angle.js b/lib/DataPoints/Angle.js new file mode 100644 index 0000000..c376b79 --- /dev/null +++ b/lib/DataPoints/Angle.js @@ -0,0 +1,9 @@ +'use strict'; +const DataPoint_1 = require("./DataPoint"); +const DataPointTypeFactory_1 = require("../DataPointTypes/DataPointTypeFactory"); +module.exports = class Angle extends DataPoint_1.DataPoint { + constructor(ga) { + super(ga, DataPointTypeFactory_1.DPTS.DPTAngle); + } +}; +//# sourceMappingURL=Angle.js.map \ No newline at end of file diff --git a/lib/DataPoints/Angle.js.map b/lib/DataPoints/Angle.js.map new file mode 100644 index 0000000..50e5e26 --- /dev/null +++ b/lib/DataPoints/Angle.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Angle.js","sourceRoot":"","sources":["../../src/DataPoints/Angle.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AASb,2CAAsC;AACtC,iFAA4D;AAG5D,iBAAS,MAAM,KAAM,SAAQ,qBAAS;IAClC,YAAY,EAAc;QACtB,KAAK,CAAC,EAAE,EAAE,2BAAI,CAAC,QAAQ,CAAC,CAAC;IAC7B,CAAC;CACJ,CAAC"} \ No newline at end of file diff --git a/lib/DataPoints/Binary.d.ts b/lib/DataPoints/Binary.d.ts new file mode 100644 index 0000000..488c43a --- /dev/null +++ b/lib/DataPoints/Binary.d.ts @@ -0,0 +1,18 @@ +import { KNXAddress } from '../protocol/KNXAddress'; +declare const _default: { + new (ga: KNXAddress): { + _knxTunnelSocket: import("..").KNXTunnelSocket; + _value: any; + _actions: import("../DataPointTypes/definitions").DPTActions; + _ga: KNXAddress; + _type: import("../DataPointTypes/DataPointType").DataPointType; + readonly id: string; + readonly value: any; + readonly type: import("../DataPointTypes/DataPointType").DataPointType; + bind(knxTunnelSocket: import("..").KNXTunnelSocket): void; + read(): Promise; + write(val?: string | number | Date | import("../DataPointTypes/DPT3").DPT3Value | import("../DataPointTypes/DPT10").DPT10Value | import("../DataPointTypes/DPT18").DPT18Value): Promise; + }; + readonly UNKOWN_VALUE: string; +}; +export = _default; diff --git a/lib/DataPoints/Binary.js b/lib/DataPoints/Binary.js new file mode 100644 index 0000000..a1b98aa --- /dev/null +++ b/lib/DataPoints/Binary.js @@ -0,0 +1,9 @@ +"use strict"; +const DataPoint_1 = require("./DataPoint"); +const DataPointTypeFactory_1 = require("../DataPointTypes/DataPointTypeFactory"); +module.exports = class Binary extends DataPoint_1.DataPoint { + constructor(ga) { + super(ga, DataPointTypeFactory_1.DPTS.DPTBinary); + } +}; +//# sourceMappingURL=Binary.js.map \ No newline at end of file diff --git a/lib/DataPoints/Binary.js.map b/lib/DataPoints/Binary.js.map new file mode 100644 index 0000000..c80c0b5 --- /dev/null +++ b/lib/DataPoints/Binary.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Binary.js","sourceRoot":"","sources":["../../src/DataPoints/Binary.ts"],"names":[],"mappings":";AAAA,2CAAsC;AACtC,iFAA4D;AAG5D,iBAAS,MAAM,MAAO,SAAQ,qBAAS;IACnC,YAAY,EAAc;QACtB,KAAK,CAAC,EAAE,EAAE,2BAAI,CAAC,SAAS,CAAC,CAAC;IAC9B,CAAC;CACJ,CAAC"} \ No newline at end of file diff --git a/lib/DataPoints/DataPoint.d.ts b/lib/DataPoints/DataPoint.d.ts new file mode 100644 index 0000000..f3ca4de --- /dev/null +++ b/lib/DataPoints/DataPoint.d.ts @@ -0,0 +1,23 @@ +import { DataPointType } from '../DataPointTypes/DataPointType'; +import { KNXAddress } from '../protocol/KNXAddress'; +import { DPT10Value } from '../DataPointTypes/DPT10'; +import { DPT3Value } from '../DataPointTypes/DPT3'; +import { DPT18Value } from '../DataPointTypes/DPT18'; +import { DPTActions } from '../DataPointTypes/definitions'; +import { KNXTunnelSocket } from '../KNXTunnelSocket'; +export declare type IDataPoint = new (_ga: KNXAddress, typeName?: string) => DataPoint; +export declare class DataPoint { + private _ga; + private _type; + protected _knxTunnelSocket: KNXTunnelSocket; + protected _value: any; + protected _actions: DPTActions; + constructor(_ga: KNXAddress, _type: DataPointType); + static get UNKOWN_VALUE(): string; + get id(): string; + get value(): any; + get type(): DataPointType; + bind(knxTunnelSocket: KNXTunnelSocket): void; + read(): Promise; + write(val?: string | number | DPT10Value | DPT3Value | Date | DPT18Value | null): Promise; +} diff --git a/lib/DataPoints/DataPoint.js b/lib/DataPoints/DataPoint.js new file mode 100644 index 0000000..f33557d --- /dev/null +++ b/lib/DataPoints/DataPoint.js @@ -0,0 +1,59 @@ +'use strict'; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.DataPoint = void 0; +const KNXDataBuffer_1 = require("../protocol/KNXDataBuffer"); +const UNKOWN_VALUE = 'n/a'; +class DataPoint { + constructor(_ga, _type) { + this._ga = _ga; + this._type = _type; + this._knxTunnelSocket = null; + this._value = UNKOWN_VALUE; + } + static get UNKOWN_VALUE() { + return UNKOWN_VALUE; + } + get id() { + return this._ga.toString(); + } + get value() { + return this._value; + } + get type() { + return this._type; + } + bind(knxTunnelSocket) { + this._knxTunnelSocket = knxTunnelSocket; + } + read() { + return __awaiter(this, void 0, void 0, function* () { + if (this._knxTunnelSocket == null) { + throw new Error('Datapoint not binded'); + } + const buf = yield this._knxTunnelSocket.readAsync(this._ga); + this._value = this._type.decode(buf); + return this._value; + }); + } + write(val = null) { + return __awaiter(this, void 0, void 0, function* () { + if (this._knxTunnelSocket == null) { + throw new Error('Datapoint not binded'); + } + const value = val == null ? this._value : val; + const buf = new KNXDataBuffer_1.KNXDataBuffer(this._type.encode(value), this); + yield this._knxTunnelSocket.writeAsync(this._ga, buf); + }); + } +} +exports.DataPoint = DataPoint; +//# sourceMappingURL=DataPoint.js.map \ No newline at end of file diff --git a/lib/DataPoints/DataPoint.js.map b/lib/DataPoints/DataPoint.js.map new file mode 100644 index 0000000..070b56d --- /dev/null +++ b/lib/DataPoints/DataPoint.js.map @@ -0,0 +1 @@ +{"version":3,"file":"DataPoint.js","sourceRoot":"","sources":["../../src/DataPoints/DataPoint.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;;;;;AAIb,6DAAwD;AAOxD,MAAM,YAAY,GAAG,KAAK,CAAC;AAG3B,MAAa,SAAS;IAIlB,YAAoB,GAAe,EAAU,KAAoB;QAA7C,QAAG,GAAH,GAAG,CAAY;QAAU,UAAK,GAAL,KAAK,CAAe;QAC7D,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC;QAC7B,IAAI,CAAC,MAAM,GAAG,YAAY,CAAC;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No newline at end of file diff --git a/lib/DataPoints/DataPointFactory.d.ts b/lib/DataPoints/DataPointFactory.d.ts new file mode 100644 index 0000000..cdf4b5b --- /dev/null +++ b/lib/DataPoints/DataPointFactory.d.ts @@ -0,0 +1,4 @@ +import { KNXAddress } from '../protocol/KNXAddress'; +import { DataPoint } from './DataPoint'; +export declare const createDataPoint: (ga: KNXAddress, typeName: string) => DataPoint; +export declare const getDataPointType: (type: string | number, subtype: string | number) => string; diff --git a/lib/DataPoints/DataPointFactory.js b/lib/DataPoints/DataPointFactory.js new file mode 100644 index 0000000..1dba486 --- /dev/null +++ b/lib/DataPoints/DataPointFactory.js @@ -0,0 +1,71 @@ +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.getDataPointType = exports.createDataPoint = void 0; +const Alarm_1 = __importDefault(require("./Alarm")); +const Angle_1 = __importDefault(require("./Angle")); +const Binary_1 = __importDefault(require("./Binary")); +const Date_1 = __importDefault(require("./Date")); +const Dimmingcontrol_1 = __importDefault(require("./Dimmingcontrol")); +const Enable_1 = __importDefault(require("./Enable")); +const Lux_1 = __importDefault(require("./Lux")); +const Percentage_1 = __importDefault(require("./Percentage")); +const Percentagescaling_1 = __importDefault(require("./Percentagescaling")); +const Scene_1 = __importDefault(require("./Scene")); +const Scenecontrol_1 = __importDefault(require("./Scenecontrol")); +const Speed_1 = __importDefault(require("./Speed")); +const Startstop_1 = __importDefault(require("./Startstop")); +const Step_1 = __importDefault(require("./Step")); +const Switch_1 = __importDefault(require("./Switch")); +const Temperature_1 = __importDefault(require("./Temperature")); +const Time_1 = __importDefault(require("./Time")); +const Trigger_1 = __importDefault(require("./Trigger")); +const Updown_1 = __importDefault(require("./Updown")); +const DataPointType_1 = require("../DataPointTypes/DataPointType"); +const DataPointFactory = { + Alarm: Alarm_1.default, + Angle: Angle_1.default, + Binary: Binary_1.default, + Date: Date_1.default, + Dimmingcontrol: Dimmingcontrol_1.default, + Enable: Enable_1.default, + Lux: Lux_1.default, + Percentage: Percentage_1.default, + Percentagescaling: Percentagescaling_1.default, + Scene: Scene_1.default, + Scenecontrol: Scenecontrol_1.default, + Speed: Speed_1.default, + Startstop: Startstop_1.default, + Step: Step_1.default, + Switch: Switch_1.default, + Temperature: Temperature_1.default, + Time: Time_1.default, + Trigger: Trigger_1.default, + Updown: Updown_1.default +}; +exports.createDataPoint = (ga, typeName) => { + const DataPointClassName = `${typeName[0].toUpperCase()}${typeName.slice(1).toLowerCase()}`; + const DataPointClass = DataPointFactory[DataPointClassName]; + if (DataPointClass == null) { + throw new Error(`Unknown DataPoint type ${typeName}`); + } + return new DataPointClass(ga); +}; +exports.getDataPointType = (type, subtype) => { + const dpt = DataPointType_1.DataPointType.TYPES[`DPT${type}`]; + if (dpt == null) { + throw new Error(`Unknown type ${type}`); + } + let _3digitSubtype = `${subtype}`; + while (_3digitSubtype.length < 3) { + _3digitSubtype = `0${_3digitSubtype}`; + } + const dptSubtype = dpt.subtypes.ids[_3digitSubtype]; + if (dptSubtype == null) { + throw new Error(`Invalid subtype ${subtype} for type DPT${type}`); + } + return dptSubtype; +}; +//# sourceMappingURL=DataPointFactory.js.map \ No newline at end of file diff --git a/lib/DataPoints/DataPointFactory.js.map b/lib/DataPoints/DataPointFactory.js.map new file mode 100644 index 0000000..95190a9 --- /dev/null +++ b/lib/DataPoints/DataPointFactory.js.map @@ -0,0 +1 @@ +{"version":3,"file":"DataPointFactory.js","sourceRoot":"","sources":["../../src/DataPoints/DataPointFactory.ts"],"names":[],"mappings":";;;;;;AAGA,oDAA4B;AAC5B,oDAA4B;AAC5B,sDAA8B;AAC9B,kDAA0B;AAC1B,sEAA8C;AAC9C,sDAA8B;AAC9B,gDAAwB;AACxB,8DAAsC;AACtC,4EAAoD;AACpD,oDAA4B;AAC5B,kEAA0C;AAC1C,oDAA4B;AAC5B,4DAAoC;AACpC,kDAA0B;AAC1B,sDAA8B;AAC9B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gB,IAAI,EAAE,CAAC,CAAC;KAC3C;IACD,IAAI,cAAc,GAAG,GAAG,OAAO,EAAE,CAAC;IAClC,OAAO,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE;QAC9B,cAAc,GAAG,IAAI,cAAc,EAAE,CAAC;KACzC;IACD,MAAM,UAAU,GAAG,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IACpD,IAAI,UAAU,IAAI,IAAI,EAAE;QACpB,MAAM,IAAI,KAAK,CAAC,mBAAmB,OAAO,gBAAgB,IAAI,EAAE,CAAC,CAAC;KACrE;IACD,OAAO,UAAU,CAAC;AACtB,CAAC,CAAC"} \ No newline at end of file diff --git a/lib/DataPoints/DataPointInterface.d.ts b/lib/DataPoints/DataPointInterface.d.ts new file mode 100644 index 0000000..ffabb10 --- /dev/null +++ b/lib/DataPoints/DataPointInterface.d.ts @@ -0,0 +1,13 @@ +import { DataPointType } from '../DataPointTypes/DataPointType'; +import { KNXTunnelSocket } from '../KNXTunnelSocket'; +import { DPT10Value } from '../DataPointTypes/DPT10'; +import { DPT3Value } from '../DataPointTypes/DPT3'; +import { DPT18Value } from '../DataPointTypes/DPT18'; +export interface IDataPoint { + id: string; + value: any; + type: DataPointType; + bind: (knxTunnelSocket: KNXTunnelSocket) => void; + read: () => Promise; + write: (val: string | number | DPT10Value | DPT3Value | Date | DPT18Value | null) => Promise; +} diff --git a/lib/DataPoints/DataPointInterface.js b/lib/DataPoints/DataPointInterface.js new file mode 100644 index 0000000..45704b0 --- /dev/null +++ b/lib/DataPoints/DataPointInterface.js @@ -0,0 +1,3 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//# sourceMappingURL=DataPointInterface.js.map \ No newline at end of file diff --git a/lib/DataPoints/DataPointInterface.js.map b/lib/DataPoints/DataPointInterface.js.map new file mode 100644 index 0000000..12fbc3f --- /dev/null +++ b/lib/DataPoints/DataPointInterface.js.map @@ -0,0 +1 @@ +{"version":3,"file":"DataPointInterface.js","sourceRoot":"","sources":["../../src/DataPoints/DataPointInterface.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/lib/DataPoints/Date.d.ts b/lib/DataPoints/Date.d.ts new file mode 100644 index 0000000..488c43a --- /dev/null +++ b/lib/DataPoints/Date.d.ts @@ -0,0 +1,18 @@ +import { KNXAddress } from '../protocol/KNXAddress'; +declare const _default: { + new (ga: KNXAddress): { + _knxTunnelSocket: import("..").KNXTunnelSocket; + _value: any; + _actions: import("../DataPointTypes/definitions").DPTActions; + _ga: KNXAddress; + _type: import("../DataPointTypes/DataPointType").DataPointType; + readonly id: string; + readonly value: any; + readonly type: import("../DataPointTypes/DataPointType").DataPointType; + bind(knxTunnelSocket: import("..").KNXTunnelSocket): void; + read(): Promise; + write(val?: string | number | Date | import("../DataPointTypes/DPT3").DPT3Value | import("../DataPointTypes/DPT10").DPT10Value | import("../DataPointTypes/DPT18").DPT18Value): Promise; + }; + readonly UNKOWN_VALUE: string; +}; +export = _default; diff --git a/lib/DataPoints/Date.js b/lib/DataPoints/Date.js new file mode 100644 index 0000000..5b3ce1e --- /dev/null +++ b/lib/DataPoints/Date.js @@ -0,0 +1,9 @@ +"use strict"; +const DataPoint_1 = require("./DataPoint"); +const DataPointTypeFactory_1 = require("../DataPointTypes/DataPointTypeFactory"); +module.exports = class Date extends DataPoint_1.DataPoint { + constructor(ga) { + super(ga, DataPointTypeFactory_1.DPTS.DPTDate); + } +}; +//# sourceMappingURL=Date.js.map \ No newline at end of file diff --git a/lib/DataPoints/Date.js.map b/lib/DataPoints/Date.js.map new file mode 100644 index 0000000..c24f7a2 --- /dev/null +++ b/lib/DataPoints/Date.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Date.js","sourceRoot":"","sources":["../../src/DataPoints/Date.ts"],"names":[],"mappings":";AAOA,2CAAsC;AACtC,iFAA4D;AAG5D,iBAAS,MAAM,IAAK,SAAQ,qBAAS;IACjC,YAAY,EAAc;QACtB,KAAK,CAAC,EAAE,EAAE,2BAAI,CAAC,OAAO,CAAC,CAAC;IAC5B,CAAC;CACJ,CAAC"} \ No newline at end of file diff --git a/lib/DataPoints/Dimmingcontrol.d.ts b/lib/DataPoints/Dimmingcontrol.d.ts new file mode 100644 index 0000000..488c43a --- /dev/null +++ b/lib/DataPoints/Dimmingcontrol.d.ts @@ -0,0 +1,18 @@ +import { KNXAddress } from '../protocol/KNXAddress'; +declare const _default: { + new (ga: KNXAddress): { + _knxTunnelSocket: import("..").KNXTunnelSocket; + _value: any; + _actions: import("../DataPointTypes/definitions").DPTActions; + _ga: KNXAddress; + _type: import("../DataPointTypes/DataPointType").DataPointType; + readonly id: string; + readonly value: any; + readonly type: import("../DataPointTypes/DataPointType").DataPointType; + bind(knxTunnelSocket: import("..").KNXTunnelSocket): void; + read(): Promise; + write(val?: string | number | Date | import("../DataPointTypes/DPT3").DPT3Value | import("../DataPointTypes/DPT10").DPT10Value | import("../DataPointTypes/DPT18").DPT18Value): Promise; + }; + readonly UNKOWN_VALUE: string; +}; +export = _default; diff --git a/lib/DataPoints/Dimmingcontrol.js b/lib/DataPoints/Dimmingcontrol.js new file mode 100644 index 0000000..ea750c8 --- /dev/null +++ b/lib/DataPoints/Dimmingcontrol.js @@ -0,0 +1,9 @@ +'use strict'; +const DataPoint_1 = require("./DataPoint"); +const DataPointTypeFactory_1 = require("../DataPointTypes/DataPointTypeFactory"); +module.exports = class Dimmingcontrol extends DataPoint_1.DataPoint { + constructor(ga) { + super(ga, DataPointTypeFactory_1.DPTS.DPTDimmingcontrol); + } +}; +//# sourceMappingURL=Dimmingcontrol.js.map \ No newline at end of file diff --git a/lib/DataPoints/Dimmingcontrol.js.map b/lib/DataPoints/Dimmingcontrol.js.map new file mode 100644 index 0000000..1285b9d --- /dev/null +++ b/lib/DataPoints/Dimmingcontrol.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Dimmingcontrol.js","sourceRoot":"","sources":["../../src/DataPoints/Dimmingcontrol.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAUb,2CAAsC;AACtC,iFAA4D;AAG5D,iBAAS,MAAM,cAAe,SAAQ,qBAAS;IAC3C,YAAY,EAAc;QACtB,KAAK,CAAC,EAAE,EAAE,2BAAI,CAAC,iBAAiB,CAAC,CAAC;IACtC,CAAC;CACJ,CAAC"} \ No newline at end of file diff --git a/lib/DataPoints/Enable.d.ts b/lib/DataPoints/Enable.d.ts new file mode 100644 index 0000000..488c43a --- /dev/null +++ b/lib/DataPoints/Enable.d.ts @@ -0,0 +1,18 @@ +import { KNXAddress } from '../protocol/KNXAddress'; +declare const _default: { + new (ga: KNXAddress): { + _knxTunnelSocket: import("..").KNXTunnelSocket; + _value: any; + _actions: import("../DataPointTypes/definitions").DPTActions; + _ga: KNXAddress; + _type: import("../DataPointTypes/DataPointType").DataPointType; + readonly id: string; + readonly value: any; + readonly type: import("../DataPointTypes/DataPointType").DataPointType; + bind(knxTunnelSocket: import("..").KNXTunnelSocket): void; + read(): Promise; + write(val?: string | number | Date | import("../DataPointTypes/DPT3").DPT3Value | import("../DataPointTypes/DPT10").DPT10Value | import("../DataPointTypes/DPT18").DPT18Value): Promise; + }; + readonly UNKOWN_VALUE: string; +}; +export = _default; diff --git a/lib/DataPoints/Enable.js b/lib/DataPoints/Enable.js new file mode 100644 index 0000000..628f9fe --- /dev/null +++ b/lib/DataPoints/Enable.js @@ -0,0 +1,9 @@ +"use strict"; +const DataPoint_1 = require("./DataPoint"); +const DataPointTypeFactory_1 = require("../DataPointTypes/DataPointTypeFactory"); +module.exports = class Enable extends DataPoint_1.DataPoint { + constructor(ga) { + super(ga, DataPointTypeFactory_1.DPTS.DPTEnable); + } +}; +//# sourceMappingURL=Enable.js.map \ No newline at end of file diff --git a/lib/DataPoints/Enable.js.map b/lib/DataPoints/Enable.js.map new file mode 100644 index 0000000..6c71d60 --- /dev/null +++ b/lib/DataPoints/Enable.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Enable.js","sourceRoot":"","sources":["../../src/DataPoints/Enable.ts"],"names":[],"mappings":";AAAA,2CAAsC;AACtC,iFAA4D;AAG5D,iBAAS,MAAM,MAAO,SAAQ,qBAAS;IACnC,YAAY,EAAc;QACtB,KAAK,CAAC,EAAE,EAAE,2BAAI,CAAC,SAAS,CAAC,CAAC;IAC9B,CAAC;CACJ,CAAC"} \ No newline at end of file diff --git a/lib/DataPoints/Lux.d.ts b/lib/DataPoints/Lux.d.ts new file mode 100644 index 0000000..488c43a --- /dev/null +++ b/lib/DataPoints/Lux.d.ts @@ -0,0 +1,18 @@ +import { KNXAddress } from '../protocol/KNXAddress'; +declare const _default: { + new (ga: KNXAddress): { + _knxTunnelSocket: import("..").KNXTunnelSocket; + _value: any; + _actions: import("../DataPointTypes/definitions").DPTActions; + _ga: KNXAddress; + _type: import("../DataPointTypes/DataPointType").DataPointType; + readonly id: string; + readonly value: any; + readonly type: import("../DataPointTypes/DataPointType").DataPointType; + bind(knxTunnelSocket: import("..").KNXTunnelSocket): void; + read(): Promise; + write(val?: string | number | Date | import("../DataPointTypes/DPT3").DPT3Value | import("../DataPointTypes/DPT10").DPT10Value | import("../DataPointTypes/DPT18").DPT18Value): Promise; + }; + readonly UNKOWN_VALUE: string; +}; +export = _default; diff --git a/lib/DataPoints/Lux.js b/lib/DataPoints/Lux.js new file mode 100644 index 0000000..921ce7b --- /dev/null +++ b/lib/DataPoints/Lux.js @@ -0,0 +1,9 @@ +"use strict"; +const DataPoint_1 = require("./DataPoint"); +const DataPointTypeFactory_1 = require("../DataPointTypes/DataPointTypeFactory"); +module.exports = class Lux extends DataPoint_1.DataPoint { + constructor(ga) { + super(ga, DataPointTypeFactory_1.DPTS.DPTLux); + } +}; +//# sourceMappingURL=Lux.js.map \ No newline at end of file diff --git a/lib/DataPoints/Lux.js.map b/lib/DataPoints/Lux.js.map new file mode 100644 index 0000000..a33df5b --- /dev/null +++ b/lib/DataPoints/Lux.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Lux.js","sourceRoot":"","sources":["../../src/DataPoints/Lux.ts"],"names":[],"mappings":";AASA,2CAAsC;AACtC,iFAA4D;AAG5D,iBAAS,MAAM,GAAI,SAAQ,qBAAS;IAChC,YAAY,EAAc;QACtB,KAAK,CAAC,EAAE,EAAE,2BAAI,CAAC,MAAM,CAAC,CAAC;IAC3B,CAAC;CACJ,CAAC"} \ No newline at end of file diff --git a/lib/DataPoints/Percentage.d.ts b/lib/DataPoints/Percentage.d.ts new file mode 100644 index 0000000..4b07b50 --- /dev/null +++ b/lib/DataPoints/Percentage.d.ts @@ -0,0 +1,21 @@ +import { KNXAddress } from '../protocol/KNXAddress'; +declare const _default: { + new (ga: KNXAddress): { + set(param: { + value: number; + }): void; + _knxTunnelSocket: import("..").KNXTunnelSocket; + _value: any; + _actions: import("../DataPointTypes/definitions").DPTActions; + _ga: KNXAddress; + _type: import("../DataPointTypes/DataPointType").DataPointType; + readonly id: string; + readonly value: any; + readonly type: import("../DataPointTypes/DataPointType").DataPointType; + bind(knxTunnelSocket: import("..").KNXTunnelSocket): void; + read(): Promise; + write(val?: string | number | Date | import("../DataPointTypes/DPT3").DPT3Value | import("../DataPointTypes/DPT10").DPT10Value | import("../DataPointTypes/DPT18").DPT18Value): Promise; + }; + readonly UNKOWN_VALUE: string; +}; +export = _default; diff --git a/lib/DataPoints/Percentage.js b/lib/DataPoints/Percentage.js new file mode 100644 index 0000000..fd57eb3 --- /dev/null +++ b/lib/DataPoints/Percentage.js @@ -0,0 +1,32 @@ +'use strict'; +const DataPoint_1 = require("./DataPoint"); +const DataPointTypeFactory_1 = require("../DataPointTypes/DataPointTypeFactory"); +const MIN = 0; +const MAX = 100; +module.exports = class Percentage extends DataPoint_1.DataPoint { + constructor(ga) { + super(ga, DataPointTypeFactory_1.DPTS.DPTPercentage); + this._actions = { + 'set': { + func: this.set.bind(this), + parameterType: { + type: 'integer', + min: MIN, + max: MAX, + default: MIN + } + } + }; + } + set(param) { + if ((param == null) || (param.value == null)) { + throw new Error('Invalid parameter received for set. Expecting {value: number} '); + } + const value = Number(param.value); + if ((value < MIN) || (value > MAX)) { + throw new Error(`Invalid value ${value}`); + } + this.write(value); + } +}; +//# sourceMappingURL=Percentage.js.map \ No newline at end of file diff --git a/lib/DataPoints/Percentage.js.map b/lib/DataPoints/Percentage.js.map new file mode 100644 index 0000000..b631fa4 --- /dev/null +++ b/lib/DataPoints/Percentage.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Percentage.js","sourceRoot":"","sources":["../../src/DataPoints/Percentage.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AASb,2CAAsC;AACtC,iFAA4D;AAG5D,MAAM,GAAG,GAAG,CAAC,CAAC;AACd,MAAM,GAAG,GAAG,GAAG,CAAC;AAEhB,iBAAS,MAAM,UAAW,SAAQ,qBAAS;IACvC,YAAY,EAAc;QACtB,KAAK,CAAC,EAAE,EAAE,2BAAI,CAAC,aAAa,CAAC,CAAC;QAE9B,IAAI,CAAC,QAAQ,GAAG;YACZ,KAAK,EAAE;gBACH,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC;gBACzB,aAAa,EAAE;oBACX,IAAI,EAAE,SAAS;oBACf,GAAG,EAAE,GAAG;oBACR,GAAG,EAAE,GAAG;oBACR,OAAO,EAAE,GAAG;iBACf;aACJ;SACJ,CAAC;IACN,CAAC;IAED,GAAG,CAAC,KAAsB;QACtB,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,IAAI,IAAI,CAAC,EAAE;YAC1C,MAAM,IAAI,KAAK,CAAC,gEAAgE,CAAC,CAAC;SACrF;QACD,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAClC,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC,EAAE;YAChC,MAAM,IAAI,KAAK,CAAC,iBAAiB,KAAK,EAAE,CAAC,CAAC;SAC7C;QACD,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACtB,CAAC;CACJ,CAAC"} \ No newline at end of file diff --git a/lib/DataPoints/Percentagescaling.d.ts b/lib/DataPoints/Percentagescaling.d.ts new file mode 100644 index 0000000..a23ea3d --- /dev/null +++ b/lib/DataPoints/Percentagescaling.d.ts @@ -0,0 +1,19 @@ +import { KNXAddress } from '../protocol/KNXAddress'; +declare const _default: { + new (ga: KNXAddress): { + set(_value: number): void; + _knxTunnelSocket: import("..").KNXTunnelSocket; + _value: any; + _actions: import("../DataPointTypes/definitions").DPTActions; + _ga: KNXAddress; + _type: import("../DataPointTypes/DataPointType").DataPointType; + readonly id: string; + readonly value: any; + readonly type: import("../DataPointTypes/DataPointType").DataPointType; + bind(knxTunnelSocket: import("..").KNXTunnelSocket): void; + read(): Promise; + write(val?: string | number | Date | import("../DataPointTypes/DPT3").DPT3Value | import("../DataPointTypes/DPT10").DPT10Value | import("../DataPointTypes/DPT18").DPT18Value): Promise; + }; + readonly UNKOWN_VALUE: string; +}; +export = _default; diff --git a/lib/DataPoints/Percentagescaling.js b/lib/DataPoints/Percentagescaling.js new file mode 100644 index 0000000..0fb61f7 --- /dev/null +++ b/lib/DataPoints/Percentagescaling.js @@ -0,0 +1,28 @@ +"use strict"; +const DataPoint_1 = require("./DataPoint"); +const DataPointTypeFactory_1 = require("../DataPointTypes/DataPointTypeFactory"); +const MIN = 0; +const MAX = 255; +module.exports = class Percentagescaling extends DataPoint_1.DataPoint { + constructor(ga) { + super(ga, DataPointTypeFactory_1.DPTS.DPTPercentagescaling); + this._actions = { + 'set': { + func: this.set.bind(this), + parameterType: { + type: 'integer', + min: MIN, + max: MAX + } + } + }; + } + set(_value) { + const value = Number(_value); + if ((value < MIN) || (value > MAX)) { + throw new Error(`Invalid value ${value}`); + } + this.write(value); + } +}; +//# sourceMappingURL=Percentagescaling.js.map \ No newline at end of file diff --git a/lib/DataPoints/Percentagescaling.js.map b/lib/DataPoints/Percentagescaling.js.map new file mode 100644 index 0000000..fb4099b --- /dev/null +++ b/lib/DataPoints/Percentagescaling.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Percentagescaling.js","sourceRoot":"","sources":["../../src/DataPoints/Percentagescaling.ts"],"names":[],"mappings":";AAAA,2CAAsC;AACtC,iFAA4D;AAG5D,MAAM,GAAG,GAAG,CAAC,CAAC;AACd,MAAM,GAAG,GAAG,GAAG,CAAC;AAEhB,iBAAS,MAAM,iBAAkB,SAAQ,qBAAS;IAC9C,YAAY,EAAc;QACtB,KAAK,CAAC,EAAE,EAAE,2BAAI,CAAC,oBAAoB,CAAC,CAAC;QAErC,IAAI,CAAC,QAAQ,GAAG;YACZ,KAAK,EAAE;gBACH,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC;gBACzB,aAAa,EAAE;oBACX,IAAI,EAAE,SAAS;oBACf,GAAG,EAAE,GAAG;oBACR,GAAG,EAAE,GAAG;iBACX;aACJ;SACJ,CAAC;IACN,CAAC;IAED,GAAG,CAAC,MAAc;QACd,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;QAC7B,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC,EAAE;YAChC,MAAM,IAAI,KAAK,CAAC,iBAAiB,KAAK,EAAE,CAAC,CAAC;SAC7C;QACD,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACtB,CAAC;CACJ,CAAC"} \ No newline at end of file diff --git a/lib/DataPoints/Scene.d.ts b/lib/DataPoints/Scene.d.ts new file mode 100644 index 0000000..488c43a --- /dev/null +++ b/lib/DataPoints/Scene.d.ts @@ -0,0 +1,18 @@ +import { KNXAddress } from '../protocol/KNXAddress'; +declare const _default: { + new (ga: KNXAddress): { + _knxTunnelSocket: import("..").KNXTunnelSocket; + _value: any; + _actions: import("../DataPointTypes/definitions").DPTActions; + _ga: KNXAddress; + _type: import("../DataPointTypes/DataPointType").DataPointType; + readonly id: string; + readonly value: any; + readonly type: import("../DataPointTypes/DataPointType").DataPointType; + bind(knxTunnelSocket: import("..").KNXTunnelSocket): void; + read(): Promise; + write(val?: string | number | Date | import("../DataPointTypes/DPT3").DPT3Value | import("../DataPointTypes/DPT10").DPT10Value | import("../DataPointTypes/DPT18").DPT18Value): Promise; + }; + readonly UNKOWN_VALUE: string; +}; +export = _default; diff --git a/lib/DataPoints/Scene.js b/lib/DataPoints/Scene.js new file mode 100644 index 0000000..e5ba55e --- /dev/null +++ b/lib/DataPoints/Scene.js @@ -0,0 +1,9 @@ +"use strict"; +const DataPoint_1 = require("./DataPoint"); +const DataPointTypeFactory_1 = require("../DataPointTypes/DataPointTypeFactory"); +module.exports = class Scene extends DataPoint_1.DataPoint { + constructor(ga) { + super(ga, DataPointTypeFactory_1.DPTS.DPTScene); + } +}; +//# sourceMappingURL=Scene.js.map \ No newline at end of file diff --git a/lib/DataPoints/Scene.js.map b/lib/DataPoints/Scene.js.map new file mode 100644 index 0000000..08232fc --- /dev/null +++ b/lib/DataPoints/Scene.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Scene.js","sourceRoot":"","sources":["../../src/DataPoints/Scene.ts"],"names":[],"mappings":";AAAA,2CAAsC;AACtC,iFAA4D;AAG5D,iBAAS,MAAM,KAAM,SAAQ,qBAAS;IAClC,YAAY,EAAc;QACtB,KAAK,CAAC,EAAE,EAAE,2BAAI,CAAC,QAAQ,CAAC,CAAC;IAC7B,CAAC;CACJ,CAAC"} \ No newline at end of file diff --git a/lib/DataPoints/Scenecontrol.d.ts b/lib/DataPoints/Scenecontrol.d.ts new file mode 100644 index 0000000..488c43a --- /dev/null +++ b/lib/DataPoints/Scenecontrol.d.ts @@ -0,0 +1,18 @@ +import { KNXAddress } from '../protocol/KNXAddress'; +declare const _default: { + new (ga: KNXAddress): { + _knxTunnelSocket: import("..").KNXTunnelSocket; + _value: any; + _actions: import("../DataPointTypes/definitions").DPTActions; + _ga: KNXAddress; + _type: import("../DataPointTypes/DataPointType").DataPointType; + readonly id: string; + readonly value: any; + readonly type: import("../DataPointTypes/DataPointType").DataPointType; + bind(knxTunnelSocket: import("..").KNXTunnelSocket): void; + read(): Promise; + write(val?: string | number | Date | import("../DataPointTypes/DPT3").DPT3Value | import("../DataPointTypes/DPT10").DPT10Value | import("../DataPointTypes/DPT18").DPT18Value): Promise; + }; + readonly UNKOWN_VALUE: string; +}; +export = _default; diff --git a/lib/DataPoints/Scenecontrol.js b/lib/DataPoints/Scenecontrol.js new file mode 100644 index 0000000..7c1941d --- /dev/null +++ b/lib/DataPoints/Scenecontrol.js @@ -0,0 +1,9 @@ +"use strict"; +const DataPoint_1 = require("./DataPoint"); +const DataPointTypeFactory_1 = require("../DataPointTypes/DataPointTypeFactory"); +module.exports = class Scenecontrol extends DataPoint_1.DataPoint { + constructor(ga) { + super(ga, DataPointTypeFactory_1.DPTS.DPTScenecontrol); + } +}; +//# sourceMappingURL=Scenecontrol.js.map \ No newline at end of file diff --git a/lib/DataPoints/Scenecontrol.js.map b/lib/DataPoints/Scenecontrol.js.map new file mode 100644 index 0000000..1a9360d --- /dev/null +++ b/lib/DataPoints/Scenecontrol.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Scenecontrol.js","sourceRoot":"","sources":["../../src/DataPoints/Scenecontrol.ts"],"names":[],"mappings":";AAAA,2CAAsC;AACtC,iFAA4D;AAG5D,iBAAS,MAAM,YAAa,SAAQ,qBAAS;IACzC,YAAY,EAAc;QACtB,KAAK,CAAC,EAAE,EAAE,2BAAI,CAAC,eAAe,CAAC,CAAC;IACpC,CAAC;CACJ,CAAC"} \ No newline at end of file diff --git a/lib/DataPoints/Speed.d.ts b/lib/DataPoints/Speed.d.ts new file mode 100644 index 0000000..488c43a --- /dev/null +++ b/lib/DataPoints/Speed.d.ts @@ -0,0 +1,18 @@ +import { KNXAddress } from '../protocol/KNXAddress'; +declare const _default: { + new (ga: KNXAddress): { + _knxTunnelSocket: import("..").KNXTunnelSocket; + _value: any; + _actions: import("../DataPointTypes/definitions").DPTActions; + _ga: KNXAddress; + _type: import("../DataPointTypes/DataPointType").DataPointType; + readonly id: string; + readonly value: any; + readonly type: import("../DataPointTypes/DataPointType").DataPointType; + bind(knxTunnelSocket: import("..").KNXTunnelSocket): void; + read(): Promise; + write(val?: string | number | Date | import("../DataPointTypes/DPT3").DPT3Value | import("../DataPointTypes/DPT10").DPT10Value | import("../DataPointTypes/DPT18").DPT18Value): Promise; + }; + readonly UNKOWN_VALUE: string; +}; +export = _default; diff --git a/lib/DataPoints/Speed.js b/lib/DataPoints/Speed.js new file mode 100644 index 0000000..a3ed999 --- /dev/null +++ b/lib/DataPoints/Speed.js @@ -0,0 +1,9 @@ +"use strict"; +const DataPoint_1 = require("./DataPoint"); +const DataPointTypeFactory_1 = require("../DataPointTypes/DataPointTypeFactory"); +module.exports = class Speed extends DataPoint_1.DataPoint { + constructor(ga) { + super(ga, DataPointTypeFactory_1.DPTS.DPTSpeed); + } +}; +//# sourceMappingURL=Speed.js.map \ No newline at end of file diff --git a/lib/DataPoints/Speed.js.map b/lib/DataPoints/Speed.js.map new file mode 100644 index 0000000..8186c6b --- /dev/null +++ b/lib/DataPoints/Speed.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Speed.js","sourceRoot":"","sources":["../../src/DataPoints/Speed.ts"],"names":[],"mappings":";AAAA,2CAAsC;AACtC,iFAA4D;AAG5D,iBAAS,MAAM,KAAM,SAAQ,qBAAS;IAClC,YAAY,EAAc;QACtB,KAAK,CAAC,EAAE,EAAE,2BAAI,CAAC,QAAQ,CAAC,CAAC;IAC7B,CAAC;CACJ,CAAC"} \ No newline at end of file diff --git a/lib/DataPoints/Startstop.d.ts b/lib/DataPoints/Startstop.d.ts new file mode 100644 index 0000000..488c43a --- /dev/null +++ b/lib/DataPoints/Startstop.d.ts @@ -0,0 +1,18 @@ +import { KNXAddress } from '../protocol/KNXAddress'; +declare const _default: { + new (ga: KNXAddress): { + _knxTunnelSocket: import("..").KNXTunnelSocket; + _value: any; + _actions: import("../DataPointTypes/definitions").DPTActions; + _ga: KNXAddress; + _type: import("../DataPointTypes/DataPointType").DataPointType; + readonly id: string; + readonly value: any; + readonly type: import("../DataPointTypes/DataPointType").DataPointType; + bind(knxTunnelSocket: import("..").KNXTunnelSocket): void; + read(): Promise; + write(val?: string | number | Date | import("../DataPointTypes/DPT3").DPT3Value | import("../DataPointTypes/DPT10").DPT10Value | import("../DataPointTypes/DPT18").DPT18Value): Promise; + }; + readonly UNKOWN_VALUE: string; +}; +export = _default; diff --git a/lib/DataPoints/Startstop.js b/lib/DataPoints/Startstop.js new file mode 100644 index 0000000..c702154 --- /dev/null +++ b/lib/DataPoints/Startstop.js @@ -0,0 +1,9 @@ +"use strict"; +const DataPoint_1 = require("./DataPoint"); +const DataPointTypeFactory_1 = require("../DataPointTypes/DataPointTypeFactory"); +module.exports = class Startstop extends DataPoint_1.DataPoint { + constructor(ga) { + super(ga, DataPointTypeFactory_1.DPTS.DPTStartstop); + } +}; +//# sourceMappingURL=Startstop.js.map \ No newline at end of file diff --git a/lib/DataPoints/Startstop.js.map b/lib/DataPoints/Startstop.js.map new file mode 100644 index 0000000..9136034 --- /dev/null +++ b/lib/DataPoints/Startstop.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Startstop.js","sourceRoot":"","sources":["../../src/DataPoints/Startstop.ts"],"names":[],"mappings":";AAAA,2CAAsC;AACtC,iFAA4D;AAG5D,iBAAS,MAAM,SAAU,SAAQ,qBAAS;IACtC,YAAY,EAAc;QACtB,KAAK,CAAC,EAAE,EAAE,2BAAI,CAAC,YAAY,CAAC,CAAC;IACjC,CAAC;CACJ,CAAC"} \ No newline at end of file diff --git a/lib/DataPoints/Step.d.ts b/lib/DataPoints/Step.d.ts new file mode 100644 index 0000000..488c43a --- /dev/null +++ b/lib/DataPoints/Step.d.ts @@ -0,0 +1,18 @@ +import { KNXAddress } from '../protocol/KNXAddress'; +declare const _default: { + new (ga: KNXAddress): { + _knxTunnelSocket: import("..").KNXTunnelSocket; + _value: any; + _actions: import("../DataPointTypes/definitions").DPTActions; + _ga: KNXAddress; + _type: import("../DataPointTypes/DataPointType").DataPointType; + readonly id: string; + readonly value: any; + readonly type: import("../DataPointTypes/DataPointType").DataPointType; + bind(knxTunnelSocket: import("..").KNXTunnelSocket): void; + read(): Promise; + write(val?: string | number | Date | import("../DataPointTypes/DPT3").DPT3Value | import("../DataPointTypes/DPT10").DPT10Value | import("../DataPointTypes/DPT18").DPT18Value): Promise; + }; + readonly UNKOWN_VALUE: string; +}; +export = _default; diff --git a/lib/DataPoints/Step.js b/lib/DataPoints/Step.js new file mode 100644 index 0000000..3e91b34 --- /dev/null +++ b/lib/DataPoints/Step.js @@ -0,0 +1,9 @@ +"use strict"; +const DataPoint_1 = require("./DataPoint"); +const DataPointTypeFactory_1 = require("../DataPointTypes/DataPointTypeFactory"); +module.exports = class Step extends DataPoint_1.DataPoint { + constructor(ga) { + super(ga, DataPointTypeFactory_1.DPTS.DPTStep); + } +}; +//# sourceMappingURL=Step.js.map \ No newline at end of file diff --git a/lib/DataPoints/Step.js.map b/lib/DataPoints/Step.js.map new file mode 100644 index 0000000..55c3c63 --- /dev/null +++ b/lib/DataPoints/Step.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Step.js","sourceRoot":"","sources":["../../src/DataPoints/Step.ts"],"names":[],"mappings":";AAAA,2CAAsC;AACtC,iFAA4D;AAY5D,iBAAS,MAAM,IAAK,SAAQ,qBAAS;IACjC,YAAY,EAAc;QACtB,KAAK,CAAC,EAAE,EAAE,2BAAI,CAAC,OAAO,CAAC,CAAC;IAC5B,CAAC;CACJ,CAAC"} \ No newline at end of file diff --git a/lib/DataPoints/Switch.d.ts b/lib/DataPoints/Switch.d.ts new file mode 100644 index 0000000..7bc9da9 --- /dev/null +++ b/lib/DataPoints/Switch.d.ts @@ -0,0 +1,20 @@ +import { KNXAddress } from '../protocol/KNXAddress'; +declare const _default: { + new (ga: KNXAddress): { + setOff(): void; + setOn(): void; + _knxTunnelSocket: import("..").KNXTunnelSocket; + _value: any; + _actions: import("../DataPointTypes/definitions").DPTActions; + _ga: KNXAddress; + _type: import("../DataPointTypes/DataPointType").DataPointType; + readonly id: string; + readonly value: any; + readonly type: import("../DataPointTypes/DataPointType").DataPointType; + bind(knxTunnelSocket: import("..").KNXTunnelSocket): void; + read(): Promise; + write(val?: string | number | Date | import("../DataPointTypes/DPT3").DPT3Value | import("../DataPointTypes/DPT10").DPT10Value | import("../DataPointTypes/DPT18").DPT18Value): Promise; + }; + readonly UNKOWN_VALUE: string; +}; +export = _default; diff --git a/lib/DataPoints/Switch.js b/lib/DataPoints/Switch.js new file mode 100644 index 0000000..16112b9 --- /dev/null +++ b/lib/DataPoints/Switch.js @@ -0,0 +1,19 @@ +"use strict"; +const DataPoint_1 = require("./DataPoint"); +const DataPointTypeFactory_1 = require("../DataPointTypes/DataPointTypeFactory"); +module.exports = class Switch extends DataPoint_1.DataPoint { + constructor(ga) { + super(ga, DataPointTypeFactory_1.DPTS.DPTSwitch); + this._actions = { + 'off': { func: this.setOff.bind(this), parameterType: null }, + 'on': { func: this.setOn.bind(this), parameterType: null } + }; + } + setOff() { + this.write(0); + } + setOn() { + this.write(1); + } +}; +//# sourceMappingURL=Switch.js.map \ No newline at end of file diff --git a/lib/DataPoints/Switch.js.map b/lib/DataPoints/Switch.js.map new file mode 100644 index 0000000..5e23aa6 --- /dev/null +++ b/lib/DataPoints/Switch.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Switch.js","sourceRoot":"","sources":["../../src/DataPoints/Switch.ts"],"names":[],"mappings":";AAAA,2CAAsC;AACtC,iFAA4D;AAY5D,iBAAS,MAAM,MAAO,SAAQ,qBAAS;IACnC,YAAY,EAAc;QACtB,KAAK,CAAC,EAAE,EAAE,2BAAI,CAAC,SAAS,CAAC,CAAC;QAC1B,IAAI,CAAC,QAAQ,GAAG;YACZ,KAAK,EAAE,EAAC,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,aAAa,EAAE,IAAI,EAAC;YAC1D,IAAI,EAAE,EAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,aAAa,EAAE,IAAI,EAAC;SAC3D,CAAC;IACN,CAAC;IAKD,MAAM;QACF,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAKD,KAAK;QACD,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;CACJ,CAAC"} \ No newline at end of file diff --git a/lib/DataPoints/Temperature.d.ts b/lib/DataPoints/Temperature.d.ts new file mode 100644 index 0000000..488c43a --- /dev/null +++ b/lib/DataPoints/Temperature.d.ts @@ -0,0 +1,18 @@ +import { KNXAddress } from '../protocol/KNXAddress'; +declare const _default: { + new (ga: KNXAddress): { + _knxTunnelSocket: import("..").KNXTunnelSocket; + _value: any; + _actions: import("../DataPointTypes/definitions").DPTActions; + _ga: KNXAddress; + _type: import("../DataPointTypes/DataPointType").DataPointType; + readonly id: string; + readonly value: any; + readonly type: import("../DataPointTypes/DataPointType").DataPointType; + bind(knxTunnelSocket: import("..").KNXTunnelSocket): void; + read(): Promise; + write(val?: string | number | Date | import("../DataPointTypes/DPT3").DPT3Value | import("../DataPointTypes/DPT10").DPT10Value | import("../DataPointTypes/DPT18").DPT18Value): Promise; + }; + readonly UNKOWN_VALUE: string; +}; +export = _default; diff --git a/lib/DataPoints/Temperature.js b/lib/DataPoints/Temperature.js new file mode 100644 index 0000000..2a62ed7 --- /dev/null +++ b/lib/DataPoints/Temperature.js @@ -0,0 +1,9 @@ +"use strict"; +const DataPoint_1 = require("./DataPoint"); +const DataPointTypeFactory_1 = require("../DataPointTypes/DataPointTypeFactory"); +module.exports = class Temperature extends DataPoint_1.DataPoint { + constructor(ga) { + super(ga, DataPointTypeFactory_1.DPTS.DPTTemperature); + } +}; +//# sourceMappingURL=Temperature.js.map \ No newline at end of file diff --git a/lib/DataPoints/Temperature.js.map b/lib/DataPoints/Temperature.js.map new file mode 100644 index 0000000..29d3fea --- /dev/null +++ b/lib/DataPoints/Temperature.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Temperature.js","sourceRoot":"","sources":["../../src/DataPoints/Temperature.ts"],"names":[],"mappings":";AAAA,2CAAsC;AACtC,iFAA4D;AAW5D,iBAAS,MAAM,WAAY,SAAQ,qBAAS;IACxC,YAAY,EAAc;QACtB,KAAK,CAAC,EAAE,EAAE,2BAAI,CAAC,cAAc,CAAC,CAAC;IACnC,CAAC;CACJ,CAAC"} \ No newline at end of file diff --git a/lib/DataPoints/Time.d.ts b/lib/DataPoints/Time.d.ts new file mode 100644 index 0000000..488c43a --- /dev/null +++ b/lib/DataPoints/Time.d.ts @@ -0,0 +1,18 @@ +import { KNXAddress } from '../protocol/KNXAddress'; +declare const _default: { + new (ga: KNXAddress): { + _knxTunnelSocket: import("..").KNXTunnelSocket; + _value: any; + _actions: import("../DataPointTypes/definitions").DPTActions; + _ga: KNXAddress; + _type: import("../DataPointTypes/DataPointType").DataPointType; + readonly id: string; + readonly value: any; + readonly type: import("../DataPointTypes/DataPointType").DataPointType; + bind(knxTunnelSocket: import("..").KNXTunnelSocket): void; + read(): Promise; + write(val?: string | number | Date | import("../DataPointTypes/DPT3").DPT3Value | import("../DataPointTypes/DPT10").DPT10Value | import("../DataPointTypes/DPT18").DPT18Value): Promise; + }; + readonly UNKOWN_VALUE: string; +}; +export = _default; diff --git a/lib/DataPoints/Time.js b/lib/DataPoints/Time.js new file mode 100644 index 0000000..c038efc --- /dev/null +++ b/lib/DataPoints/Time.js @@ -0,0 +1,9 @@ +"use strict"; +const DataPoint_1 = require("./DataPoint"); +const DataPointTypeFactory_1 = require("../DataPointTypes/DataPointTypeFactory"); +module.exports = class Time extends DataPoint_1.DataPoint { + constructor(ga) { + super(ga, DataPointTypeFactory_1.DPTS.DPTTime); + } +}; +//# sourceMappingURL=Time.js.map \ No newline at end of file diff --git a/lib/DataPoints/Time.js.map b/lib/DataPoints/Time.js.map new file mode 100644 index 0000000..a411730 --- /dev/null +++ b/lib/DataPoints/Time.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Time.js","sourceRoot":"","sources":["../../src/DataPoints/Time.ts"],"names":[],"mappings":";AAAA,2CAAsC;AACtC,iFAA4D;AAU5D,iBAAS,MAAM,IAAK,SAAQ,qBAAS;IACjC,YAAY,EAAc;QACtB,KAAK,CAAC,EAAE,EAAE,2BAAI,CAAC,OAAO,CAAC,CAAC;IAC5B,CAAC;CACJ,CAAC"} \ No newline at end of file diff --git a/lib/DataPoints/Trigger.d.ts b/lib/DataPoints/Trigger.d.ts new file mode 100644 index 0000000..488c43a --- /dev/null +++ b/lib/DataPoints/Trigger.d.ts @@ -0,0 +1,18 @@ +import { KNXAddress } from '../protocol/KNXAddress'; +declare const _default: { + new (ga: KNXAddress): { + _knxTunnelSocket: import("..").KNXTunnelSocket; + _value: any; + _actions: import("../DataPointTypes/definitions").DPTActions; + _ga: KNXAddress; + _type: import("../DataPointTypes/DataPointType").DataPointType; + readonly id: string; + readonly value: any; + readonly type: import("../DataPointTypes/DataPointType").DataPointType; + bind(knxTunnelSocket: import("..").KNXTunnelSocket): void; + read(): Promise; + write(val?: string | number | Date | import("../DataPointTypes/DPT3").DPT3Value | import("../DataPointTypes/DPT10").DPT10Value | import("../DataPointTypes/DPT18").DPT18Value): Promise; + }; + readonly UNKOWN_VALUE: string; +}; +export = _default; diff --git a/lib/DataPoints/Trigger.js b/lib/DataPoints/Trigger.js new file mode 100644 index 0000000..ff611cc --- /dev/null +++ b/lib/DataPoints/Trigger.js @@ -0,0 +1,9 @@ +"use strict"; +const DataPoint_1 = require("./DataPoint"); +const DataPointTypeFactory_1 = require("../DataPointTypes/DataPointTypeFactory"); +module.exports = class Trigger extends DataPoint_1.DataPoint { + constructor(ga) { + super(ga, DataPointTypeFactory_1.DPTS.DPTTrigger); + } +}; +//# sourceMappingURL=Trigger.js.map \ No newline at end of file diff --git a/lib/DataPoints/Trigger.js.map b/lib/DataPoints/Trigger.js.map new file mode 100644 index 0000000..3fb996d --- /dev/null +++ b/lib/DataPoints/Trigger.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Trigger.js","sourceRoot":"","sources":["../../src/DataPoints/Trigger.ts"],"names":[],"mappings":";AAAA,2CAAsC;AACtC,iFAA4D;AAG5D,iBAAS,MAAM,OAAQ,SAAQ,qBAAS;IACpC,YAAY,EAAc;QACtB,KAAK,CAAC,EAAE,EAAE,2BAAI,CAAC,UAAU,CAAC,CAAC;IAC/B,CAAC;CACJ,CAAC"} \ No newline at end of file diff --git a/lib/DataPoints/Updown.d.ts b/lib/DataPoints/Updown.d.ts new file mode 100644 index 0000000..488c43a --- /dev/null +++ b/lib/DataPoints/Updown.d.ts @@ -0,0 +1,18 @@ +import { KNXAddress } from '../protocol/KNXAddress'; +declare const _default: { + new (ga: KNXAddress): { + _knxTunnelSocket: import("..").KNXTunnelSocket; + _value: any; + _actions: import("../DataPointTypes/definitions").DPTActions; + _ga: KNXAddress; + _type: import("../DataPointTypes/DataPointType").DataPointType; + readonly id: string; + readonly value: any; + readonly type: import("../DataPointTypes/DataPointType").DataPointType; + bind(knxTunnelSocket: import("..").KNXTunnelSocket): void; + read(): Promise; + write(val?: string | number | Date | import("../DataPointTypes/DPT3").DPT3Value | import("../DataPointTypes/DPT10").DPT10Value | import("../DataPointTypes/DPT18").DPT18Value): Promise; + }; + readonly UNKOWN_VALUE: string; +}; +export = _default; diff --git a/lib/DataPoints/Updown.js b/lib/DataPoints/Updown.js new file mode 100644 index 0000000..18702d6 --- /dev/null +++ b/lib/DataPoints/Updown.js @@ -0,0 +1,9 @@ +"use strict"; +const DataPoint_1 = require("./DataPoint"); +const DataPointTypeFactory_1 = require("../DataPointTypes/DataPointTypeFactory"); +module.exports = class Updown extends DataPoint_1.DataPoint { + constructor(ga) { + super(ga, DataPointTypeFactory_1.DPTS.DPTUpdown); + } +}; +//# sourceMappingURL=Updown.js.map \ No newline at end of file diff --git a/lib/DataPoints/Updown.js.map b/lib/DataPoints/Updown.js.map new file mode 100644 index 0000000..69801bf --- /dev/null +++ b/lib/DataPoints/Updown.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Updown.js","sourceRoot":"","sources":["../../src/DataPoints/Updown.ts"],"names":[],"mappings":";AAAA,2CAAsC;AACtC,iFAA4D;AAG5D,iBAAS,MAAM,MAAO,SAAQ,qBAAS;IACnC,YAAY,EAAc;QACtB,KAAK,CAAC,EAAE,EAAE,2BAAI,CAAC,SAAS,CAAC,CAAC;IAC9B,CAAC;CACJ,CAAC"} \ No newline at end of file diff --git a/lib/DataPoints/index.d.ts b/lib/DataPoints/index.d.ts new file mode 100644 index 0000000..10a357e --- /dev/null +++ b/lib/DataPoints/index.d.ts @@ -0,0 +1,21 @@ +export { default as Alarm } from './Alarm'; +export { default as Angle } from './Angle'; +export { default as Binary } from './Binary'; +export { default as Date } from './Date'; +export { default as Dimmingcontrol } from './Dimmingcontrol'; +export { default as Enable } from './Enable'; +export { default as Lux } from './Lux'; +export { default as Percentage } from './Percentage'; +export { default as Percentagescaling } from './Percentagescaling'; +export { default as Scene } from './Scene'; +export { default as Scenecontrol } from './Scenecontrol'; +export { default as Speed } from './Speed'; +export { default as Startstop } from './Startstop'; +export { default as Step } from './Step'; +export { default as Switch } from './Switch'; +export { default as Temperature } from './Temperature'; +export { default as Time } from './Time'; +export { default as Trigger } from './Trigger'; +export { default as Updown } from './Updown'; +export { DataPoint } from './DataPoint'; +export { createDataPoint, getDataPointType } from './DataPointFactory'; diff --git a/lib/DataPoints/index.js b/lib/DataPoints/index.js new file mode 100644 index 0000000..485a3aa --- /dev/null +++ b/lib/DataPoints/index.js @@ -0,0 +1,46 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var Alarm_1 = require("./Alarm"); +Object.defineProperty(exports, "Alarm", { enumerable: true, get: function () { return Alarm_1.default; } }); +var Angle_1 = require("./Angle"); +Object.defineProperty(exports, "Angle", { enumerable: true, get: function () { return Angle_1.default; } }); +var Binary_1 = require("./Binary"); +Object.defineProperty(exports, "Binary", { enumerable: true, get: function () { return Binary_1.default; } }); +var Date_1 = require("./Date"); +Object.defineProperty(exports, "Date", { enumerable: true, get: function () { return Date_1.default; } }); +var Dimmingcontrol_1 = require("./Dimmingcontrol"); +Object.defineProperty(exports, "Dimmingcontrol", { enumerable: true, get: function () { return Dimmingcontrol_1.default; } }); +var Enable_1 = require("./Enable"); +Object.defineProperty(exports, "Enable", { enumerable: true, get: function () { return Enable_1.default; } }); +var Lux_1 = require("./Lux"); +Object.defineProperty(exports, "Lux", { enumerable: true, get: function () { return Lux_1.default; } }); +var Percentage_1 = require("./Percentage"); +Object.defineProperty(exports, "Percentage", { enumerable: true, get: function () { return Percentage_1.default; } }); +var Percentagescaling_1 = require("./Percentagescaling"); +Object.defineProperty(exports, "Percentagescaling", { enumerable: true, get: function () { return Percentagescaling_1.default; } }); +var Scene_1 = require("./Scene"); +Object.defineProperty(exports, "Scene", { enumerable: true, get: function () { return Scene_1.default; } }); +var Scenecontrol_1 = require("./Scenecontrol"); +Object.defineProperty(exports, "Scenecontrol", { enumerable: true, get: function () { return Scenecontrol_1.default; } }); +var Speed_1 = require("./Speed"); +Object.defineProperty(exports, "Speed", { enumerable: true, get: function () { return Speed_1.default; } }); +var Startstop_1 = require("./Startstop"); +Object.defineProperty(exports, "Startstop", { enumerable: true, get: function () { return Startstop_1.default; } }); +var Step_1 = require("./Step"); +Object.defineProperty(exports, "Step", { enumerable: true, get: function () { return Step_1.default; } }); +var Switch_1 = require("./Switch"); +Object.defineProperty(exports, "Switch", { enumerable: true, get: function () { return Switch_1.default; } }); +var Temperature_1 = require("./Temperature"); +Object.defineProperty(exports, "Temperature", { enumerable: true, get: function () { return Temperature_1.default; } }); +var Time_1 = require("./Time"); +Object.defineProperty(exports, "Time", { enumerable: true, get: function () { return Time_1.default; } }); +var Trigger_1 = require("./Trigger"); +Object.defineProperty(exports, "Trigger", { enumerable: true, get: function () { return Trigger_1.default; } }); +var Updown_1 = require("./Updown"); +Object.defineProperty(exports, "Updown", { enumerable: true, get: function () { return Updown_1.default; } }); +var DataPoint_1 = require("./DataPoint"); +Object.defineProperty(exports, "DataPoint", { enumerable: true, get: function () { return DataPoint_1.DataPoint; } }); +var DataPointFactory_1 = require("./DataPointFactory"); +Object.defineProperty(exports, "createDataPoint", { enumerable: true, get: function () { return DataPointFactory_1.createDataPoint; } }); +Object.defineProperty(exports, "getDataPointType", { enumerable: true, get: function () { return DataPointFactory_1.getDataPointType; } }); +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/lib/DataPoints/index.js.map b/lib/DataPoints/index.js.map new file mode 100644 index 0000000..f4d5490 --- /dev/null +++ b/lib/DataPoints/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/DataPoints/index.ts"],"names":[],"mappings":";;AAAA,iCAA4C;AAAlC,8FAAA,OAAO,OAAS;AAC1B,iCAA6C;AAAnC,8FAAA,OAAO,OAAU;AAC3B,mCAA+C;AAArC,gGAAA,OAAO,OAAW;AAC5B,+BAA2C;AAAjC,4FAAA,OAAO,OAAS;AAC1B,mDAA+D;AAArD,gHAAA,OAAO,OAAmB;AACpC,mCAA+C;AAArC,gGAAA,OAAO,OAAW;AAC5B,6BAAyC;AAA/B,0FAAA,OAAO,OAAQ;AACzB,2CAAuD;AAA7C,wGAAA,OAAO,OAAe;AAChC,yDAAqE;AAA3D,sHAAA,OAAO,OAAsB;AACvC,iCAA6C;AAAnC,8FAAA,OAAO,OAAU;AAC3B,+CAA2D;AAAjD,4GAAA,OAAO,OAAiB;AAClC,iCAA6C;AAAnC,8FAAA,OAAO,OAAU;AAC3B,yCAAqD;AAA3C,sGAAA,OAAO,OAAc;AAC/B,+BAA2C;AAAjC,4FAAA,OAAO,OAAS;AAC1B,mCAA+C;AAArC,gGAAA,OAAO,OAAW;AAC5B,6CAAyD;AAA/C,0GAAA,OAAO,OAAgB;AACjC,+BAA2C;AAAjC,4FAAA,OAAO,OAAS;AAC1B,qCAAkD;AAAxC,kGAAA,OAAO,OAAa;AAC9B,mCAAgD;AAAtC,gGAAA,OAAO,OAAY;AAC7B,yCAAwC;AAA/B,sGAAA,SAAS,OAAA;AAClB,uDAAuE;AAA9D,mHAAA,eAAe,OAAA;AAAE,oHAAA,gBAAgB,OAAA"} \ No newline at end of file diff --git a/lib/KNXClient.d.ts b/lib/KNXClient.d.ts new file mode 100644 index 0000000..8c28aee --- /dev/null +++ b/lib/KNXClient.d.ts @@ -0,0 +1,60 @@ +/// +import { EventEmitter } from 'events'; +import { KNXPacket } from './protocol/KNXPacket'; +import { KNXDataBuffer } from './protocol/KNXDataBuffer'; +import { KNXAddress } from './protocol/KNXAddress'; +import { TunnelTypes } from './protocol/TunnelCRI'; +declare enum KNXClientEvents { + error = "error", + disconnected = "disconnected", + discover = "discover", + indication = "indication", + connected = "connected", + ready = "ready", + response = "response" +} +export declare class KNXClient extends EventEmitter { + static KNXClientEvents: typeof KNXClientEvents; + get channelID(): number; + private _host; + private _port; + private _peerHost; + private _peerPort; + private _timer; + private _discovery_timer; + private _awaitingResponseType; + private _discoverySocket; + private _clientSocket; + private _clientTunnelSeqNumber; + private _channelID; + private _connectionState; + private _tunnelReqTimer; + private _pendingTunnelAnswer; + constructor(); + bindSocketPort(port: number): void; + send(knxPacket: KNXPacket, host?: string, port?: number): void; + sendWriteRequest(srcAddress: KNXAddress, dstAddress: KNXAddress, data: KNXDataBuffer, cb?: (e: Error) => void, host?: string, port?: number): void; + sendReadRequest(srcAddress: KNXAddress, dstAddress: KNXAddress, cb?: (e: Error, d?: Buffer) => void, host?: string, port?: number): void; + startDiscovery(host: string, port?: number): void; + stopDiscovery(): void; + getDescription(host: string, port: number): void; + openTunnelConnection(host: string, port: number, knxLayer?: TunnelTypes): void; + getConnectionStatus(host: string, port: number, channelID?: number): void; + disconnect(host: string, port: number, channelID?: number): void; + close(): void; + isConnected(): boolean; + private _incSeqNumber; + private _initDiscoverySocket; + private _handleResponse; + private _keyFromCEMIMessage; + private _setTimerAndCallback; + private _processInboundMessage; + private _sendDescriptionRequestMessage; + private _sendSearchRequestMessage; + private _sendConnectRequestMessage; + private _sendConnectionStateRequestMessage; + private _sendDisconnectRequestMessage; + private _sendDisconnectResponseMessage; + private _bindDiscoverySocket; +} +export {}; diff --git a/lib/KNXClient.js b/lib/KNXClient.js new file mode 100644 index 0000000..5bb9aa8 --- /dev/null +++ b/lib/KNXClient.js @@ -0,0 +1,380 @@ +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.KNXClient = void 0; +const events_1 = require("events"); +const dgram_1 = __importDefault(require("dgram")); +const KNXConstants_1 = require("./protocol/KNXConstants"); +const CEMIConstants_1 = require("./protocol/cEMI/CEMIConstants"); +const CEMIFactory_1 = require("./protocol/cEMI/CEMIFactory"); +const KNXProtocol_1 = require("./protocol/KNXProtocol"); +const KNXConnectResponse_1 = require("./protocol/KNXConnectResponse"); +const HPAI_1 = require("./protocol/HPAI"); +const TunnelCRI_1 = require("./protocol/TunnelCRI"); +var STATE; +(function (STATE) { + STATE[STATE["STARTED"] = 0] = "STARTED"; + STATE[STATE["CONNECTING"] = 3] = "CONNECTING"; + STATE[STATE["CONNECTED"] = 4] = "CONNECTED"; + STATE[STATE["DISCONNECTING"] = 5] = "DISCONNECTING"; +})(STATE || (STATE = {})); +var TUNNELSTATE; +(function (TUNNELSTATE) { + TUNNELSTATE[TUNNELSTATE["READY"] = 0] = "READY"; +})(TUNNELSTATE || (TUNNELSTATE = {})); +const SocketEvents = { + error: 'error', + message: 'message' +}; +var KNXClientEvents; +(function (KNXClientEvents) { + KNXClientEvents["error"] = "error"; + KNXClientEvents["disconnected"] = "disconnected"; + KNXClientEvents["discover"] = "discover"; + KNXClientEvents["indication"] = "indication"; + KNXClientEvents["connected"] = "connected"; + KNXClientEvents["ready"] = "ready"; + KNXClientEvents["response"] = "response"; +})(KNXClientEvents || (KNXClientEvents = {})); +class KNXClient extends events_1.EventEmitter { + constructor() { + super(); + this._clientTunnelSeqNumber = 0; + this._host = null; + this._port = null; + this._peerHost = null; + this._peerPort = null; + this._timer = null; + this._discovery_timer = null; + this._awaitingResponseType = null; + this._discoverySocket = null; + this._clientSocket = dgram_1.default.createSocket('udp4'); + this._clientTunnelSeqNumber = 0; + this._channelID = null; + this._connectionState = STATE.STARTED; + this._tunnelReqTimer = new Map(); + this._pendingTunnelAnswer = new Map(); + this._processInboundMessage = this._processInboundMessage.bind(this); + this._clientSocket.on('message', this._processInboundMessage); + } + get channelID() { + return this._channelID; + } + bindSocketPort(port) { + try { + this._clientSocket.bind(port, '0.0.0.0'); + } + catch (err) { + this.emit(KNXClient.KNXClientEvents.error, err); + } + } + send(knxPacket, host, port) { + const peerHost = host == null ? this._peerHost : host; + const peerPort = port == null ? this._peerPort : port; + this._clientSocket.send(knxPacket.toBuffer(), peerPort, peerHost, err => { + if (err) { + this.emit(KNXClient.KNXClientEvents.error, err); + } + }); + } + sendWriteRequest(srcAddress, dstAddress, data, cb = null, host, port) { + const key = dstAddress.toString(); + if (this._pendingTunnelAnswer.has(key)) { + const err = new Error(`Requested already pending for ${key}`); + if (cb) { + cb(err); + } + this.emit(KNXClient.KNXClientEvents.error, err); + return; + } + const peerHost = host == null ? this._peerHost : host; + const peerPort = port == null ? this._peerPort : port; + const cEMIMessage = CEMIFactory_1.CEMIFactory.newLDataRequestMessage(true, true, srcAddress, dstAddress, data); + cEMIMessage.control.ack = 1; + cEMIMessage.control.broadcast = 1; + cEMIMessage.control.priority = 3; + cEMIMessage.control.addressType = 1; + cEMIMessage.control.hopCount = 6; + const seqNum = this._incSeqNumber(); + const knxTunnelingRequest = KNXProtocol_1.KNXProtocol.newKNXTunnelingRequest(this._channelID, seqNum, cEMIMessage); + this._setTimerAndCallback(knxTunnelingRequest, cb); + this.send(knxTunnelingRequest, peerHost, peerPort); + } + sendReadRequest(srcAddress, dstAddress, cb = null, host, port) { + const key = dstAddress.toString(); + if (this._pendingTunnelAnswer.has(key)) { + const err = new Error(`Requested already pending for ${key}`); + if (cb) { + cb(err); + } + this.emit(KNXClient.KNXClientEvents.error, err); + return; + } + const peerHost = host == null ? this._peerHost : host; + const peerPort = port == null ? this._peerPort : port; + const cEMIMessage = CEMIFactory_1.CEMIFactory.newLDataRequestMessage(false, true, srcAddress, dstAddress, null); + cEMIMessage.control.ack = 1; + cEMIMessage.control.broadcast = 1; + cEMIMessage.control.priority = 3; + cEMIMessage.control.addressType = 1; + cEMIMessage.control.hopCount = 6; + const seqNum = this._incSeqNumber(); + const knxTunnelingRequest = KNXProtocol_1.KNXProtocol.newKNXTunnelingRequest(this._channelID, seqNum, cEMIMessage); + this._setTimerAndCallback(knxTunnelingRequest, cb); + this.send(knxTunnelingRequest, peerHost, peerPort); + } + startDiscovery(host, port = KNXConstants_1.KNX_CONSTANTS.KNX_PORT) { + this._host = host; + this._port = port; + this._bindDiscoverySocket(host, port); + this._discovery_timer = setTimeout(() => { + this._discovery_timer = null; + }, 1000 * KNXConstants_1.KNX_CONSTANTS.SEARCH_TIMEOUT); + this._sendSearchRequestMessage(); + } + stopDiscovery() { + if (this._discoverySocket == null || this._host == null) { + return; + } + if (this._discovery_timer != null) { + clearTimeout(this._discovery_timer); + this._discovery_timer = null; + } + this._discoverySocket.close(); + this._discoverySocket = null; + } + getDescription(host, port) { + if (this._clientSocket == null) { + throw new Error('No client socket defined'); + } + this._timer = setTimeout(() => { + this._timer = null; + }, 1000 * KNXConstants_1.KNX_CONSTANTS.DEVICE_CONFIGURATION_REQUEST_TIMEOUT); + this._awaitingResponseType = KNXConstants_1.KNX_CONSTANTS.DESCRIPTION_RESPONSE; + this._sendDescriptionRequestMessage(host, port); + } + openTunnelConnection(host, port, knxLayer = TunnelCRI_1.TunnelTypes.TUNNEL_LINKLAYER) { + if (this._clientSocket == null) { + throw new Error('No client socket defined'); + } + const timeoutError = new Error(`Connection timeout to ${host}:${port}`); + this._timer = setTimeout(() => { + this._timer = null; + this.emit(KNXClient.KNXClientEvents.error, timeoutError); + }, 1000 * KNXConstants_1.KNX_CONSTANTS.CONNECT_REQUEST_TIMEOUT); + this._awaitingResponseType = KNXConstants_1.KNX_CONSTANTS.CONNECT_RESPONSE; + this._sendConnectRequestMessage(host, port, new TunnelCRI_1.TunnelCRI(knxLayer)); + } + getConnectionStatus(host, port, channelID) { + if (this._clientSocket == null) { + throw new Error('No client socket defined'); + } + this._timer = setTimeout(() => { + this._timer = null; + }, 1000 * KNXConstants_1.KNX_CONSTANTS.CONNECTIONSTATE_REQUEST_TIMEOUT); + this._awaitingResponseType = KNXConstants_1.KNX_CONSTANTS.CONNECTIONSTATE_RESPONSE; + if (channelID == null) { + channelID = this._channelID; + } + this._sendConnectionStateRequestMessage(host, port, channelID); + } + disconnect(host, port, channelID) { + if (this._clientSocket == null) { + throw new Error('No client socket defined'); + } + this._timer = setTimeout(() => { + this._timer = null; + }, 1000 * KNXConstants_1.KNX_CONSTANTS.CONNECT_REQUEST_TIMEOUT); + this._awaitingResponseType = KNXConstants_1.KNX_CONSTANTS.DISCONNECT_RESPONSE; + this._connectionState = STATE.DISCONNECTING; + if (channelID == null) { + channelID = this._channelID; + } + this._sendDisconnectRequestMessage(host, port, channelID); + } + close() { + if (this._clientSocket) { + this._clientSocket.close(); + this._clientSocket = null; + } + } + isConnected() { + return this._connectionState === STATE.CONNECTED; + } + _incSeqNumber() { + const seq = this._clientTunnelSeqNumber++; + if (this._clientTunnelSeqNumber > 255) { + this._clientTunnelSeqNumber = 0; + } + return seq; + } + _initDiscoverySocket() { + if (this._discoverySocket == null) { + throw new Error('No server socket defined'); + } + this._discoverySocket.on(SocketEvents.error, err => { + this.emit(KNXClient.KNXClientEvents.error, err); + }); + this._discoverySocket.on(SocketEvents.message, this._processInboundMessage); + } + _handleResponse(knxTunnelingResponse) { + const ind = knxTunnelingResponse.cEMIMessage; + const key = this._keyFromCEMIMessage(ind); + if (this._pendingTunnelAnswer.has(key)) { + const { cb, timer, req } = this._pendingTunnelAnswer.get(key); + if (ind.msgCode === CEMIConstants_1.CEMIConstants.L_DATA_CON && + req.cEMIMessage.npdu.action === CEMIConstants_1.CEMIConstants.GROUP_READ) { + return; + } + if (timer) { + clearTimeout(timer); + } + if (cb) { + cb(null, ind.npdu.dataValue); + } + this._pendingTunnelAnswer.delete(key); + } + } + _keyFromCEMIMessage(cEMIMessage) { + return cEMIMessage.dstAddress.toString(); + } + _setTimerAndCallback(knxTunnelingRequest, cb) { + const timeoutErr = new Error(`Request ${knxTunnelingRequest.seqCounter} timed out`); + const key = this._keyFromCEMIMessage(knxTunnelingRequest.cEMIMessage); + this._pendingTunnelAnswer.set(key, { + cb, + timer: setTimeout(() => { + this._pendingTunnelAnswer.delete(key); + if (cb) { + cb(timeoutErr); + } + else { + this.emit(KNXClient.KNXClientEvents.error, timeoutErr); + } + }, KNXConstants_1.KNX_CONSTANTS.TUNNELING_REQUEST_TIMEOUT * 2000), + req: knxTunnelingRequest + }); + this._tunnelReqTimer.set(knxTunnelingRequest.seqCounter, setTimeout(() => { + this._tunnelReqTimer.delete(knxTunnelingRequest.seqCounter); + this._pendingTunnelAnswer.delete(key); + if (cb) { + cb(timeoutErr); + } + else { + this.emit(KNXClient.KNXClientEvents.error, timeoutErr); + } + }, KNXConstants_1.KNX_CONSTANTS.TUNNELING_REQUEST_TIMEOUT * 1000)); + } + _processInboundMessage(msg, rinfo) { + try { + const { knxHeader, knxMessage } = KNXProtocol_1.KNXProtocol.parseMessage(msg); + if (knxHeader.service_type === KNXConstants_1.KNX_CONSTANTS.SEARCH_RESPONSE) { + if (this._discovery_timer == null) { + return; + } + this.emit(KNXClient.KNXClientEvents.discover, `${rinfo.address}:${rinfo.port}`, knxHeader, knxMessage); + } + else if (knxHeader.service_type === KNXConstants_1.KNX_CONSTANTS.CONNECT_RESPONSE) { + if (this._connectionState === STATE.CONNECTING) { + clearTimeout(this._timer); + this._timer = null; + const knxConnectResponse = knxMessage; + if (knxConnectResponse.status !== KNXConstants_1.ConnectionStatus.E_NO_ERROR) { + this._connectionState = STATE.STARTED; + this.emit(KNXClient.KNXClientEvents.error, KNXConnectResponse_1.KNXConnectResponse.statusToString(knxConnectResponse.status)); + return; + } + this._connectionState = STATE.CONNECTED; + this._channelID = knxConnectResponse.channelID; + this.emit(KNXClient.KNXClientEvents.connected, `${rinfo.address}:${rinfo.port}`, this._channelID); + } + } + else if (knxHeader.service_type === KNXConstants_1.KNX_CONSTANTS.DISCONNECT_RESPONSE) { + if (this._connectionState === STATE.DISCONNECTING) { + this._connectionState = STATE.STARTED; + this._channelID = null; + this.emit(KNXClient.KNXClientEvents.disconnected, `${rinfo.address}:${rinfo.port}`, this._channelID); + } + } + else if (knxHeader.service_type === KNXConstants_1.KNX_CONSTANTS.DISCONNECT_REQUEST) { + this._connectionState = STATE.STARTED; + const knxDisconnectRequest = knxMessage; + this._sendDisconnectResponseMessage(rinfo.address, rinfo.port, knxDisconnectRequest.channelID); + this.emit(KNXClient.KNXClientEvents.disconnected, `${rinfo.address}:${rinfo.port}`, knxHeader, knxDisconnectRequest); + } + else if (knxHeader.service_type === KNXConstants_1.KNX_CONSTANTS.TUNNELING_REQUEST) { + const knxTunnelingRequest = knxMessage; + if (knxTunnelingRequest.cEMIMessage.msgCode === CEMIConstants_1.CEMIConstants.L_DATA_IND) { + const ind = knxTunnelingRequest.cEMIMessage; + if (ind.npdu.isGroupResponse) { + this._handleResponse(knxTunnelingRequest); + } + else { + this.emit(KNXClient.KNXClientEvents.indication, ind.srcAddress, ind.dstAddress, ind.npdu); + } + } + else if (knxTunnelingRequest.cEMIMessage.msgCode === CEMIConstants_1.CEMIConstants.L_DATA_CON) { + this._handleResponse(knxTunnelingRequest); + } + const knxTunnelAck = KNXProtocol_1.KNXProtocol.newKNXTunnelingACK(knxTunnelingRequest.channelID, knxTunnelingRequest.seqCounter, KNXConstants_1.KNX_CONSTANTS.E_NO_ERROR); + this.send(knxTunnelAck); + } + else if (knxHeader.service_type === KNXConstants_1.KNX_CONSTANTS.TUNNELING_ACK) { + const knxTunnelingAck = knxMessage; + if (this._tunnelReqTimer.has(knxTunnelingAck.seqCounter)) { + clearTimeout(this._tunnelReqTimer.get(knxTunnelingAck.seqCounter)); + this._tunnelReqTimer.delete(knxTunnelingAck.seqCounter); + } + } + else { + if (knxHeader.service_type === this._awaitingResponseType) { + clearTimeout(this._timer); + } + this.emit(KNXClient.KNXClientEvents.response, `${rinfo.address}:${rinfo.port}`, knxHeader, knxMessage); + } + } + catch (e) { + this.emit(KNXClient.KNXClientEvents.error, e); + } + } + _sendDescriptionRequestMessage(host, port) { + this._clientSocket.send(KNXProtocol_1.KNXProtocol.newKNXDescriptionRequest(new HPAI_1.HPAI(this._host)).toBuffer(), port, host, err => this.emit(KNXClient.KNXClientEvents.error, err)); + } + _sendSearchRequestMessage() { + this._discoverySocket.send(KNXProtocol_1.KNXProtocol.newKNXSearchRequest(new HPAI_1.HPAI(this._host, this._port)).toBuffer(), KNXConstants_1.KNX_CONSTANTS.KNX_PORT, KNXConstants_1.KNX_CONSTANTS.KNX_IP, err => this.emit(KNXClient.KNXClientEvents.error, err)); + } + _sendConnectRequestMessage(host, port, cri) { + this._peerHost = host; + this._peerPort = port; + this._connectionState = STATE.CONNECTING; + this._clientSocket.send(KNXProtocol_1.KNXProtocol.newKNXConnectRequest(cri).toBuffer(), port, host, null); + } + _sendConnectionStateRequestMessage(host, port, channelID) { + this._clientSocket.send(KNXProtocol_1.KNXProtocol.newKNXConnectionStateRequest(channelID).toBuffer(), port, host, err => this.emit(KNXClient.KNXClientEvents.error, err)); + } + _sendDisconnectRequestMessage(host, port, channelID) { + this._connectionState = STATE.DISCONNECTING; + this._clientSocket.send(KNXProtocol_1.KNXProtocol.newKNXDisconnectRequest(channelID).toBuffer(), port, host, err => this.emit(KNXClient.KNXClientEvents.error, err)); + } + _sendDisconnectResponseMessage(host, port, channelID, status = KNXConstants_1.ConnectionStatus.E_NO_ERROR) { + this._clientSocket.send(KNXProtocol_1.KNXProtocol.newKNXDisconnectResponse(channelID, status).toBuffer(), port, host, err => this.emit(KNXClient.KNXClientEvents.error, err)); + } + _bindDiscoverySocket(host, port) { + if (this._discoverySocket != null) { + throw new Error('Discovery socket already binded'); + } + this._discoverySocket = dgram_1.default.createSocket({ type: 'udp4', reuseAddr: true }); + this._initDiscoverySocket(); + this._discoverySocket.bind(port, host, () => { + this._discoverySocket.setMulticastInterface(host); + this._discoverySocket.setMulticastTTL(16); + this._host = host; + this.emit(KNXClient.KNXClientEvents.ready); + }); + } +} +exports.KNXClient = KNXClient; +KNXClient.KNXClientEvents = KNXClientEvents; +//# sourceMappingURL=KNXClient.js.map \ No newline at end of file diff --git a/lib/KNXClient.js.map b/lib/KNXClient.js.map new file mode 100644 index 0000000..266da89 --- /dev/null +++ b/lib/KNXClient.js.map @@ -0,0 +1 @@ +{"version":3,"file":"KNXClient.js","sourceRoot":"","sources":["../src/KNXClient.ts"],"names":[],"mappings":";;;;;;AAAA,mCAAoC;AACpC,kDAA0B;AAC1B,0DAAwE;AACxE,iEAA4D;AAC5D,6DAAwD;AAIxD,wDAAqD;AACrD,sEAAiE;AAGjE,0CAAuC;AAKvC,oDAA8D;AAE9D,IAAK,KAKJ;AALD,WAAK,KAAK;IACN,uCAAW,CAAA;IACX,6CAAc,CAAA;IACd,2CAAa,CAAA;IACb,mDAAiB,CAAA;AACrB,CAAC,EALI,KAAK,KAAL,KAAK,QAKT;AAeD,IAAK,WAEJ;AAFD,WAAK,WAAW;IACZ,+CAAS,CAAA;AACb,CAAC,EAFI,WAAW,KAAX,WAAW,QAEf;AAED,MAAM,YAAY,GAAG;IACjB,KAAK,EAAE,OAAO;IACd,OAAO,EAAE,SAAS;CACrB,CAAC;AAEF,IAAK,eAQJ;AARD,WAAK,eAAe;IAChB,kCAAe,CAAA;IACf,gDAA6B,CAAA;IAC7B,wCAAqB,CAAA;IACrB,4CAAyB,CAAA;IACzB,0CAAuB,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IAAY,EACZ,SAAiB,EACjB,SAA2B,+BAAgB,CAAC,UAAU;QACtD,IAAI,CAAC,aAAa,CAAC,IAAI,CACnB,yBAAW,CAAC,wBAAwB,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC,QAAQ,EAAE,EAClE,IAAI,EACJ,IAAI,EACJ,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,eAAe,CAAC,KAAK,EAAE,GAAG,CAAC,CACzD,CAAC;IACN,CAAC;IAEO,oBAAoB,CAAC,IAAY,EAAE,IAAY;QACnD,IAAI,IAAI,CAAC,gBAAgB,IAAI,IAAI,EAAE;YAC/B,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;SACtD;QACD,IAAI,CAAC,gBAAgB,GAAG,eAAK,CAAC,YAAY,CAAC,EAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAC,CAAC,CAAC;QAC5E,IAAI,CAAC,oBAAoB,EAAE,CAAC;QAC5B,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE;YACxC,IAAI,CAAC,gBAAgB,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC;YAClD,IAAI,CAAC,gBAAgB,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC;YAC1C,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;YAIlB,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;QAC/C,CAAC,CAAC,CAAC;IACP,CAAC;;AAzdL,8BA0dC;AAxdW,yBAAe,GAAG,eAAe,CAAC"} \ No newline at end of file diff --git a/lib/KNXTunnelSocket.d.ts b/lib/KNXTunnelSocket.d.ts new file mode 100644 index 0000000..f6c949b --- /dev/null +++ b/lib/KNXTunnelSocket.d.ts @@ -0,0 +1,32 @@ +/// +import { EventEmitter } from 'events'; +import { KNXAddress } from './protocol/KNXAddress'; +import { KNXDataBuffer } from './protocol/KNXDataBuffer'; +export declare enum KNXTunnelSocketEvents { + disconnected = "disconnected", + indication = "indication", + error = "error" +} +export declare class KNXTunnelSocket extends EventEmitter { + static KNXTunnelSocketEvents: typeof KNXTunnelSocketEvents; + get channelID(): number; + private _knxClient; + private _connectionCB; + private _disconnectCB; + private _monitoringBus; + private _connected; + private _srcAddress; + private _host; + private _port; + constructor(srcAddress?: string, socketPort?: number); + bindSocketPort(port: number): Promise; + close(): void; + connectAsync(host: string, port: number): Promise; + disconnectAsync(): Promise; + writeAsync(dstAddress: KNXAddress, data: KNXDataBuffer): Promise; + readAsync(dstAddress: KNXAddress): Promise; + monitorBus(): void; + stopBusMonitor(): void; + private _init; + private _handleBusEvent; +} diff --git a/lib/KNXTunnelSocket.js b/lib/KNXTunnelSocket.js new file mode 100644 index 0000000..febf4e1 --- /dev/null +++ b/lib/KNXTunnelSocket.js @@ -0,0 +1,157 @@ +'use strict'; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.KNXTunnelSocket = exports.KNXTunnelSocketEvents = void 0; +const events_1 = require("events"); +const KNXClient_1 = require("./KNXClient"); +const KNXAddress_1 = require("./protocol/KNXAddress"); +var KNXTunnelSocketEvents; +(function (KNXTunnelSocketEvents) { + KNXTunnelSocketEvents["disconnected"] = "disconnected"; + KNXTunnelSocketEvents["indication"] = "indication"; + KNXTunnelSocketEvents["error"] = "error"; +})(KNXTunnelSocketEvents = exports.KNXTunnelSocketEvents || (exports.KNXTunnelSocketEvents = {})); +class KNXTunnelSocket extends events_1.EventEmitter { + constructor(srcAddress = null, socketPort) { + super(); + this._knxClient = new KNXClient_1.KNXClient(); + if (socketPort != null) { + this._knxClient.bindSocketPort(socketPort); + } + this._connectionCB = null; + this._disconnectCB = null; + this._monitoringBus = false; + this._connected = false; + this._srcAddress = srcAddress == null ? KNXAddress_1.KNXAddress.createFromString('15.15.200') : KNXAddress_1.KNXAddress.createFromString(srcAddress); + this._handleBusEvent = this._handleBusEvent.bind(this); + this._init(); + } + get channelID() { + return this._knxClient.channelID; + } + bindSocketPort(port) { + if (this._knxClient.isConnected() === true) { + return Promise.reject('Socket already connected'); + } + return new Promise((resolve, reject) => { + try { + this._knxClient.bindSocketPort(port); + resolve(); + } + catch (err) { + reject(err); + } + }); + } + close() { + this._knxClient.close(); + } + connectAsync(host, port) { + if (this._connected) { + return Promise.reject('Already connected'); + } + this._host = host; + this._port = port; + return new Promise((resolve, reject) => { + this._connectionCB = err => { + this._connectionCB = null; + if (err != null) { + reject(err); + } + else { + resolve(); + } + }; + try { + this._knxClient.openTunnelConnection(host, port); + } + catch (err) { + reject(err); + } + }); + } + disconnectAsync() { + return new Promise((resolve, reject) => { + this._disconnectCB = (err) => { + this._disconnectCB = null; + if (err != null) { + reject(err); + } + resolve(); + }; + this._knxClient.disconnect(this._host, this._port); + }); + } + writeAsync(dstAddress, data) { + return new Promise((resolve, reject) => { + this._knxClient.sendWriteRequest(this._srcAddress, dstAddress, data, (err) => { + if (err) { + reject(err); + } + else { + resolve(); + } + }); + }); + } + readAsync(dstAddress) { + return new Promise((resolve, reject) => { + this._knxClient.sendReadRequest(this._srcAddress, dstAddress, (err, data) => { + if (err) { + reject(err); + } + else { + resolve(data); + } + }); + }); + } + monitorBus() { + if (this._knxClient.isConnected() === false) { + throw new Error('Socket not connected'); + } + if (this._monitoringBus) { + return; + } + this._monitoringBus = true; + this._knxClient.on(KNXTunnelSocketEvents.indication, this._handleBusEvent); + } + stopBusMonitor() { + if (this._knxClient.isConnected() === false) { + throw new Error('Socket not connected'); + } + if (this._monitoringBus === false) { + return; + } + this._monitoringBus = false; + this._knxClient.off(KNXTunnelSocketEvents.indication, this._handleBusEvent); + } + _init() { + this._knxClient.on(KNXClient_1.KNXClient.KNXClientEvents.connected, () => { + if (this._connectionCB != null) { + this._connectionCB(); + } + }).on(KNXClient_1.KNXClient.KNXClientEvents.error, (err) => { + if (err == null) { + return; + } + if (this._connectionCB != null) { + this._connectionCB(err); + } + else if (this._disconnectCB != null) { + this._disconnectCB(err); + } + }).on(KNXClient_1.KNXClient.KNXClientEvents.disconnected, () => { + this._connected = false; + if (this._disconnectCB != null) { + this._disconnectCB(); + } + this.emit(KNXTunnelSocketEvents.disconnected); + }); + } + _handleBusEvent(srcAddress, dstAddress, npdu) { + this.emit(KNXTunnelSocketEvents.indication, srcAddress, dstAddress, npdu); + } +} +exports.KNXTunnelSocket = KNXTunnelSocket; +KNXTunnelSocket.KNXTunnelSocketEvents = KNXTunnelSocketEvents; +//# sourceMappingURL=KNXTunnelSocket.js.map \ No newline at end of file diff --git a/lib/KNXTunnelSocket.js.map b/lib/KNXTunnelSocket.js.map new file mode 100644 index 0000000..07ef706 --- /dev/null +++ b/lib/KNXTunnelSocket.js.map @@ -0,0 +1 @@ +{"version":3,"file":"KNXTunnelSocket.js","sourceRoot":"","sources":["../src/KNXTunnelSocket.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AACb,mCAAoC;AACpC,2CAAsC;AACtC,sDAAiD;AAIjD,IAAY,qBAIX;AAJD,WAAY,qBAAqB;IAC7B,sDAA6B,CAAA;IAC7B,kDAAyB,CAAA;IACzB,wCAAe,CAAA;AACnB,CAAC,EAJW,qBAAqB,GAArB,6BAAqB,KAArB,6BAAqB,QAIhC;AAED,MAAa,eAAgB,SAAQ,qBAAY;IAc7C,YAAY,aAAqB,IAAI,EAAE,UAAmB;QACtD,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,UAAU,GAAG,IAAI,qBAAS,EAAE,CAAC;QAClC,IAAI,UAAU,IAAI,IAAI,EAAE;YACpB,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;SAC9C;QACD,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;QAC1B,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;QAC1B,IAAI,CAAC,cAAc,GAAG,KAAK,CAAC;QAC5B,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;QACxB,IAAI,CAAC,WAA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EAAE,CAAC,GAAU,EAAE,EAAE;YAClD,IAAI,GAAG,IAAI,IAAI,EAAE;gBAAE,OAAO;aAAE;YAC5B,IAAI,IAAI,CAAC,aAAa,IAAI,IAAI,EAAE;gBAC5B,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;aAC3B;iBAAM,IAAI,IAAI,CAAC,aAAa,IAAI,IAAI,EAAE;gBACnC,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;aAC3B;QACL,CAAC,CAAC,CAAC,EAAE,CAAC,qBAAS,CAAC,eAAe,CAAC,YAAY,EAAE,GAAG,EAAE;YAC/C,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;YACxB,IAAI,IAAI,CAAC,aAAa,IAAI,IAAI,EAAE;gBAC5B,IAAI,CAAC,aAAa,EAAE,CAAC;aACxB;YACD,IAAI,CAAC,IAAI,CAAC,qBAAqB,CAAC,YAAY,CAAC,CAAC;QAClD,CAAC,CAAC,CAAC;IACP,CAAC;IASO,eAAe,CAAC,UAAsB,EAAE,UAAsB,EAAE,IAAU;QAO9E,IAAI,CAAC,IAAI,CAAC,qBAAqB,CAAC,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,IAAI,CAAC,CAAC;IAC9E,CAAC;;AA5KL,0CA6KC;AA5KU,qCAAqB,GAAG,qBAAqB,CAAC"} \ No newline at end of file diff --git a/lib/index.d.ts b/lib/index.d.ts new file mode 100644 index 0000000..ae0f24e --- /dev/null +++ b/lib/index.d.ts @@ -0,0 +1,31 @@ +export { KNXClient } from './KNXClient'; +export { KNXTunnelSocket } from './KNXTunnelSocket'; +export { KNXAddress } from './protocol/KNXAddress'; +export { DeviceInfo } from './protocol/DeviceInfo'; +export { HPAI } from './protocol/HPAI'; +export { KNXProtocol } from './protocol/KNXProtocol'; +export { NPDU } from './protocol/cEMI/NPDU'; +export { KNXPacket } from './protocol/KNXPacket'; +export { KNXDataBuffer } from './protocol/KNXDataBuffer'; +export { default as Alarm } from './DataPoints/Alarm'; +export { default as Angle } from './DataPoints/Angle'; +export { default as Binary } from './DataPoints/Binary'; +export { default as Date } from './DataPoints/Date'; +export { default as Dimmingcontrol } from './DataPoints/Dimmingcontrol'; +export { default as Enable } from './DataPoints/Enable'; +export { default as Lux } from './DataPoints/Lux'; +export { default as Percentage } from './DataPoints/Percentage'; +export { default as Percentagescaling } from './DataPoints/Percentagescaling'; +export { default as Scene } from './DataPoints/Scene'; +export { default as Scenecontrol } from './DataPoints/Scenecontrol'; +export { default as Speed } from './DataPoints/Speed'; +export { default as Startstop } from './DataPoints/Startstop'; +export { default as Step } from './DataPoints/Step'; +export { default as Switch } from './DataPoints/Switch'; +export { default as Temperature } from './DataPoints/Temperature'; +export { default as Time } from './DataPoints/Time'; +export { default as Trigger } from './DataPoints/Trigger'; +export { default as Updown } from './DataPoints/Updown'; +export { DataPoint } from './DataPoints/DataPoint'; +export { createDataPoint, getDataPointType } from './DataPoints/DataPointFactory'; +export { DPTS as DataPointType } from './DataPointTypes/DataPointTypeFactory'; diff --git a/lib/index.js b/lib/index.js new file mode 100644 index 0000000..017fcb7 --- /dev/null +++ b/lib/index.js @@ -0,0 +1,66 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var KNXClient_1 = require("./KNXClient"); +Object.defineProperty(exports, "KNXClient", { enumerable: true, get: function () { return KNXClient_1.KNXClient; } }); +var KNXTunnelSocket_1 = require("./KNXTunnelSocket"); +Object.defineProperty(exports, "KNXTunnelSocket", { enumerable: true, get: function () { return KNXTunnelSocket_1.KNXTunnelSocket; } }); +var KNXAddress_1 = require("./protocol/KNXAddress"); +Object.defineProperty(exports, "KNXAddress", { enumerable: true, get: function () { return KNXAddress_1.KNXAddress; } }); +var DeviceInfo_1 = require("./protocol/DeviceInfo"); +Object.defineProperty(exports, "DeviceInfo", { enumerable: true, get: function () { return DeviceInfo_1.DeviceInfo; } }); +var HPAI_1 = require("./protocol/HPAI"); +Object.defineProperty(exports, "HPAI", { enumerable: true, get: function () { return HPAI_1.HPAI; } }); +var KNXProtocol_1 = require("./protocol/KNXProtocol"); +Object.defineProperty(exports, "KNXProtocol", { enumerable: true, get: function () { return KNXProtocol_1.KNXProtocol; } }); +var NPDU_1 = require("./protocol/cEMI/NPDU"); +Object.defineProperty(exports, "NPDU", { enumerable: true, get: function () { return NPDU_1.NPDU; } }); +var KNXPacket_1 = require("./protocol/KNXPacket"); +Object.defineProperty(exports, "KNXPacket", { enumerable: true, get: function () { return KNXPacket_1.KNXPacket; } }); +var KNXDataBuffer_1 = require("./protocol/KNXDataBuffer"); +Object.defineProperty(exports, "KNXDataBuffer", { enumerable: true, get: function () { return KNXDataBuffer_1.KNXDataBuffer; } }); +var Alarm_1 = require("./DataPoints/Alarm"); +Object.defineProperty(exports, "Alarm", { enumerable: true, get: function () { return Alarm_1.default; } }); +var Angle_1 = require("./DataPoints/Angle"); +Object.defineProperty(exports, "Angle", { enumerable: true, get: function () { return Angle_1.default; } }); +var Binary_1 = require("./DataPoints/Binary"); +Object.defineProperty(exports, "Binary", { enumerable: true, get: function () { return Binary_1.default; } }); +var Date_1 = require("./DataPoints/Date"); +Object.defineProperty(exports, "Date", { enumerable: true, get: function () { return Date_1.default; } }); +var Dimmingcontrol_1 = require("./DataPoints/Dimmingcontrol"); +Object.defineProperty(exports, "Dimmingcontrol", { enumerable: true, get: function () { return Dimmingcontrol_1.default; } }); +var Enable_1 = require("./DataPoints/Enable"); +Object.defineProperty(exports, "Enable", { enumerable: true, get: function () { return Enable_1.default; } }); +var Lux_1 = require("./DataPoints/Lux"); +Object.defineProperty(exports, "Lux", { enumerable: true, get: function () { return Lux_1.default; } }); +var Percentage_1 = require("./DataPoints/Percentage"); +Object.defineProperty(exports, "Percentage", { enumerable: true, get: function () { return Percentage_1.default; } }); +var Percentagescaling_1 = require("./DataPoints/Percentagescaling"); +Object.defineProperty(exports, "Percentagescaling", { enumerable: true, get: function () { return Percentagescaling_1.default; } }); +var Scene_1 = require("./DataPoints/Scene"); +Object.defineProperty(exports, "Scene", { enumerable: true, get: function () { return Scene_1.default; } }); +var Scenecontrol_1 = require("./DataPoints/Scenecontrol"); +Object.defineProperty(exports, "Scenecontrol", { enumerable: true, get: function () { return Scenecontrol_1.default; } }); +var Speed_1 = require("./DataPoints/Speed"); +Object.defineProperty(exports, "Speed", { enumerable: true, get: function () { return Speed_1.default; } }); +var Startstop_1 = require("./DataPoints/Startstop"); +Object.defineProperty(exports, "Startstop", { enumerable: true, get: function () { return Startstop_1.default; } }); +var Step_1 = require("./DataPoints/Step"); +Object.defineProperty(exports, "Step", { enumerable: true, get: function () { return Step_1.default; } }); +var Switch_1 = require("./DataPoints/Switch"); +Object.defineProperty(exports, "Switch", { enumerable: true, get: function () { return Switch_1.default; } }); +var Temperature_1 = require("./DataPoints/Temperature"); +Object.defineProperty(exports, "Temperature", { enumerable: true, get: function () { return Temperature_1.default; } }); +var Time_1 = require("./DataPoints/Time"); +Object.defineProperty(exports, "Time", { enumerable: true, get: function () { return Time_1.default; } }); +var Trigger_1 = require("./DataPoints/Trigger"); +Object.defineProperty(exports, "Trigger", { enumerable: true, get: function () { return Trigger_1.default; } }); +var Updown_1 = require("./DataPoints/Updown"); +Object.defineProperty(exports, "Updown", { enumerable: true, get: function () { return Updown_1.default; } }); +var DataPoint_1 = require("./DataPoints/DataPoint"); +Object.defineProperty(exports, "DataPoint", { enumerable: true, get: function () { return DataPoint_1.DataPoint; } }); +var DataPointFactory_1 = require("./DataPoints/DataPointFactory"); +Object.defineProperty(exports, "createDataPoint", { enumerable: true, get: function () { return DataPointFactory_1.createDataPoint; } }); +Object.defineProperty(exports, "getDataPointType", { enumerable: true, get: function () { return DataPointFactory_1.getDataPointType; } }); +var DataPointTypeFactory_1 = require("./DataPointTypes/DataPointTypeFactory"); +Object.defineProperty(exports, "DataPointType", { enumerable: true, get: function () { return DataPointTypeFactory_1.DPTS; } }); +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/lib/index.js.map b/lib/index.js.map new file mode 100644 index 0000000..f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9B,8CAA2D;AAAjD,gGAAA,OAAO,OAAY;AAC7B,oDAAmD;AAA1C,sGAAA,SAAS,OAAA;AAClB,kEAAkF;AAAzE,mHAAA,eAAe,OAAA;AAAE,oHAAA,gBAAgB,OAAA;AAC1C,8EAA4E;AAApE,qHAAA,IAAI,OAAiB"} \ No newline at end of file diff --git a/lib/protocol/CRD.d.ts b/lib/protocol/CRD.d.ts new file mode 100644 index 0000000..ba503de --- /dev/null +++ b/lib/protocol/CRD.d.ts @@ -0,0 +1,21 @@ +/// +import { KNXAddress } from './KNXAddress'; +export declare enum ConnectionType { + TUNNEL_CONNECTION, + DEVICE_MGMT_CONNECTION, + REMLOG_CONNECTION, + REMCONF_CONNECTION, + OBJSVR_CONNECTION +} +export declare class CRD { + set knxAddress(knxAddress: KNXAddress); + get knxAddress(): KNXAddress; + get length(): number; + set connectionType(connectionType: ConnectionType); + get connectionType(): ConnectionType; + private _knxAddress; + private _connectionType; + constructor(connectionType: ConnectionType, knxAddress: KNXAddress); + static createFromBuffer(buffer: Buffer, offset: number): CRD; + toBuffer(): Buffer; +} diff --git a/lib/protocol/CRD.js b/lib/protocol/CRD.js new file mode 100644 index 0000000..fb1fd12 --- /dev/null +++ b/lib/protocol/CRD.js @@ -0,0 +1,58 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.CRD = exports.ConnectionType = void 0; +const KNXConstants_1 = require("./KNXConstants"); +const KNXAddress_1 = require("./KNXAddress"); +const CRD_LENGTH = 4; +var ConnectionType; +(function (ConnectionType) { + ConnectionType[ConnectionType["TUNNEL_CONNECTION"] = KNXConstants_1.KNX_CONSTANTS.TUNNEL_CONNECTION] = "TUNNEL_CONNECTION"; + ConnectionType[ConnectionType["DEVICE_MGMT_CONNECTION"] = KNXConstants_1.KNX_CONSTANTS.DEVICE_MGMT_CONNECTION] = "DEVICE_MGMT_CONNECTION"; + ConnectionType[ConnectionType["REMLOG_CONNECTION"] = KNXConstants_1.KNX_CONSTANTS.REMLOG_CONNECTION] = "REMLOG_CONNECTION"; + ConnectionType[ConnectionType["REMCONF_CONNECTION"] = KNXConstants_1.KNX_CONSTANTS.REMCONF_CONNECTION] = "REMCONF_CONNECTION"; + ConnectionType[ConnectionType["OBJSVR_CONNECTION"] = KNXConstants_1.KNX_CONSTANTS.OBJSVR_CONNECTION] = "OBJSVR_CONNECTION"; +})(ConnectionType = exports.ConnectionType || (exports.ConnectionType = {})); +class CRD { + constructor(connectionType, knxAddress) { + this.connectionType = connectionType; + this.knxAddress = knxAddress; + } + set knxAddress(knxAddress) { + this._knxAddress = knxAddress; + } + get knxAddress() { + return this._knxAddress; + } + get length() { + return CRD_LENGTH; + } + set connectionType(connectionType) { + this._connectionType = connectionType; + } + get connectionType() { + return this._connectionType; + } + static createFromBuffer(buffer, offset) { + if (offset >= buffer.length) { + throw new Error('Buffer too short'); + } + const structureLength = buffer.readUInt8(offset); + if (offset + structureLength > buffer.length) { + throw new Error('Buffer too short'); + } + offset += 1; + const connectionType = buffer.readUInt8(offset++); + const knxAddress = buffer.readUInt16BE(offset); + return new CRD(connectionType, KNXAddress_1.KNXAddress.createFromString(knxAddress)); + } + toBuffer() { + const buffer = Buffer.alloc(this.length); + let offset = 0; + buffer.writeUInt8(this.length, offset++); + buffer.writeUInt8(this.connectionType, offset++); + buffer.writeUInt16BE(this.knxAddress.get(), offset); + return buffer; + } +} +exports.CRD = CRD; +//# sourceMappingURL=CRD.js.map \ No newline at end of file diff --git a/lib/protocol/CRD.js.map b/lib/protocol/CRD.js.map new file mode 100644 index 0000000..596505c --- /dev/null +++ b/lib/protocol/CRD.js.map @@ -0,0 +1 @@ +{"version":3,"file":"CRD.js","sourceRoot":"","sources":["../../src/protocol/CRD.ts"],"names":[],"mappings":";;;AAAA,iDAA6C;AAC7C,6CAA0C;AAC1C,MAAM,UAAU,GAAG,CAAC,CAAC;AAErB,IAAY,cAMX;AAND,WAAY,cAAc;IACtB,qDAAoB,4BAAa,CAAC,iBAAiB,uBAAA,CAAA;IAC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AAY,CAAC,MAAM,CAAC,CAAC;QAC/C,OAAO,IAAI,GAAG,CAAC,cAAc,EAAE,uBAAU,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC,CAAC;IAC5E,CAAC;IAED,QAAQ;QACJ,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACzC,IAAI,MAAM,GAAG,CAAC,CAAC;QACf,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;QACzC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,cAAc,EAAE,MAAM,EAAE,CAAC,CAAC;QACjD,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,EAAE,EAAE,MAAM,CAAC,CAAC;QACpD,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ;AAxDD,kBAwDC"} \ No newline at end of file diff --git a/lib/protocol/CRI.d.ts b/lib/protocol/CRI.d.ts new file mode 100644 index 0000000..0ae9c48 --- /dev/null +++ b/lib/protocol/CRI.d.ts @@ -0,0 +1,16 @@ +/// +export declare enum ConnectionTypes { + TUNNEL_CONNECTION, + DEVICE_MGMT_CONNECTION, + REMLOG_CONNECTION, + REMCONF_CONNECTION, + OBJSVR_CONNECTION +} +export declare class CRI { + private _connectionType; + constructor(_connectionType: ConnectionTypes); + get length(): number; + set connectionType(connectionType: ConnectionTypes); + get connectionType(): ConnectionTypes; + toBuffer(): Buffer; +} diff --git a/lib/protocol/CRI.js b/lib/protocol/CRI.js new file mode 100644 index 0000000..5ca88fa --- /dev/null +++ b/lib/protocol/CRI.js @@ -0,0 +1,31 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.CRI = exports.ConnectionTypes = void 0; +const KNXConstants_1 = require("./KNXConstants"); +var ConnectionTypes; +(function (ConnectionTypes) { + ConnectionTypes[ConnectionTypes["TUNNEL_CONNECTION"] = KNXConstants_1.KNX_CONSTANTS.TUNNEL_CONNECTION] = "TUNNEL_CONNECTION"; + ConnectionTypes[ConnectionTypes["DEVICE_MGMT_CONNECTION"] = KNXConstants_1.KNX_CONSTANTS.DEVICE_MGMT_CONNECTION] = "DEVICE_MGMT_CONNECTION"; + ConnectionTypes[ConnectionTypes["REMLOG_CONNECTION"] = KNXConstants_1.KNX_CONSTANTS.REMLOG_CONNECTION] = "REMLOG_CONNECTION"; + ConnectionTypes[ConnectionTypes["REMCONF_CONNECTION"] = KNXConstants_1.KNX_CONSTANTS.REMCONF_CONNECTION] = "REMCONF_CONNECTION"; + ConnectionTypes[ConnectionTypes["OBJSVR_CONNECTION"] = KNXConstants_1.KNX_CONSTANTS.OBJSVR_CONNECTION] = "OBJSVR_CONNECTION"; +})(ConnectionTypes = exports.ConnectionTypes || (exports.ConnectionTypes = {})); +class CRI { + constructor(_connectionType) { + this._connectionType = _connectionType; + } + get length() { + return 2; + } + set connectionType(connectionType) { + this._connectionType = connectionType; + } + get connectionType() { + return this._connectionType; + } + toBuffer() { + return Buffer.alloc(0); + } +} +exports.CRI = CRI; +//# sourceMappingURL=CRI.js.map \ No newline at end of file diff --git a/lib/protocol/CRI.js.map b/lib/protocol/CRI.js.map new file mode 100644 index 0000000..93e556d --- /dev/null +++ b/lib/protocol/CRI.js.map @@ -0,0 +1 @@ +{"version":3,"file":"CRI.js","sourceRoot":"","sources":["../../src/protocol/CRI.ts"],"names":[],"mappings":";;;AAAA,iDAA6C;AAE7C,IAAY,eAMX;AAND,WAAY,eAAe;IACvB,uDAAoB,4BAAa,CAAC,iBAAiB,uBAAA,CAAA;IACnD,4DAAyB,4BAAa,CAAC,sBAAsB,4BAAA,CAAA;IAC7D,uDAAoB,4BAAa,CAAC,iBAAiB,uBAAA,CAAA;IACnD,wDAAqB,4BAAa,CAAC,kBAAkB,wBAAA,CAAA;IACrD,uDAAoB,4BAAa,CAAC,iBAAiB,uBAAA,CAAA;AACvD,CAAC,EANW,eAAe,GAAf,uBAAe,KAAf,uBAAe,QAM1B;AAED,MAAa,GAAG;IACZ,YAAoB,eAAgC;QAAhC,oBAAe,GAAf,eAAe,CAAiB;IACpD,CAAC;IAED,IAAI,MAAM;QACN,OAAO,CAAC,CAAC;IACb,CAAC;IAMD,IAAI,cAAc,CAAC,cAA+B;QAC9C,IAAI,CAAC,eAAe,GAAG,cAAc,CAAC;IAC1C,CAAC;IAMD,IAAI,cAAc;QACd,OAAO,IAAI,CAAC,eAAe,CAAC;IAChC,CAAC;IAMD,QAAQ;QACJ,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAC3B,CAAC;CACJ;AA/BD,kBA+BC"} \ No newline at end of file diff --git a/lib/protocol/CRIFactory.d.ts b/lib/protocol/CRIFactory.d.ts new file mode 100644 index 0000000..1aad6e8 --- /dev/null +++ b/lib/protocol/CRIFactory.d.ts @@ -0,0 +1,7 @@ +/// +import { CRI } from './CRI'; +declare const _default: { + new (): {}; + createFromBuffer(buffer: Buffer, offset: number): CRI; +}; +export = _default; diff --git a/lib/protocol/CRIFactory.js b/lib/protocol/CRIFactory.js new file mode 100644 index 0000000..60df58f --- /dev/null +++ b/lib/protocol/CRIFactory.js @@ -0,0 +1,21 @@ +'use strict'; +const KNXConstants_1 = require("./KNXConstants"); +const TunnelCRI_1 = require("./TunnelCRI"); +module.exports = class CRIFactory { + static createFromBuffer(buffer, offset) { + if (offset >= buffer.length) { + throw new Error('Buffer too short'); + } + const structureLength = buffer.readUInt8(offset); + if (offset + structureLength > buffer.length) { + throw new Error('Buffer too short'); + } + offset += 1; + const connectionType = buffer.readUInt8(offset++); + switch (connectionType) { + case KNXConstants_1.KNX_CONSTANTS.TUNNEL_CONNECTION: + return TunnelCRI_1.TunnelCRI.createFromBuffer(buffer, offset); + } + } +}; +//# sourceMappingURL=CRIFactory.js.map \ No newline at end of file diff --git a/lib/protocol/CRIFactory.js.map b/lib/protocol/CRIFactory.js.map new file mode 100644 index 0000000..09ad487 --- /dev/null +++ b/lib/protocol/CRIFactory.js.map @@ -0,0 +1 @@ +{"version":3,"file":"CRIFactory.js","sourceRoot":"","sources":["../../src/protocol/CRIFactory.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AACb,iDAA6C;AAC7C,2CAAsC;AAGtC,iBAAS,MAAM,UAAU;IACrB,MAAM,CAAC,gBAAgB,CAAC,MAAc,EAAE,MAAc;QAClD,IAAI,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE;YACzB,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;SACvC;QACD,MAAM,eAAe,GAAG,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QACjD,IAAI,MAAM,GAAG,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE;YAC1C,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;SACvC;QACD,MAAM,IAAI,CAAC,CAAC;QACZ,MAAM,cAAc,GAAI,MAAM,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC;QACnD,QAAQ,cAAc,EAAE;YACpB,KAAK,4BAAa,CAAC,iBAAiB;gBAChC,OAAO,qBAAS,CAAC,gBAAgB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;SACzD;IACL,CAAC;CACJ,CAAC"} \ No newline at end of file diff --git a/lib/protocol/DIB.d.ts b/lib/protocol/DIB.d.ts new file mode 100644 index 0000000..bd7930c --- /dev/null +++ b/lib/protocol/DIB.d.ts @@ -0,0 +1,3 @@ +export interface DIB { + type: number; +} diff --git a/lib/protocol/DIB.js b/lib/protocol/DIB.js new file mode 100644 index 0000000..34b3294 --- /dev/null +++ b/lib/protocol/DIB.js @@ -0,0 +1,3 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//# sourceMappingURL=DIB.js.map \ No newline at end of file diff --git a/lib/protocol/DIB.js.map b/lib/protocol/DIB.js.map new file mode 100644 index 0000000..48974e9 --- /dev/null +++ b/lib/protocol/DIB.js.map @@ -0,0 +1 @@ +{"version":3,"file":"DIB.js","sourceRoot":"","sources":["../../src/protocol/DIB.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/lib/protocol/DeviceInfo.d.ts b/lib/protocol/DeviceInfo.d.ts new file mode 100644 index 0000000..ad3e1aa --- /dev/null +++ b/lib/protocol/DeviceInfo.d.ts @@ -0,0 +1,44 @@ +/// +import { DIB } from './DIB'; +export declare enum Medium { + TP1, + PL110, + RF, + IP +} +export declare class DeviceInfo implements DIB { + get type(): number; + set ip(ip: string); + get ip(): string; + get status(): number; + set status(status: number); + set name(name: string); + get name(): string; + set projectID(id: number); + get projectID(): number; + set serialNumber(serialNumber: number[]); + get serialNumber(): number[]; + set macAddress(macAddress: number[]); + get macAddress(): number[]; + set medium(medium: Medium); + get medium(): Medium; + get formattedMedium(): string; + set address(address: number); + get address(): number; + get formattedAddress(): string; + get length(): number; + private _status; + private _splitIP; + private _name; + private _projectID; + private _serialNumber; + private _macAddress; + private _medium; + private _address; + private _type; + constructor(medium: Medium, status: number, address: number, projectID: number, serialNumber: number[], ip: string, macAddress: number[], name: string); + static validArray: (a: Array, length: number) => Array; + static createFromBuffer(buffer: Buffer, offset?: number): DeviceInfo; + setMediumFromString(medium: string): void; + toBuffer(): Buffer; +} diff --git a/lib/protocol/DeviceInfo.js b/lib/protocol/DeviceInfo.js new file mode 100644 index 0000000..da3445e --- /dev/null +++ b/lib/protocol/DeviceInfo.js @@ -0,0 +1,211 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.DeviceInfo = exports.Medium = void 0; +const KNXConstants_1 = require("./KNXConstants"); +const KNXUtils_1 = require("./KNXUtils"); +const DEVICE_INFO_LENGTH = 0x36; +const SERIALNUMBER_LENGTH = 6; +const MACADDRESS_LENGTH = 6; +const NAME_LENGTH = 30; +var Medium; +(function (Medium) { + Medium[Medium["TP1"] = KNXConstants_1.KNX_CONSTANTS.TP1] = "TP1"; + Medium[Medium["PL110"] = KNXConstants_1.KNX_CONSTANTS.PL110] = "PL110"; + Medium[Medium["RF"] = KNXConstants_1.KNX_CONSTANTS.RF] = "RF"; + Medium[Medium["IP"] = KNXConstants_1.KNX_CONSTANTS.IP] = "IP"; +})(Medium = exports.Medium || (exports.Medium = {})); +class DeviceInfo { + constructor(medium, status, address, projectID, serialNumber, ip, macAddress, name) { + this._type = KNXConstants_1.KNX_CONSTANTS.DEVICE_INFO; + this.medium = medium; + this.status = status; + this.ip = ip; + this.name = name; + this.serialNumber = serialNumber; + this.projectID = projectID; + this.address = address; + } + get type() { + return this._type; + } + set ip(ip) { + this._splitIP = KNXUtils_1.splitIP(ip); + } + get ip() { + return this._splitIP.input; + } + get status() { + return this._status; + } + set status(status) { + this._status = status & 1; + } + set name(name) { + if (name.length > NAME_LENGTH) { + throw new Error(`Invalid name format or too long - ${name}(${name.length}`); + } + this._name = name; + } + get name() { + return this._name; + } + set projectID(id) { + const _id = Number(id); + if (isNaN(_id) || _id > 0xFFFF || _id < 0) { + throw new Error('Invalid project id'); + } + this._projectID = _id; + } + get projectID() { + return this._projectID; + } + set serialNumber(serialNumber) { + this._serialNumber = DeviceInfo.validArray(serialNumber, SERIALNUMBER_LENGTH); + } + get serialNumber() { + return this._serialNumber; + } + set macAddress(macAddress) { + this._macAddress = DeviceInfo.validArray(macAddress, MACADDRESS_LENGTH); + } + get macAddress() { + return this._macAddress; + } + set medium(medium) { + this._medium = medium; + } + get medium() { + return this._medium; + } + get formattedMedium() { + switch (this._medium) { + case KNXConstants_1.KNX_CONSTANTS.TP1: + return 'TP1'; + case KNXConstants_1.KNX_CONSTANTS.PL110: + return 'PL110'; + case KNXConstants_1.KNX_CONSTANTS.RF: + return 'RF'; + case KNXConstants_1.KNX_CONSTANTS.IP: + return 'IP'; + } + } + set address(address) { + this._address = KNXUtils_1.validateKNXAddress(address); + } + get address() { + return this._address; + } + get formattedAddress() { + let address = ''; + if (this._address > 0xFFF) { + address = `${(this._address & 0xF000) >> 12}.`; + } + address += `${(this._address & 0x0F00) >> 8}.${this._address & 0xFF}`; + return address; + } + get length() { + return DEVICE_INFO_LENGTH; + } + static createFromBuffer(buffer, offset = 0) { + if (offset + this.length >= buffer.length) { + throw new Error(`offset ${offset} out of buffer range ${buffer.length}`); + } + const structureLength = buffer.readUInt8(offset); + if (offset + structureLength > buffer.length) { + throw new Error(`offset ${offset} block length: ${structureLength} out of buffer range ${buffer.length}`); + } + offset++; + const type = buffer.readUInt8(offset++); + if (type !== KNXConstants_1.KNX_CONSTANTS.DEVICE_INFO) { + throw new Error(`Invalid DeviceInfo type ${type}`); + } + const medium = buffer.readUInt8(offset++); + const status = buffer.readUInt8(offset++); + const address = buffer.readUInt16BE(offset); + offset += 2; + const projectID = buffer.readUInt16BE(offset); + offset += 2; + const serialNumber = [0, 0, 0, 0, 0, 0]; + for (let i = 0; i < SERIALNUMBER_LENGTH; i++) { + serialNumber[i] = buffer.readUInt8(offset++); + } + const ip = []; + for (let i = 1; i <= 4; i++) { + ip.push(buffer.readUInt8(offset++)); + } + const textIP = ip.join('.'); + const macAddress = [0, 0, 0, 0, 0, 0]; + for (let i = 0; i < MACADDRESS_LENGTH; i++) { + macAddress[i] = buffer.readUInt8(offset++); + } + let name = ''; + for (let i = 0; i < NAME_LENGTH; i++) { + const char = buffer.readUInt8(offset++); + if (char !== 0) { + name += String.fromCharCode(char); + } + else { + break; + } + } + return new DeviceInfo(medium, status, address, projectID, serialNumber, textIP, macAddress, name); + } + setMediumFromString(medium) { + switch (medium) { + case 'TP1': + this._medium = KNXConstants_1.KNX_CONSTANTS.TP1; + break; + case 'PL110': + this._medium = KNXConstants_1.KNX_CONSTANTS.PL110; + break; + case 'RF': + this._medium = KNXConstants_1.KNX_CONSTANTS.RF; + break; + case 'IP': + this._medium = KNXConstants_1.KNX_CONSTANTS.IP; + break; + default: + throw new Error(`Invalid medium ${medium}`); + } + } + toBuffer() { + const buffer = Buffer.alloc(DEVICE_INFO_LENGTH); + let offset = 0; + buffer.writeUInt8(this.length, offset++); + buffer.writeUInt8(KNXConstants_1.KNX_CONSTANTS.DEVICE_INFO, offset++); + buffer.writeUInt8(this.medium, offset++); + buffer.writeUInt8(this.status, offset++); + buffer.writeUInt16BE(this.address, offset); + offset += 2; + buffer.writeUInt16BE(this.projectID, offset); + offset += 2; + for (let i = 0; i < this.serialNumber.length; i++) { + buffer.writeUInt8(this.serialNumber[i], offset++); + } + for (let i = 1; i <= KNXConstants_1.KNX_CONSTANTS.IPV4_ADDRESS_LENGTH; i++) { + buffer.writeUInt8(Number(this._splitIP[i]), offset++); + } + for (let i = 0; i < this.macAddress.length; i++) { + buffer.writeUInt8(this.macAddress[i], offset++); + } + for (let i = 0; i < NAME_LENGTH; i++) { + buffer.writeUInt8(i >= this.name.length ? 0 : Number(this.name[i]), offset++); + } + return buffer; + } +} +exports.DeviceInfo = DeviceInfo; +DeviceInfo.validArray = function (a, length) { + if ((!Array.isArray(a)) || a.length !== length) { + throw new Error('Invalid array format'); + } + const validA = [0, 0, 0, 0, 0, 0]; + for (let i = 0; i < a.length; i++) { + validA[i] = Number(a[i]); + if (isNaN(validA[i]) || validA[i] < 0 || validA[i] > 255) { + throw new Error(`Invalid byte at pos ${i}`); + } + } + return validA; +}; +//# sourceMappingURL=DeviceInfo.js.map \ No newline at end of file diff --git a/lib/protocol/DeviceInfo.js.map b/lib/protocol/DeviceInfo.js.map new file mode 100644 index 0000000..0604eba --- /dev/null +++ b/lib/protocol/DeviceInfo.js.map @@ -0,0 +1 @@ +{"version":3,"file":"DeviceInfo.js","sourceRoot":"","sources":["../../src/protocol/DeviceInfo.ts"],"names":[],"mappings":";;;AACA,iDAA6C;AAC7C,yCAAuD;AAEvD,MAAM,kBAAkB,GAAG,IAAI,CAAC;AAChC,MAAM,mBAAmB,GAAG,CAAC,CAAC;AAC9B,MAAM,iBAAiB,GAAG,CAAC,CAAC;AAC5B,MAAM,WAAW,GAAG,EAAE,CAAC;AAEvB,IAAY,MAKX;AALD,WAAY,MAAM;IACd,uBAAM,4BAAa,CAAC,GAAG,SAAA,CAAA;IACvB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CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;SACjF;QACD,OAAO,MAAM,CAAC;IAClB,CAAC;;AA7OL,gCA8OC;AAtGU,qBAAU,GAAG,UAAS,CAAgB,EAAE,MAAc;IACzD,IAAI,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,KAAK,MAAM,EAAE;QAC5C,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;KAC3C;IACD,MAAM,MAAM,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAClC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QAC/B,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACzB,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,GAAG,GAAG,EAAE;YACtD,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,EAAE,CAAC,CAAC;SAC/C;KACJ;IACD,OAAO,MAAM,CAAC;AAClB,CAAC,CAAC"} \ No newline at end of file diff --git a/lib/protocol/HPAI.d.ts b/lib/protocol/HPAI.d.ts new file mode 100644 index 0000000..3c568b9 --- /dev/null +++ b/lib/protocol/HPAI.d.ts @@ -0,0 +1,25 @@ +/// +import { KNXHeader } from './KNXHeader'; +export declare enum KnxProtocol { + IPV4_UDP, + IPV4_TCP +} +export declare class HPAI { + private _port; + private _protocol; + set protocol(proto: KnxProtocol); + get protocol(): KnxProtocol; + set port(port: number); + get port(): number; + get header(): KNXHeader; + set host(host: string); + get host(): string; + get length(): number; + static get NULLHPAI(): HPAI; + private _header; + private _splitHost; + private _host; + constructor(_host: string, _port?: number, _protocol?: KnxProtocol); + static createFromBuffer(buffer: Buffer, offset?: number): HPAI; + toBuffer(): Buffer; +} diff --git a/lib/protocol/HPAI.js b/lib/protocol/HPAI.js new file mode 100644 index 0000000..b27e140 --- /dev/null +++ b/lib/protocol/HPAI.js @@ -0,0 +1,92 @@ +'use strict'; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.HPAI = exports.KnxProtocol = void 0; +const KNXConstants_1 = require("./KNXConstants"); +const HPAI_STRUCTURE_LENGTH = 8; +var KnxProtocol; +(function (KnxProtocol) { + KnxProtocol[KnxProtocol["IPV4_UDP"] = KNXConstants_1.KNX_CONSTANTS.IPV4_UDP] = "IPV4_UDP"; + KnxProtocol[KnxProtocol["IPV4_TCP"] = KNXConstants_1.KNX_CONSTANTS.IPV4_TCP] = "IPV4_TCP"; +})(KnxProtocol = exports.KnxProtocol || (exports.KnxProtocol = {})); +class HPAI { + constructor(_host, _port = KNXConstants_1.KNX_CONSTANTS.KNX_PORT, _protocol = KNXConstants_1.KNX_CONSTANTS.IPV4_UDP) { + this._port = _port; + this._protocol = _protocol; + this.host = _host; + } + set protocol(proto) { + this._protocol = proto; + } + get protocol() { + return this._protocol; + } + set port(port) { + if (isNaN(port) || typeof (port) !== 'number' || port < 0 || port > 65535) { + throw new Error(`Invalid port ${port}`); + } + this._port = port; + } + get port() { + return this._port; + } + get header() { + return this._header; + } + set host(host) { + if (host == null) { + throw new Error('Host undefined'); + } + const m = host.match(/(\d+)\.(\d+)\.(\d+)\.(\d+)/); + if (m === null) { + throw new Error(`Invalid host format - ${host}`); + } + this._host = host; + this._splitHost = m; + } + get host() { + return this._host; + } + get length() { + return HPAI_STRUCTURE_LENGTH; + } + static get NULLHPAI() { + const NULLHPAI = new HPAI('0.0.0.0', 0); + return NULLHPAI; + } + static createFromBuffer(buffer, offset = 0) { + if (offset >= buffer.length) { + throw new Error(`offset ${offset} out of buffer range ${buffer.length}`); + } + const structureLength = buffer.readUInt8(offset); + if (offset + structureLength > buffer.length) { + throw new Error(`offset ${offset} block length: ${structureLength} out of buffer range ${buffer.length}`); + } + offset++; + const protocol = buffer.readUInt8(offset); + offset += 1; + const ip = []; + for (let i = 1; i <= 4; i++) { + ip.push(buffer.readUInt8(offset)); + offset += 1; + } + const port = buffer.readUInt8(offset); + const host = ip.join('.'); + return new HPAI(host, port, protocol); + } + toBuffer() { + const buffer = Buffer.alloc(this.length); + let offset = 0; + buffer.writeUInt8(this.length, offset); + offset += 1; + buffer.writeUInt8(this.protocol, offset); + offset += 1; + for (let i = 1; i <= KNXConstants_1.KNX_CONSTANTS.IPV4_ADDRESS_LENGTH; i++) { + buffer.writeUInt8(Number(this._splitHost[i]), offset); + offset += 1; + } + buffer.writeUInt16BE(this.port, offset); + return buffer; + } +} +exports.HPAI = HPAI; +//# sourceMappingURL=HPAI.js.map \ No newline at end of file diff --git a/lib/protocol/HPAI.js.map b/lib/protocol/HPAI.js.map new file mode 100644 index 0000000..18ad7a1 --- /dev/null +++ b/lib/protocol/HPAI.js.map @@ -0,0 +1 @@ +{"version":3,"file":"HPAI.js","sourceRoot":"","sources":["../../src/protocol/HPAI.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AACb,iDAA6C;AAE7C,MAAM,qBAAqB,GAAG,CAAC,CAAC;AAEhC,IAAY,WAGX;AAHD,WAAY,WAAW;IACnB,sCAAW,4BAAa,CAAC,QAAQ,cAAA,CAAA;IACjC,sCAAW,4BAAa,CAAC,QAAQ,cAAA,CAAA;AACrC,CAAC,EAHW,WAAW,GAAX,mBAAW,KAAX,mBAAW,QAGtB;AACD,MAAa,IAAI;IAyDb,YAAa,KAAa,EAAU,QAAgB,4BAAa,CAAC,QAAQ,EAAU,YAAyB,4BAAa,CAAC,QAAQ;QAA/F,UAAK,GAAL,KAAK,CAAiC;QAAU,cAAS,GAAT,SAAS,C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AAC,CAAC;QACvC,MAAM,IAAI,CAAC,CAAC;QACZ,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QACzC,MAAM,IAAI,CAAC,CAAC;QACZ,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,4BAAa,CAAC,mBAAmB,EAAE,CAAC,EAAE,EAAE;YACzD,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;YACtD,MAAM,IAAI,CAAC,CAAC;SACf;QACD,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QACxC,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ;AAhGD,oBAgGC"} \ No newline at end of file diff --git a/lib/protocol/IPConfig.d.ts b/lib/protocol/IPConfig.d.ts new file mode 100644 index 0000000..59b37ee --- /dev/null +++ b/lib/protocol/IPConfig.d.ts @@ -0,0 +1,32 @@ +/// +declare const _default: { + new (_ip: string, _mask: string, gateway: string, capabilities: number, assignment: number): { + readonly type: number; + ip: string; + mask: string; + gateway: string; + readonly length: number; + _type: number; + _splitIP: RegExpMatchArray; + _splitMask: RegExpMatchArray; + _splitGateway: RegExpMatchArray; + readonly capabilities: number; + readonly assignment: number; + toBuffer(): Buffer; + }; + createFromBuffer(buffer: Buffer, offset?: number): { + readonly type: number; + ip: string; + mask: string; + gateway: string; + readonly length: number; + _type: number; + _splitIP: RegExpMatchArray; + _splitMask: RegExpMatchArray; + _splitGateway: RegExpMatchArray; + readonly capabilities: number; + readonly assignment: number; + toBuffer(): Buffer; + }; +}; +export = _default; diff --git a/lib/protocol/IPConfig.js b/lib/protocol/IPConfig.js new file mode 100644 index 0000000..f8c47e7 --- /dev/null +++ b/lib/protocol/IPConfig.js @@ -0,0 +1,86 @@ +'use strict'; +const KNXConstants_1 = require("./KNXConstants"); +const KNXUtils_1 = require("./KNXUtils"); +const IP_CONFIG_LENGTH = 16; +module.exports = class IPConfig { + constructor(_ip, _mask, gateway, capabilities, assignment) { + this.capabilities = capabilities; + this.assignment = assignment; + this._type = KNXConstants_1.KNX_CONSTANTS.IP_CONFIG; + this.ip = _ip; + this.mask = _mask; + this.gateway = gateway; + } + get type() { + return this._type; + } + set ip(ip) { + this._splitIP = KNXUtils_1.splitIP(ip); + } + get ip() { + return this._splitIP.input; + } + set mask(mask) { + this._splitMask = KNXUtils_1.splitIP(mask, 'mask'); + } + get mask() { + return this._splitMask.input; + } + set gateway(gateway) { + this._splitGateway = KNXUtils_1.splitIP(gateway, 'gateway'); + } + get length() { + return IP_CONFIG_LENGTH; + } + static createFromBuffer(buffer, offset = 0) { + if (offset + this.length >= buffer.length) { + throw new Error(`offset ${offset} out of buffer range ${buffer.length}`); + } + const structureLength = buffer.readUInt8(offset); + if (offset + structureLength > buffer.length) { + throw new Error(`offset ${offset} block length: ${structureLength} out of buffer range ${buffer.length}`); + } + offset++; + const type = buffer.readUInt8(offset++); + if (type !== KNXConstants_1.KNX_CONSTANTS.IP_CONFIG) { + throw new Error(`Invalid IPConfig type ${type}`); + } + const ip = []; + for (let i = 1; i <= 4; i++) { + ip.push(buffer.readUInt8(offset++)); + } + const textIP = ip.join('.'); + const mask = []; + for (let i = 1; i <= 4; i++) { + mask.push(buffer.readUInt8(offset++)); + } + const textMask = mask.join('.'); + const gateway = []; + for (let i = 1; i <= 4; i++) { + gateway.push(buffer.readUInt8(offset++)); + } + const textGateway = gateway.join('.'); + const capabilities = buffer.readUInt8(offset++); + const assignment = buffer.readUInt8(offset); + return new IPConfig(textIP, textMask, textGateway, capabilities, assignment); + } + toBuffer() { + const buffer = Buffer.alloc(this.length); + let offset = 0; + buffer.writeUInt8(this.length, offset++); + buffer.writeUInt8(KNXConstants_1.KNX_CONSTANTS.IP_CONFIG, offset++); + for (let i = 1; i <= KNXConstants_1.KNX_CONSTANTS.IPV4_ADDRESS_LENGTH; i++) { + buffer.writeUInt8(Number(this._splitIP[i]), offset++); + } + for (let i = 1; i <= KNXConstants_1.KNX_CONSTANTS.IPV4_ADDRESS_LENGTH; i++) { + buffer.writeUInt8(Number(this._splitMask[i]), offset++); + } + for (let i = 1; i <= KNXConstants_1.KNX_CONSTANTS.IPV4_ADDRESS_LENGTH; i++) { + buffer.writeUInt8(Number(this._splitGateway[i]), offset++); + } + buffer.writeUInt8(this.capabilities, offset++); + buffer.writeUInt8(this.assignment, offset); + return buffer; + } +}; +//# sourceMappingURL=IPConfig.js.map \ No newline at end of file diff --git a/lib/protocol/IPConfig.js.map b/lib/protocol/IPConfig.js.map new file mode 100644 index 0000000..5012a8a --- /dev/null +++ b/lib/protocol/IPConfig.js.map @@ -0,0 +1 @@ +{"version":3,"file":"IPConfig.js","sourceRoot":"","sources":["../../src/protocol/IPConfig.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,iDAA6C;AAC7C,yCAAmC;AACnC,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAE5B,iBAAS,MAAM,QAAQ;IA0CnB,YAAY,GAAW,EAAE,KAAa,EAAE,OAAe,EAAW,YAAoB,EAAW,UAAkB;QAAjD,iBAAY,GAAZ,YAAY,CAAQ;QAAW,eAAU,GAAV,UAAU,CAAQ;QAC/G,IAAI,CAAC,KAAK,GAAG,4BAAa,CAAC,SAAS,CAAC;QACrC,IAAI,CAAC,EAAE,GAAG,GAAG,CAAC;QACd,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC;QAClB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IAC3B,CAAC;IA7CD,IAAI,IAAI;QACJ,OAAO,IAAI,CAAC,KAAK,CAAC;IACtB,CAAC;IAED,IAAI,EAAE,CAAC,EAAU;QACb,IAAI,CAAC,QAAQ,GAAG,kBAAO,CAAC,EAAE,CAAC,CAAC;IAChC,CAAC;IAED,IAAI,EAAE;QACF,OAAO,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;IAC/B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,CAAC,mBAAmB,EAAE,CAAC,EAAE,EAAE;YACzD,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;SACzD;QACD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,4BAAa,CAAC,mBAAmB,EAAE,CAAC,EAAE,EAAE;YACzD,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;SAC3D;QACD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,4BAAa,CAAC,mBAAmB,EAAE,CAAC,EAAE,EAAE;YACzD,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;SAC9D;QACD,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,YAAY,EAAE,MAAM,EAAE,CAAC,CAAC;QAC/C,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;QAC3C,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ,CAAC"} \ No newline at end of file diff --git a/lib/protocol/IPCurrentConfig.d.ts b/lib/protocol/IPCurrentConfig.d.ts new file mode 100644 index 0000000..d618256 --- /dev/null +++ b/lib/protocol/IPCurrentConfig.d.ts @@ -0,0 +1,34 @@ +/// +declare const _default: { + new (_ip: string, _mask: string, gateway: string, dhcpServer: string, assignment: number): { + readonly type: number; + ip: string; + mask: string; + gateway: string; + dhcpServer: string; + readonly length: number; + _type: number; + _splitIP: RegExpMatchArray; + _splitMask: RegExpMatchArray; + _splitGateway: RegExpMatchArray; + _splitDhcpServer: RegExpMatchArray; + readonly assignment: number; + toBuffer(): Buffer; + }; + createFromBuffer(buffer: Buffer, offset?: number): { + readonly type: number; + ip: string; + mask: string; + gateway: string; + dhcpServer: string; + readonly length: number; + _type: number; + _splitIP: RegExpMatchArray; + _splitMask: RegExpMatchArray; + _splitGateway: RegExpMatchArray; + _splitDhcpServer: RegExpMatchArray; + readonly assignment: number; + toBuffer(): Buffer; + }; +}; +export = _default; diff --git a/lib/protocol/IPCurrentConfig.js b/lib/protocol/IPCurrentConfig.js new file mode 100644 index 0000000..e3a99fe --- /dev/null +++ b/lib/protocol/IPCurrentConfig.js @@ -0,0 +1,99 @@ +'use strict'; +const KNXConstants_1 = require("./KNXConstants"); +const KNXUtils_1 = require("./KNXUtils"); +const IP_CURRENT_CONFIG_LENGTH = 20; +module.exports = class IPCurrentConfig { + constructor(_ip, _mask, gateway, dhcpServer, assignment) { + this.assignment = assignment; + this._type = KNXConstants_1.KNX_CONSTANTS.IP_CONFIG; + this.ip = _ip; + this.mask = _mask; + this.gateway = gateway; + this.dhcpServer = dhcpServer; + this.assignment = assignment; + } + get type() { + return this._type; + } + set ip(ip) { + this._splitIP = KNXUtils_1.splitIP(ip); + } + get ip() { + return this._splitIP.input; + } + set mask(mask) { + this._splitMask = KNXUtils_1.splitIP(mask, 'mask'); + } + get mask() { + return this._splitMask.input; + } + set gateway(gateway) { + this._splitGateway = KNXUtils_1.splitIP(gateway, 'gateway'); + } + set dhcpServer(dhcpServer) { + this._splitDhcpServer = KNXUtils_1.splitIP(dhcpServer, 'dhcpServer'); + } + get dhcpServer() { + return this._splitDhcpServer.input; + } + get length() { + return IP_CURRENT_CONFIG_LENGTH; + } + static createFromBuffer(buffer, offset = 0) { + if (offset + this.length >= buffer.length) { + throw new Error(`offset ${offset} out of buffer range ${buffer.length}`); + } + const structureLength = buffer.readUInt8(offset); + if (offset + structureLength > buffer.length) { + throw new Error(`offset ${offset} block length: ${structureLength} out of buffer range ${buffer.length}`); + } + offset++; + const type = buffer.readUInt8(offset++); + if (type !== KNXConstants_1.KNX_CONSTANTS.IP_CONFIG) { + throw new Error(`Invalid IPConfig type ${type}`); + } + const ip = []; + for (let i = 1; i <= 4; i++) { + ip.push(buffer.readUInt8(offset++)); + } + const textIP = ip.join('.'); + const mask = []; + for (let i = 1; i <= 4; i++) { + mask.push(buffer.readUInt8(offset++)); + } + const textMask = mask.join('.'); + const gateway = []; + for (let i = 1; i <= 4; i++) { + gateway.push(buffer.readUInt8(offset++)); + } + const textGateway = gateway.join('.'); + const dhcpServer = []; + for (let i = 1; i <= 4; i++) { + dhcpServer.push(buffer.readUInt8(offset++)); + } + const textDhcpServer = dhcpServer.join('.'); + const assignment = buffer.readUInt8(offset); + return new IPCurrentConfig(textIP, textMask, textGateway, textDhcpServer, assignment); + } + toBuffer() { + const buffer = Buffer.alloc(this.length); + let offset = 0; + buffer.writeUInt8(this.length, offset++); + buffer.writeUInt8(KNXConstants_1.KNX_CONSTANTS.IP_CONFIG, offset++); + for (let i = 1; i <= KNXConstants_1.KNX_CONSTANTS.IPV4_ADDRESS_LENGTH; i++) { + buffer.writeUInt8(Number(this._splitIP[i]), offset++); + } + for (let i = 1; i <= KNXConstants_1.KNX_CONSTANTS.IPV4_ADDRESS_LENGTH; i++) { + buffer.writeUInt8(Number(this._splitMask[i]), offset++); + } + for (let i = 1; i <= KNXConstants_1.KNX_CONSTANTS.IPV4_ADDRESS_LENGTH; i++) { + buffer.writeUInt8(Number(this._splitGateway[i]), offset++); + } + for (let i = 1; i <= KNXConstants_1.KNX_CONSTANTS.IPV4_ADDRESS_LENGTH; i++) { + buffer.writeUInt8(Number(this._splitDhcpServer[i]), offset++); + } + buffer.writeUInt8(this.assignment, offset); + return buffer; + } +}; +//# sourceMappingURL=IPCurrentConfig.js.map \ No newline at end of file diff --git a/lib/protocol/IPCurrentConfig.js.map b/lib/protocol/IPCurrentConfig.js.map new file mode 100644 index 0000000..a3419a9 --- /dev/null +++ b/lib/protocol/IPCurrentConfig.js.map @@ -0,0 +1 @@ +{"version":3,"file":"IPCurrentConfig.js","sourceRoot":"","sources":["../../src/protocol/IPCurrentConfig.ts"],"names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AI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;SACzD;QACD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,4BAAa,CAAC,mBAAmB,EAAE,CAAC,EAAE,EAAE;YACzD,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;SAC3D;QACD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,4BAAa,CAAC,mBAAmB,EAAE,CAAC,EAAE,EAAE;YACzD,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;SAC9D;QACD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,4BAAa,CAAC,mBAAmB,EAAE,CAAC,EAAE,EAAE;YACzD,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;SACjE;QACD,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;QAC3C,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ,CAAC"} \ No newline at end of file diff --git a/lib/protocol/KNXAddress.d.ts b/lib/protocol/KNXAddress.d.ts new file mode 100644 index 0000000..a83b657 --- /dev/null +++ b/lib/protocol/KNXAddress.d.ts @@ -0,0 +1,24 @@ +/// +export declare enum KNXAddressType { + TYPE_INDIVIDUAL = 0, + TYPE_GROUP = 1 +} +export declare enum KNXAddressLevel { + LEVEL_TWO = 2, + LEVEL_THREE = 3 +} +export declare class KNXAddress { + readonly type: KNXAddressType; + readonly level: KNXAddressLevel; + readonly length: number; + private _address; + constructor(address: number, type?: KNXAddressType, level?: KNXAddressLevel); + static get TYPE_INDIVIDUAL(): KNXAddressType; + static get TYPE_GROUP(): KNXAddressType; + static createFromString(address: string | number, type?: KNXAddressType): KNXAddress; + static createFromBuffer(buffer: Buffer, offset?: number, type?: KNXAddressType): KNXAddress; + set(address: number): void; + get(): number; + toString(): string; + toBuffer(): Buffer; +} diff --git a/lib/protocol/KNXAddress.js b/lib/protocol/KNXAddress.js new file mode 100644 index 0000000..914dfed --- /dev/null +++ b/lib/protocol/KNXAddress.js @@ -0,0 +1,85 @@ +'use strict'; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.KNXAddress = exports.KNXAddressLevel = exports.KNXAddressType = void 0; +const KNXUtils_1 = require("./KNXUtils"); +const ADDRESS_LENGTH = 2; +var KNXAddressType; +(function (KNXAddressType) { + KNXAddressType[KNXAddressType["TYPE_INDIVIDUAL"] = 0] = "TYPE_INDIVIDUAL"; + KNXAddressType[KNXAddressType["TYPE_GROUP"] = 1] = "TYPE_GROUP"; +})(KNXAddressType = exports.KNXAddressType || (exports.KNXAddressType = {})); +var KNXAddressLevel; +(function (KNXAddressLevel) { + KNXAddressLevel[KNXAddressLevel["LEVEL_TWO"] = 2] = "LEVEL_TWO"; + KNXAddressLevel[KNXAddressLevel["LEVEL_THREE"] = 3] = "LEVEL_THREE"; +})(KNXAddressLevel = exports.KNXAddressLevel || (exports.KNXAddressLevel = {})); +class KNXAddress { + constructor(address, type = KNXAddressType.TYPE_INDIVIDUAL, level = KNXAddressLevel.LEVEL_THREE) { + this.type = type; + this.level = level; + this.set(address); + this.length = ADDRESS_LENGTH; + } + static get TYPE_INDIVIDUAL() { + return KNXAddressType.TYPE_INDIVIDUAL; + } + static get TYPE_GROUP() { + return KNXAddressType.TYPE_GROUP; + } + static createFromString(address, type = KNXAddressType.TYPE_INDIVIDUAL) { + return new KNXAddress(KNXUtils_1.validateKNXAddress(address, type === KNXAddressType.TYPE_GROUP), type); + } + static createFromBuffer(buffer, offset = 0, type = KNXAddressType.TYPE_INDIVIDUAL) { + if (offset + ADDRESS_LENGTH >= buffer.length) { + throw new Error(`offset ${offset} out of buffer range ${buffer.length}`); + } + const address = buffer.readUInt16BE(offset); + return new KNXAddress(address, type); + } + set(address) { + if (isNaN(address)) { + throw new Error('Invalid address format'); + } + else if (address > 0xFFFF) { + throw new Error('Invalid address number'); + } + else { + this._address = address; + } + } + get() { + return this._address; + } + toString() { + const digits = []; + if (this.level === KNXAddressLevel.LEVEL_TWO) { + digits.push((this._address >> 8) & 0xFF); + digits.push(this._address & 0xFF); + } + else { + if (this._address > 0x7FF) { + if (this.type === KNXAddressType.TYPE_GROUP) { + digits.push((this._address >> 11) & 0x1F); + } + else { + digits.push((this._address >> 12) & 0x0F); + } + } + if (this.type === KNXAddressType.TYPE_GROUP) { + digits.push((this._address >> 8) & 0x07); + } + else { + digits.push((this._address >> 8) & 0x0F); + } + } + digits.push(this._address & 0xFF); + return digits.join('.'); + } + toBuffer() { + const buffer = Buffer.alloc(this.length); + buffer.writeUInt16BE(this._address, 0); + return buffer; + } +} +exports.KNXAddress = KNXAddress; +//# sourceMappingURL=KNXAddress.js.map \ No newline at end of file diff --git a/lib/protocol/KNXAddress.js.map b/lib/protocol/KNXAddress.js.map new file mode 100644 index 0000000..f5ae384 --- /dev/null +++ b/lib/protocol/KNXAddress.js.map @@ -0,0 +1 @@ +{"version":3,"file":"KNXAddress.js","sourceRoot":"","sources":["../../src/protocol/KNXAddress.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAEb,yCAA8C;AAC9C,MAAM,cAAc,GAAG,CAAC,CAAC;AAEzB,IAAY,cAGX;AAHD,WAAY,cAAc;IACtB,yEAAmB,CAAA;IACnB,+DAAc,CAAA;AAClB,CAAC,EAHW,cAAc,GAAd,sBAAc,KAAd,sBAAc,QAGzB;AAED,IAAY,eAGX;AAHD,WAAY,eAAe;IACvB,+DAAa,CAAA;IACb,mEAAe,CAAA;AACnB,CAAC,EAHW,eAAe,GAAf,uBAAe,KAAf,uBAAe,QAG1B;AAED,MAAa,UA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,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;QACvC,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ;AA1ED,gCA0EC"} \ No newline at end of file diff --git a/lib/protocol/KNXAddresses.d.ts b/lib/protocol/KNXAddresses.d.ts new file mode 100644 index 0000000..c834206 --- /dev/null +++ b/lib/protocol/KNXAddresses.d.ts @@ -0,0 +1,12 @@ +/// +import { DIB } from './DIB'; +export declare class KNXAddresses implements DIB { + get length(): number; + get type(): number; + private _addresses; + private _type; + constructor(); + static createFromBuffer(buffer: Buffer, offset?: number): KNXAddresses; + add(address: string | number): void; + toBuffer(): Buffer; +} diff --git a/lib/protocol/KNXAddresses.js b/lib/protocol/KNXAddresses.js new file mode 100644 index 0000000..75c003b --- /dev/null +++ b/lib/protocol/KNXAddresses.js @@ -0,0 +1,53 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.KNXAddresses = void 0; +const KNXConstants_1 = require("./KNXConstants"); +const KNXAddress_1 = require("./KNXAddress"); +class KNXAddresses { + constructor() { + this._type = KNXConstants_1.KNX_CONSTANTS.KNX_ADDRESSES; + this._addresses = new Set(); + } + get length() { + return 2 + this._addresses.size * 2; + } + get type() { + return this._type; + } + static createFromBuffer(buffer, offset = 0) { + if (offset + this.length >= buffer.length) { + throw new Error(`offset ${offset} out of buffer range ${buffer.length}`); + } + const structureLength = buffer.readUInt8(offset); + if (offset + structureLength > buffer.length) { + throw new Error(`offset ${offset} block length: ${structureLength} out of buffer range ${buffer.length}`); + } + offset++; + const type = buffer.readUInt8(offset++); + if (type !== KNXConstants_1.KNX_CONSTANTS.KNX_ADDRESSES) { + throw new Error(`Invalid KNXAddresses type ${type}`); + } + const knxAddresses = new KNXAddresses(); + for (let i = 2; i < structureLength; i += 2) { + knxAddresses.add(buffer.readUInt16BE(offset)); + offset += 2; + } + return knxAddresses; + } + add(address) { + this._addresses.add(KNXAddress_1.KNXAddress.createFromString(address)); + } + toBuffer() { + const buffer = Buffer.alloc(this.length); + let offset = 0; + buffer.writeUInt8(this.length, offset++); + buffer.writeUInt8(KNXConstants_1.KNX_CONSTANTS.KNX_ADDRESSES, offset++); + for (const knxAddress of this._addresses) { + buffer.writeUInt16BE(knxAddress.get(), offset); + offset += 2; + } + return buffer; + } +} +exports.KNXAddresses = KNXAddresses; +//# sourceMappingURL=KNXAddresses.js.map \ No newline at end of file diff --git a/lib/protocol/KNXAddresses.js.map b/lib/protocol/KNXAddresses.js.map new file mode 100644 index 0000000..277ba93 --- /dev/null +++ b/lib/protocol/KNXAddresses.js.map @@ -0,0 +1 @@ +{"version":3,"file":"KNXAddresses.js","sourceRoot":"","sources":["../../src/protocol/KNXAddresses.ts"],"names":[],"mappings":";;;AACA,iDAA6C;AAC7C,6CAA0C;AAE1C,MAAa,YAAY;IAYrB;QACI,IAAI,CAAC,KAAK,GAAG,4BAAa,CAAC,aAAa,CAAC;QACzC,IAAI,CAAC,UAAU,GAAG,IAAI,GAAG,EAAE,CAAC;IAChC,CAAC;IAbD,IAAI,MAAM;QACN,OAAO,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,GAAG,CAAC,CAAC;IACxC,CAAC;IAED,IAAI,IAAI;QACJ,OAAO,IAAI,CAAC,KAAK,CAAC;IACtB,CAAC;IASD,MAAM,CAAC,gBAAgB,CAAC,MAAc,EAAE,SAAiB,CAAC;QACtD,IAAI,MAAM,GAAG,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE;YACvC,MAAM,IAAI,KAAK,CAAC,UAAU,MAAM,wBAAwB,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;SAC5E;QACD,MAAM,eAAe,GAAG,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QACjD,IAAI,MAAM,GAAG,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE;YAC1C,MAAM,IAAI,KAAK,CAAC,UAAU,MAAM,kBAAkB,eAAe,wBAAwB,MAA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/KNXConnectRequest.d.ts new file mode 100644 index 0000000..54cf413 --- /dev/null +++ b/lib/protocol/KNXConnectRequest.d.ts @@ -0,0 +1,12 @@ +/// +import { KNXPacket } from './KNXPacket'; +import { HPAI } from './HPAI'; +import { CRI } from './CRI'; +export declare class KNXConnectRequest extends KNXPacket { + readonly cri: CRI; + readonly hpaiControl: HPAI; + readonly hpaiData: HPAI; + constructor(cri: CRI, hpaiControl?: HPAI, hpaiData?: HPAI); + static createFromBuffer(buffer: Buffer, offset?: number): KNXConnectRequest; + toBuffer(): Buffer; +} diff --git a/lib/protocol/KNXConnectRequest.js b/lib/protocol/KNXConnectRequest.js new file mode 100644 index 0000000..aca68cb --- /dev/null +++ b/lib/protocol/KNXConnectRequest.js @@ -0,0 +1,39 @@ +'use strict'; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.KNXConnectRequest = void 0; +const KNXConstants_1 = require("./KNXConstants"); +const KNXPacket_1 = require("./KNXPacket"); +const HPAI_1 = require("./HPAI"); +const CRIFactory_1 = __importDefault(require("./CRIFactory")); +class KNXConnectRequest extends KNXPacket_1.KNXPacket { + constructor(cri, hpaiControl = HPAI_1.HPAI.NULLHPAI, hpaiData = HPAI_1.HPAI.NULLHPAI) { + super(KNXConstants_1.KNX_CONSTANTS.CONNECT_REQUEST, hpaiControl.length + hpaiData.length + cri.length); + this.cri = cri; + this.hpaiControl = hpaiControl; + this.hpaiData = hpaiData; + } + static createFromBuffer(buffer, offset = 0) { + if (offset >= buffer.length) { + throw new Error('Buffer too short'); + } + const hpaiControl = HPAI_1.HPAI.createFromBuffer(buffer, offset); + offset += hpaiControl.length; + const hpaiData = HPAI_1.HPAI.createFromBuffer(buffer, offset); + offset += hpaiData.length; + const cri = CRIFactory_1.default.createFromBuffer(buffer, offset); + return new KNXConnectRequest(cri, hpaiControl, hpaiData); + } + toBuffer() { + return Buffer.concat([ + this.header.toBuffer(), + this.hpaiControl.toBuffer(), + this.hpaiData.toBuffer(), + this.cri.toBuffer() + ]); + } +} +exports.KNXConnectRequest = KNXConnectRequest; +//# sourceMappingURL=KNXConnectRequest.js.map \ No newline at end of file diff --git a/lib/protocol/KNXConnectRequest.js.map b/lib/protocol/KNXConnectRequest.js.map new file mode 100644 index 0000000..252d09a --- /dev/null +++ b/lib/protocol/KNXConnectRequest.js.map @@ -0,0 +1 @@ +{"version":3,"file":"KNXConnectRequest.js","sourceRoot":"","sources":["../../src/protocol/KNXConnectRequest.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;AACb,iDAA6C;AAC7C,2CAAsC;AACtC,iCAA4B;AAC5B,8DAAsC;AAGtC,MAAa,iBAAkB,SAAQ,qBAAS;IAC5C,YAAqB,GAAQ,EAAW,cAAoB,WAAI,CAAC,QAAQ,EAAW,WAAiB,WAAI,CAAC,QAAQ;QAC9G,KAAK,CAAC,4BAAa,CAAC,eAAe,EAAE,WAAW,CAAC,MAAM,GAAG,QAAQ,CAAC,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC;QADvE,QAAG,GAAH,GAAG,CAAK;QAAW,gBAAW,GAAX,WAAW,CAAsB;QAAW,aAAQ,GAAR,QAAQ,CAAsB;IAElH,CAAC;IAED,MAAM,CAAC,gBAAgB,CAAC,MAAc,EAAE,SAAiB,CAAC;QACtD,IAAI,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE;YACzB,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;SACvC;QACD,MAAM,WAAW,GAAG,WAAI,CAAC,gBAAgB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAC1D,MAAM,IAAI,WAAW,CAAC,MAAM,CAAC;QAC7B,MAAM,QAAQ,GAAG,WAAI,CAAC,gBAAgB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACvD,MAAM,IAAI,QAAQ,CAAC,MAAM,CAAC;QAC1B,MAAM,GAAG,GAAG,oBAAU,CAAC,gBAAgB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACxD,OAAO,IAAI,iBAAiB,CAAC,GAAG,EAAE,WAAW,EAAE,QAAQ,CAAC,CAAC;IAC7D,CAAC;IAMD,QAAQ;QACJ,OAAO,MAAM,CAAC,MAAM,CAAC;YACjB,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE;YACtB,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE;YAC3B,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE;YACxB,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE;SAAC,CAAC,CAAC;IAC9B,CAAC;CACJ;AA5BD,8CA4BC"} \ No newline at end of file diff --git a/lib/protocol/KNXConnectResponse.d.ts b/lib/protocol/KNXConnectResponse.d.ts new file mode 100644 index 0000000..d164526 --- /dev/null +++ b/lib/protocol/KNXConnectResponse.d.ts @@ -0,0 +1,14 @@ +/// +import { KNXPacket } from './KNXPacket'; +import { HPAI } from './HPAI'; +import { CRD } from './CRD'; +export declare class KNXConnectResponse extends KNXPacket { + readonly channelID: number; + readonly status: number; + readonly hpai: HPAI; + readonly crd: CRD; + constructor(channelID: number, status: number, hpai: HPAI, crd: CRD); + static createFromBuffer(buffer: Buffer, offset?: number): KNXConnectResponse; + static statusToString(status: number): string; + toBuffer(): Buffer; +} diff --git a/lib/protocol/KNXConnectResponse.js b/lib/protocol/KNXConnectResponse.js new file mode 100644 index 0000000..aa8d67e --- /dev/null +++ b/lib/protocol/KNXConnectResponse.js @@ -0,0 +1,61 @@ +'use strict'; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.KNXConnectResponse = void 0; +const KNXConstants_1 = require("./KNXConstants"); +const KNXPacket_1 = require("./KNXPacket"); +const HPAI_1 = require("./HPAI"); +const CRD_1 = require("./CRD"); +class KNXConnectResponse extends KNXPacket_1.KNXPacket { + constructor(channelID, status, hpai, crd) { + super(KNXConstants_1.KNX_CONSTANTS.CONNECT_RESPONSE, hpai == null ? 2 : 2 + hpai.length + crd.length); + this.channelID = channelID; + this.status = status; + this.hpai = hpai; + this.crd = crd; + } + static createFromBuffer(buffer, offset = 0) { + if (offset + 2 > buffer.length) { + throw new Error('Buffer too short'); + } + const channelID = buffer.readUInt8(offset++); + const status = buffer.readUInt8(offset++); + let hpai, crd; + if (offset < buffer.length) { + hpai = HPAI_1.HPAI.createFromBuffer(buffer, offset); + offset += hpai.length; + crd = CRD_1.CRD.createFromBuffer(buffer, offset); + } + return new KNXConnectResponse(channelID, status, hpai, crd); + } + static statusToString(status) { + switch (status) { + case KNXConstants_1.KNX_CONSTANTS.E_SEQUENCE_NUMBER: + return 'Invalid Sequence Number'; + case KNXConstants_1.KNX_CONSTANTS.E_CONNECTION_TYPE: + return 'Invalid Connection Type'; + case KNXConstants_1.KNX_CONSTANTS.E_CONNECTION_OPTION: + return 'Invalid Connection Option'; + case KNXConstants_1.KNX_CONSTANTS.E_NO_MORE_CONNECTIONS: + return 'No More Connections'; + case KNXConstants_1.KNX_CONSTANTS.E_DATA_CONNECTION: + return 'Invalid Data Connection'; + case KNXConstants_1.KNX_CONSTANTS.E_KNX_CONNECTION: + return 'Invalid KNX Connection'; + case KNXConstants_1.KNX_CONSTANTS.E_TUNNELING_LAYER: + return 'Invalid Tunneling Layer'; + default: + return `Unknown error ${status}`; + } + } + toBuffer() { + const buffer = Buffer.alloc(2); + buffer.writeUInt8(this.channelID, 0); + buffer.writeUInt8(this.status, 1); + if (this.hpai == null) { + return buffer; + } + return Buffer.concat([buffer, this.hpai.toBuffer(), this.crd.toBuffer()]); + } +} +exports.KNXConnectResponse = KNXConnectResponse; +//# sourceMappingURL=KNXConnectResponse.js.map \ No newline at end of file diff --git a/lib/protocol/KNXConnectResponse.js.map b/lib/protocol/KNXConnectResponse.js.map new file mode 100644 index 0000000..5ca5ac9 --- /dev/null +++ b/lib/protocol/KNXConnectResponse.js.map @@ -0,0 +1 @@ +{"version":3,"file":"KNXConnectResponse.js","sourceRoot":"","sources":["../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,CAAC,cAAc,CAAC,MAAc;QAChC,QAAQ,MAAM,EAAE;YACZ,KAAK,4BAAa,CAAC,iBAAiB;gBAChC,OAAO,yBAAyB,CAAC;YACrC,KAAK,4BAAa,CAAC,iBAAiB;gBAChC,OAAO,yBAAyB,CAAC;YACrC,KAAK,4BAAa,CAAC,mBAAmB;gBAClC,OAAO,2BAA2B,CAAC;YACvC,KAAK,4BAAa,CAAC,qBAAqB;gBACpC,OAAO,qBAAqB,CAAC;YACjC,KAAK,4BAAa,CAAC,iBAAiB;gBAChC,OAAO,yBAAyB,CAAC;YACrC,KAAK,4BAAa,CAAC,gBAAgB;gBAC/B,OAAO,wBAAwB,CAAC;YACpC,KAAK,4BAAa,CAAC,iBAAiB;gBAChC,OAAO,yBAAyB,CAAC;YACrC;gBACI,OAAO,iBAAiB,MAAM,EAAE,CAAC;SACxC;IACL,CAAC;IAMD,QAAQ;QACJ,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAC/B,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;QACrC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;QAClC,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,EAAE;YACnB,OAAO,MAAM,CAAC;SACjB;QACD,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;IAC9E,CAAC;CACJ;AAtDD,gDAsDC"} \ No newline at end of file diff --git a/lib/protocol/KNXConnectionStateRequest.d.ts b/lib/protocol/KNXConnectionStateRequest.d.ts new file mode 100644 index 0000000..b0673fd --- /dev/null +++ b/lib/protocol/KNXConnectionStateRequest.d.ts @@ -0,0 +1,10 @@ +/// +import { KNXPacket } from './KNXPacket'; +import { HPAI } from './HPAI'; +export declare class KNXConnectionStateRequest extends KNXPacket { + readonly channelID: number; + readonly hpaiControl: HPAI; + constructor(channelID: number, hpaiControl?: HPAI); + static createFromBuffer(buffer: Buffer, offset?: number): KNXConnectionStateRequest; + toBuffer(): Buffer; +} diff --git a/lib/protocol/KNXConnectionStateRequest.js b/lib/protocol/KNXConnectionStateRequest.js new file mode 100644 index 0000000..6beb352 --- /dev/null +++ b/lib/protocol/KNXConnectionStateRequest.js @@ -0,0 +1,36 @@ +'use strict'; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.KNXConnectionStateRequest = void 0; +const KNXPacket_1 = require("./KNXPacket"); +const KNXConstants_1 = require("./KNXConstants"); +const HPAI_1 = require("./HPAI"); +class KNXConnectionStateRequest extends KNXPacket_1.KNXPacket { + constructor(channelID, hpaiControl = HPAI_1.HPAI.NULLHPAI) { + super(KNXConstants_1.KNX_CONSTANTS.CONNECTIONSTATE_REQUEST, hpaiControl.length + 2); + this.channelID = channelID; + this.hpaiControl = hpaiControl; + this.channelID = channelID; + this.hpaiControl = hpaiControl; + } + static createFromBuffer(buffer, offset = 0) { + if (offset >= buffer.length) { + throw new Error('Buffer too short'); + } + const channelID = buffer.readUInt8(offset++); + offset++; + const hpaiControl = HPAI_1.HPAI.createFromBuffer(buffer, offset); + return new KNXConnectionStateRequest(channelID, hpaiControl); + } + toBuffer() { + const buffer = Buffer.alloc(2); + buffer.writeUInt8(this.channelID, 0); + buffer.writeUInt8(0, 1); + return Buffer.concat([ + this.header.toBuffer(), + buffer, + this.hpaiControl.toBuffer() + ]); + } +} +exports.KNXConnectionStateRequest = KNXConnectionStateRequest; +//# sourceMappingURL=KNXConnectionStateRequest.js.map \ No newline at end of file diff --git a/lib/protocol/KNXConnectionStateRequest.js.map b/lib/protocol/KNXConnectionStateRequest.js.map new file mode 100644 index 0000000..e0a8cbc --- /dev/null +++ b/lib/protocol/KNXConnectionStateRequest.js.map @@ -0,0 +1 @@ +{"version":3,"file":"KNXConnectionState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9B,CAAC,CAAC;IACP,CAAC;CACJ;AA5BD,8DA4BC"} \ No newline at end of file diff --git a/lib/protocol/KNXConnectionStateResponse.d.ts b/lib/protocol/KNXConnectionStateResponse.d.ts new file mode 100644 index 0000000..64a8a75 --- /dev/null +++ b/lib/protocol/KNXConnectionStateResponse.d.ts @@ -0,0 +1,10 @@ +/// +import { ConnectionStatus } from './KNXConstants'; +import { KNXPacket } from './KNXPacket'; +export declare class KNXConnectionStateResponse extends KNXPacket { + readonly channelID: number; + readonly status: ConnectionStatus; + constructor(channelID: number, status: ConnectionStatus); + static createFromBuffer(buffer: Buffer, offset?: number): KNXConnectionStateResponse; + toBuffer(): Buffer; +} diff --git a/lib/protocol/KNXConnectionStateResponse.js b/lib/protocol/KNXConnectionStateResponse.js new file mode 100644 index 0000000..e550b66 --- /dev/null +++ b/lib/protocol/KNXConnectionStateResponse.js @@ -0,0 +1,28 @@ +'use strict'; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.KNXConnectionStateResponse = void 0; +const KNXConstants_1 = require("./KNXConstants"); +const KNXPacket_1 = require("./KNXPacket"); +class KNXConnectionStateResponse extends KNXPacket_1.KNXPacket { + constructor(channelID, status) { + super(KNXConstants_1.KNX_CONSTANTS.CONNECTIONSTATE_RESPONSE, 2); + this.channelID = channelID; + this.status = status; + } + static createFromBuffer(buffer, offset = 0) { + if (offset >= buffer.length) { + throw new Error('Buffer too short'); + } + const channelID = buffer.readUInt8(offset++); + const status = buffer.readUInt8(offset); + return new KNXConnectionStateResponse(channelID, status); + } + toBuffer() { + const buffer = Buffer.alloc(2); + buffer.writeUInt8(this.channelID, 0); + buffer.writeUInt8(this.status, 1); + return Buffer.concat([this.header.toBuffer(), buffer]); + } +} +exports.KNXConnectionStateResponse = KNXConnectionStateResponse; +//# sourceMappingURL=KNXConnectionStateResponse.js.map \ No newline at end of file diff --git a/lib/protocol/KNXConnectionStateResponse.js.map b/lib/protocol/KNXConnectionStateResponse.js.map new file mode 100644 index 0000000..f5ab4b7 --- /dev/null +++ b/lib/protocol/KNXConnectionStateResponse.js.map @@ -0,0 +1 @@ +{"version":3,"file":"KNXConnectionStateResponse.js","sourceRoot":"","sources":["../../src/protocol/KNXConnectionStateResponse.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AACb,iDAA+D;AAC/D,2CAAsC;AAEtC,MAAa,0BAA2B,SAAQ,qBAAS;IAMrD,YAAqB,SAAiB,EAAW,MAAwB;QACrE,KAAK,CAAC,4BAAa,CAAC,wBAAwB,EAAE,CAAC,CAAC,CAAC;QADhC,cAAS,GAAT,SAAS,CAAQ;QAAW,WAAM,GAAN,MAAM,CAAkB;IAEzE,CAAC;IAQD,MAAM,CAAC,gBAAgB,CAAC,MAAc,EAAE,MAAM,GAAG,CAAC;QAC9C,IAAI,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE;YACzB,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;SACvC;QACD,MAAM,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC;QAC7C,MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QACxC,OAAO,IAAI,0BAA0B,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;IAC7D,CAAC;IAMD,QAAQ;QACJ,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAC/B,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;QACrC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;QAClC,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC;IAC3D,CAAC;CACJ;AAnCD,gEAmCC"} \ No newline at end of file diff --git a/lib/protocol/KNXConstants.d.ts b/lib/protocol/KNXConstants.d.ts new file mode 100644 index 0000000..16ae975 --- /dev/null +++ b/lib/protocol/KNXConstants.d.ts @@ -0,0 +1,66 @@ +export declare const KNX_CONSTANTS: { + KNXNETIP_VERSION_10: number; + HEADER_SIZE_10: number; + SEARCH_REQUEST: number; + SEARCH_RESPONSE: number; + DESCRIPTION_REQUEST: number; + DESCRIPTION_RESPONSE: number; + CONNECT_REQUEST: number; + CONNECT_RESPONSE: number; + CONNECTIONSTATE_REQUEST: number; + CONNECTIONSTATE_RESPONSE: number; + DISCONNECT_REQUEST: number; + DISCONNECT_RESPONSE: number; + DEVICE_CONFIGURATION_REQUEST: number; + DEVICE_CONFIGURATION_ACK: number; + TUNNELING_REQUEST: number; + TUNNELING_ACK: number; + ROUTING_INDICATION: number; + ROUTING_LOST_MESSAGE: number; + DEVICE_MGMT_CONNECTION: number; + TUNNEL_CONNECTION: number; + REMLOG_CONNECTION: number; + REMCONF_CONNECTION: number; + OBJSVR_CONNECTION: number; + E_NO_ERROR: number; + E_HOST_PROTOCOL_TYPE: number; + E_VERSION_NOT_SUPPORTED: number; + E_SEQUENCE_NUMBER: number; + E_CONNECTION_ID: number; + E_CONNECTION_TYPE: number; + E_CONNECTION_OPTION: number; + E_NO_MORE_CONNECTIONS: number; + E_DATA_CONNECTION: number; + E_KNX_CONNECTION: number; + E_TUNNELING_LAYER: number; + DEVICE_INFO: number; + SUPP_SVC_FAMILIES: number; + IP_CONFIG: number; + IP_CUR_CONFIG: number; + KNX_ADDRESSES: number; + MFR_DATA: number; + TP1: number; + PL110: number; + RF: number; + IP: number; + IPV4_UDP: number; + IPV4_TCP: number; + SEARCH_TIMEOUT: number; + CONNECT_REQUEST_TIMEOUT: number; + CONNECTIONSTATE_REQUEST_TIMEOUT: number; + DEVICE_CONFIGURATION_REQUEST_TIMEOUT: number; + TUNNELING_REQUEST_TIMEOUT: number; + CONNECTION_ALIVE_TIME: number; + TUNNEL_LINKLAYER: number; + TUNNEL_RAW: number; + TUNNEL_BUSMONITOR: number; + KNX_PORT: number; + KNX_IP: string; + IPV4_ADDRESS_LENGTH: number; +}; +export declare enum ConnectionStatus { + E_CONNECTION_ID, + E_NO_ERROR, + E_DATA_CONNECTION, + E_KNX_CONNECTION +} diff --git a/lib/protocol/KNXConstants.js b/lib/protocol/KNXConstants.js new file mode 100644 index 0000000..2db12fa --- /dev/null +++ b/lib/protocol/KNXConstants.js @@ -0,0 +1,71 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.ConnectionStatus = exports.KNX_CONSTANTS = void 0; +exports.KNX_CONSTANTS = { + KNXNETIP_VERSION_10: 0x10, + HEADER_SIZE_10: 0x6, + SEARCH_REQUEST: 0x0201, + SEARCH_RESPONSE: 0x0202, + DESCRIPTION_REQUEST: 0x203, + DESCRIPTION_RESPONSE: 0x0204, + CONNECT_REQUEST: 0x0205, + CONNECT_RESPONSE: 0x0206, + CONNECTIONSTATE_REQUEST: 0x0207, + CONNECTIONSTATE_RESPONSE: 0x0208, + DISCONNECT_REQUEST: 0x0209, + DISCONNECT_RESPONSE: 0x020A, + DEVICE_CONFIGURATION_REQUEST: 0x0310, + DEVICE_CONFIGURATION_ACK: 0x0311, + TUNNELING_REQUEST: 0x0420, + TUNNELING_ACK: 0x0421, + ROUTING_INDICATION: 0x0530, + ROUTING_LOST_MESSAGE: 0x0531, + DEVICE_MGMT_CONNECTION: 0x03, + TUNNEL_CONNECTION: 0x04, + REMLOG_CONNECTION: 0x06, + REMCONF_CONNECTION: 0x07, + OBJSVR_CONNECTION: 0x08, + E_NO_ERROR: 0x00, + E_HOST_PROTOCOL_TYPE: 0x01, + E_VERSION_NOT_SUPPORTED: 0x02, + E_SEQUENCE_NUMBER: 0x04, + E_CONNECTION_ID: 0x21, + E_CONNECTION_TYPE: 0x22, + E_CONNECTION_OPTION: 0x23, + E_NO_MORE_CONNECTIONS: 0x24, + E_DATA_CONNECTION: 0x26, + E_KNX_CONNECTION: 0x27, + E_TUNNELING_LAYER: 0x29, + DEVICE_INFO: 0x01, + SUPP_SVC_FAMILIES: 0x02, + IP_CONFIG: 0x03, + IP_CUR_CONFIG: 0x04, + KNX_ADDRESSES: 0x05, + MFR_DATA: 0xFE, + TP1: 0x02, + PL110: 0x04, + RF: 0x10, + IP: 0x20, + IPV4_UDP: 0x01, + IPV4_TCP: 0x02, + SEARCH_TIMEOUT: 10, + CONNECT_REQUEST_TIMEOUT: 10, + CONNECTIONSTATE_REQUEST_TIMEOUT: 10, + DEVICE_CONFIGURATION_REQUEST_TIMEOUT: 10, + TUNNELING_REQUEST_TIMEOUT: 1, + CONNECTION_ALIVE_TIME: 120, + TUNNEL_LINKLAYER: 0x02, + TUNNEL_RAW: 0x04, + TUNNEL_BUSMONITOR: 0x80, + KNX_PORT: 3671, + KNX_IP: '224.0.23.12', + IPV4_ADDRESS_LENGTH: 4 +}; +var ConnectionStatus; +(function (ConnectionStatus) { + ConnectionStatus[ConnectionStatus["E_CONNECTION_ID"] = exports.KNX_CONSTANTS.E_CONNECTION_ID] = "E_CONNECTION_ID"; + ConnectionStatus[ConnectionStatus["E_NO_ERROR"] = exports.KNX_CONSTANTS.E_NO_ERROR] = "E_NO_ERROR"; + ConnectionStatus[ConnectionStatus["E_DATA_CONNECTION"] = exports.KNX_CONSTANTS.E_DATA_CONNECTION] = "E_DATA_CONNECTION"; + ConnectionStatus[ConnectionStatus["E_KNX_CONNECTION"] = exports.KNX_CONSTANTS.E_KNX_CONNECTION] = "E_KNX_CONNECTION"; +})(ConnectionStatus = exports.ConnectionStatus || (exports.ConnectionStatus = {})); +//# sourceMappingURL=KNXConstants.js.map \ No newline at end of file diff --git a/lib/protocol/KNXConstants.js.map b/lib/protocol/KNXConstants.js.map new file mode 100644 index 0000000..cf8c78a --- /dev/null +++ b/lib/protocol/KNXConstants.js.map @@ -0,0 +1 @@ +{"version":3,"file":"KNXConstants.js","sourceRoot":"","sources":["../../src/protocol/KNXConstants.ts"],"names":[],"mappings":";;;AAAa,QAAA,aAAa,GAAG;IACzB,mBAAmB,EAAE,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EAAE,EAAE;IACnC,oCAAoC,EAAE,EAAE;IACxC,yBAAyB,EAAE,CAAC;IAC5B,qBAAqB,EAAE,GAAG;IAE1B,gBAAgB,EAAE,IAAI;IACtB,UAAU,EAAE,IAAI;IAChB,iBAAiB,EAAE,IAAI;IAEvB,QAAQ,EAAE,IAAI;IACd,MAAM,EAAE,aAAa;IAErB,mBAAmB,EAAE,CAAC;CACzB,CAAC;AAEF,IAAY,gBAKX;AALD,WAAY,gBAAgB;IACxB,uDAAkB,qBAAa,CAAC,eAAe,qBAAA,CAAA;IAC/C,kDAAa,qBAAa,CAAC,UAAU,gBAAA,CAAA;IACrC,yDAAoB,qBAAa,CAAC,iBAAiB,uBAAA,CAAA;IACnD,wDAAmB,qBAAa,CAAC,gBAAgB,sBAAA,CAAA;AACrD,CAAC,EALW,gBAAgB,GAAhB,wBAAgB,KAAhB,wBAAgB,QAK3B"} \ No newline at end of file diff --git a/lib/protocol/KNXDataBuffer.d.ts b/lib/protocol/KNXDataBuffer.d.ts new file mode 100644 index 0000000..a7b45c7 --- /dev/null +++ b/lib/protocol/KNXDataBuffer.d.ts @@ -0,0 +1,11 @@ +/// +import { IDataPoint } from '../DataPoints/DataPointInterface'; +export declare class KNXDataBuffer { + private _data; + private _info?; + constructor(_data: Buffer, _info?: IDataPoint); + get length(): number; + get value(): Buffer; + get info(): IDataPoint | null; + sixBits(): boolean; +} diff --git a/lib/protocol/KNXDataBuffer.js b/lib/protocol/KNXDataBuffer.js new file mode 100644 index 0000000..622b7c4 --- /dev/null +++ b/lib/protocol/KNXDataBuffer.js @@ -0,0 +1,26 @@ +'use strict'; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.KNXDataBuffer = void 0; +class KNXDataBuffer { + constructor(_data, _info) { + this._data = _data; + this._info = _info; + } + get length() { + return this._data == null ? 0 : this._data.length; + } + get value() { + return this._data; + } + get info() { + return this._info; + } + sixBits() { + if (this.info == null) { + return true; + } + return this.info.type.type === '1'; + } +} +exports.KNXDataBuffer = KNXDataBuffer; +//# sourceMappingURL=KNXDataBuffer.js.map \ No newline at end of file diff --git a/lib/protocol/KNXDataBuffer.js.map b/lib/protocol/KNXDataBuffer.js.map new file mode 100644 index 0000000..f3ab7e9 --- /dev/null +++ b/lib/protocol/KNXDataBuffer.js.map @@ -0,0 +1 @@ +{"version":3,"file":"KNXDataBuffer.js","sourceRoot":"","sources":["../../src/protocol/KNXDataBuffer.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAIb,MAAa,aAAa;IAMtB,YAAoB,KAAa,EAAU,KAAkB;QAAzC,UAAK,GAAL,KAAK,CAAQ;QAAU,UAAK,GAAL,KAAK,CAAa;IAC7D,CAAC;IAED,IAAI,MAAM;QACN,OAAO,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;IACtD,CAAC;IAED,IAAI,KAAK;QACL,OAAO,IAAI,CAAC,KAAK,CAAC;IACtB,CAAC;IAED,IAAI,IAAI;QACJ,OAAO,IAAI,CAAC,KAAK,CAAC;IACtB,CAAC;IAED,OAAO;QACH,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,EAAE;YAAE,OAAO,IAAI,CAAC;SAAE;QACvC,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,GAAG,CAAC;IACvC,CAAC;CACJ;AAzBD,sCAyBC"} \ No newline at end of file diff --git a/lib/protocol/KNXDescriptionRequest.d.ts b/lib/protocol/KNXDescriptionRequest.d.ts new file mode 100644 index 0000000..7134b42 --- /dev/null +++ b/lib/protocol/KNXDescriptionRequest.d.ts @@ -0,0 +1,9 @@ +/// +import { KNXPacket } from './KNXPacket'; +import { HPAI } from './HPAI'; +export declare class KNXDescriptionRequest extends KNXPacket { + readonly hpai: HPAI; + constructor(hpai: HPAI); + static createFromBuffer(buffer: Buffer, offset?: number): KNXDescriptionRequest; + toBuffer(): Buffer; +} diff --git a/lib/protocol/KNXDescriptionRequest.js b/lib/protocol/KNXDescriptionRequest.js new file mode 100644 index 0000000..94b9929 --- /dev/null +++ b/lib/protocol/KNXDescriptionRequest.js @@ -0,0 +1,24 @@ +'use strict'; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.KNXDescriptionRequest = void 0; +const KNXConstants_1 = require("./KNXConstants"); +const KNXPacket_1 = require("./KNXPacket"); +const HPAI_1 = require("./HPAI"); +class KNXDescriptionRequest extends KNXPacket_1.KNXPacket { + constructor(hpai) { + super(KNXConstants_1.KNX_CONSTANTS.DESCRIPTION_REQUEST, hpai.length); + this.hpai = hpai; + } + static createFromBuffer(buffer, offset = 0) { + if (offset + this.length >= buffer.length) { + throw new Error('Buffer too short'); + } + const hpai = HPAI_1.HPAI.createFromBuffer(buffer, offset); + return new KNXDescriptionRequest(hpai); + } + toBuffer() { + return Buffer.concat([this.header.toBuffer(), this.hpai.toBuffer()]); + } +} +exports.KNXDescriptionRequest = KNXDescriptionRequest; +//# sourceMappingURL=KNXDescriptionRequest.js.map \ No newline at end of file diff --git a/lib/protocol/KNXDescriptionRequest.js.map b/lib/protocol/KNXDescriptionRequest.js.map new file mode 100644 index 0000000..d00d8b9 --- /dev/null +++ b/lib/protocol/KNXDescriptionRequest.js.map @@ -0,0 +1 @@ +{"version":3,"file":"KNXDescriptionRequest.js","sourceRoot":"","sources":["../../src/protocol/KNXDescriptionRequest.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AACb,iDAA6C;AAC7C,2CAAsC;AACtC,iCAA4B;AAE5B,MAAa,qBAAsB,SAAQ,qBAAS;IAChD,YAAqB,IAAU;QAC3B,KAAK,CAAC,4BAAa,CAAC,mBAAmB,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QADrC,SAAI,GAAJ,IAAI,CAAM;IAE/B,CAAC;IAED,MAAM,CAAC,gBAAgB,CAAC,MAAc,EAAE,SAAiB,CAAC;QACtD,IAAI,MAAM,GAAG,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE;YACvC,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;SACvC;QACD,MAAM,IAAI,GAAG,WAAI,CAAC,gBAAgB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACnD,OAAO,IAAI,qBAAqB,CAAC,IAAI,CAAC,CAAC;IAC3C,CAAC;IAED,QAAQ;QACJ,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,EAAE,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;IACzE,CAAC;CACJ;AAhBD,sDAgBC"} \ No newline at end of file diff --git a/lib/protocol/KNXDescriptionResponse.d.ts b/lib/protocol/KNXDescriptionResponse.d.ts new file mode 100644 index 0000000..23b94b1 --- /dev/null +++ b/lib/protocol/KNXDescriptionResponse.d.ts @@ -0,0 +1,11 @@ +/// +import { KNXPacket } from './KNXPacket'; +import { DeviceInfo } from './DeviceInfo'; +import ServiceFamilies from './ServiceFamilies'; +export declare class KNXDescriptionResponse extends KNXPacket { + readonly deviceInfo: DeviceInfo; + readonly serviceFamilies: ServiceFamilies; + constructor(deviceInfo: DeviceInfo, serviceFamilies: ServiceFamilies); + static createFromBuffer(buffer: Buffer, offset?: number): KNXDescriptionResponse; + toBuffer(): Buffer; +} diff --git a/lib/protocol/KNXDescriptionResponse.js b/lib/protocol/KNXDescriptionResponse.js new file mode 100644 index 0000000..d32b72b --- /dev/null +++ b/lib/protocol/KNXDescriptionResponse.js @@ -0,0 +1,35 @@ +'use strict'; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.KNXDescriptionResponse = void 0; +const KNXConstants_1 = require("./KNXConstants"); +const KNXPacket_1 = require("./KNXPacket"); +const DeviceInfo_1 = require("./DeviceInfo"); +const ServiceFamilies_1 = __importDefault(require("./ServiceFamilies")); +class KNXDescriptionResponse extends KNXPacket_1.KNXPacket { + constructor(deviceInfo, serviceFamilies) { + super(KNXConstants_1.KNX_CONSTANTS.DESCRIPTION_RESPONSE, deviceInfo.length + serviceFamilies.length); + this.deviceInfo = deviceInfo; + this.serviceFamilies = serviceFamilies; + } + static createFromBuffer(buffer, offset = 0) { + if (offset + this.length >= buffer.length) { + throw new Error('Buffer too short'); + } + const deviceInfo = DeviceInfo_1.DeviceInfo.createFromBuffer(buffer, offset); + offset += deviceInfo.length; + const serviceFamilies = ServiceFamilies_1.default.createFromBuffer(buffer, offset); + return new KNXDescriptionResponse(deviceInfo, serviceFamilies); + } + toBuffer() { + return Buffer.concat([ + this.header.toBuffer(), + this.deviceInfo.toBuffer(), + this.serviceFamilies.toBuffer() + ]); + } +} +exports.KNXDescriptionResponse = KNXDescriptionResponse; +//# sourceMappingURL=KNXDescriptionResponse.js.map \ No newline at end of file diff --git a/lib/protocol/KNXDescriptionResponse.js.map b/lib/protocol/KNXDescriptionResponse.js.map new file mode 100644 index 0000000..ea711b5 --- /dev/null +++ b/lib/protocol/KNXDescriptionResponse.js.map @@ -0,0 +1 @@ +{"version":3,"file":"KNXDescriptionResponse.js","sourceRoot":"","sources":["../../src/protocol/KNXDescriptionResponse.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;AACb,iDAA6C;AAC7C,2CAAsC;AACtC,6CAAwC;AACxC,wEAAgD;AAEhD,MAAa,sBAAuB,SAAQ,qBAAS;IAEjD,YAAqB,UAAsB,EAAW,eAAgC;QAClF,KAAK,CAAC,4BAAa,CAAC,oBAAoB,EAAE,UAAU,CAAC,MAAM,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;QADrE,eAAU,GAAV,UAAU,CAAY;QAAW,oBAAe,GAAf,eAAe,CAAiB;IAEtF,CAAC;IAED,MAAM,CAAC,gBAAgB,CAAC,MAAc,EAAE,SAAiB,CAAC;QACtD,IAAI,MAAM,GAAG,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE;YACvC,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;SACvC;QACD,MAAM,UAAU,GAAG,uBAAU,CAAC,gBAAgB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAC/D,MAAM,IAAI,UAAU,CAAC,MAAM,CAAC;QAC5B,MAAM,eAAe,GAAG,yBAAe,CAAC,gBAAgB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACzE,OAAO,IAAI,sBAAsB,CAAC,UAAU,EAAE,eAAe,CAAC,CAAC;IACnE,CAAC;IAMD,QAAQ;QACJ,OAAO,MAAM,CAAC,MAAM,CAAC;YACjB,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE;YACtB,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE;YAC1B,IAAI,CAAC,eAAe,CAAC,QAAQ,EAAE;SAClC,CAAC,CAAC;IACP,CAAC;CACJ;AA3BD,wDA2BC"} \ No newline at end of file diff --git a/lib/protocol/KNXDisconnectRequest.d.ts b/lib/protocol/KNXDisconnectRequest.d.ts new file mode 100644 index 0000000..ec343d0 --- /dev/null +++ b/lib/protocol/KNXDisconnectRequest.d.ts @@ -0,0 +1,10 @@ +/// +import { KNXPacket } from './KNXPacket'; +import { HPAI } from './HPAI'; +export declare class KNXDisconnectRequest extends KNXPacket { + readonly channelID: number; + readonly hpaiControl: HPAI; + constructor(channelID: number, hpaiControl?: HPAI); + static createFromBuffer(buffer: Buffer, offset?: number): KNXDisconnectRequest; + toBuffer(): Buffer; +} diff --git a/lib/protocol/KNXDisconnectRequest.js b/lib/protocol/KNXDisconnectRequest.js new file mode 100644 index 0000000..2ddad41 --- /dev/null +++ b/lib/protocol/KNXDisconnectRequest.js @@ -0,0 +1,34 @@ +'use strict'; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.KNXDisconnectRequest = void 0; +const KNXConstants_1 = require("./KNXConstants"); +const KNXPacket_1 = require("./KNXPacket"); +const HPAI_1 = require("./HPAI"); +class KNXDisconnectRequest extends KNXPacket_1.KNXPacket { + constructor(channelID, hpaiControl = HPAI_1.HPAI.NULLHPAI) { + super(KNXConstants_1.KNX_CONSTANTS.DISCONNECT_REQUEST, hpaiControl.length + 2); + this.channelID = channelID; + this.hpaiControl = hpaiControl; + } + static createFromBuffer(buffer, offset = 0) { + if (offset >= buffer.length) { + throw new Error('Buffer too short'); + } + const channelID = buffer.readUInt8(offset++); + offset++; + const hpaiControl = HPAI_1.HPAI.createFromBuffer(buffer, offset); + return new KNXDisconnectRequest(channelID, hpaiControl); + } + toBuffer() { + const buffer = Buffer.alloc(2); + buffer.writeUInt8(this.channelID, 0); + buffer.writeUInt8(0, 1); + return Buffer.concat([ + this.header.toBuffer(), + buffer, + this.hpaiControl.toBuffer() + ]); + } +} +exports.KNXDisconnectRequest = KNXDisconnectRequest; +//# sourceMappingURL=KNXDisconnectRequest.js.map \ No newline at end of file diff --git a/lib/protocol/KNXDisconnectRequest.js.map b/lib/protocol/KNXDisconnectRequest.js.map new file mode 100644 index 0000000..e1e610c --- /dev/null +++ b/lib/protocol/KNXDisconnectRequest.js.map @@ -0,0 +1 @@ +{"version":3,"file":"KNXDisconnectRequest.js","sourceRoot":"","sources":["../../src/protocol/KNXDisconnectRequest.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AACb,iDAA6C;AAC7C,2CAAsC;AACtC,iCAA4B;AAE5B,MAAa,oBAAqB,SAAQ,qBAAS;IAE/C,YAAqB,SAAiB,EAAW,cAAoB,WAAI,CAAC,QAAQ;QAC9E,KAAK,CAAC,4BAAa,CAAC,kBAAkB,EAAE,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QAD/C,cAAS,GAAT,SAAS,CAAQ;QAAW,gBAAW,GAAX,WAAW,CAAsB;IAElF,CAAC;IAED,MAAM,CAAC,gBAAgB,CAAC,MAAc,EAAE,SAAiB,CAAC;QACtD,IAAI,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE;YACzB,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;SACvC;QACD,MAAM,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC;QAE7C,MAAM,EAAE,CAAC;QACT,MAAM,WAAW,GAAG,WAAI,CAAC,gBAAgB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAC1D,OAAO,IAAI,oBAAoB,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;IAC5D,CAAC;IAED,QAAQ;QACJ,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAC/B,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;QACrC,MAAM,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACxB,OAAO,MAAM,CAAC,MAAM,CAAC;YACjB,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE;YACtB,MAAM;YACN,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE;SAC9B,CAAC,CAAC;IACP,CAAC;CACJ;AA3BD,oDA2BC"} \ No newline at end of file diff --git a/lib/protocol/KNXDisconnectResponse.d.ts b/lib/protocol/KNXDisconnectResponse.d.ts new file mode 100644 index 0000000..c43f678 --- /dev/null +++ b/lib/protocol/KNXDisconnectResponse.d.ts @@ -0,0 +1,10 @@ +/// +import { KNXPacket } from './KNXPacket'; +import { ConnectionStatus } from './KNXConstants'; +export declare class KNXDisconnectResponse extends KNXPacket { + readonly channelID: number; + readonly status: ConnectionStatus; + constructor(channelID: number, status: ConnectionStatus); + static createFromBuffer(buffer: Buffer, offset?: number): KNXDisconnectResponse; + toBuffer(): Buffer; +} diff --git a/lib/protocol/KNXDisconnectResponse.js b/lib/protocol/KNXDisconnectResponse.js new file mode 100644 index 0000000..2225c54 --- /dev/null +++ b/lib/protocol/KNXDisconnectResponse.js @@ -0,0 +1,28 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.KNXDisconnectResponse = void 0; +const KNXPacket_1 = require("./KNXPacket"); +const KNXConstants_1 = require("./KNXConstants"); +class KNXDisconnectResponse extends KNXPacket_1.KNXPacket { + constructor(channelID, status) { + super(KNXConstants_1.KNX_CONSTANTS.DISCONNECT_RESPONSE, 2); + this.channelID = channelID; + this.status = status; + } + static createFromBuffer(buffer, offset = 0) { + if (offset >= buffer.length) { + throw new Error('Buffer too short'); + } + const channelID = buffer.readUInt8(offset++); + const status = buffer.readUInt8(offset); + return new KNXDisconnectResponse(channelID, status); + } + toBuffer() { + const buffer = Buffer.alloc(2); + buffer.writeUInt8(this.channelID, 0); + buffer.writeUInt8(this.status, 1); + return Buffer.concat([this.header.toBuffer(), buffer]); + } +} +exports.KNXDisconnectResponse = KNXDisconnectResponse; +//# sourceMappingURL=KNXDisconnectResponse.js.map \ No newline at end of file diff --git a/lib/protocol/KNXDisconnectResponse.js.map b/lib/protocol/KNXDisconnectResponse.js.map new file mode 100644 index 0000000..a9fbf5c --- /dev/null +++ b/lib/protocol/KNXDisconnectResponse.js.map @@ -0,0 +1 @@ +{"version":3,"file":"KNXDisconnectResponse.js","sourceRoot":"","sources":["../../src/protocol/KNXDisconnectResponse.ts"],"names":[],"mappings":";;;AACA,2CAAsC;AACtC,iDAA+D;AAE/D,MAAa,qBAAsB,SAAQ,qBAAS;IAChD,YAAqB,SAAiB,EAAW,MAAwB;QACrE,KAAK,CAAC,4BAAa,CAAC,mBAAmB,EAAE,CAAC,CAAC,CAAC;QAD3B,cAAS,GAAT,SAAS,CAAQ;QAAW,WAAM,GAAN,MAAM,CAAkB;IAEzE,CAAC;IAED,MAAM,CAAC,gBAAgB,CAAC,MAAc,EAAE,SAAiB,CAAC;QACtD,IAAI,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE;YACzB,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;SACvC;QACD,MAAM,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC;QAC7C,MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QACxC,OAAO,IAAI,qBAAqB,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;IACxD,CAAC;IAED,QAAQ;QACJ,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAC/B,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;QACrC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;QAClC,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC;IAC3D,CAAC;CACJ;AApBD,sDAoBC"} \ No newline at end of file diff --git a/lib/protocol/KNXHeader.d.ts b/lib/protocol/KNXHeader.d.ts new file mode 100644 index 0000000..024e0d8 --- /dev/null +++ b/lib/protocol/KNXHeader.d.ts @@ -0,0 +1,12 @@ +/// +export declare class KNXHeader { + get headerLength(): number; + get version(): number; + readonly service_type: number; + private _headerLength; + private _version; + private length; + constructor(type: number, length: number); + static createFromBuffer(buffer: Buffer, offset?: number): KNXHeader; + toBuffer(): Buffer; +} diff --git a/lib/protocol/KNXHeader.js b/lib/protocol/KNXHeader.js new file mode 100644 index 0000000..d9edca9 --- /dev/null +++ b/lib/protocol/KNXHeader.js @@ -0,0 +1,54 @@ +'use strict'; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.KNXHeader = void 0; +const KNXConstants_1 = require("./KNXConstants"); +class KNXHeader { + constructor(type, length) { + this._headerLength = KNXConstants_1.KNX_CONSTANTS.HEADER_SIZE_10; + this._version = KNXConstants_1.KNX_CONSTANTS.KNXNETIP_VERSION_10; + this.service_type = type; + this.length = KNXConstants_1.KNX_CONSTANTS.HEADER_SIZE_10 + length; + } + get headerLength() { + return this._headerLength; + } + get version() { + return this._version; + } + static createFromBuffer(buffer, offset = 0) { + if (buffer.length < KNXConstants_1.KNX_CONSTANTS.HEADER_SIZE_10) { + throw new Error('Incomplete buffer'); + } + const header_length = buffer.readUInt8(offset); + if (header_length !== KNXConstants_1.KNX_CONSTANTS.HEADER_SIZE_10) { + throw new Error(`Invalid buffer length ${header_length}`); + } + offset += 1; + const version = buffer.readUInt8(offset); + if (version !== KNXConstants_1.KNX_CONSTANTS.KNXNETIP_VERSION_10) { + throw new Error(`Unknown version ${version}`); + } + offset += 1; + const type = buffer.readUInt16BE(offset); + offset += 2; + const length = buffer.readUInt16BE(offset); + if (length !== buffer.length) { + throw new Error(`Message length mismatch ${length}/${buffer.length}`); + } + return new KNXHeader(type, length - header_length); + } + toBuffer() { + const buffer = Buffer.alloc(this._headerLength); + let offset = 0; + buffer.writeUInt8(this._headerLength, offset); + offset += 1; + buffer.writeUInt8(this._version, offset); + offset += 1; + buffer.writeUInt16BE(this.service_type, offset); + offset += 2; + buffer.writeUInt16BE(this.length, offset); + return buffer; + } +} +exports.KNXHeader = KNXHeader; +//# sourceMappingURL=KNXHeader.js.map \ No newline at end of file diff --git a/lib/protocol/KNXHeader.js.map b/lib/protocol/KNXHeader.js.map new file mode 100644 index 0000000..7ffa624 --- /dev/null +++ b/lib/protocol/KNXHeader.js.map @@ -0,0 +1 @@ +{"version":3,"file":"KNXHeader.js","sourceRoot":"","sources":["../../src/protocol/KNXHeader.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AACb,iDAA6C;AAc7C,MAAa,SAAS;IAclB,YAAY,IAAY,EAAE,MAAc;QACpC,IAAI,CAAC,aAAa,GAAG,4BAAa,CAAC,cAAc,CAAC;QAClD,IAAI,CAAC,QAAQ,GAAG,4BAAa,CAAC,mBAAmB,CAAC;QAClD,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;QACzB,IAAI,CAAC,MAAM,GAAG,4BAAa,CAAC,cAAc,GAAG,MAAM,CAAC;IACxD,CAAC;IAjBD,IAA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,CAAC,CAAC;QACf,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;QAC9C,MAAM,IAAI,CAAC,CAAC;QACZ,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QACzC,MAAM,IAAI,CAAC,CAAC;QACZ,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;QAChD,MAAM,IAAI,CAAC,CAAC;QACZ,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAC1C,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ;AAxDD,8BAwDC"} \ No newline at end of file diff --git a/lib/protocol/KNXPacket.d.ts b/lib/protocol/KNXPacket.d.ts new file mode 100644 index 0000000..48e5206 --- /dev/null +++ b/lib/protocol/KNXPacket.d.ts @@ -0,0 +1,10 @@ +/// +import { KNXHeader } from './KNXHeader'; +export declare class KNXPacket { + readonly type: number; + readonly length: number; + private _header; + constructor(type: number, length: number); + get header(): KNXHeader; + toBuffer(): Buffer; +} diff --git a/lib/protocol/KNXPacket.js b/lib/protocol/KNXPacket.js new file mode 100644 index 0000000..4cc267b --- /dev/null +++ b/lib/protocol/KNXPacket.js @@ -0,0 +1,21 @@ +'use strict'; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.KNXPacket = void 0; +const KNXHeader_1 = require("./KNXHeader"); +class KNXPacket { + constructor(type, length) { + this.type = type; + this.length = length; + this._header = new KNXHeader_1.KNXHeader(type, length); + this.type = type; + this.length = length; + } + get header() { + return this._header; + } + toBuffer() { + return Buffer.alloc(0); + } +} +exports.KNXPacket = KNXPacket; +//# sourceMappingURL=KNXPacket.js.map \ No newline at end of file diff --git a/lib/protocol/KNXPacket.js.map b/lib/protocol/KNXPacket.js.map new file mode 100644 index 0000000..a97f1a1 --- /dev/null +++ b/lib/protocol/KNXPacket.js.map @@ -0,0 +1 @@ +{"version":3,"file":"KNXPacket.js","sourceRoot":"","sources":["../../src/protocol/KNXPacket.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AACb,2CAAsC;AAEtC,MAAa,SAAS;IAElB,YAAqB,IAAY,EAAW,MAAc;QAArC,SAAI,GAAJ,IAAI,CAAQ;QAAW,WAAM,GAAN,MAAM,CAAQ;QAClD,IAAI,CAAC,OAAO,GAAG,IAAI,qBAAS,CAC5B,IAAI,EACJ,MAAM,CACT,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACzB,CAAC;IAED,IAAI,MAAM;QACN,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IAED,QAAQ;QACJ,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAC3B,CAAC;CACJ;AAlBD,8BAkBC"} \ No newline at end of file diff --git a/lib/protocol/KNXProtocol.d.ts b/lib/protocol/KNXProtocol.d.ts new file mode 100644 index 0000000..969f731 --- /dev/null +++ b/lib/protocol/KNXProtocol.d.ts @@ -0,0 +1,31 @@ +/// +import { ConnectionStatus } from './KNXConstants'; +import { KNXHeader } from './KNXHeader'; +import { KNXSearchRequest } from './KNXSearchRequest'; +import { KNXDescriptionRequest } from './KNXDescriptionRequest'; +import { KNXConnectRequest } from './KNXConnectRequest'; +import { KNXConnectionStateRequest } from './KNXConnectionStateRequest'; +import { KNXDisconnectRequest } from './KNXDisconnectRequest'; +import { KNXDisconnectResponse } from './KNXDisconnectResponse'; +import { KNXTunnelingRequest } from './KNXTunnelingRequest'; +import { KNXTunnelingAck } from './KNXTunnelingAck'; +import { HPAI } from './HPAI'; +import { CRI } from './CRI'; +import { KNXPacket } from './KNXPacket'; +import { CEMIMessage } from './cEMI/CEMIMessage'; +export interface KNXProtocolInfo { + knxHeader: KNXHeader; + knxMessage: KNXPacket; + knxData: Buffer; +} +export declare class KNXProtocol { + static parseMessage(buffer: Buffer): KNXProtocolInfo; + static newKNXSearchRequest(hpai: HPAI): KNXSearchRequest; + static newKNXDescriptionRequest(hpai: HPAI): KNXDescriptionRequest; + static newKNXConnectRequest(cri: CRI, hpaiControl?: HPAI, hpaiData?: HPAI): KNXConnectRequest; + static newKNXConnectionStateRequest(channelID: number, hpaiControl?: HPAI): KNXConnectionStateRequest; + static newKNXDisconnectRequest(channelID: number, hpaiControl?: HPAI): KNXDisconnectRequest; + static newKNXDisconnectResponse(channelID: number, status: ConnectionStatus): KNXDisconnectResponse; + static newKNXTunnelingACK(channelID: number, seqCounter: number, status: ConnectionStatus): KNXTunnelingAck; + static newKNXTunnelingRequest(channelID: number, seqCounter: number, cEMIMessage: CEMIMessage): KNXTunnelingRequest; +} diff --git a/lib/protocol/KNXProtocol.js b/lib/protocol/KNXProtocol.js new file mode 100644 index 0000000..e6d9ad8 --- /dev/null +++ b/lib/protocol/KNXProtocol.js @@ -0,0 +1,90 @@ +'use strict'; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.KNXProtocol = void 0; +const KNXConstants_1 = require("./KNXConstants"); +const KNXHeader_1 = require("./KNXHeader"); +const KNXSearchRequest_1 = require("./KNXSearchRequest"); +const KNXSearchResponse_1 = require("./KNXSearchResponse"); +const KNXDescriptionRequest_1 = require("./KNXDescriptionRequest"); +const KNXDescriptionResponse_1 = require("./KNXDescriptionResponse"); +const KNXConnectRequest_1 = require("./KNXConnectRequest"); +const KNXConnectResponse_1 = require("./KNXConnectResponse"); +const KNXConnectionStateRequest_1 = require("./KNXConnectionStateRequest"); +const KNXConnectionStateResponse_1 = require("./KNXConnectionStateResponse"); +const KNXDisconnectRequest_1 = require("./KNXDisconnectRequest"); +const KNXDisconnectResponse_1 = require("./KNXDisconnectResponse"); +const KNXTunnelingRequest_1 = require("./KNXTunnelingRequest"); +const KNXTunnelingAck_1 = require("./KNXTunnelingAck"); +const HPAI_1 = require("./HPAI"); +class KNXProtocol { + static parseMessage(buffer) { + const knxHeader = KNXHeader_1.KNXHeader.createFromBuffer(buffer); + const knxData = buffer.slice(knxHeader.headerLength); + let knxMessage; + switch (knxHeader.service_type) { + case KNXConstants_1.KNX_CONSTANTS.SEARCH_REQUEST: + knxMessage = KNXSearchRequest_1.KNXSearchRequest.createFromBuffer(knxData); + break; + case KNXConstants_1.KNX_CONSTANTS.SEARCH_RESPONSE: + knxMessage = KNXSearchResponse_1.KNXSearchResponse.createFromBuffer(knxData); + break; + case KNXConstants_1.KNX_CONSTANTS.DESCRIPTION_REQUEST: + knxMessage = KNXDescriptionRequest_1.KNXDescriptionRequest.createFromBuffer(knxData); + break; + case KNXConstants_1.KNX_CONSTANTS.DESCRIPTION_RESPONSE: + knxMessage = KNXDescriptionResponse_1.KNXDescriptionResponse.createFromBuffer(knxData); + break; + case KNXConstants_1.KNX_CONSTANTS.CONNECT_REQUEST: + knxMessage = KNXDescriptionResponse_1.KNXDescriptionResponse.createFromBuffer(knxData); + break; + case KNXConstants_1.KNX_CONSTANTS.CONNECT_RESPONSE: + knxMessage = KNXConnectResponse_1.KNXConnectResponse.createFromBuffer(knxData); + break; + case KNXConstants_1.KNX_CONSTANTS.CONNECTIONSTATE_REQUEST: + knxMessage = KNXConnectionStateRequest_1.KNXConnectionStateRequest.createFromBuffer(knxData); + break; + case KNXConstants_1.KNX_CONSTANTS.CONNECTIONSTATE_RESPONSE: + knxMessage = KNXConnectionStateResponse_1.KNXConnectionStateResponse.createFromBuffer(knxData); + break; + case KNXConstants_1.KNX_CONSTANTS.DISCONNECT_REQUEST: + knxMessage = KNXDisconnectRequest_1.KNXDisconnectRequest.createFromBuffer(knxData); + break; + case KNXConstants_1.KNX_CONSTANTS.DISCONNECT_RESPONSE: + knxMessage = KNXDisconnectResponse_1.KNXDisconnectResponse.createFromBuffer(knxData); + break; + case KNXConstants_1.KNX_CONSTANTS.TUNNELING_REQUEST: + knxMessage = KNXTunnelingRequest_1.KNXTunnelingRequest.createFromBuffer(knxData); + break; + case KNXConstants_1.KNX_CONSTANTS.TUNNELING_ACK: + knxMessage = KNXTunnelingAck_1.KNXTunnelingAck.createFromBuffer(buffer); + break; + } + return { knxHeader, knxMessage, knxData }; + } + static newKNXSearchRequest(hpai) { + return new KNXSearchRequest_1.KNXSearchRequest(hpai); + } + static newKNXDescriptionRequest(hpai) { + return new KNXDescriptionRequest_1.KNXDescriptionRequest(hpai); + } + static newKNXConnectRequest(cri, hpaiControl = HPAI_1.HPAI.NULLHPAI, hpaiData = HPAI_1.HPAI.NULLHPAI) { + return new KNXConnectRequest_1.KNXConnectRequest(cri, hpaiControl, hpaiData); + } + static newKNXConnectionStateRequest(channelID, hpaiControl = HPAI_1.HPAI.NULLHPAI) { + return new KNXConnectionStateRequest_1.KNXConnectionStateRequest(channelID, hpaiControl); + } + static newKNXDisconnectRequest(channelID, hpaiControl = HPAI_1.HPAI.NULLHPAI) { + return new KNXDisconnectRequest_1.KNXDisconnectRequest(channelID, hpaiControl); + } + static newKNXDisconnectResponse(channelID, status) { + return new KNXDisconnectResponse_1.KNXDisconnectResponse(channelID, status); + } + static newKNXTunnelingACK(channelID, seqCounter, status) { + return new KNXTunnelingAck_1.KNXTunnelingAck(channelID, seqCounter, status); + } + static newKNXTunnelingRequest(channelID, seqCounter, cEMIMessage) { + return new KNXTunnelingRequest_1.KNXTunnelingRequest(channelID, seqCounter, cEMIMessage); + } +} +exports.KNXProtocol = KNXProtocol; +//# sourceMappingURL=KNXProtocol.js.map \ No newline at end of file diff --git a/lib/protocol/KNXProtocol.js.map b/lib/protocol/KNXProtocol.js.map new file mode 100644 index 0000000..bc31ac8 --- /dev/null +++ b/lib/protocol/KNXProtocol.js.map @@ -0,0 +1 @@ +{"version":3,"file":"KNXProtocol.js","sourceRoot":"","sources":["../../src/protocol/KNXProtocol.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AACb,iDAA+D;AAC/D,2CAAsC;AACtC,yDAAoD;AACpD,2DAAsD;AACtD,mEAA8D;AAC9D,qEAAgE;AAChE,2DAAsD;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EAAE,WAAW,CAAC,CAAC;IAC5D,CAAC;IAED,MAAM,CAAC,wBAAwB,CAAC,SAAiB,EAAE,MAAwB;QACvE,OAAO,IAAI,6CAAqB,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;IACxD,CAAC;IAED,MAAM,CAAC,kBAAkB,CAAC,SAAiB,EAAE,UAAkB,EAAE,MAAwB;QACrF,OAAO,IAAI,iCAAe,CAAC,SAAS,EAAE,UAAU,EAAE,MAAM,CAAC,CAAC;IAC9D,CAAC;IAED,MAAM,CAAC,sBAAsB,CAAC,SAAiB,EAAE,UAAkB,EAAE,WAAwB;QACzF,OAAO,IAAI,yCAAmB,CAAC,SAAS,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC;IACvE,CAAC;CACJ;AAlFD,kCAkFC"} \ No newline at end of file diff --git a/lib/protocol/KNXSearchRequest.d.ts b/lib/protocol/KNXSearchRequest.d.ts new file mode 100644 index 0000000..cb5e15a --- /dev/null +++ b/lib/protocol/KNXSearchRequest.d.ts @@ -0,0 +1,9 @@ +/// +import { KNXPacket } from './KNXPacket'; +import { HPAI } from './HPAI'; +export declare class KNXSearchRequest extends KNXPacket { + readonly hpai: HPAI; + constructor(hpai: HPAI); + static createFromBuffer(buffer: Buffer, offset?: number): KNXSearchRequest; + toBuffer(): Buffer; +} diff --git a/lib/protocol/KNXSearchRequest.js b/lib/protocol/KNXSearchRequest.js new file mode 100644 index 0000000..e4bdf26 --- /dev/null +++ b/lib/protocol/KNXSearchRequest.js @@ -0,0 +1,24 @@ +'use strict'; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.KNXSearchRequest = void 0; +const KNXConstants_1 = require("./KNXConstants"); +const KNXPacket_1 = require("./KNXPacket"); +const HPAI_1 = require("./HPAI"); +class KNXSearchRequest extends KNXPacket_1.KNXPacket { + constructor(hpai) { + super(KNXConstants_1.KNX_CONSTANTS.SEARCH_REQUEST, hpai.length); + this.hpai = hpai; + } + static createFromBuffer(buffer, offset = 0) { + if (offset >= buffer.length) { + throw new Error('Buffer too short'); + } + const hpai = HPAI_1.HPAI.createFromBuffer(buffer, offset); + return new KNXSearchRequest(hpai); + } + toBuffer() { + return Buffer.concat([this.header.toBuffer(), this.hpai.toBuffer()]); + } +} +exports.KNXSearchRequest = KNXSearchRequest; +//# sourceMappingURL=KNXSearchRequest.js.map \ No newline at end of file diff --git a/lib/protocol/KNXSearchRequest.js.map b/lib/protocol/KNXSearchRequest.js.map new file mode 100644 index 0000000..a054124 --- /dev/null +++ b/lib/protocol/KNXSearchRequest.js.map @@ -0,0 +1 @@ +{"version":3,"file":"KNXSearchRequest.js","sourceRoot":"","sources":["../../src/protocol/KNXSearchRequest.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AACb,iDAA6C;AAC7C,2CAAsC;AACtC,iCAA4B;AAE5B,MAAa,gBAAiB,SAAQ,qBAAS;IAC3C,YAAqB,IAAU;QAC3B,KAAK,CAAC,4BAAa,CAAC,cAAc,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QADhC,SAAI,GAAJ,IAAI,CAAM;IAE/B,CAAC;IAED,MAAM,CAAC,gBAAgB,CAAC,MAAc,EAAE,SAAiB,CAAC;QACtD,IAAI,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE;YACzB,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;SACvC;QACD,MAAM,IAAI,GAAG,WAAI,CAAC,gBAAgB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACnD,OAAO,IAAI,gBAAgB,CAAC,IAAI,CAAC,CAAC;IACtC,CAAC;IAED,QAAQ;QACJ,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,EAAE,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;IACzE,CAAC;CACJ;AAhBD,4CAgBC"} \ No newline at end of file diff --git a/lib/protocol/KNXSearchResponse.d.ts b/lib/protocol/KNXSearchResponse.d.ts new file mode 100644 index 0000000..6f3fbf9 --- /dev/null +++ b/lib/protocol/KNXSearchResponse.d.ts @@ -0,0 +1,13 @@ +/// +import { KNXPacket } from './KNXPacket'; +import { DeviceInfo } from './DeviceInfo'; +import ServiceFamilies from './ServiceFamilies'; +import { HPAI } from './HPAI'; +export declare class KNXSearchResponse extends KNXPacket { + readonly hpai: HPAI; + readonly deviceInfo: DeviceInfo; + readonly serviceFamilies: ServiceFamilies; + constructor(hpai: HPAI, deviceInfo: DeviceInfo, serviceFamilies: ServiceFamilies); + static createFromBuffer(buffer: Buffer, offset?: number): KNXSearchResponse; + toBuffer(): Buffer; +} diff --git a/lib/protocol/KNXSearchResponse.js b/lib/protocol/KNXSearchResponse.js new file mode 100644 index 0000000..89f7f1a --- /dev/null +++ b/lib/protocol/KNXSearchResponse.js @@ -0,0 +1,37 @@ +'use strict'; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.KNXSearchResponse = void 0; +const KNXConstants_1 = require("./KNXConstants"); +const KNXPacket_1 = require("./KNXPacket"); +const DeviceInfo_1 = require("./DeviceInfo"); +const ServiceFamilies_1 = __importDefault(require("./ServiceFamilies")); +const HPAI_1 = require("./HPAI"); +class KNXSearchResponse extends KNXPacket_1.KNXPacket { + constructor(hpai, deviceInfo, serviceFamilies) { + super(KNXConstants_1.KNX_CONSTANTS.SEARCH_RESPONSE, hpai.length + deviceInfo.length + serviceFamilies.length); + this.hpai = hpai; + this.deviceInfo = deviceInfo; + this.serviceFamilies = serviceFamilies; + } + static createFromBuffer(buffer, offset = 0) { + const hpai = HPAI_1.HPAI.createFromBuffer(buffer, offset); + offset += hpai.length; + const deviceInfo = DeviceInfo_1.DeviceInfo.createFromBuffer(buffer, offset); + offset += deviceInfo.length; + const serviceFamilies = ServiceFamilies_1.default.createFromBuffer(buffer, offset); + return new KNXSearchResponse(hpai, deviceInfo, serviceFamilies); + } + toBuffer() { + return Buffer.concat([ + this.header.toBuffer(), + this.hpai.toBuffer(), + this.deviceInfo.toBuffer(), + this.serviceFamilies.toBuffer() + ]); + } +} +exports.KNXSearchResponse = KNXSearchResponse; +//# sourceMappingURL=KNXSearchResponse.js.map \ No newline at end of file diff --git a/lib/protocol/KNXSearchResponse.js.map b/lib/protocol/KNXSearchResponse.js.map new file mode 100644 index 0000000..21e840e --- /dev/null +++ b/lib/protocol/KNXSearchResponse.js.map @@ -0,0 +1 @@ +{"version":3,"file":"KNXSearchResponse.js","sourceRoot":"","sources":["../../src/protocol/KNXSearchResponse.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;AACb,iDAA6C;AAC7C,2CAAsC;AACtC,6CAAwC;AACxC,wEAAgD;AAChD,iCAA4B;AAE5B,MAAa,iBAAkB,SAAQ,qBAAS;IAO5C,YAAqB,IAAU,EAAW,UAAsB,EAAW,eAAgC;QACvG,KAAK,CAAC,4BAAa,CAAC,eAAe,EAAE,IAAI,CAAC,MAAM,GAAG,UAAU,CAAC,MAAM,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;QAD9E,SAAI,GAAJ,IAAI,CAAM;QAAW,eAAU,GAAV,UAAU,CAAY;QAAW,oBAAe,GAAf,eAAe,CAAiB;IAG3G,CAAC;IAED,MAAM,CAAC,gBAAgB,CAAC,MAAc,EAAE,SAAiB,CAAC;QACtD,MAAM,IAAI,GAAG,WAAI,CAAC,gBAAgB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACnD,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC;QACtB,MAAM,UAAU,GAAG,uBAAU,CAAC,gBAAgB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAC/D,MAAM,IAAI,UAAU,CAAC,MAAM,CAAC;QAC5B,MAAM,eAAe,GAAG,yBAAe,CAAC,gBAAgB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACzE,OAAO,IAAI,iBAAiB,CAAC,IAAI,EAAE,UAAU,EAAE,eAAe,CAAC,CAAC;IACpE,CAAC;IAED,QAAQ;QACJ,OAAO,MAAM,CAAC,MAAM,CAAC;YACjB,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE;YACtB,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;YACpB,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE;YAC1B,IAAI,CAAC,eAAe,CAAC,QAAQ,EAAE;SAClC,CAAC,CAAC;IACP,CAAC;CAEJ;AA9BD,8CA8BC"} \ No newline at end of file diff --git a/lib/protocol/KNXTunnelingAck.d.ts b/lib/protocol/KNXTunnelingAck.d.ts new file mode 100644 index 0000000..be94471 --- /dev/null +++ b/lib/protocol/KNXTunnelingAck.d.ts @@ -0,0 +1,10 @@ +/// +import { KNXPacket } from './KNXPacket'; +export declare class KNXTunnelingAck extends KNXPacket { + readonly channelID: number; + readonly seqCounter: number; + readonly status: number; + constructor(channelID: number, seqCounter: number, status: number); + static createFromBuffer(buffer: Buffer, offset?: number): KNXTunnelingAck; + toBuffer(): Buffer; +} diff --git a/lib/protocol/KNXTunnelingAck.js b/lib/protocol/KNXTunnelingAck.js new file mode 100644 index 0000000..9e272d0 --- /dev/null +++ b/lib/protocol/KNXTunnelingAck.js @@ -0,0 +1,37 @@ +'use strict'; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.KNXTunnelingAck = void 0; +const KNXPacket_1 = require("./KNXPacket"); +const KNXConstants_1 = require("./KNXConstants"); +class KNXTunnelingAck extends KNXPacket_1.KNXPacket { + constructor(channelID, seqCounter, status) { + super(KNXConstants_1.KNX_CONSTANTS.TUNNELING_ACK, 4); + this.channelID = channelID; + this.seqCounter = seqCounter; + this.status = status; + } + static createFromBuffer(buffer, offset = 0) { + if (offset >= buffer.length) { + throw new Error('Buffer too short'); + } + const structureLength = buffer.readUInt8(offset); + if (offset + structureLength > buffer.length) { + throw new Error('Buffer too short'); + } + offset += 1; + const channelID = buffer.readUInt8(offset++); + const seqCounter = buffer.readUInt8(offset++); + const status = buffer.readUInt8(offset); + return new KNXTunnelingAck(channelID, seqCounter, status); + } + toBuffer() { + const buffer = Buffer.alloc(this.length); + buffer.writeUInt8(this.length, 0); + buffer.writeUInt8(this.channelID, 1); + buffer.writeUInt8(this.seqCounter, 2); + buffer.writeUInt8(this.status, 3); + return Buffer.concat([this.header.toBuffer(), buffer]); + } +} +exports.KNXTunnelingAck = KNXTunnelingAck; +//# sourceMappingURL=KNXTunnelingAck.js.map \ No newline at end of file diff --git a/lib/protocol/KNXTunnelingAck.js.map b/lib/protocol/KNXTunnelingAck.js.map new file mode 100644 index 0000000..9d9174e --- /dev/null +++ b/lib/protocol/KNXTunnelingAck.js.map @@ -0,0 +1 @@ +{"version":3,"file":"KNXTunnelingAck.js","sourceRoot":"","sources":["../../src/protocol/KNXTunnelingAck.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AACb,2CAAsC;AACtC,iDAA6C;AAE7C,MAAa,eAAgB,SAAQ,qBAAS;IAO1C,YAAqB,SAAiB,EAAW,UAAkB,EAAW,MAAc;QACxF,KAAK,CAAC,4BAAa,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC;QADrB,cAAS,GAAT,SAAS,CAAQ;QAAW,eAAU,GAAV,UAAU,CAAQ;QAAW,WAAM,GAAN,MAAM,CAAQ;IAE5F,CAAC;IAED,MAAM,CAAC,gBAAgB,CAAC,MAAc,EAAE,SAAiB,CAAC;QACtD,IAAI,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE;YACzB,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;SACvC;QACD,MAAM,eAAe,GAAG,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QACjD,IAAI,MAAM,GAAG,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE;YAC1C,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;SACvC;QACD,MAAM,IAAI,CAAC,CAAC;QACZ,MAAM,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC;QAC7C,MAAM,UAAU,GAAG,MAAM,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC;QAC9C,MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QACxC,OAAO,IAAI,eAAe,CAAC,SAAS,EAAE,UAAU,EAAE,MAAM,CAAC,CAAC;IAC9D,CAAC;IAED,QAAQ;QACJ,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACzC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;QAClC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;QACrC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC;QACtC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;QAClC,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC;IAC3D,CAAC;CACJ;AAlCD,0CAkCC"} \ No newline at end of file diff --git a/lib/protocol/KNXTunnelingRequest.d.ts b/lib/protocol/KNXTunnelingRequest.d.ts new file mode 100644 index 0000000..ef7a25b --- /dev/null +++ b/lib/protocol/KNXTunnelingRequest.d.ts @@ -0,0 +1,12 @@ +/// +import { KNXPacket } from './KNXPacket'; +import { CEMIMessage } from './cEMI/CEMIMessage'; +export declare class KNXTunnelingRequest extends KNXPacket { + readonly channelID: number; + readonly seqCounter: number; + readonly cEMIMessage: CEMIMessage; + constructor(channelID: number, seqCounter: number, cEMIMessage: CEMIMessage); + static parseCEMIMessage(buffer: Buffer, offset: number): CEMIMessage; + static createFromBuffer(buffer: Buffer, offset?: number): KNXTunnelingRequest; + toBuffer(): Buffer; +} diff --git a/lib/protocol/KNXTunnelingRequest.js b/lib/protocol/KNXTunnelingRequest.js new file mode 100644 index 0000000..6ac8e79 --- /dev/null +++ b/lib/protocol/KNXTunnelingRequest.js @@ -0,0 +1,46 @@ +'use strict'; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.KNXTunnelingRequest = void 0; +const KNXPacket_1 = require("./KNXPacket"); +const KNXConstants_1 = require("./KNXConstants"); +const CEMIFactory_1 = require("./cEMI/CEMIFactory"); +class KNXTunnelingRequest extends KNXPacket_1.KNXPacket { + constructor(channelID, seqCounter, cEMIMessage) { + super(KNXConstants_1.KNX_CONSTANTS.TUNNELING_REQUEST, 4 + cEMIMessage.length); + this.channelID = channelID; + this.seqCounter = seqCounter; + this.cEMIMessage = cEMIMessage; + } + static parseCEMIMessage(buffer, offset) { + if (offset > buffer.length) { + throw new Error('Buffer too short'); + } + const msgCode = buffer.readUInt8(offset++); + return CEMIFactory_1.CEMIFactory.createFromBuffer(msgCode, buffer, offset); + } + static createFromBuffer(buffer, offset = 0) { + if (offset >= buffer.length) { + throw new Error('Buffer too short'); + } + const structureLength = buffer.readUInt8(offset); + if (offset + structureLength > buffer.length) { + throw new Error('Buffer too short'); + } + offset += 1; + const channelID = buffer.readUInt8(offset++); + const seqCounter = buffer.readUInt8(offset++); + offset++; + const cEMIMessage = this.parseCEMIMessage(buffer, offset); + return new KNXTunnelingRequest(channelID, seqCounter, cEMIMessage); + } + toBuffer() { + const buffer = Buffer.alloc(4); + buffer.writeUInt8(4, 0); + buffer.writeUInt8(this.channelID, 1); + buffer.writeUInt8(this.seqCounter, 2); + buffer.writeUInt8(0, 3); + return Buffer.concat([this.header.toBuffer(), buffer, this.cEMIMessage.toBuffer()]); + } +} +exports.KNXTunnelingRequest = KNXTunnelingRequest; +//# sourceMappingURL=KNXTunnelingRequest.js.map \ No newline at end of file diff --git a/lib/protocol/KNXTunnelingRequest.js.map b/lib/protocol/KNXTunnelingRequest.js.map new file mode 100644 index 0000000..a331694 --- /dev/null +++ b/lib/protocol/KNXTunnelingRequest.js.map @@ -0,0 +1 @@ +{"version":3,"file":"KNXTunnelingRequest.js","sourceRoot":"","sources":["../../src/protocol/KNXTunnelingRequest.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AACb,2CAAsC;AACtC,iDAA6C;AAC7C,oDAA+C;AAG/C,MAAa,mBAAoB,SAAQ,qBAAS;IAC9C,YAAqB,SAAiB,EAAW,UAAkB,EAAW,WAAwB;QAClG,KAAK,CAAC,4BAAa,CAAC,iBAAiB,EAAE,CAAC,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;QAD9C,cAAS,GAAT,SAAS,CAAQ;QAAW,eAAU,GAAV,UAAU,CAAQ;QAAW,gBAAW,GAAX,WAAW,CAAa;IAEtG,CAAC;IAED,MAAM,CAAC,gBAAgB,CAAC,MAAc,EAAE,MAAc;QAClD,IAAI,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE;YACxB,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;SACvC;QACD,MAAM,OAAO,GAAI,MAAM,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC;QAC5C,OAAO,yBAAW,CAAC,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACjE,CAAC;IAED,MAAM,CAAC,gBAAgB,CAAC,MAAc,EAAE,SAAiB,CAAC;QACtD,IAAI,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE;YACzB,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;SACvC;QACD,MAAM,eAAe,GAAG,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QACjD,IAAI,MAAM,GAAG,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE;YAC1C,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;SACvC;QACD,MAAM,IAAI,CAAC,CAAC;QACZ,MAAM,SAAS,GAAI,MAAM,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC;QAC9C,MAAM,UAAU,GAAI,MAAM,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC;QAE/C,MAAM,EAAE,CAAC;QACT,MAAM,WAAW,GAAG,IAAI,CAAC,gBAAgB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAC1D,OAAO,IAAI,mBAAmB,CAAC,SAAS,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC;IACvE,CAAC;IAED,QAAQ;QACJ,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAE/B,MAAM,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACxB,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;QACrC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC;QAEtC,MAAM,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACxB,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;IACxF,CAAC;CACJ;AAxCD,kDAwCC"} \ No newline at end of file diff --git a/lib/protocol/KNXUtils.d.ts b/lib/protocol/KNXUtils.d.ts new file mode 100644 index 0000000..1652782 --- /dev/null +++ b/lib/protocol/KNXUtils.d.ts @@ -0,0 +1,2 @@ +export declare const splitIP: (ip: string, name?: string) => RegExpMatchArray; +export declare const validateKNXAddress: (address: string | number, isGroup?: boolean) => number; diff --git a/lib/protocol/KNXUtils.js b/lib/protocol/KNXUtils.js new file mode 100644 index 0000000..46c151c --- /dev/null +++ b/lib/protocol/KNXUtils.js @@ -0,0 +1,52 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.validateKNXAddress = exports.splitIP = void 0; +exports.splitIP = (ip, name = 'ip') => { + if (ip == null) { + throw new Error(`${name} undefined`); + } + const m = ip.match(/(\d+)\.(\d+)\.(\d+)\.(\d+)/); + if (m === null) { + throw new Error(`Invalid ${name} format - ${ip}`); + } + return m; +}; +exports.validateKNXAddress = (address, isGroup = false) => { + if (typeof (address) === 'string') { + const digits = address.split(/[./]/); + if (digits.length < 2 || digits.length > 3) { + throw new Error(`Invalid address format: ${address}`); + } + let count = 0; + let newAddress = 0; + for (let i = digits.length - 1; i >= 0; i--, count++) { + const digit = Number(digits[i]); + if (isNaN(digit) || (count > 1 && digit > 15) || (count === 0 && digit > 255)) { + throw new Error(`Invalid digit at pos ${i} inside address: ${address}`); + } + if (count === 0) { + newAddress = digit; + } + else if (count === 1) { + newAddress = newAddress + (digit << 8); + } + else { + if (isGroup) { + newAddress = newAddress + (digit << 11); + } + else { + newAddress = newAddress + (digit << 12); + } + } + } + return newAddress; + } + else { + const _address = Number(address); + if (isNaN(_address) || _address < 0 || _address > 0xFFFF) { + throw new Error(`Invalid address ${address}`); + } + return _address; + } +}; +//# sourceMappingURL=KNXUtils.js.map \ No newline at end of file diff --git a/lib/protocol/KNXUtils.js.map b/lib/protocol/KNXUtils.js.map new file mode 100644 index 0000000..6341ec8 --- /dev/null +++ b/lib/protocol/KNXUtils.js.map @@ -0,0 +1 @@ +{"version":3,"file":"KNXUtils.js","sourceRoot":"","sources":["../../src/protocol/KNXUtils.ts"],"names":[],"mappings":";;;AAAa,QAAA,OAAO,GAAG,CAAC,EAAU,EAAE,OAAe,IAAI,EAAoB,EAAE;IACzE,IAAI,EAAE,IAAI,IAAI,EAAE;QACZ,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,YAAY,CAAC,CAAC;KACxC;IACD,MAAM,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,4BAA4B,CAAC,CAAC;IACjD,IAAI,CAAC,KAAK,IAAI,EAAE;QACZ,MAAM,IAAI,KAAK,CAAC,WAAW,IAAI,aAAa,EAAE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UAAU,GAAG,UAAU,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;iBAC3C;aACJ;SACJ;QACD,OAAO,UAAU,CAAC;KACrB;SAAM;QACH,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;QACjC,IAAI,KAAK,CAAC,QAAQ,CAAC,IAAI,QAAQ,GAAG,CAAC,IAAI,QAAQ,GAAG,MAAM,EAAE;YACtD,MAAM,IAAI,KAAK,CAAC,mBAAmB,OAAO,EAAE,CAAC,CAAC;SACjD;QACD,OAAO,QAAQ,CAAC;KACnB;AACL,CAAC,CAAC"} \ No newline at end of file diff --git a/lib/protocol/ServiceFamilies.d.ts b/lib/protocol/ServiceFamilies.d.ts new file mode 100644 index 0000000..cea9903 --- /dev/null +++ b/lib/protocol/ServiceFamilies.d.ts @@ -0,0 +1,24 @@ +/// +declare const _default: { + new (): { + readonly type: number; + readonly length: number; + readonly services: Map; + _type: number; + _services: Map; + set(id: number, version: number): void; + service(id: number): number; + toBuffer(): Buffer; + }; + createFromBuffer(buffer: Buffer, offset?: number): { + readonly type: number; + readonly length: number; + readonly services: Map; + _type: number; + _services: Map; + set(id: number, version: number): void; + service(id: number): number; + toBuffer(): Buffer; + }; +}; +export = _default; diff --git a/lib/protocol/ServiceFamilies.js b/lib/protocol/ServiceFamilies.js new file mode 100644 index 0000000..2197894 --- /dev/null +++ b/lib/protocol/ServiceFamilies.js @@ -0,0 +1,63 @@ +'use strict'; +const KNXConstants_1 = require("./KNXConstants"); +module.exports = class ServiceFamilies { + constructor() { + this._type = KNXConstants_1.KNX_CONSTANTS.SUPP_SVC_FAMILIES; + this._services = new Map(); + } + get type() { + return this._type; + } + get length() { + return 2 * this._services.size + 2; + } + get services() { + return this._services; + } + static createFromBuffer(buffer, offset = 0) { + if (offset >= buffer.length) { + throw new Error(`offset ${offset} out of buffer range ${buffer.length}`); + } + const structureLength = buffer.readUInt8(offset); + if (offset + structureLength > buffer.length) { + throw new Error(`offset ${offset} block length: ${structureLength} out of buffer range ${buffer.length}`); + } + offset++; + const type = buffer.readUInt8(offset++); + if (type !== KNXConstants_1.KNX_CONSTANTS.SUPP_SVC_FAMILIES) { + throw new Error(`Invalid Service Family type ${type}`); + } + const serviceFamily = new ServiceFamilies(); + for (let i = 2; i < structureLength; i += 2) { + serviceFamily.set(buffer.readUInt8(offset), buffer.readUInt8(offset + 1)); + offset += 2; + } + return serviceFamily; + } + set(id, version) { + const _id = Number(id); + if (isNaN(_id) || id > 0xFF || id < 0) { + throw new Error('Invalid service id'); + } + const _version = Number(version); + if (isNaN(_version) || version > 0xFF || version < 0) { + throw new Error('Invalid service version'); + } + this._services.set(id, version); + } + service(id) { + return this._services.get(id); + } + toBuffer() { + const buffer = Buffer.alloc(this.length); + let offset = 0; + buffer.writeUInt8(this.length, offset++); + buffer.writeUInt8(KNXConstants_1.KNX_CONSTANTS.SUPP_SVC_FAMILIES, offset++); + for (const [id, version] of this._services) { + buffer.writeUInt8(id, offset++); + buffer.writeUInt8(version, offset++); + } + return buffer; + } +}; +//# sourceMappingURL=ServiceFamilies.js.map \ No newline at end of file diff --git a/lib/protocol/ServiceFamilies.js.map b/lib/protocol/ServiceFamilies.js.map new file mode 100644 index 0000000..60160da --- /dev/null +++ b/lib/protocol/ServiceFamilies.js.map @@ -0,0 +1 @@ +{"version":3,"file":"ServiceFamilies.js","sourceRoot":"","sources":["../../src/protocol/ServiceFamilies.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,iDAA6C;AAE7C,iBAAS,MAAM,eAAe;IAe1B;QACI,IAAI,CAAC,KAAK,GAAG,4BAAa,CAAC,iBAAiB,CAAC;QAC7C,IAAI,CAAC,SAAS,GAAG,IAAI,GAAG,EAAE,CAAC;IAC/B,CAAC;IAhBD,IAAI,IAAI;QACJ,OAAO,IAAI,CAAC,KAAK,CAAC;IACtB,CAAC;IAED,IAAI,MAAM;QACN,OAAO,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,GAAG,C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IAAI,EAAE,GAAG,CAAC,EAAE;YACnC,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;SACzC;QACD,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;QACjC,IAAI,KAAK,CAAC,QAAQ,CAAC,IAAI,OAAO,GAAG,IAAI,IAAI,OAAO,GAAG,CAAC,EAAE;YAClD,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;SAC9C;QACD,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;IACpC,CAAC;IAED,OAAO,CAAC,EAAU;QACd,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAClC,CAAC;IAED,QAAQ;QACJ,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACzC,IAAI,MAAM,GAAG,CAAC,CAAC;QACf,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;QACzC,MAAM,CAAC,UAAU,CAAC,4BAAa,CAAC,iBAAiB,EAAE,MAAM,EAAE,CAAC,CAAC;QAC7D,KAAK,MAAM,CAAC,EAAE,EAAE,OAAO,CAAC,IAAI,IAAI,CAAC,SAAS,EAAE;YACxC,MAAM,CAAC,UAAU,CAAC,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;YAChC,MAAM,CAAC,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;SACxC;QACD,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ,CAAC"} \ No newline at end of file diff --git a/lib/protocol/TunnelCRI.d.ts b/lib/protocol/TunnelCRI.d.ts new file mode 100644 index 0000000..1629489 --- /dev/null +++ b/lib/protocol/TunnelCRI.d.ts @@ -0,0 +1,14 @@ +/// +import { CRI } from './CRI'; +export declare enum TunnelTypes { + TUNNEL_LINKLAYER, + TUNNEL_RAW, + TUNNEL_BUSMONITOR +} +export declare class TunnelCRI extends CRI { + knxLayer: TunnelTypes; + get length(): number; + constructor(knxLayer: TunnelTypes); + static createFromBuffer(buffer: Buffer, offset?: number): TunnelCRI; + toBuffer(): Buffer; +} diff --git a/lib/protocol/TunnelCRI.js b/lib/protocol/TunnelCRI.js new file mode 100644 index 0000000..df8995c --- /dev/null +++ b/lib/protocol/TunnelCRI.js @@ -0,0 +1,37 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.TunnelCRI = exports.TunnelTypes = void 0; +const KNXConstants_1 = require("./KNXConstants"); +const CRI_1 = require("./CRI"); +const TUNNEL_CRI_LENGTH = 4; +var TunnelTypes; +(function (TunnelTypes) { + TunnelTypes[TunnelTypes["TUNNEL_LINKLAYER"] = KNXConstants_1.KNX_CONSTANTS.TUNNEL_LINKLAYER] = "TUNNEL_LINKLAYER"; + TunnelTypes[TunnelTypes["TUNNEL_RAW"] = KNXConstants_1.KNX_CONSTANTS.TUNNEL_RAW] = "TUNNEL_RAW"; + TunnelTypes[TunnelTypes["TUNNEL_BUSMONITOR"] = KNXConstants_1.KNX_CONSTANTS.TUNNEL_BUSMONITOR] = "TUNNEL_BUSMONITOR"; +})(TunnelTypes = exports.TunnelTypes || (exports.TunnelTypes = {})); +class TunnelCRI extends CRI_1.CRI { + constructor(knxLayer) { + super(KNXConstants_1.KNX_CONSTANTS.TUNNEL_CONNECTION); + this.knxLayer = knxLayer; + } + get length() { + return TUNNEL_CRI_LENGTH; + } + static createFromBuffer(buffer, offset = 0) { + const knxLayer = buffer.readUInt8(offset++); + buffer.readUInt8(offset); + return new TunnelCRI(knxLayer); + } + toBuffer() { + const buffer = Buffer.alloc(this.length); + let offset = 0; + buffer.writeUInt8(this.length, offset++); + buffer.writeUInt8(KNXConstants_1.KNX_CONSTANTS.TUNNEL_CONNECTION, offset++); + buffer.writeUInt8(this.knxLayer, offset++); + buffer.writeUInt8(0x00, offset); + return buffer; + } +} +exports.TunnelCRI = TunnelCRI; +//# sourceMappingURL=TunnelCRI.js.map \ No newline at end of file diff --git a/lib/protocol/TunnelCRI.js.map b/lib/protocol/TunnelCRI.js.map new file mode 100644 index 0000000..7cbe9ed --- /dev/null +++ b/lib/protocol/TunnelCRI.js.map @@ -0,0 +1 @@ +{"version":3,"file":"TunnelCRI.js","sourceRoot":"","sources":["../../src/protocol/TunnelCRI.ts"],"names":[],"mappings":";;;AACA,iDAA+C;AAC/C,+BAA4B;AAE5B,MAAM,iBAAiB,GAAG,CAAC,CAAC;AAE5B,IAAY,WAIX;AAJD,WAAY,WAAW;IACnB,8CAAmB,4BAAa,CAAC,gBAAgB,sBAAA,CAAA;IACjD,wCAAa,4BAAa,CAAC,UAAU,gBAAA,CAAA;IACrC,+CAAoB,4BAAa,CAAC,iBAAiB,uBAAA,CAAA;AACvD,CAAC,EAJW,WAAW,GAAX,mBAAW,KAAX,mBAAW,QAItB;AAED,MAAa,SAAU,SAAQ,SAAG;IAS9B,YAAmB,QAAqB;QACpC,KAAK,CAAC,4BAAa,CAAC,iBAAiB,CAAC,CAAC;QADxB,aAAQ,GAAR,QAAQ,CAAa;IAExC,CAAC;IALD,IAAI,MAAM;QACN,OAAO,iBAAiB,CAAC;IAC7B,CAAC;IAWD,MAAM,CAAC,gBAAgB,CAAC,MAAc,EAAE,SAAiB,CAAC;QACtD,MAAM,QAAQ,GAAG,MAAM,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC;QAC5C,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QAEzB,OAAO,IAAI,SAAS,CAAC,QAAQ,CAAC,CAAC;IACnC,CAAC;IAKD,QAAQ;QACJ,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACzC,IAAI,MAAM,GAAG,CAAC,CAAC;QACf,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;QACzC,MAAM,CAAC,UAAU,CAAC,4BAAa,CAAC,iBAAiB,EAAE,MAAM,EAAE,CAAC,CAAC;QAC7D,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;QAC3C,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAChC,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ;AAtCD,8BAsCC"} \ No newline at end of file diff --git a/lib/protocol/cEMI/AdditionalInfo.d.ts b/lib/protocol/cEMI/AdditionalInfo.d.ts new file mode 100644 index 0000000..7b1d71b --- /dev/null +++ b/lib/protocol/cEMI/AdditionalInfo.d.ts @@ -0,0 +1,10 @@ +/// +import { TLVInfo } from './TLVInfo'; +export declare class AdditionalInfo { + private _tlvs; + private _length; + constructor(_tlvs?: TLVInfo[]); + static createFromBuffer(buffer: Buffer, offset?: number): AdditionalInfo; + addTLV(tlv: TLVInfo): void; + toBuffer(): Buffer; +} diff --git a/lib/protocol/cEMI/AdditionalInfo.js b/lib/protocol/cEMI/AdditionalInfo.js new file mode 100644 index 0000000..b4693f8 --- /dev/null +++ b/lib/protocol/cEMI/AdditionalInfo.js @@ -0,0 +1,34 @@ +'use strict'; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.AdditionalInfo = void 0; +const TLVInfo_1 = require("./TLVInfo"); +class AdditionalInfo { + constructor(_tlvs = []) { + this._tlvs = _tlvs; + this._length = 0; + for (const tlv of _tlvs) { + this._length += tlv.length; + } + } + static createFromBuffer(buffer, offset = 0) { + const tlvs = []; + const _getOneTLV = () => { + if (offset >= buffer.length) { + return tlvs; + } + const tlv = TLVInfo_1.TLVInfo.createFromBuffer(buffer, offset); + tlvs.push(tlv); + offset += tlv.length; + return _getOneTLV(); + }; + return new AdditionalInfo(_getOneTLV()); + } + addTLV(tlv) { + this._tlvs.push(tlv); + } + toBuffer() { + return Buffer.concat(this._tlvs.map(tlv => tlv.toBuffer())); + } +} +exports.AdditionalInfo = AdditionalInfo; +//# sourceMappingURL=AdditionalInfo.js.map \ No newline at end of file diff --git a/lib/protocol/cEMI/AdditionalInfo.js.map b/lib/protocol/cEMI/AdditionalInfo.js.map new file mode 100644 index 0000000..3109dc0 --- /dev/null +++ b/lib/protocol/cEMI/AdditionalInfo.js.map @@ -0,0 +1 @@ +{"version":3,"file":"AdditionalInfo.js","sourceRoot":"","sources":["../../../src/protocol/cEMI/AdditionalInfo.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AACb,uCAAkC;AAElC,MAAa,cAAc;IAEvB,YAAoB,QAAmB,EAAE;QAArB,UAAK,GAAL,KAAK,CAAgB;QACrC,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC;QACjB,KAAK,MAAM,GAAG,IAAI,KAAK,EAAE;YACrB,IAAI,CAAC,OAAO,IAAI,GAAG,CAAC,MAAM,CAAC;SAC9B;IACL,CAAC;IAED,MAAM,CAAC,gBAAgB,CAAC,MAAc,EAAE,SAAiB,CAAC;QAEtD,MAAM,IAAI,GAAc,EAAE,CAAC;QAC3B,MAAM,UAAU,GAAoB,GAAG,EAAE;YACrC,IAAI,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE;gBACzB,OAAO,IAAI,CAAC;aACf;YACD,MAAM,GAAG,GAAG,iBAAO,CAAC,gBAAgB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;YACrD,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YACf,MAAM,IAAI,GAAG,CAAC,MAAM,CAAC;YACrB,OAAO,UAAU,EAAE,CAAC;QACxB,CAAC,CAAC;QACF,OAAO,IAAI,cAAc,CAAC,UAAU,EAAE,CAAC,CAAC;IAC5C,CAAC;IAED,MAAM,CAAC,GAAY;QACf,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACzB,CAAC;IAED,QAAQ;QACJ,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;IAChE,CAAC;CAEJ;AAhCD,wCAgCC"} \ No newline at end of file diff --git a/lib/protocol/cEMI/CEMIConstants.d.ts b/lib/protocol/cEMI/CEMIConstants.d.ts new file mode 100644 index 0000000..7e2a1bd --- /dev/null +++ b/lib/protocol/cEMI/CEMIConstants.d.ts @@ -0,0 +1,24 @@ +export declare const CEMIConstants: { + PL_MEDIUM_INFO: number; + RF_MEDIUM_INFO: number; + BUSMONITOR_STATUS_INFO: number; + TIMESTAMP_RELATIVE: number; + TIME_DELAY_TILL_SENDING: number; + EXTENDED_RELATIVE_TIMESTAMP: number; + BIBAT_INFO: number; + RF_MULTI_INFO: number; + PREAMBLE: number; + POSTAMBLE: number; + RF_FASK_ACK_INFO: number; + MANUFACTURER_SPECIFIC_INFO: number; + L_DATA_REQ: number; + L_DATA_CON: number; + L_DATA_IND: number; + GROUP_READ: number; + GROUP_RESPONSE: number; + GROUP_WRITE: number; + INDIVIDUAL_WRITE: number; + INDIVIDUAL_READ: number; + INDIVIDUAL_RESPONSE: number; + TPCI_UNUMBERED_PACKET: number; +}; diff --git a/lib/protocol/cEMI/CEMIConstants.js b/lib/protocol/cEMI/CEMIConstants.js new file mode 100644 index 0000000..182404d --- /dev/null +++ b/lib/protocol/cEMI/CEMIConstants.js @@ -0,0 +1,28 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.CEMIConstants = void 0; +exports.CEMIConstants = { + PL_MEDIUM_INFO: 0x01, + RF_MEDIUM_INFO: 0x02, + BUSMONITOR_STATUS_INFO: 0x03, + TIMESTAMP_RELATIVE: 0x04, + TIME_DELAY_TILL_SENDING: 0x05, + EXTENDED_RELATIVE_TIMESTAMP: 0x06, + BIBAT_INFO: 0x07, + RF_MULTI_INFO: 0x08, + PREAMBLE: 0x09, + POSTAMBLE: 0x09, + RF_FASK_ACK_INFO: 0x0A, + MANUFACTURER_SPECIFIC_INFO: 0xFE, + L_DATA_REQ: 0x11, + L_DATA_CON: 0x2E, + L_DATA_IND: 0x29, + GROUP_READ: 0x0, + GROUP_RESPONSE: 0x01, + GROUP_WRITE: 0x02, + INDIVIDUAL_WRITE: 0x03, + INDIVIDUAL_READ: 0x04, + INDIVIDUAL_RESPONSE: 0x04, + TPCI_UNUMBERED_PACKET: 0x0 +}; +//# sourceMappingURL=CEMIConstants.js.map \ No newline at end of file diff --git a/lib/protocol/cEMI/CEMIConstants.js.map b/lib/protocol/cEMI/CEMIConstants.js.map new file mode 100644 index 0000000..cbec9ef --- /dev/null +++ b/lib/protocol/cEMI/CEMIConstants.js.map @@ -0,0 +1 @@ +{"version":3,"file":"CEMIConstants.js","sourceRoot":"","sources":["../../../src/protocol/cEMI/CEMIConstants.ts"],"names":[],"mappings":";;;AAAa,QAAA,aAAa,GAAG;IAEzB,cAAc,EAAE,IAAI;IACpB,cAAc,EAAE,IAAI;IACpB,sBAAsB,EAAE,IAAI;IAC5B,kBAAkB,EAAE,IAAI;IACxB,uBAAuB,EAAE,IAAI;IAC7B,2BAA2B,EAAE,IAAI;IACjC,UAAU,EAAE,IAAI;IAChB,aAAa,EAAE,IAAI;IACnB,QAAQ,EAAE,IAAI;IACd,SAAS,EAAE,IAAI;IACf,gBAAgB,EAAE,IAAI;IACtB,0BAA0B,EAAE,IAAI;IAEhC,UAAU,EAAE,IAAI;IAChB,UAAU,EAAE,IAAI;IAChB,UAAU,EAAE,IAAI;IAChB,UAAU,EAAE,GAAG;IACf,cAAc,EAAE,IAAI;IACpB,WAAW,EAAE,IAAI;IACjB,gBAAgB,EAAE,IAAI;IACtB,eAAe,EAAE,IAAI;IACrB,mBAAmB,EAAE,IAAI;IACzB,qBAAqB,EAAE,GAAG;CAC7B,CAAC"} \ No newline at end of file diff --git a/lib/protocol/cEMI/CEMIFactory.d.ts b/lib/protocol/cEMI/CEMIFactory.d.ts new file mode 100644 index 0000000..7877964 --- /dev/null +++ b/lib/protocol/cEMI/CEMIFactory.d.ts @@ -0,0 +1,12 @@ +/// +import { KNXAddress } from '../KNXAddress'; +import { CEMIMessage } from './CEMIMessage'; +import { LDataInd } from './LDataInd'; +import { LDataReq } from './LDataReq'; +import { KNXDataBuffer } from '../KNXDataBuffer'; +export declare class CEMIFactory { + static createFromBuffer(type: number, buffer: Buffer, offset: number): CEMIMessage; + static newLDataIndicationMessage(isGroupAddress: boolean, srcAddress: KNXAddress, dstAddress: KNXAddress, data: KNXDataBuffer): LDataInd; + static newLDataRequestMessage(isWrite: boolean, isGroupAddress: boolean, srcAddress: KNXAddress, dstAddress: KNXAddress, data: KNXDataBuffer): LDataReq; + static newLDataConfirmationMessage(isGroupAddress: boolean, srcAddress: KNXAddress, dstAddress: KNXAddress, data: KNXDataBuffer): LDataReq; +} diff --git a/lib/protocol/cEMI/CEMIFactory.js b/lib/protocol/cEMI/CEMIFactory.js new file mode 100644 index 0000000..7cd56ac --- /dev/null +++ b/lib/protocol/cEMI/CEMIFactory.js @@ -0,0 +1,55 @@ +'use strict'; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.CEMIFactory = void 0; +const CEMIConstants_1 = require("./CEMIConstants"); +const LDataInd_1 = require("./LDataInd"); +const LDataCon_1 = require("./LDataCon"); +const LDataReq_1 = require("./LDataReq"); +const ControlField_1 = require("./ControlField"); +const NPDU_1 = require("./NPDU"); +class CEMIFactory { + static createFromBuffer(type, buffer, offset) { + switch (type) { + case CEMIConstants_1.CEMIConstants.L_DATA_IND: + return LDataInd_1.LDataInd.createFromBuffer(buffer, offset); + case CEMIConstants_1.CEMIConstants.L_DATA_CON: + return LDataCon_1.LDataCon.createFromBuffer(buffer, offset); + case CEMIConstants_1.CEMIConstants.L_DATA_REQ: + return LDataReq_1.LDataReq.createFromBuffer(buffer, offset); + default: + throw new Error(`Unsupported type cEMI message type ${type}`); + } + } + static newLDataIndicationMessage(isGroupAddress, srcAddress, dstAddress, data) { + const controlField = new ControlField_1.ControlField(); + controlField.addressType = isGroupAddress === true ? 1 : 0; + controlField.ack = 0; + const npdu = new NPDU_1.NPDU(); + npdu.tpci = NPDU_1.NPDU.TPCI_UNUMBERED_PACKET; + npdu.action = NPDU_1.NPDU.GROUP_WRITE; + npdu.data = data; + return new LDataInd_1.LDataInd(null, controlField, srcAddress, dstAddress, npdu); + } + static newLDataRequestMessage(isWrite, isGroupAddress, srcAddress, dstAddress, data) { + const controlField = new ControlField_1.ControlField(); + controlField.addressType = isGroupAddress ? 1 : 0; + controlField.ack = isWrite ? 1 : 0; + const npdu = new NPDU_1.NPDU(); + npdu.tpci = NPDU_1.NPDU.TPCI_UNUMBERED_PACKET; + npdu.action = isWrite ? NPDU_1.NPDU.GROUP_WRITE : NPDU_1.NPDU.GROUP_READ; + npdu.data = data; + return new LDataReq_1.LDataReq(null, controlField, srcAddress, dstAddress, npdu); + } + static newLDataConfirmationMessage(isGroupAddress, srcAddress, dstAddress, data) { + const controlField = new ControlField_1.ControlField(); + controlField.addressType = isGroupAddress === true ? 1 : 0; + controlField.ack = 0; + const npdu = new NPDU_1.NPDU(); + npdu.tpci = NPDU_1.NPDU.TPCI_UNUMBERED_PACKET; + npdu.action = NPDU_1.NPDU.GROUP_WRITE; + npdu.data = data; + return new LDataReq_1.LDataReq(null, controlField, srcAddress, dstAddress, npdu); + } +} +exports.CEMIFactory = CEMIFactory; +//# sourceMappingURL=CEMIFactory.js.map \ No newline at end of file diff --git a/lib/protocol/cEMI/CEMIFactory.js.map b/lib/protocol/cEMI/CEMIFactory.js.map new file mode 100644 index 0000000..89ce683 --- /dev/null +++ b/lib/protocol/cEMI/CEMIFactory.js.map @@ -0,0 +1 @@ +{"version":3,"file":"CEMIFactory.js","sourceRoot":"","sources":["../../../src/protocol/cEMI/CEMIFactory.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAIb,mDAA+C;AAE/C,yCAAoC;AACpC,yCAAoC;AACpC,yCAAoC;AACpC,iDAA8C;AAC9C,iCAA4B;AAG5B,MAAa,WAAW;IAQpB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 0000000..7d0ddbf --- /dev/null +++ b/lib/protocol/cEMI/CEMIMessage.d.ts @@ -0,0 +1,17 @@ +/// +import { KNXDataBuffer } from '../KNXDataBuffer'; +import { ControlField } from './ControlField'; +import { KNXAddress } from '../KNXAddress'; +import { NPDU } from './NPDU'; +export declare class CEMIMessage { + readonly msgCode: number; + readonly length: number; + readonly additionalInfo: KNXDataBuffer; + readonly control: ControlField; + readonly srcAddress: KNXAddress; + readonly dstAddress: KNXAddress; + readonly npdu: NPDU; + constructor(msgCode: number, length: number, additionalInfo: KNXDataBuffer, control: ControlField, srcAddress: KNXAddress, dstAddress: KNXAddress, npdu: NPDU); + toBuffer(): Buffer; + protected static GetLength(additionalInfo: KNXDataBuffer, control: ControlField, srcAddress: KNXAddress, dstAddress: KNXAddress, npdu: NPDU): number; +} diff --git a/lib/protocol/cEMI/CEMIMessage.js b/lib/protocol/cEMI/CEMIMessage.js new file mode 100644 index 0000000..498c54c --- /dev/null +++ b/lib/protocol/cEMI/CEMIMessage.js @@ -0,0 +1,31 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.CEMIMessage = void 0; +class CEMIMessage { + constructor(msgCode, length, additionalInfo = null, control, srcAddress, dstAddress, npdu) { + this.msgCode = msgCode; + this.length = length; + this.additionalInfo = additionalInfo; + this.control = control; + this.srcAddress = srcAddress; + this.dstAddress = dstAddress; + this.npdu = npdu; + } + toBuffer() { + const buffer = Buffer.alloc(2); + buffer.writeUInt8(this.msgCode, 0); + const len = this.additionalInfo == null ? 0 : this.additionalInfo.length; + buffer.writeUInt8(len, 1); + if (this.additionalInfo) { + return Buffer.concat([buffer, this.additionalInfo.value]); + } + return buffer; + } + static GetLength(additionalInfo, control, srcAddress, dstAddress, npdu) { + const length = additionalInfo == null ? 1 : additionalInfo.length; + const npduLength = npdu == null ? 0 : npdu.length; + return 1 + length + control.length + srcAddress.length + dstAddress.length + npduLength; + } +} +exports.CEMIMessage = CEMIMessage; +//# sourceMappingURL=CEMIMessage.js.map \ No newline at end of file diff --git a/lib/protocol/cEMI/CEMIMessage.js.map b/lib/protocol/cEMI/CEMIMessage.js.map new file mode 100644 index 0000000..6709f5a --- /dev/null +++ b/lib/protocol/cEMI/CEMIMessage.js.map @@ -0,0 +1 @@ +{"version":3,"file":"CEMIMessage.js","sourceRoot":"","sources":["../../../src/protocol/cEMI/CEMIMessage.ts"],"names":[],"mappings":";;;AAMA,MAAa,WAAW;IAEpB,YACa,OAAe,EACf,MAAc,EACd,iBAAgC,IAAI,EACpC,OAAqB,EACrB,UAAsB,EACtB,UAAsB,EACtB,IAAU;QANV,YAAO,GAAP,OAAO,CAAQ;QACf,WAAM,GAAN,MAAM,CAAQ;QACd,mBAAc,GAAd,cAAc,CAAsB;QACpC,YAAO,GAAP,OAAO,CAAc;QACrB,eAAU,GAAV,UAAU,CAAY;QACtB,eAAU,GAAV,UAAU,CAAY;QACtB,SAAI,GAAJ,IAAI,CAAM;IACvB,CAAC;IAED,QAAQ;QACJ,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAC/B,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;QACnC,MAAM,GAAG,GAAG,IAAI,CAAC,cAAc,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC;QACzE,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;QAC1B,IAAI,IAAI,CAAC,cAAc,EAAE;YACrB,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC;SAC7D;QACD,OAAO,MAAM,CAAC;IAClB,CAAC;IAES,MAAM,CAAC,SAAS,CAAC,cAA6B,EACpD,OAAqB,EACrB,UAAsB,EACtB,UAAsB,EACtB,IAAU;QAEN,MAAM,MAAM,GAAG,cAAc,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,MAAM,CAAC;QAClE,MAAM,UAAU,GAAG,IAAI,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC;QAClD,OAAO,CAAC,GAAG,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,UAAU,CAAC,MAAM,GAAG,UAAU,CAAC,MAAM,GAAG,UAAU,CAAC;IAChG,CAAC;CACJ;AAjCD,kCAiCC"} \ No newline at end of file diff --git a/lib/protocol/cEMI/ControlField.d.ts b/lib/protocol/cEMI/ControlField.d.ts new file mode 100644 index 0000000..0eb9a6a --- /dev/null +++ b/lib/protocol/cEMI/ControlField.d.ts @@ -0,0 +1,44 @@ +/// +import { KNXAddressType } from '../KNXAddress'; +export declare enum FrameType { + type0 = 0, + type1 = 1 +} +export declare enum OnOff { + off = 0, + on = 1 +} +export declare enum Priority { + Prio0 = 0, + Prio1 = 1, + Prio2 = 2, + Prio3 = 3 +} +export declare class ControlField { + private control1; + private control2; + set frameType(frameType: FrameType); + get frameType(): FrameType; + set repeat(repeat: OnOff); + get repeat(): OnOff; + set broadcast(broadcast: OnOff); + get broadcast(): OnOff; + set priority(priority: Priority); + get priority(): Priority; + set ack(ack: OnOff); + get ack(): OnOff; + set error(error: OnOff); + get error(): OnOff; + set addressType(type: KNXAddressType); + get addressType(): KNXAddressType; + set hopCount(hopCount: number); + get hopCount(): number; + set frameFormat(format: number); + get framrFormat(): number; + static get DEFAULT_CONTROL1(): number; + static get DEFAULT_CONTROL2(): number; + readonly length: number; + constructor(control1?: number, control2?: number); + static createFromBuffer(buffer: Buffer, offset?: number): ControlField; + toBuffer(): Buffer; +} diff --git a/lib/protocol/cEMI/ControlField.js b/lib/protocol/cEMI/ControlField.js new file mode 100644 index 0000000..c7cc6d2 --- /dev/null +++ b/lib/protocol/cEMI/ControlField.js @@ -0,0 +1,112 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.ControlField = exports.Priority = exports.OnOff = exports.FrameType = void 0; +const CONTROL_LENGTH = 2; +var FrameType; +(function (FrameType) { + FrameType[FrameType["type0"] = 0] = "type0"; + FrameType[FrameType["type1"] = 1] = "type1"; +})(FrameType = exports.FrameType || (exports.FrameType = {})); +var OnOff; +(function (OnOff) { + OnOff[OnOff["off"] = 0] = "off"; + OnOff[OnOff["on"] = 1] = "on"; +})(OnOff = exports.OnOff || (exports.OnOff = {})); +var Priority; +(function (Priority) { + Priority[Priority["Prio0"] = 0] = "Prio0"; + Priority[Priority["Prio1"] = 1] = "Prio1"; + Priority[Priority["Prio2"] = 2] = "Prio2"; + Priority[Priority["Prio3"] = 3] = "Prio3"; +})(Priority = exports.Priority || (exports.Priority = {})); +class ControlField { + constructor(control1 = ControlField.DEFAULT_CONTROL1, control2 = ControlField.DEFAULT_CONTROL2) { + this.control1 = control1; + this.control2 = control2; + this.control1 = control1; + this.control2 = control2; + this.length = CONTROL_LENGTH; + } + set frameType(frameType) { + this.control1 = (this.control1 & 0x7F) | (Number(frameType) << 7); + } + get frameType() { + return (this.control1 & 0x80) >> 7; + } + set repeat(repeat) { + this.control1 = (this.control1 & 0xDF) | (Number(repeat) << 5); + } + get repeat() { + return (this.control1 & 0x20) >> 5; + } + set broadcast(broadcast) { + this.control1 = (this.control1 & 0xEF) | (Number(broadcast) << 4); + } + get broadcast() { + return (this.control1 & 0x10) >> 4; + } + set priority(priority) { + this.control1 = (this.control1 & 0xF3) | (Number(priority) << 2); + } + get priority() { + return (this.control1 & 0x0C) >> 2; + } + set ack(ack) { + this.control1 = (this.control1 & 0xFD) | (Number(ack) << 1); + } + get ack() { + return (this.control1 & 0x02) >> 1; + } + set error(error) { + this.control1 = (this.control1 & 0xFE) | Number(error); + } + get error() { + return this.control1 & 0x01; + } + set addressType(type) { + this.control2 = (this.control2 & 0x7F) | (Number(type) << 7); + } + get addressType() { + return (this.control2 & 0x80) >> 7; + } + set hopCount(hopCount) { + if (isNaN(hopCount) || (hopCount < 0 && hopCount > 7)) { + throw new Error('Invalid hop count'); + } + this.control2 = (this.control2 & 0x8F) | (Number(hopCount) << 4); + } + get hopCount() { + return (this.control2 & 0x70) >> 4; + } + set frameFormat(format) { + if (isNaN(format) || (format < 0 && format > 15)) { + throw new Error('Invalid frame format'); + } + this.control2 = (this.control2 & 0xF0) | Number(format); + } + get framrFormat() { + return this.control2 & 0xF; + } + static get DEFAULT_CONTROL1() { + return 0xBE; + } + static get DEFAULT_CONTROL2() { + return 0xE0; + } + static createFromBuffer(buffer, offset = 0) { + if (offset + CONTROL_LENGTH >= buffer.length) { + throw new Error(`offset ${offset} out of buffer range ${buffer.length}`); + } + const control1 = buffer.readUInt8(offset++); + const control2 = buffer.readUInt8(offset); + return new ControlField(control1, control2); + } + toBuffer() { + const buffer = Buffer.alloc(this.length); + buffer.writeUInt8(this.control1, 0); + buffer.writeUInt8(this.control2, 1); + return buffer; + } +} +exports.ControlField = ControlField; +//# sourceMappingURL=ControlField.js.map \ No newline at end of file diff --git a/lib/protocol/cEMI/ControlField.js.map b/lib/protocol/cEMI/ControlField.js.map new file mode 100644 index 0000000..978adb3 --- /dev/null +++ b/lib/protocol/cEMI/ControlField.js.map @@ -0,0 +1 @@ +{"version":3,"file":"ControlField.js","sourceRoot":"","sources":["../../../src/protocol/cEMI/ControlField.ts"],"names":[],"mappings":";;;AAEA,MAAM,cAAc,GAAG,CAAC,CAAC;AAEzB,IAAY,SAGX;AAHD,WAAY,SAAS;IACjB,2CAAS,CAAA;IACT,2CAAK,CAAA;AACT,CAAC,EAHW,SAAS,GAAT,iBAAS,KAAT,iBAAS,QAGpB;AAED,IAAY,KAGX;AAHD,WAAY,KAAK;IACb,+BAAO,CAAA;IACP,6BAAE,CAAA;AACN,CAAC,EAHW,KAAK,GAAL,aAAK,KAAL,aAAK,QAGhB;AAED,IAAY,QAKX;AALD,WAAY,QAAQ;IAChB,yCAAS,CAAA;IACT,yCAAK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CAAC;IAED,QAAQ;QACJ,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACzC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;QACpC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;QACpC,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ;AA5HD,oCA4HC"} \ No newline at end of file diff --git a/lib/protocol/cEMI/LDataCon.d.ts b/lib/protocol/cEMI/LDataCon.d.ts new file mode 100644 index 0000000..ff40d9d --- /dev/null +++ b/lib/protocol/cEMI/LDataCon.d.ts @@ -0,0 +1,11 @@ +/// +import { CEMIMessage } from './CEMIMessage'; +import { KNXAddress } from '../KNXAddress'; +import { ControlField } from './ControlField'; +import { NPDU } from './NPDU'; +import { KNXDataBuffer } from '../KNXDataBuffer'; +export declare class LDataCon extends CEMIMessage { + constructor(additionalInfo: KNXDataBuffer, control: ControlField, srcAddress: KNXAddress, dstAddress: KNXAddress, npdu: NPDU); + static createFromBuffer(buffer: Buffer, offset?: number): LDataCon; + toBuffer(): Buffer; +} diff --git a/lib/protocol/cEMI/LDataCon.js b/lib/protocol/cEMI/LDataCon.js new file mode 100644 index 0000000..e6f9177 --- /dev/null +++ b/lib/protocol/cEMI/LDataCon.js @@ -0,0 +1,53 @@ +'use strict'; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.LDataCon = void 0; +const CEMIMessage_1 = require("./CEMIMessage"); +const CEMIConstants_1 = require("./CEMIConstants"); +const KNXAddress_1 = require("../KNXAddress"); +const ControlField_1 = require("./ControlField"); +const NPDU_1 = require("./NPDU"); +const KNXDataBuffer_1 = require("../KNXDataBuffer"); +class LDataCon extends CEMIMessage_1.CEMIMessage { + constructor(additionalInfo, control, srcAddress, dstAddress, npdu) { + super(CEMIConstants_1.CEMIConstants.L_DATA_CON, CEMIMessage_1.CEMIMessage.GetLength(additionalInfo, control, srcAddress, dstAddress, npdu), additionalInfo, control, srcAddress, dstAddress, npdu); + } + static createFromBuffer(buffer, offset = 0) { + if (offset >= buffer.length) { + throw new Error('Buffer too short'); + } + const addLength = buffer.readUInt8(offset++); + let additionalInfo = null; + if (addLength > 0) { + additionalInfo = new KNXDataBuffer_1.KNXDataBuffer(buffer.slice(offset, addLength)); + offset += addLength; + } + const controlField = ControlField_1.ControlField.createFromBuffer(buffer, offset); + offset += controlField.length; + const srcAddress = KNXAddress_1.KNXAddress.createFromBuffer(buffer, offset); + offset += srcAddress.length; + const dstAddress = KNXAddress_1.KNXAddress.createFromBuffer(buffer, offset, controlField.addressType); + offset += dstAddress.length; + const npdu = NPDU_1.NPDU.createFromBuffer(buffer, offset); + return new LDataCon(additionalInfo, controlField, srcAddress, dstAddress, npdu); + } + toBuffer() { + const buffer = Buffer.alloc(1); + const msgBuffer = [buffer]; + let offset = 0; + buffer.writeUInt8(this.msgCode, offset++); + if (this.additionalInfo == null) { + buffer.writeUInt8(0, offset); + } + else { + buffer.writeUInt8(this.additionalInfo.length, offset); + msgBuffer.push(this.additionalInfo.value); + } + msgBuffer.push(this.control.toBuffer()); + msgBuffer.push(this.srcAddress.toBuffer()); + msgBuffer.push(this.dstAddress.toBuffer()); + msgBuffer.push(this.npdu.toBuffer()); + return Buffer.concat(msgBuffer); + } +} +exports.LDataCon = LDataCon; +//# sourceMappingURL=LDataCon.js.map \ No newline at end of file diff --git a/lib/protocol/cEMI/LDataCon.js.map b/lib/protocol/cEMI/LDataCon.js.map new file mode 100644 index 0000000..903be6b --- /dev/null +++ b/lib/protocol/cEMI/LDataCon.js.map @@ -0,0 +1 @@ +{"version":3,"file":"LDataCon.js","sourceRoot":"","sources":["../../../src/protocol/cEMI/LDataCon.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AACb,+CAA0C;AAC1C,mDAAgD;AAChD,8CAA2C;AAC3C,iDAA6C;AAC7C,iCAA4B;AAC5B,oDAA+C;AAE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OAAO,IAAI,QAAQ,CAAC,cAAc,EAAE,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,IAAI,CAAC,CAAC;IACpF,CAAC;IAMD,QAAQ;QACJ,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAC/B,MAAM,SAAS,GAAG,CAAC,MAAM,CAAC,CAAC;QAC3B,IAAI,MAAM,GAAG,CAAC,CAAC;QACf,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;QAC1C,IAAI,IAAI,CAAC,cAAc,IAAI,IAAI,EAAE;YAC7B,MAAM,CAAC,UAAU,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;SAChC;aAAM;YACH,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;YACtD,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;SAC7C;QACD,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;QACxC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC,CAAC;QAC3C,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC,CAAC;QAC3C,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;QACrC,OAAO,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IACpC,CAAC;CACJ;AAhED,4BAgEC"} \ No newline at end of file diff --git a/lib/protocol/cEMI/LDataInd.d.ts b/lib/protocol/cEMI/LDataInd.d.ts new file mode 100644 index 0000000..80662fb --- /dev/null +++ b/lib/protocol/cEMI/LDataInd.d.ts @@ -0,0 +1,11 @@ +/// +import { CEMIMessage } from './CEMIMessage'; +import { KNXAddress } from '../KNXAddress'; +import { ControlField } from './ControlField'; +import { NPDU } from './NPDU'; +import { KNXDataBuffer } from '../KNXDataBuffer'; +export declare class LDataInd extends CEMIMessage { + constructor(additionalInfo: KNXDataBuffer, control: ControlField, srcAddress: KNXAddress, dstAddress: KNXAddress, npdu: NPDU); + static createFromBuffer(buffer: Buffer, offset?: number): LDataInd; + toBuffer(): Buffer; +} diff --git a/lib/protocol/cEMI/LDataInd.js b/lib/protocol/cEMI/LDataInd.js new file mode 100644 index 0000000..15de479 --- /dev/null +++ b/lib/protocol/cEMI/LDataInd.js @@ -0,0 +1,53 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.LDataInd = void 0; +const CEMIMessage_1 = require("./CEMIMessage"); +const CEMIConstants_1 = require("./CEMIConstants"); +const KNXAddress_1 = require("../KNXAddress"); +const ControlField_1 = require("./ControlField"); +const NPDU_1 = require("./NPDU"); +const KNXDataBuffer_1 = require("../KNXDataBuffer"); +class LDataInd extends CEMIMessage_1.CEMIMessage { + constructor(additionalInfo, control, srcAddress, dstAddress, npdu) { + super(CEMIConstants_1.CEMIConstants.L_DATA_IND, CEMIMessage_1.CEMIMessage.GetLength(additionalInfo, control, srcAddress, dstAddress, npdu), additionalInfo, control, srcAddress, dstAddress, npdu); + } + static createFromBuffer(buffer, offset = 0) { + if (offset >= buffer.length) { + throw new Error('Buffer too short'); + } + const addLength = buffer.readUInt8(offset++); + let additionalInfo = null; + if (addLength > 0) { + additionalInfo = new KNXDataBuffer_1.KNXDataBuffer(buffer.slice(offset, addLength)); + offset += addLength; + } + const controlField = ControlField_1.ControlField.createFromBuffer(buffer, offset); + offset += controlField.length; + const srcAddress = KNXAddress_1.KNXAddress.createFromBuffer(buffer, offset); + offset += srcAddress.length; + const dstAddress = KNXAddress_1.KNXAddress.createFromBuffer(buffer, offset, controlField.addressType); + offset += dstAddress.length; + const npdu = NPDU_1.NPDU.createFromBuffer(buffer, offset); + return new LDataInd(additionalInfo, controlField, srcAddress, dstAddress, npdu); + } + toBuffer() { + const buffer = Buffer.alloc(1); + const msgBuffer = [buffer]; + let offset = 0; + buffer.writeUInt8(this.msgCode, offset++); + if (this.additionalInfo == null) { + buffer.writeUInt8(0, offset); + } + else { + buffer.writeUInt8(this.additionalInfo.length, offset); + msgBuffer.push(this.additionalInfo.value); + } + msgBuffer.push(this.control.toBuffer()); + msgBuffer.push(this.srcAddress.toBuffer()); + msgBuffer.push(this.dstAddress.toBuffer()); + msgBuffer.push(this.npdu.toBuffer()); + return Buffer.concat(msgBuffer); + } +} +exports.LDataInd = LDataInd; +//# sourceMappingURL=LDataInd.js.map \ No newline at end of file diff --git a/lib/protocol/cEMI/LDataInd.js.map b/lib/protocol/cEMI/LDataInd.js.map new file mode 100644 index 0000000..229b817 --- /dev/null +++ b/lib/protocol/cEMI/LDataInd.js.map @@ -0,0 +1 @@ +{"version":3,"file":"LDataInd.js","sourceRoot":"","sources":["../../../src/protocol/cEMI/LDataInd.ts"],"names":[],"mappings":";;;AAAA,+CAA0C;AAC1C,mDAAgD;AAChD,8CAA2C;AAC3C,iDAA6C;AAC7C,iCAA4B;AAC5B,oDAA+C;AAE/C,MAAa,QAAS,SAAQ,yBAAW;IACrC,YACI,cAA6B,EAC7B,OAAqB,EACrB,UAAsB,EACtB,UAAsB,EACtB,IAAU;QACV,KAAK,CACD,6BAAa,CAAC,UAAU,EACxB,yBAAW,CAAC,SAAS,CAAC,cAAc,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,IAAI,CAAC,EAC5E,cAAc,EACd,OAAO,EACP,UAAU,EACV,UAAU,EACV,IAAI,CAAC,CAAC;IACd,CAAC;IAQD,MAAM,CAAC,gBAAgB,CAAC,MAAc,EAAE,SAAiB,CAAC;QACtD,IAAI,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE;YACzB,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;SACvC;QACD,MAAM,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC,M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AAC,MAAM,EAAE,MAAM,CAAC,CAAC;YACtD,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;SAC7C;QACD,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;QACxC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC,CAAC;QAC3C,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC,CAAC;QAC3C,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;QACrC,OAAO,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IACpC,CAAC;CACJ;AAhED,4BAgEC"} \ No newline at end of file diff --git a/lib/protocol/cEMI/LDataReq.d.ts b/lib/protocol/cEMI/LDataReq.d.ts new file mode 100644 index 0000000..d8adc71 --- /dev/null +++ b/lib/protocol/cEMI/LDataReq.d.ts @@ -0,0 +1,11 @@ +/// +import { CEMIMessage } from './CEMIMessage'; +import { KNXAddress } from '../KNXAddress'; +import { ControlField } from './ControlField'; +import { NPDU } from './NPDU'; +import { KNXDataBuffer } from '../KNXDataBuffer'; +export declare class LDataReq extends CEMIMessage { + constructor(additionalInfo: KNXDataBuffer, control: ControlField, srcAddress: KNXAddress, dstAddress: KNXAddress, npdu: NPDU); + static createFromBuffer(buffer: Buffer, offset?: number): LDataReq; + toBuffer(): Buffer; +} diff --git a/lib/protocol/cEMI/LDataReq.js b/lib/protocol/cEMI/LDataReq.js new file mode 100644 index 0000000..c17fced --- /dev/null +++ b/lib/protocol/cEMI/LDataReq.js @@ -0,0 +1,53 @@ +'use strict'; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.LDataReq = void 0; +const CEMIMessage_1 = require("./CEMIMessage"); +const CEMIConstants_1 = require("./CEMIConstants"); +const KNXAddress_1 = require("../KNXAddress"); +const ControlField_1 = require("./ControlField"); +const NPDU_1 = require("./NPDU"); +const KNXDataBuffer_1 = require("../KNXDataBuffer"); +class LDataReq extends CEMIMessage_1.CEMIMessage { + constructor(additionalInfo, control, srcAddress, dstAddress, npdu) { + super(CEMIConstants_1.CEMIConstants.L_DATA_REQ, CEMIMessage_1.CEMIMessage.GetLength(additionalInfo, control, srcAddress, dstAddress, npdu), additionalInfo, control, srcAddress, dstAddress, npdu); + } + static createFromBuffer(buffer, offset = 0) { + if (offset >= buffer.length) { + throw new Error('Buffer too short'); + } + const addLength = buffer.readUInt8(offset++); + let additionalInfo = null; + if (addLength > 0) { + additionalInfo = new KNXDataBuffer_1.KNXDataBuffer(buffer.slice(offset, addLength)); + offset += addLength; + } + const controlField = ControlField_1.ControlField.createFromBuffer(buffer, offset); + offset += controlField.length; + const srcAddress = KNXAddress_1.KNXAddress.createFromBuffer(buffer, offset); + offset += srcAddress.length; + const dstAddress = KNXAddress_1.KNXAddress.createFromBuffer(buffer, offset, controlField.addressType); + offset += dstAddress.length; + const npdu = NPDU_1.NPDU.createFromBuffer(buffer, offset); + return new LDataReq(additionalInfo, controlField, srcAddress, dstAddress, npdu); + } + toBuffer() { + const buffer = Buffer.alloc(2); + const msgBuffer = [buffer]; + let offset = 0; + buffer.writeUInt8(this.msgCode, offset++); + if (this.additionalInfo == null) { + buffer.writeUInt8(0, offset); + } + else { + buffer.writeUInt8(this.additionalInfo.length, offset); + msgBuffer.push(this.additionalInfo.value); + } + msgBuffer.push(this.control.toBuffer()); + msgBuffer.push(this.srcAddress.toBuffer()); + msgBuffer.push(this.dstAddress.toBuffer()); + msgBuffer.push(this.npdu.toBuffer()); + return Buffer.concat(msgBuffer); + } +} +exports.LDataReq = LDataReq; +//# sourceMappingURL=LDataReq.js.map \ No newline at end of file diff --git a/lib/protocol/cEMI/LDataReq.js.map b/lib/protocol/cEMI/LDataReq.js.map new file mode 100644 index 0000000..068237d --- /dev/null +++ b/lib/protocol/cEMI/LDataReq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C;CACJ;AA9DD,4BA8DC"} \ No newline at end of file diff --git a/lib/protocol/cEMI/NPDU.d.ts b/lib/protocol/cEMI/NPDU.d.ts new file mode 100644 index 0000000..5c7f7ee --- /dev/null +++ b/lib/protocol/cEMI/NPDU.d.ts @@ -0,0 +1,30 @@ +/// +import { KNXDataBuffer } from '../KNXDataBuffer'; +export declare class NPDU { + private _tpci; + private _apci; + private _data; + set tpci(tpci: number); + get tpci(): number; + set apci(apci: number); + get apci(): number; + get dataBuffer(): KNXDataBuffer; + get dataValue(): Buffer; + set data(data: KNXDataBuffer); + get length(): number; + get action(): number; + set action(action: number); + get isGroupRead(): boolean; + get isGroupWrite(): boolean; + get isGroupResponse(): boolean; + static get GROUP_READ(): number; + static get GROUP_RESPONSE(): number; + static get GROUP_WRITE(): number; + static get INDIVIDUAL_WRITE(): number; + static get INDIVIDUAL_READ(): number; + static get INDIVIDUAL_RESPONSE(): number; + static get TPCI_UNUMBERED_PACKET(): number; + constructor(_tpci?: number, _apci?: number, _data?: KNXDataBuffer); + static createFromBuffer(buffer: Buffer, offset?: number): NPDU; + toBuffer(): Buffer; +} diff --git a/lib/protocol/cEMI/NPDU.js b/lib/protocol/cEMI/NPDU.js new file mode 100644 index 0000000..c9c3181 --- /dev/null +++ b/lib/protocol/cEMI/NPDU.js @@ -0,0 +1,126 @@ +'use strict'; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.NPDU = void 0; +const CEMIConstants_1 = require("./CEMIConstants"); +const KNXDataBuffer_1 = require("../KNXDataBuffer"); +class NPDU { + constructor(_tpci = 0x0, _apci = 0x0, _data = null) { + this._tpci = _tpci; + this._apci = _apci; + this._data = _data; + } + set tpci(tpci) { + if (isNaN(tpci) || (tpci < 0 && tpci > 0xFF)) { + throw new Error('Invalid TPCI'); + } + this._tpci = tpci; + } + get tpci() { + return this._tpci; + } + set apci(apci) { + if (isNaN(apci) || (apci < 0 && apci > 0xFF)) { + throw new Error('Invalid APCI'); + } + this._apci = apci; + } + get apci() { + return this._apci; + } + get dataBuffer() { + return this._data; + } + get dataValue() { + if (this._data == null) { + const val = this.apci & 0x3F; + return Buffer.alloc(1, val); + } + return this._data.value; + } + set data(data) { + if (data == null) { + this._data = null; + return; + } + if (!(data instanceof KNXDataBuffer_1.KNXDataBuffer)) { + throw new Error('Invalid data Buffer'); + } + if (data.sixBits() && data.length === 1 && data.value.readUInt8(0) < 0x3F) { + this.apci = (this.apci & 0xC0) | data.value.readUInt8(0); + this._data = null; + return; + } + this._data = data; + } + get length() { + if (this._data === null) { + return 3; + } + return 3 + this._data.length; + } + get action() { + return ((this.apci & 0xC0) >> 6) | ((this.tpci & 0x3) << 2); + } + set action(action) { + this.tpci = (action & 0xC) << 4; + if (this.action === NPDU.GROUP_READ || this.action >= NPDU.INDIVIDUAL_WRITE) { + this.apci = (action & 0x3) << 6; + } + else { + this.apci = ((action & 0x3) << 6) | (this.apci & 0x3F); + } + } + get isGroupRead() { + return this.action === NPDU.GROUP_READ; + } + get isGroupWrite() { + return this.action === NPDU.GROUP_WRITE; + } + get isGroupResponse() { + return this.action === NPDU.GROUP_RESPONSE; + } + static get GROUP_READ() { + return CEMIConstants_1.CEMIConstants.GROUP_READ; + } + static get GROUP_RESPONSE() { + return CEMIConstants_1.CEMIConstants.GROUP_RESPONSE; + } + static get GROUP_WRITE() { + return CEMIConstants_1.CEMIConstants.GROUP_WRITE; + } + static get INDIVIDUAL_WRITE() { + return CEMIConstants_1.CEMIConstants.INDIVIDUAL_WRITE; + } + static get INDIVIDUAL_READ() { + return CEMIConstants_1.CEMIConstants.INDIVIDUAL_READ; + } + static get INDIVIDUAL_RESPONSE() { + return CEMIConstants_1.CEMIConstants.INDIVIDUAL_RESPONSE; + } + static get TPCI_UNUMBERED_PACKET() { + return CEMIConstants_1.CEMIConstants.TPCI_UNUMBERED_PACKET; + } + static createFromBuffer(buffer, offset = 0) { + if (offset > buffer.length) { + throw new Error(`offset ${offset} out of buffer range ${buffer.length}`); + } + const npduLength = buffer.readUInt8(offset++); + const tpci = buffer.readUInt8(offset++); + const apci = buffer.readUInt8(offset++); + const data = npduLength > 1 ? buffer.slice(offset, offset + npduLength - 1) : null; + return new NPDU(tpci, apci, data == null ? null : new KNXDataBuffer_1.KNXDataBuffer(data)); + } + toBuffer() { + const length = this._data == null ? 1 : this._data.length + 1; + const buffer = Buffer.alloc(3); + buffer.writeUInt8(length, 0); + buffer.writeUInt8(this.tpci, 1); + buffer.writeUInt8(this.apci, 2); + if (length === 1) { + return buffer; + } + return Buffer.concat([buffer, this._data.value]); + } +} +exports.NPDU = NPDU; +//# sourceMappingURL=NPDU.js.map \ No newline at end of file diff --git a/lib/protocol/cEMI/NPDU.js.map b/lib/protocol/cEMI/NPDU.js.map new file mode 100644 index 0000000..1b062f5 --- /dev/null +++ b/lib/protocol/cEMI/NPDU.js.map @@ -0,0 +1 @@ +{"version":3,"file":"NPDU.js","sourceRoot":"","sources":["../../../src/protocol/cEMI/NPDU.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AACb,mDAA8C;AAC9C,oDAA+C;AAE/C,MAAa,IAAI;IA+Gb,YAAoB,QAAgB,GAAG,EAAU,QAAgB,GAAG,EAAU,QAAuB,IAAI;QAArF,UAAK,GAAL,KAAK,CAAc;QAAU,UAAK,GAAL,KAAK,CAAc;QAAU,UAAK,GAAL,KAAK,CAAsB;IACzG,CAAC;IA9GD,IAAI,IAAI,CAAC,IAAY;QACjB,IAAI,KAAK,CAAC,IAAI,CAAC,IAAK,CAAC,IAAI,GAAG,CAAC,IAAI,IAAI,GAAG,IAAI,CAAC,EAAE;YAC3C,MAAM,IAAI,KAAK,CAAC,cAAc,CAAC,CAAC;SACnC;QACD,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACtB,CAAC;IAED,IAAI,IAAI;QACJ,OAAO,IAAI,CAAC,KAAK,CAAC;IACtB,CAAC;IAED,IAAI,IAAI,CAAC,IAAY;QACjB,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,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,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAC/B,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;QAC7B,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;QAChC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;QAChC,IAAI,MAAM,KAAK,CAAC,EAAE;YACd,OAAO,MAAM,CAAC;SACjB;QACD,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;IACrD,CAAC;CACJ;AAxID,oBAwIC"} \ No newline at end of file diff --git a/lib/protocol/cEMI/TLVInfo.d.ts b/lib/protocol/cEMI/TLVInfo.d.ts new file mode 100644 index 0000000..349b57e --- /dev/null +++ b/lib/protocol/cEMI/TLVInfo.d.ts @@ -0,0 +1,9 @@ +/// +export declare class TLVInfo { + readonly type: number; + readonly length: number; + readonly info: Buffer; + constructor(type: number, length: number, info: Buffer); + static createFromBuffer(buffer: Buffer, offset?: number): TLVInfo; + toBuffer(): Buffer; +} diff --git a/lib/protocol/cEMI/TLVInfo.js b/lib/protocol/cEMI/TLVInfo.js new file mode 100644 index 0000000..56ad970 --- /dev/null +++ b/lib/protocol/cEMI/TLVInfo.js @@ -0,0 +1,27 @@ +'use strict'; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.TLVInfo = void 0; +class TLVInfo { + constructor(type, length, info) { + this.type = type; + this.length = length; + this.info = info; + } + static createFromBuffer(buffer, offset = 0) { + const type = buffer.readUInt8(offset++); + const length = buffer.readUInt8(offset++); + const info = Buffer.alloc(length); + for (let i = 0; i < length; i++) { + info.writeUInt8(buffer.readUInt8(offset++), i); + } + return new TLVInfo(type, length, info); + } + toBuffer() { + const buffer = Buffer.alloc(2); + buffer.writeUInt8(this.type, 0); + buffer.writeUInt8(this.length, 1); + return Buffer.concat([buffer, this.info]); + } +} +exports.TLVInfo = TLVInfo; +//# sourceMappingURL=TLVInfo.js.map \ No newline at end of file diff --git a/lib/protocol/cEMI/TLVInfo.js.map b/lib/protocol/cEMI/TLVInfo.js.map new file mode 100644 index 0000000..1afc8e7 --- /dev/null +++ b/lib/protocol/cEMI/TLVInfo.js.map @@ -0,0 +1 @@ +{"version":3,"file":"TLVInfo.js","sourceRoot":"","sources":["../../../src/protocol/cEMI/TLVInfo.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAEb,MAAa,OAAO;IAChB,YAAqB,IAAY,EAAW,MAAc,EAAW,IAAY;QAA5D,SAAI,GAAJ,IAAI,CAAQ;QAAW,WAAM,GAAN,MAAM,CAAQ;QAAW,SAAI,GAAJ,IAAI,CAAQ;IACjF,CAAC;IAED,MAAM,CAAC,gBAAgB,CAAC,MAAc,EAAE,SAAiB,CAAC;QACtD,MAAM,IAAI,GAAG,MAAM,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC;QACxC,MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC;QAC1C,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAClC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC,EAAE,EAAE;YAC7B,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;SAClD;QACD,OAAO,IAAI,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;IAC3C,CAAC;IAED,QAAQ;QACJ,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAC/B,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;QAChC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;QAClC,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAC9C,CAAC;CACJ;AApBD,0BAoBC"} \ No newline at end of file diff --git a/lib/protocol/index.d.ts b/lib/protocol/index.d.ts new file mode 100644 index 0000000..9293602 --- /dev/null +++ b/lib/protocol/index.d.ts @@ -0,0 +1,7 @@ +export { KNXAddress } from './KNXAddress'; +export { DeviceInfo } from './DeviceInfo'; +export { HPAI } from './HPAI'; +export { KNXProtocol } from './KNXProtocol'; +export { NPDU } from './cEMI/NPDU'; +export { KNXPacket } from './KNXPacket'; +export { KNXDataBuffer } from './KNXDataBuffer'; diff --git a/lib/protocol/index.js b/lib/protocol/index.js new file mode 100644 index 0000000..8446a4e --- /dev/null +++ b/lib/protocol/index.js @@ -0,0 +1,17 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var KNXAddress_1 = require("./KNXAddress"); +Object.defineProperty(exports, "KNXAddress", { enumerable: true, get: function () { return KNXAddress_1.KNXAddress; } }); +var DeviceInfo_1 = require("./DeviceInfo"); +Object.defineProperty(exports, "DeviceInfo", { enumerable: true, get: function () { return DeviceInfo_1.DeviceInfo; } }); +var HPAI_1 = require("./HPAI"); +Object.defineProperty(exports, "HPAI", { enumerable: true, get: function () { return HPAI_1.HPAI; } }); +var KNXProtocol_1 = require("./KNXProtocol"); +Object.defineProperty(exports, "KNXProtocol", { enumerable: true, get: function () { return KNXProtocol_1.KNXProtocol; } }); +var NPDU_1 = require("./cEMI/NPDU"); +Object.defineProperty(exports, "NPDU", { enumerable: true, get: function () { return NPDU_1.NPDU; } }); +var KNXPacket_1 = require("./KNXPacket"); +Object.defineProperty(exports, "KNXPacket", { enumerable: true, get: function () { return KNXPacket_1.KNXPacket; } }); +var KNXDataBuffer_1 = require("./KNXDataBuffer"); +Object.defineProperty(exports, "KNXDataBuffer", { enumerable: true, get: function () { return KNXDataBuffer_1.KNXDataBuffer; } }); +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/lib/protocol/index.js.map b/lib/protocol/index.js.map new file mode 100644 index 0000000..30a9393 --- /dev/null +++ b/lib/protocol/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/protocol/index.ts"],"names":[],"mappings":";;AAAA,2CAAwC;AAAhC,wGAAA,UAAU,OAAA;AAClB,2CAAwC;AAAhC,wGAAA,UAAU,OAAA;AAClB,+BAA4B;AAApB,4FAAA,IAAI,OAAA;AACZ,6CAA0C;AAAlC,0GAAA,WAAW,OAAA;AACnB,oCAAiC;AAAzB,4FAAA,IAAI,OAAA;AACZ,yCAAsC;AAA9B,sGAAA,SAAS,OAAA;AACjB,iDAA8C;AAAtC,8GAAA,aAAa,OAAA"} \ No newline at end of file From ed7f52df4548a8ce7484fc87898b0598376880f3 Mon Sep 17 00:00:00 2001 From: Nyoto Date: Mon, 10 Aug 2020 17:54:55 +0800 Subject: [PATCH 3/4] change build export class name --- lib/DataPoints/Alarm.d.ts | 21 ++----- lib/DataPoints/Alarm.js | 7 ++- lib/DataPoints/Alarm.js.map | 2 +- lib/DataPoints/Angle.d.ts | 21 ++----- lib/DataPoints/Angle.js | 7 ++- lib/DataPoints/Angle.js.map | 2 +- lib/DataPoints/Binary.d.ts | 21 ++----- lib/DataPoints/Binary.js | 7 ++- lib/DataPoints/Binary.js.map | 2 +- lib/DataPoints/DataPointFactory.js | 79 ++++++++++++------------- lib/DataPoints/DataPointFactory.js.map | 2 +- lib/DataPoints/Date.d.ts | 21 ++----- lib/DataPoints/Date.js | 7 ++- lib/DataPoints/Date.js.map | 2 +- lib/DataPoints/Dimmingcontrol.d.ts | 21 ++----- lib/DataPoints/Dimmingcontrol.js | 7 ++- lib/DataPoints/Dimmingcontrol.js.map | 2 +- lib/DataPoints/Enable.d.ts | 21 ++----- lib/DataPoints/Enable.js | 7 ++- lib/DataPoints/Enable.js.map | 2 +- lib/DataPoints/Lux.d.ts | 21 ++----- lib/DataPoints/Lux.js | 7 ++- lib/DataPoints/Lux.js.map | 2 +- lib/DataPoints/Percentage.d.ts | 27 +++------ lib/DataPoints/Percentage.js | 7 ++- lib/DataPoints/Percentage.js.map | 2 +- lib/DataPoints/Percentagescaling.d.ts | 23 ++----- lib/DataPoints/Percentagescaling.js | 7 ++- lib/DataPoints/Percentagescaling.js.map | 2 +- lib/DataPoints/Scene.d.ts | 21 ++----- lib/DataPoints/Scene.js | 7 ++- lib/DataPoints/Scene.js.map | 2 +- lib/DataPoints/Scenecontrol.d.ts | 21 ++----- lib/DataPoints/Scenecontrol.js | 7 ++- lib/DataPoints/Scenecontrol.js.map | 2 +- lib/DataPoints/Speed.d.ts | 21 ++----- lib/DataPoints/Speed.js | 7 ++- lib/DataPoints/Speed.js.map | 2 +- lib/DataPoints/Startstop.d.ts | 21 ++----- lib/DataPoints/Startstop.js | 7 ++- lib/DataPoints/Startstop.js.map | 2 +- lib/DataPoints/Step.d.ts | 21 ++----- lib/DataPoints/Step.js | 7 ++- lib/DataPoints/Step.js.map | 2 +- lib/DataPoints/Switch.d.ts | 25 ++------ lib/DataPoints/Switch.js | 7 ++- lib/DataPoints/Switch.js.map | 2 +- lib/DataPoints/Temperature.d.ts | 21 ++----- lib/DataPoints/Temperature.js | 7 ++- lib/DataPoints/Temperature.js.map | 2 +- lib/DataPoints/Time.d.ts | 21 ++----- lib/DataPoints/Time.js | 7 ++- lib/DataPoints/Time.js.map | 2 +- lib/DataPoints/Trigger.d.ts | 21 ++----- lib/DataPoints/Trigger.js | 7 ++- lib/DataPoints/Trigger.js.map | 2 +- lib/DataPoints/Updown.d.ts | 21 ++----- lib/DataPoints/Updown.js | 7 ++- lib/DataPoints/Updown.js.map | 2 +- lib/DataPoints/index.d.ts | 38 ++++++------ lib/DataPoints/index.js | 38 ++++++------ lib/DataPoints/index.js.map | 2 +- lib/index.d.ts | 38 ++++++------ lib/index.js | 38 ++++++------ lib/index.js.map | 2 +- package.json | 2 +- src/DataPoints/Alarm.ts | 4 +- src/DataPoints/Angle.ts | 4 +- src/DataPoints/Binary.ts | 4 +- src/DataPoints/DataPointFactory.ts | 38 ++++++------ src/DataPoints/Date.ts | 4 +- src/DataPoints/Dimmingcontrol.ts | 4 +- src/DataPoints/Enable.ts | 4 +- src/DataPoints/Lux.ts | 4 +- src/DataPoints/Percentage.ts | 4 +- src/DataPoints/Percentagescaling.ts | 4 +- src/DataPoints/Scene.ts | 4 +- src/DataPoints/Scenecontrol.ts | 4 +- src/DataPoints/Speed.ts | 4 +- src/DataPoints/Startstop.ts | 4 +- src/DataPoints/Step.ts | 4 +- src/DataPoints/Switch.ts | 4 +- src/DataPoints/Temperature.ts | 4 +- src/DataPoints/Time.ts | 4 +- src/DataPoints/Trigger.ts | 4 +- src/DataPoints/Updown.ts | 6 +- src/DataPoints/index.ts | 38 ++++++------ src/index.ts | 38 ++++++------ 88 files changed, 410 insertions(+), 603 deletions(-) diff --git a/lib/DataPoints/Alarm.d.ts b/lib/DataPoints/Alarm.d.ts index 488c43a..c58218a 100644 --- a/lib/DataPoints/Alarm.d.ts +++ b/lib/DataPoints/Alarm.d.ts @@ -1,18 +1,5 @@ +import { DataPoint } from './DataPoint'; import { KNXAddress } from '../protocol/KNXAddress'; -declare const _default: { - new (ga: KNXAddress): { - _knxTunnelSocket: import("..").KNXTunnelSocket; - _value: any; - _actions: import("../DataPointTypes/definitions").DPTActions; - _ga: KNXAddress; - _type: import("../DataPointTypes/DataPointType").DataPointType; - readonly id: string; - readonly value: any; - readonly type: import("../DataPointTypes/DataPointType").DataPointType; - bind(knxTunnelSocket: import("..").KNXTunnelSocket): void; - read(): Promise; - write(val?: string | number | Date | import("../DataPointTypes/DPT3").DPT3Value | import("../DataPointTypes/DPT10").DPT10Value | import("../DataPointTypes/DPT18").DPT18Value): Promise; - }; - readonly UNKOWN_VALUE: string; -}; -export = _default; +export declare class Alarm extends DataPoint { + constructor(ga: KNXAddress); +} diff --git a/lib/DataPoints/Alarm.js b/lib/DataPoints/Alarm.js index 1296b22..09ee389 100644 --- a/lib/DataPoints/Alarm.js +++ b/lib/DataPoints/Alarm.js @@ -1,9 +1,12 @@ 'use strict'; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Alarm = void 0; const DataPoint_1 = require("./DataPoint"); const DataPointTypeFactory_1 = require("../DataPointTypes/DataPointTypeFactory"); -module.exports = class Alarm extends DataPoint_1.DataPoint { +class Alarm extends DataPoint_1.DataPoint { constructor(ga) { super(ga, DataPointTypeFactory_1.DPTS.DPTAlarm); } -}; +} +exports.Alarm = Alarm; //# sourceMappingURL=Alarm.js.map \ No newline at end of file diff --git a/lib/DataPoints/Alarm.js.map b/lib/DataPoints/Alarm.js.map index 6c2c765..9e455f5 100644 --- a/lib/DataPoints/Alarm.js.map +++ b/lib/DataPoints/Alarm.js.map @@ -1 +1 @@ -{"version":3,"file":"Alarm.js","sourceRoot":"","sources":["../../src/DataPoints/Alarm.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAUb,2CAAsC;AACtC,iFAA4D;AAG5D,iBAAS,MAAM,KAAM,SAAQ,qBAAS;IAClC,YAAY,EAAc;QACtB,KAAK,CAAC,EAAE,EAAE,2BAAI,CAAC,QAAQ,CAAC,CAAC;IAC7B,CAAC;CACJ,CAAC"} \ No newline at end of file +{"version":3,"file":"Alarm.js","sourceRoot":"","sources":["../../src/DataPoints/Alarm.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAUb,2CAAsC;AACtC,iFAA4D;AAG5D,MAAa,KAAM,SAAQ,qBAAS;IAChC,YAAY,EAAc;QACtB,KAAK,CAAC,EAAE,EAAE,2BAAI,CAAC,QAAQ,CAAC,CAAC;IAC7B,CAAC;CACJ;AAJD,sBAIC"} \ No newline at end of file diff --git a/lib/DataPoints/Angle.d.ts b/lib/DataPoints/Angle.d.ts index 488c43a..0d374bf 100644 --- a/lib/DataPoints/Angle.d.ts +++ b/lib/DataPoints/Angle.d.ts @@ -1,18 +1,5 @@ +import { DataPoint } from './DataPoint'; import { KNXAddress } from '../protocol/KNXAddress'; -declare const _default: { - new (ga: KNXAddress): { - _knxTunnelSocket: import("..").KNXTunnelSocket; - _value: any; - _actions: import("../DataPointTypes/definitions").DPTActions; - _ga: KNXAddress; - _type: import("../DataPointTypes/DataPointType").DataPointType; - readonly id: string; - readonly value: any; - readonly type: import("../DataPointTypes/DataPointType").DataPointType; - bind(knxTunnelSocket: import("..").KNXTunnelSocket): void; - read(): Promise; - write(val?: string | number | Date | import("../DataPointTypes/DPT3").DPT3Value | import("../DataPointTypes/DPT10").DPT10Value | import("../DataPointTypes/DPT18").DPT18Value): Promise; - }; - readonly UNKOWN_VALUE: string; -}; -export = _default; +export declare class Angle extends DataPoint { + constructor(ga: KNXAddress); +} diff --git a/lib/DataPoints/Angle.js b/lib/DataPoints/Angle.js index c376b79..a979f28 100644 --- a/lib/DataPoints/Angle.js +++ b/lib/DataPoints/Angle.js @@ -1,9 +1,12 @@ 'use strict'; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Angle = void 0; const DataPoint_1 = require("./DataPoint"); const DataPointTypeFactory_1 = require("../DataPointTypes/DataPointTypeFactory"); -module.exports = class Angle extends DataPoint_1.DataPoint { +class Angle extends DataPoint_1.DataPoint { constructor(ga) { super(ga, DataPointTypeFactory_1.DPTS.DPTAngle); } -}; +} +exports.Angle = Angle; //# sourceMappingURL=Angle.js.map \ No newline at end of file diff --git a/lib/DataPoints/Angle.js.map b/lib/DataPoints/Angle.js.map index 50e5e26..1f69083 100644 --- a/lib/DataPoints/Angle.js.map +++ b/lib/DataPoints/Angle.js.map @@ -1 +1 @@ -{"version":3,"file":"Angle.js","sourceRoot":"","sources":["../../src/DataPoints/Angle.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AASb,2CAAsC;AACtC,iFAA4D;AAG5D,iBAAS,MAAM,KAAM,SAAQ,qBAAS;IAClC,YAAY,EAAc;QACtB,KAAK,CAAC,EAAE,EAAE,2BAAI,CAAC,QAAQ,CAAC,CAAC;IAC7B,CAAC;CACJ,CAAC"} \ No newline at end of file +{"version":3,"file":"Angle.js","sourceRoot":"","sources":["../../src/DataPoints/Angle.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AASb,2CAAsC;AACtC,iFAA4D;AAG5D,MAAa,KAAM,SAAQ,qBAAS;IAChC,YAAY,EAAc;QACtB,KAAK,CAAC,EAAE,EAAE,2BAAI,CAAC,QAAQ,CAAC,CAAC;IAC7B,CAAC;CACJ;AAJD,sBAIC"} \ No newline at end of file diff --git a/lib/DataPoints/Binary.d.ts b/lib/DataPoints/Binary.d.ts index 488c43a..952e24c 100644 --- a/lib/DataPoints/Binary.d.ts +++ b/lib/DataPoints/Binary.d.ts @@ -1,18 +1,5 @@ +import { DataPoint } from './DataPoint'; import { KNXAddress } from '../protocol/KNXAddress'; -declare const _default: { - new (ga: KNXAddress): { - _knxTunnelSocket: import("..").KNXTunnelSocket; - _value: any; - _actions: import("../DataPointTypes/definitions").DPTActions; - _ga: KNXAddress; - _type: import("../DataPointTypes/DataPointType").DataPointType; - readonly id: string; - readonly value: any; - readonly type: import("../DataPointTypes/DataPointType").DataPointType; - bind(knxTunnelSocket: import("..").KNXTunnelSocket): void; - read(): Promise; - write(val?: string | number | Date | import("../DataPointTypes/DPT3").DPT3Value | import("../DataPointTypes/DPT10").DPT10Value | import("../DataPointTypes/DPT18").DPT18Value): Promise; - }; - readonly UNKOWN_VALUE: string; -}; -export = _default; +export declare class Binary extends DataPoint { + constructor(ga: KNXAddress); +} diff --git a/lib/DataPoints/Binary.js b/lib/DataPoints/Binary.js index a1b98aa..cdfb48d 100644 --- a/lib/DataPoints/Binary.js +++ b/lib/DataPoints/Binary.js @@ -1,9 +1,12 @@ "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Binary = void 0; const DataPoint_1 = require("./DataPoint"); const DataPointTypeFactory_1 = require("../DataPointTypes/DataPointTypeFactory"); -module.exports = class Binary extends DataPoint_1.DataPoint { +class Binary extends DataPoint_1.DataPoint { constructor(ga) { super(ga, DataPointTypeFactory_1.DPTS.DPTBinary); } -}; +} +exports.Binary = Binary; //# sourceMappingURL=Binary.js.map \ No newline at end of file diff --git a/lib/DataPoints/Binary.js.map b/lib/DataPoints/Binary.js.map index c80c0b5..4b52371 100644 --- a/lib/DataPoints/Binary.js.map +++ b/lib/DataPoints/Binary.js.map @@ -1 +1 @@ -{"version":3,"file":"Binary.js","sourceRoot":"","sources":["../../src/DataPoints/Binary.ts"],"names":[],"mappings":";AAAA,2CAAsC;AACtC,iFAA4D;AAG5D,iBAAS,MAAM,MAAO,SAAQ,qBAAS;IACnC,YAAY,EAAc;QACtB,KAAK,CAAC,EAAE,EAAE,2BAAI,CAAC,SAAS,CAAC,CAAC;IAC9B,CAAC;CACJ,CAAC"} \ No newline at end of file +{"version":3,"file":"Binary.js","sourceRoot":"","sources":["../../src/DataPoints/Binary.ts"],"names":[],"mappings":";;;AAAA,2CAAsC;AACtC,iFAA4D;AAG5D,MAAa,MAAO,SAAQ,qBAAS;IACjC,YAAY,EAAc;QACtB,KAAK,CAAC,EAAE,EAAE,2BAAI,CAAC,SAAS,CAAC,CAAC;IAC9B,CAAC;CACJ;AAJD,wBAIC"} \ No newline at end of file diff --git a/lib/DataPoints/DataPointFactory.js b/lib/DataPoints/DataPointFactory.js index 1dba486..97f715c 100644 --- a/lib/DataPoints/DataPointFactory.js +++ b/lib/DataPoints/DataPointFactory.js @@ -1,49 +1,46 @@ "use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; Object.defineProperty(exports, "__esModule", { value: true }); exports.getDataPointType = exports.createDataPoint = void 0; -const Alarm_1 = __importDefault(require("./Alarm")); -const Angle_1 = __importDefault(require("./Angle")); -const Binary_1 = __importDefault(require("./Binary")); -const Date_1 = __importDefault(require("./Date")); -const Dimmingcontrol_1 = __importDefault(require("./Dimmingcontrol")); -const Enable_1 = __importDefault(require("./Enable")); -const Lux_1 = __importDefault(require("./Lux")); -const Percentage_1 = __importDefault(require("./Percentage")); -const Percentagescaling_1 = __importDefault(require("./Percentagescaling")); -const Scene_1 = __importDefault(require("./Scene")); -const Scenecontrol_1 = __importDefault(require("./Scenecontrol")); -const Speed_1 = __importDefault(require("./Speed")); -const Startstop_1 = __importDefault(require("./Startstop")); -const Step_1 = __importDefault(require("./Step")); -const Switch_1 = __importDefault(require("./Switch")); -const Temperature_1 = __importDefault(require("./Temperature")); -const Time_1 = __importDefault(require("./Time")); -const Trigger_1 = __importDefault(require("./Trigger")); -const Updown_1 = __importDefault(require("./Updown")); +const Alarm_1 = require("./Alarm"); +const Angle_1 = require("./Angle"); +const Binary_1 = require("./Binary"); +const Date_1 = require("./Date"); +const Dimmingcontrol_1 = require("./Dimmingcontrol"); +const Enable_1 = require("./Enable"); +const Lux_1 = require("./Lux"); +const Percentage_1 = require("./Percentage"); +const Percentagescaling_1 = require("./Percentagescaling"); +const Scene_1 = require("./Scene"); +const Scenecontrol_1 = require("./Scenecontrol"); +const Speed_1 = require("./Speed"); +const Startstop_1 = require("./Startstop"); +const Step_1 = require("./Step"); +const Switch_1 = require("./Switch"); +const Temperature_1 = require("./Temperature"); +const Time_1 = require("./Time"); +const Trigger_1 = require("./Trigger"); +const Updown_1 = require("./Updown"); const DataPointType_1 = require("../DataPointTypes/DataPointType"); const DataPointFactory = { - Alarm: Alarm_1.default, - Angle: Angle_1.default, - Binary: Binary_1.default, - Date: Date_1.default, - Dimmingcontrol: Dimmingcontrol_1.default, - Enable: Enable_1.default, - Lux: Lux_1.default, - Percentage: Percentage_1.default, - Percentagescaling: Percentagescaling_1.default, - Scene: Scene_1.default, - Scenecontrol: Scenecontrol_1.default, - Speed: Speed_1.default, - Startstop: Startstop_1.default, - Step: Step_1.default, - Switch: Switch_1.default, - Temperature: Temperature_1.default, - Time: Time_1.default, - Trigger: Trigger_1.default, - Updown: Updown_1.default + Alarm: Alarm_1.Alarm, + Angle: Angle_1.Angle, + Binary: Binary_1.Binary, + Date: Date_1.Date, + Dimmingcontrol: Dimmingcontrol_1.Dimmingcontrol, + Enable: Enable_1.Enable, + Lux: Lux_1.Lux, + Percentage: Percentage_1.Percentage, + Percentagescaling: Percentagescaling_1.Percentagescaling, + Scene: Scene_1.Scene, + Scenecontrol: Scenecontrol_1.Scenecontrol, + Speed: Speed_1.Speed, + Startstop: Startstop_1.Startstop, + Step: Step_1.Step, + Switch: Switch_1.Switch, + Temperature: Temperature_1.Temperature, + Time: Time_1.Time, + Trigger: Trigger_1.Trigger, + Updown: Updown_1.Updown }; exports.createDataPoint = (ga, typeName) => { const DataPointClassName = `${typeName[0].toUpperCase()}${typeName.slice(1).toLowerCase()}`; diff --git a/lib/DataPoints/DataPointFactory.js.map b/lib/DataPoints/DataPointFactory.js.map index 95190a9..3b74aea 100644 --- a/lib/DataPoints/DataPointFactory.js.map +++ b/lib/DataPoints/DataPointFactory.js.map @@ -1 +1 @@ -{"version":3,"file":"DataPointFactory.js","sourceRoot":"","sources":["../../src/DataPoints/DataPointFactory.ts"],"names":[],"mappings":";;;;;;AAGA,oDAA4B;AAC5B,oDAA4B;AAC5B,sDAA8B;AAC9B,kDAA0B;AAC1B,sEAA8C;AAC9C,sDAA8B;AAC9B,gDAAwB;AACxB,8DAAsC;AACtC,4EAAoD;AACpD,oDAA4B;AAC5B,kEAA0C;AAC1C,oDAA4B;AAC5B,4DAAoC;AACpC,kDAA0B;AAC1B,sDAA8B;AAC9B,gEAAwC;AACxC,kDAA0B;AAC1B,wDAAgC;AAChC,sDAA8B;AAC9B,mEAAgE;AAShE,MAAM,gBAAgB,GAA4C;IAC9D,KAAK,EAAL,eAAK;IACL,KAAK,EAAL,eAAK;IACL,MAAM,EAAN,gBAAM;IACN,IAAI,EAAJ,cAAI;IACJ,cAAc,EAAd,wBAAc;IACd,MAAM,EAAN,gBAAM;IACN,GAAG,EAAH,aAAG;IACH,UAAU,EAAV,oBAAU;IACV,iBAAiB,EAA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AAI,KAAK,CAAC,mBAAmB,OAAO,gBAAgB,IAAI,EAAE,CAAC,CAAC;KACrE;IACD,OAAO,UAAU,CAAC;AACtB,CAAC,CAAC"} \ No newline at end of file +{"version":3,"file":"DataPointFactory.js","sourceRoot":"","sources":["../../src/DataPoints/DataPointFactory.ts"],"names":[],"mappings":";;;AAGA,mCAAgC;AAChC,mCAAgC;AAChC,qCAAkC;AAClC,iCAA8B;AAC9B,qDAAkD;AAClD,qCAAkC;AAClC,+BAA4B;AAC5B,6CAA0C;AAC1C,2DAAwD;AACxD,mCAAgC;AAChC,iDAA8C;AAC9C,mCAAgC;AAChC,2CAAwC;AACxC,iCAA8B;AAC9B,qCAAkC;AAClC,+CAA4C;AAC5C,iCAA8B;AAC9B,uCAAoC;AACpC,qCAAkC;AAClC,mEAAgE;AAShE,MAAM,gBAAgB,GAA4C;IAC9D,KAAK,EAAL,aAAK;IACL,KAAK,EAAL,aAAK;IACL,MAAM,EAAN,eAAM;IACN,IAAI,EAAJ,WAAI;IACJ,cAAc,EAAd,+BAAc;IACd,MAAM,EAAN,eAAM;IACN,GAAG,EAAH,SAAG;IACH,UAAU,EAAV,uBAAU;IACV,iBAAiB,EAAjB,qCAAiB;IACjB,KAAK,EAAL,aAAK;IACL,YAAY,EAAZ,2BAAY;IACZ,KAAK,EAAL,aAAK;IACL,SAAS,EAAT,qBAAS;IACT,IAAI,EAAJ,WAAI;IACJ,MAAM,EAAN,eAAM;IACN,WAAW,EAAX,yBAAW;IACX,IAAI,EAAJ,WAAI;IACJ,OAAO,EAAP,iBAAO;IACP,MAAM,EAAN,eAAM;CACT,CAAC;AAEW,QAAA,eAAe,GAAG,CAAC,EAAc,EAAE,QAAgB,EAAa,EAAE;IAE3E,MAAM,kBAAkB,GAAG,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC;IAC5F,MAAM,cAAc,GAAe,gBAAgB,CAAC,kBAAkB,CAAe,CAAC;IACtF,IAAI,cAAc,IAAI,IAAI,EAAE;QACxB,MAAM,IAAI,KAAK,CAAC,0BAA0B,QAAQ,EAAE,CAAC,CAAC;KACzD;IACD,OAAO,IAAI,cAAc,CAAC,EAAE,CAAC,CAAC;AAClC,CAAC,CAAC;AAEW,QAAA,gBAAgB,GAAG,CAAC,IAAmB,EAAE,OAAsB,EAAU,EAAE;IACpF,MAAM,GAAG,GAAQ,6BAAa,CAAC,KAAK,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC;IACnD,IAAI,GAAG,IAAI,IAAI,EAAE;QACb,MAAM,IAAI,KAAK,CAAC,gBAAgB,IAAI,EAAE,CAAC,CAAC;KAC3C;IACD,IAAI,cAAc,GAAG,GAAG,OAAO,EAAE,CAAC;IAClC,OAAO,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE;QAC9B,cAAc,GAAG,IAAI,cAAc,EAAE,CAAC;KACzC;IACD,MAAM,UAAU,GAAG,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IACpD,IAAI,UAAU,IAAI,IAAI,EAAE;QACpB,MAAM,IAAI,KAAK,CAAC,mBAAmB,OAAO,gBAAgB,IAAI,EAAE,CAAC,CAAC;KACrE;IACD,OAAO,UAAU,CAAC;AACtB,CAAC,CAAC"} \ No newline at end of file diff --git a/lib/DataPoints/Date.d.ts b/lib/DataPoints/Date.d.ts index 488c43a..e955b80 100644 --- a/lib/DataPoints/Date.d.ts +++ b/lib/DataPoints/Date.d.ts @@ -1,18 +1,5 @@ +import { DataPoint } from './DataPoint'; import { KNXAddress } from '../protocol/KNXAddress'; -declare const _default: { - new (ga: KNXAddress): { - _knxTunnelSocket: import("..").KNXTunnelSocket; - _value: any; - _actions: import("../DataPointTypes/definitions").DPTActions; - _ga: KNXAddress; - _type: import("../DataPointTypes/DataPointType").DataPointType; - readonly id: string; - readonly value: any; - readonly type: import("../DataPointTypes/DataPointType").DataPointType; - bind(knxTunnelSocket: import("..").KNXTunnelSocket): void; - read(): Promise; - write(val?: string | number | Date | import("../DataPointTypes/DPT3").DPT3Value | import("../DataPointTypes/DPT10").DPT10Value | import("../DataPointTypes/DPT18").DPT18Value): Promise; - }; - readonly UNKOWN_VALUE: string; -}; -export = _default; +export declare class Date extends DataPoint { + constructor(ga: KNXAddress); +} diff --git a/lib/DataPoints/Date.js b/lib/DataPoints/Date.js index 5b3ce1e..2ce5dcf 100644 --- a/lib/DataPoints/Date.js +++ b/lib/DataPoints/Date.js @@ -1,9 +1,12 @@ "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Date = void 0; const DataPoint_1 = require("./DataPoint"); const DataPointTypeFactory_1 = require("../DataPointTypes/DataPointTypeFactory"); -module.exports = class Date extends DataPoint_1.DataPoint { +class Date extends DataPoint_1.DataPoint { constructor(ga) { super(ga, DataPointTypeFactory_1.DPTS.DPTDate); } -}; +} +exports.Date = Date; //# sourceMappingURL=Date.js.map \ No newline at end of file diff --git a/lib/DataPoints/Date.js.map b/lib/DataPoints/Date.js.map index c24f7a2..7113f5a 100644 --- a/lib/DataPoints/Date.js.map +++ b/lib/DataPoints/Date.js.map @@ -1 +1 @@ -{"version":3,"file":"Date.js","sourceRoot":"","sources":["../../src/DataPoints/Date.ts"],"names":[],"mappings":";AAOA,2CAAsC;AACtC,iFAA4D;AAG5D,iBAAS,MAAM,IAAK,SAAQ,qBAAS;IACjC,YAAY,EAAc;QACtB,KAAK,CAAC,EAAE,EAAE,2BAAI,CAAC,OAAO,CAAC,CAAC;IAC5B,CAAC;CACJ,CAAC"} \ No newline at end of file +{"version":3,"file":"Date.js","sourceRoot":"","sources":["../../src/DataPoints/Date.ts"],"names":[],"mappings":";;;AAOA,2CAAsC;AACtC,iFAA4D;AAG5D,MAAa,IAAK,SAAQ,qBAAS;IAC/B,YAAY,EAAc;QACtB,KAAK,CAAC,EAAE,EAAE,2BAAI,CAAC,OAAO,CAAC,CAAC;IAC5B,CAAC;CACJ;AAJD,oBAIC"} \ No newline at end of file diff --git a/lib/DataPoints/Dimmingcontrol.d.ts b/lib/DataPoints/Dimmingcontrol.d.ts index 488c43a..448754a 100644 --- a/lib/DataPoints/Dimmingcontrol.d.ts +++ b/lib/DataPoints/Dimmingcontrol.d.ts @@ -1,18 +1,5 @@ +import { DataPoint } from './DataPoint'; import { KNXAddress } from '../protocol/KNXAddress'; -declare const _default: { - new (ga: KNXAddress): { - _knxTunnelSocket: import("..").KNXTunnelSocket; - _value: any; - _actions: import("../DataPointTypes/definitions").DPTActions; - _ga: KNXAddress; - _type: import("../DataPointTypes/DataPointType").DataPointType; - readonly id: string; - readonly value: any; - readonly type: import("../DataPointTypes/DataPointType").DataPointType; - bind(knxTunnelSocket: import("..").KNXTunnelSocket): void; - read(): Promise; - write(val?: string | number | Date | import("../DataPointTypes/DPT3").DPT3Value | import("../DataPointTypes/DPT10").DPT10Value | import("../DataPointTypes/DPT18").DPT18Value): Promise; - }; - readonly UNKOWN_VALUE: string; -}; -export = _default; +export declare class Dimmingcontrol extends DataPoint { + constructor(ga: KNXAddress); +} diff --git a/lib/DataPoints/Dimmingcontrol.js b/lib/DataPoints/Dimmingcontrol.js index ea750c8..ef098fc 100644 --- a/lib/DataPoints/Dimmingcontrol.js +++ b/lib/DataPoints/Dimmingcontrol.js @@ -1,9 +1,12 @@ 'use strict'; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Dimmingcontrol = void 0; const DataPoint_1 = require("./DataPoint"); const DataPointTypeFactory_1 = require("../DataPointTypes/DataPointTypeFactory"); -module.exports = class Dimmingcontrol extends DataPoint_1.DataPoint { +class Dimmingcontrol extends DataPoint_1.DataPoint { constructor(ga) { super(ga, DataPointTypeFactory_1.DPTS.DPTDimmingcontrol); } -}; +} +exports.Dimmingcontrol = Dimmingcontrol; //# sourceMappingURL=Dimmingcontrol.js.map \ No newline at end of file diff --git a/lib/DataPoints/Dimmingcontrol.js.map b/lib/DataPoints/Dimmingcontrol.js.map index 1285b9d..2e87841 100644 --- a/lib/DataPoints/Dimmingcontrol.js.map +++ b/lib/DataPoints/Dimmingcontrol.js.map @@ -1 +1 @@ -{"version":3,"file":"Dimmingcontrol.js","sourceRoot":"","sources":["../../src/DataPoints/Dimmingcontrol.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAUb,2CAAsC;AACtC,iFAA4D;AAG5D,iBAAS,MAAM,cAAe,SAAQ,qBAAS;IAC3C,YAAY,EAAc;QACtB,KAAK,CAAC,EAAE,EAAE,2BAAI,CAAC,iBAAiB,CAAC,CAAC;IACtC,CAAC;CACJ,CAAC"} \ No newline at end of file +{"version":3,"file":"Dimmingcontrol.js","sourceRoot":"","sources":["../../src/DataPoints/Dimmingcontrol.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAUb,2CAAsC;AACtC,iFAA4D;AAG5D,MAAa,cAAe,SAAQ,qBAAS;IACzC,YAAY,EAAc;QACtB,KAAK,CAAC,EAAE,EAAE,2BAAI,CAAC,iBAAiB,CAAC,CAAC;IACtC,CAAC;CACJ;AAJD,wCAIC"} \ No newline at end of file diff --git a/lib/DataPoints/Enable.d.ts b/lib/DataPoints/Enable.d.ts index 488c43a..0b40800 100644 --- a/lib/DataPoints/Enable.d.ts +++ b/lib/DataPoints/Enable.d.ts @@ -1,18 +1,5 @@ +import { DataPoint } from './DataPoint'; import { KNXAddress } from '../protocol/KNXAddress'; -declare const _default: { - new (ga: KNXAddress): { - _knxTunnelSocket: import("..").KNXTunnelSocket; - _value: any; - _actions: import("../DataPointTypes/definitions").DPTActions; - _ga: KNXAddress; - _type: import("../DataPointTypes/DataPointType").DataPointType; - readonly id: string; - readonly value: any; - readonly type: import("../DataPointTypes/DataPointType").DataPointType; - bind(knxTunnelSocket: import("..").KNXTunnelSocket): void; - read(): Promise; - write(val?: string | number | Date | import("../DataPointTypes/DPT3").DPT3Value | import("../DataPointTypes/DPT10").DPT10Value | import("../DataPointTypes/DPT18").DPT18Value): Promise; - }; - readonly UNKOWN_VALUE: string; -}; -export = _default; +export declare class Enable extends DataPoint { + constructor(ga: KNXAddress); +} diff --git a/lib/DataPoints/Enable.js b/lib/DataPoints/Enable.js index 628f9fe..8cbb6ea 100644 --- a/lib/DataPoints/Enable.js +++ b/lib/DataPoints/Enable.js @@ -1,9 +1,12 @@ "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Enable = void 0; const DataPoint_1 = require("./DataPoint"); const DataPointTypeFactory_1 = require("../DataPointTypes/DataPointTypeFactory"); -module.exports = class Enable extends DataPoint_1.DataPoint { +class Enable extends DataPoint_1.DataPoint { constructor(ga) { super(ga, DataPointTypeFactory_1.DPTS.DPTEnable); } -}; +} +exports.Enable = Enable; //# sourceMappingURL=Enable.js.map \ No newline at end of file diff --git a/lib/DataPoints/Enable.js.map b/lib/DataPoints/Enable.js.map index 6c71d60..4778ae5 100644 --- a/lib/DataPoints/Enable.js.map +++ b/lib/DataPoints/Enable.js.map @@ -1 +1 @@ -{"version":3,"file":"Enable.js","sourceRoot":"","sources":["../../src/DataPoints/Enable.ts"],"names":[],"mappings":";AAAA,2CAAsC;AACtC,iFAA4D;AAG5D,iBAAS,MAAM,MAAO,SAAQ,qBAAS;IACnC,YAAY,EAAc;QACtB,KAAK,CAAC,EAAE,EAAE,2BAAI,CAAC,SAAS,CAAC,CAAC;IAC9B,CAAC;CACJ,CAAC"} \ No newline at end of file +{"version":3,"file":"Enable.js","sourceRoot":"","sources":["../../src/DataPoints/Enable.ts"],"names":[],"mappings":";;;AAAA,2CAAsC;AACtC,iFAA4D;AAG5D,MAAa,MAAO,SAAQ,qBAAS;IACjC,YAAY,EAAc;QACtB,KAAK,CAAC,EAAE,EAAE,2BAAI,CAAC,SAAS,CAAC,CAAC;IAC9B,CAAC;CACJ;AAJD,wBAIC"} \ No newline at end of file diff --git a/lib/DataPoints/Lux.d.ts b/lib/DataPoints/Lux.d.ts index 488c43a..29dcf0e 100644 --- a/lib/DataPoints/Lux.d.ts +++ b/lib/DataPoints/Lux.d.ts @@ -1,18 +1,5 @@ +import { DataPoint } from './DataPoint'; import { KNXAddress } from '../protocol/KNXAddress'; -declare const _default: { - new (ga: KNXAddress): { - _knxTunnelSocket: import("..").KNXTunnelSocket; - _value: any; - _actions: import("../DataPointTypes/definitions").DPTActions; - _ga: KNXAddress; - _type: import("../DataPointTypes/DataPointType").DataPointType; - readonly id: string; - readonly value: any; - readonly type: import("../DataPointTypes/DataPointType").DataPointType; - bind(knxTunnelSocket: import("..").KNXTunnelSocket): void; - read(): Promise; - write(val?: string | number | Date | import("../DataPointTypes/DPT3").DPT3Value | import("../DataPointTypes/DPT10").DPT10Value | import("../DataPointTypes/DPT18").DPT18Value): Promise; - }; - readonly UNKOWN_VALUE: string; -}; -export = _default; +export declare class Lux extends DataPoint { + constructor(ga: KNXAddress); +} diff --git a/lib/DataPoints/Lux.js b/lib/DataPoints/Lux.js index 921ce7b..e830d4a 100644 --- a/lib/DataPoints/Lux.js +++ b/lib/DataPoints/Lux.js @@ -1,9 +1,12 @@ "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Lux = void 0; const DataPoint_1 = require("./DataPoint"); const DataPointTypeFactory_1 = require("../DataPointTypes/DataPointTypeFactory"); -module.exports = class Lux extends DataPoint_1.DataPoint { +class Lux extends DataPoint_1.DataPoint { constructor(ga) { super(ga, DataPointTypeFactory_1.DPTS.DPTLux); } -}; +} +exports.Lux = Lux; //# sourceMappingURL=Lux.js.map \ No newline at end of file diff --git a/lib/DataPoints/Lux.js.map b/lib/DataPoints/Lux.js.map index a33df5b..0f80d07 100644 --- a/lib/DataPoints/Lux.js.map +++ b/lib/DataPoints/Lux.js.map @@ -1 +1 @@ -{"version":3,"file":"Lux.js","sourceRoot":"","sources":["../../src/DataPoints/Lux.ts"],"names":[],"mappings":";AASA,2CAAsC;AACtC,iFAA4D;AAG5D,iBAAS,MAAM,GAAI,SAAQ,qBAAS;IAChC,YAAY,EAAc;QACtB,KAAK,CAAC,EAAE,EAAE,2BAAI,CAAC,MAAM,CAAC,CAAC;IAC3B,CAAC;CACJ,CAAC"} \ No newline at end of file +{"version":3,"file":"Lux.js","sourceRoot":"","sources":["../../src/DataPoints/Lux.ts"],"names":[],"mappings":";;;AASA,2CAAsC;AACtC,iFAA4D;AAG5D,MAAa,GAAI,SAAQ,qBAAS;IAC9B,YAAY,EAAc;QACtB,KAAK,CAAC,EAAE,EAAE,2BAAI,CAAC,MAAM,CAAC,CAAC;IAC3B,CAAC;CACJ;AAJD,kBAIC"} \ No newline at end of file diff --git a/lib/DataPoints/Percentage.d.ts b/lib/DataPoints/Percentage.d.ts index 4b07b50..b58333e 100644 --- a/lib/DataPoints/Percentage.d.ts +++ b/lib/DataPoints/Percentage.d.ts @@ -1,21 +1,8 @@ +import { DataPoint } from './DataPoint'; import { KNXAddress } from '../protocol/KNXAddress'; -declare const _default: { - new (ga: KNXAddress): { - set(param: { - value: number; - }): void; - _knxTunnelSocket: import("..").KNXTunnelSocket; - _value: any; - _actions: import("../DataPointTypes/definitions").DPTActions; - _ga: KNXAddress; - _type: import("../DataPointTypes/DataPointType").DataPointType; - readonly id: string; - readonly value: any; - readonly type: import("../DataPointTypes/DataPointType").DataPointType; - bind(knxTunnelSocket: import("..").KNXTunnelSocket): void; - read(): Promise; - write(val?: string | number | Date | import("../DataPointTypes/DPT3").DPT3Value | import("../DataPointTypes/DPT10").DPT10Value | import("../DataPointTypes/DPT18").DPT18Value): Promise; - }; - readonly UNKOWN_VALUE: string; -}; -export = _default; +export declare class Percentage extends DataPoint { + constructor(ga: KNXAddress); + set(param: { + value: number; + }): void; +} diff --git a/lib/DataPoints/Percentage.js b/lib/DataPoints/Percentage.js index fd57eb3..9f6dae4 100644 --- a/lib/DataPoints/Percentage.js +++ b/lib/DataPoints/Percentage.js @@ -1,9 +1,11 @@ 'use strict'; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Percentage = void 0; const DataPoint_1 = require("./DataPoint"); const DataPointTypeFactory_1 = require("../DataPointTypes/DataPointTypeFactory"); const MIN = 0; const MAX = 100; -module.exports = class Percentage extends DataPoint_1.DataPoint { +class Percentage extends DataPoint_1.DataPoint { constructor(ga) { super(ga, DataPointTypeFactory_1.DPTS.DPTPercentage); this._actions = { @@ -28,5 +30,6 @@ module.exports = class Percentage extends DataPoint_1.DataPoint { } this.write(value); } -}; +} +exports.Percentage = Percentage; //# sourceMappingURL=Percentage.js.map \ No newline at end of file diff --git a/lib/DataPoints/Percentage.js.map b/lib/DataPoints/Percentage.js.map index b631fa4..cbba8f6 100644 --- a/lib/DataPoints/Percentage.js.map +++ b/lib/DataPoints/Percentage.js.map @@ -1 +1 @@ -{"version":3,"file":"Percentage.js","sourceRoot":"","sources":["../../src/DataPoints/Percentage.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AASb,2CAAsC;AACtC,iFAA4D;AAG5D,MAAM,GAAG,GAAG,CAAC,CAAC;AACd,MAAM,GAAG,GAAG,GAAG,CAAC;AAEhB,iBAAS,MAAM,UAAW,SAAQ,qBAAS;IACvC,YAAY,EAAc;QACtB,KAAK,CAAC,EAAE,EAAE,2BAAI,CAAC,aAAa,CAAC,CAAC;QAE9B,IAAI,CAAC,QAAQ,GAAG;YACZ,KAAK,EAAE;gBACH,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC;gBACzB,aAAa,EAAE;oBACX,IAAI,EAAE,SAAS;oBACf,GAAG,EAAE,GAAG;oBACR,GAAG,EAAE,GAAG;oBACR,OAAO,EAAE,GAAG;iBACf;aACJ;SACJ,CAAC;IACN,CAAC;IAED,GAAG,CAAC,KAAsB;QACtB,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,IAAI,IAAI,CAAC,EAAE;YAC1C,MAAM,IAAI,KAAK,CAAC,gEAAgE,CAAC,CAAC;SACrF;QACD,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAClC,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC,EAAE;YAChC,MAAM,IAAI,KAAK,CAAC,iBAAiB,KAAK,EAAE,CAAC,CAAC;SAC7C;QACD,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACtB,CAAC;CACJ,CAAC"} \ No newline at end of file +{"version":3,"file":"Percentage.js","sourceRoot":"","sources":["../../src/DataPoints/Percentage.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AASb,2CAAsC;AACtC,iFAA4D;AAG5D,MAAM,GAAG,GAAG,CAAC,CAAC;AACd,MAAM,GAAG,GAAG,GAAG,CAAC;AAEhB,MAAa,UAAW,SAAQ,qBAAS;IACrC,YAAY,EAAc;QACtB,KAAK,CAAC,EAAE,EAAE,2BAAI,CAAC,aAAa,CAAC,CAAC;QAE9B,IAAI,CAAC,QAAQ,GAAG;YACZ,KAAK,EAAE;gBACH,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC;gBACzB,aAAa,EAAE;oBACX,IAAI,EAAE,SAAS;oBACf,GAAG,EAAE,GAAG;oBACR,GAAG,EAAE,GAAG;oBACR,OAAO,EAAE,GAAG;iBACf;aACJ;SACJ,CAAC;IACN,CAAC;IAED,GAAG,CAAC,KAAsB;QACtB,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,IAAI,IAAI,CAAC,EAAE;YAC1C,MAAM,IAAI,KAAK,CAAC,gEAAgE,CAAC,CAAC;SACrF;QACD,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAClC,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC,EAAE;YAChC,MAAM,IAAI,KAAK,CAAC,iBAAiB,KAAK,EAAE,CAAC,CAAC;SAC7C;QACD,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACtB,CAAC;CACJ;AA3BD,gCA2BC"} \ No newline at end of file diff --git a/lib/DataPoints/Percentagescaling.d.ts b/lib/DataPoints/Percentagescaling.d.ts index a23ea3d..9752eb9 100644 --- a/lib/DataPoints/Percentagescaling.d.ts +++ b/lib/DataPoints/Percentagescaling.d.ts @@ -1,19 +1,6 @@ +import { DataPoint } from './DataPoint'; import { KNXAddress } from '../protocol/KNXAddress'; -declare const _default: { - new (ga: KNXAddress): { - set(_value: number): void; - _knxTunnelSocket: import("..").KNXTunnelSocket; - _value: any; - _actions: import("../DataPointTypes/definitions").DPTActions; - _ga: KNXAddress; - _type: import("../DataPointTypes/DataPointType").DataPointType; - readonly id: string; - readonly value: any; - readonly type: import("../DataPointTypes/DataPointType").DataPointType; - bind(knxTunnelSocket: import("..").KNXTunnelSocket): void; - read(): Promise; - write(val?: string | number | Date | import("../DataPointTypes/DPT3").DPT3Value | import("../DataPointTypes/DPT10").DPT10Value | import("../DataPointTypes/DPT18").DPT18Value): Promise; - }; - readonly UNKOWN_VALUE: string; -}; -export = _default; +export declare class Percentagescaling extends DataPoint { + constructor(ga: KNXAddress); + set(_value: number): void; +} diff --git a/lib/DataPoints/Percentagescaling.js b/lib/DataPoints/Percentagescaling.js index 0fb61f7..cf54779 100644 --- a/lib/DataPoints/Percentagescaling.js +++ b/lib/DataPoints/Percentagescaling.js @@ -1,9 +1,11 @@ "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Percentagescaling = void 0; const DataPoint_1 = require("./DataPoint"); const DataPointTypeFactory_1 = require("../DataPointTypes/DataPointTypeFactory"); const MIN = 0; const MAX = 255; -module.exports = class Percentagescaling extends DataPoint_1.DataPoint { +class Percentagescaling extends DataPoint_1.DataPoint { constructor(ga) { super(ga, DataPointTypeFactory_1.DPTS.DPTPercentagescaling); this._actions = { @@ -24,5 +26,6 @@ module.exports = class Percentagescaling extends DataPoint_1.DataPoint { } this.write(value); } -}; +} +exports.Percentagescaling = Percentagescaling; //# sourceMappingURL=Percentagescaling.js.map \ No newline at end of file diff --git a/lib/DataPoints/Percentagescaling.js.map b/lib/DataPoints/Percentagescaling.js.map index fb4099b..3cb76a3 100644 --- a/lib/DataPoints/Percentagescaling.js.map +++ b/lib/DataPoints/Percentagescaling.js.map @@ -1 +1 @@ -{"version":3,"file":"Percentagescaling.js","sourceRoot":"","sources":["../../src/DataPoints/Percentagescaling.ts"],"names":[],"mappings":";AAAA,2CAAsC;AACtC,iFAA4D;AAG5D,MAAM,GAAG,GAAG,CAAC,CAAC;AACd,MAAM,GAAG,GAAG,GAAG,CAAC;AAEhB,iBAAS,MAAM,iBAAkB,SAAQ,qBAAS;IAC9C,YAAY,EAAc;QACtB,KAAK,CAAC,EAAE,EAAE,2BAAI,CAAC,oBAAoB,CAAC,CAAC;QAErC,IAAI,CAAC,QAAQ,GAAG;YACZ,KAAK,EAAE;gBACH,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC;gBACzB,aAAa,EAAE;oBACX,IAAI,EAAE,SAAS;oBACf,GAAG,EAAE,GAAG;oBACR,GAAG,EAAE,GAAG;iBACX;aACJ;SACJ,CAAC;IACN,CAAC;IAED,GAAG,CAAC,MAAc;QACd,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;QAC7B,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC,EAAE;YAChC,MAAM,IAAI,KAAK,CAAC,iBAAiB,KAAK,EAAE,CAAC,CAAC;SAC7C;QACD,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACtB,CAAC;CACJ,CAAC"} \ No newline at end of file +{"version":3,"file":"Percentagescaling.js","sourceRoot":"","sources":["../../src/DataPoints/Percentagescaling.ts"],"names":[],"mappings":";;;AAAA,2CAAsC;AACtC,iFAA4D;AAG5D,MAAM,GAAG,GAAG,CAAC,CAAC;AACd,MAAM,GAAG,GAAG,GAAG,CAAC;AAEhB,MAAa,iBAAkB,SAAQ,qBAAS;IAC5C,YAAY,EAAc;QACtB,KAAK,CAAC,EAAE,EAAE,2BAAI,CAAC,oBAAoB,CAAC,CAAC;QAErC,IAAI,CAAC,QAAQ,GAAG;YACZ,KAAK,EAAE;gBACH,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC;gBACzB,aAAa,EAAE;oBACX,IAAI,EAAE,SAAS;oBACf,GAAG,EAAE,GAAG;oBACR,GAAG,EAAE,GAAG;iBACX;aACJ;SACJ,CAAC;IACN,CAAC;IAED,GAAG,CAAC,MAAc;QACd,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;QAC7B,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC,EAAE;YAChC,MAAM,IAAI,KAAK,CAAC,iBAAiB,KAAK,EAAE,CAAC,CAAC;SAC7C;QACD,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACtB,CAAC;CACJ;AAvBD,8CAuBC"} \ No newline at end of file diff --git a/lib/DataPoints/Scene.d.ts b/lib/DataPoints/Scene.d.ts index 488c43a..5136bb6 100644 --- a/lib/DataPoints/Scene.d.ts +++ b/lib/DataPoints/Scene.d.ts @@ -1,18 +1,5 @@ +import { DataPoint } from './DataPoint'; import { KNXAddress } from '../protocol/KNXAddress'; -declare const _default: { - new (ga: KNXAddress): { - _knxTunnelSocket: import("..").KNXTunnelSocket; - _value: any; - _actions: import("../DataPointTypes/definitions").DPTActions; - _ga: KNXAddress; - _type: import("../DataPointTypes/DataPointType").DataPointType; - readonly id: string; - readonly value: any; - readonly type: import("../DataPointTypes/DataPointType").DataPointType; - bind(knxTunnelSocket: import("..").KNXTunnelSocket): void; - read(): Promise; - write(val?: string | number | Date | import("../DataPointTypes/DPT3").DPT3Value | import("../DataPointTypes/DPT10").DPT10Value | import("../DataPointTypes/DPT18").DPT18Value): Promise; - }; - readonly UNKOWN_VALUE: string; -}; -export = _default; +export declare class Scene extends DataPoint { + constructor(ga: KNXAddress); +} diff --git a/lib/DataPoints/Scene.js b/lib/DataPoints/Scene.js index e5ba55e..e0a464b 100644 --- a/lib/DataPoints/Scene.js +++ b/lib/DataPoints/Scene.js @@ -1,9 +1,12 @@ "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Scene = void 0; const DataPoint_1 = require("./DataPoint"); const DataPointTypeFactory_1 = require("../DataPointTypes/DataPointTypeFactory"); -module.exports = class Scene extends DataPoint_1.DataPoint { +class Scene extends DataPoint_1.DataPoint { constructor(ga) { super(ga, DataPointTypeFactory_1.DPTS.DPTScene); } -}; +} +exports.Scene = Scene; //# sourceMappingURL=Scene.js.map \ No newline at end of file diff --git a/lib/DataPoints/Scene.js.map b/lib/DataPoints/Scene.js.map index 08232fc..a771701 100644 --- a/lib/DataPoints/Scene.js.map +++ b/lib/DataPoints/Scene.js.map @@ -1 +1 @@ -{"version":3,"file":"Scene.js","sourceRoot":"","sources":["../../src/DataPoints/Scene.ts"],"names":[],"mappings":";AAAA,2CAAsC;AACtC,iFAA4D;AAG5D,iBAAS,MAAM,KAAM,SAAQ,qBAAS;IAClC,YAAY,EAAc;QACtB,KAAK,CAAC,EAAE,EAAE,2BAAI,CAAC,QAAQ,CAAC,CAAC;IAC7B,CAAC;CACJ,CAAC"} \ No newline at end of file +{"version":3,"file":"Scene.js","sourceRoot":"","sources":["../../src/DataPoints/Scene.ts"],"names":[],"mappings":";;;AAAA,2CAAsC;AACtC,iFAA4D;AAG5D,MAAa,KAAM,SAAQ,qBAAS;IAChC,YAAY,EAAc;QACtB,KAAK,CAAC,EAAE,EAAE,2BAAI,CAAC,QAAQ,CAAC,CAAC;IAC7B,CAAC;CACJ;AAJD,sBAIC"} \ No newline at end of file diff --git a/lib/DataPoints/Scenecontrol.d.ts b/lib/DataPoints/Scenecontrol.d.ts index 488c43a..42c034e 100644 --- a/lib/DataPoints/Scenecontrol.d.ts +++ b/lib/DataPoints/Scenecontrol.d.ts @@ -1,18 +1,5 @@ +import { DataPoint } from './DataPoint'; import { KNXAddress } from '../protocol/KNXAddress'; -declare const _default: { - new (ga: KNXAddress): { - _knxTunnelSocket: import("..").KNXTunnelSocket; - _value: any; - _actions: import("../DataPointTypes/definitions").DPTActions; - _ga: KNXAddress; - _type: import("../DataPointTypes/DataPointType").DataPointType; - readonly id: string; - readonly value: any; - readonly type: import("../DataPointTypes/DataPointType").DataPointType; - bind(knxTunnelSocket: import("..").KNXTunnelSocket): void; - read(): Promise; - write(val?: string | number | Date | import("../DataPointTypes/DPT3").DPT3Value | import("../DataPointTypes/DPT10").DPT10Value | import("../DataPointTypes/DPT18").DPT18Value): Promise; - }; - readonly UNKOWN_VALUE: string; -}; -export = _default; +export declare class Scenecontrol extends DataPoint { + constructor(ga: KNXAddress); +} diff --git a/lib/DataPoints/Scenecontrol.js b/lib/DataPoints/Scenecontrol.js index 7c1941d..ff89ca6 100644 --- a/lib/DataPoints/Scenecontrol.js +++ b/lib/DataPoints/Scenecontrol.js @@ -1,9 +1,12 @@ "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Scenecontrol = void 0; const DataPoint_1 = require("./DataPoint"); const DataPointTypeFactory_1 = require("../DataPointTypes/DataPointTypeFactory"); -module.exports = class Scenecontrol extends DataPoint_1.DataPoint { +class Scenecontrol extends DataPoint_1.DataPoint { constructor(ga) { super(ga, DataPointTypeFactory_1.DPTS.DPTScenecontrol); } -}; +} +exports.Scenecontrol = Scenecontrol; //# sourceMappingURL=Scenecontrol.js.map \ No newline at end of file diff --git a/lib/DataPoints/Scenecontrol.js.map b/lib/DataPoints/Scenecontrol.js.map index 1a9360d..c9c8c29 100644 --- a/lib/DataPoints/Scenecontrol.js.map +++ b/lib/DataPoints/Scenecontrol.js.map @@ -1 +1 @@ -{"version":3,"file":"Scenecontrol.js","sourceRoot":"","sources":["../../src/DataPoints/Scenecontrol.ts"],"names":[],"mappings":";AAAA,2CAAsC;AACtC,iFAA4D;AAG5D,iBAAS,MAAM,YAAa,SAAQ,qBAAS;IACzC,YAAY,EAAc;QACtB,KAAK,CAAC,EAAE,EAAE,2BAAI,CAAC,eAAe,CAAC,CAAC;IACpC,CAAC;CACJ,CAAC"} \ No newline at end of file +{"version":3,"file":"Scenecontrol.js","sourceRoot":"","sources":["../../src/DataPoints/Scenecontrol.ts"],"names":[],"mappings":";;;AAAA,2CAAsC;AACtC,iFAA4D;AAG5D,MAAa,YAAa,SAAQ,qBAAS;IACvC,YAAY,EAAc;QACtB,KAAK,CAAC,EAAE,EAAE,2BAAI,CAAC,eAAe,CAAC,CAAC;IACpC,CAAC;CACJ;AAJD,oCAIC"} \ No newline at end of file diff --git a/lib/DataPoints/Speed.d.ts b/lib/DataPoints/Speed.d.ts index 488c43a..2cb2a3a 100644 --- a/lib/DataPoints/Speed.d.ts +++ b/lib/DataPoints/Speed.d.ts @@ -1,18 +1,5 @@ +import { DataPoint } from './DataPoint'; import { KNXAddress } from '../protocol/KNXAddress'; -declare const _default: { - new (ga: KNXAddress): { - _knxTunnelSocket: import("..").KNXTunnelSocket; - _value: any; - _actions: import("../DataPointTypes/definitions").DPTActions; - _ga: KNXAddress; - _type: import("../DataPointTypes/DataPointType").DataPointType; - readonly id: string; - readonly value: any; - readonly type: import("../DataPointTypes/DataPointType").DataPointType; - bind(knxTunnelSocket: import("..").KNXTunnelSocket): void; - read(): Promise; - write(val?: string | number | Date | import("../DataPointTypes/DPT3").DPT3Value | import("../DataPointTypes/DPT10").DPT10Value | import("../DataPointTypes/DPT18").DPT18Value): Promise; - }; - readonly UNKOWN_VALUE: string; -}; -export = _default; +export declare class Speed extends DataPoint { + constructor(ga: KNXAddress); +} diff --git a/lib/DataPoints/Speed.js b/lib/DataPoints/Speed.js index a3ed999..d47e380 100644 --- a/lib/DataPoints/Speed.js +++ b/lib/DataPoints/Speed.js @@ -1,9 +1,12 @@ "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Speed = void 0; const DataPoint_1 = require("./DataPoint"); const DataPointTypeFactory_1 = require("../DataPointTypes/DataPointTypeFactory"); -module.exports = class Speed extends DataPoint_1.DataPoint { +class Speed extends DataPoint_1.DataPoint { constructor(ga) { super(ga, DataPointTypeFactory_1.DPTS.DPTSpeed); } -}; +} +exports.Speed = Speed; //# sourceMappingURL=Speed.js.map \ No newline at end of file diff --git a/lib/DataPoints/Speed.js.map b/lib/DataPoints/Speed.js.map index 8186c6b..c2d7fa3 100644 --- a/lib/DataPoints/Speed.js.map +++ b/lib/DataPoints/Speed.js.map @@ -1 +1 @@ -{"version":3,"file":"Speed.js","sourceRoot":"","sources":["../../src/DataPoints/Speed.ts"],"names":[],"mappings":";AAAA,2CAAsC;AACtC,iFAA4D;AAG5D,iBAAS,MAAM,KAAM,SAAQ,qBAAS;IAClC,YAAY,EAAc;QACtB,KAAK,CAAC,EAAE,EAAE,2BAAI,CAAC,QAAQ,CAAC,CAAC;IAC7B,CAAC;CACJ,CAAC"} \ No newline at end of file +{"version":3,"file":"Speed.js","sourceRoot":"","sources":["../../src/DataPoints/Speed.ts"],"names":[],"mappings":";;;AAAA,2CAAsC;AACtC,iFAA4D;AAG5D,MAAa,KAAM,SAAQ,qBAAS;IAChC,YAAY,EAAc;QACtB,KAAK,CAAC,EAAE,EAAE,2BAAI,CAAC,QAAQ,CAAC,CAAC;IAC7B,CAAC;CACJ;AAJD,sBAIC"} \ No newline at end of file diff --git a/lib/DataPoints/Startstop.d.ts b/lib/DataPoints/Startstop.d.ts index 488c43a..91b2ebe 100644 --- a/lib/DataPoints/Startstop.d.ts +++ b/lib/DataPoints/Startstop.d.ts @@ -1,18 +1,5 @@ +import { DataPoint } from './DataPoint'; import { KNXAddress } from '../protocol/KNXAddress'; -declare const _default: { - new (ga: KNXAddress): { - _knxTunnelSocket: import("..").KNXTunnelSocket; - _value: any; - _actions: import("../DataPointTypes/definitions").DPTActions; - _ga: KNXAddress; - _type: import("../DataPointTypes/DataPointType").DataPointType; - readonly id: string; - readonly value: any; - readonly type: import("../DataPointTypes/DataPointType").DataPointType; - bind(knxTunnelSocket: import("..").KNXTunnelSocket): void; - read(): Promise; - write(val?: string | number | Date | import("../DataPointTypes/DPT3").DPT3Value | import("../DataPointTypes/DPT10").DPT10Value | import("../DataPointTypes/DPT18").DPT18Value): Promise; - }; - readonly UNKOWN_VALUE: string; -}; -export = _default; +export declare class Startstop extends DataPoint { + constructor(ga: KNXAddress); +} diff --git a/lib/DataPoints/Startstop.js b/lib/DataPoints/Startstop.js index c702154..bcf7a33 100644 --- a/lib/DataPoints/Startstop.js +++ b/lib/DataPoints/Startstop.js @@ -1,9 +1,12 @@ "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Startstop = void 0; const DataPoint_1 = require("./DataPoint"); const DataPointTypeFactory_1 = require("../DataPointTypes/DataPointTypeFactory"); -module.exports = class Startstop extends DataPoint_1.DataPoint { +class Startstop extends DataPoint_1.DataPoint { constructor(ga) { super(ga, DataPointTypeFactory_1.DPTS.DPTStartstop); } -}; +} +exports.Startstop = Startstop; //# sourceMappingURL=Startstop.js.map \ No newline at end of file diff --git a/lib/DataPoints/Startstop.js.map b/lib/DataPoints/Startstop.js.map index 9136034..9f9f6bf 100644 --- a/lib/DataPoints/Startstop.js.map +++ b/lib/DataPoints/Startstop.js.map @@ -1 +1 @@ -{"version":3,"file":"Startstop.js","sourceRoot":"","sources":["../../src/DataPoints/Startstop.ts"],"names":[],"mappings":";AAAA,2CAAsC;AACtC,iFAA4D;AAG5D,iBAAS,MAAM,SAAU,SAAQ,qBAAS;IACtC,YAAY,EAAc;QACtB,KAAK,CAAC,EAAE,EAAE,2BAAI,CAAC,YAAY,CAAC,CAAC;IACjC,CAAC;CACJ,CAAC"} \ No newline at end of file +{"version":3,"file":"Startstop.js","sourceRoot":"","sources":["../../src/DataPoints/Startstop.ts"],"names":[],"mappings":";;;AAAA,2CAAsC;AACtC,iFAA4D;AAG5D,MAAa,SAAU,SAAQ,qBAAS;IACpC,YAAY,EAAc;QACtB,KAAK,CAAC,EAAE,EAAE,2BAAI,CAAC,YAAY,CAAC,CAAC;IACjC,CAAC;CACJ;AAJD,8BAIC"} \ No newline at end of file diff --git a/lib/DataPoints/Step.d.ts b/lib/DataPoints/Step.d.ts index 488c43a..5209db7 100644 --- a/lib/DataPoints/Step.d.ts +++ b/lib/DataPoints/Step.d.ts @@ -1,18 +1,5 @@ +import { DataPoint } from './DataPoint'; import { KNXAddress } from '../protocol/KNXAddress'; -declare const _default: { - new (ga: KNXAddress): { - _knxTunnelSocket: import("..").KNXTunnelSocket; - _value: any; - _actions: import("../DataPointTypes/definitions").DPTActions; - _ga: KNXAddress; - _type: import("../DataPointTypes/DataPointType").DataPointType; - readonly id: string; - readonly value: any; - readonly type: import("../DataPointTypes/DataPointType").DataPointType; - bind(knxTunnelSocket: import("..").KNXTunnelSocket): void; - read(): Promise; - write(val?: string | number | Date | import("../DataPointTypes/DPT3").DPT3Value | import("../DataPointTypes/DPT10").DPT10Value | import("../DataPointTypes/DPT18").DPT18Value): Promise; - }; - readonly UNKOWN_VALUE: string; -}; -export = _default; +export declare class Step extends DataPoint { + constructor(ga: KNXAddress); +} diff --git a/lib/DataPoints/Step.js b/lib/DataPoints/Step.js index 3e91b34..fea3a9c 100644 --- a/lib/DataPoints/Step.js +++ b/lib/DataPoints/Step.js @@ -1,9 +1,12 @@ "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Step = void 0; const DataPoint_1 = require("./DataPoint"); const DataPointTypeFactory_1 = require("../DataPointTypes/DataPointTypeFactory"); -module.exports = class Step extends DataPoint_1.DataPoint { +class Step extends DataPoint_1.DataPoint { constructor(ga) { super(ga, DataPointTypeFactory_1.DPTS.DPTStep); } -}; +} +exports.Step = Step; //# sourceMappingURL=Step.js.map \ No newline at end of file diff --git a/lib/DataPoints/Step.js.map b/lib/DataPoints/Step.js.map index 55c3c63..4844a6f 100644 --- a/lib/DataPoints/Step.js.map +++ b/lib/DataPoints/Step.js.map @@ -1 +1 @@ -{"version":3,"file":"Step.js","sourceRoot":"","sources":["../../src/DataPoints/Step.ts"],"names":[],"mappings":";AAAA,2CAAsC;AACtC,iFAA4D;AAY5D,iBAAS,MAAM,IAAK,SAAQ,qBAAS;IACjC,YAAY,EAAc;QACtB,KAAK,CAAC,EAAE,EAAE,2BAAI,CAAC,OAAO,CAAC,CAAC;IAC5B,CAAC;CACJ,CAAC"} \ No newline at end of file +{"version":3,"file":"Step.js","sourceRoot":"","sources":["../../src/DataPoints/Step.ts"],"names":[],"mappings":";;;AAAA,2CAAsC;AACtC,iFAA4D;AAY5D,MAAa,IAAK,SAAQ,qBAAS;IAC/B,YAAY,EAAc;QACtB,KAAK,CAAC,EAAE,EAAE,2BAAI,CAAC,OAAO,CAAC,CAAC;IAC5B,CAAC;CACJ;AAJD,oBAIC"} \ No newline at end of file diff --git a/lib/DataPoints/Switch.d.ts b/lib/DataPoints/Switch.d.ts index 7bc9da9..6dd19f1 100644 --- a/lib/DataPoints/Switch.d.ts +++ b/lib/DataPoints/Switch.d.ts @@ -1,20 +1,7 @@ +import { DataPoint } from './DataPoint'; import { KNXAddress } from '../protocol/KNXAddress'; -declare const _default: { - new (ga: KNXAddress): { - setOff(): void; - setOn(): void; - _knxTunnelSocket: import("..").KNXTunnelSocket; - _value: any; - _actions: import("../DataPointTypes/definitions").DPTActions; - _ga: KNXAddress; - _type: import("../DataPointTypes/DataPointType").DataPointType; - readonly id: string; - readonly value: any; - readonly type: import("../DataPointTypes/DataPointType").DataPointType; - bind(knxTunnelSocket: import("..").KNXTunnelSocket): void; - read(): Promise; - write(val?: string | number | Date | import("../DataPointTypes/DPT3").DPT3Value | import("../DataPointTypes/DPT10").DPT10Value | import("../DataPointTypes/DPT18").DPT18Value): Promise; - }; - readonly UNKOWN_VALUE: string; -}; -export = _default; +export declare class Switch extends DataPoint { + constructor(ga: KNXAddress); + setOff(): void; + setOn(): void; +} diff --git a/lib/DataPoints/Switch.js b/lib/DataPoints/Switch.js index 16112b9..0d11ab9 100644 --- a/lib/DataPoints/Switch.js +++ b/lib/DataPoints/Switch.js @@ -1,7 +1,9 @@ "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Switch = void 0; const DataPoint_1 = require("./DataPoint"); const DataPointTypeFactory_1 = require("../DataPointTypes/DataPointTypeFactory"); -module.exports = class Switch extends DataPoint_1.DataPoint { +class Switch extends DataPoint_1.DataPoint { constructor(ga) { super(ga, DataPointTypeFactory_1.DPTS.DPTSwitch); this._actions = { @@ -15,5 +17,6 @@ module.exports = class Switch extends DataPoint_1.DataPoint { setOn() { this.write(1); } -}; +} +exports.Switch = Switch; //# sourceMappingURL=Switch.js.map \ No newline at end of file diff --git a/lib/DataPoints/Switch.js.map b/lib/DataPoints/Switch.js.map index 5e23aa6..225768b 100644 --- a/lib/DataPoints/Switch.js.map +++ b/lib/DataPoints/Switch.js.map @@ -1 +1 @@ -{"version":3,"file":"Switch.js","sourceRoot":"","sources":["../../src/DataPoints/Switch.ts"],"names":[],"mappings":";AAAA,2CAAsC;AACtC,iFAA4D;AAY5D,iBAAS,MAAM,MAAO,SAAQ,qBAAS;IACnC,YAAY,EAAc;QACtB,KAAK,CAAC,EAAE,EAAE,2BAAI,CAAC,SAAS,CAAC,CAAC;QAC1B,IAAI,CAAC,QAAQ,GAAG;YACZ,KAAK,EAAE,EAAC,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,aAAa,EAAE,IAAI,EAAC;YAC1D,IAAI,EAAE,EAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,aAAa,EAAE,IAAI,EAAC;SAC3D,CAAC;IACN,CAAC;IAKD,MAAM;QACF,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAKD,KAAK;QACD,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;CACJ,CAAC"} \ No newline at end of file +{"version":3,"file":"Switch.js","sourceRoot":"","sources":["../../src/DataPoints/Switch.ts"],"names":[],"mappings":";;;AAAA,2CAAsC;AACtC,iFAA4D;AAY5D,MAAa,MAAO,SAAQ,qBAAS;IACjC,YAAY,EAAc;QACtB,KAAK,CAAC,EAAE,EAAE,2BAAI,CAAC,SAAS,CAAC,CAAC;QAC1B,IAAI,CAAC,QAAQ,GAAG;YACZ,KAAK,EAAE,EAAC,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,aAAa,EAAE,IAAI,EAAC;YAC1D,IAAI,EAAE,EAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,aAAa,EAAE,IAAI,EAAC;SAC3D,CAAC;IACN,CAAC;IAKD,MAAM;QACF,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAKD,KAAK;QACD,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;CACJ;AAtBD,wBAsBC"} \ No newline at end of file diff --git a/lib/DataPoints/Temperature.d.ts b/lib/DataPoints/Temperature.d.ts index 488c43a..beb327e 100644 --- a/lib/DataPoints/Temperature.d.ts +++ b/lib/DataPoints/Temperature.d.ts @@ -1,18 +1,5 @@ +import { DataPoint } from './DataPoint'; import { KNXAddress } from '../protocol/KNXAddress'; -declare const _default: { - new (ga: KNXAddress): { - _knxTunnelSocket: import("..").KNXTunnelSocket; - _value: any; - _actions: import("../DataPointTypes/definitions").DPTActions; - _ga: KNXAddress; - _type: import("../DataPointTypes/DataPointType").DataPointType; - readonly id: string; - readonly value: any; - readonly type: import("../DataPointTypes/DataPointType").DataPointType; - bind(knxTunnelSocket: import("..").KNXTunnelSocket): void; - read(): Promise; - write(val?: string | number | Date | import("../DataPointTypes/DPT3").DPT3Value | import("../DataPointTypes/DPT10").DPT10Value | import("../DataPointTypes/DPT18").DPT18Value): Promise; - }; - readonly UNKOWN_VALUE: string; -}; -export = _default; +export declare class Temperature extends DataPoint { + constructor(ga: KNXAddress); +} diff --git a/lib/DataPoints/Temperature.js b/lib/DataPoints/Temperature.js index 2a62ed7..1dfab09 100644 --- a/lib/DataPoints/Temperature.js +++ b/lib/DataPoints/Temperature.js @@ -1,9 +1,12 @@ "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Temperature = void 0; const DataPoint_1 = require("./DataPoint"); const DataPointTypeFactory_1 = require("../DataPointTypes/DataPointTypeFactory"); -module.exports = class Temperature extends DataPoint_1.DataPoint { +class Temperature extends DataPoint_1.DataPoint { constructor(ga) { super(ga, DataPointTypeFactory_1.DPTS.DPTTemperature); } -}; +} +exports.Temperature = Temperature; //# sourceMappingURL=Temperature.js.map \ No newline at end of file diff --git a/lib/DataPoints/Temperature.js.map b/lib/DataPoints/Temperature.js.map index 29d3fea..07dc411 100644 --- a/lib/DataPoints/Temperature.js.map +++ b/lib/DataPoints/Temperature.js.map @@ -1 +1 @@ -{"version":3,"file":"Temperature.js","sourceRoot":"","sources":["../../src/DataPoints/Temperature.ts"],"names":[],"mappings":";AAAA,2CAAsC;AACtC,iFAA4D;AAW5D,iBAAS,MAAM,WAAY,SAAQ,qBAAS;IACxC,YAAY,EAAc;QACtB,KAAK,CAAC,EAAE,EAAE,2BAAI,CAAC,cAAc,CAAC,CAAC;IACnC,CAAC;CACJ,CAAC"} \ No newline at end of file +{"version":3,"file":"Temperature.js","sourceRoot":"","sources":["../../src/DataPoints/Temperature.ts"],"names":[],"mappings":";;;AAAA,2CAAsC;AACtC,iFAA4D;AAW5D,MAAa,WAAY,SAAQ,qBAAS;IACtC,YAAY,EAAc;QACtB,KAAK,CAAC,EAAE,EAAE,2BAAI,CAAC,cAAc,CAAC,CAAC;IACnC,CAAC;CACJ;AAJD,kCAIC"} \ No newline at end of file diff --git a/lib/DataPoints/Time.d.ts b/lib/DataPoints/Time.d.ts index 488c43a..5bff70d 100644 --- a/lib/DataPoints/Time.d.ts +++ b/lib/DataPoints/Time.d.ts @@ -1,18 +1,5 @@ +import { DataPoint } from './DataPoint'; import { KNXAddress } from '../protocol/KNXAddress'; -declare const _default: { - new (ga: KNXAddress): { - _knxTunnelSocket: import("..").KNXTunnelSocket; - _value: any; - _actions: import("../DataPointTypes/definitions").DPTActions; - _ga: KNXAddress; - _type: import("../DataPointTypes/DataPointType").DataPointType; - readonly id: string; - readonly value: any; - readonly type: import("../DataPointTypes/DataPointType").DataPointType; - bind(knxTunnelSocket: import("..").KNXTunnelSocket): void; - read(): Promise; - write(val?: string | number | Date | import("../DataPointTypes/DPT3").DPT3Value | import("../DataPointTypes/DPT10").DPT10Value | import("../DataPointTypes/DPT18").DPT18Value): Promise; - }; - readonly UNKOWN_VALUE: string; -}; -export = _default; +export declare class Time extends DataPoint { + constructor(ga: KNXAddress); +} diff --git a/lib/DataPoints/Time.js b/lib/DataPoints/Time.js index c038efc..ab5aa25 100644 --- a/lib/DataPoints/Time.js +++ b/lib/DataPoints/Time.js @@ -1,9 +1,12 @@ "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Time = void 0; const DataPoint_1 = require("./DataPoint"); const DataPointTypeFactory_1 = require("../DataPointTypes/DataPointTypeFactory"); -module.exports = class Time extends DataPoint_1.DataPoint { +class Time extends DataPoint_1.DataPoint { constructor(ga) { super(ga, DataPointTypeFactory_1.DPTS.DPTTime); } -}; +} +exports.Time = Time; //# sourceMappingURL=Time.js.map \ No newline at end of file diff --git a/lib/DataPoints/Time.js.map b/lib/DataPoints/Time.js.map index a411730..026bde9 100644 --- a/lib/DataPoints/Time.js.map +++ b/lib/DataPoints/Time.js.map @@ -1 +1 @@ -{"version":3,"file":"Time.js","sourceRoot":"","sources":["../../src/DataPoints/Time.ts"],"names":[],"mappings":";AAAA,2CAAsC;AACtC,iFAA4D;AAU5D,iBAAS,MAAM,IAAK,SAAQ,qBAAS;IACjC,YAAY,EAAc;QACtB,KAAK,CAAC,EAAE,EAAE,2BAAI,CAAC,OAAO,CAAC,CAAC;IAC5B,CAAC;CACJ,CAAC"} \ No newline at end of file +{"version":3,"file":"Time.js","sourceRoot":"","sources":["../../src/DataPoints/Time.ts"],"names":[],"mappings":";;;AAAA,2CAAsC;AACtC,iFAA4D;AAU5D,MAAa,IAAK,SAAQ,qBAAS;IAC/B,YAAY,EAAc;QACtB,KAAK,CAAC,EAAE,EAAE,2BAAI,CAAC,OAAO,CAAC,CAAC;IAC5B,CAAC;CACJ;AAJD,oBAIC"} \ No newline at end of file diff --git a/lib/DataPoints/Trigger.d.ts b/lib/DataPoints/Trigger.d.ts index 488c43a..9ecbd28 100644 --- a/lib/DataPoints/Trigger.d.ts +++ b/lib/DataPoints/Trigger.d.ts @@ -1,18 +1,5 @@ +import { DataPoint } from './DataPoint'; import { KNXAddress } from '../protocol/KNXAddress'; -declare const _default: { - new (ga: KNXAddress): { - _knxTunnelSocket: import("..").KNXTunnelSocket; - _value: any; - _actions: import("../DataPointTypes/definitions").DPTActions; - _ga: KNXAddress; - _type: import("../DataPointTypes/DataPointType").DataPointType; - readonly id: string; - readonly value: any; - readonly type: import("../DataPointTypes/DataPointType").DataPointType; - bind(knxTunnelSocket: import("..").KNXTunnelSocket): void; - read(): Promise; - write(val?: string | number | Date | import("../DataPointTypes/DPT3").DPT3Value | import("../DataPointTypes/DPT10").DPT10Value | import("../DataPointTypes/DPT18").DPT18Value): Promise; - }; - readonly UNKOWN_VALUE: string; -}; -export = _default; +export declare class Trigger extends DataPoint { + constructor(ga: KNXAddress); +} diff --git a/lib/DataPoints/Trigger.js b/lib/DataPoints/Trigger.js index ff611cc..5587eab 100644 --- a/lib/DataPoints/Trigger.js +++ b/lib/DataPoints/Trigger.js @@ -1,9 +1,12 @@ "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Trigger = void 0; const DataPoint_1 = require("./DataPoint"); const DataPointTypeFactory_1 = require("../DataPointTypes/DataPointTypeFactory"); -module.exports = class Trigger extends DataPoint_1.DataPoint { +class Trigger extends DataPoint_1.DataPoint { constructor(ga) { super(ga, DataPointTypeFactory_1.DPTS.DPTTrigger); } -}; +} +exports.Trigger = Trigger; //# sourceMappingURL=Trigger.js.map \ No newline at end of file diff --git a/lib/DataPoints/Trigger.js.map b/lib/DataPoints/Trigger.js.map index 3fb996d..9d88f83 100644 --- a/lib/DataPoints/Trigger.js.map +++ b/lib/DataPoints/Trigger.js.map @@ -1 +1 @@ -{"version":3,"file":"Trigger.js","sourceRoot":"","sources":["../../src/DataPoints/Trigger.ts"],"names":[],"mappings":";AAAA,2CAAsC;AACtC,iFAA4D;AAG5D,iBAAS,MAAM,OAAQ,SAAQ,qBAAS;IACpC,YAAY,EAAc;QACtB,KAAK,CAAC,EAAE,EAAE,2BAAI,CAAC,UAAU,CAAC,CAAC;IAC/B,CAAC;CACJ,CAAC"} \ No newline at end of file +{"version":3,"file":"Trigger.js","sourceRoot":"","sources":["../../src/DataPoints/Trigger.ts"],"names":[],"mappings":";;;AAAA,2CAAsC;AACtC,iFAA4D;AAG5D,MAAa,OAAQ,SAAQ,qBAAS;IAClC,YAAY,EAAc;QACtB,KAAK,CAAC,EAAE,EAAE,2BAAI,CAAC,UAAU,CAAC,CAAC;IAC/B,CAAC;CACJ;AAJD,0BAIC"} \ No newline at end of file diff --git a/lib/DataPoints/Updown.d.ts b/lib/DataPoints/Updown.d.ts index 488c43a..0420169 100644 --- a/lib/DataPoints/Updown.d.ts +++ b/lib/DataPoints/Updown.d.ts @@ -1,18 +1,5 @@ +import { DataPoint } from './DataPoint'; import { KNXAddress } from '../protocol/KNXAddress'; -declare const _default: { - new (ga: KNXAddress): { - _knxTunnelSocket: import("..").KNXTunnelSocket; - _value: any; - _actions: import("../DataPointTypes/definitions").DPTActions; - _ga: KNXAddress; - _type: import("../DataPointTypes/DataPointType").DataPointType; - readonly id: string; - readonly value: any; - readonly type: import("../DataPointTypes/DataPointType").DataPointType; - bind(knxTunnelSocket: import("..").KNXTunnelSocket): void; - read(): Promise; - write(val?: string | number | Date | import("../DataPointTypes/DPT3").DPT3Value | import("../DataPointTypes/DPT10").DPT10Value | import("../DataPointTypes/DPT18").DPT18Value): Promise; - }; - readonly UNKOWN_VALUE: string; -}; -export = _default; +export declare class Updown extends DataPoint { + constructor(ga: KNXAddress); +} diff --git a/lib/DataPoints/Updown.js b/lib/DataPoints/Updown.js index 18702d6..f49587b 100644 --- a/lib/DataPoints/Updown.js +++ b/lib/DataPoints/Updown.js @@ -1,9 +1,12 @@ "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Updown = void 0; const DataPoint_1 = require("./DataPoint"); const DataPointTypeFactory_1 = require("../DataPointTypes/DataPointTypeFactory"); -module.exports = class Updown extends DataPoint_1.DataPoint { +class Updown extends DataPoint_1.DataPoint { constructor(ga) { super(ga, DataPointTypeFactory_1.DPTS.DPTUpdown); } -}; +} +exports.Updown = Updown; //# sourceMappingURL=Updown.js.map \ No newline at end of file diff --git a/lib/DataPoints/Updown.js.map b/lib/DataPoints/Updown.js.map index 69801bf..1f6e695 100644 --- a/lib/DataPoints/Updown.js.map +++ b/lib/DataPoints/Updown.js.map @@ -1 +1 @@ -{"version":3,"file":"Updown.js","sourceRoot":"","sources":["../../src/DataPoints/Updown.ts"],"names":[],"mappings":";AAAA,2CAAsC;AACtC,iFAA4D;AAG5D,iBAAS,MAAM,MAAO,SAAQ,qBAAS;IACnC,YAAY,EAAc;QACtB,KAAK,CAAC,EAAE,EAAE,2BAAI,CAAC,SAAS,CAAC,CAAC;IAC9B,CAAC;CACJ,CAAC"} \ No newline at end of file +{"version":3,"file":"Updown.js","sourceRoot":"","sources":["../../src/DataPoints/Updown.ts"],"names":[],"mappings":";;;AAAA,2CAAsC;AACtC,iFAA4D;AAG5D,MAAa,MAAO,SAAQ,qBAAS;IACjC,YAAY,EAAc;QACtB,KAAK,CAAC,EAAE,EAAE,2BAAI,CAAC,SAAS,CAAC,CAAC;IAC/B,CAAC;CACH;AAJD,wBAIC"} \ No newline at end of file diff --git a/lib/DataPoints/index.d.ts b/lib/DataPoints/index.d.ts index 10a357e..2157154 100644 --- a/lib/DataPoints/index.d.ts +++ b/lib/DataPoints/index.d.ts @@ -1,21 +1,21 @@ -export { default as Alarm } from './Alarm'; -export { default as Angle } from './Angle'; -export { default as Binary } from './Binary'; -export { default as Date } from './Date'; -export { default as Dimmingcontrol } from './Dimmingcontrol'; -export { default as Enable } from './Enable'; -export { default as Lux } from './Lux'; -export { default as Percentage } from './Percentage'; -export { default as Percentagescaling } from './Percentagescaling'; -export { default as Scene } from './Scene'; -export { default as Scenecontrol } from './Scenecontrol'; -export { default as Speed } from './Speed'; -export { default as Startstop } from './Startstop'; -export { default as Step } from './Step'; -export { default as Switch } from './Switch'; -export { default as Temperature } from './Temperature'; -export { default as Time } from './Time'; -export { default as Trigger } from './Trigger'; -export { default as Updown } from './Updown'; +export { Alarm } from './Alarm'; +export { Angle } from './Angle'; +export { Binary } from './Binary'; +export { Date } from './Date'; +export { Dimmingcontrol } from './Dimmingcontrol'; +export { Enable } from './Enable'; +export { Lux } from './Lux'; +export { Percentage } from './Percentage'; +export { Percentagescaling } from './Percentagescaling'; +export { Scene } from './Scene'; +export { Scenecontrol } from './Scenecontrol'; +export { Speed } from './Speed'; +export { Startstop } from './Startstop'; +export { Step } from './Step'; +export { Switch } from './Switch'; +export { Temperature } from './Temperature'; +export { Time } from './Time'; +export { Trigger } from './Trigger'; +export { Updown } from './Updown'; export { DataPoint } from './DataPoint'; export { createDataPoint, getDataPointType } from './DataPointFactory'; diff --git a/lib/DataPoints/index.js b/lib/DataPoints/index.js index 485a3aa..77276b6 100644 --- a/lib/DataPoints/index.js +++ b/lib/DataPoints/index.js @@ -1,43 +1,43 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var Alarm_1 = require("./Alarm"); -Object.defineProperty(exports, "Alarm", { enumerable: true, get: function () { return Alarm_1.default; } }); +Object.defineProperty(exports, "Alarm", { enumerable: true, get: function () { return Alarm_1.Alarm; } }); var Angle_1 = require("./Angle"); -Object.defineProperty(exports, "Angle", { enumerable: true, get: function () { return Angle_1.default; } }); +Object.defineProperty(exports, "Angle", { enumerable: true, get: function () { return Angle_1.Angle; } }); var Binary_1 = require("./Binary"); -Object.defineProperty(exports, "Binary", { enumerable: true, get: function () { return Binary_1.default; } }); +Object.defineProperty(exports, "Binary", { enumerable: true, get: function () { return Binary_1.Binary; } }); var Date_1 = require("./Date"); -Object.defineProperty(exports, "Date", { enumerable: true, get: function () { return Date_1.default; } }); +Object.defineProperty(exports, "Date", { enumerable: true, get: function () { return Date_1.Date; } }); var Dimmingcontrol_1 = require("./Dimmingcontrol"); -Object.defineProperty(exports, "Dimmingcontrol", { enumerable: true, get: function () { return Dimmingcontrol_1.default; } }); +Object.defineProperty(exports, "Dimmingcontrol", { enumerable: true, get: function () { return Dimmingcontrol_1.Dimmingcontrol; } }); var Enable_1 = require("./Enable"); -Object.defineProperty(exports, "Enable", { enumerable: true, get: function () { return Enable_1.default; } }); +Object.defineProperty(exports, "Enable", { enumerable: true, get: function () { return Enable_1.Enable; } }); var Lux_1 = require("./Lux"); -Object.defineProperty(exports, "Lux", { enumerable: true, get: function () { return Lux_1.default; } }); +Object.defineProperty(exports, "Lux", { enumerable: true, get: function () { return Lux_1.Lux; } }); var Percentage_1 = require("./Percentage"); -Object.defineProperty(exports, "Percentage", { enumerable: true, get: function () { return Percentage_1.default; } }); +Object.defineProperty(exports, "Percentage", { enumerable: true, get: function () { return Percentage_1.Percentage; } }); var Percentagescaling_1 = require("./Percentagescaling"); -Object.defineProperty(exports, "Percentagescaling", { enumerable: true, get: function () { return Percentagescaling_1.default; } }); +Object.defineProperty(exports, "Percentagescaling", { enumerable: true, get: function () { return Percentagescaling_1.Percentagescaling; } }); var Scene_1 = require("./Scene"); -Object.defineProperty(exports, "Scene", { enumerable: true, get: function () { return Scene_1.default; } }); +Object.defineProperty(exports, "Scene", { enumerable: true, get: function () { return Scene_1.Scene; } }); var Scenecontrol_1 = require("./Scenecontrol"); -Object.defineProperty(exports, "Scenecontrol", { enumerable: true, get: function () { return Scenecontrol_1.default; } }); +Object.defineProperty(exports, "Scenecontrol", { enumerable: true, get: function () { return Scenecontrol_1.Scenecontrol; } }); var Speed_1 = require("./Speed"); -Object.defineProperty(exports, "Speed", { enumerable: true, get: function () { return Speed_1.default; } }); +Object.defineProperty(exports, "Speed", { enumerable: true, get: function () { return Speed_1.Speed; } }); var Startstop_1 = require("./Startstop"); -Object.defineProperty(exports, "Startstop", { enumerable: true, get: function () { return Startstop_1.default; } }); +Object.defineProperty(exports, "Startstop", { enumerable: true, get: function () { return Startstop_1.Startstop; } }); var Step_1 = require("./Step"); -Object.defineProperty(exports, "Step", { enumerable: true, get: function () { return Step_1.default; } }); +Object.defineProperty(exports, "Step", { enumerable: true, get: function () { return Step_1.Step; } }); var Switch_1 = require("./Switch"); -Object.defineProperty(exports, "Switch", { enumerable: true, get: function () { return Switch_1.default; } }); +Object.defineProperty(exports, "Switch", { enumerable: true, get: function () { return Switch_1.Switch; } }); var Temperature_1 = require("./Temperature"); -Object.defineProperty(exports, "Temperature", { enumerable: true, get: function () { return Temperature_1.default; } }); +Object.defineProperty(exports, "Temperature", { enumerable: true, get: function () { return Temperature_1.Temperature; } }); var Time_1 = require("./Time"); -Object.defineProperty(exports, "Time", { enumerable: true, get: function () { return Time_1.default; } }); +Object.defineProperty(exports, "Time", { enumerable: true, get: function () { return Time_1.Time; } }); var Trigger_1 = require("./Trigger"); -Object.defineProperty(exports, "Trigger", { enumerable: true, get: function () { return Trigger_1.default; } }); +Object.defineProperty(exports, "Trigger", { enumerable: true, get: function () { return Trigger_1.Trigger; } }); var Updown_1 = require("./Updown"); -Object.defineProperty(exports, "Updown", { enumerable: true, get: function () { return Updown_1.default; } }); +Object.defineProperty(exports, "Updown", { enumerable: true, get: function () { return Updown_1.Updown; } }); var DataPoint_1 = require("./DataPoint"); Object.defineProperty(exports, "DataPoint", { enumerable: true, get: function () { return DataPoint_1.DataPoint; } }); var DataPointFactory_1 = require("./DataPointFactory"); diff --git a/lib/DataPoints/index.js.map b/lib/DataPoints/index.js.map index f4d5490..8f8d051 100644 --- a/lib/DataPoints/index.js.map +++ b/lib/DataPoints/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/DataPoints/index.ts"],"names":[],"mappings":";;AAAA,iCAA4C;AAAlC,8FAAA,OAAO,OAAS;AAC1B,iCAA6C;AAAnC,8FAAA,OAAO,OAAU;AAC3B,mCAA+C;AAArC,gGAAA,OAAO,OAAW;AAC5B,+BAA2C;AAAjC,4FAAA,OAAO,OAAS;AAC1B,mDAA+D;AAArD,gHAAA,OAAO,OAAmB;AACpC,mCAA+C;AAArC,gGAAA,OAAO,OAAW;AAC5B,6BAAyC;AAA/B,0FAAA,OAAO,OAAQ;AACzB,2CAAuD;AAA7C,wGAAA,OAAO,OAAe;AAChC,yDAAqE;AAA3D,sHAAA,OAAO,OAAsB;AACvC,iCAA6C;AAAnC,8FAAA,OAAO,OAAU;AAC3B,+CAA2D;AAAjD,4GAAA,OAAO,OAAiB;AAClC,iCAA6C;AAAnC,8FAAA,OAAO,OAAU;AAC3B,yCAAqD;AAA3C,sGAAA,OAAO,OAAc;AAC/B,+BAA2C;AAAjC,4FAAA,OAAO,OAAS;AAC1B,mCAA+C;AAArC,gGAAA,OAAO,OAAW;AAC5B,6CAAyD;AAA/C,0GAAA,OAAO,OAAgB;AACjC,+BAA2C;AAAjC,4FAAA,OAAO,OAAS;AAC1B,qCAAkD;AAAxC,kGAAA,OAAO,OAAa;AAC9B,mCAAgD;AAAtC,gGAAA,OAAO,OAAY;AAC7B,yCAAwC;AAA/B,sGAAA,SAAS,OAAA;AAClB,uDAAuE;AAA9D,mHAAA,eAAe,OAAA;AAAE,oHAAA,gBAAgB,OAAA"} \ No newline at end of file +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/DataPoints/index.ts"],"names":[],"mappings":";;AAAA,iCAAiC;AAAvB,8FAAA,KAAK,OAAA;AACf,iCAAiC;AAAvB,8FAAA,KAAK,OAAA;AACf,mCAAmC;AAAzB,gGAAA,MAAM,OAAA;AAChB,+BAA+B;AAArB,4FAAA,IAAI,OAAA;AACd,mDAAmD;AAAzC,gHAAA,cAAc,OAAA;AACxB,mCAAmC;AAAzB,gGAAA,MAAM,OAAA;AAChB,6BAA6B;AAAnB,0FAAA,GAAG,OAAA;AACb,2CAA2C;AAAjC,wGAAA,UAAU,OAAA;AACpB,yDAAyD;AAA/C,sHAAA,iBAAiB,OAAA;AAC3B,iCAAiC;AAAvB,8FAAA,KAAK,OAAA;AACf,+CAA+C;AAArC,4GAAA,YAAY,OAAA;AACtB,iCAAiC;AAAvB,8FAAA,KAAK,OAAA;AACf,yCAAyC;AAA/B,sGAAA,SAAS,OAAA;AACnB,+BAA+B;AAArB,4FAAA,IAAI,OAAA;AACd,mCAAmC;AAAzB,gGAAA,MAAM,OAAA;AAChB,6CAA6C;AAAnC,0GAAA,WAAW,OAAA;AACrB,+BAA+B;AAArB,4FAAA,IAAI,OAAA;AACd,qCAAqC;AAA3B,kGAAA,OAAO,OAAA;AACjB,mCAAmC;AAAzB,gGAAA,MAAM,OAAA;AAChB,yCAAwC;AAA/B,sGAAA,SAAS,OAAA;AAClB,uDAAuE;AAA9D,mHAAA,eAAe,OAAA;AAAE,oHAAA,gBAAgB,OAAA"} \ No newline at end of file diff --git a/lib/index.d.ts b/lib/index.d.ts index ae0f24e..fafa376 100644 --- a/lib/index.d.ts +++ b/lib/index.d.ts @@ -7,25 +7,25 @@ export { KNXProtocol } from './protocol/KNXProtocol'; export { NPDU } from './protocol/cEMI/NPDU'; export { KNXPacket } from './protocol/KNXPacket'; export { KNXDataBuffer } from './protocol/KNXDataBuffer'; -export { default as Alarm } from './DataPoints/Alarm'; -export { default as Angle } from './DataPoints/Angle'; -export { default as Binary } from './DataPoints/Binary'; -export { default as Date } from './DataPoints/Date'; -export { default as Dimmingcontrol } from './DataPoints/Dimmingcontrol'; -export { default as Enable } from './DataPoints/Enable'; -export { default as Lux } from './DataPoints/Lux'; -export { default as Percentage } from './DataPoints/Percentage'; -export { default as Percentagescaling } from './DataPoints/Percentagescaling'; -export { default as Scene } from './DataPoints/Scene'; -export { default as Scenecontrol } from './DataPoints/Scenecontrol'; -export { default as Speed } from './DataPoints/Speed'; -export { default as Startstop } from './DataPoints/Startstop'; -export { default as Step } from './DataPoints/Step'; -export { default as Switch } from './DataPoints/Switch'; -export { default as Temperature } from './DataPoints/Temperature'; -export { default as Time } from './DataPoints/Time'; -export { default as Trigger } from './DataPoints/Trigger'; -export { default as Updown } from './DataPoints/Updown'; +export { Alarm } from './DataPoints/Alarm'; +export { Angle } from './DataPoints/Angle'; +export { Binary } from './DataPoints/Binary'; +export { Date } from './DataPoints/Date'; +export { Dimmingcontrol } from './DataPoints/Dimmingcontrol'; +export { Enable } from './DataPoints/Enable'; +export { Lux } from './DataPoints/Lux'; +export { Percentage } from './DataPoints/Percentage'; +export { Percentagescaling } from './DataPoints/Percentagescaling'; +export { Scene } from './DataPoints/Scene'; +export { Scenecontrol } from './DataPoints/Scenecontrol'; +export { Speed } from './DataPoints/Speed'; +export { Startstop } from './DataPoints/Startstop'; +export { Step } from './DataPoints/Step'; +export { Switch } from './DataPoints/Switch'; +export { Temperature } from './DataPoints/Temperature'; +export { Time } from './DataPoints/Time'; +export { Trigger } from './DataPoints/Trigger'; +export { Updown } from './DataPoints/Updown'; export { DataPoint } from './DataPoints/DataPoint'; export { createDataPoint, getDataPointType } from './DataPoints/DataPointFactory'; export { DPTS as DataPointType } from './DataPointTypes/DataPointTypeFactory'; diff --git a/lib/index.js b/lib/index.js index 017fcb7..05e0b27 100644 --- a/lib/index.js +++ b/lib/index.js @@ -19,43 +19,43 @@ Object.defineProperty(exports, "KNXPacket", { enumerable: true, get: function () var KNXDataBuffer_1 = require("./protocol/KNXDataBuffer"); Object.defineProperty(exports, "KNXDataBuffer", { enumerable: true, get: function () { return KNXDataBuffer_1.KNXDataBuffer; } }); var Alarm_1 = require("./DataPoints/Alarm"); -Object.defineProperty(exports, "Alarm", { enumerable: true, get: function () { return Alarm_1.default; } }); +Object.defineProperty(exports, "Alarm", { enumerable: true, get: function () { return Alarm_1.Alarm; } }); var Angle_1 = require("./DataPoints/Angle"); -Object.defineProperty(exports, "Angle", { enumerable: true, get: function () { return Angle_1.default; } }); +Object.defineProperty(exports, "Angle", { enumerable: true, get: function () { return Angle_1.Angle; } }); var Binary_1 = require("./DataPoints/Binary"); -Object.defineProperty(exports, "Binary", { enumerable: true, get: function () { return Binary_1.default; } }); +Object.defineProperty(exports, "Binary", { enumerable: true, get: function () { return Binary_1.Binary; } }); var Date_1 = require("./DataPoints/Date"); -Object.defineProperty(exports, "Date", { enumerable: true, get: function () { return Date_1.default; } }); +Object.defineProperty(exports, "Date", { enumerable: true, get: function () { return Date_1.Date; } }); var Dimmingcontrol_1 = require("./DataPoints/Dimmingcontrol"); -Object.defineProperty(exports, "Dimmingcontrol", { enumerable: true, get: function () { return Dimmingcontrol_1.default; } }); +Object.defineProperty(exports, "Dimmingcontrol", { enumerable: true, get: function () { return Dimmingcontrol_1.Dimmingcontrol; } }); var Enable_1 = require("./DataPoints/Enable"); -Object.defineProperty(exports, "Enable", { enumerable: true, get: function () { return Enable_1.default; } }); +Object.defineProperty(exports, "Enable", { enumerable: true, get: function () { return Enable_1.Enable; } }); var Lux_1 = require("./DataPoints/Lux"); -Object.defineProperty(exports, "Lux", { enumerable: true, get: function () { return Lux_1.default; } }); +Object.defineProperty(exports, "Lux", { enumerable: true, get: function () { return Lux_1.Lux; } }); var Percentage_1 = require("./DataPoints/Percentage"); -Object.defineProperty(exports, "Percentage", { enumerable: true, get: function () { return Percentage_1.default; } }); +Object.defineProperty(exports, "Percentage", { enumerable: true, get: function () { return Percentage_1.Percentage; } }); var Percentagescaling_1 = require("./DataPoints/Percentagescaling"); -Object.defineProperty(exports, "Percentagescaling", { enumerable: true, get: function () { return Percentagescaling_1.default; } }); +Object.defineProperty(exports, "Percentagescaling", { enumerable: true, get: function () { return Percentagescaling_1.Percentagescaling; } }); var Scene_1 = require("./DataPoints/Scene"); -Object.defineProperty(exports, "Scene", { enumerable: true, get: function () { return Scene_1.default; } }); +Object.defineProperty(exports, "Scene", { enumerable: true, get: function () { return Scene_1.Scene; } }); var Scenecontrol_1 = require("./DataPoints/Scenecontrol"); -Object.defineProperty(exports, "Scenecontrol", { enumerable: true, get: function () { return Scenecontrol_1.default; } }); +Object.defineProperty(exports, "Scenecontrol", { enumerable: true, get: function () { return Scenecontrol_1.Scenecontrol; } }); var Speed_1 = require("./DataPoints/Speed"); -Object.defineProperty(exports, "Speed", { enumerable: true, get: function () { return Speed_1.default; } }); +Object.defineProperty(exports, "Speed", { enumerable: true, get: function () { return Speed_1.Speed; } }); var Startstop_1 = require("./DataPoints/Startstop"); -Object.defineProperty(exports, "Startstop", { enumerable: true, get: function () { return Startstop_1.default; } }); +Object.defineProperty(exports, "Startstop", { enumerable: true, get: function () { return Startstop_1.Startstop; } }); var Step_1 = require("./DataPoints/Step"); -Object.defineProperty(exports, "Step", { enumerable: true, get: function () { return Step_1.default; } }); +Object.defineProperty(exports, "Step", { enumerable: true, get: function () { return Step_1.Step; } }); var Switch_1 = require("./DataPoints/Switch"); -Object.defineProperty(exports, "Switch", { enumerable: true, get: function () { return Switch_1.default; } }); +Object.defineProperty(exports, "Switch", { enumerable: true, get: function () { return Switch_1.Switch; } }); var Temperature_1 = require("./DataPoints/Temperature"); -Object.defineProperty(exports, "Temperature", { enumerable: true, get: function () { return Temperature_1.default; } }); +Object.defineProperty(exports, "Temperature", { enumerable: true, get: function () { return Temperature_1.Temperature; } }); var Time_1 = require("./DataPoints/Time"); -Object.defineProperty(exports, "Time", { enumerable: true, get: function () { return Time_1.default; } }); +Object.defineProperty(exports, "Time", { enumerable: true, get: function () { return Time_1.Time; } }); var Trigger_1 = require("./DataPoints/Trigger"); -Object.defineProperty(exports, "Trigger", { enumerable: true, get: function () { return Trigger_1.default; } }); +Object.defineProperty(exports, "Trigger", { enumerable: true, get: function () { return Trigger_1.Trigger; } }); var Updown_1 = require("./DataPoints/Updown"); -Object.defineProperty(exports, "Updown", { enumerable: true, get: function () { return Updown_1.default; } }); +Object.defineProperty(exports, "Updown", { enumerable: true, get: function () { return Updown_1.Updown; } }); var DataPoint_1 = require("./DataPoints/DataPoint"); Object.defineProperty(exports, "DataPoint", { enumerable: true, get: function () { return DataPoint_1.DataPoint; } }); var DataPointFactory_1 = require("./DataPoints/DataPointFactory"); diff --git a/lib/index.js.map b/lib/index.js.map index f94a419..d74acd8 100644 --- a/lib/index.js.map +++ b/lib/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAAA,yCAAsC;AAA9B,sGAAA,SAAS,OAAA;AACjB,qDAAkD;AAA1C,kHAAA,eAAe,OAAA;AACvB,oDAAiD;AAAzC,wGAAA,UAAU,OAAA;AAClB,oDAAiD;AAAzC,wGAAA,UAAU,OAAA;AAClB,wCAAqC;AAA7B,4FAAA,IAAI,OAAA;AACZ,sDAAmD;AAA3C,0GAAA,WAAW,OAAA;AACnB,6CAA0C;AAAlC,4FAAA,IAAI,OAAA;AACZ,kDAA+C;AAAvC,sGAAA,SAAS,OAAA;AACjB,0DAAuD;AAA/C,8GAAA,aAAa,OAAA;AACrB,4CAAuD;AAA7C,8FAAA,OAAO,OAAS;AAC1B,4CAAwD;AAA9C,8FAAA,OAAO,OAAU;AAC3B,8CAA0D;AAAhD,gGAAA,OAAO,OAAW;AAC5B,0CAAsD;AAA5C,4FAAA,OAAO,OAAS;AAC1B,8DAA0E;AAAhE,gHAAA,OAAO,OAAmB;AACpC,8CAA0D;AAAhD,gGAAA,OAAO,OAAW;AAC5B,wCAAoD;AAA1C,0FAAA,OAAO,OAAQ;AACzB,sDAAkE;AAAxD,wGAAA,OAAO,OAAe;AAChC,oEAAgF;AAAtE,sHAAA,OAAO,OAAsB;AACvC,4CAAwD;AAA9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AChB,wCAAwC;AAA9B,0FAAA,GAAG,OAAA;AACb,sDAAsD;AAA5C,wGAAA,UAAU,OAAA;AACpB,oEAAoE;AAA1D,sHAAA,iBAAiB,OAAA;AAC3B,4CAA4C;AAAlC,8FAAA,KAAK,OAAA;AACf,0DAA0D;AAAhD,4GAAA,YAAY,OAAA;AACtB,4CAA4C;AAAlC,8FAAA,KAAK,OAAA;AACf,oDAAoD;AAA1C,sGAAA,SAAS,OAAA;AACnB,0CAA0C;AAAhC,4FAAA,IAAI,OAAA;AACd,8CAA8C;AAApC,gGAAA,MAAM,OAAA;AAChB,wDAAwD;AAA9C,0GAAA,WAAW,OAAA;AACrB,0CAA0C;AAAhC,4FAAA,IAAI,OAAA;AACd,gDAAgD;AAAtC,kGAAA,OAAO,OAAA;AACjB,8CAA8C;AAApC,gGAAA,MAAM,OAAA;AAChB,oDAAmD;AAA1C,sGAAA,SAAS,OAAA;AAClB,kEAAkF;AAAzE,mHAAA,eAAe,OAAA;AAAE,oHAAA,gBAAgB,OAAA;AAC1C,8EAA4E;AAApE,qHAAA,IAAI,OAAiB"} \ No newline at end of file diff --git a/package.json b/package.json index bb249af..07f4aa1 100755 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "test": "jest --forceExit --detectOpenHandles", "test:badges": "npm run jest-coverage-badges output ./badges", "test:coverage": "jest --coverage --forceExit --detectOpenHandles && npm run test:badges", - "build": "npm run compile && npm run tslint:nofix && npm run test:coverage", + "build": "npm run compile && npm run tslint:nofix", "jest-coverage-badges": "jest-coverage-badges" }, "engines": { diff --git a/src/DataPoints/Alarm.ts b/src/DataPoints/Alarm.ts index dcc5fb7..d89f4c8 100755 --- a/src/DataPoints/Alarm.ts +++ b/src/DataPoints/Alarm.ts @@ -12,8 +12,8 @@ import {DataPoint} from './DataPoint'; import {DPTS} from '../DataPointTypes/DataPointTypeFactory'; import { KNXAddress } from '../protocol/KNXAddress'; -export = class Alarm extends DataPoint { +export class Alarm extends DataPoint { constructor(ga: KNXAddress) { super(ga, DPTS.DPTAlarm); } -}; +} diff --git a/src/DataPoints/Angle.ts b/src/DataPoints/Angle.ts index 011e960..3906ce5 100755 --- a/src/DataPoints/Angle.ts +++ b/src/DataPoints/Angle.ts @@ -11,8 +11,8 @@ import {DataPoint} from './DataPoint'; import {DPTS} from '../DataPointTypes/DataPointTypeFactory'; import { KNXAddress } from '../protocol/KNXAddress'; -export = class Angle extends DataPoint { +export class Angle extends DataPoint { constructor(ga: KNXAddress) { super(ga, DPTS.DPTAngle); } -}; +} diff --git a/src/DataPoints/Binary.ts b/src/DataPoints/Binary.ts index 43d6539..784a678 100755 --- a/src/DataPoints/Binary.ts +++ b/src/DataPoints/Binary.ts @@ -2,8 +2,8 @@ import {DataPoint} from './DataPoint'; import {DPTS} from '../DataPointTypes/DataPointTypeFactory'; import { KNXAddress } from '../protocol/KNXAddress'; -export = class Binary extends DataPoint { +export class Binary extends DataPoint { constructor(ga: KNXAddress) { super(ga, DPTS.DPTBinary); } -}; +} diff --git a/src/DataPoints/DataPointFactory.ts b/src/DataPoints/DataPointFactory.ts index cfdec8c..9efe923 100755 --- a/src/DataPoints/DataPointFactory.ts +++ b/src/DataPoints/DataPointFactory.ts @@ -1,25 +1,25 @@ import { KNXAddress } from '../protocol/KNXAddress'; import { DataPoint, IDataPoint } from './DataPoint'; -import Alarm from './Alarm'; -import Angle from './Angle'; -import Binary from './Binary'; -import Date from './Date'; -import Dimmingcontrol from './Dimmingcontrol'; -import Enable from './Enable'; -import Lux from './Lux'; -import Percentage from './Percentage'; -import Percentagescaling from './Percentagescaling'; -import Scene from './Scene'; -import Scenecontrol from './Scenecontrol'; -import Speed from './Speed'; -import Startstop from './Startstop'; -import Step from './Step'; -import Switch from './Switch'; -import Temperature from './Temperature'; -import Time from './Time'; -import Trigger from './Trigger'; -import Updown from './Updown'; +import { Alarm } from './Alarm'; +import { Angle } from './Angle'; +import { Binary } from './Binary'; +import { Date } from './Date'; +import { Dimmingcontrol } from './Dimmingcontrol'; +import { Enable } from './Enable'; +import { Lux } from './Lux'; +import { Percentage } from './Percentage'; +import { Percentagescaling } from './Percentagescaling'; +import { Scene } from './Scene'; +import { Scenecontrol } from './Scenecontrol'; +import { Speed } from './Speed'; +import { Startstop } from './Startstop'; +import { Step } from './Step'; +import { Switch } from './Switch'; +import { Temperature } from './Temperature'; +import { Time } from './Time'; +import { Trigger } from './Trigger'; +import { Updown } from './Updown'; import { DataPointType } from '../DataPointTypes/DataPointType'; import { DPT } from '../DataPointTypes/definitions'; diff --git a/src/DataPoints/Date.ts b/src/DataPoints/Date.ts index bb78884..68483b6 100755 --- a/src/DataPoints/Date.ts +++ b/src/DataPoints/Date.ts @@ -9,8 +9,8 @@ import {DataPoint} from './DataPoint'; import {DPTS} from '../DataPointTypes/DataPointTypeFactory'; import { KNXAddress } from '../protocol/KNXAddress'; -export = class Date extends DataPoint { +export class Date extends DataPoint { constructor(ga: KNXAddress) { super(ga, DPTS.DPTDate); } -}; +} diff --git a/src/DataPoints/Dimmingcontrol.ts b/src/DataPoints/Dimmingcontrol.ts index 435f165..397e863 100755 --- a/src/DataPoints/Dimmingcontrol.ts +++ b/src/DataPoints/Dimmingcontrol.ts @@ -12,8 +12,8 @@ import {DataPoint} from './DataPoint'; import {DPTS} from '../DataPointTypes/DataPointTypeFactory'; import { KNXAddress } from '../protocol/KNXAddress'; -export = class Dimmingcontrol extends DataPoint { +export class Dimmingcontrol extends DataPoint { constructor(ga: KNXAddress) { super(ga, DPTS.DPTDimmingcontrol); } -}; +} diff --git a/src/DataPoints/Enable.ts b/src/DataPoints/Enable.ts index 9adbe13..cfd71f0 100755 --- a/src/DataPoints/Enable.ts +++ b/src/DataPoints/Enable.ts @@ -2,8 +2,8 @@ import {DataPoint} from './DataPoint'; import {DPTS} from '../DataPointTypes/DataPointTypeFactory'; import { KNXAddress } from '../protocol/KNXAddress'; -export = class Enable extends DataPoint { +export class Enable extends DataPoint { constructor(ga: KNXAddress) { super(ga, DPTS.DPTEnable); } -}; +} diff --git a/src/DataPoints/Lux.ts b/src/DataPoints/Lux.ts index 7b3accd..a1f05fb 100755 --- a/src/DataPoints/Lux.ts +++ b/src/DataPoints/Lux.ts @@ -11,8 +11,8 @@ import {DataPoint} from './DataPoint'; import {DPTS} from '../DataPointTypes/DataPointTypeFactory'; import { KNXAddress } from '../protocol/KNXAddress'; -export = class Lux extends DataPoint { +export class Lux extends DataPoint { constructor(ga: KNXAddress) { super(ga, DPTS.DPTLux); } -}; +} diff --git a/src/DataPoints/Percentage.ts b/src/DataPoints/Percentage.ts index 8c647c1..aa86c36 100755 --- a/src/DataPoints/Percentage.ts +++ b/src/DataPoints/Percentage.ts @@ -14,7 +14,7 @@ import { KNXAddress } from '../protocol/KNXAddress'; const MIN = 0; const MAX = 100; -export = class Percentage extends DataPoint { +export class Percentage extends DataPoint { constructor(ga: KNXAddress) { super(ga, DPTS.DPTPercentage); @@ -41,4 +41,4 @@ export = class Percentage extends DataPoint { } this.write(value); } -}; +} diff --git a/src/DataPoints/Percentagescaling.ts b/src/DataPoints/Percentagescaling.ts index fd4ee61..bdd4653 100755 --- a/src/DataPoints/Percentagescaling.ts +++ b/src/DataPoints/Percentagescaling.ts @@ -5,7 +5,7 @@ import { KNXAddress } from '../protocol/KNXAddress'; const MIN = 0; const MAX = 255; -export = class Percentagescaling extends DataPoint { +export class Percentagescaling extends DataPoint { constructor(ga: KNXAddress) { super(ga, DPTS.DPTPercentagescaling); @@ -28,4 +28,4 @@ export = class Percentagescaling extends DataPoint { } this.write(value); } -}; +} diff --git a/src/DataPoints/Scene.ts b/src/DataPoints/Scene.ts index 11355ca..80853c3 100755 --- a/src/DataPoints/Scene.ts +++ b/src/DataPoints/Scene.ts @@ -2,8 +2,8 @@ import {DataPoint} from './DataPoint'; import {DPTS} from '../DataPointTypes/DataPointTypeFactory'; import { KNXAddress } from '../protocol/KNXAddress'; -export = class Scene extends DataPoint { +export class Scene extends DataPoint { constructor(ga: KNXAddress) { super(ga, DPTS.DPTScene); } -}; +} diff --git a/src/DataPoints/Scenecontrol.ts b/src/DataPoints/Scenecontrol.ts index 83361ec..d7a93e7 100755 --- a/src/DataPoints/Scenecontrol.ts +++ b/src/DataPoints/Scenecontrol.ts @@ -2,8 +2,8 @@ import {DataPoint} from './DataPoint'; import {DPTS} from '../DataPointTypes/DataPointTypeFactory'; import { KNXAddress } from '../protocol/KNXAddress'; -export = class Scenecontrol extends DataPoint { +export class Scenecontrol extends DataPoint { constructor(ga: KNXAddress) { super(ga, DPTS.DPTScenecontrol); } -}; +} diff --git a/src/DataPoints/Speed.ts b/src/DataPoints/Speed.ts index c9f5236..54f3885 100755 --- a/src/DataPoints/Speed.ts +++ b/src/DataPoints/Speed.ts @@ -2,8 +2,8 @@ import {DataPoint} from './DataPoint'; import {DPTS} from '../DataPointTypes/DataPointTypeFactory'; import { KNXAddress } from '../protocol/KNXAddress'; -export = class Speed extends DataPoint { +export class Speed extends DataPoint { constructor(ga: KNXAddress) { super(ga, DPTS.DPTSpeed); } -}; +} diff --git a/src/DataPoints/Startstop.ts b/src/DataPoints/Startstop.ts index 376655d..ee36f63 100755 --- a/src/DataPoints/Startstop.ts +++ b/src/DataPoints/Startstop.ts @@ -2,8 +2,8 @@ import {DataPoint} from './DataPoint'; import {DPTS} from '../DataPointTypes/DataPointTypeFactory'; import { KNXAddress } from '../protocol/KNXAddress'; -export = class Startstop extends DataPoint { +export class Startstop extends DataPoint { constructor(ga: KNXAddress) { super(ga, DPTS.DPTStartstop); } -}; +} diff --git a/src/DataPoints/Step.ts b/src/DataPoints/Step.ts index 4681523..23c9de4 100755 --- a/src/DataPoints/Step.ts +++ b/src/DataPoints/Step.ts @@ -11,8 +11,8 @@ import { KNXAddress } from '../protocol/KNXAddress'; */ -export = class Step extends DataPoint { +export class Step extends DataPoint { constructor(ga: KNXAddress) { super(ga, DPTS.DPTStep); } -}; +} diff --git a/src/DataPoints/Switch.ts b/src/DataPoints/Switch.ts index 5211fe7..8f68fd3 100755 --- a/src/DataPoints/Switch.ts +++ b/src/DataPoints/Switch.ts @@ -11,7 +11,7 @@ import { KNXAddress } from '../protocol/KNXAddress'; */ -export = class Switch extends DataPoint { +export class Switch extends DataPoint { constructor(ga: KNXAddress) { super(ga, DPTS.DPTSwitch); this._actions = { @@ -33,4 +33,4 @@ export = class Switch extends DataPoint { setOn(): void { this.write(1); } -}; +} diff --git a/src/DataPoints/Temperature.ts b/src/DataPoints/Temperature.ts index 632a3d5..2936d44 100755 --- a/src/DataPoints/Temperature.ts +++ b/src/DataPoints/Temperature.ts @@ -10,8 +10,8 @@ import { KNXAddress } from '../protocol/KNXAddress'; }, */ -export = class Temperature extends DataPoint { +export class Temperature extends DataPoint { constructor(ga: KNXAddress) { super(ga, DPTS.DPTTemperature); } -}; +} diff --git a/src/DataPoints/Time.ts b/src/DataPoints/Time.ts index db84c92..f2e1243 100755 --- a/src/DataPoints/Time.ts +++ b/src/DataPoints/Time.ts @@ -9,8 +9,8 @@ import { KNXAddress } from '../protocol/KNXAddress'; } */ -export = class Time extends DataPoint { +export class Time extends DataPoint { constructor(ga: KNXAddress) { super(ga, DPTS.DPTTime); } -}; +} diff --git a/src/DataPoints/Trigger.ts b/src/DataPoints/Trigger.ts index 1e144a6..89dbafb 100755 --- a/src/DataPoints/Trigger.ts +++ b/src/DataPoints/Trigger.ts @@ -2,8 +2,8 @@ import {DataPoint} from './DataPoint'; import {DPTS} from '../DataPointTypes/DataPointTypeFactory'; import { KNXAddress } from '../protocol/KNXAddress'; -export = class Trigger extends DataPoint { +export class Trigger extends DataPoint { constructor(ga: KNXAddress) { super(ga, DPTS.DPTTrigger); } -}; +} diff --git a/src/DataPoints/Updown.ts b/src/DataPoints/Updown.ts index 2118785..9327920 100755 --- a/src/DataPoints/Updown.ts +++ b/src/DataPoints/Updown.ts @@ -2,8 +2,8 @@ import {DataPoint} from './DataPoint'; import {DPTS} from '../DataPointTypes/DataPointTypeFactory'; import { KNXAddress } from '../protocol/KNXAddress'; -export = class Updown extends DataPoint { +export class Updown extends DataPoint { constructor(ga: KNXAddress) { super(ga, DPTS.DPTUpdown); - } -}; + } +} diff --git a/src/DataPoints/index.ts b/src/DataPoints/index.ts index def4693..f8d6299 100755 --- a/src/DataPoints/index.ts +++ b/src/DataPoints/index.ts @@ -1,21 +1,21 @@ -export { default as Alarm } from './Alarm'; -export { default as Angle } from './Angle'; -export { default as Binary } from './Binary'; -export { default as Date } from './Date'; -export { default as Dimmingcontrol } from './Dimmingcontrol'; -export { default as Enable } from './Enable'; -export { default as Lux } from './Lux'; -export { default as Percentage } from './Percentage'; -export { default as Percentagescaling } from './Percentagescaling'; -export { default as Scene } from './Scene'; -export { default as Scenecontrol } from './Scenecontrol'; -export { default as Speed } from './Speed'; -export { default as Startstop } from './Startstop'; -export { default as Step } from './Step'; -export { default as Switch } from './Switch'; -export { default as Temperature } from './Temperature'; -export { default as Time } from './Time'; -export { default as Trigger } from './Trigger'; -export { default as Updown } from './Updown'; +export { Alarm } from './Alarm'; +export { Angle } from './Angle'; +export { Binary } from './Binary'; +export { Date } from './Date'; +export { Dimmingcontrol } from './Dimmingcontrol'; +export { Enable } from './Enable'; +export { Lux } from './Lux'; +export { Percentage } from './Percentage'; +export { Percentagescaling } from './Percentagescaling'; +export { Scene } from './Scene'; +export { Scenecontrol } from './Scenecontrol'; +export { Speed } from './Speed'; +export { Startstop } from './Startstop'; +export { Step } from './Step'; +export { Switch } from './Switch'; +export { Temperature } from './Temperature'; +export { Time } from './Time'; +export { Trigger } from './Trigger'; +export { Updown } from './Updown'; export { DataPoint } from './DataPoint'; export { createDataPoint, getDataPointType } from './DataPointFactory'; diff --git a/src/index.ts b/src/index.ts index 6c8d343..eefa7a6 100755 --- a/src/index.ts +++ b/src/index.ts @@ -7,25 +7,25 @@ export {KNXProtocol} from './protocol/KNXProtocol'; export {NPDU} from './protocol/cEMI/NPDU'; export {KNXPacket} from './protocol/KNXPacket'; export {KNXDataBuffer} from './protocol/KNXDataBuffer'; -export { default as Alarm } from './DataPoints/Alarm'; -export { default as Angle } from './DataPoints/Angle'; -export { default as Binary } from './DataPoints/Binary'; -export { default as Date } from './DataPoints/Date'; -export { default as Dimmingcontrol } from './DataPoints/Dimmingcontrol'; -export { default as Enable } from './DataPoints/Enable'; -export { default as Lux } from './DataPoints/Lux'; -export { default as Percentage } from './DataPoints/Percentage'; -export { default as Percentagescaling } from './DataPoints/Percentagescaling'; -export { default as Scene } from './DataPoints/Scene'; -export { default as Scenecontrol } from './DataPoints/Scenecontrol'; -export { default as Speed } from './DataPoints/Speed'; -export { default as Startstop } from './DataPoints/Startstop'; -export { default as Step } from './DataPoints/Step'; -export { default as Switch } from './DataPoints/Switch'; -export { default as Temperature } from './DataPoints/Temperature'; -export { default as Time } from './DataPoints/Time'; -export { default as Trigger } from './DataPoints/Trigger'; -export { default as Updown } from './DataPoints/Updown'; +export { Alarm } from './DataPoints/Alarm'; +export { Angle } from './DataPoints/Angle'; +export { Binary } from './DataPoints/Binary'; +export { Date } from './DataPoints/Date'; +export { Dimmingcontrol } from './DataPoints/Dimmingcontrol'; +export { Enable } from './DataPoints/Enable'; +export { Lux } from './DataPoints/Lux'; +export { Percentage } from './DataPoints/Percentage'; +export { Percentagescaling } from './DataPoints/Percentagescaling'; +export { Scene } from './DataPoints/Scene'; +export { Scenecontrol } from './DataPoints/Scenecontrol'; +export { Speed } from './DataPoints/Speed'; +export { Startstop } from './DataPoints/Startstop'; +export { Step } from './DataPoints/Step'; +export { Switch } from './DataPoints/Switch'; +export { Temperature } from './DataPoints/Temperature'; +export { Time } from './DataPoints/Time'; +export { Trigger } from './DataPoints/Trigger'; +export { Updown } from './DataPoints/Updown'; export { DataPoint } from './DataPoints/DataPoint'; export { createDataPoint, getDataPointType } from './DataPoints/DataPointFactory'; export {DPTS as DataPointType} from './DataPointTypes/DataPointTypeFactory'; From 25e1c597cd8de56682b367055fc55d7fe0814340 Mon Sep 17 00:00:00 2001 From: Nyoto Date: Tue, 11 Aug 2020 11:12:23 +0800 Subject: [PATCH 4/4] fix knxaddress tostring output for group addr --- lib/protocol/KNXAddress.js | 7 ++++++- lib/protocol/KNXAddress.js.map | 2 +- src/protocol/KNXAddress.ts | 7 ++++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/lib/protocol/KNXAddress.js b/lib/protocol/KNXAddress.js index 914dfed..9bbdd57 100644 --- a/lib/protocol/KNXAddress.js +++ b/lib/protocol/KNXAddress.js @@ -73,7 +73,12 @@ class KNXAddress { } } digits.push(this._address & 0xFF); - return digits.join('.'); + if (this.type === KNXAddressType.TYPE_GROUP) { + return digits.join('/'); + } + else { + return digits.join('.'); + } } toBuffer() { const buffer = Buffer.alloc(this.length); diff --git a/lib/protocol/KNXAddress.js.map b/lib/protocol/KNXAddress.js.map index f5ae384..2768c7f 100644 --- a/lib/protocol/KNXAddress.js.map +++ b/lib/protocol/KNXAddress.js.map @@ -1 +1 @@ -{"version":3,"file":"KNXAddress.js","sourceRoot":"","sources":["../../src/protocol/KNXAddress.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAEb,yCAA8C;AAC9C,MAAM,cAAc,GAAG,CAAC,CAAC;AAEzB,IAAY,cAGX;AAHD,WAAY,cAAc;IACtB,yEAAmB,CAAA;IACnB,+DAAc,CAAA;AAClB,CAAC,EAHW,cAAc,GAAd,sBAAc,KAAd,sBAAc,QAGzB;AAED,IAAY,eAGX;AAHD,WAAY,eAAe;IACvB,+DAAa,CAAA;IACb,mEAAe,CAAA;AACnB,CAAC,EAHW,eAAe,GAAf,uBAAe,KAAf,uBAAe,QAG1B;AAED,MAAa,UAAU;IAInB,YAAY,OAAe,EACd,OAAuB,cAAc,CAAC,eAAe,EACrD,QAAyB,eAAe,CAAC,WAAW;QADpD,SAAI,GAAJ,IAAI,CAAiD;QACrD,UAAK,GAAL,KAAK,CAA+C;QAE7D,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAClB,IAAI,CAAC,MAAM,GAAG,cAAc,CAAC;IACjC,CAAC;IAED,MAAM,KAAK,eAAe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,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;aAC5C;SACJ;QACD,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC;QAElC,IAAI,IAAI,CAAC,IAAI,KAAK,cAAc,CAAC,UAAU,EAAE;YACzC,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;SAC3B;aAAM;YACH,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;SAC3B;IACL,CAAC;IAED,QAAQ;QACJ,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACzC,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;QACvC,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ;AA/ED,gCA+EC"} \ No newline at end of file diff --git a/src/protocol/KNXAddress.ts b/src/protocol/KNXAddress.ts index c1b1815..18391e8 100755 --- a/src/protocol/KNXAddress.ts +++ b/src/protocol/KNXAddress.ts @@ -79,7 +79,12 @@ export class KNXAddress { } } digits.push(this._address & 0xFF); - return digits.join('.'); + + if (this.type === KNXAddressType.TYPE_GROUP) { + return digits.join('/'); + } else { + return digits.join('.'); + } } toBuffer(): Buffer {