@willieee802/zigbee-herdsman 0.15.0 → 0.15.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapter/adapter.d.ts +61 -61
- package/dist/adapter/adapter.d.ts.map +1 -1
- package/dist/adapter/adapter.js +146 -100
- package/dist/adapter/adapter.js.map +1 -1
- package/dist/adapter/deconz/adapter/deconzAdapter.d.ts +68 -68
- package/dist/adapter/deconz/adapter/deconzAdapter.d.ts.map +1 -1
- package/dist/adapter/deconz/adapter/deconzAdapter.js +1060 -1063
- package/dist/adapter/deconz/adapter/deconzAdapter.js.map +1 -1
- package/dist/adapter/deconz/adapter/index.d.ts +2 -2
- package/dist/adapter/deconz/adapter/index.js +10 -10
- package/dist/adapter/deconz/driver/constants.d.ts +104 -104
- package/dist/adapter/deconz/driver/constants.js +55 -55
- package/dist/adapter/deconz/driver/driver.d.ts +81 -81
- package/dist/adapter/deconz/driver/driver.js +732 -732
- package/dist/adapter/deconz/driver/frame.d.ts +6 -6
- package/dist/adapter/deconz/driver/frame.js +13 -13
- package/dist/adapter/deconz/driver/frameParser.d.ts +2 -2
- package/dist/adapter/deconz/driver/frameParser.js +443 -443
- package/dist/adapter/deconz/driver/parser.d.ts +12 -12
- package/dist/adapter/deconz/driver/parser.js +61 -61
- package/dist/adapter/deconz/driver/writer.d.ts +8 -8
- package/dist/adapter/deconz/driver/writer.js +44 -44
- package/dist/adapter/events.d.ts +47 -47
- package/dist/adapter/events.js +14 -14
- package/dist/adapter/ezsp/adapter/backup.d.ts +9 -9
- package/dist/adapter/ezsp/adapter/backup.js +53 -53
- package/dist/adapter/ezsp/adapter/ezspAdapter.d.ts +59 -59
- package/dist/adapter/ezsp/adapter/ezspAdapter.js +585 -585
- package/dist/adapter/ezsp/adapter/index.d.ts +2 -2
- package/dist/adapter/ezsp/adapter/index.js +10 -10
- package/dist/adapter/ezsp/driver/commands.d.ts +36 -34
- package/dist/adapter/ezsp/driver/commands.d.ts.map +1 -1
- package/dist/adapter/ezsp/driver/commands.js +2359 -2357
- package/dist/adapter/ezsp/driver/commands.js.map +1 -1
- package/dist/adapter/ezsp/driver/consts.d.ts +10 -10
- package/dist/adapter/ezsp/driver/consts.js +13 -13
- package/dist/adapter/ezsp/driver/driver.d.ts +103 -103
- package/dist/adapter/ezsp/driver/driver.js +639 -639
- package/dist/adapter/ezsp/driver/driver.js.map +1 -1
- package/dist/adapter/ezsp/driver/ezsp.d.ts +96 -96
- package/dist/adapter/ezsp/driver/ezsp.d.ts.map +1 -1
- package/dist/adapter/ezsp/driver/ezsp.js +586 -577
- package/dist/adapter/ezsp/driver/ezsp.js.map +1 -1
- package/dist/adapter/ezsp/driver/index.d.ts +3 -3
- package/dist/adapter/ezsp/driver/index.js +8 -8
- package/dist/adapter/ezsp/driver/multicast.d.ts +12 -12
- package/dist/adapter/ezsp/driver/multicast.js +74 -74
- package/dist/adapter/ezsp/driver/parser.d.ts +12 -12
- package/dist/adapter/ezsp/driver/parser.js +111 -111
- package/dist/adapter/ezsp/driver/types/basic.d.ts +62 -62
- package/dist/adapter/ezsp/driver/types/basic.js +208 -208
- package/dist/adapter/ezsp/driver/types/basic.js.map +1 -1
- package/dist/adapter/ezsp/driver/types/index.d.ts +9 -9
- package/dist/adapter/ezsp/driver/types/index.js +133 -133
- package/dist/adapter/ezsp/driver/types/named.d.ts +697 -697
- package/dist/adapter/ezsp/driver/types/named.js +1726 -1726
- package/dist/adapter/ezsp/driver/types/named.js.map +1 -1
- package/dist/adapter/ezsp/driver/types/struct.d.ts +251 -251
- package/dist/adapter/ezsp/driver/types/struct.js +708 -708
- package/dist/adapter/ezsp/driver/types/struct.js.map +1 -1
- package/dist/adapter/ezsp/driver/uart.d.ts +44 -44
- package/dist/adapter/ezsp/driver/uart.d.ts.map +1 -1
- package/dist/adapter/ezsp/driver/uart.js +368 -366
- package/dist/adapter/ezsp/driver/uart.js.map +1 -1
- package/dist/adapter/ezsp/driver/utils/crc16ccitt.d.ts +2 -2
- package/dist/adapter/ezsp/driver/utils/crc16ccitt.js +55 -55
- package/dist/adapter/ezsp/driver/utils/index.d.ts +18 -18
- package/dist/adapter/ezsp/driver/utils/index.js +67 -67
- package/dist/adapter/ezsp/driver/writer.d.ts +13 -13
- package/dist/adapter/ezsp/driver/writer.js +88 -88
- package/dist/adapter/index.d.ts +4 -4
- package/dist/adapter/index.js +35 -35
- package/dist/adapter/serialPort.d.ts +8 -8
- package/dist/adapter/serialPort.js +22 -22
- package/dist/adapter/serialPort.js.map +1 -1
- package/dist/adapter/serialPortUtils.d.ts +12 -12
- package/dist/adapter/serialPortUtils.js +18 -18
- package/dist/adapter/socketPortUtils.d.ts +10 -10
- package/dist/adapter/socketPortUtils.js +16 -16
- package/dist/adapter/tstype.d.ts +85 -85
- package/dist/adapter/tstype.js +2 -2
- package/dist/adapter/z-stack/adapter/adapter-backup.d.ts +62 -62
- package/dist/adapter/z-stack/adapter/adapter-backup.js +441 -441
- package/dist/adapter/z-stack/adapter/adapter-nv-memory.d.ts +150 -150
- package/dist/adapter/z-stack/adapter/adapter-nv-memory.js +258 -258
- package/dist/adapter/z-stack/adapter/endpoints.d.ts +11 -11
- package/dist/adapter/z-stack/adapter/endpoints.js +73 -73
- package/dist/adapter/z-stack/adapter/index.d.ts +2 -2
- package/dist/adapter/z-stack/adapter/index.js +8 -8
- package/dist/adapter/z-stack/adapter/manager.d.ts +86 -86
- package/dist/adapter/z-stack/adapter/manager.js +476 -476
- package/dist/adapter/z-stack/adapter/tstype.d.ts +6 -6
- package/dist/adapter/z-stack/adapter/tstype.js +10 -10
- package/dist/adapter/z-stack/adapter/zStackAdapter.d.ts +81 -81
- package/dist/adapter/z-stack/adapter/zStackAdapter.js +868 -868
- package/dist/adapter/z-stack/constants/af.d.ts +23 -23
- package/dist/adapter/z-stack/constants/af.js +27 -27
- package/dist/adapter/z-stack/constants/common.d.ts +278 -278
- package/dist/adapter/z-stack/constants/common.js +289 -289
- package/dist/adapter/z-stack/constants/dbg.d.ts +22 -22
- package/dist/adapter/z-stack/constants/dbg.js +24 -24
- package/dist/adapter/z-stack/constants/index.d.ts +10 -10
- package/dist/adapter/z-stack/constants/index.js +47 -47
- package/dist/adapter/z-stack/constants/mac.d.ts +127 -127
- package/dist/adapter/z-stack/constants/mac.js +129 -129
- package/dist/adapter/z-stack/constants/sapi.d.ts +24 -24
- package/dist/adapter/z-stack/constants/sapi.js +26 -26
- package/dist/adapter/z-stack/constants/sys.d.ts +71 -71
- package/dist/adapter/z-stack/constants/sys.js +73 -73
- package/dist/adapter/z-stack/constants/util.d.ts +81 -81
- package/dist/adapter/z-stack/constants/util.js +83 -83
- package/dist/adapter/z-stack/constants/utils.d.ts +4 -4
- package/dist/adapter/z-stack/constants/utils.js +14 -14
- package/dist/adapter/z-stack/constants/zdo.d.ts +102 -102
- package/dist/adapter/z-stack/constants/zdo.js +104 -104
- package/dist/adapter/z-stack/models/index.d.ts +1 -1
- package/dist/adapter/z-stack/models/index.js +17 -17
- package/dist/adapter/z-stack/models/startup-options.d.ts +12 -12
- package/dist/adapter/z-stack/models/startup-options.js +2 -2
- package/dist/adapter/z-stack/structs/entries/address-manager-entry.d.ts +23 -23
- package/dist/adapter/z-stack/structs/entries/address-manager-entry.js +45 -45
- package/dist/adapter/z-stack/structs/entries/address-manager-table.d.ts +10 -10
- package/dist/adapter/z-stack/structs/entries/address-manager-table.js +22 -22
- package/dist/adapter/z-stack/structs/entries/aps-link-key-data-entry.d.ts +10 -10
- package/dist/adapter/z-stack/structs/entries/aps-link-key-data-entry.js +21 -21
- package/dist/adapter/z-stack/structs/entries/aps-link-key-data-table.d.ts +10 -10
- package/dist/adapter/z-stack/structs/entries/aps-link-key-data-table.js +23 -23
- package/dist/adapter/z-stack/structs/entries/aps-tc-link-key-entry.d.ts +10 -10
- package/dist/adapter/z-stack/structs/entries/aps-tc-link-key-entry.js +24 -24
- package/dist/adapter/z-stack/structs/entries/aps-tc-link-key-table.d.ts +10 -10
- package/dist/adapter/z-stack/structs/entries/aps-tc-link-key-table.js +23 -23
- package/dist/adapter/z-stack/structs/entries/channel-list.d.ts +8 -8
- package/dist/adapter/z-stack/structs/entries/channel-list.js +15 -15
- package/dist/adapter/z-stack/structs/entries/has-configured.d.ts +8 -8
- package/dist/adapter/z-stack/structs/entries/has-configured.js +16 -16
- package/dist/adapter/z-stack/structs/entries/index.d.ts +16 -16
- package/dist/adapter/z-stack/structs/entries/index.js +32 -32
- package/dist/adapter/z-stack/structs/entries/nib.d.ts +10 -10
- package/dist/adapter/z-stack/structs/entries/nib.js +68 -68
- package/dist/adapter/z-stack/structs/entries/nwk-key-descriptor.d.ts +10 -10
- package/dist/adapter/z-stack/structs/entries/nwk-key-descriptor.js +18 -18
- package/dist/adapter/z-stack/structs/entries/nwk-key.d.ts +8 -8
- package/dist/adapter/z-stack/structs/entries/nwk-key.js +15 -15
- package/dist/adapter/z-stack/structs/entries/nwk-pan-id.d.ts +8 -8
- package/dist/adapter/z-stack/structs/entries/nwk-pan-id.js +15 -15
- package/dist/adapter/z-stack/structs/entries/nwk-sec-material-descriptor-entry.d.ts +13 -13
- package/dist/adapter/z-stack/structs/entries/nwk-sec-material-descriptor-entry.js +23 -23
- package/dist/adapter/z-stack/structs/entries/nwk-sec-material-descriptor-table.d.ts +10 -10
- package/dist/adapter/z-stack/structs/entries/nwk-sec-material-descriptor-table.js +22 -22
- package/dist/adapter/z-stack/structs/entries/security-manager-entry.d.ts +20 -20
- package/dist/adapter/z-stack/structs/entries/security-manager-entry.js +36 -36
- package/dist/adapter/z-stack/structs/entries/security-manager-table.d.ts +10 -10
- package/dist/adapter/z-stack/structs/entries/security-manager-table.js +24 -24
- package/dist/adapter/z-stack/structs/index.d.ts +4 -4
- package/dist/adapter/z-stack/structs/index.js +20 -20
- package/dist/adapter/z-stack/structs/serializable-memory-object.d.ts +13 -13
- package/dist/adapter/z-stack/structs/serializable-memory-object.js +2 -2
- package/dist/adapter/z-stack/structs/struct.d.ts +99 -99
- package/dist/adapter/z-stack/structs/struct.js +295 -295
- package/dist/adapter/z-stack/structs/table.d.ts +94 -94
- package/dist/adapter/z-stack/structs/table.js +161 -161
- package/dist/adapter/z-stack/unpi/constants.d.ts +28 -28
- package/dist/adapter/z-stack/unpi/constants.js +41 -41
- package/dist/adapter/z-stack/unpi/frame.d.ts +16 -16
- package/dist/adapter/z-stack/unpi/frame.js +48 -48
- package/dist/adapter/z-stack/unpi/index.d.ts +5 -5
- package/dist/adapter/z-stack/unpi/index.js +37 -37
- package/dist/adapter/z-stack/unpi/parser.d.ts +10 -10
- package/dist/adapter/z-stack/unpi/parser.js +74 -74
- package/dist/adapter/z-stack/unpi/writer.d.ts +10 -10
- package/dist/adapter/z-stack/unpi/writer.js +44 -44
- package/dist/adapter/z-stack/utils/channel-list.d.ts +20 -20
- package/dist/adapter/z-stack/utils/channel-list.js +40 -40
- package/dist/adapter/z-stack/utils/index.d.ts +2 -2
- package/dist/adapter/z-stack/utils/index.js +18 -18
- package/dist/adapter/z-stack/utils/network-options.d.ts +8 -8
- package/dist/adapter/z-stack/utils/network-options.js +22 -22
- package/dist/adapter/z-stack/znp/buffaloZnp.d.ts +11 -11
- package/dist/adapter/z-stack/znp/buffaloZnp.js +113 -113
- package/dist/adapter/z-stack/znp/definition.d.ts +5 -5
- package/dist/adapter/z-stack/znp/definition.js +3050 -3050
- package/dist/adapter/z-stack/znp/index.d.ts +3 -3
- package/dist/adapter/z-stack/znp/index.js +10 -10
- package/dist/adapter/z-stack/znp/parameterType.d.ts +22 -22
- package/dist/adapter/z-stack/znp/parameterType.js +25 -25
- package/dist/adapter/z-stack/znp/tstype.d.ts +21 -21
- package/dist/adapter/z-stack/znp/tstype.js +2 -2
- package/dist/adapter/z-stack/znp/znp.d.ts +43 -43
- package/dist/adapter/z-stack/znp/znp.js +325 -325
- package/dist/adapter/z-stack/znp/zpiObject.d.ts +19 -19
- package/dist/adapter/z-stack/znp/zpiObject.js +96 -96
- package/dist/adapter/zigate/adapter/index.d.ts +2 -2
- package/dist/adapter/zigate/adapter/index.js +10 -10
- package/dist/adapter/zigate/adapter/zigateAdapter.d.ts +69 -69
- package/dist/adapter/zigate/adapter/zigateAdapter.js +678 -678
- package/dist/adapter/zigate/debug.d.ts +7 -7
- package/dist/adapter/zigate/debug.js +22 -22
- package/dist/adapter/zigate/driver/buffaloZiGate.d.ts +18 -18
- package/dist/adapter/zigate/driver/buffaloZiGate.js +139 -139
- package/dist/adapter/zigate/driver/commandType.d.ts +41 -41
- package/dist/adapter/zigate/driver/commandType.js +385 -385
- package/dist/adapter/zigate/driver/constants.d.ts +276 -276
- package/dist/adapter/zigate/driver/constants.js +371 -371
- package/dist/adapter/zigate/driver/frame.d.ts +26 -26
- package/dist/adapter/zigate/driver/frame.js +172 -172
- package/dist/adapter/zigate/driver/frame.js.map +1 -1
- package/dist/adapter/zigate/driver/messageType.d.ts +11 -11
- package/dist/adapter/zigate/driver/messageType.js +278 -278
- package/dist/adapter/zigate/driver/parameterType.d.ts +20 -20
- package/dist/adapter/zigate/driver/parameterType.js +23 -23
- package/dist/adapter/zigate/driver/ziGateObject.d.ts +23 -23
- package/dist/adapter/zigate/driver/ziGateObject.js +106 -106
- package/dist/adapter/zigate/driver/zigate.d.ts +49 -49
- package/dist/adapter/zigate/driver/zigate.js +303 -303
- package/dist/buffalo/buffalo.d.ts +50 -48
- package/dist/buffalo/buffalo.d.ts.map +1 -1
- package/dist/buffalo/buffalo.js +322 -307
- package/dist/buffalo/buffalo.js.map +1 -1
- package/dist/buffalo/index.d.ts +3 -3
- package/dist/buffalo/index.js +33 -33
- package/dist/buffalo/tstype.d.ts +8 -8
- package/dist/buffalo/tstype.js +2 -2
- package/dist/controller/controller.d.ts +110 -110
- package/dist/controller/controller.js +607 -607
- package/dist/controller/database.d.ts +18 -18
- package/dist/controller/database.js +93 -93
- package/dist/controller/events.d.ts +55 -55
- package/dist/controller/events.d.ts.map +1 -1
- package/dist/controller/events.js +101 -99
- package/dist/controller/events.js.map +1 -1
- package/dist/controller/greenPower.d.ts +12 -12
- package/dist/controller/greenPower.js +220 -220
- package/dist/controller/helpers/index.d.ts +2 -2
- package/dist/controller/helpers/index.js +28 -28
- package/dist/controller/helpers/request.d.ts +23 -0
- package/dist/controller/helpers/request.d.ts.map +1 -0
- package/dist/controller/helpers/request.js +72 -0
- package/dist/controller/helpers/request.js.map +1 -0
- package/dist/controller/helpers/zclFrameConverter.d.ts +7 -7
- package/dist/controller/helpers/zclFrameConverter.js +31 -31
- package/dist/controller/helpers/zclTransactionSequenceNumber.d.ts +5 -5
- package/dist/controller/helpers/zclTransactionSequenceNumber.js +13 -13
- package/dist/controller/index.d.ts +5 -5
- package/dist/controller/index.js +8 -8
- package/dist/controller/logger-stub.d.ts +6 -6
- package/dist/controller/logger-stub.js +2 -2
- package/dist/controller/model/device.d.ts +132 -127
- package/dist/controller/model/device.d.ts.map +1 -1
- package/dist/controller/model/device.js +708 -681
- package/dist/controller/model/device.js.map +1 -1
- package/dist/controller/model/endpoint.d.ts +131 -128
- package/dist/controller/model/endpoint.d.ts.map +1 -1
- package/dist/controller/model/endpoint.js +817 -665
- package/dist/controller/model/endpoint.js.map +1 -1
- package/dist/controller/model/entity.d.ts +14 -14
- package/dist/controller/model/entity.js +26 -26
- package/dist/controller/model/group.d.ts +39 -39
- package/dist/controller/model/group.js +221 -221
- package/dist/controller/model/index.d.ts +5 -5
- package/dist/controller/model/index.js +14 -14
- package/dist/controller/touchlink.d.ts +19 -19
- package/dist/controller/touchlink.js +157 -157
- package/dist/controller/tstype.d.ts +21 -20
- package/dist/controller/tstype.d.ts.map +1 -1
- package/dist/controller/tstype.js +9 -9
- package/dist/controller/tstype.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +33 -33
- package/dist/models/backup-storage-legacy.d.ts +26 -26
- package/dist/models/backup-storage-legacy.js +2 -2
- package/dist/models/backup-storage-unified.d.ts +49 -49
- package/dist/models/backup-storage-unified.js +2 -2
- package/dist/models/backup.d.ts +37 -37
- package/dist/models/backup.js +2 -2
- package/dist/models/index.d.ts +4 -4
- package/dist/models/index.js +20 -20
- package/dist/models/network-options.d.ts +12 -12
- package/dist/models/network-options.js +2 -2
- package/dist/utils/assertString.d.ts +2 -2
- package/dist/utils/assertString.js +8 -8
- package/dist/utils/backup.d.ts +20 -20
- package/dist/utils/backup.js +187 -187
- package/dist/utils/equalsPartial.d.ts +2 -2
- package/dist/utils/equalsPartial.js +11 -11
- package/dist/utils/index.d.ts +9 -9
- package/dist/utils/index.js +45 -45
- package/dist/utils/isNumberArray.d.ts +2 -2
- package/dist/utils/isNumberArray.js +6 -6
- package/dist/utils/queue.d.ts +11 -11
- package/dist/utils/queue.js +50 -50
- package/dist/utils/realpathSync.d.ts +2 -2
- package/dist/utils/realpathSync.js +12 -12
- package/dist/utils/wait.d.ts +2 -2
- package/dist/utils/wait.js +8 -8
- package/dist/utils/waitress.d.ts +21 -21
- package/dist/utils/waitress.js +61 -61
- package/dist/zcl/buffaloZcl.d.ts +41 -41
- package/dist/zcl/buffaloZcl.js +591 -591
- package/dist/zcl/definition/buffaloZclDataType.d.ts +17 -17
- package/dist/zcl/definition/buffaloZclDataType.js +20 -20
- package/dist/zcl/definition/cluster.d.ts +29 -29
- package/dist/zcl/definition/cluster.d.ts.map +1 -1
- package/dist/zcl/definition/cluster.js +5335 -5215
- package/dist/zcl/definition/cluster.js.map +1 -1
- package/dist/zcl/definition/dataType.d.ts +59 -59
- package/dist/zcl/definition/dataType.d.ts.map +1 -1
- package/dist/zcl/definition/dataType.js +64 -64
- package/dist/zcl/definition/dataType.js.map +1 -1
- package/dist/zcl/definition/direction.d.ts +5 -5
- package/dist/zcl/definition/direction.js +8 -8
- package/dist/zcl/definition/endpointDeviceType.d.ts +4 -4
- package/dist/zcl/definition/endpointDeviceType.js +15 -15
- package/dist/zcl/definition/foundation.d.ts +11 -11
- package/dist/zcl/definition/foundation.js +167 -167
- package/dist/zcl/definition/frameControl.d.ts +10 -10
- package/dist/zcl/definition/frameControl.js +2 -2
- package/dist/zcl/definition/frameType.d.ts +5 -5
- package/dist/zcl/definition/frameType.js +8 -8
- package/dist/zcl/definition/index.d.ts +13 -13
- package/dist/zcl/definition/index.js +51 -51
- package/dist/zcl/definition/manufacturerCode.d.ts +1074 -1074
- package/dist/zcl/definition/manufacturerCode.js +1079 -1079
- package/dist/zcl/definition/powerSource.d.ts +4 -4
- package/dist/zcl/definition/powerSource.js +12 -12
- package/dist/zcl/definition/status.d.ts +38 -38
- package/dist/zcl/definition/status.js +41 -41
- package/dist/zcl/definition/tstype.d.ts +16 -16
- package/dist/zcl/definition/tstype.js +2 -2
- package/dist/zcl/index.d.ts +15 -15
- package/dist/zcl/index.js +55 -55
- package/dist/zcl/tstype.d.ts +56 -56
- package/dist/zcl/tstype.js +10 -10
- package/dist/zcl/utils.d.ts +6 -6
- package/dist/zcl/utils.js +165 -165
- package/dist/zcl/zclFrame.d.ts +45 -45
- package/dist/zcl/zclFrame.js +347 -347
- package/dist/zcl/zclStatusError.d.ts +5 -5
- package/dist/zcl/zclStatusError.js +13 -13
- package/package.json +1 -1
- package/.github/ISSUE_TEMPLATE/config.yml +0 -5
- package/.github/dependabot.yml +0 -6
- package/.github/workflows/ci.yml +0 -40
- package/.github/workflows/release_please.yml +0 -20
- package/.github/workflows/stale.yml +0 -20
- package/.github/workflows/update_deps.yml +0 -29
|
@@ -1,586 +1,586 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
const debug_1 = __importDefault(require("debug"));
|
|
30
|
-
const adapter_1 = __importDefault(require("../../adapter"));
|
|
31
|
-
const debug = (0, debug_1.default)("zigbee-herdsman:adapter:ezsp:debg");
|
|
32
|
-
const driver_1 = require("../driver");
|
|
33
|
-
const types_1 = require("../driver/types");
|
|
34
|
-
const zcl_1 = require("../../../zcl");
|
|
35
|
-
const Events = __importStar(require("../../events"));
|
|
36
|
-
const utils_1 = require("../../../utils");
|
|
37
|
-
const serialPortUtils_1 = __importDefault(require("../../serialPortUtils"));
|
|
38
|
-
const socketPortUtils_1 = __importDefault(require("../../socketPortUtils"));
|
|
39
|
-
const backup_1 = require("./backup");
|
|
40
|
-
const autoDetectDefinitions = [
|
|
41
|
-
{ manufacturer: 'ITEAD', vendorId: '1a86', productId: '55d4' },
|
|
42
|
-
{ manufacturer: 'Nabu Casa', vendorId: '10c4', productId: 'ea60' }, // Home Assistant SkyConnect
|
|
43
|
-
];
|
|
44
|
-
class EZSPAdapter extends adapter_1.default {
|
|
45
|
-
constructor(networkOptions, serialPortOptions, backupPath, adapterOptions) {
|
|
46
|
-
super(networkOptions, serialPortOptions, backupPath, adapterOptions);
|
|
47
|
-
this.port = serialPortOptions;
|
|
48
|
-
this.waitress = new utils_1.Waitress(this.waitressValidator, this.waitressTimeoutFormatter);
|
|
49
|
-
this.interpanLock = false;
|
|
50
|
-
this.driver = new driver_1.Driver();
|
|
51
|
-
this.driver.on('deviceJoined', this.handleDeviceJoin.bind(this));
|
|
52
|
-
this.driver.on('deviceLeft', this.handleDeviceLeft.bind(this));
|
|
53
|
-
this.driver.on('incomingMessage', this.processMessage.bind(this));
|
|
54
|
-
this.backupMan = new backup_1.EZSPAdapterBackup(this.driver, backupPath);
|
|
55
|
-
}
|
|
56
|
-
async processMessage(frame) {
|
|
57
|
-
debug(`processMessage: ${JSON.stringify(frame)}`);
|
|
58
|
-
if (frame.apsFrame.profileId == 0) {
|
|
59
|
-
if (frame.apsFrame.clusterId == types_1.EmberZDOCmd.Device_annce &&
|
|
60
|
-
frame.apsFrame.destinationEndpoint == 0) {
|
|
61
|
-
let nwk, rst, ieee;
|
|
62
|
-
[nwk, rst] = types_1.uint16_t.deserialize(types_1.uint16_t, frame.message.subarray(1));
|
|
63
|
-
[ieee, rst] = types_1.EmberEUI64.deserialize(types_1.EmberEUI64, rst);
|
|
64
|
-
ieee = new types_1.EmberEUI64(ieee);
|
|
65
|
-
debug("ZDO Device announce: %s, %s", nwk, ieee.toString());
|
|
66
|
-
this.driver.handleNodeJoined(nwk, ieee);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
else if (frame.apsFrame.profileId == 260 || frame.apsFrame.profileId == 0xFFFF) {
|
|
70
|
-
try {
|
|
71
|
-
const payload = {
|
|
72
|
-
frame: zcl_1.ZclFrame.fromBuffer(frame.apsFrame.clusterId, frame.message),
|
|
73
|
-
address: frame.sender,
|
|
74
|
-
endpoint: frame.apsFrame.sourceEndpoint,
|
|
75
|
-
linkquality: frame.lqi,
|
|
76
|
-
groupID: frame.apsFrame.groupId,
|
|
77
|
-
wasBroadcast: false,
|
|
78
|
-
destinationEndpoint: frame.apsFrame.destinationEndpoint,
|
|
79
|
-
};
|
|
80
|
-
this.waitress.resolve(payload);
|
|
81
|
-
this.emit(Events.Events.zclData, payload);
|
|
82
|
-
}
|
|
83
|
-
catch (error) {
|
|
84
|
-
const payload = {
|
|
85
|
-
clusterID: frame.apsFrame.clusterId,
|
|
86
|
-
data: frame.message,
|
|
87
|
-
address: frame.sender,
|
|
88
|
-
endpoint: frame.apsFrame.sourceEndpoint,
|
|
89
|
-
linkquality: frame.lqi,
|
|
90
|
-
groupID: frame.apsFrame.groupId,
|
|
91
|
-
wasBroadcast: false,
|
|
92
|
-
destinationEndpoint: frame.apsFrame.destinationEndpoint,
|
|
93
|
-
};
|
|
94
|
-
this.emit(Events.Events.rawData, payload);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
else if (frame.apsFrame.profileId == 0xc05e && frame.senderEui64) { // ZLL Frame
|
|
98
|
-
const payload = {
|
|
99
|
-
frame: zcl_1.ZclFrame.fromBuffer(frame.apsFrame.clusterId, frame.message),
|
|
100
|
-
address: `0x${frame.senderEui64.toString()}`,
|
|
101
|
-
endpoint: 0xFE,
|
|
102
|
-
linkquality: frame.lqi,
|
|
103
|
-
groupID: null,
|
|
104
|
-
wasBroadcast: false,
|
|
105
|
-
destinationEndpoint: null,
|
|
106
|
-
};
|
|
107
|
-
this.waitress.resolve(payload);
|
|
108
|
-
this.emit(Events.Events.zclData, payload);
|
|
109
|
-
}
|
|
110
|
-
else if (frame.apsFrame.profileId == 0xA1E0) { // GP Frame
|
|
111
|
-
const zclFrame = zcl_1.ZclFrame.create(zcl_1.FrameType.SPECIFIC, zcl_1.Direction.CLIENT_TO_SERVER, true, null, frame.apsFrame.sequence, (frame.messageType == 0xE0) ? 'commisioningNotification' : 'notification', frame.apsFrame.clusterId, frame.message);
|
|
112
|
-
const payload = {
|
|
113
|
-
frame: zclFrame,
|
|
114
|
-
address: frame.sender,
|
|
115
|
-
endpoint: frame.apsFrame.sourceEndpoint,
|
|
116
|
-
linkquality: frame.lqi,
|
|
117
|
-
groupID: null,
|
|
118
|
-
wasBroadcast: true,
|
|
119
|
-
destinationEndpoint: frame.apsFrame.sourceEndpoint,
|
|
120
|
-
};
|
|
121
|
-
this.waitress.resolve(payload);
|
|
122
|
-
this.emit(Events.Events.zclData, payload);
|
|
123
|
-
}
|
|
124
|
-
this.emit('event', frame);
|
|
125
|
-
}
|
|
126
|
-
async handleDeviceJoin(arr) {
|
|
127
|
-
let [nwk, ieee] = arr;
|
|
128
|
-
debug('Device join request received: %s %s', nwk, ieee.toString('hex'));
|
|
129
|
-
const payload = {
|
|
130
|
-
networkAddress: nwk,
|
|
131
|
-
ieeeAddr: `0x${ieee.toString('hex')}`,
|
|
132
|
-
};
|
|
133
|
-
if (nwk == 0) {
|
|
134
|
-
const nd = await this.nodeDescriptor(nwk);
|
|
135
|
-
}
|
|
136
|
-
else {
|
|
137
|
-
this.emit(Events.Events.deviceJoined, payload);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
handleDeviceLeft(arr) {
|
|
141
|
-
let [nwk, ieee] = arr;
|
|
142
|
-
debug('Device left network request received: %s %s', nwk, ieee);
|
|
143
|
-
const payload = {
|
|
144
|
-
networkAddress: nwk,
|
|
145
|
-
ieeeAddr: `0x${ieee.toString('hex')}`,
|
|
146
|
-
};
|
|
147
|
-
this.emit(Events.Events.deviceLeave, payload);
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* Adapter methods
|
|
151
|
-
*/
|
|
152
|
-
async start() {
|
|
153
|
-
return await this.driver.startup(this.port.path, {
|
|
154
|
-
baudRate: this.port.baudRate || 115200,
|
|
155
|
-
rtscts: this.port.rtscts,
|
|
156
|
-
parity: 'none',
|
|
157
|
-
stopBits: 1,
|
|
158
|
-
xon: true,
|
|
159
|
-
xoff: true
|
|
160
|
-
}, this.networkOptions, this.greenPowerGroup);
|
|
161
|
-
}
|
|
162
|
-
async stop() {
|
|
163
|
-
await this.driver.stop();
|
|
164
|
-
}
|
|
165
|
-
static async isValidPath(path) {
|
|
166
|
-
// For TCP paths we cannot get device information, therefore we cannot validate it.
|
|
167
|
-
if (socketPortUtils_1.default.isTcpPath(path)) {
|
|
168
|
-
return false;
|
|
169
|
-
}
|
|
170
|
-
try {
|
|
171
|
-
return serialPortUtils_1.default.is((0, utils_1.RealpathSync)(path), autoDetectDefinitions);
|
|
172
|
-
}
|
|
173
|
-
catch (error) {
|
|
174
|
-
debug(`Failed to determine if path is valid: '${error}'`);
|
|
175
|
-
return false;
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
static async autoDetectPath() {
|
|
179
|
-
const paths = await serialPortUtils_1.default.find(autoDetectDefinitions);
|
|
180
|
-
paths.sort((a, b) => (a < b) ? -1 : 1);
|
|
181
|
-
return paths.length > 0 ? paths[0] : null;
|
|
182
|
-
}
|
|
183
|
-
async getCoordinator() {
|
|
184
|
-
return this.driver.queue.execute(async () => {
|
|
185
|
-
this.checkInterpanLock();
|
|
186
|
-
const networkAddress = 0x0000;
|
|
187
|
-
const message = await this.driver.zdoRequest(networkAddress, types_1.EmberZDOCmd.Active_EP_req, types_1.EmberZDOCmd.Active_EP_rsp, { dstaddr: networkAddress });
|
|
188
|
-
const activeEndpoints = message.activeeplist;
|
|
189
|
-
const endpoints = [];
|
|
190
|
-
for (const endpoint of activeEndpoints) {
|
|
191
|
-
const descriptor = await this.driver.zdoRequest(networkAddress, types_1.EmberZDOCmd.Simple_Desc_req, types_1.EmberZDOCmd.Simple_Desc_rsp, { dstaddr: networkAddress, targetEp: endpoint });
|
|
192
|
-
endpoints.push({
|
|
193
|
-
profileID: descriptor.descriptor.profileid,
|
|
194
|
-
ID: descriptor.descriptor.endpoint,
|
|
195
|
-
deviceID: descriptor.descriptor.deviceid,
|
|
196
|
-
inputClusters: descriptor.descriptor.inclusterlist,
|
|
197
|
-
outputClusters: descriptor.descriptor.outclusterlist,
|
|
198
|
-
});
|
|
199
|
-
}
|
|
200
|
-
return {
|
|
201
|
-
networkAddress: networkAddress,
|
|
202
|
-
manufacturerID: 0,
|
|
203
|
-
ieeeAddr: `0x${this.driver.ieee.toString()}`,
|
|
204
|
-
endpoints,
|
|
205
|
-
};
|
|
206
|
-
});
|
|
207
|
-
}
|
|
208
|
-
async permitJoin(seconds, networkAddress) {
|
|
209
|
-
return this.driver.queue.execute(async () => {
|
|
210
|
-
this.checkInterpanLock();
|
|
211
|
-
if (seconds) {
|
|
212
|
-
this.driver.preJoining();
|
|
213
|
-
}
|
|
214
|
-
if (networkAddress) {
|
|
215
|
-
const result = await this.driver.zdoRequest(networkAddress, types_1.EmberZDOCmd.Mgmt_Permit_Joining_req, types_1.EmberZDOCmd.Mgmt_Permit_Joining_rsp, { duration: seconds, tcSignificant: false });
|
|
216
|
-
if (result.status !== types_1.EmberStatus.SUCCESS) {
|
|
217
|
-
throw new Error(`permitJoin for '${networkAddress}' failed`);
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
else {
|
|
221
|
-
await this.driver.permitJoining(seconds);
|
|
222
|
-
}
|
|
223
|
-
});
|
|
224
|
-
}
|
|
225
|
-
async getCoordinatorVersion() {
|
|
226
|
-
return { type: `EZSP v${this.driver.version.product}`, meta: this.driver.version };
|
|
227
|
-
}
|
|
228
|
-
async addInstallCode(ieeeAddress, key) {
|
|
229
|
-
if ([8, 10, 14, 18].indexOf(key.length) === -1) {
|
|
230
|
-
throw new Error('Wrong install code length');
|
|
231
|
-
}
|
|
232
|
-
await this.driver.addInstallCode(ieeeAddress, key);
|
|
233
|
-
}
|
|
234
|
-
async reset(type) {
|
|
235
|
-
return Promise.reject(new Error("Not supported"));
|
|
236
|
-
}
|
|
237
|
-
async lqi(networkAddress) {
|
|
238
|
-
return this.driver.queue.execute(async () => {
|
|
239
|
-
this.checkInterpanLock();
|
|
240
|
-
const neighbors = [];
|
|
241
|
-
const request = async (startIndex) => {
|
|
242
|
-
const result = await this.driver.zdoRequest(networkAddress, types_1.EmberZDOCmd.Mgmt_Lqi_req, types_1.EmberZDOCmd.Mgmt_Lqi_rsp, { startindex: startIndex });
|
|
243
|
-
if (result.status !== types_1.EmberStatus.SUCCESS) {
|
|
244
|
-
throw new Error(`LQI for '${networkAddress}' failed with with status code ${result.status}`);
|
|
245
|
-
}
|
|
246
|
-
return result;
|
|
247
|
-
};
|
|
248
|
-
// eslint-disable-next-line
|
|
249
|
-
const add = (list) => {
|
|
250
|
-
for (const entry of list) {
|
|
251
|
-
this.driver.setNode(entry.nodeid, entry.ieee);
|
|
252
|
-
neighbors.push({
|
|
253
|
-
linkquality: entry.lqi,
|
|
254
|
-
networkAddress: entry.nodeid,
|
|
255
|
-
ieeeAddr: `0x${new types_1.EmberEUI64(entry.ieee).toString()}`,
|
|
256
|
-
relationship: (entry.packed >> 4) & 0x7,
|
|
257
|
-
depth: entry.depth,
|
|
258
|
-
});
|
|
259
|
-
}
|
|
260
|
-
};
|
|
261
|
-
let response = await request(0);
|
|
262
|
-
add(response.neighborlqilist.neighbors);
|
|
263
|
-
const size = response.neighborlqilist.entries;
|
|
264
|
-
let nextStartIndex = response.neighborlqilist.neighbors.length;
|
|
265
|
-
while (neighbors.length < size) {
|
|
266
|
-
response = await request(nextStartIndex);
|
|
267
|
-
add(response.neighborlqilist.neighbors);
|
|
268
|
-
nextStartIndex += response.neighborlqilist.neighbors.length;
|
|
269
|
-
}
|
|
270
|
-
return { neighbors };
|
|
271
|
-
}, networkAddress);
|
|
272
|
-
}
|
|
273
|
-
async routingTable(networkAddress) {
|
|
274
|
-
return this.driver.queue.execute(async () => {
|
|
275
|
-
this.checkInterpanLock();
|
|
276
|
-
const table = [];
|
|
277
|
-
const request = async (startIndex) => {
|
|
278
|
-
const result = await this.driver.zdoRequest(networkAddress, types_1.EmberZDOCmd.Mgmt_Rtg_req, types_1.EmberZDOCmd.Mgmt_Rtg_rsp, { startindex: startIndex });
|
|
279
|
-
if (result.status !== types_1.EmberStatus.SUCCESS) {
|
|
280
|
-
throw new Error(`Routing table for '${networkAddress}' failed with status code ${result.status}`);
|
|
281
|
-
}
|
|
282
|
-
return result;
|
|
283
|
-
};
|
|
284
|
-
// eslint-disable-next-line
|
|
285
|
-
const add = (list) => {
|
|
286
|
-
for (const entry of list) {
|
|
287
|
-
table.push({
|
|
288
|
-
destinationAddress: entry.destination,
|
|
289
|
-
status: entry.status,
|
|
290
|
-
nextHop: entry.nexthop
|
|
291
|
-
});
|
|
292
|
-
}
|
|
293
|
-
};
|
|
294
|
-
let response = await request(0);
|
|
295
|
-
add(response.routingtablelist.table);
|
|
296
|
-
const size = response.routingtablelist.entries;
|
|
297
|
-
let nextStartIndex = response.routingtablelist.table.length;
|
|
298
|
-
while (table.length < size) {
|
|
299
|
-
response = await request(nextStartIndex);
|
|
300
|
-
add(response.routingtablelist.table);
|
|
301
|
-
nextStartIndex += response.routingtablelist.table.length;
|
|
302
|
-
}
|
|
303
|
-
return { table };
|
|
304
|
-
}, networkAddress);
|
|
305
|
-
}
|
|
306
|
-
async nodeDescriptor(networkAddress) {
|
|
307
|
-
return this.driver.queue.execute(async () => {
|
|
308
|
-
this.checkInterpanLock();
|
|
309
|
-
try {
|
|
310
|
-
debug(`Requesting 'Node Descriptor' for '${networkAddress}'`);
|
|
311
|
-
const result = await this.nodeDescriptorInternal(networkAddress);
|
|
312
|
-
return result;
|
|
313
|
-
}
|
|
314
|
-
catch (error) {
|
|
315
|
-
debug(`Node descriptor request for '${networkAddress}' failed (${error}), retry`);
|
|
316
|
-
throw error;
|
|
317
|
-
}
|
|
318
|
-
});
|
|
319
|
-
}
|
|
320
|
-
async nodeDescriptorInternal(networkAddress) {
|
|
321
|
-
const descriptor = await this.driver.zdoRequest(networkAddress, types_1.EmberZDOCmd.Node_Desc_req, types_1.EmberZDOCmd.Node_Desc_rsp, { dstaddr: networkAddress });
|
|
322
|
-
const logicaltype = descriptor.descriptor.byte1 & 0x07;
|
|
323
|
-
return {
|
|
324
|
-
manufacturerCode: descriptor.descriptor.manufacturer_code,
|
|
325
|
-
type: (logicaltype == 0) ? 'Coordinator' : (logicaltype == 1) ? 'Router' : 'EndDevice'
|
|
326
|
-
};
|
|
327
|
-
}
|
|
328
|
-
async activeEndpoints(networkAddress) {
|
|
329
|
-
debug(`Requesting 'Active endpoints' for '${networkAddress}'`);
|
|
330
|
-
return this.driver.queue.execute(async () => {
|
|
331
|
-
const endpoints = await this.driver.zdoRequest(networkAddress, types_1.EmberZDOCmd.Active_EP_req, types_1.EmberZDOCmd.Active_EP_rsp, { dstaddr: networkAddress });
|
|
332
|
-
return { endpoints: [...endpoints.activeeplist] };
|
|
333
|
-
}, networkAddress);
|
|
334
|
-
}
|
|
335
|
-
async simpleDescriptor(networkAddress, endpointID) {
|
|
336
|
-
debug(`Requesting 'Simple Descriptor' for '${networkAddress}' endpoint ${endpointID}`);
|
|
337
|
-
return this.driver.queue.execute(async () => {
|
|
338
|
-
this.checkInterpanLock();
|
|
339
|
-
const descriptor = await this.driver.zdoRequest(networkAddress, types_1.EmberZDOCmd.Simple_Desc_req, types_1.EmberZDOCmd.Simple_Desc_rsp, { dstaddr: networkAddress, targetEp: endpointID });
|
|
340
|
-
return {
|
|
341
|
-
profileID: descriptor.descriptor.profileid,
|
|
342
|
-
endpointID: descriptor.descriptor.endpoint,
|
|
343
|
-
deviceID: descriptor.descriptor.deviceid,
|
|
344
|
-
inputClusters: descriptor.descriptor.inclusterlist,
|
|
345
|
-
outputClusters: descriptor.descriptor.outclusterlist,
|
|
346
|
-
};
|
|
347
|
-
}, networkAddress);
|
|
348
|
-
}
|
|
349
|
-
async sendZclFrameToEndpoint(ieeeAddr, networkAddress, endpoint, zclFrame, timeout, disableResponse, disableRecovery, sourceEndpoint) {
|
|
350
|
-
return this.driver.queue.execute(async () => {
|
|
351
|
-
this.checkInterpanLock();
|
|
352
|
-
return this.sendZclFrameToEndpointInternal(ieeeAddr, networkAddress, endpoint, sourceEndpoint || 1, zclFrame, timeout, disableResponse, disableRecovery, 0, 0, false, false, false, null);
|
|
353
|
-
}, networkAddress);
|
|
354
|
-
}
|
|
355
|
-
async sendZclFrameToEndpointInternal(ieeeAddr, networkAddress, endpoint, sourceEndpoint, zclFrame, timeout, disableResponse, disableRecovery, responseAttempt, dataRequestAttempt, checkedNetworkAddress, discoveredRoute, assocRemove, assocRestore) {
|
|
356
|
-
if (ieeeAddr == null) {
|
|
357
|
-
ieeeAddr = `0x${this.driver.ieee.toString()}`;
|
|
358
|
-
}
|
|
359
|
-
debug('sendZclFrameToEndpointInternal %s:%i/%i (%i,%i,%i)', ieeeAddr, networkAddress, endpoint, responseAttempt, dataRequestAttempt, this.driver.queue.count());
|
|
360
|
-
let response = null;
|
|
361
|
-
const command = zclFrame.getCommand();
|
|
362
|
-
if (command.hasOwnProperty('response') && disableResponse === false) {
|
|
363
|
-
response = this.waitForInternal(networkAddress, endpoint, zclFrame.Header.transactionSequenceNumber, zclFrame.Cluster.ID, command.response, timeout);
|
|
364
|
-
}
|
|
365
|
-
else if (!zclFrame.Header.frameControl.disableDefaultResponse) {
|
|
366
|
-
response = this.waitForInternal(networkAddress, endpoint, zclFrame.Header.transactionSequenceNumber, zclFrame.Cluster.ID, zcl_1.Foundation.defaultRsp.ID, timeout);
|
|
367
|
-
}
|
|
368
|
-
const frame = this.driver.makeApsFrame(zclFrame.Cluster.ID, disableResponse || zclFrame.Header.frameControl.disableDefaultResponse);
|
|
369
|
-
frame.profileId = 0x0104;
|
|
370
|
-
frame.sourceEndpoint = sourceEndpoint || 0x01;
|
|
371
|
-
frame.destinationEndpoint = endpoint;
|
|
372
|
-
frame.groupId = 0;
|
|
373
|
-
this.driver.setNode(networkAddress, new types_1.EmberEUI64(ieeeAddr));
|
|
374
|
-
const dataConfirmResult = await this.driver.request(networkAddress, frame, zclFrame.toBuffer());
|
|
375
|
-
if (!dataConfirmResult) {
|
|
376
|
-
if (response != null) {
|
|
377
|
-
response.cancel();
|
|
378
|
-
}
|
|
379
|
-
throw Error('sendZclFrameToEndpointInternal error');
|
|
380
|
-
}
|
|
381
|
-
if (response !== null) {
|
|
382
|
-
try {
|
|
383
|
-
const result = await response.start().promise;
|
|
384
|
-
return result;
|
|
385
|
-
}
|
|
386
|
-
catch (error) {
|
|
387
|
-
debug('Response timeout (%s:%d,%d)', ieeeAddr, networkAddress, responseAttempt);
|
|
388
|
-
if (responseAttempt < 1 && !disableRecovery) {
|
|
389
|
-
return this.sendZclFrameToEndpointInternal(ieeeAddr, networkAddress, endpoint, sourceEndpoint, zclFrame, timeout, disableResponse, disableRecovery, responseAttempt + 1, dataRequestAttempt, checkedNetworkAddress, discoveredRoute, assocRemove, assocRestore);
|
|
390
|
-
}
|
|
391
|
-
else {
|
|
392
|
-
throw error;
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
else {
|
|
397
|
-
return null;
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
async sendZclFrameToGroup(groupID, zclFrame) {
|
|
401
|
-
return this.driver.queue.execute(async () => {
|
|
402
|
-
this.checkInterpanLock();
|
|
403
|
-
const frame = this.driver.makeApsFrame(zclFrame.Cluster.ID, false);
|
|
404
|
-
frame.profileId = 0x0104;
|
|
405
|
-
frame.sourceEndpoint = 0x01;
|
|
406
|
-
frame.destinationEndpoint = 0x01;
|
|
407
|
-
frame.groupId = groupID;
|
|
408
|
-
const dataConfirmResult = await this.driver.mrequest(frame, zclFrame.toBuffer());
|
|
409
|
-
/**
|
|
410
|
-
* As a group command is not confirmed and thus immidiately returns
|
|
411
|
-
* (contrary to network address requests) we will give the
|
|
412
|
-
* command some time to 'settle' in the network.
|
|
413
|
-
*/
|
|
414
|
-
await (0, utils_1.Wait)(200);
|
|
415
|
-
});
|
|
416
|
-
}
|
|
417
|
-
async sendZclFrameToAll(endpoint, zclFrame, sourceEndpoint) {
|
|
418
|
-
return this.driver.queue.execute(async () => {
|
|
419
|
-
this.checkInterpanLock();
|
|
420
|
-
const frame = this.driver.makeApsFrame(zclFrame.Cluster.ID, false);
|
|
421
|
-
frame.profileId = sourceEndpoint === 242 && endpoint === 242 ? 0xA1E0 : 0x0104;
|
|
422
|
-
frame.sourceEndpoint = sourceEndpoint;
|
|
423
|
-
frame.destinationEndpoint = endpoint;
|
|
424
|
-
frame.groupId = 0xFFFD;
|
|
425
|
-
const dataConfirmResult = await this.driver.mrequest(frame, zclFrame.toBuffer());
|
|
426
|
-
/**
|
|
427
|
-
* As a broadcast command is not confirmed and thus immidiately returns
|
|
428
|
-
* (contrary to network address requests) we will give the
|
|
429
|
-
* command some time to 'settle' in the network.
|
|
430
|
-
*/
|
|
431
|
-
await (0, utils_1.Wait)(200);
|
|
432
|
-
});
|
|
433
|
-
}
|
|
434
|
-
async bind(destinationNetworkAddress, sourceIeeeAddress, sourceEndpoint, clusterID, destinationAddressOrGroup, type, destinationEndpoint) {
|
|
435
|
-
return this.driver.queue.execute(async () => {
|
|
436
|
-
this.checkInterpanLock();
|
|
437
|
-
const ieee = new types_1.EmberEUI64(sourceIeeeAddress);
|
|
438
|
-
const addrmode = (type === 'group') ? 1 : 3;
|
|
439
|
-
const ieeeDst = (type === 'group') ? destinationAddressOrGroup :
|
|
440
|
-
new types_1.EmberEUI64(destinationAddressOrGroup);
|
|
441
|
-
if (type !== 'group') {
|
|
442
|
-
this.driver.setNode(destinationNetworkAddress, ieeeDst);
|
|
443
|
-
}
|
|
444
|
-
await this.driver.zdoRequest(destinationNetworkAddress, types_1.EmberZDOCmd.Bind_req, types_1.EmberZDOCmd.Bind_rsp, { sourceEui: ieee, sourceEp: sourceEndpoint, clusterId: clusterID,
|
|
445
|
-
destAddr: { addrmode: addrmode, ieee: ieeeDst, endpoint: destinationEndpoint } });
|
|
446
|
-
}, destinationNetworkAddress);
|
|
447
|
-
}
|
|
448
|
-
async unbind(destinationNetworkAddress, sourceIeeeAddress, sourceEndpoint, clusterID, destinationAddressOrGroup, type, destinationEndpoint) {
|
|
449
|
-
return this.driver.queue.execute(async () => {
|
|
450
|
-
this.checkInterpanLock();
|
|
451
|
-
const ieee = new types_1.EmberEUI64(sourceIeeeAddress);
|
|
452
|
-
const addrmode = (type === 'group') ? 1 : 3;
|
|
453
|
-
const ieeeDst = (type === 'group') ? destinationAddressOrGroup :
|
|
454
|
-
new types_1.EmberEUI64(destinationAddressOrGroup);
|
|
455
|
-
if (type !== 'group') {
|
|
456
|
-
this.driver.setNode(destinationNetworkAddress, ieeeDst);
|
|
457
|
-
}
|
|
458
|
-
await this.driver.zdoRequest(destinationNetworkAddress, types_1.EmberZDOCmd.Unbind_req, types_1.EmberZDOCmd.Unbind_rsp, { sourceEui: ieee, sourceEp: sourceEndpoint, clusterId: clusterID,
|
|
459
|
-
destAddr: { addrmode: addrmode, ieee: ieeeDst, endpoint: destinationEndpoint } });
|
|
460
|
-
}, destinationNetworkAddress);
|
|
461
|
-
}
|
|
462
|
-
removeDevice(networkAddress, ieeeAddr) {
|
|
463
|
-
return this.driver.queue.execute(async () => {
|
|
464
|
-
this.checkInterpanLock();
|
|
465
|
-
const ieee = new types_1.EmberEUI64(ieeeAddr);
|
|
466
|
-
this.driver.setNode(networkAddress, ieee);
|
|
467
|
-
await this.driver.zdoRequest(networkAddress, types_1.EmberZDOCmd.Mgmt_Leave_req, types_1.EmberZDOCmd.Mgmt_Leave_rsp, { destAddr: ieee, removechildrenRejoin: 0x00 });
|
|
468
|
-
}, networkAddress);
|
|
469
|
-
}
|
|
470
|
-
async getNetworkParameters() {
|
|
471
|
-
return {
|
|
472
|
-
panID: this.driver.networkParams.panId,
|
|
473
|
-
extendedPanID: this.driver.networkParams.extendedPanId[0],
|
|
474
|
-
channel: this.driver.networkParams.radioChannel
|
|
475
|
-
};
|
|
476
|
-
}
|
|
477
|
-
async supportsBackup() {
|
|
478
|
-
return true;
|
|
479
|
-
}
|
|
480
|
-
async backup() {
|
|
481
|
-
return this.backupMan.createBackup();
|
|
482
|
-
}
|
|
483
|
-
async restoreChannelInterPAN() {
|
|
484
|
-
return this.driver.queue.execute(async () => {
|
|
485
|
-
const channel = (await this.getNetworkParameters()).channel;
|
|
486
|
-
await this.driver.setChannel(channel);
|
|
487
|
-
// Give adapter some time to restore, otherwise stuff crashes
|
|
488
|
-
await (0, utils_1.Wait)(3000);
|
|
489
|
-
this.interpanLock = false;
|
|
490
|
-
});
|
|
491
|
-
}
|
|
492
|
-
checkInterpanLock() {
|
|
493
|
-
if (this.interpanLock) {
|
|
494
|
-
throw new Error(`Cannot execute command, in Inter-PAN mode`);
|
|
495
|
-
}
|
|
496
|
-
}
|
|
497
|
-
async sendZclFrameInterPANToIeeeAddr(zclFrame, ieeeAddr) {
|
|
498
|
-
return this.driver.queue.execute(async () => {
|
|
499
|
-
debug(`sendZclFrameInterPANToIeeeAddr to ${ieeeAddr}`);
|
|
500
|
-
try {
|
|
501
|
-
const frame = this.driver.makeEmberIeeeRawFrame();
|
|
502
|
-
frame.ieeeFrameControl = 0xcc21;
|
|
503
|
-
frame.destPanId = 0xFFFF;
|
|
504
|
-
frame.destAddress = new types_1.EmberEUI64(ieeeAddr);
|
|
505
|
-
frame.sourcePanId = this.driver.networkParams.panId;
|
|
506
|
-
frame.sourceAddress = this.driver.ieee;
|
|
507
|
-
frame.nwkFrameControl = 0x000b;
|
|
508
|
-
frame.appFrameControl = 0x03;
|
|
509
|
-
frame.clusterId = zclFrame.Cluster.ID;
|
|
510
|
-
frame.profileId = 0xc05e;
|
|
511
|
-
const dataConfirmResult = await this.driver.ieeerawrequest(frame, zclFrame.toBuffer());
|
|
512
|
-
}
|
|
513
|
-
catch (error) {
|
|
514
|
-
throw error;
|
|
515
|
-
}
|
|
516
|
-
});
|
|
517
|
-
}
|
|
518
|
-
async sendZclFrameInterPANBroadcast(zclFrame, timeout) {
|
|
519
|
-
return this.driver.queue.execute(async () => {
|
|
520
|
-
debug(`sendZclFrameInterPANBroadcast`);
|
|
521
|
-
const command = zclFrame.getCommand();
|
|
522
|
-
if (!command.hasOwnProperty('response')) {
|
|
523
|
-
throw new Error(`Command '${command.name}' has no response, cannot wait for response`);
|
|
524
|
-
}
|
|
525
|
-
const response = this.waitForInternal(null, 0xFE, null, zclFrame.Cluster.ID, command.response, timeout);
|
|
526
|
-
try {
|
|
527
|
-
const frame = this.driver.makeEmberRawFrame();
|
|
528
|
-
frame.ieeeFrameControl = 0xc801;
|
|
529
|
-
frame.destPanId = 0xFFFF;
|
|
530
|
-
frame.destNodeId = 0xFFFF;
|
|
531
|
-
frame.sourcePanId = this.driver.networkParams.panId;
|
|
532
|
-
frame.ieeeAddress = this.driver.ieee;
|
|
533
|
-
frame.nwkFrameControl = 0x000b;
|
|
534
|
-
frame.appFrameControl = 0x0b;
|
|
535
|
-
frame.clusterId = zclFrame.Cluster.ID;
|
|
536
|
-
frame.profileId = 0xc05e;
|
|
537
|
-
const dataConfirmResult = await this.driver.rawrequest(frame, zclFrame.toBuffer());
|
|
538
|
-
}
|
|
539
|
-
catch (error) {
|
|
540
|
-
response.cancel();
|
|
541
|
-
throw error;
|
|
542
|
-
}
|
|
543
|
-
return response.start().promise;
|
|
544
|
-
});
|
|
545
|
-
}
|
|
546
|
-
async setTransmitPower(value) {
|
|
547
|
-
debug(`setTransmitPower to ${value}`);
|
|
548
|
-
return this.driver.queue.execute(async () => {
|
|
549
|
-
await this.driver.setRadioPower(value);
|
|
550
|
-
});
|
|
551
|
-
}
|
|
552
|
-
async setChannelInterPAN(channel) {
|
|
553
|
-
return this.driver.queue.execute(async () => {
|
|
554
|
-
this.interpanLock = true;
|
|
555
|
-
await this.driver.setChannel(channel);
|
|
556
|
-
});
|
|
557
|
-
}
|
|
558
|
-
waitForInternal(networkAddress, endpoint, transactionSequenceNumber, clusterID, commandIdentifier, timeout) {
|
|
559
|
-
const payload = {
|
|
560
|
-
address: networkAddress, endpoint, clusterID, commandIdentifier,
|
|
561
|
-
transactionSequenceNumber,
|
|
562
|
-
};
|
|
563
|
-
const waiter = this.waitress.waitFor(payload, timeout);
|
|
564
|
-
const cancel = () => this.waitress.remove(waiter.ID);
|
|
565
|
-
return { start: waiter.start, cancel };
|
|
566
|
-
}
|
|
567
|
-
waitFor(networkAddress, endpoint, frameType, direction, transactionSequenceNumber, clusterID, commandIdentifier, timeout) {
|
|
568
|
-
const waiter = this.waitForInternal(networkAddress, endpoint, transactionSequenceNumber, clusterID, commandIdentifier, timeout);
|
|
569
|
-
return { cancel: waiter.cancel, promise: waiter.start().promise };
|
|
570
|
-
}
|
|
571
|
-
waitressTimeoutFormatter(matcher, timeout) {
|
|
572
|
-
return `Timeout - ${matcher.address} - ${matcher.endpoint}` +
|
|
573
|
-
` - ${matcher.transactionSequenceNumber} - ${matcher.clusterID}` +
|
|
574
|
-
` - ${matcher.commandIdentifier} after ${timeout}ms`;
|
|
575
|
-
}
|
|
576
|
-
waitressValidator(payload, matcher) {
|
|
577
|
-
const transactionSequenceNumber = payload.frame.Header.transactionSequenceNumber;
|
|
578
|
-
return (!matcher.address || payload.address === matcher.address) &&
|
|
579
|
-
payload.endpoint === matcher.endpoint &&
|
|
580
|
-
(!matcher.transactionSequenceNumber || transactionSequenceNumber === matcher.transactionSequenceNumber) &&
|
|
581
|
-
payload.frame.Cluster.ID === matcher.clusterID &&
|
|
582
|
-
matcher.commandIdentifier === payload.frame.Header.commandIdentifier;
|
|
583
|
-
}
|
|
584
|
-
}
|
|
585
|
-
exports.default = EZSPAdapter;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
const debug_1 = __importDefault(require("debug"));
|
|
30
|
+
const adapter_1 = __importDefault(require("../../adapter"));
|
|
31
|
+
const debug = (0, debug_1.default)("zigbee-herdsman:adapter:ezsp:debg");
|
|
32
|
+
const driver_1 = require("../driver");
|
|
33
|
+
const types_1 = require("../driver/types");
|
|
34
|
+
const zcl_1 = require("../../../zcl");
|
|
35
|
+
const Events = __importStar(require("../../events"));
|
|
36
|
+
const utils_1 = require("../../../utils");
|
|
37
|
+
const serialPortUtils_1 = __importDefault(require("../../serialPortUtils"));
|
|
38
|
+
const socketPortUtils_1 = __importDefault(require("../../socketPortUtils"));
|
|
39
|
+
const backup_1 = require("./backup");
|
|
40
|
+
const autoDetectDefinitions = [
|
|
41
|
+
{ manufacturer: 'ITEAD', vendorId: '1a86', productId: '55d4' },
|
|
42
|
+
{ manufacturer: 'Nabu Casa', vendorId: '10c4', productId: 'ea60' }, // Home Assistant SkyConnect
|
|
43
|
+
];
|
|
44
|
+
class EZSPAdapter extends adapter_1.default {
|
|
45
|
+
constructor(networkOptions, serialPortOptions, backupPath, adapterOptions) {
|
|
46
|
+
super(networkOptions, serialPortOptions, backupPath, adapterOptions);
|
|
47
|
+
this.port = serialPortOptions;
|
|
48
|
+
this.waitress = new utils_1.Waitress(this.waitressValidator, this.waitressTimeoutFormatter);
|
|
49
|
+
this.interpanLock = false;
|
|
50
|
+
this.driver = new driver_1.Driver();
|
|
51
|
+
this.driver.on('deviceJoined', this.handleDeviceJoin.bind(this));
|
|
52
|
+
this.driver.on('deviceLeft', this.handleDeviceLeft.bind(this));
|
|
53
|
+
this.driver.on('incomingMessage', this.processMessage.bind(this));
|
|
54
|
+
this.backupMan = new backup_1.EZSPAdapterBackup(this.driver, backupPath);
|
|
55
|
+
}
|
|
56
|
+
async processMessage(frame) {
|
|
57
|
+
debug(`processMessage: ${JSON.stringify(frame)}`);
|
|
58
|
+
if (frame.apsFrame.profileId == 0) {
|
|
59
|
+
if (frame.apsFrame.clusterId == types_1.EmberZDOCmd.Device_annce &&
|
|
60
|
+
frame.apsFrame.destinationEndpoint == 0) {
|
|
61
|
+
let nwk, rst, ieee;
|
|
62
|
+
[nwk, rst] = types_1.uint16_t.deserialize(types_1.uint16_t, frame.message.subarray(1));
|
|
63
|
+
[ieee, rst] = types_1.EmberEUI64.deserialize(types_1.EmberEUI64, rst);
|
|
64
|
+
ieee = new types_1.EmberEUI64(ieee);
|
|
65
|
+
debug("ZDO Device announce: %s, %s", nwk, ieee.toString());
|
|
66
|
+
this.driver.handleNodeJoined(nwk, ieee);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
else if (frame.apsFrame.profileId == 260 || frame.apsFrame.profileId == 0xFFFF) {
|
|
70
|
+
try {
|
|
71
|
+
const payload = {
|
|
72
|
+
frame: zcl_1.ZclFrame.fromBuffer(frame.apsFrame.clusterId, frame.message),
|
|
73
|
+
address: frame.sender,
|
|
74
|
+
endpoint: frame.apsFrame.sourceEndpoint,
|
|
75
|
+
linkquality: frame.lqi,
|
|
76
|
+
groupID: frame.apsFrame.groupId,
|
|
77
|
+
wasBroadcast: false,
|
|
78
|
+
destinationEndpoint: frame.apsFrame.destinationEndpoint,
|
|
79
|
+
};
|
|
80
|
+
this.waitress.resolve(payload);
|
|
81
|
+
this.emit(Events.Events.zclData, payload);
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
const payload = {
|
|
85
|
+
clusterID: frame.apsFrame.clusterId,
|
|
86
|
+
data: frame.message,
|
|
87
|
+
address: frame.sender,
|
|
88
|
+
endpoint: frame.apsFrame.sourceEndpoint,
|
|
89
|
+
linkquality: frame.lqi,
|
|
90
|
+
groupID: frame.apsFrame.groupId,
|
|
91
|
+
wasBroadcast: false,
|
|
92
|
+
destinationEndpoint: frame.apsFrame.destinationEndpoint,
|
|
93
|
+
};
|
|
94
|
+
this.emit(Events.Events.rawData, payload);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
else if (frame.apsFrame.profileId == 0xc05e && frame.senderEui64) { // ZLL Frame
|
|
98
|
+
const payload = {
|
|
99
|
+
frame: zcl_1.ZclFrame.fromBuffer(frame.apsFrame.clusterId, frame.message),
|
|
100
|
+
address: `0x${frame.senderEui64.toString()}`,
|
|
101
|
+
endpoint: 0xFE,
|
|
102
|
+
linkquality: frame.lqi,
|
|
103
|
+
groupID: null,
|
|
104
|
+
wasBroadcast: false,
|
|
105
|
+
destinationEndpoint: null,
|
|
106
|
+
};
|
|
107
|
+
this.waitress.resolve(payload);
|
|
108
|
+
this.emit(Events.Events.zclData, payload);
|
|
109
|
+
}
|
|
110
|
+
else if (frame.apsFrame.profileId == 0xA1E0) { // GP Frame
|
|
111
|
+
const zclFrame = zcl_1.ZclFrame.create(zcl_1.FrameType.SPECIFIC, zcl_1.Direction.CLIENT_TO_SERVER, true, null, frame.apsFrame.sequence, (frame.messageType == 0xE0) ? 'commisioningNotification' : 'notification', frame.apsFrame.clusterId, frame.message);
|
|
112
|
+
const payload = {
|
|
113
|
+
frame: zclFrame,
|
|
114
|
+
address: frame.sender,
|
|
115
|
+
endpoint: frame.apsFrame.sourceEndpoint,
|
|
116
|
+
linkquality: frame.lqi,
|
|
117
|
+
groupID: null,
|
|
118
|
+
wasBroadcast: true,
|
|
119
|
+
destinationEndpoint: frame.apsFrame.sourceEndpoint,
|
|
120
|
+
};
|
|
121
|
+
this.waitress.resolve(payload);
|
|
122
|
+
this.emit(Events.Events.zclData, payload);
|
|
123
|
+
}
|
|
124
|
+
this.emit('event', frame);
|
|
125
|
+
}
|
|
126
|
+
async handleDeviceJoin(arr) {
|
|
127
|
+
let [nwk, ieee] = arr;
|
|
128
|
+
debug('Device join request received: %s %s', nwk, ieee.toString('hex'));
|
|
129
|
+
const payload = {
|
|
130
|
+
networkAddress: nwk,
|
|
131
|
+
ieeeAddr: `0x${ieee.toString('hex')}`,
|
|
132
|
+
};
|
|
133
|
+
if (nwk == 0) {
|
|
134
|
+
const nd = await this.nodeDescriptor(nwk);
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
this.emit(Events.Events.deviceJoined, payload);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
handleDeviceLeft(arr) {
|
|
141
|
+
let [nwk, ieee] = arr;
|
|
142
|
+
debug('Device left network request received: %s %s', nwk, ieee);
|
|
143
|
+
const payload = {
|
|
144
|
+
networkAddress: nwk,
|
|
145
|
+
ieeeAddr: `0x${ieee.toString('hex')}`,
|
|
146
|
+
};
|
|
147
|
+
this.emit(Events.Events.deviceLeave, payload);
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Adapter methods
|
|
151
|
+
*/
|
|
152
|
+
async start() {
|
|
153
|
+
return await this.driver.startup(this.port.path, {
|
|
154
|
+
baudRate: this.port.baudRate || 115200,
|
|
155
|
+
rtscts: this.port.rtscts,
|
|
156
|
+
parity: 'none',
|
|
157
|
+
stopBits: 1,
|
|
158
|
+
xon: true,
|
|
159
|
+
xoff: true
|
|
160
|
+
}, this.networkOptions, this.greenPowerGroup);
|
|
161
|
+
}
|
|
162
|
+
async stop() {
|
|
163
|
+
await this.driver.stop();
|
|
164
|
+
}
|
|
165
|
+
static async isValidPath(path) {
|
|
166
|
+
// For TCP paths we cannot get device information, therefore we cannot validate it.
|
|
167
|
+
if (socketPortUtils_1.default.isTcpPath(path)) {
|
|
168
|
+
return false;
|
|
169
|
+
}
|
|
170
|
+
try {
|
|
171
|
+
return serialPortUtils_1.default.is((0, utils_1.RealpathSync)(path), autoDetectDefinitions);
|
|
172
|
+
}
|
|
173
|
+
catch (error) {
|
|
174
|
+
debug(`Failed to determine if path is valid: '${error}'`);
|
|
175
|
+
return false;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
static async autoDetectPath() {
|
|
179
|
+
const paths = await serialPortUtils_1.default.find(autoDetectDefinitions);
|
|
180
|
+
paths.sort((a, b) => (a < b) ? -1 : 1);
|
|
181
|
+
return paths.length > 0 ? paths[0] : null;
|
|
182
|
+
}
|
|
183
|
+
async getCoordinator() {
|
|
184
|
+
return this.driver.queue.execute(async () => {
|
|
185
|
+
this.checkInterpanLock();
|
|
186
|
+
const networkAddress = 0x0000;
|
|
187
|
+
const message = await this.driver.zdoRequest(networkAddress, types_1.EmberZDOCmd.Active_EP_req, types_1.EmberZDOCmd.Active_EP_rsp, { dstaddr: networkAddress });
|
|
188
|
+
const activeEndpoints = message.activeeplist;
|
|
189
|
+
const endpoints = [];
|
|
190
|
+
for (const endpoint of activeEndpoints) {
|
|
191
|
+
const descriptor = await this.driver.zdoRequest(networkAddress, types_1.EmberZDOCmd.Simple_Desc_req, types_1.EmberZDOCmd.Simple_Desc_rsp, { dstaddr: networkAddress, targetEp: endpoint });
|
|
192
|
+
endpoints.push({
|
|
193
|
+
profileID: descriptor.descriptor.profileid,
|
|
194
|
+
ID: descriptor.descriptor.endpoint,
|
|
195
|
+
deviceID: descriptor.descriptor.deviceid,
|
|
196
|
+
inputClusters: descriptor.descriptor.inclusterlist,
|
|
197
|
+
outputClusters: descriptor.descriptor.outclusterlist,
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
return {
|
|
201
|
+
networkAddress: networkAddress,
|
|
202
|
+
manufacturerID: 0,
|
|
203
|
+
ieeeAddr: `0x${this.driver.ieee.toString()}`,
|
|
204
|
+
endpoints,
|
|
205
|
+
};
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
async permitJoin(seconds, networkAddress) {
|
|
209
|
+
return this.driver.queue.execute(async () => {
|
|
210
|
+
this.checkInterpanLock();
|
|
211
|
+
if (seconds) {
|
|
212
|
+
this.driver.preJoining();
|
|
213
|
+
}
|
|
214
|
+
if (networkAddress) {
|
|
215
|
+
const result = await this.driver.zdoRequest(networkAddress, types_1.EmberZDOCmd.Mgmt_Permit_Joining_req, types_1.EmberZDOCmd.Mgmt_Permit_Joining_rsp, { duration: seconds, tcSignificant: false });
|
|
216
|
+
if (result.status !== types_1.EmberStatus.SUCCESS) {
|
|
217
|
+
throw new Error(`permitJoin for '${networkAddress}' failed`);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
else {
|
|
221
|
+
await this.driver.permitJoining(seconds);
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
async getCoordinatorVersion() {
|
|
226
|
+
return { type: `EZSP v${this.driver.version.product}`, meta: this.driver.version };
|
|
227
|
+
}
|
|
228
|
+
async addInstallCode(ieeeAddress, key) {
|
|
229
|
+
if ([8, 10, 14, 18].indexOf(key.length) === -1) {
|
|
230
|
+
throw new Error('Wrong install code length');
|
|
231
|
+
}
|
|
232
|
+
await this.driver.addInstallCode(ieeeAddress, key);
|
|
233
|
+
}
|
|
234
|
+
async reset(type) {
|
|
235
|
+
return Promise.reject(new Error("Not supported"));
|
|
236
|
+
}
|
|
237
|
+
async lqi(networkAddress) {
|
|
238
|
+
return this.driver.queue.execute(async () => {
|
|
239
|
+
this.checkInterpanLock();
|
|
240
|
+
const neighbors = [];
|
|
241
|
+
const request = async (startIndex) => {
|
|
242
|
+
const result = await this.driver.zdoRequest(networkAddress, types_1.EmberZDOCmd.Mgmt_Lqi_req, types_1.EmberZDOCmd.Mgmt_Lqi_rsp, { startindex: startIndex });
|
|
243
|
+
if (result.status !== types_1.EmberStatus.SUCCESS) {
|
|
244
|
+
throw new Error(`LQI for '${networkAddress}' failed with with status code ${result.status}`);
|
|
245
|
+
}
|
|
246
|
+
return result;
|
|
247
|
+
};
|
|
248
|
+
// eslint-disable-next-line
|
|
249
|
+
const add = (list) => {
|
|
250
|
+
for (const entry of list) {
|
|
251
|
+
this.driver.setNode(entry.nodeid, entry.ieee);
|
|
252
|
+
neighbors.push({
|
|
253
|
+
linkquality: entry.lqi,
|
|
254
|
+
networkAddress: entry.nodeid,
|
|
255
|
+
ieeeAddr: `0x${new types_1.EmberEUI64(entry.ieee).toString()}`,
|
|
256
|
+
relationship: (entry.packed >> 4) & 0x7,
|
|
257
|
+
depth: entry.depth,
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
};
|
|
261
|
+
let response = await request(0);
|
|
262
|
+
add(response.neighborlqilist.neighbors);
|
|
263
|
+
const size = response.neighborlqilist.entries;
|
|
264
|
+
let nextStartIndex = response.neighborlqilist.neighbors.length;
|
|
265
|
+
while (neighbors.length < size) {
|
|
266
|
+
response = await request(nextStartIndex);
|
|
267
|
+
add(response.neighborlqilist.neighbors);
|
|
268
|
+
nextStartIndex += response.neighborlqilist.neighbors.length;
|
|
269
|
+
}
|
|
270
|
+
return { neighbors };
|
|
271
|
+
}, networkAddress);
|
|
272
|
+
}
|
|
273
|
+
async routingTable(networkAddress) {
|
|
274
|
+
return this.driver.queue.execute(async () => {
|
|
275
|
+
this.checkInterpanLock();
|
|
276
|
+
const table = [];
|
|
277
|
+
const request = async (startIndex) => {
|
|
278
|
+
const result = await this.driver.zdoRequest(networkAddress, types_1.EmberZDOCmd.Mgmt_Rtg_req, types_1.EmberZDOCmd.Mgmt_Rtg_rsp, { startindex: startIndex });
|
|
279
|
+
if (result.status !== types_1.EmberStatus.SUCCESS) {
|
|
280
|
+
throw new Error(`Routing table for '${networkAddress}' failed with status code ${result.status}`);
|
|
281
|
+
}
|
|
282
|
+
return result;
|
|
283
|
+
};
|
|
284
|
+
// eslint-disable-next-line
|
|
285
|
+
const add = (list) => {
|
|
286
|
+
for (const entry of list) {
|
|
287
|
+
table.push({
|
|
288
|
+
destinationAddress: entry.destination,
|
|
289
|
+
status: entry.status,
|
|
290
|
+
nextHop: entry.nexthop
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
};
|
|
294
|
+
let response = await request(0);
|
|
295
|
+
add(response.routingtablelist.table);
|
|
296
|
+
const size = response.routingtablelist.entries;
|
|
297
|
+
let nextStartIndex = response.routingtablelist.table.length;
|
|
298
|
+
while (table.length < size) {
|
|
299
|
+
response = await request(nextStartIndex);
|
|
300
|
+
add(response.routingtablelist.table);
|
|
301
|
+
nextStartIndex += response.routingtablelist.table.length;
|
|
302
|
+
}
|
|
303
|
+
return { table };
|
|
304
|
+
}, networkAddress);
|
|
305
|
+
}
|
|
306
|
+
async nodeDescriptor(networkAddress) {
|
|
307
|
+
return this.driver.queue.execute(async () => {
|
|
308
|
+
this.checkInterpanLock();
|
|
309
|
+
try {
|
|
310
|
+
debug(`Requesting 'Node Descriptor' for '${networkAddress}'`);
|
|
311
|
+
const result = await this.nodeDescriptorInternal(networkAddress);
|
|
312
|
+
return result;
|
|
313
|
+
}
|
|
314
|
+
catch (error) {
|
|
315
|
+
debug(`Node descriptor request for '${networkAddress}' failed (${error}), retry`);
|
|
316
|
+
throw error;
|
|
317
|
+
}
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
async nodeDescriptorInternal(networkAddress) {
|
|
321
|
+
const descriptor = await this.driver.zdoRequest(networkAddress, types_1.EmberZDOCmd.Node_Desc_req, types_1.EmberZDOCmd.Node_Desc_rsp, { dstaddr: networkAddress });
|
|
322
|
+
const logicaltype = descriptor.descriptor.byte1 & 0x07;
|
|
323
|
+
return {
|
|
324
|
+
manufacturerCode: descriptor.descriptor.manufacturer_code,
|
|
325
|
+
type: (logicaltype == 0) ? 'Coordinator' : (logicaltype == 1) ? 'Router' : 'EndDevice'
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
async activeEndpoints(networkAddress) {
|
|
329
|
+
debug(`Requesting 'Active endpoints' for '${networkAddress}'`);
|
|
330
|
+
return this.driver.queue.execute(async () => {
|
|
331
|
+
const endpoints = await this.driver.zdoRequest(networkAddress, types_1.EmberZDOCmd.Active_EP_req, types_1.EmberZDOCmd.Active_EP_rsp, { dstaddr: networkAddress });
|
|
332
|
+
return { endpoints: [...endpoints.activeeplist] };
|
|
333
|
+
}, networkAddress);
|
|
334
|
+
}
|
|
335
|
+
async simpleDescriptor(networkAddress, endpointID) {
|
|
336
|
+
debug(`Requesting 'Simple Descriptor' for '${networkAddress}' endpoint ${endpointID}`);
|
|
337
|
+
return this.driver.queue.execute(async () => {
|
|
338
|
+
this.checkInterpanLock();
|
|
339
|
+
const descriptor = await this.driver.zdoRequest(networkAddress, types_1.EmberZDOCmd.Simple_Desc_req, types_1.EmberZDOCmd.Simple_Desc_rsp, { dstaddr: networkAddress, targetEp: endpointID });
|
|
340
|
+
return {
|
|
341
|
+
profileID: descriptor.descriptor.profileid,
|
|
342
|
+
endpointID: descriptor.descriptor.endpoint,
|
|
343
|
+
deviceID: descriptor.descriptor.deviceid,
|
|
344
|
+
inputClusters: descriptor.descriptor.inclusterlist,
|
|
345
|
+
outputClusters: descriptor.descriptor.outclusterlist,
|
|
346
|
+
};
|
|
347
|
+
}, networkAddress);
|
|
348
|
+
}
|
|
349
|
+
async sendZclFrameToEndpoint(ieeeAddr, networkAddress, endpoint, zclFrame, timeout, disableResponse, disableRecovery, sourceEndpoint) {
|
|
350
|
+
return this.driver.queue.execute(async () => {
|
|
351
|
+
this.checkInterpanLock();
|
|
352
|
+
return this.sendZclFrameToEndpointInternal(ieeeAddr, networkAddress, endpoint, sourceEndpoint || 1, zclFrame, timeout, disableResponse, disableRecovery, 0, 0, false, false, false, null);
|
|
353
|
+
}, networkAddress);
|
|
354
|
+
}
|
|
355
|
+
async sendZclFrameToEndpointInternal(ieeeAddr, networkAddress, endpoint, sourceEndpoint, zclFrame, timeout, disableResponse, disableRecovery, responseAttempt, dataRequestAttempt, checkedNetworkAddress, discoveredRoute, assocRemove, assocRestore) {
|
|
356
|
+
if (ieeeAddr == null) {
|
|
357
|
+
ieeeAddr = `0x${this.driver.ieee.toString()}`;
|
|
358
|
+
}
|
|
359
|
+
debug('sendZclFrameToEndpointInternal %s:%i/%i (%i,%i,%i)', ieeeAddr, networkAddress, endpoint, responseAttempt, dataRequestAttempt, this.driver.queue.count());
|
|
360
|
+
let response = null;
|
|
361
|
+
const command = zclFrame.getCommand();
|
|
362
|
+
if (command.hasOwnProperty('response') && disableResponse === false) {
|
|
363
|
+
response = this.waitForInternal(networkAddress, endpoint, zclFrame.Header.transactionSequenceNumber, zclFrame.Cluster.ID, command.response, timeout);
|
|
364
|
+
}
|
|
365
|
+
else if (!zclFrame.Header.frameControl.disableDefaultResponse) {
|
|
366
|
+
response = this.waitForInternal(networkAddress, endpoint, zclFrame.Header.transactionSequenceNumber, zclFrame.Cluster.ID, zcl_1.Foundation.defaultRsp.ID, timeout);
|
|
367
|
+
}
|
|
368
|
+
const frame = this.driver.makeApsFrame(zclFrame.Cluster.ID, disableResponse || zclFrame.Header.frameControl.disableDefaultResponse);
|
|
369
|
+
frame.profileId = 0x0104;
|
|
370
|
+
frame.sourceEndpoint = sourceEndpoint || 0x01;
|
|
371
|
+
frame.destinationEndpoint = endpoint;
|
|
372
|
+
frame.groupId = 0;
|
|
373
|
+
this.driver.setNode(networkAddress, new types_1.EmberEUI64(ieeeAddr));
|
|
374
|
+
const dataConfirmResult = await this.driver.request(networkAddress, frame, zclFrame.toBuffer());
|
|
375
|
+
if (!dataConfirmResult) {
|
|
376
|
+
if (response != null) {
|
|
377
|
+
response.cancel();
|
|
378
|
+
}
|
|
379
|
+
throw Error('sendZclFrameToEndpointInternal error');
|
|
380
|
+
}
|
|
381
|
+
if (response !== null) {
|
|
382
|
+
try {
|
|
383
|
+
const result = await response.start().promise;
|
|
384
|
+
return result;
|
|
385
|
+
}
|
|
386
|
+
catch (error) {
|
|
387
|
+
debug('Response timeout (%s:%d,%d)', ieeeAddr, networkAddress, responseAttempt);
|
|
388
|
+
if (responseAttempt < 1 && !disableRecovery) {
|
|
389
|
+
return this.sendZclFrameToEndpointInternal(ieeeAddr, networkAddress, endpoint, sourceEndpoint, zclFrame, timeout, disableResponse, disableRecovery, responseAttempt + 1, dataRequestAttempt, checkedNetworkAddress, discoveredRoute, assocRemove, assocRestore);
|
|
390
|
+
}
|
|
391
|
+
else {
|
|
392
|
+
throw error;
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
else {
|
|
397
|
+
return null;
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
async sendZclFrameToGroup(groupID, zclFrame) {
|
|
401
|
+
return this.driver.queue.execute(async () => {
|
|
402
|
+
this.checkInterpanLock();
|
|
403
|
+
const frame = this.driver.makeApsFrame(zclFrame.Cluster.ID, false);
|
|
404
|
+
frame.profileId = 0x0104;
|
|
405
|
+
frame.sourceEndpoint = 0x01;
|
|
406
|
+
frame.destinationEndpoint = 0x01;
|
|
407
|
+
frame.groupId = groupID;
|
|
408
|
+
const dataConfirmResult = await this.driver.mrequest(frame, zclFrame.toBuffer());
|
|
409
|
+
/**
|
|
410
|
+
* As a group command is not confirmed and thus immidiately returns
|
|
411
|
+
* (contrary to network address requests) we will give the
|
|
412
|
+
* command some time to 'settle' in the network.
|
|
413
|
+
*/
|
|
414
|
+
await (0, utils_1.Wait)(200);
|
|
415
|
+
});
|
|
416
|
+
}
|
|
417
|
+
async sendZclFrameToAll(endpoint, zclFrame, sourceEndpoint) {
|
|
418
|
+
return this.driver.queue.execute(async () => {
|
|
419
|
+
this.checkInterpanLock();
|
|
420
|
+
const frame = this.driver.makeApsFrame(zclFrame.Cluster.ID, false);
|
|
421
|
+
frame.profileId = sourceEndpoint === 242 && endpoint === 242 ? 0xA1E0 : 0x0104;
|
|
422
|
+
frame.sourceEndpoint = sourceEndpoint;
|
|
423
|
+
frame.destinationEndpoint = endpoint;
|
|
424
|
+
frame.groupId = 0xFFFD;
|
|
425
|
+
const dataConfirmResult = await this.driver.mrequest(frame, zclFrame.toBuffer());
|
|
426
|
+
/**
|
|
427
|
+
* As a broadcast command is not confirmed and thus immidiately returns
|
|
428
|
+
* (contrary to network address requests) we will give the
|
|
429
|
+
* command some time to 'settle' in the network.
|
|
430
|
+
*/
|
|
431
|
+
await (0, utils_1.Wait)(200);
|
|
432
|
+
});
|
|
433
|
+
}
|
|
434
|
+
async bind(destinationNetworkAddress, sourceIeeeAddress, sourceEndpoint, clusterID, destinationAddressOrGroup, type, destinationEndpoint) {
|
|
435
|
+
return this.driver.queue.execute(async () => {
|
|
436
|
+
this.checkInterpanLock();
|
|
437
|
+
const ieee = new types_1.EmberEUI64(sourceIeeeAddress);
|
|
438
|
+
const addrmode = (type === 'group') ? 1 : 3;
|
|
439
|
+
const ieeeDst = (type === 'group') ? destinationAddressOrGroup :
|
|
440
|
+
new types_1.EmberEUI64(destinationAddressOrGroup);
|
|
441
|
+
if (type !== 'group') {
|
|
442
|
+
this.driver.setNode(destinationNetworkAddress, ieeeDst);
|
|
443
|
+
}
|
|
444
|
+
await this.driver.zdoRequest(destinationNetworkAddress, types_1.EmberZDOCmd.Bind_req, types_1.EmberZDOCmd.Bind_rsp, { sourceEui: ieee, sourceEp: sourceEndpoint, clusterId: clusterID,
|
|
445
|
+
destAddr: { addrmode: addrmode, ieee: ieeeDst, endpoint: destinationEndpoint } });
|
|
446
|
+
}, destinationNetworkAddress);
|
|
447
|
+
}
|
|
448
|
+
async unbind(destinationNetworkAddress, sourceIeeeAddress, sourceEndpoint, clusterID, destinationAddressOrGroup, type, destinationEndpoint) {
|
|
449
|
+
return this.driver.queue.execute(async () => {
|
|
450
|
+
this.checkInterpanLock();
|
|
451
|
+
const ieee = new types_1.EmberEUI64(sourceIeeeAddress);
|
|
452
|
+
const addrmode = (type === 'group') ? 1 : 3;
|
|
453
|
+
const ieeeDst = (type === 'group') ? destinationAddressOrGroup :
|
|
454
|
+
new types_1.EmberEUI64(destinationAddressOrGroup);
|
|
455
|
+
if (type !== 'group') {
|
|
456
|
+
this.driver.setNode(destinationNetworkAddress, ieeeDst);
|
|
457
|
+
}
|
|
458
|
+
await this.driver.zdoRequest(destinationNetworkAddress, types_1.EmberZDOCmd.Unbind_req, types_1.EmberZDOCmd.Unbind_rsp, { sourceEui: ieee, sourceEp: sourceEndpoint, clusterId: clusterID,
|
|
459
|
+
destAddr: { addrmode: addrmode, ieee: ieeeDst, endpoint: destinationEndpoint } });
|
|
460
|
+
}, destinationNetworkAddress);
|
|
461
|
+
}
|
|
462
|
+
removeDevice(networkAddress, ieeeAddr) {
|
|
463
|
+
return this.driver.queue.execute(async () => {
|
|
464
|
+
this.checkInterpanLock();
|
|
465
|
+
const ieee = new types_1.EmberEUI64(ieeeAddr);
|
|
466
|
+
this.driver.setNode(networkAddress, ieee);
|
|
467
|
+
await this.driver.zdoRequest(networkAddress, types_1.EmberZDOCmd.Mgmt_Leave_req, types_1.EmberZDOCmd.Mgmt_Leave_rsp, { destAddr: ieee, removechildrenRejoin: 0x00 });
|
|
468
|
+
}, networkAddress);
|
|
469
|
+
}
|
|
470
|
+
async getNetworkParameters() {
|
|
471
|
+
return {
|
|
472
|
+
panID: this.driver.networkParams.panId,
|
|
473
|
+
extendedPanID: this.driver.networkParams.extendedPanId[0],
|
|
474
|
+
channel: this.driver.networkParams.radioChannel
|
|
475
|
+
};
|
|
476
|
+
}
|
|
477
|
+
async supportsBackup() {
|
|
478
|
+
return true;
|
|
479
|
+
}
|
|
480
|
+
async backup() {
|
|
481
|
+
return this.backupMan.createBackup();
|
|
482
|
+
}
|
|
483
|
+
async restoreChannelInterPAN() {
|
|
484
|
+
return this.driver.queue.execute(async () => {
|
|
485
|
+
const channel = (await this.getNetworkParameters()).channel;
|
|
486
|
+
await this.driver.setChannel(channel);
|
|
487
|
+
// Give adapter some time to restore, otherwise stuff crashes
|
|
488
|
+
await (0, utils_1.Wait)(3000);
|
|
489
|
+
this.interpanLock = false;
|
|
490
|
+
});
|
|
491
|
+
}
|
|
492
|
+
checkInterpanLock() {
|
|
493
|
+
if (this.interpanLock) {
|
|
494
|
+
throw new Error(`Cannot execute command, in Inter-PAN mode`);
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
async sendZclFrameInterPANToIeeeAddr(zclFrame, ieeeAddr) {
|
|
498
|
+
return this.driver.queue.execute(async () => {
|
|
499
|
+
debug(`sendZclFrameInterPANToIeeeAddr to ${ieeeAddr}`);
|
|
500
|
+
try {
|
|
501
|
+
const frame = this.driver.makeEmberIeeeRawFrame();
|
|
502
|
+
frame.ieeeFrameControl = 0xcc21;
|
|
503
|
+
frame.destPanId = 0xFFFF;
|
|
504
|
+
frame.destAddress = new types_1.EmberEUI64(ieeeAddr);
|
|
505
|
+
frame.sourcePanId = this.driver.networkParams.panId;
|
|
506
|
+
frame.sourceAddress = this.driver.ieee;
|
|
507
|
+
frame.nwkFrameControl = 0x000b;
|
|
508
|
+
frame.appFrameControl = 0x03;
|
|
509
|
+
frame.clusterId = zclFrame.Cluster.ID;
|
|
510
|
+
frame.profileId = 0xc05e;
|
|
511
|
+
const dataConfirmResult = await this.driver.ieeerawrequest(frame, zclFrame.toBuffer());
|
|
512
|
+
}
|
|
513
|
+
catch (error) {
|
|
514
|
+
throw error;
|
|
515
|
+
}
|
|
516
|
+
});
|
|
517
|
+
}
|
|
518
|
+
async sendZclFrameInterPANBroadcast(zclFrame, timeout) {
|
|
519
|
+
return this.driver.queue.execute(async () => {
|
|
520
|
+
debug(`sendZclFrameInterPANBroadcast`);
|
|
521
|
+
const command = zclFrame.getCommand();
|
|
522
|
+
if (!command.hasOwnProperty('response')) {
|
|
523
|
+
throw new Error(`Command '${command.name}' has no response, cannot wait for response`);
|
|
524
|
+
}
|
|
525
|
+
const response = this.waitForInternal(null, 0xFE, null, zclFrame.Cluster.ID, command.response, timeout);
|
|
526
|
+
try {
|
|
527
|
+
const frame = this.driver.makeEmberRawFrame();
|
|
528
|
+
frame.ieeeFrameControl = 0xc801;
|
|
529
|
+
frame.destPanId = 0xFFFF;
|
|
530
|
+
frame.destNodeId = 0xFFFF;
|
|
531
|
+
frame.sourcePanId = this.driver.networkParams.panId;
|
|
532
|
+
frame.ieeeAddress = this.driver.ieee;
|
|
533
|
+
frame.nwkFrameControl = 0x000b;
|
|
534
|
+
frame.appFrameControl = 0x0b;
|
|
535
|
+
frame.clusterId = zclFrame.Cluster.ID;
|
|
536
|
+
frame.profileId = 0xc05e;
|
|
537
|
+
const dataConfirmResult = await this.driver.rawrequest(frame, zclFrame.toBuffer());
|
|
538
|
+
}
|
|
539
|
+
catch (error) {
|
|
540
|
+
response.cancel();
|
|
541
|
+
throw error;
|
|
542
|
+
}
|
|
543
|
+
return response.start().promise;
|
|
544
|
+
});
|
|
545
|
+
}
|
|
546
|
+
async setTransmitPower(value) {
|
|
547
|
+
debug(`setTransmitPower to ${value}`);
|
|
548
|
+
return this.driver.queue.execute(async () => {
|
|
549
|
+
await this.driver.setRadioPower(value);
|
|
550
|
+
});
|
|
551
|
+
}
|
|
552
|
+
async setChannelInterPAN(channel) {
|
|
553
|
+
return this.driver.queue.execute(async () => {
|
|
554
|
+
this.interpanLock = true;
|
|
555
|
+
await this.driver.setChannel(channel);
|
|
556
|
+
});
|
|
557
|
+
}
|
|
558
|
+
waitForInternal(networkAddress, endpoint, transactionSequenceNumber, clusterID, commandIdentifier, timeout) {
|
|
559
|
+
const payload = {
|
|
560
|
+
address: networkAddress, endpoint, clusterID, commandIdentifier,
|
|
561
|
+
transactionSequenceNumber,
|
|
562
|
+
};
|
|
563
|
+
const waiter = this.waitress.waitFor(payload, timeout);
|
|
564
|
+
const cancel = () => this.waitress.remove(waiter.ID);
|
|
565
|
+
return { start: waiter.start, cancel };
|
|
566
|
+
}
|
|
567
|
+
waitFor(networkAddress, endpoint, frameType, direction, transactionSequenceNumber, clusterID, commandIdentifier, timeout) {
|
|
568
|
+
const waiter = this.waitForInternal(networkAddress, endpoint, transactionSequenceNumber, clusterID, commandIdentifier, timeout);
|
|
569
|
+
return { cancel: waiter.cancel, promise: waiter.start().promise };
|
|
570
|
+
}
|
|
571
|
+
waitressTimeoutFormatter(matcher, timeout) {
|
|
572
|
+
return `Timeout - ${matcher.address} - ${matcher.endpoint}` +
|
|
573
|
+
` - ${matcher.transactionSequenceNumber} - ${matcher.clusterID}` +
|
|
574
|
+
` - ${matcher.commandIdentifier} after ${timeout}ms`;
|
|
575
|
+
}
|
|
576
|
+
waitressValidator(payload, matcher) {
|
|
577
|
+
const transactionSequenceNumber = payload.frame.Header.transactionSequenceNumber;
|
|
578
|
+
return (!matcher.address || payload.address === matcher.address) &&
|
|
579
|
+
payload.endpoint === matcher.endpoint &&
|
|
580
|
+
(!matcher.transactionSequenceNumber || transactionSequenceNumber === matcher.transactionSequenceNumber) &&
|
|
581
|
+
payload.frame.Cluster.ID === matcher.clusterID &&
|
|
582
|
+
matcher.commandIdentifier === payload.frame.Header.commandIdentifier;
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
exports.default = EZSPAdapter;
|
|
586
586
|
//# sourceMappingURL=ezspAdapter.js.map
|