@willieee802/zigbee-herdsman 0.36.0 → 0.48.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/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +317 -0
- package/dist/adapter/adapter.d.ts +14 -13
- package/dist/adapter/adapter.d.ts.map +1 -1
- package/dist/adapter/adapter.js +15 -17
- package/dist/adapter/adapter.js.map +1 -1
- package/dist/adapter/deconz/adapter/deconzAdapter.d.ts +14 -12
- package/dist/adapter/deconz/adapter/deconzAdapter.d.ts.map +1 -1
- package/dist/adapter/deconz/adapter/deconzAdapter.js +118 -128
- package/dist/adapter/deconz/adapter/deconzAdapter.js.map +1 -1
- package/dist/adapter/deconz/driver/driver.d.ts.map +1 -1
- package/dist/adapter/deconz/driver/driver.js +44 -44
- package/dist/adapter/deconz/driver/driver.js.map +1 -1
- package/dist/adapter/deconz/driver/frameParser.js +43 -43
- package/dist/adapter/deconz/driver/frameParser.js.map +1 -1
- package/dist/adapter/deconz/driver/parser.js +6 -6
- package/dist/adapter/deconz/driver/parser.js.map +1 -1
- package/dist/adapter/deconz/driver/writer.js +3 -3
- package/dist/adapter/deconz/driver/writer.js.map +1 -1
- package/dist/adapter/ember/adapter/emberAdapter.d.ts +32 -36
- package/dist/adapter/ember/adapter/emberAdapter.d.ts.map +1 -1
- package/dist/adapter/ember/adapter/emberAdapter.js +418 -446
- package/dist/adapter/ember/adapter/emberAdapter.js.map +1 -1
- package/dist/adapter/ember/adapter/endpoints.d.ts +5 -3
- package/dist/adapter/ember/adapter/endpoints.d.ts.map +1 -1
- package/dist/adapter/ember/adapter/endpoints.js +33 -31
- package/dist/adapter/ember/adapter/endpoints.js.map +1 -1
- package/dist/adapter/ember/adapter/oneWaitress.d.ts +10 -2
- package/dist/adapter/ember/adapter/oneWaitress.d.ts.map +1 -1
- package/dist/adapter/ember/adapter/oneWaitress.js +19 -5
- package/dist/adapter/ember/adapter/oneWaitress.js.map +1 -1
- package/dist/adapter/ember/adapter/requestQueue.d.ts +2 -4
- package/dist/adapter/ember/adapter/requestQueue.d.ts.map +1 -1
- package/dist/adapter/ember/adapter/requestQueue.js +16 -21
- package/dist/adapter/ember/adapter/requestQueue.js.map +1 -1
- package/dist/adapter/ember/adapter/tokensManager.d.ts.map +1 -1
- package/dist/adapter/ember/adapter/tokensManager.js +23 -20
- package/dist/adapter/ember/adapter/tokensManager.js.map +1 -1
- package/dist/adapter/ember/consts.d.ts +0 -7
- package/dist/adapter/ember/consts.d.ts.map +1 -1
- package/dist/adapter/ember/consts.js +2 -9
- package/dist/adapter/ember/consts.js.map +1 -1
- package/dist/adapter/ember/enums.d.ts +12 -14
- package/dist/adapter/ember/enums.d.ts.map +1 -1
- package/dist/adapter/ember/enums.js +12 -14
- package/dist/adapter/ember/enums.js.map +1 -1
- package/dist/adapter/ember/ezsp/buffalo.js +4 -4
- package/dist/adapter/ember/ezsp/buffalo.js.map +1 -1
- package/dist/adapter/ember/ezsp/ezsp.d.ts +1 -2
- package/dist/adapter/ember/ezsp/ezsp.d.ts.map +1 -1
- package/dist/adapter/ember/ezsp/ezsp.js +218 -199
- package/dist/adapter/ember/ezsp/ezsp.js.map +1 -1
- package/dist/adapter/ember/types.d.ts +9 -9
- package/dist/adapter/ember/types.d.ts.map +1 -1
- package/dist/adapter/ember/uart/ash.d.ts +11 -5
- package/dist/adapter/ember/uart/ash.d.ts.map +1 -1
- package/dist/adapter/ember/uart/ash.js +125 -93
- package/dist/adapter/ember/uart/ash.js.map +1 -1
- package/dist/adapter/ember/uart/consts.d.ts +1 -1
- package/dist/adapter/ember/uart/consts.js +1 -1
- package/dist/adapter/ember/uart/parser.d.ts.map +1 -1
- package/dist/adapter/ember/uart/parser.js +5 -9
- package/dist/adapter/ember/uart/parser.js.map +1 -1
- package/dist/adapter/ember/uart/queues.d.ts.map +1 -1
- package/dist/adapter/ember/uart/queues.js +3 -1
- package/dist/adapter/ember/uart/queues.js.map +1 -1
- package/dist/adapter/ember/uart/writer.d.ts.map +1 -1
- package/dist/adapter/ember/uart/writer.js +4 -6
- package/dist/adapter/ember/uart/writer.js.map +1 -1
- package/dist/adapter/ember/zdo.d.ts +6 -2
- package/dist/adapter/ember/zdo.d.ts.map +1 -1
- package/dist/adapter/ember/zdo.js +2 -2
- package/dist/adapter/ember/zdo.js.map +1 -1
- package/dist/adapter/events.d.ts +17 -23
- package/dist/adapter/events.d.ts.map +1 -1
- package/dist/adapter/events.js +1 -2
- package/dist/adapter/events.js.map +1 -1
- package/dist/adapter/ezsp/adapter/backup.d.ts +0 -1
- package/dist/adapter/ezsp/adapter/backup.d.ts.map +1 -1
- package/dist/adapter/ezsp/adapter/backup.js +3 -7
- package/dist/adapter/ezsp/adapter/backup.js.map +1 -1
- package/dist/adapter/ezsp/adapter/ezspAdapter.d.ts +13 -10
- package/dist/adapter/ezsp/adapter/ezspAdapter.d.ts.map +1 -1
- package/dist/adapter/ezsp/adapter/ezspAdapter.js +79 -72
- package/dist/adapter/ezsp/adapter/ezspAdapter.js.map +1 -1
- package/dist/adapter/ezsp/driver/commands.d.ts.map +1 -1
- package/dist/adapter/ezsp/driver/commands.js +3 -5
- package/dist/adapter/ezsp/driver/commands.js.map +1 -1
- package/dist/adapter/ezsp/driver/driver.d.ts +1 -4
- package/dist/adapter/ezsp/driver/driver.d.ts.map +1 -1
- package/dist/adapter/ezsp/driver/driver.js +101 -122
- package/dist/adapter/ezsp/driver/driver.js.map +1 -1
- package/dist/adapter/ezsp/driver/ezsp.d.ts.map +1 -1
- package/dist/adapter/ezsp/driver/ezsp.js +61 -50
- package/dist/adapter/ezsp/driver/ezsp.js.map +1 -1
- package/dist/adapter/ezsp/driver/multicast.d.ts.map +1 -1
- package/dist/adapter/ezsp/driver/multicast.js +8 -12
- package/dist/adapter/ezsp/driver/multicast.js.map +1 -1
- package/dist/adapter/ezsp/driver/parser.js +5 -5
- package/dist/adapter/ezsp/driver/parser.js.map +1 -1
- package/dist/adapter/ezsp/driver/types/basic.js +1 -1
- package/dist/adapter/ezsp/driver/types/basic.js.map +1 -1
- package/dist/adapter/ezsp/driver/types/named.js +2 -2
- package/dist/adapter/ezsp/driver/types/named.js.map +1 -1
- package/dist/adapter/ezsp/driver/types/struct.js +2 -2
- package/dist/adapter/ezsp/driver/types/struct.js.map +1 -1
- package/dist/adapter/ezsp/driver/uart.d.ts.map +1 -1
- package/dist/adapter/ezsp/driver/uart.js +46 -46
- package/dist/adapter/ezsp/driver/uart.js.map +1 -1
- package/dist/adapter/ezsp/driver/writer.js +3 -6
- package/dist/adapter/ezsp/driver/writer.js.map +1 -1
- package/dist/adapter/z-stack/adapter/adapter-backup.d.ts +0 -1
- package/dist/adapter/z-stack/adapter/adapter-backup.d.ts.map +1 -1
- package/dist/adapter/z-stack/adapter/adapter-backup.js +25 -29
- package/dist/adapter/z-stack/adapter/adapter-backup.js.map +1 -1
- package/dist/adapter/z-stack/adapter/endpoints.js +4 -4
- package/dist/adapter/z-stack/adapter/endpoints.js.map +1 -1
- package/dist/adapter/z-stack/adapter/manager.d.ts +1 -4
- package/dist/adapter/z-stack/adapter/manager.d.ts.map +1 -1
- package/dist/adapter/z-stack/adapter/manager.js +52 -61
- package/dist/adapter/z-stack/adapter/manager.js.map +1 -1
- package/dist/adapter/z-stack/adapter/zStackAdapter.d.ts +12 -10
- package/dist/adapter/z-stack/adapter/zStackAdapter.d.ts.map +1 -1
- package/dist/adapter/z-stack/adapter/zStackAdapter.js +92 -68
- package/dist/adapter/z-stack/adapter/zStackAdapter.js.map +1 -1
- package/dist/adapter/z-stack/unpi/parser.js +6 -6
- package/dist/adapter/z-stack/unpi/parser.js.map +1 -1
- package/dist/adapter/z-stack/unpi/writer.js +4 -7
- package/dist/adapter/z-stack/unpi/writer.js.map +1 -1
- package/dist/adapter/z-stack/znp/buffaloZnp.d.ts +4 -2
- package/dist/adapter/z-stack/znp/buffaloZnp.d.ts.map +1 -1
- package/dist/adapter/z-stack/znp/buffaloZnp.js +154 -25
- package/dist/adapter/z-stack/znp/buffaloZnp.js.map +1 -1
- package/dist/adapter/z-stack/znp/definition.d.ts.map +1 -1
- package/dist/adapter/z-stack/znp/definition.js +2 -1
- package/dist/adapter/z-stack/znp/definition.js.map +1 -1
- package/dist/adapter/z-stack/znp/tstype.d.ts +4 -3
- package/dist/adapter/z-stack/znp/tstype.d.ts.map +1 -1
- package/dist/adapter/z-stack/znp/znp.d.ts.map +1 -1
- package/dist/adapter/z-stack/znp/znp.js +18 -25
- package/dist/adapter/z-stack/znp/znp.js.map +1 -1
- package/dist/adapter/z-stack/znp/zpiObject.js +2 -2
- package/dist/adapter/z-stack/znp/zpiObject.js.map +1 -1
- package/dist/adapter/zigate/adapter/zigateAdapter.d.ts +13 -12
- package/dist/adapter/zigate/adapter/zigateAdapter.d.ts.map +1 -1
- package/dist/adapter/zigate/adapter/zigateAdapter.js +81 -90
- package/dist/adapter/zigate/adapter/zigateAdapter.js.map +1 -1
- package/dist/adapter/zigate/driver/buffaloZiGate.d.ts +7 -8
- package/dist/adapter/zigate/driver/buffaloZiGate.d.ts.map +1 -1
- package/dist/adapter/zigate/driver/buffaloZiGate.js +150 -100
- package/dist/adapter/zigate/driver/buffaloZiGate.js.map +1 -1
- package/dist/adapter/zigate/driver/commandType.d.ts +2 -1
- package/dist/adapter/zigate/driver/commandType.d.ts.map +1 -1
- package/dist/adapter/zigate/driver/commandType.js +56 -52
- package/dist/adapter/zigate/driver/commandType.js.map +1 -1
- package/dist/adapter/zigate/driver/frame.d.ts.map +1 -1
- package/dist/adapter/zigate/driver/frame.js +8 -8
- package/dist/adapter/zigate/driver/frame.js.map +1 -1
- package/dist/adapter/zigate/driver/messageType.d.ts +2 -1
- package/dist/adapter/zigate/driver/messageType.d.ts.map +1 -1
- package/dist/adapter/zigate/driver/messageType.js +113 -108
- package/dist/adapter/zigate/driver/messageType.js.map +1 -1
- package/dist/adapter/zigate/driver/parameterType.d.ts +8 -1
- package/dist/adapter/zigate/driver/parameterType.d.ts.map +1 -1
- package/dist/adapter/zigate/driver/parameterType.js +9 -0
- package/dist/adapter/zigate/driver/parameterType.js.map +1 -1
- package/dist/adapter/zigate/driver/ziGateObject.d.ts.map +1 -1
- package/dist/adapter/zigate/driver/ziGateObject.js +9 -9
- package/dist/adapter/zigate/driver/ziGateObject.js.map +1 -1
- package/dist/adapter/zigate/driver/zigate.d.ts.map +1 -1
- package/dist/adapter/zigate/driver/zigate.js +23 -31
- package/dist/adapter/zigate/driver/zigate.js.map +1 -1
- package/dist/buffalo/buffalo.d.ts +23 -19
- package/dist/buffalo/buffalo.d.ts.map +1 -1
- package/dist/buffalo/buffalo.js +74 -169
- package/dist/buffalo/buffalo.js.map +1 -1
- package/dist/buffalo/index.d.ts +1 -2
- package/dist/buffalo/index.d.ts.map +1 -1
- package/dist/buffalo/index.js +1 -26
- package/dist/buffalo/index.js.map +1 -1
- package/dist/controller/controller.d.ts +8 -5
- package/dist/controller/controller.d.ts.map +1 -1
- package/dist/controller/controller.js +181 -126
- package/dist/controller/controller.js.map +1 -1
- package/dist/controller/database.d.ts +1 -0
- package/dist/controller/database.d.ts.map +1 -1
- package/dist/controller/database.js +7 -10
- package/dist/controller/database.js.map +1 -1
- package/dist/controller/events.d.ts +2 -2
- package/dist/controller/events.d.ts.map +1 -1
- package/dist/controller/events.js +4 -0
- package/dist/controller/events.js.map +1 -1
- package/dist/controller/greenPower.d.ts +2 -1
- package/dist/controller/greenPower.d.ts.map +1 -1
- package/dist/controller/greenPower.js +51 -57
- package/dist/controller/greenPower.js.map +1 -1
- package/dist/controller/helpers/request.d.ts +3 -3
- package/dist/controller/helpers/request.d.ts.map +1 -1
- package/dist/controller/helpers/request.js +2 -2
- package/dist/controller/helpers/request.js.map +1 -1
- package/dist/controller/helpers/requestQueue.d.ts.map +1 -1
- package/dist/controller/helpers/requestQueue.js +26 -36
- package/dist/controller/helpers/requestQueue.js.map +1 -1
- package/dist/controller/helpers/zclFrameConverter.d.ts +4 -3
- package/dist/controller/helpers/zclFrameConverter.d.ts.map +1 -1
- package/dist/controller/helpers/zclFrameConverter.js +33 -14
- package/dist/controller/helpers/zclFrameConverter.js.map +1 -1
- package/dist/controller/model/device.d.ts +12 -5
- package/dist/controller/model/device.d.ts.map +1 -1
- package/dist/controller/model/device.js +105 -86
- package/dist/controller/model/device.js.map +1 -1
- package/dist/controller/model/endpoint.d.ts +22 -17
- package/dist/controller/model/endpoint.d.ts.map +1 -1
- package/dist/controller/model/endpoint.js +139 -228
- package/dist/controller/model/endpoint.js.map +1 -1
- package/dist/controller/model/group.d.ts +1 -1
- package/dist/controller/model/group.d.ts.map +1 -1
- package/dist/controller/model/group.js +18 -18
- package/dist/controller/model/group.js.map +1 -1
- package/dist/controller/touchlink.js +25 -28
- package/dist/controller/touchlink.js.map +1 -1
- package/dist/index.d.ts +5 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -5
- package/dist/index.js.map +1 -1
- package/dist/utils/logger.d.ts +9 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +14 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/zspec/consts.d.ts +60 -0
- package/dist/zspec/consts.d.ts.map +1 -0
- package/dist/zspec/consts.js +64 -0
- package/dist/zspec/consts.js.map +1 -0
- package/dist/zspec/enums.d.ts +19 -0
- package/dist/zspec/enums.d.ts.map +1 -0
- package/dist/zspec/enums.js +28 -0
- package/dist/zspec/enums.js.map +1 -0
- package/dist/zspec/index.d.ts +4 -0
- package/dist/zspec/index.d.ts.map +1 -0
- package/dist/zspec/index.js +43 -0
- package/dist/zspec/index.js.map +1 -0
- package/dist/zspec/tstypes.d.ts +19 -0
- package/dist/zspec/tstypes.d.ts.map +1 -0
- package/dist/{buffalo/tstype.js → zspec/tstypes.js} +1 -1
- package/dist/zspec/tstypes.js.map +1 -0
- package/dist/zspec/utils.d.ts +14 -0
- package/dist/zspec/utils.d.ts.map +1 -0
- package/dist/zspec/utils.js +29 -0
- package/dist/zspec/utils.js.map +1 -0
- package/dist/zspec/zcl/buffaloZcl.d.ts +55 -0
- package/dist/zspec/zcl/buffaloZcl.d.ts.map +1 -0
- package/dist/zspec/zcl/buffaloZcl.js +929 -0
- package/dist/zspec/zcl/buffaloZcl.js.map +1 -0
- package/dist/zspec/zcl/definition/cluster.d.ts +3 -0
- package/dist/zspec/zcl/definition/cluster.d.ts.map +1 -0
- package/dist/zspec/zcl/definition/cluster.js +5500 -0
- package/dist/zspec/zcl/definition/cluster.js.map +1 -0
- package/dist/zspec/zcl/definition/consts.d.ts +9 -0
- package/dist/zspec/zcl/definition/consts.d.ts.map +1 -0
- package/dist/zspec/zcl/definition/consts.js +27 -0
- package/dist/zspec/zcl/definition/consts.js.map +1 -0
- package/dist/zspec/zcl/definition/enums.d.ts +177 -0
- package/dist/zspec/zcl/definition/enums.d.ts.map +1 -0
- package/dist/zspec/zcl/definition/enums.js +187 -0
- package/dist/zspec/zcl/definition/enums.js.map +1 -0
- package/dist/zspec/zcl/definition/foundation.d.ts +11 -0
- package/dist/zspec/zcl/definition/foundation.d.ts.map +1 -0
- package/dist/zspec/zcl/definition/foundation.js +241 -0
- package/dist/zspec/zcl/definition/foundation.js.map +1 -0
- package/dist/zspec/zcl/definition/manufacturerCode.d.ts +727 -0
- package/dist/zspec/zcl/definition/manufacturerCode.d.ts.map +1 -0
- package/dist/zspec/zcl/definition/manufacturerCode.js +733 -0
- package/dist/zspec/zcl/definition/manufacturerCode.js.map +1 -0
- package/dist/zspec/zcl/definition/status.d.ts +69 -0
- package/dist/zspec/zcl/definition/status.d.ts.map +1 -0
- package/dist/zspec/zcl/definition/status.js +74 -0
- package/dist/zspec/zcl/definition/status.js.map +1 -0
- package/dist/zspec/zcl/definition/tstype.d.ts +114 -0
- package/dist/zspec/zcl/definition/tstype.d.ts.map +1 -0
- package/dist/{zcl/zclHeader.js → zspec/zcl/definition/tstype.js} +2 -1
- package/dist/zspec/zcl/definition/tstype.js.map +1 -0
- package/dist/zspec/zcl/index.d.ts +11 -0
- package/dist/zspec/zcl/index.d.ts.map +1 -0
- package/dist/zspec/zcl/index.js +47 -0
- package/dist/zspec/zcl/index.js.map +1 -0
- package/dist/zspec/zcl/utils.d.ts +7 -0
- package/dist/zspec/zcl/utils.d.ts.map +1 -0
- package/dist/zspec/zcl/utils.js +234 -0
- package/dist/zspec/zcl/utils.js.map +1 -0
- package/dist/zspec/zcl/zclFrame.d.ts +36 -0
- package/dist/zspec/zcl/zclFrame.d.ts.map +1 -0
- package/dist/zspec/zcl/zclFrame.js +304 -0
- package/dist/zspec/zcl/zclFrame.js.map +1 -0
- package/dist/zspec/zcl/zclHeader.d.ts +17 -0
- package/dist/zspec/zcl/zclHeader.d.ts.map +1 -0
- package/dist/zspec/zcl/zclHeader.js +88 -0
- package/dist/zspec/zcl/zclHeader.js.map +1 -0
- package/dist/zspec/zcl/zclStatusError.d.ts +6 -0
- package/dist/zspec/zcl/zclStatusError.d.ts.map +1 -0
- package/dist/zspec/zcl/zclStatusError.js +13 -0
- package/dist/zspec/zcl/zclStatusError.js.map +1 -0
- package/dist/zspec/zdo/buffaloZdo.d.ts +438 -0
- package/dist/zspec/zdo/buffaloZdo.d.ts.map +1 -0
- package/dist/zspec/zdo/buffaloZdo.js +1892 -0
- package/dist/zspec/zdo/buffaloZdo.js.map +1 -0
- package/dist/zspec/zdo/definition/clusters.d.ts +624 -0
- package/dist/zspec/zdo/definition/clusters.d.ts.map +1 -0
- package/dist/zspec/zdo/definition/clusters.js +687 -0
- package/dist/zspec/zdo/definition/clusters.js.map +1 -0
- package/dist/zspec/zdo/definition/consts.d.ts +13 -0
- package/dist/zspec/zdo/definition/consts.d.ts.map +1 -0
- package/dist/zspec/zdo/definition/consts.js +16 -0
- package/dist/zspec/zdo/definition/consts.js.map +1 -0
- package/dist/zspec/zdo/definition/enums.d.ts +75 -0
- package/dist/zspec/zdo/definition/enums.d.ts.map +1 -0
- package/dist/zspec/zdo/definition/enums.js +97 -0
- package/dist/zspec/zdo/definition/enums.js.map +1 -0
- package/dist/zspec/zdo/definition/status.d.ts +99 -0
- package/dist/zspec/zdo/definition/status.d.ts.map +1 -0
- package/dist/zspec/zdo/definition/status.js +109 -0
- package/dist/zspec/zdo/definition/status.js.map +1 -0
- package/dist/zspec/zdo/definition/tstypes.d.ts +787 -0
- package/dist/zspec/zdo/definition/tstypes.d.ts.map +1 -0
- package/dist/{zcl/definition/tstype.js → zspec/zdo/definition/tstypes.js} +1 -1
- package/dist/zspec/zdo/definition/tstypes.js.map +1 -0
- package/dist/zspec/zdo/index.d.ts +7 -0
- package/dist/zspec/zdo/index.d.ts.map +1 -0
- package/dist/zspec/zdo/index.js +39 -0
- package/dist/zspec/zdo/index.js.map +1 -0
- package/dist/zspec/zdo/utils.d.ts +25 -0
- package/dist/zspec/zdo/utils.d.ts.map +1 -0
- package/dist/zspec/zdo/utils.js +75 -0
- package/dist/zspec/zdo/utils.js.map +1 -0
- package/dist/zspec/zdo/zdoStatusError.d.ts +6 -0
- package/dist/zspec/zdo/zdoStatusError.d.ts.map +1 -0
- package/dist/zspec/zdo/zdoStatusError.js +13 -0
- package/dist/zspec/zdo/zdoStatusError.js.map +1 -0
- package/examples/join-and-log.js +7 -12
- package/package.json +5 -5
- package/dist/adapter/zigate/debug.d.ts +0 -8
- package/dist/adapter/zigate/debug.d.ts.map +0 -1
- package/dist/adapter/zigate/debug.js +0 -20
- package/dist/adapter/zigate/debug.js.map +0 -1
- package/dist/buffalo/tstype.d.ts +0 -9
- package/dist/buffalo/tstype.d.ts.map +0 -1
- package/dist/buffalo/tstype.js.map +0 -1
- package/dist/controller/logger-stub.d.ts +0 -7
- package/dist/controller/logger-stub.d.ts.map +0 -1
- package/dist/controller/logger-stub.js +0 -3
- package/dist/controller/logger-stub.js.map +0 -1
- package/dist/zcl/buffaloZcl.d.ts +0 -42
- package/dist/zcl/buffaloZcl.d.ts.map +0 -1
- package/dist/zcl/buffaloZcl.js +0 -595
- package/dist/zcl/buffaloZcl.js.map +0 -1
- package/dist/zcl/definition/buffaloZclDataType.d.ts +0 -18
- package/dist/zcl/definition/buffaloZclDataType.d.ts.map +0 -1
- package/dist/zcl/definition/buffaloZclDataType.js +0 -21
- package/dist/zcl/definition/buffaloZclDataType.js.map +0 -1
- package/dist/zcl/definition/cluster.d.ts +0 -30
- package/dist/zcl/definition/cluster.d.ts.map +0 -1
- package/dist/zcl/definition/cluster.js +0 -5531
- package/dist/zcl/definition/cluster.js.map +0 -1
- package/dist/zcl/definition/dataType.d.ts +0 -60
- package/dist/zcl/definition/dataType.d.ts.map +0 -1
- package/dist/zcl/definition/dataType.js +0 -65
- package/dist/zcl/definition/dataType.js.map +0 -1
- package/dist/zcl/definition/direction.d.ts +0 -6
- package/dist/zcl/definition/direction.d.ts.map +0 -1
- package/dist/zcl/definition/direction.js +0 -9
- package/dist/zcl/definition/direction.js.map +0 -1
- package/dist/zcl/definition/endpointDeviceType.d.ts +0 -5
- package/dist/zcl/definition/endpointDeviceType.d.ts.map +0 -1
- package/dist/zcl/definition/endpointDeviceType.js +0 -16
- package/dist/zcl/definition/endpointDeviceType.js.map +0 -1
- package/dist/zcl/definition/foundation.d.ts +0 -12
- package/dist/zcl/definition/foundation.d.ts.map +0 -1
- package/dist/zcl/definition/foundation.js +0 -168
- package/dist/zcl/definition/foundation.js.map +0 -1
- package/dist/zcl/definition/frameControl.d.ts +0 -11
- package/dist/zcl/definition/frameControl.d.ts.map +0 -1
- package/dist/zcl/definition/frameControl.js +0 -3
- package/dist/zcl/definition/frameControl.js.map +0 -1
- package/dist/zcl/definition/frameType.d.ts +0 -6
- package/dist/zcl/definition/frameType.d.ts.map +0 -1
- package/dist/zcl/definition/frameType.js +0 -9
- package/dist/zcl/definition/frameType.js.map +0 -1
- package/dist/zcl/definition/index.d.ts +0 -14
- package/dist/zcl/definition/index.d.ts.map +0 -1
- package/dist/zcl/definition/index.js +0 -52
- package/dist/zcl/definition/index.js.map +0 -1
- package/dist/zcl/definition/manufacturerCode.d.ts +0 -1078
- package/dist/zcl/definition/manufacturerCode.d.ts.map +0 -1
- package/dist/zcl/definition/manufacturerCode.js +0 -1083
- package/dist/zcl/definition/manufacturerCode.js.map +0 -1
- package/dist/zcl/definition/powerSource.d.ts +0 -5
- package/dist/zcl/definition/powerSource.d.ts.map +0 -1
- package/dist/zcl/definition/powerSource.js +0 -13
- package/dist/zcl/definition/powerSource.js.map +0 -1
- package/dist/zcl/definition/status.d.ts +0 -39
- package/dist/zcl/definition/status.d.ts.map +0 -1
- package/dist/zcl/definition/status.js +0 -42
- package/dist/zcl/definition/status.js.map +0 -1
- package/dist/zcl/definition/tstype.d.ts +0 -17
- package/dist/zcl/definition/tstype.d.ts.map +0 -1
- package/dist/zcl/definition/tstype.js.map +0 -1
- package/dist/zcl/index.d.ts +0 -17
- package/dist/zcl/index.d.ts.map +0 -1
- package/dist/zcl/index.js +0 -56
- package/dist/zcl/index.js.map +0 -1
- package/dist/zcl/tstype.d.ts +0 -57
- package/dist/zcl/tstype.d.ts.map +0 -1
- package/dist/zcl/tstype.js +0 -10
- package/dist/zcl/tstype.js.map +0 -1
- package/dist/zcl/utils.d.ts +0 -7
- package/dist/zcl/utils.d.ts.map +0 -1
- package/dist/zcl/utils.js +0 -165
- package/dist/zcl/utils.js.map +0 -1
- package/dist/zcl/zclFrame.d.ts +0 -41
- package/dist/zcl/zclFrame.d.ts.map +0 -1
- package/dist/zcl/zclFrame.js +0 -352
- package/dist/zcl/zclFrame.js.map +0 -1
- package/dist/zcl/zclHeader.d.ts +0 -9
- package/dist/zcl/zclHeader.d.ts.map +0 -1
- package/dist/zcl/zclHeader.js.map +0 -1
- package/dist/zcl/zclStatusError.d.ts +0 -6
- package/dist/zcl/zclStatusError.d.ts.map +0 -1
- package/dist/zcl/zclStatusError.js +0 -15
- package/dist/zcl/zclStatusError.js.map +0 -1
|
@@ -0,0 +1,1892 @@
|
|
|
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
|
+
exports.BuffaloZdo = void 0;
|
|
30
|
+
const buffalo_1 = __importDefault(require("../../buffalo/buffalo"));
|
|
31
|
+
const status_1 = require("./definition/status");
|
|
32
|
+
const zdoStatusError_1 = require("./zdoStatusError");
|
|
33
|
+
const enums_1 = require("./definition/enums");
|
|
34
|
+
const consts_1 = require("./definition/consts");
|
|
35
|
+
const logger_1 = require("../../utils/logger");
|
|
36
|
+
const consts_2 = require("../consts");
|
|
37
|
+
const Utils = __importStar(require("./utils"));
|
|
38
|
+
const ZSpecUtils = __importStar(require("../utils"));
|
|
39
|
+
const clusters_1 = require("./definition/clusters");
|
|
40
|
+
const NS = 'zh:zdo:buffalo';
|
|
41
|
+
const MAX_BUFFER_SIZE = 255;
|
|
42
|
+
class BuffaloZdo extends buffalo_1.default {
|
|
43
|
+
/**
|
|
44
|
+
* Set the position of the internal position tracker.
|
|
45
|
+
* TODO: move to base `Buffalo` class
|
|
46
|
+
* @param position
|
|
47
|
+
*/
|
|
48
|
+
setPosition(position) {
|
|
49
|
+
this.position = position;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Set the byte at given position without affecting the internal position tracker.
|
|
53
|
+
* TODO: move to base `Buffalo` class
|
|
54
|
+
* @param position
|
|
55
|
+
* @param value
|
|
56
|
+
*/
|
|
57
|
+
setByte(position, value) {
|
|
58
|
+
this.buffer.writeUInt8(value, position);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Get the byte at given position without affecting the internal position tracker.
|
|
62
|
+
* TODO: move to base `Buffalo` class
|
|
63
|
+
* @param position
|
|
64
|
+
* @returns
|
|
65
|
+
*/
|
|
66
|
+
getByte(position) {
|
|
67
|
+
return this.buffer.readUInt8(position);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Check if internal buffer has enough bytes to satisfy: (current position + given count).
|
|
71
|
+
* TODO: move to base `Buffalo` class
|
|
72
|
+
* @param count
|
|
73
|
+
* @returns True if has given more bytes
|
|
74
|
+
*/
|
|
75
|
+
isMoreBy(count) {
|
|
76
|
+
return (this.position + count) <= this.buffer.length;
|
|
77
|
+
}
|
|
78
|
+
//-- GLOBAL TLVS
|
|
79
|
+
writeManufacturerSpecificGlobalTLV(tlv) {
|
|
80
|
+
this.writeUInt16(tlv.zigbeeManufacturerId);
|
|
81
|
+
this.writeBuffer(tlv.additionalData, tlv.additionalData.length);
|
|
82
|
+
}
|
|
83
|
+
readManufacturerSpecificGlobalTLV(length) {
|
|
84
|
+
logger_1.logger.debug(`readManufacturerSpecificGlobalTLV with length=${length}`, NS);
|
|
85
|
+
if (length < 2) {
|
|
86
|
+
throw new Error(`Malformed TLV. Invalid length '${length}', expected at least 2.`);
|
|
87
|
+
}
|
|
88
|
+
const zigbeeManufacturerId = this.readUInt16();
|
|
89
|
+
const additionalData = this.readBuffer(length - 2);
|
|
90
|
+
return {
|
|
91
|
+
zigbeeManufacturerId,
|
|
92
|
+
additionalData,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
writeSupportedKeyNegotiationMethodsGlobalTLV(tlv) {
|
|
96
|
+
this.writeUInt8(tlv.keyNegotiationProtocolsBitmask);
|
|
97
|
+
this.writeUInt8(tlv.preSharedSecretsBitmask);
|
|
98
|
+
if (tlv.sourceDeviceEui64) {
|
|
99
|
+
this.writeIeeeAddr(tlv.sourceDeviceEui64);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
readSupportedKeyNegotiationMethodsGlobalTLV(length) {
|
|
103
|
+
logger_1.logger.debug(`readSupportedKeyNegotiationMethodsGlobalTLV with length=${length}`, NS);
|
|
104
|
+
if (length < 2) {
|
|
105
|
+
throw new Error(`Malformed TLV. Invalid length '${length}', expected at least 2.`);
|
|
106
|
+
}
|
|
107
|
+
const keyNegotiationProtocolsBitmask = this.readUInt8();
|
|
108
|
+
const preSharedSecretsBitmask = this.readUInt8();
|
|
109
|
+
let sourceDeviceEui64;
|
|
110
|
+
if (length >= (2 + consts_2.EUI64_SIZE)) {
|
|
111
|
+
sourceDeviceEui64 = this.readIeeeAddr();
|
|
112
|
+
}
|
|
113
|
+
return {
|
|
114
|
+
keyNegotiationProtocolsBitmask,
|
|
115
|
+
preSharedSecretsBitmask,
|
|
116
|
+
sourceDeviceEui64,
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
writePanIdConflictReportGlobalTLV(tlv) {
|
|
120
|
+
this.writeUInt16(tlv.nwkPanIdConflictCount);
|
|
121
|
+
}
|
|
122
|
+
readPanIdConflictReportGlobalTLV(length) {
|
|
123
|
+
logger_1.logger.debug(`readPanIdConflictReportGlobalTLV with length=${length}`, NS);
|
|
124
|
+
if (length < 2) {
|
|
125
|
+
throw new Error(`Malformed TLV. Invalid length '${length}', expected at least 2.`);
|
|
126
|
+
}
|
|
127
|
+
const nwkPanIdConflictCount = this.readUInt16();
|
|
128
|
+
return {
|
|
129
|
+
nwkPanIdConflictCount,
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
writeNextPanIdChangeGlobalTLV(tlv) {
|
|
133
|
+
this.writeUInt16(tlv.panId);
|
|
134
|
+
}
|
|
135
|
+
readNextPanIdChangeGlobalTLV(length) {
|
|
136
|
+
logger_1.logger.debug(`readNextPanIdChangeGlobalTLV with length=${length}`, NS);
|
|
137
|
+
if (length < consts_2.PAN_ID_SIZE) {
|
|
138
|
+
throw new Error(`Malformed TLV. Invalid length '${length}', expected at least ${consts_2.PAN_ID_SIZE}.`);
|
|
139
|
+
}
|
|
140
|
+
const panId = this.readUInt16();
|
|
141
|
+
return {
|
|
142
|
+
panId,
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
writeNextChannelChangeGlobalTLV(tlv) {
|
|
146
|
+
this.writeUInt32(tlv.channel);
|
|
147
|
+
}
|
|
148
|
+
readNextChannelChangeGlobalTLV(length) {
|
|
149
|
+
logger_1.logger.debug(`readNextChannelChangeGlobalTLV with length=${length}`, NS);
|
|
150
|
+
if (length < 4) {
|
|
151
|
+
throw new Error(`Malformed TLV. Invalid length '${length}', expected at least 4.`);
|
|
152
|
+
}
|
|
153
|
+
const channel = this.readUInt32();
|
|
154
|
+
return {
|
|
155
|
+
channel,
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
writeSymmetricPassphraseGlobalTLV(tlv) {
|
|
159
|
+
this.writeBuffer(tlv.passphrase, consts_2.DEFAULT_ENCRYPTION_KEY_SIZE);
|
|
160
|
+
}
|
|
161
|
+
readSymmetricPassphraseGlobalTLV(length) {
|
|
162
|
+
logger_1.logger.debug(`readSymmetricPassphraseGlobalTLV with length=${length}`, NS);
|
|
163
|
+
if (length < consts_2.DEFAULT_ENCRYPTION_KEY_SIZE) {
|
|
164
|
+
throw new Error(`Malformed TLV. Invalid length '${length}', expected at least ${consts_2.DEFAULT_ENCRYPTION_KEY_SIZE}.`);
|
|
165
|
+
}
|
|
166
|
+
const passphrase = this.readBuffer(consts_2.DEFAULT_ENCRYPTION_KEY_SIZE);
|
|
167
|
+
return {
|
|
168
|
+
passphrase,
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
writeRouterInformationGlobalTLV(tlv) {
|
|
172
|
+
this.writeUInt16(tlv.bitmask);
|
|
173
|
+
}
|
|
174
|
+
readRouterInformationGlobalTLV(length) {
|
|
175
|
+
logger_1.logger.debug(`readRouterInformationGlobalTLV with length=${length}`, NS);
|
|
176
|
+
if (length < 2) {
|
|
177
|
+
throw new Error(`Malformed TLV. Invalid length '${length}', expected at least 2.`);
|
|
178
|
+
}
|
|
179
|
+
const bitmask = this.readUInt16();
|
|
180
|
+
return {
|
|
181
|
+
bitmask,
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
writeFragmentationParametersGlobalTLV(tlv) {
|
|
185
|
+
this.writeUInt16(tlv.nwkAddress);
|
|
186
|
+
if (tlv.fragmentationOptions != undefined) {
|
|
187
|
+
this.writeUInt8(tlv.fragmentationOptions);
|
|
188
|
+
}
|
|
189
|
+
if (tlv.maxIncomingTransferUnit != undefined) {
|
|
190
|
+
this.writeUInt16(tlv.maxIncomingTransferUnit);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
readFragmentationParametersGlobalTLV(length) {
|
|
194
|
+
logger_1.logger.debug(`readFragmentationParametersGlobalTLV with length=${length}`, NS);
|
|
195
|
+
if (length < 2) {
|
|
196
|
+
throw new Error(`Malformed TLV. Invalid length '${length}', expected at least 2.`);
|
|
197
|
+
}
|
|
198
|
+
const nwkAddress = this.readUInt16();
|
|
199
|
+
let fragmentationOptions;
|
|
200
|
+
let maxIncomingTransferUnit;
|
|
201
|
+
if (length >= 3) {
|
|
202
|
+
fragmentationOptions = this.readUInt8();
|
|
203
|
+
}
|
|
204
|
+
if (length >= 5) {
|
|
205
|
+
maxIncomingTransferUnit = this.readUInt16();
|
|
206
|
+
}
|
|
207
|
+
return {
|
|
208
|
+
nwkAddress,
|
|
209
|
+
fragmentationOptions,
|
|
210
|
+
maxIncomingTransferUnit,
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
writeJoinerEncapsulationGlobalTLV(encapsulationTLV) {
|
|
214
|
+
this.writeGlobalTLVs(encapsulationTLV.additionalTLVs);
|
|
215
|
+
}
|
|
216
|
+
readJoinerEncapsulationGlobalTLV(length) {
|
|
217
|
+
logger_1.logger.debug(`readJoinerEncapsulationGlobalTLV with length=${length}`, NS);
|
|
218
|
+
// at least the length of tagId+length for first encapsulated tlv, doesn't make sense otherwise
|
|
219
|
+
if (length < 2) {
|
|
220
|
+
throw new Error(`Malformed TLV. Invalid length '${length}', expected at least 2.`);
|
|
221
|
+
}
|
|
222
|
+
const encapsulationBuffalo = new BuffaloZdo(this.readBuffer(length));
|
|
223
|
+
const additionalTLVs = encapsulationBuffalo.readTLVs(null, true);
|
|
224
|
+
return {
|
|
225
|
+
additionalTLVs,
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
writeBeaconAppendixEncapsulationGlobalTLV(encapsulationTLV) {
|
|
229
|
+
this.writeGlobalTLVs(encapsulationTLV.additionalTLVs);
|
|
230
|
+
}
|
|
231
|
+
readBeaconAppendixEncapsulationGlobalTLV(length) {
|
|
232
|
+
logger_1.logger.debug(`readBeaconAppendixEncapsulationGlobalTLV with length=${length}`, NS);
|
|
233
|
+
// at least the length of tagId+length for first encapsulated tlv, doesn't make sense otherwise
|
|
234
|
+
if (length < 2) {
|
|
235
|
+
throw new Error(`Malformed TLV. Invalid length '${length}', expected at least 2.`);
|
|
236
|
+
}
|
|
237
|
+
const encapsulationBuffalo = new BuffaloZdo(this.readBuffer(length));
|
|
238
|
+
// Global: SupportedKeyNegotiationMethodsGlobalTLV
|
|
239
|
+
// Global: FragmentationParametersGlobalTLV
|
|
240
|
+
const additionalTLVs = encapsulationBuffalo.readTLVs(null, true);
|
|
241
|
+
return {
|
|
242
|
+
additionalTLVs,
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
writeConfigurationParametersGlobalTLV(configurationParameters) {
|
|
246
|
+
this.writeUInt16(configurationParameters.configurationParameters);
|
|
247
|
+
}
|
|
248
|
+
readConfigurationParametersGlobalTLV(length) {
|
|
249
|
+
logger_1.logger.debug(`readConfigurationParametersGlobalTLV with length=${length}`, NS);
|
|
250
|
+
if (length < 2) {
|
|
251
|
+
throw new Error(`Malformed TLV. Invalid length '${length}', expected at least 2.`);
|
|
252
|
+
}
|
|
253
|
+
const configurationParameters = this.readUInt16();
|
|
254
|
+
return {
|
|
255
|
+
configurationParameters,
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
writeDeviceCapabilityExtensionGlobalTLV(tlv) {
|
|
259
|
+
this.writeBuffer(tlv.data, tlv.data.length);
|
|
260
|
+
}
|
|
261
|
+
readDeviceCapabilityExtensionGlobalTLV(length) {
|
|
262
|
+
logger_1.logger.debug(`readDeviceCapabilityExtensionGlobalTLV with length=${length}`, NS);
|
|
263
|
+
const data = this.readBuffer(length);
|
|
264
|
+
return {
|
|
265
|
+
data,
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
writeGlobalTLV(tlv) {
|
|
269
|
+
this.writeUInt8(tlv.tagId);
|
|
270
|
+
this.writeUInt8(tlv.length - 1); // remove offset (spec quirk...)
|
|
271
|
+
switch (tlv.tagId) {
|
|
272
|
+
case enums_1.GlobalTLV.MANUFACTURER_SPECIFIC: {
|
|
273
|
+
this.writeManufacturerSpecificGlobalTLV(tlv.tlv);
|
|
274
|
+
break;
|
|
275
|
+
}
|
|
276
|
+
case enums_1.GlobalTLV.SUPPORTED_KEY_NEGOTIATION_METHODS: {
|
|
277
|
+
this.writeSupportedKeyNegotiationMethodsGlobalTLV(tlv.tlv);
|
|
278
|
+
break;
|
|
279
|
+
}
|
|
280
|
+
case enums_1.GlobalTLV.PAN_ID_CONFLICT_REPORT: {
|
|
281
|
+
this.writePanIdConflictReportGlobalTLV(tlv.tlv);
|
|
282
|
+
break;
|
|
283
|
+
}
|
|
284
|
+
case enums_1.GlobalTLV.NEXT_PAN_ID_CHANGE: {
|
|
285
|
+
this.writeNextPanIdChangeGlobalTLV(tlv.tlv);
|
|
286
|
+
break;
|
|
287
|
+
}
|
|
288
|
+
case enums_1.GlobalTLV.NEXT_CHANNEL_CHANGE: {
|
|
289
|
+
this.writeNextChannelChangeGlobalTLV(tlv.tlv);
|
|
290
|
+
break;
|
|
291
|
+
}
|
|
292
|
+
case enums_1.GlobalTLV.SYMMETRIC_PASSPHRASE: {
|
|
293
|
+
this.writeSymmetricPassphraseGlobalTLV(tlv.tlv);
|
|
294
|
+
break;
|
|
295
|
+
}
|
|
296
|
+
case enums_1.GlobalTLV.ROUTER_INFORMATION: {
|
|
297
|
+
this.writeRouterInformationGlobalTLV(tlv.tlv);
|
|
298
|
+
break;
|
|
299
|
+
}
|
|
300
|
+
case enums_1.GlobalTLV.FRAGMENTATION_PARAMETERS: {
|
|
301
|
+
this.writeFragmentationParametersGlobalTLV(tlv.tlv);
|
|
302
|
+
break;
|
|
303
|
+
}
|
|
304
|
+
case enums_1.GlobalTLV.JOINER_ENCAPSULATION: {
|
|
305
|
+
this.writeJoinerEncapsulationGlobalTLV(tlv.tlv);
|
|
306
|
+
break;
|
|
307
|
+
}
|
|
308
|
+
case enums_1.GlobalTLV.BEACON_APPENDIX_ENCAPSULATION: {
|
|
309
|
+
this.writeBeaconAppendixEncapsulationGlobalTLV(tlv.tlv);
|
|
310
|
+
break;
|
|
311
|
+
}
|
|
312
|
+
case enums_1.GlobalTLV.CONFIGURATION_PARAMETERS: {
|
|
313
|
+
this.writeConfigurationParametersGlobalTLV(tlv.tlv);
|
|
314
|
+
break;
|
|
315
|
+
}
|
|
316
|
+
case enums_1.GlobalTLV.DEVICE_CAPABILITY_EXTENSION: {
|
|
317
|
+
this.writeDeviceCapabilityExtensionGlobalTLV(tlv.tlv);
|
|
318
|
+
break;
|
|
319
|
+
}
|
|
320
|
+
default: {
|
|
321
|
+
throw new zdoStatusError_1.ZdoStatusError(status_1.Status.NOT_SUPPORTED);
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
readGlobalTLV(tagId, length) {
|
|
326
|
+
switch (tagId) {
|
|
327
|
+
case enums_1.GlobalTLV.MANUFACTURER_SPECIFIC: {
|
|
328
|
+
return this.readManufacturerSpecificGlobalTLV(length);
|
|
329
|
+
}
|
|
330
|
+
case enums_1.GlobalTLV.SUPPORTED_KEY_NEGOTIATION_METHODS: {
|
|
331
|
+
return this.readSupportedKeyNegotiationMethodsGlobalTLV(length);
|
|
332
|
+
}
|
|
333
|
+
case enums_1.GlobalTLV.PAN_ID_CONFLICT_REPORT: {
|
|
334
|
+
return this.readPanIdConflictReportGlobalTLV(length);
|
|
335
|
+
}
|
|
336
|
+
case enums_1.GlobalTLV.NEXT_PAN_ID_CHANGE: {
|
|
337
|
+
return this.readNextPanIdChangeGlobalTLV(length);
|
|
338
|
+
}
|
|
339
|
+
case enums_1.GlobalTLV.NEXT_CHANNEL_CHANGE: {
|
|
340
|
+
return this.readNextChannelChangeGlobalTLV(length);
|
|
341
|
+
}
|
|
342
|
+
case enums_1.GlobalTLV.SYMMETRIC_PASSPHRASE: {
|
|
343
|
+
return this.readSymmetricPassphraseGlobalTLV(length);
|
|
344
|
+
}
|
|
345
|
+
case enums_1.GlobalTLV.ROUTER_INFORMATION: {
|
|
346
|
+
return this.readRouterInformationGlobalTLV(length);
|
|
347
|
+
}
|
|
348
|
+
case enums_1.GlobalTLV.FRAGMENTATION_PARAMETERS: {
|
|
349
|
+
return this.readFragmentationParametersGlobalTLV(length);
|
|
350
|
+
}
|
|
351
|
+
case enums_1.GlobalTLV.JOINER_ENCAPSULATION: {
|
|
352
|
+
return this.readJoinerEncapsulationGlobalTLV(length);
|
|
353
|
+
}
|
|
354
|
+
case enums_1.GlobalTLV.BEACON_APPENDIX_ENCAPSULATION: {
|
|
355
|
+
return this.readBeaconAppendixEncapsulationGlobalTLV(length);
|
|
356
|
+
}
|
|
357
|
+
case enums_1.GlobalTLV.CONFIGURATION_PARAMETERS: {
|
|
358
|
+
return this.readConfigurationParametersGlobalTLV(length);
|
|
359
|
+
}
|
|
360
|
+
case enums_1.GlobalTLV.DEVICE_CAPABILITY_EXTENSION: {
|
|
361
|
+
return this.readDeviceCapabilityExtensionGlobalTLV(length);
|
|
362
|
+
}
|
|
363
|
+
default: {
|
|
364
|
+
// validation: unknown tag shall be ignored
|
|
365
|
+
return null;
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
writeGlobalTLVs(tlvs) {
|
|
370
|
+
for (const tlv of tlvs) {
|
|
371
|
+
this.writeGlobalTLV(tlv);
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
//-- LOCAL TLVS
|
|
375
|
+
// write only
|
|
376
|
+
// private readBeaconSurveyConfigurationTLV(length: number): BeaconSurveyConfigurationTLV {
|
|
377
|
+
// logger.debug(`readBeaconSurveyConfigurationTLV with length=${length}`, NS);
|
|
378
|
+
// const count = this.readUInt8();
|
|
379
|
+
// /* istanbul ignore else */
|
|
380
|
+
// if (length !== (1 + (count * 4) + 1)) {
|
|
381
|
+
// throw new Error(`Malformed TLV. Invalid length '${length}', expected ${(1 + (count * 4) + 1)}.`);
|
|
382
|
+
// }
|
|
383
|
+
// const scanChannelList = this.readListUInt32(count);
|
|
384
|
+
// const configurationBitmask = this.readUInt8();
|
|
385
|
+
// return {
|
|
386
|
+
// scanChannelList,
|
|
387
|
+
// configurationBitmask,
|
|
388
|
+
// };
|
|
389
|
+
// }
|
|
390
|
+
readCurve25519PublicPointTLV(length) {
|
|
391
|
+
logger_1.logger.debug(`readCurve25519PublicPointTLV with length=${length}`, NS);
|
|
392
|
+
if (length !== (consts_2.EUI64_SIZE + consts_1.CURVE_PUBLIC_POINT_SIZE)) {
|
|
393
|
+
throw new Error(`Malformed TLV. Invalid length '${length}', expected ${(consts_2.EUI64_SIZE + consts_1.CURVE_PUBLIC_POINT_SIZE)}.`);
|
|
394
|
+
}
|
|
395
|
+
const eui64 = this.readIeeeAddr();
|
|
396
|
+
const publicPoint = this.readBuffer(consts_1.CURVE_PUBLIC_POINT_SIZE);
|
|
397
|
+
return {
|
|
398
|
+
eui64,
|
|
399
|
+
publicPoint,
|
|
400
|
+
};
|
|
401
|
+
}
|
|
402
|
+
// write only
|
|
403
|
+
// private readTargetIEEEAddressTLV(length: number): TargetIEEEAddressTLV {
|
|
404
|
+
// logger.debug(`readTargetIEEEAddressTLV with length=${length}`, NS);
|
|
405
|
+
// /* istanbul ignore else */
|
|
406
|
+
// if (length !== EUI64_SIZE) {
|
|
407
|
+
// throw new Error(`Malformed TLV. Invalid length '${length}', expected ${EUI64_SIZE}.`);
|
|
408
|
+
// }
|
|
409
|
+
// const ieee = this.readIeeeAddr();
|
|
410
|
+
// return {
|
|
411
|
+
// ieee,
|
|
412
|
+
// };
|
|
413
|
+
// }
|
|
414
|
+
// write only
|
|
415
|
+
// private readSelectedKeyNegotiationMethodTLV(length: number): SelectedKeyNegotiationMethodTLV {
|
|
416
|
+
// logger.debug(`readSelectedKeyNegotiationMethodTLV with length=${length}`, NS);
|
|
417
|
+
// /* istanbul ignore else */
|
|
418
|
+
// if (length !== 10) {
|
|
419
|
+
// throw new Error(`Malformed TLV. Invalid length '${length}', expected 10.`);
|
|
420
|
+
// }
|
|
421
|
+
// const protocol = this.readUInt8();
|
|
422
|
+
// const presharedSecret = this.readUInt8();
|
|
423
|
+
// const sendingDeviceEui64 = this.readIeeeAddr();
|
|
424
|
+
// return {
|
|
425
|
+
// protocol,
|
|
426
|
+
// presharedSecret,
|
|
427
|
+
// sendingDeviceEui64,
|
|
428
|
+
// };
|
|
429
|
+
// }
|
|
430
|
+
// write only
|
|
431
|
+
// private readDeviceEUI64ListTLV(length: number): DeviceEUI64ListTLV {
|
|
432
|
+
// logger.debug(`readDeviceEUI64ListTLV with length=${length}`, NS);
|
|
433
|
+
// const count = this.readUInt8();
|
|
434
|
+
// /* istanbul ignore else */
|
|
435
|
+
// if (length !== (1 + (count * EUI64_SIZE))) {
|
|
436
|
+
// throw new Error(`Malformed TLV. Invalid length '${length}', expected ${(1 + (count * EUI64_SIZE))}.`);
|
|
437
|
+
// }
|
|
438
|
+
// const eui64List: DeviceEUI64ListTLV['eui64List'] = [];
|
|
439
|
+
// for (let i = 0; i < count; i++) {
|
|
440
|
+
// const eui64 = this.readIeeeAddr();
|
|
441
|
+
// eui64List.push(eui64);
|
|
442
|
+
// }
|
|
443
|
+
// return {
|
|
444
|
+
// eui64List,
|
|
445
|
+
// };
|
|
446
|
+
// }
|
|
447
|
+
readAPSFrameCounterResponseTLV(length) {
|
|
448
|
+
logger_1.logger.debug(`readAPSFrameCounterResponseTLV with length=${length}`, NS);
|
|
449
|
+
if (length !== 32) {
|
|
450
|
+
throw new Error(`Malformed TLV. Invalid length '${length}', expected 32.`);
|
|
451
|
+
}
|
|
452
|
+
const responderEui64 = this.readIeeeAddr();
|
|
453
|
+
const receivedChallengeValue = this.readBuffer(consts_1.CHALLENGE_VALUE_SIZE);
|
|
454
|
+
const apsFrameCounter = this.readUInt32();
|
|
455
|
+
const challengeSecurityFrameCounter = this.readUInt32();
|
|
456
|
+
const mic = this.readBuffer(8);
|
|
457
|
+
return {
|
|
458
|
+
responderEui64,
|
|
459
|
+
receivedChallengeValue,
|
|
460
|
+
apsFrameCounter,
|
|
461
|
+
challengeSecurityFrameCounter,
|
|
462
|
+
mic,
|
|
463
|
+
};
|
|
464
|
+
}
|
|
465
|
+
readBeaconSurveyResultsTLV(length) {
|
|
466
|
+
logger_1.logger.debug(`readBeaconSurveyResultsTLV with length=${length}`, NS);
|
|
467
|
+
if (length !== 4) {
|
|
468
|
+
throw new Error(`Malformed TLV. Invalid length '${length}', expected 4.`);
|
|
469
|
+
}
|
|
470
|
+
const totalBeaconsReceived = this.readUInt8();
|
|
471
|
+
const onNetworkBeacons = this.readUInt8();
|
|
472
|
+
const potentialParentBeacons = this.readUInt8();
|
|
473
|
+
const otherNetworkBeacons = this.readUInt8();
|
|
474
|
+
return {
|
|
475
|
+
totalBeaconsReceived,
|
|
476
|
+
onNetworkBeacons,
|
|
477
|
+
potentialParentBeacons,
|
|
478
|
+
otherNetworkBeacons,
|
|
479
|
+
};
|
|
480
|
+
}
|
|
481
|
+
readPotentialParentsTLV(length) {
|
|
482
|
+
logger_1.logger.debug(`readPotentialParentsTLV with length=${length}`, NS);
|
|
483
|
+
if (length < 4) {
|
|
484
|
+
throw new Error(`Malformed TLV. Invalid length '${length}', expected at least 4.`);
|
|
485
|
+
}
|
|
486
|
+
const currentParentNwkAddress = this.readUInt16();
|
|
487
|
+
const currentParentLQA = this.readUInt8();
|
|
488
|
+
// [0x00 - 0x05]
|
|
489
|
+
const entryCount = this.readUInt8();
|
|
490
|
+
if (length !== (4 + (entryCount * 3))) {
|
|
491
|
+
throw new Error(`Malformed TLV. Invalid length '${length}', expected ${(4 + (entryCount * 3))}.`);
|
|
492
|
+
}
|
|
493
|
+
const potentialParents = [];
|
|
494
|
+
for (let i = 0; i < entryCount; i++) {
|
|
495
|
+
const nwkAddress = this.readUInt16();
|
|
496
|
+
const lqa = this.readUInt8();
|
|
497
|
+
potentialParents.push({
|
|
498
|
+
nwkAddress,
|
|
499
|
+
lqa,
|
|
500
|
+
});
|
|
501
|
+
}
|
|
502
|
+
return {
|
|
503
|
+
currentParentNwkAddress,
|
|
504
|
+
currentParentLQA,
|
|
505
|
+
entryCount,
|
|
506
|
+
potentialParents,
|
|
507
|
+
};
|
|
508
|
+
}
|
|
509
|
+
readDeviceAuthenticationLevelTLV(length) {
|
|
510
|
+
logger_1.logger.debug(`readDeviceAuthenticationLevelTLV with length=${length}`, NS);
|
|
511
|
+
if (length !== 10) {
|
|
512
|
+
throw new Error(`Malformed TLV. Invalid length '${length}', expected 10.`);
|
|
513
|
+
}
|
|
514
|
+
const remoteNodeIeee = this.readIeeeAddr();
|
|
515
|
+
const initialJoinMethod = this.readUInt8();
|
|
516
|
+
const activeLinkKeyType = this.readUInt8();
|
|
517
|
+
return {
|
|
518
|
+
remoteNodeIeee,
|
|
519
|
+
initialJoinMethod,
|
|
520
|
+
activeLinkKeyType,
|
|
521
|
+
};
|
|
522
|
+
}
|
|
523
|
+
readProcessingStatusTLV(length) {
|
|
524
|
+
logger_1.logger.debug(`readProcessingStatusTLV with length=${length}`, NS);
|
|
525
|
+
const count = this.readUInt8();
|
|
526
|
+
if (length !== (1 + (count * 2))) {
|
|
527
|
+
throw new Error(`Malformed TLV. Invalid length '${length}', expected ${(1 + (count * 2))}.`);
|
|
528
|
+
}
|
|
529
|
+
const tlvs = [];
|
|
530
|
+
for (let i = 0; i < count; i++) {
|
|
531
|
+
const tagId = this.readUInt8();
|
|
532
|
+
const processingStatus = this.readUInt8();
|
|
533
|
+
tlvs.push({
|
|
534
|
+
tagId,
|
|
535
|
+
processingStatus,
|
|
536
|
+
});
|
|
537
|
+
}
|
|
538
|
+
return {
|
|
539
|
+
count,
|
|
540
|
+
tlvs,
|
|
541
|
+
};
|
|
542
|
+
}
|
|
543
|
+
/**
|
|
544
|
+
* ANNEX I ZIGBEE TLV DEFINITIONS AND FORMAT
|
|
545
|
+
*
|
|
546
|
+
* Unknown tags => TLV ignored
|
|
547
|
+
* Duplicate tags => reject message except for MANUFACTURER_SPECIFIC_GLOBAL_TLV
|
|
548
|
+
* Malformed TLVs => reject message
|
|
549
|
+
*
|
|
550
|
+
* @param localTLVReaders Mapping of tagID to local TLV reader function
|
|
551
|
+
* @param encapsulated Default false. If true, this is reading inside an encapsuled TLV (excludes further encapsulation)
|
|
552
|
+
* @returns
|
|
553
|
+
*/
|
|
554
|
+
readTLVs(localTLVReaders = null, encapsulated = false) {
|
|
555
|
+
const tlvs = [];
|
|
556
|
+
while (this.isMore()) {
|
|
557
|
+
const tagId = this.readUInt8();
|
|
558
|
+
// validation: cannot have duplicate tagId, except MANUFACTURER_SPECIFIC_GLOBAL_TLV
|
|
559
|
+
if ((tagId !== enums_1.GlobalTLV.MANUFACTURER_SPECIFIC) && (tlvs.findIndex((tlv) => tlv.tagId === tagId) !== -1)) {
|
|
560
|
+
throw new Error(`Duplicate tag. Cannot have more than one of tagId=${tagId}.`);
|
|
561
|
+
}
|
|
562
|
+
// validation: encapsulation TLV cannot contain another encapsulation TLV, outer considered malformed, reject message
|
|
563
|
+
if (encapsulated && ((tagId === enums_1.GlobalTLV.BEACON_APPENDIX_ENCAPSULATION) || (tagId === enums_1.GlobalTLV.JOINER_ENCAPSULATION))) {
|
|
564
|
+
throw new Error(`Invalid nested encapsulation for tagId=${tagId}.`);
|
|
565
|
+
}
|
|
566
|
+
const length = this.readUInt8() + 1; // add offset (spec quirk...)
|
|
567
|
+
console.log(this.position, length);
|
|
568
|
+
// validation: invalid if not at least ${length} bytes to read
|
|
569
|
+
if (!this.isMoreBy(length)) {
|
|
570
|
+
throw new Error(`Malformed TLV. Invalid data length for tagId=${tagId}, expected ${length}.`);
|
|
571
|
+
}
|
|
572
|
+
const nextTLVStart = this.getPosition() + length;
|
|
573
|
+
// null == unknown tag
|
|
574
|
+
let tlv = null;
|
|
575
|
+
if (tagId < enums_1.GlobalTLV.MANUFACTURER_SPECIFIC) {
|
|
576
|
+
/* istanbul ignore else */
|
|
577
|
+
if (localTLVReaders) {
|
|
578
|
+
const localTLVReader = localTLVReaders.get(tagId);
|
|
579
|
+
/* istanbul ignore else */
|
|
580
|
+
if (localTLVReader) {
|
|
581
|
+
tlv = localTLVReader.call(this, length);
|
|
582
|
+
}
|
|
583
|
+
else {
|
|
584
|
+
logger_1.logger.debug(`Local TLV found tagId=${tagId} but no reader given for it. Ignoring it.`, NS);
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
else {
|
|
588
|
+
logger_1.logger.debug(`Local TLV found tagId=${tagId} but no reader available. Ignoring it.`, NS);
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
else {
|
|
592
|
+
tlv = this.readGlobalTLV(tagId, length);
|
|
593
|
+
}
|
|
594
|
+
// validation: unknown tag shall be ignored
|
|
595
|
+
/* istanbul ignore else */
|
|
596
|
+
if (tlv != null) {
|
|
597
|
+
tlvs.push({
|
|
598
|
+
tagId,
|
|
599
|
+
length,
|
|
600
|
+
tlv,
|
|
601
|
+
});
|
|
602
|
+
}
|
|
603
|
+
else {
|
|
604
|
+
logger_1.logger.debug(`Unknown TLV tagId=${tagId}. Ignoring it.`, NS);
|
|
605
|
+
}
|
|
606
|
+
// ensure we're at the right position as dictated by the tlv length field, and not the tlv reader (should be the same if proper)
|
|
607
|
+
this.setPosition(nextTLVStart);
|
|
608
|
+
}
|
|
609
|
+
return tlvs;
|
|
610
|
+
}
|
|
611
|
+
//-- REQUESTS
|
|
612
|
+
/**
|
|
613
|
+
* @see ClusterId.NETWORK_ADDRESS_REQUEST
|
|
614
|
+
* @param target IEEE address for the request
|
|
615
|
+
* @param reportKids True to request that the target list their children in the response. [request type = 0x01]
|
|
616
|
+
* @param childStartIndex The index of the first child to list in the response. Ignored if reportKids is false.
|
|
617
|
+
*/
|
|
618
|
+
static buildNetworkAddressRequest(target, reportKids, childStartIndex) {
|
|
619
|
+
const buffalo = new BuffaloZdo(Buffer.alloc(MAX_BUFFER_SIZE), consts_1.ZDO_MESSAGE_OVERHEAD);
|
|
620
|
+
buffalo.writeIeeeAddr(target);
|
|
621
|
+
buffalo.writeUInt8(reportKids ? 1 : 0);
|
|
622
|
+
buffalo.writeUInt8(childStartIndex);
|
|
623
|
+
return buffalo.getWritten();
|
|
624
|
+
}
|
|
625
|
+
/**
|
|
626
|
+
* @see ClusterId.IEEE_ADDRESS_REQUEST
|
|
627
|
+
* Can be sent to target, or to another node that will send to target.
|
|
628
|
+
* @param target NWK address for the request
|
|
629
|
+
* @param reportKids True to request that the target list their children in the response. [request type = 0x01]
|
|
630
|
+
* @param childStartIndex The index of the first child to list in the response. Ignored if reportKids is false.
|
|
631
|
+
*/
|
|
632
|
+
static buildIeeeAddressRequest(target, reportKids, childStartIndex) {
|
|
633
|
+
const buffalo = new BuffaloZdo(Buffer.alloc(MAX_BUFFER_SIZE), consts_1.ZDO_MESSAGE_OVERHEAD);
|
|
634
|
+
buffalo.writeUInt16(target);
|
|
635
|
+
buffalo.writeUInt8(reportKids ? 1 : 0);
|
|
636
|
+
buffalo.writeUInt8(childStartIndex);
|
|
637
|
+
return buffalo.getWritten();
|
|
638
|
+
}
|
|
639
|
+
/**
|
|
640
|
+
* @see ClusterId.NODE_DESCRIPTOR_REQUEST
|
|
641
|
+
* @param target NWK address for the request
|
|
642
|
+
*/
|
|
643
|
+
static buildNodeDescriptorRequest(target, fragmentationParameters) {
|
|
644
|
+
const buffalo = new BuffaloZdo(Buffer.alloc(MAX_BUFFER_SIZE), consts_1.ZDO_MESSAGE_OVERHEAD);
|
|
645
|
+
buffalo.writeUInt16(target);
|
|
646
|
+
if (fragmentationParameters) {
|
|
647
|
+
let length = 2;
|
|
648
|
+
/* istanbul ignore else */
|
|
649
|
+
if (fragmentationParameters.fragmentationOptions) {
|
|
650
|
+
length += 1;
|
|
651
|
+
}
|
|
652
|
+
/* istanbul ignore else */
|
|
653
|
+
if (fragmentationParameters.maxIncomingTransferUnit) {
|
|
654
|
+
length += 2;
|
|
655
|
+
}
|
|
656
|
+
buffalo.writeGlobalTLV({ tagId: enums_1.GlobalTLV.FRAGMENTATION_PARAMETERS, length, tlv: fragmentationParameters });
|
|
657
|
+
}
|
|
658
|
+
return buffalo.getWritten();
|
|
659
|
+
}
|
|
660
|
+
/**
|
|
661
|
+
* @see ClusterId.POWER_DESCRIPTOR_REQUEST
|
|
662
|
+
* @param target NWK address for the request
|
|
663
|
+
*/
|
|
664
|
+
static buildPowerDescriptorRequest(target) {
|
|
665
|
+
const buffalo = new BuffaloZdo(Buffer.alloc(MAX_BUFFER_SIZE), consts_1.ZDO_MESSAGE_OVERHEAD);
|
|
666
|
+
buffalo.writeUInt16(target);
|
|
667
|
+
return buffalo.getWritten();
|
|
668
|
+
}
|
|
669
|
+
/**
|
|
670
|
+
* @see ClusterId.SIMPLE_DESCRIPTOR_REQUEST
|
|
671
|
+
* @param target NWK address for the request
|
|
672
|
+
* @param targetEndpoint The endpoint on the destination
|
|
673
|
+
*/
|
|
674
|
+
static buildSimpleDescriptorRequest(target, targetEndpoint) {
|
|
675
|
+
const buffalo = new BuffaloZdo(Buffer.alloc(MAX_BUFFER_SIZE), consts_1.ZDO_MESSAGE_OVERHEAD);
|
|
676
|
+
buffalo.writeUInt16(target);
|
|
677
|
+
buffalo.writeUInt8(targetEndpoint);
|
|
678
|
+
return buffalo.getWritten();
|
|
679
|
+
}
|
|
680
|
+
/**
|
|
681
|
+
* @see ClusterId.ACTIVE_ENDPOINTS_REQUEST
|
|
682
|
+
* @param target NWK address for the request
|
|
683
|
+
*/
|
|
684
|
+
static buildActiveEndpointsRequest(target) {
|
|
685
|
+
const buffalo = new BuffaloZdo(Buffer.alloc(MAX_BUFFER_SIZE), consts_1.ZDO_MESSAGE_OVERHEAD);
|
|
686
|
+
buffalo.writeUInt16(target);
|
|
687
|
+
return buffalo.getWritten();
|
|
688
|
+
}
|
|
689
|
+
/**
|
|
690
|
+
* @see ClusterId.MATCH_DESCRIPTORS_REQUEST
|
|
691
|
+
* @param target NWK address for the request
|
|
692
|
+
* @param profileId Profile ID to be matched at the destination
|
|
693
|
+
* @param inClusterList List of Input ClusterIDs to be used for matching
|
|
694
|
+
* @param outClusterList List of Output ClusterIDs to be used for matching
|
|
695
|
+
*/
|
|
696
|
+
static buildMatchDescriptorRequest(target, profileId, inClusterList, outClusterList) {
|
|
697
|
+
const buffalo = new BuffaloZdo(Buffer.alloc(MAX_BUFFER_SIZE), consts_1.ZDO_MESSAGE_OVERHEAD);
|
|
698
|
+
buffalo.writeUInt16(target);
|
|
699
|
+
buffalo.writeUInt16(profileId);
|
|
700
|
+
buffalo.writeUInt8(inClusterList.length);
|
|
701
|
+
buffalo.writeListUInt16(inClusterList);
|
|
702
|
+
buffalo.writeUInt8(outClusterList.length);
|
|
703
|
+
buffalo.writeListUInt16(outClusterList);
|
|
704
|
+
return buffalo.getWritten();
|
|
705
|
+
}
|
|
706
|
+
/**
|
|
707
|
+
* @see ClusterId.SYSTEM_SERVER_DISCOVERY_REQUEST
|
|
708
|
+
* @param serverMask See Table 2-34 for bit assignments.
|
|
709
|
+
*/
|
|
710
|
+
static buildSystemServiceDiscoveryRequest(serverMask) {
|
|
711
|
+
const buffalo = new BuffaloZdo(Buffer.alloc(MAX_BUFFER_SIZE), consts_1.ZDO_MESSAGE_OVERHEAD);
|
|
712
|
+
buffalo.writeUInt16(Utils.createServerMask(serverMask));
|
|
713
|
+
return buffalo.getWritten();
|
|
714
|
+
}
|
|
715
|
+
/**
|
|
716
|
+
* @see ClusterId.PARENT_ANNOUNCE
|
|
717
|
+
* @param children The IEEE addresses of the children bound to the parent.
|
|
718
|
+
*/
|
|
719
|
+
static buildParentAnnounce(children) {
|
|
720
|
+
const buffalo = new BuffaloZdo(Buffer.alloc(MAX_BUFFER_SIZE), consts_1.ZDO_MESSAGE_OVERHEAD);
|
|
721
|
+
buffalo.writeUInt8(children.length);
|
|
722
|
+
for (const child of children) {
|
|
723
|
+
buffalo.writeIeeeAddr(child);
|
|
724
|
+
}
|
|
725
|
+
return buffalo.getWritten();
|
|
726
|
+
}
|
|
727
|
+
/**
|
|
728
|
+
* @see ClusterId.BIND_REQUEST
|
|
729
|
+
*
|
|
730
|
+
* @param source The IEEE address for the source.
|
|
731
|
+
* @param sourceEndpoint The source endpoint for the binding entry.
|
|
732
|
+
* @param clusterId The identifier of the cluster on the source device that is bound to the destination.
|
|
733
|
+
* @param type The addressing mode for the destination address used in this command, either ::UNICAST_BINDING, ::MULTICAST_BINDING.
|
|
734
|
+
* @param destination The destination address for the binding entry. IEEE for ::UNICAST_BINDING.
|
|
735
|
+
* @param groupAddress The destination address for the binding entry. Group ID for ::MULTICAST_BINDING.
|
|
736
|
+
* @param destinationEndpoint The destination endpoint for the binding entry. Only if ::UNICAST_BINDING.
|
|
737
|
+
*/
|
|
738
|
+
static buildBindRequest(source, sourceEndpoint, clusterId, type, destination, groupAddress, destinationEndpoint) {
|
|
739
|
+
const buffalo = new BuffaloZdo(Buffer.alloc(MAX_BUFFER_SIZE), consts_1.ZDO_MESSAGE_OVERHEAD);
|
|
740
|
+
buffalo.writeIeeeAddr(source);
|
|
741
|
+
buffalo.writeUInt8(sourceEndpoint);
|
|
742
|
+
buffalo.writeUInt16(clusterId);
|
|
743
|
+
buffalo.writeUInt8(type);
|
|
744
|
+
switch (type) {
|
|
745
|
+
case consts_1.UNICAST_BINDING: {
|
|
746
|
+
buffalo.writeIeeeAddr(destination);
|
|
747
|
+
buffalo.writeUInt8(destinationEndpoint);
|
|
748
|
+
break;
|
|
749
|
+
}
|
|
750
|
+
case consts_1.MULTICAST_BINDING: {
|
|
751
|
+
buffalo.writeUInt16(groupAddress);
|
|
752
|
+
break;
|
|
753
|
+
}
|
|
754
|
+
default:
|
|
755
|
+
throw new zdoStatusError_1.ZdoStatusError(status_1.Status.NOT_SUPPORTED);
|
|
756
|
+
}
|
|
757
|
+
return buffalo.getWritten();
|
|
758
|
+
}
|
|
759
|
+
/**
|
|
760
|
+
* @see ClusterId.UNBIND_REQUEST
|
|
761
|
+
*
|
|
762
|
+
* @param source The IEEE address for the source.
|
|
763
|
+
* @param sourceEndpoint The source endpoint for the binding entry.
|
|
764
|
+
* @param clusterId The identifier of the cluster on the source device that is bound to the destination.
|
|
765
|
+
* @param type The addressing mode for the destination address used in this command, either ::UNICAST_BINDING, ::MULTICAST_BINDING.
|
|
766
|
+
* @param destination The destination address for the binding entry. IEEE for ::UNICAST_BINDING.
|
|
767
|
+
* @param groupAddress The destination address for the binding entry. Group ID for ::MULTICAST_BINDING.
|
|
768
|
+
* @param destinationEndpoint The destination endpoint for the binding entry. Only if ::UNICAST_BINDING.
|
|
769
|
+
*/
|
|
770
|
+
static buildUnbindRequest(source, sourceEndpoint, clusterId, type, destination, groupAddress, destinationEndpoint) {
|
|
771
|
+
const buffalo = new BuffaloZdo(Buffer.alloc(MAX_BUFFER_SIZE), consts_1.ZDO_MESSAGE_OVERHEAD);
|
|
772
|
+
buffalo.writeIeeeAddr(source);
|
|
773
|
+
buffalo.writeUInt8(sourceEndpoint);
|
|
774
|
+
buffalo.writeUInt16(clusterId);
|
|
775
|
+
buffalo.writeUInt8(type);
|
|
776
|
+
switch (type) {
|
|
777
|
+
case consts_1.UNICAST_BINDING: {
|
|
778
|
+
buffalo.writeIeeeAddr(destination);
|
|
779
|
+
buffalo.writeUInt8(destinationEndpoint);
|
|
780
|
+
break;
|
|
781
|
+
}
|
|
782
|
+
case consts_1.MULTICAST_BINDING: {
|
|
783
|
+
buffalo.writeUInt16(groupAddress);
|
|
784
|
+
break;
|
|
785
|
+
}
|
|
786
|
+
default:
|
|
787
|
+
throw new zdoStatusError_1.ZdoStatusError(status_1.Status.NOT_SUPPORTED);
|
|
788
|
+
}
|
|
789
|
+
return buffalo.getWritten();
|
|
790
|
+
}
|
|
791
|
+
/**
|
|
792
|
+
* @see ClusterId.CLEAR_ALL_BINDINGS_REQUEST
|
|
793
|
+
*/
|
|
794
|
+
static buildClearAllBindingsRequest(tlv) {
|
|
795
|
+
const buffalo = new BuffaloZdo(Buffer.alloc(MAX_BUFFER_SIZE), consts_1.ZDO_MESSAGE_OVERHEAD);
|
|
796
|
+
// ClearAllBindingsReqEUI64TLV: Local: ID: 0x00
|
|
797
|
+
buffalo.writeUInt8(0x00);
|
|
798
|
+
buffalo.writeUInt8(tlv.eui64List.length * consts_2.EUI64_SIZE + 1 - 1);
|
|
799
|
+
buffalo.writeUInt8(tlv.eui64List.length);
|
|
800
|
+
for (const entry of tlv.eui64List) {
|
|
801
|
+
buffalo.writeIeeeAddr(entry);
|
|
802
|
+
}
|
|
803
|
+
return buffalo.getWritten();
|
|
804
|
+
}
|
|
805
|
+
/**
|
|
806
|
+
* @see ClusterId.LQI_TABLE_REQUEST
|
|
807
|
+
* @param startIndex Starting Index for the requested elements of the Neighbor Table.
|
|
808
|
+
*/
|
|
809
|
+
static buildLqiTableRequest(startIndex) {
|
|
810
|
+
const buffalo = new BuffaloZdo(Buffer.alloc(MAX_BUFFER_SIZE), consts_1.ZDO_MESSAGE_OVERHEAD);
|
|
811
|
+
buffalo.writeUInt8(startIndex);
|
|
812
|
+
return buffalo.getWritten();
|
|
813
|
+
}
|
|
814
|
+
/**
|
|
815
|
+
* @see ClusterId.ROUTING_TABLE_REQUEST
|
|
816
|
+
* @param startIndex Starting Index for the requested elements of the Neighbor Table.
|
|
817
|
+
*/
|
|
818
|
+
static buildRoutingTableRequest(startIndex) {
|
|
819
|
+
const buffalo = new BuffaloZdo(Buffer.alloc(MAX_BUFFER_SIZE), consts_1.ZDO_MESSAGE_OVERHEAD);
|
|
820
|
+
buffalo.writeUInt8(startIndex);
|
|
821
|
+
return buffalo.getWritten();
|
|
822
|
+
}
|
|
823
|
+
/**
|
|
824
|
+
* @see ClusterId.BINDING_TABLE_REQUEST
|
|
825
|
+
* @param startIndex Starting Index for the requested elements of the Neighbor Table.
|
|
826
|
+
*/
|
|
827
|
+
static buildBindingTableRequest(startIndex) {
|
|
828
|
+
const buffalo = new BuffaloZdo(Buffer.alloc(MAX_BUFFER_SIZE), consts_1.ZDO_MESSAGE_OVERHEAD);
|
|
829
|
+
buffalo.writeUInt8(startIndex);
|
|
830
|
+
return buffalo.getWritten();
|
|
831
|
+
}
|
|
832
|
+
/**
|
|
833
|
+
* @see ClusterId.LEAVE_REQUEST
|
|
834
|
+
* @param deviceAddress All zeros if the target is to remove itself from the network or
|
|
835
|
+
* the EUI64 of a child of the target device to remove that child.
|
|
836
|
+
* @param leaveRequestFlags A bitmask of leave options. Include ::AND_REJOIN if the target is to rejoin the network immediately after leaving.
|
|
837
|
+
*/
|
|
838
|
+
static buildLeaveRequest(deviceAddress, leaveRequestFlags) {
|
|
839
|
+
const buffalo = new BuffaloZdo(Buffer.alloc(MAX_BUFFER_SIZE), consts_1.ZDO_MESSAGE_OVERHEAD);
|
|
840
|
+
buffalo.writeIeeeAddr(deviceAddress);
|
|
841
|
+
buffalo.writeUInt8(leaveRequestFlags);
|
|
842
|
+
return buffalo.getWritten();
|
|
843
|
+
}
|
|
844
|
+
/**
|
|
845
|
+
* @see ClusterId.PERMIT_JOINING_REQUEST
|
|
846
|
+
* @param duration A value of 0x00 disables joining. A value of 0xFF enables joining. Any other value enables joining for that number of seconds.
|
|
847
|
+
* @param authentication Controls Trust Center authentication behavior.
|
|
848
|
+
* This field SHALL always have a value of 1, indicating a request to change the Trust Center policy.
|
|
849
|
+
* If a frame is received with a value of 0, it shall be treated as having a value of 1.
|
|
850
|
+
*/
|
|
851
|
+
static buildPermitJoining(duration, authentication, tlvs) {
|
|
852
|
+
const buffalo = new BuffaloZdo(Buffer.alloc(MAX_BUFFER_SIZE), consts_1.ZDO_MESSAGE_OVERHEAD);
|
|
853
|
+
buffalo.writeUInt8(duration);
|
|
854
|
+
buffalo.writeUInt8(authentication);
|
|
855
|
+
// BeaconAppendixEncapsulationGlobalTLV
|
|
856
|
+
// - SupportedKeyNegotiationMethodsGlobalTLV
|
|
857
|
+
// - FragmentationParametersGlobalTLV
|
|
858
|
+
buffalo.writeGlobalTLVs(tlvs);
|
|
859
|
+
return buffalo.getWritten();
|
|
860
|
+
}
|
|
861
|
+
/**
|
|
862
|
+
* @see ClusterId.NWK_UPDATE_REQUEST
|
|
863
|
+
* @param channels See Table 3-7 for details on the 32-bit field structure..
|
|
864
|
+
* @param duration A value used to calculate the length of time to spend scanning each channel.
|
|
865
|
+
* The time spent scanning each channel is (aBaseSuperframeDuration * (2n + 1)) symbols, where n is the value of the duration parameter.
|
|
866
|
+
* If has a value of 0xfe this is a request for channel change.
|
|
867
|
+
* If has a value of 0xff this is a request to change the apsChannelMaskList and nwkManagerAddr attributes.
|
|
868
|
+
* @param count This field represents the number of energy scans to be conducted and reported.
|
|
869
|
+
* This field SHALL be present only if the duration is within the range of 0x00 to 0x05.
|
|
870
|
+
* @param nwkUpdateId The value of the nwkUpdateId contained in this request.
|
|
871
|
+
* This value is set by the Network Channel Manager prior to sending the message.
|
|
872
|
+
* This field SHALL only be present if the duration is 0xfe or 0xff.
|
|
873
|
+
* If the ScanDuration is 0xff, then the value in the nwkUpdateID SHALL be ignored.
|
|
874
|
+
* @param nwkManagerAddr This field SHALL be present only if the duration is set to 0xff, and, where present,
|
|
875
|
+
* indicates the NWK address for the device with the Network Manager bit set in its Node Descriptor.
|
|
876
|
+
*/
|
|
877
|
+
static buildNwkUpdateRequest(channels, duration, count, nwkUpdateId, nwkManagerAddr) {
|
|
878
|
+
const buffalo = new BuffaloZdo(Buffer.alloc(MAX_BUFFER_SIZE), consts_1.ZDO_MESSAGE_OVERHEAD);
|
|
879
|
+
buffalo.writeUInt32(ZSpecUtils.channelsToUInt32Mask(channels));
|
|
880
|
+
buffalo.writeUInt8(duration);
|
|
881
|
+
if (count != null && (duration >= 0x00 && duration <= 0x05)) {
|
|
882
|
+
buffalo.writeUInt8(count);
|
|
883
|
+
}
|
|
884
|
+
// TODO: What does "This value is set by the Network Channel Manager prior to sending the message." mean exactly??
|
|
885
|
+
// (isn't used/mentioned in EmberZNet, confirmed working if not set at all for channel change)
|
|
886
|
+
// for now, allow to bypass with null, otherwise should throw if null and duration passes below conditions (see NwkEnhancedUpdateRequest)
|
|
887
|
+
if (nwkUpdateId != null && (duration === 0xFE || duration === 0xFF)) {
|
|
888
|
+
buffalo.writeUInt8(nwkUpdateId);
|
|
889
|
+
}
|
|
890
|
+
if (nwkManagerAddr != null && duration === 0xFF) {
|
|
891
|
+
buffalo.writeUInt16(nwkManagerAddr);
|
|
892
|
+
}
|
|
893
|
+
return buffalo.getWritten();
|
|
894
|
+
}
|
|
895
|
+
/**
|
|
896
|
+
* Shortcut for @see BuffaloZdo.buildNwkUpdateRequest
|
|
897
|
+
*/
|
|
898
|
+
static buildScanChannelsRequest(scanChannels, duration, count) {
|
|
899
|
+
return BuffaloZdo.buildNwkUpdateRequest(scanChannels, duration, count, null, null);
|
|
900
|
+
}
|
|
901
|
+
/**
|
|
902
|
+
* Shortcut for @see BuffaloZdo.buildNwkUpdateRequest
|
|
903
|
+
*/
|
|
904
|
+
static buildChannelChangeRequest(channel, nwkUpdateId) {
|
|
905
|
+
return BuffaloZdo.buildNwkUpdateRequest([channel], 0xFE, null, nwkUpdateId, null);
|
|
906
|
+
}
|
|
907
|
+
/**
|
|
908
|
+
* Shortcut for @see BuffaloZdo.buildNwkUpdateRequest
|
|
909
|
+
*/
|
|
910
|
+
static buildSetActiveChannelsAndNwkManagerIdRequest(channels, nwkUpdateId, nwkManagerAddr) {
|
|
911
|
+
return BuffaloZdo.buildNwkUpdateRequest(channels, 0xFF, null, nwkUpdateId, nwkManagerAddr);
|
|
912
|
+
}
|
|
913
|
+
/**
|
|
914
|
+
* @see ClusterId.NWK_ENHANCED_UPDATE_REQUEST
|
|
915
|
+
* @param channelPages The set of channels (32-bit bitmap) for each channel page.
|
|
916
|
+
* The five most significant bits (b27,..., b31) represent the binary encoded Channel Page.
|
|
917
|
+
* The 27 least significant bits (b0, b1,... b26) indicate which channels are to be scanned
|
|
918
|
+
* (1 = scan, 0 = do not scan) for each of the 27 valid channels
|
|
919
|
+
* If duration is in the range 0x00 to 0x05, SHALL be restricted to a single page.
|
|
920
|
+
* @param duration A value used to calculate the length of time to spend scanning each channel.
|
|
921
|
+
* The time spent scanning each channel is (aBaseSuperframeDuration * (2n + 1)) symbols, where n is the value of the duration parameter.
|
|
922
|
+
* If has a value of 0xfe this is a request for channel change.
|
|
923
|
+
* If has a value of 0xff this is a request to change the apsChannelMaskList and nwkManagerAddr attributes.
|
|
924
|
+
* @param count This field represents the number of energy scans to be conducted and reported.
|
|
925
|
+
* This field SHALL be present only if the duration is within the range of 0x00 to 0x05.
|
|
926
|
+
* @param nwkUpdateId The value of the nwkUpdateId contained in this request.
|
|
927
|
+
* This value is set by the Network Channel Manager prior to sending the message.
|
|
928
|
+
* This field SHALL only be present if the duration is 0xfe or 0xff.
|
|
929
|
+
* If the ScanDuration is 0xff, then the value in the nwkUpdateID SHALL be ignored.
|
|
930
|
+
* @param nwkManagerAddr This field SHALL be present only if the duration is set to 0xff, and, where present,
|
|
931
|
+
* indicates the NWK address for the device with the Network Manager bit set in its Node Descriptor.
|
|
932
|
+
* @param configurationBitmask Defined in defined in section 2.4.3.3.12.
|
|
933
|
+
* The configurationBitmask must be added to the end of the list of parameters.
|
|
934
|
+
* This octet may or may not be present.
|
|
935
|
+
* If not present then assumption should be that it is enhanced active scan.
|
|
936
|
+
* Bit 0: This bit determines whether to do an Active Scan or Enhanced Active Scan.
|
|
937
|
+
* When the bit is set to 1 it indicates an Enhanced Active Scan.
|
|
938
|
+
* And in case of Enhanced Active scan EBR shall be sent with EPID filter instead of PJOIN filter.
|
|
939
|
+
* Bit 1-7: Reserved
|
|
940
|
+
*/
|
|
941
|
+
static buildNwkEnhancedUpdateRequest(channelPages, duration, count, nwkUpdateId, nwkManagerAddr, configurationBitmask) {
|
|
942
|
+
const buffalo = new BuffaloZdo(Buffer.alloc(MAX_BUFFER_SIZE), consts_1.ZDO_MESSAGE_OVERHEAD);
|
|
943
|
+
buffalo.writeUInt8(channelPages.length);
|
|
944
|
+
for (const channelPage of channelPages) {
|
|
945
|
+
buffalo.writeUInt32(channelPage);
|
|
946
|
+
}
|
|
947
|
+
buffalo.writeUInt8(duration);
|
|
948
|
+
if (count != null && (duration >= 0x00 && duration <= 0x05)) {
|
|
949
|
+
buffalo.writeUInt8(count);
|
|
950
|
+
}
|
|
951
|
+
if (nwkUpdateId != null && (duration === 0xFE || duration === 0xFF)) {
|
|
952
|
+
buffalo.writeUInt8(nwkUpdateId);
|
|
953
|
+
}
|
|
954
|
+
if (nwkManagerAddr != null && duration === 0xFF) {
|
|
955
|
+
buffalo.writeUInt16(nwkManagerAddr);
|
|
956
|
+
}
|
|
957
|
+
/* istanbul ignore else */
|
|
958
|
+
if (configurationBitmask != null) {
|
|
959
|
+
buffalo.writeUInt8(configurationBitmask);
|
|
960
|
+
}
|
|
961
|
+
return buffalo.getWritten();
|
|
962
|
+
}
|
|
963
|
+
/**
|
|
964
|
+
* Shortcut for @see BuffaloZdo.buildNwkEnhancedUpdateRequest
|
|
965
|
+
*/
|
|
966
|
+
static buildEnhancedScanChannelsRequest(channelPages, duration, count, configurationBitmask) {
|
|
967
|
+
return BuffaloZdo.buildNwkEnhancedUpdateRequest(channelPages, duration, count, null, null, configurationBitmask);
|
|
968
|
+
}
|
|
969
|
+
/**
|
|
970
|
+
* Shortcut for @see BuffaloZdo.buildNwkEnhancedUpdateRequest
|
|
971
|
+
*/
|
|
972
|
+
static buildEnhancedChannelChangeRequest(channelPage, nwkUpdateId, configurationBitmask) {
|
|
973
|
+
return BuffaloZdo.buildNwkEnhancedUpdateRequest([channelPage], 0xFE, null, nwkUpdateId, null, configurationBitmask);
|
|
974
|
+
}
|
|
975
|
+
/**
|
|
976
|
+
* Shortcut for @see BuffaloZdo.buildNwkEnhancedUpdateRequest
|
|
977
|
+
*/
|
|
978
|
+
static buildEnhancedSetActiveChannelsAndNwkManagerIdRequest(channelPages, nwkUpdateId, nwkManagerAddr, configurationBitmask) {
|
|
979
|
+
return BuffaloZdo.buildNwkEnhancedUpdateRequest(channelPages, 0xFF, null, nwkUpdateId, nwkManagerAddr, configurationBitmask);
|
|
980
|
+
}
|
|
981
|
+
/**
|
|
982
|
+
* @see ClusterId.NWK_IEEE_JOINING_LIST_REQUEST
|
|
983
|
+
* @param startIndex The starting index into the receiving device’s nwkIeeeJoiningList that SHALL be sent back.
|
|
984
|
+
*/
|
|
985
|
+
static buildNwkIEEEJoiningListRequest(startIndex) {
|
|
986
|
+
const buffalo = new BuffaloZdo(Buffer.alloc(MAX_BUFFER_SIZE), consts_1.ZDO_MESSAGE_OVERHEAD);
|
|
987
|
+
buffalo.writeUInt8(startIndex);
|
|
988
|
+
return buffalo.getWritten();
|
|
989
|
+
}
|
|
990
|
+
/**
|
|
991
|
+
* @see ClusterId.NWK_BEACON_SURVEY_REQUEST
|
|
992
|
+
*/
|
|
993
|
+
static buildNwkBeaconSurveyRequest(tlv) {
|
|
994
|
+
const buffalo = new BuffaloZdo(Buffer.alloc(MAX_BUFFER_SIZE), consts_1.ZDO_MESSAGE_OVERHEAD);
|
|
995
|
+
// BeaconSurveyConfigurationTLV: Local: ID: 0x00
|
|
996
|
+
buffalo.writeUInt8(0x00);
|
|
997
|
+
buffalo.writeUInt8(2 + (tlv.scanChannelList.length * 4) - 1);
|
|
998
|
+
buffalo.writeUInt8(tlv.scanChannelList.length);
|
|
999
|
+
buffalo.writeListUInt32(tlv.scanChannelList);
|
|
1000
|
+
buffalo.writeUInt8(tlv.configurationBitmask);
|
|
1001
|
+
return buffalo.getWritten();
|
|
1002
|
+
}
|
|
1003
|
+
/**
|
|
1004
|
+
* @see ClusterId.START_KEY_NEGOTIATION_REQUEST
|
|
1005
|
+
*/
|
|
1006
|
+
static buildStartKeyNegotiationRequest(tlv) {
|
|
1007
|
+
const buffalo = new BuffaloZdo(Buffer.alloc(MAX_BUFFER_SIZE), consts_1.ZDO_MESSAGE_OVERHEAD);
|
|
1008
|
+
// Curve25519PublicPointTLV: Local: ID: 0x00
|
|
1009
|
+
buffalo.writeUInt8(0x00);
|
|
1010
|
+
buffalo.writeUInt8(consts_2.EUI64_SIZE + consts_1.CURVE_PUBLIC_POINT_SIZE - 1);
|
|
1011
|
+
buffalo.writeIeeeAddr(tlv.eui64);
|
|
1012
|
+
buffalo.writeBuffer(tlv.publicPoint, consts_1.CURVE_PUBLIC_POINT_SIZE);
|
|
1013
|
+
return buffalo.getWritten();
|
|
1014
|
+
}
|
|
1015
|
+
/**
|
|
1016
|
+
* @see ClusterId.RETRIEVE_AUTHENTICATION_TOKEN_REQUEST
|
|
1017
|
+
*/
|
|
1018
|
+
static buildRetrieveAuthenticationTokenRequest(tlv) {
|
|
1019
|
+
const buffalo = new BuffaloZdo(Buffer.alloc(MAX_BUFFER_SIZE), consts_1.ZDO_MESSAGE_OVERHEAD);
|
|
1020
|
+
// AuthenticationTokenIdTLV: Local: ID: 0x00
|
|
1021
|
+
buffalo.writeUInt8(0x00);
|
|
1022
|
+
buffalo.writeUInt8(1 - 1);
|
|
1023
|
+
buffalo.writeUInt8(tlv.tlvTypeTagId);
|
|
1024
|
+
return buffalo.getWritten();
|
|
1025
|
+
}
|
|
1026
|
+
/**
|
|
1027
|
+
* @see ClusterId.GET_AUTHENTICATION_LEVEL_REQUEST
|
|
1028
|
+
*/
|
|
1029
|
+
static buildGetAuthenticationLevelRequest(tlv) {
|
|
1030
|
+
const buffalo = new BuffaloZdo(Buffer.alloc(MAX_BUFFER_SIZE), consts_1.ZDO_MESSAGE_OVERHEAD);
|
|
1031
|
+
// TargetIEEEAddressTLV: Local: ID: 0x00
|
|
1032
|
+
buffalo.writeUInt8(0x00);
|
|
1033
|
+
buffalo.writeUInt8(consts_2.EUI64_SIZE - 1);
|
|
1034
|
+
buffalo.writeIeeeAddr(tlv.ieee);
|
|
1035
|
+
return buffalo.getWritten();
|
|
1036
|
+
}
|
|
1037
|
+
/**
|
|
1038
|
+
* @see ClusterId.SET_CONFIGURATION_REQUEST
|
|
1039
|
+
*/
|
|
1040
|
+
static buildSetConfigurationRequest(nextPanIdChange, nextChannelChange, configurationParameters) {
|
|
1041
|
+
const buffalo = new BuffaloZdo(Buffer.alloc(MAX_BUFFER_SIZE), consts_1.ZDO_MESSAGE_OVERHEAD);
|
|
1042
|
+
buffalo.writeGlobalTLV({ tagId: enums_1.GlobalTLV.NEXT_PAN_ID_CHANGE, length: consts_2.PAN_ID_SIZE, tlv: nextPanIdChange });
|
|
1043
|
+
buffalo.writeGlobalTLV({ tagId: enums_1.GlobalTLV.NEXT_CHANNEL_CHANGE, length: 4, tlv: nextChannelChange });
|
|
1044
|
+
buffalo.writeGlobalTLV({ tagId: enums_1.GlobalTLV.CONFIGURATION_PARAMETERS, length: 2, tlv: configurationParameters });
|
|
1045
|
+
return buffalo.getWritten();
|
|
1046
|
+
}
|
|
1047
|
+
/**
|
|
1048
|
+
* @see ClusterId.GET_CONFIGURATION_REQUEST
|
|
1049
|
+
* @param tlvIds The IDs of each TLV that are being requested.
|
|
1050
|
+
* Maximum number dependent on the underlying maximum size of the message as allowed by fragmentation.
|
|
1051
|
+
*/
|
|
1052
|
+
static buildGetConfigurationRequest(tlvIds) {
|
|
1053
|
+
const buffalo = new BuffaloZdo(Buffer.alloc(MAX_BUFFER_SIZE), consts_1.ZDO_MESSAGE_OVERHEAD);
|
|
1054
|
+
buffalo.writeUInt8(tlvIds.length);
|
|
1055
|
+
for (const tlvId of tlvIds) {
|
|
1056
|
+
buffalo.writeUInt8(tlvId);
|
|
1057
|
+
}
|
|
1058
|
+
return buffalo.getWritten();
|
|
1059
|
+
}
|
|
1060
|
+
/**
|
|
1061
|
+
* @see ClusterId.START_KEY_UPDATE_REQUEST
|
|
1062
|
+
*/
|
|
1063
|
+
static buildStartKeyUpdateRequest(selectedKeyNegotiationMethod, fragmentationParameters) {
|
|
1064
|
+
const buffalo = new BuffaloZdo(Buffer.alloc(MAX_BUFFER_SIZE), consts_1.ZDO_MESSAGE_OVERHEAD);
|
|
1065
|
+
// SelectedKeyNegotiationMethodTLV: Local: ID: 0x00
|
|
1066
|
+
buffalo.writeUInt8(0x00);
|
|
1067
|
+
buffalo.writeUInt8(consts_2.EUI64_SIZE + 2 - 1);
|
|
1068
|
+
buffalo.writeUInt8(selectedKeyNegotiationMethod.protocol);
|
|
1069
|
+
buffalo.writeUInt8(selectedKeyNegotiationMethod.presharedSecret);
|
|
1070
|
+
buffalo.writeIeeeAddr(selectedKeyNegotiationMethod.sendingDeviceEui64);
|
|
1071
|
+
{
|
|
1072
|
+
let length = 2;
|
|
1073
|
+
/* istanbul ignore else */
|
|
1074
|
+
if (fragmentationParameters.fragmentationOptions) {
|
|
1075
|
+
length += 1;
|
|
1076
|
+
}
|
|
1077
|
+
/* istanbul ignore else */
|
|
1078
|
+
if (fragmentationParameters.maxIncomingTransferUnit) {
|
|
1079
|
+
length += 2;
|
|
1080
|
+
}
|
|
1081
|
+
buffalo.writeGlobalTLV({ tagId: enums_1.GlobalTLV.FRAGMENTATION_PARAMETERS, length, tlv: fragmentationParameters });
|
|
1082
|
+
}
|
|
1083
|
+
return buffalo.getWritten();
|
|
1084
|
+
}
|
|
1085
|
+
/**
|
|
1086
|
+
* @see ClusterId.DECOMMISSION_REQUEST
|
|
1087
|
+
*/
|
|
1088
|
+
static buildDecommissionRequest(tlv) {
|
|
1089
|
+
const buffalo = new BuffaloZdo(Buffer.alloc(MAX_BUFFER_SIZE), consts_1.ZDO_MESSAGE_OVERHEAD);
|
|
1090
|
+
// DeviceEUI64ListTLV: Local: ID: 0x00
|
|
1091
|
+
buffalo.writeUInt8(0x00);
|
|
1092
|
+
buffalo.writeUInt8(tlv.eui64List.length * consts_2.EUI64_SIZE + 1 - 1);
|
|
1093
|
+
buffalo.writeUInt8(tlv.eui64List.length);
|
|
1094
|
+
for (const eui64 of tlv.eui64List) {
|
|
1095
|
+
buffalo.writeIeeeAddr(eui64);
|
|
1096
|
+
}
|
|
1097
|
+
return buffalo.getWritten();
|
|
1098
|
+
}
|
|
1099
|
+
/**
|
|
1100
|
+
* @see ClusterId.CHALLENGE_REQUEST
|
|
1101
|
+
*/
|
|
1102
|
+
static buildChallengeRequest(tlv) {
|
|
1103
|
+
const buffalo = new BuffaloZdo(Buffer.alloc(MAX_BUFFER_SIZE), consts_1.ZDO_MESSAGE_OVERHEAD);
|
|
1104
|
+
// APSFrameCounterChallengeTLV: Local: ID: 0x00
|
|
1105
|
+
buffalo.writeUInt8(0x00);
|
|
1106
|
+
buffalo.writeUInt8(consts_2.EUI64_SIZE + consts_1.CHALLENGE_VALUE_SIZE - 1);
|
|
1107
|
+
buffalo.writeIeeeAddr(tlv.senderEui64);
|
|
1108
|
+
buffalo.writeBuffer(tlv.challengeValue, consts_1.CHALLENGE_VALUE_SIZE);
|
|
1109
|
+
return buffalo.getWritten();
|
|
1110
|
+
}
|
|
1111
|
+
//-- RESPONSES
|
|
1112
|
+
static readResponse(clusterId, buffer) {
|
|
1113
|
+
const buffalo = new BuffaloZdo(buffer, consts_1.ZDO_MESSAGE_OVERHEAD); // set pos to skip `transaction sequence number`
|
|
1114
|
+
switch (clusterId) {
|
|
1115
|
+
case clusters_1.ClusterId.NETWORK_ADDRESS_RESPONSE: {
|
|
1116
|
+
return buffalo.readNetworkAddressResponse();
|
|
1117
|
+
}
|
|
1118
|
+
case clusters_1.ClusterId.IEEE_ADDRESS_RESPONSE: {
|
|
1119
|
+
return buffalo.readIEEEAddressResponse();
|
|
1120
|
+
}
|
|
1121
|
+
case clusters_1.ClusterId.NODE_DESCRIPTOR_RESPONSE: {
|
|
1122
|
+
return buffalo.readNodeDescriptorResponse();
|
|
1123
|
+
}
|
|
1124
|
+
case clusters_1.ClusterId.POWER_DESCRIPTOR_RESPONSE: {
|
|
1125
|
+
return buffalo.readPowerDescriptorResponse();
|
|
1126
|
+
}
|
|
1127
|
+
case clusters_1.ClusterId.SIMPLE_DESCRIPTOR_RESPONSE: {
|
|
1128
|
+
return buffalo.readSimpleDescriptorResponse();
|
|
1129
|
+
}
|
|
1130
|
+
case clusters_1.ClusterId.ACTIVE_ENDPOINTS_RESPONSE: {
|
|
1131
|
+
return buffalo.readActiveEndpointsResponse();
|
|
1132
|
+
}
|
|
1133
|
+
case clusters_1.ClusterId.MATCH_DESCRIPTORS_RESPONSE: {
|
|
1134
|
+
return buffalo.readMatchDescriptorsResponse();
|
|
1135
|
+
}
|
|
1136
|
+
case clusters_1.ClusterId.END_DEVICE_ANNOUNCE: {
|
|
1137
|
+
return buffalo.readEndDeviceAnnounce();
|
|
1138
|
+
}
|
|
1139
|
+
case clusters_1.ClusterId.SYSTEM_SERVER_DISCOVERY_RESPONSE: {
|
|
1140
|
+
return buffalo.readSystemServerDiscoveryResponse();
|
|
1141
|
+
}
|
|
1142
|
+
case clusters_1.ClusterId.PARENT_ANNOUNCE_RESPONSE: {
|
|
1143
|
+
return buffalo.readParentAnnounceResponse();
|
|
1144
|
+
}
|
|
1145
|
+
case clusters_1.ClusterId.BIND_RESPONSE: {
|
|
1146
|
+
return buffalo.readBindResponse();
|
|
1147
|
+
}
|
|
1148
|
+
case clusters_1.ClusterId.UNBIND_RESPONSE: {
|
|
1149
|
+
return buffalo.readUnbindResponse();
|
|
1150
|
+
}
|
|
1151
|
+
case clusters_1.ClusterId.CLEAR_ALL_BINDINGS_RESPONSE: {
|
|
1152
|
+
return buffalo.readClearAllBindingsResponse();
|
|
1153
|
+
}
|
|
1154
|
+
case clusters_1.ClusterId.LQI_TABLE_RESPONSE: {
|
|
1155
|
+
return buffalo.readLQITableResponse();
|
|
1156
|
+
}
|
|
1157
|
+
case clusters_1.ClusterId.ROUTING_TABLE_RESPONSE: {
|
|
1158
|
+
return buffalo.readRoutingTableResponse();
|
|
1159
|
+
}
|
|
1160
|
+
case clusters_1.ClusterId.BINDING_TABLE_RESPONSE: {
|
|
1161
|
+
return buffalo.readBindingTableResponse();
|
|
1162
|
+
}
|
|
1163
|
+
case clusters_1.ClusterId.LEAVE_RESPONSE: {
|
|
1164
|
+
return buffalo.readLeaveResponse();
|
|
1165
|
+
}
|
|
1166
|
+
case clusters_1.ClusterId.PERMIT_JOINING_RESPONSE: {
|
|
1167
|
+
return buffalo.readPermitJoiningResponse();
|
|
1168
|
+
}
|
|
1169
|
+
case clusters_1.ClusterId.NWK_UPDATE_RESPONSE: {
|
|
1170
|
+
return buffalo.readNwkUpdateResponse();
|
|
1171
|
+
}
|
|
1172
|
+
case clusters_1.ClusterId.NWK_ENHANCED_UPDATE_RESPONSE: {
|
|
1173
|
+
return buffalo.readNwkEnhancedUpdateResponse();
|
|
1174
|
+
}
|
|
1175
|
+
case clusters_1.ClusterId.NWK_IEEE_JOINING_LIST_REPONSE: {
|
|
1176
|
+
return buffalo.readNwkIEEEJoiningListResponse();
|
|
1177
|
+
}
|
|
1178
|
+
case clusters_1.ClusterId.NWK_UNSOLICITED_ENHANCED_UPDATE_RESPONSE: {
|
|
1179
|
+
return buffalo.readNwkUnsolicitedEnhancedUpdateResponse();
|
|
1180
|
+
}
|
|
1181
|
+
case clusters_1.ClusterId.NWK_BEACON_SURVEY_RESPONSE: {
|
|
1182
|
+
return buffalo.readNwkBeaconSurveyResponse();
|
|
1183
|
+
}
|
|
1184
|
+
case clusters_1.ClusterId.START_KEY_NEGOTIATION_RESPONSE: {
|
|
1185
|
+
return buffalo.readStartKeyNegotiationResponse();
|
|
1186
|
+
}
|
|
1187
|
+
case clusters_1.ClusterId.RETRIEVE_AUTHENTICATION_TOKEN_RESPONSE: {
|
|
1188
|
+
return buffalo.readRetrieveAuthenticationTokenResponse();
|
|
1189
|
+
}
|
|
1190
|
+
case clusters_1.ClusterId.GET_AUTHENTICATION_LEVEL_RESPONSE: {
|
|
1191
|
+
return buffalo.readGetAuthenticationLevelResponse();
|
|
1192
|
+
}
|
|
1193
|
+
case clusters_1.ClusterId.SET_CONFIGURATION_RESPONSE: {
|
|
1194
|
+
return buffalo.readSetConfigurationResponse();
|
|
1195
|
+
}
|
|
1196
|
+
case clusters_1.ClusterId.GET_CONFIGURATION_RESPONSE: {
|
|
1197
|
+
return buffalo.readGetConfigurationResponse();
|
|
1198
|
+
}
|
|
1199
|
+
case clusters_1.ClusterId.START_KEY_UPDATE_RESPONSE: {
|
|
1200
|
+
return buffalo.readStartKeyUpdateResponse();
|
|
1201
|
+
}
|
|
1202
|
+
case clusters_1.ClusterId.DECOMMISSION_RESPONSE: {
|
|
1203
|
+
return buffalo.readDecommissionResponse();
|
|
1204
|
+
}
|
|
1205
|
+
case clusters_1.ClusterId.CHALLENGE_RESPONSE: {
|
|
1206
|
+
return buffalo.readChallengeResponse();
|
|
1207
|
+
}
|
|
1208
|
+
default: {
|
|
1209
|
+
throw new Error(`Unsupported response reading for cluster ID '${clusterId}'.`);
|
|
1210
|
+
}
|
|
1211
|
+
}
|
|
1212
|
+
}
|
|
1213
|
+
/**
|
|
1214
|
+
* @see ClusterId.NETWORK_ADDRESS_RESPONSE
|
|
1215
|
+
*/
|
|
1216
|
+
readNetworkAddressResponse() {
|
|
1217
|
+
const status = this.readUInt8();
|
|
1218
|
+
if (status !== status_1.Status.SUCCESS) {
|
|
1219
|
+
// INV_REQUESTTYPE or DEVICE_NOT_FOUND
|
|
1220
|
+
throw new zdoStatusError_1.ZdoStatusError(status);
|
|
1221
|
+
}
|
|
1222
|
+
else {
|
|
1223
|
+
const eui64 = this.readIeeeAddr();
|
|
1224
|
+
const nwkAddress = this.readUInt16();
|
|
1225
|
+
let assocDevCount = 0;
|
|
1226
|
+
let startIndex = 0;
|
|
1227
|
+
let assocDevList = [];
|
|
1228
|
+
if (this.isMore()) {
|
|
1229
|
+
assocDevCount = this.readUInt8();
|
|
1230
|
+
startIndex = this.readUInt8();
|
|
1231
|
+
assocDevList = this.readListUInt16(assocDevCount);
|
|
1232
|
+
}
|
|
1233
|
+
return {
|
|
1234
|
+
eui64,
|
|
1235
|
+
nwkAddress,
|
|
1236
|
+
startIndex,
|
|
1237
|
+
assocDevList,
|
|
1238
|
+
};
|
|
1239
|
+
}
|
|
1240
|
+
}
|
|
1241
|
+
/**
|
|
1242
|
+
* @see ClusterId.IEEE_ADDRESS_RESPONSE
|
|
1243
|
+
*/
|
|
1244
|
+
readIEEEAddressResponse() {
|
|
1245
|
+
const status = this.readUInt8();
|
|
1246
|
+
if (status !== status_1.Status.SUCCESS) {
|
|
1247
|
+
// INV_REQUESTTYPE or DEVICE_NOT_FOUND
|
|
1248
|
+
throw new zdoStatusError_1.ZdoStatusError(status);
|
|
1249
|
+
}
|
|
1250
|
+
else {
|
|
1251
|
+
const eui64 = this.readIeeeAddr();
|
|
1252
|
+
const nwkAddress = this.readUInt16();
|
|
1253
|
+
let assocDevCount = 0;
|
|
1254
|
+
let startIndex = 0;
|
|
1255
|
+
let assocDevList = [];
|
|
1256
|
+
if (this.isMore()) {
|
|
1257
|
+
assocDevCount = this.readUInt8();
|
|
1258
|
+
startIndex = this.readUInt8();
|
|
1259
|
+
assocDevList = this.readListUInt16(assocDevCount);
|
|
1260
|
+
}
|
|
1261
|
+
return {
|
|
1262
|
+
eui64,
|
|
1263
|
+
nwkAddress,
|
|
1264
|
+
startIndex,
|
|
1265
|
+
assocDevList,
|
|
1266
|
+
};
|
|
1267
|
+
}
|
|
1268
|
+
}
|
|
1269
|
+
/**
|
|
1270
|
+
* @see ClusterId.NODE_DESCRIPTOR_RESPONSE
|
|
1271
|
+
*/
|
|
1272
|
+
readNodeDescriptorResponse() {
|
|
1273
|
+
const status = this.readUInt8();
|
|
1274
|
+
if (status !== status_1.Status.SUCCESS) {
|
|
1275
|
+
// DEVICE_NOT_FOUND, INV_REQUESTTYPE, or NO_DESCRIPTOR
|
|
1276
|
+
throw new zdoStatusError_1.ZdoStatusError(status);
|
|
1277
|
+
}
|
|
1278
|
+
else {
|
|
1279
|
+
const nwkAddress = this.readUInt16();
|
|
1280
|
+
// in bits: [logical type: 3] [deprecated: 1] [deprecated: 1] [fragmentation supported (R23): 1] [reserved/unused: 2]
|
|
1281
|
+
const nodeDescByte1 = this.readUInt8();
|
|
1282
|
+
// in bits: [aps flags: 3] [frequency band: 5]
|
|
1283
|
+
const nodeDescByte2 = this.readUInt8();
|
|
1284
|
+
const macCapFlags = Utils.getMacCapFlags(this.readUInt8());
|
|
1285
|
+
const manufacturerCode = this.readUInt16();
|
|
1286
|
+
const maxBufSize = this.readUInt8();
|
|
1287
|
+
const maxIncTxSize = this.readUInt16();
|
|
1288
|
+
const serverMask = Utils.getServerMask(this.readUInt16());
|
|
1289
|
+
const maxOutTxSize = this.readUInt16();
|
|
1290
|
+
const deprecated1 = this.readUInt8();
|
|
1291
|
+
// Global: FragmentationParametersGlobalTLV
|
|
1292
|
+
const tlvs = this.readTLVs();
|
|
1293
|
+
return {
|
|
1294
|
+
nwkAddress,
|
|
1295
|
+
logicalType: (nodeDescByte1 & 0x07),
|
|
1296
|
+
fragmentationSupported: (serverMask.stackComplianceResivion >= 23) ? ((nodeDescByte1 & 0x20) >> 5) === 1 : null,
|
|
1297
|
+
apsFlags: (nodeDescByte2 & 0x07),
|
|
1298
|
+
frequencyBand: (nodeDescByte2 & 0xF8) >> 3,
|
|
1299
|
+
capabilities: macCapFlags,
|
|
1300
|
+
manufacturerCode,
|
|
1301
|
+
maxBufSize,
|
|
1302
|
+
maxIncTxSize,
|
|
1303
|
+
serverMask,
|
|
1304
|
+
maxOutTxSize,
|
|
1305
|
+
deprecated1,
|
|
1306
|
+
tlvs,
|
|
1307
|
+
};
|
|
1308
|
+
}
|
|
1309
|
+
}
|
|
1310
|
+
/**
|
|
1311
|
+
* @see ClusterId.POWER_DESCRIPTOR_RESPONSE
|
|
1312
|
+
*/
|
|
1313
|
+
readPowerDescriptorResponse() {
|
|
1314
|
+
const status = this.readUInt8();
|
|
1315
|
+
if (status !== status_1.Status.SUCCESS) {
|
|
1316
|
+
// DEVICE_NOT_FOUND, INV_REQUESTTYPE, or NO_DESCRIPTOR
|
|
1317
|
+
throw new zdoStatusError_1.ZdoStatusError(status);
|
|
1318
|
+
}
|
|
1319
|
+
else {
|
|
1320
|
+
const nwkAddress = this.readUInt16();
|
|
1321
|
+
const byte1 = this.readUInt8();
|
|
1322
|
+
const byte2 = this.readUInt8();
|
|
1323
|
+
return {
|
|
1324
|
+
nwkAddress,
|
|
1325
|
+
currentPowerMode: (byte1 & 0xF),
|
|
1326
|
+
availPowerSources: ((byte1 >> 4) & 0xF),
|
|
1327
|
+
currentPowerSource: (byte2 & 0xF),
|
|
1328
|
+
currentPowerSourceLevel: ((byte2 >> 4) & 0xF),
|
|
1329
|
+
};
|
|
1330
|
+
}
|
|
1331
|
+
}
|
|
1332
|
+
/**
|
|
1333
|
+
* @see ClusterId.SIMPLE_DESCRIPTOR_RESPONSE
|
|
1334
|
+
*/
|
|
1335
|
+
readSimpleDescriptorResponse() {
|
|
1336
|
+
const status = this.readUInt8();
|
|
1337
|
+
if (status !== status_1.Status.SUCCESS) {
|
|
1338
|
+
// INVALID_EP, NOT_ACTIVE, DEVICE_NOT_FOUND, INV_REQUESTTYPE or NO_DESCRIPTOR
|
|
1339
|
+
throw new zdoStatusError_1.ZdoStatusError(status);
|
|
1340
|
+
}
|
|
1341
|
+
else {
|
|
1342
|
+
const nwkAddress = this.readUInt16();
|
|
1343
|
+
// Length in bytes of the Simple Descriptor to follow. [0x00-0xff]
|
|
1344
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1345
|
+
const length = this.readUInt8();
|
|
1346
|
+
const endpoint = this.readUInt8();
|
|
1347
|
+
const profileId = this.readUInt16();
|
|
1348
|
+
const deviceId = this.readUInt16();
|
|
1349
|
+
const deviceVersion = this.readUInt8();
|
|
1350
|
+
const inClusterCount = this.readUInt8();
|
|
1351
|
+
const inClusterList = this.readListUInt16(inClusterCount); // empty if inClusterCount==0
|
|
1352
|
+
const outClusterCount = this.readUInt8();
|
|
1353
|
+
const outClusterList = this.readListUInt16(outClusterCount); // empty if outClusterCount==0
|
|
1354
|
+
return {
|
|
1355
|
+
nwkAddress,
|
|
1356
|
+
endpoint,
|
|
1357
|
+
profileId,
|
|
1358
|
+
deviceId,
|
|
1359
|
+
deviceVersion,
|
|
1360
|
+
inClusterList,
|
|
1361
|
+
outClusterList,
|
|
1362
|
+
};
|
|
1363
|
+
}
|
|
1364
|
+
}
|
|
1365
|
+
/**
|
|
1366
|
+
* @see ClusterId.ACTIVE_ENDPOINTS_RESPONSE
|
|
1367
|
+
*/
|
|
1368
|
+
readActiveEndpointsResponse() {
|
|
1369
|
+
const status = this.readUInt8();
|
|
1370
|
+
if (status !== status_1.Status.SUCCESS) {
|
|
1371
|
+
// DEVICE_NOT_FOUND, INV_REQUESTTYPE, or NO_DESCRIPTOR
|
|
1372
|
+
throw new zdoStatusError_1.ZdoStatusError(status);
|
|
1373
|
+
}
|
|
1374
|
+
else {
|
|
1375
|
+
const nwkAddress = this.readUInt16();
|
|
1376
|
+
const endpointCount = this.readUInt8();
|
|
1377
|
+
const endpointList = this.readListUInt8(endpointCount);
|
|
1378
|
+
return {
|
|
1379
|
+
nwkAddress,
|
|
1380
|
+
endpointList,
|
|
1381
|
+
};
|
|
1382
|
+
}
|
|
1383
|
+
}
|
|
1384
|
+
/**
|
|
1385
|
+
* @see ClusterId.MATCH_DESCRIPTORS_RESPONSE
|
|
1386
|
+
*/
|
|
1387
|
+
readMatchDescriptorsResponse() {
|
|
1388
|
+
const status = this.readUInt8();
|
|
1389
|
+
if (status !== status_1.Status.SUCCESS) {
|
|
1390
|
+
// DEVICE_NOT_FOUND, INV_REQUESTTYPE, or NO_DESCRIPTOR
|
|
1391
|
+
throw new zdoStatusError_1.ZdoStatusError(status);
|
|
1392
|
+
}
|
|
1393
|
+
else {
|
|
1394
|
+
const nwkAddress = this.readUInt16();
|
|
1395
|
+
const endpointCount = this.readUInt8();
|
|
1396
|
+
const endpointList = this.readListUInt8(endpointCount);
|
|
1397
|
+
return {
|
|
1398
|
+
nwkAddress,
|
|
1399
|
+
endpointList,
|
|
1400
|
+
};
|
|
1401
|
+
}
|
|
1402
|
+
}
|
|
1403
|
+
/**
|
|
1404
|
+
* @see ClusterId.END_DEVICE_ANNOUNCE
|
|
1405
|
+
*/
|
|
1406
|
+
readEndDeviceAnnounce() {
|
|
1407
|
+
const nwkAddress = this.readUInt16();
|
|
1408
|
+
const eui64 = this.readIeeeAddr();
|
|
1409
|
+
/** @see MACCapabilityFlags */
|
|
1410
|
+
const capabilities = this.readUInt8();
|
|
1411
|
+
return { nwkAddress, eui64, capabilities: Utils.getMacCapFlags(capabilities) };
|
|
1412
|
+
}
|
|
1413
|
+
/**
|
|
1414
|
+
* @see ClusterId.SYSTEM_SERVER_DISCOVERY_RESPONSE
|
|
1415
|
+
*/
|
|
1416
|
+
readSystemServerDiscoveryResponse() {
|
|
1417
|
+
const status = this.readUInt8();
|
|
1418
|
+
if (status !== status_1.Status.SUCCESS) {
|
|
1419
|
+
// Shouldn't happen
|
|
1420
|
+
throw new zdoStatusError_1.ZdoStatusError(status);
|
|
1421
|
+
}
|
|
1422
|
+
else {
|
|
1423
|
+
const serverMask = Utils.getServerMask(this.readUInt16());
|
|
1424
|
+
return {
|
|
1425
|
+
serverMask,
|
|
1426
|
+
};
|
|
1427
|
+
}
|
|
1428
|
+
}
|
|
1429
|
+
/**
|
|
1430
|
+
* @see ClusterId.PARENT_ANNOUNCE_RESPONSE
|
|
1431
|
+
*/
|
|
1432
|
+
readParentAnnounceResponse() {
|
|
1433
|
+
const status = this.readUInt8();
|
|
1434
|
+
if (status !== status_1.Status.SUCCESS) {
|
|
1435
|
+
// NOT_SUPPORTED
|
|
1436
|
+
throw new zdoStatusError_1.ZdoStatusError(status);
|
|
1437
|
+
}
|
|
1438
|
+
else {
|
|
1439
|
+
const numberOfChildren = this.readUInt8();
|
|
1440
|
+
const children = [];
|
|
1441
|
+
for (let i = 0; i < numberOfChildren; i++) {
|
|
1442
|
+
const childEui64 = this.readIeeeAddr();
|
|
1443
|
+
children.push(childEui64);
|
|
1444
|
+
}
|
|
1445
|
+
return { children };
|
|
1446
|
+
}
|
|
1447
|
+
}
|
|
1448
|
+
/**
|
|
1449
|
+
* @see ClusterId.BIND_RESPONSE
|
|
1450
|
+
* @returns No response payload, throws if not success
|
|
1451
|
+
*/
|
|
1452
|
+
readBindResponse() {
|
|
1453
|
+
const status = this.readUInt8();
|
|
1454
|
+
/* istanbul ignore else */
|
|
1455
|
+
if (status !== status_1.Status.SUCCESS) {
|
|
1456
|
+
// NOT_SUPPORTED, INVALID_EP, TABLE_FULL, or NOT_AUTHORIZED
|
|
1457
|
+
throw new zdoStatusError_1.ZdoStatusError(status);
|
|
1458
|
+
}
|
|
1459
|
+
}
|
|
1460
|
+
/**
|
|
1461
|
+
* @see ClusterId.UNBIND_RESPONSE
|
|
1462
|
+
* @returns No response payload, throws if not success
|
|
1463
|
+
*/
|
|
1464
|
+
readUnbindResponse() {
|
|
1465
|
+
const status = this.readUInt8();
|
|
1466
|
+
/* istanbul ignore else */
|
|
1467
|
+
if (status !== status_1.Status.SUCCESS) {
|
|
1468
|
+
// NOT_SUPPORTED, INVALID_EP, NO_ENTRY or NOT_AUTHORIZED
|
|
1469
|
+
throw new zdoStatusError_1.ZdoStatusError(status);
|
|
1470
|
+
}
|
|
1471
|
+
}
|
|
1472
|
+
/**
|
|
1473
|
+
* @see ClusterId.CLEAR_ALL_BINDINGS_RESPONSE
|
|
1474
|
+
* @returns No response payload, throws if not success
|
|
1475
|
+
*/
|
|
1476
|
+
readClearAllBindingsResponse() {
|
|
1477
|
+
const status = this.readUInt8();
|
|
1478
|
+
/* istanbul ignore else */
|
|
1479
|
+
if (status !== status_1.Status.SUCCESS) {
|
|
1480
|
+
// NOT_SUPPORTED, NOT_AUTHORIZED, INV_REQUESTTYPE, or NO_MATCH.
|
|
1481
|
+
throw new zdoStatusError_1.ZdoStatusError(status);
|
|
1482
|
+
}
|
|
1483
|
+
}
|
|
1484
|
+
/**
|
|
1485
|
+
* @see ClusterId.LQI_TABLE_RESPONSE
|
|
1486
|
+
*/
|
|
1487
|
+
readLQITableResponse() {
|
|
1488
|
+
const status = this.readUInt8();
|
|
1489
|
+
if (status !== status_1.Status.SUCCESS) {
|
|
1490
|
+
// NOT_SUPPORTED or any status code returned from the NLME-GET.confirm primitive.
|
|
1491
|
+
throw new zdoStatusError_1.ZdoStatusError(status);
|
|
1492
|
+
}
|
|
1493
|
+
else {
|
|
1494
|
+
const neighborTableEntries = this.readUInt8();
|
|
1495
|
+
const startIndex = this.readUInt8();
|
|
1496
|
+
// [0x00-0x02]
|
|
1497
|
+
const entryCount = this.readUInt8();
|
|
1498
|
+
const entryList = [];
|
|
1499
|
+
for (let i = 0; i < entryCount; i++) {
|
|
1500
|
+
const extendedPanId = this.readListUInt8(consts_2.EXTENDED_PAN_ID_SIZE);
|
|
1501
|
+
const eui64 = this.readIeeeAddr();
|
|
1502
|
+
const nwkAddress = this.readUInt16();
|
|
1503
|
+
const deviceTypeByte = this.readUInt8();
|
|
1504
|
+
const permitJoiningByte = this.readUInt8();
|
|
1505
|
+
const depth = this.readUInt8();
|
|
1506
|
+
const lqi = this.readUInt8();
|
|
1507
|
+
entryList.push({
|
|
1508
|
+
extendedPanId,
|
|
1509
|
+
eui64,
|
|
1510
|
+
nwkAddress,
|
|
1511
|
+
deviceType: deviceTypeByte & 0x03,
|
|
1512
|
+
rxOnWhenIdle: (deviceTypeByte & 0x0C) >> 2,
|
|
1513
|
+
relationship: (deviceTypeByte & 0x70) >> 4,
|
|
1514
|
+
reserved1: (deviceTypeByte & 0x10) >> 7,
|
|
1515
|
+
permitJoining: permitJoiningByte & 0x03,
|
|
1516
|
+
reserved2: (permitJoiningByte & 0xFC) >> 2,
|
|
1517
|
+
depth,
|
|
1518
|
+
lqi,
|
|
1519
|
+
});
|
|
1520
|
+
}
|
|
1521
|
+
return {
|
|
1522
|
+
neighborTableEntries,
|
|
1523
|
+
startIndex,
|
|
1524
|
+
entryList,
|
|
1525
|
+
};
|
|
1526
|
+
}
|
|
1527
|
+
}
|
|
1528
|
+
/**
|
|
1529
|
+
* @see ClusterId.ROUTING_TABLE_RESPONSE
|
|
1530
|
+
*/
|
|
1531
|
+
readRoutingTableResponse() {
|
|
1532
|
+
const status = this.readUInt8();
|
|
1533
|
+
if (status !== status_1.Status.SUCCESS) {
|
|
1534
|
+
// NOT_SUPPORTED or any status code returned from the NLMEGET.confirm primitive.
|
|
1535
|
+
throw new zdoStatusError_1.ZdoStatusError(status);
|
|
1536
|
+
}
|
|
1537
|
+
else {
|
|
1538
|
+
const routingTableEntries = this.readUInt8();
|
|
1539
|
+
const startIndex = this.readUInt8();
|
|
1540
|
+
// [0x00-0xFF]
|
|
1541
|
+
const entryCount = this.readUInt8();
|
|
1542
|
+
const entryList = [];
|
|
1543
|
+
for (let i = 0; i < entryCount; i++) {
|
|
1544
|
+
const destinationAddress = this.readUInt16();
|
|
1545
|
+
const statusByte = this.readUInt8();
|
|
1546
|
+
const nextHopAddress = this.readUInt16();
|
|
1547
|
+
entryList.push({
|
|
1548
|
+
destinationAddress,
|
|
1549
|
+
status: statusByte & 0x07,
|
|
1550
|
+
memoryConstrained: (statusByte & 0x08) >> 3,
|
|
1551
|
+
manyToOne: (statusByte & 0x10) >> 4,
|
|
1552
|
+
routeRecordRequired: (statusByte & 0x20) >> 5,
|
|
1553
|
+
reserved1: (statusByte & 0xC0) >> 6,
|
|
1554
|
+
nextHopAddress,
|
|
1555
|
+
});
|
|
1556
|
+
}
|
|
1557
|
+
return {
|
|
1558
|
+
routingTableEntries,
|
|
1559
|
+
startIndex,
|
|
1560
|
+
entryList,
|
|
1561
|
+
};
|
|
1562
|
+
}
|
|
1563
|
+
}
|
|
1564
|
+
/**
|
|
1565
|
+
* @see ClusterId.BINDING_TABLE_RESPONSE
|
|
1566
|
+
*/
|
|
1567
|
+
readBindingTableResponse() {
|
|
1568
|
+
const status = this.readUInt8();
|
|
1569
|
+
if (status !== status_1.Status.SUCCESS) {
|
|
1570
|
+
// NOT_SUPPORTED or any status code returned from the APSMEGET.confirm primitive.
|
|
1571
|
+
throw new zdoStatusError_1.ZdoStatusError(status);
|
|
1572
|
+
}
|
|
1573
|
+
else {
|
|
1574
|
+
const bindingTableEntries = this.readUInt8();
|
|
1575
|
+
const startIndex = this.readUInt8();
|
|
1576
|
+
// [0x00-0xFF]
|
|
1577
|
+
const entryCount = this.readUInt8();
|
|
1578
|
+
const entryList = [];
|
|
1579
|
+
for (let i = 0; i < entryCount; i++) {
|
|
1580
|
+
const sourceEui64 = this.readIeeeAddr();
|
|
1581
|
+
const sourceEndpoint = this.readUInt8();
|
|
1582
|
+
const clusterId = this.readUInt16();
|
|
1583
|
+
const destAddrMode = this.readUInt8();
|
|
1584
|
+
const dest = (destAddrMode === 0x01) ? this.readUInt16() : ((destAddrMode === 0x03) ? this.readIeeeAddr() : null);
|
|
1585
|
+
const destEndpoint = (destAddrMode === 0x03) ? this.readUInt8() : null;
|
|
1586
|
+
entryList.push({
|
|
1587
|
+
sourceEui64,
|
|
1588
|
+
sourceEndpoint,
|
|
1589
|
+
clusterId,
|
|
1590
|
+
destAddrMode,
|
|
1591
|
+
dest,
|
|
1592
|
+
destEndpoint,
|
|
1593
|
+
});
|
|
1594
|
+
}
|
|
1595
|
+
return {
|
|
1596
|
+
bindingTableEntries,
|
|
1597
|
+
startIndex,
|
|
1598
|
+
entryList,
|
|
1599
|
+
};
|
|
1600
|
+
}
|
|
1601
|
+
}
|
|
1602
|
+
/**
|
|
1603
|
+
* @see ClusterId.LEAVE_RESPONSE
|
|
1604
|
+
* @returns No response payload, throws if not success
|
|
1605
|
+
*/
|
|
1606
|
+
readLeaveResponse() {
|
|
1607
|
+
const status = this.readUInt8();
|
|
1608
|
+
/* istanbul ignore else */
|
|
1609
|
+
if (status !== status_1.Status.SUCCESS) {
|
|
1610
|
+
// NOT_SUPPORTED, NOT_AUTHORIZED or any status code returned from the NLMELEAVE.confirm primitive.
|
|
1611
|
+
throw new zdoStatusError_1.ZdoStatusError(status);
|
|
1612
|
+
}
|
|
1613
|
+
}
|
|
1614
|
+
/**
|
|
1615
|
+
* @see ClusterId.PERMIT_JOINING_RESPONSE
|
|
1616
|
+
* @returns No response payload, throws if not success
|
|
1617
|
+
*/
|
|
1618
|
+
readPermitJoiningResponse() {
|
|
1619
|
+
const status = this.readUInt8();
|
|
1620
|
+
/* istanbul ignore else */
|
|
1621
|
+
if (status !== status_1.Status.SUCCESS) {
|
|
1622
|
+
// INV_REQUESTTYPE, NOT_AUTHORIZED, or any status code returned from the NLME-PERMIT-JOINING.confirm primitive.
|
|
1623
|
+
throw new zdoStatusError_1.ZdoStatusError(status);
|
|
1624
|
+
}
|
|
1625
|
+
}
|
|
1626
|
+
/**
|
|
1627
|
+
* @see ClusterId.NWK_UPDATE_RESPONSE
|
|
1628
|
+
*/
|
|
1629
|
+
readNwkUpdateResponse() {
|
|
1630
|
+
const status = this.readUInt8();
|
|
1631
|
+
if (status !== status_1.Status.SUCCESS) {
|
|
1632
|
+
// INV_REQUESTTYPE, NOT_SUPPORTED, or any status values returned from the MLME-SCAN.confirm primitive
|
|
1633
|
+
throw new zdoStatusError_1.ZdoStatusError(status);
|
|
1634
|
+
}
|
|
1635
|
+
else {
|
|
1636
|
+
const scannedChannels = this.readUInt32();
|
|
1637
|
+
const totalTransmissions = this.readUInt16();
|
|
1638
|
+
const totalFailures = this.readUInt16();
|
|
1639
|
+
// [0x00-0xFF]
|
|
1640
|
+
const entryCount = this.readUInt8();
|
|
1641
|
+
const entryList = this.readListUInt8(entryCount);
|
|
1642
|
+
return {
|
|
1643
|
+
scannedChannels,
|
|
1644
|
+
totalTransmissions,
|
|
1645
|
+
totalFailures,
|
|
1646
|
+
entryList,
|
|
1647
|
+
};
|
|
1648
|
+
}
|
|
1649
|
+
}
|
|
1650
|
+
/**
|
|
1651
|
+
* @see ClusterId.NWK_ENHANCED_UPDATE_RESPONSE
|
|
1652
|
+
*/
|
|
1653
|
+
readNwkEnhancedUpdateResponse() {
|
|
1654
|
+
const status = this.readUInt8();
|
|
1655
|
+
if (status !== status_1.Status.SUCCESS) {
|
|
1656
|
+
// INV_REQUESTTYPE, NOT_SUPPORTED, or any status values returned from the MLME-SCAN.confirm primitive.
|
|
1657
|
+
throw new zdoStatusError_1.ZdoStatusError(status);
|
|
1658
|
+
}
|
|
1659
|
+
else {
|
|
1660
|
+
const scannedChannels = this.readUInt32();
|
|
1661
|
+
const totalTransmissions = this.readUInt16();
|
|
1662
|
+
const totalFailures = this.readUInt16();
|
|
1663
|
+
// [0x00-0xFF]
|
|
1664
|
+
const entryCount = this.readUInt8();
|
|
1665
|
+
const entryList = this.readListUInt8(entryCount);
|
|
1666
|
+
return {
|
|
1667
|
+
scannedChannels,
|
|
1668
|
+
totalTransmissions,
|
|
1669
|
+
totalFailures,
|
|
1670
|
+
entryList,
|
|
1671
|
+
};
|
|
1672
|
+
}
|
|
1673
|
+
}
|
|
1674
|
+
/**
|
|
1675
|
+
* @see ClusterId.NWK_IEEE_JOINING_LIST_REPONSE
|
|
1676
|
+
*/
|
|
1677
|
+
readNwkIEEEJoiningListResponse() {
|
|
1678
|
+
const status = this.readUInt8();
|
|
1679
|
+
if (status !== status_1.Status.SUCCESS) {
|
|
1680
|
+
// INV_REQUESTTYPE, or NOT_SUPPORTED
|
|
1681
|
+
throw new zdoStatusError_1.ZdoStatusError(status);
|
|
1682
|
+
}
|
|
1683
|
+
else {
|
|
1684
|
+
const updateId = this.readUInt8();
|
|
1685
|
+
const joiningPolicy = this.readUInt8();
|
|
1686
|
+
// [0x00-0xFF]
|
|
1687
|
+
const entryListTotal = this.readUInt8();
|
|
1688
|
+
let startIndex;
|
|
1689
|
+
let entryList;
|
|
1690
|
+
if (entryListTotal > 0) {
|
|
1691
|
+
startIndex = this.readUInt8();
|
|
1692
|
+
const entryCount = this.readUInt8();
|
|
1693
|
+
entryList = [];
|
|
1694
|
+
for (let i = 0; i < entryCount; i++) {
|
|
1695
|
+
const ieee = this.readIeeeAddr();
|
|
1696
|
+
entryList.push(ieee);
|
|
1697
|
+
}
|
|
1698
|
+
}
|
|
1699
|
+
return {
|
|
1700
|
+
updateId,
|
|
1701
|
+
joiningPolicy,
|
|
1702
|
+
entryListTotal,
|
|
1703
|
+
startIndex,
|
|
1704
|
+
entryList,
|
|
1705
|
+
};
|
|
1706
|
+
}
|
|
1707
|
+
}
|
|
1708
|
+
/**
|
|
1709
|
+
* @see ClusterId.NWK_UNSOLICITED_ENHANCED_UPDATE_RESPONSE
|
|
1710
|
+
*/
|
|
1711
|
+
readNwkUnsolicitedEnhancedUpdateResponse() {
|
|
1712
|
+
const status = this.readUInt8();
|
|
1713
|
+
if (status !== status_1.Status.SUCCESS) {
|
|
1714
|
+
// ??
|
|
1715
|
+
throw new zdoStatusError_1.ZdoStatusError(status);
|
|
1716
|
+
}
|
|
1717
|
+
else {
|
|
1718
|
+
const channelInUse = this.readUInt32();
|
|
1719
|
+
const macTxUCastTotal = this.readUInt16();
|
|
1720
|
+
const macTxUCastFailures = this.readUInt16();
|
|
1721
|
+
const macTxUCastRetries = this.readUInt16();
|
|
1722
|
+
const timePeriod = this.readUInt8();
|
|
1723
|
+
return {
|
|
1724
|
+
channelInUse,
|
|
1725
|
+
macTxUCastTotal,
|
|
1726
|
+
macTxUCastFailures,
|
|
1727
|
+
macTxUCastRetries,
|
|
1728
|
+
timePeriod,
|
|
1729
|
+
};
|
|
1730
|
+
}
|
|
1731
|
+
}
|
|
1732
|
+
/**
|
|
1733
|
+
* @see ClusterId.NWK_BEACON_SURVEY_RESPONSE
|
|
1734
|
+
*/
|
|
1735
|
+
readNwkBeaconSurveyResponse() {
|
|
1736
|
+
const status = this.readUInt8();
|
|
1737
|
+
if (status !== status_1.Status.SUCCESS) {
|
|
1738
|
+
// INV_REQUESTTYPE, or NOT_SUPPORTED
|
|
1739
|
+
throw new zdoStatusError_1.ZdoStatusError(status);
|
|
1740
|
+
}
|
|
1741
|
+
else {
|
|
1742
|
+
const localTLVs = new Map([
|
|
1743
|
+
// Local: ID: 0x01: BeaconSurveyResultsTLV
|
|
1744
|
+
[0x01, this.readBeaconSurveyResultsTLV],
|
|
1745
|
+
// Local: ID: 0x02: PotentialParentsTLV
|
|
1746
|
+
[0x02, this.readPotentialParentsTLV],
|
|
1747
|
+
]);
|
|
1748
|
+
const tlvs = this.readTLVs(localTLVs);
|
|
1749
|
+
return {
|
|
1750
|
+
tlvs,
|
|
1751
|
+
};
|
|
1752
|
+
}
|
|
1753
|
+
}
|
|
1754
|
+
/**
|
|
1755
|
+
* @see ClusterId.START_KEY_NEGOTIATION_RESPONSE
|
|
1756
|
+
*/
|
|
1757
|
+
readStartKeyNegotiationResponse() {
|
|
1758
|
+
const status = this.readUInt8();
|
|
1759
|
+
if (status !== status_1.Status.SUCCESS) {
|
|
1760
|
+
// INVALID_TLV, MISSING_TLV, TEMPORARY_FAILURE, NOT_AUTHORIZED
|
|
1761
|
+
throw new zdoStatusError_1.ZdoStatusError(status);
|
|
1762
|
+
}
|
|
1763
|
+
else {
|
|
1764
|
+
const localTLVs = new Map([
|
|
1765
|
+
// Local: ID: 0x00: Curve25519PublicPointTLV
|
|
1766
|
+
[0x00, this.readCurve25519PublicPointTLV],
|
|
1767
|
+
]);
|
|
1768
|
+
const tlvs = this.readTLVs(localTLVs);
|
|
1769
|
+
return {
|
|
1770
|
+
tlvs,
|
|
1771
|
+
};
|
|
1772
|
+
}
|
|
1773
|
+
}
|
|
1774
|
+
/**
|
|
1775
|
+
* @see ClusterId.RETRIEVE_AUTHENTICATION_TOKEN_RESPONSE
|
|
1776
|
+
*/
|
|
1777
|
+
readRetrieveAuthenticationTokenResponse() {
|
|
1778
|
+
const status = this.readUInt8();
|
|
1779
|
+
if (status !== status_1.Status.SUCCESS) {
|
|
1780
|
+
throw new zdoStatusError_1.ZdoStatusError(status);
|
|
1781
|
+
}
|
|
1782
|
+
else {
|
|
1783
|
+
// no local TLV
|
|
1784
|
+
const tlvs = this.readTLVs();
|
|
1785
|
+
return {
|
|
1786
|
+
tlvs,
|
|
1787
|
+
};
|
|
1788
|
+
}
|
|
1789
|
+
}
|
|
1790
|
+
/**
|
|
1791
|
+
* @see ClusterId.GET_AUTHENTICATION_LEVEL_RESPONSE
|
|
1792
|
+
*/
|
|
1793
|
+
readGetAuthenticationLevelResponse() {
|
|
1794
|
+
const status = this.readUInt8();
|
|
1795
|
+
if (status !== status_1.Status.SUCCESS) {
|
|
1796
|
+
// NOT_SUPPORTED, INV_REQUESTTYPE, MISSING_TLV, and NOT_AUTHORIZED
|
|
1797
|
+
throw new zdoStatusError_1.ZdoStatusError(status);
|
|
1798
|
+
}
|
|
1799
|
+
else {
|
|
1800
|
+
const localTLVs = new Map([
|
|
1801
|
+
// Local: ID: 0x00: DeviceAuthenticationLevelTLV
|
|
1802
|
+
[0x00, this.readDeviceAuthenticationLevelTLV],
|
|
1803
|
+
]);
|
|
1804
|
+
const tlvs = this.readTLVs(localTLVs);
|
|
1805
|
+
return {
|
|
1806
|
+
tlvs,
|
|
1807
|
+
};
|
|
1808
|
+
}
|
|
1809
|
+
}
|
|
1810
|
+
/**
|
|
1811
|
+
* @see ClusterId.SET_CONFIGURATION_RESPONSE
|
|
1812
|
+
*/
|
|
1813
|
+
readSetConfigurationResponse() {
|
|
1814
|
+
const status = this.readUInt8();
|
|
1815
|
+
if (status !== status_1.Status.SUCCESS) {
|
|
1816
|
+
// INV_REQUESTTYPE, or NOT_SUPPORTED
|
|
1817
|
+
throw new zdoStatusError_1.ZdoStatusError(status);
|
|
1818
|
+
}
|
|
1819
|
+
else {
|
|
1820
|
+
const localTLVs = new Map([
|
|
1821
|
+
// Local: ID: 0x00: ProcessingStatusTLV
|
|
1822
|
+
[0x00, this.readProcessingStatusTLV],
|
|
1823
|
+
]);
|
|
1824
|
+
const tlvs = this.readTLVs(localTLVs);
|
|
1825
|
+
return {
|
|
1826
|
+
tlvs,
|
|
1827
|
+
};
|
|
1828
|
+
}
|
|
1829
|
+
}
|
|
1830
|
+
/**
|
|
1831
|
+
* @see ClusterId.GET_CONFIGURATION_RESPONSE
|
|
1832
|
+
*/
|
|
1833
|
+
readGetConfigurationResponse() {
|
|
1834
|
+
const status = this.readUInt8();
|
|
1835
|
+
if (status !== status_1.Status.SUCCESS) {
|
|
1836
|
+
// INV_REQUESTTYPE, or NOT_SUPPORTED
|
|
1837
|
+
throw new zdoStatusError_1.ZdoStatusError(status);
|
|
1838
|
+
}
|
|
1839
|
+
else {
|
|
1840
|
+
// Global: IDs: x, y, z
|
|
1841
|
+
const tlvs = this.readTLVs();
|
|
1842
|
+
return {
|
|
1843
|
+
tlvs,
|
|
1844
|
+
};
|
|
1845
|
+
}
|
|
1846
|
+
}
|
|
1847
|
+
/**
|
|
1848
|
+
* @see ClusterId.START_KEY_UPDATE_RESPONSE
|
|
1849
|
+
* @returns No response payload, throws if not success
|
|
1850
|
+
*/
|
|
1851
|
+
readStartKeyUpdateResponse() {
|
|
1852
|
+
const status = this.readUInt8();
|
|
1853
|
+
/* istanbul ignore else */
|
|
1854
|
+
if (status !== status_1.Status.SUCCESS) {
|
|
1855
|
+
// INV_REQUESTTYPE, NOT_AUTHORIZED or NOT_SUPPORTED
|
|
1856
|
+
throw new zdoStatusError_1.ZdoStatusError(status);
|
|
1857
|
+
}
|
|
1858
|
+
}
|
|
1859
|
+
/**
|
|
1860
|
+
* @see ClusterId.DECOMMISSION_RESPONSE
|
|
1861
|
+
* @returns No response payload, throws if not success
|
|
1862
|
+
*/
|
|
1863
|
+
readDecommissionResponse() {
|
|
1864
|
+
const status = this.readUInt8();
|
|
1865
|
+
/* istanbul ignore else */
|
|
1866
|
+
if (status !== status_1.Status.SUCCESS) {
|
|
1867
|
+
// INV_REQUESTTYPE, NOT_AUTHORIZED or NOT_SUPPORTED
|
|
1868
|
+
throw new zdoStatusError_1.ZdoStatusError(status);
|
|
1869
|
+
}
|
|
1870
|
+
}
|
|
1871
|
+
/**
|
|
1872
|
+
* @see ClusterId.CHALLENGE_RESPONSE
|
|
1873
|
+
*/
|
|
1874
|
+
readChallengeResponse() {
|
|
1875
|
+
const status = this.readUInt8();
|
|
1876
|
+
if (status !== status_1.Status.SUCCESS) {
|
|
1877
|
+
throw new zdoStatusError_1.ZdoStatusError(status);
|
|
1878
|
+
}
|
|
1879
|
+
else {
|
|
1880
|
+
const localTLVs = new Map([
|
|
1881
|
+
// Local: ID: 0x00: APSFrameCounterResponseTLV
|
|
1882
|
+
[0x00, this.readAPSFrameCounterResponseTLV],
|
|
1883
|
+
]);
|
|
1884
|
+
const tlvs = this.readTLVs(localTLVs);
|
|
1885
|
+
return {
|
|
1886
|
+
tlvs,
|
|
1887
|
+
};
|
|
1888
|
+
}
|
|
1889
|
+
}
|
|
1890
|
+
}
|
|
1891
|
+
exports.BuffaloZdo = BuffaloZdo;
|
|
1892
|
+
//# sourceMappingURL=buffaloZdo.js.map
|