zwave-js 14.3.3 → 14.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/lib/_version.d.ts +1 -1
- package/build/cjs/lib/_version.js +1 -1
- package/build/cjs/lib/_version.js.map +1 -1
- package/build/cjs/lib/controller/Controller.js +66 -60
- package/build/cjs/lib/controller/Controller.js.map +1 -1
- package/build/cjs/lib/controller/ControllerStatistics.js +4 -0
- package/build/cjs/lib/controller/ControllerStatistics.js.map +1 -1
- package/build/cjs/lib/controller/FirmwareUpdateService.js +8 -0
- package/build/cjs/lib/controller/FirmwareUpdateService.js.map +1 -1
- package/build/cjs/lib/controller/MockControllerBehaviors.js +3 -0
- package/build/cjs/lib/controller/MockControllerBehaviors.js.map +1 -1
- package/build/cjs/lib/controller/NVMIO.js +7 -0
- package/build/cjs/lib/controller/NVMIO.js.map +1 -1
- package/build/cjs/lib/controller/NodeInformationFrame.js +2 -0
- package/build/cjs/lib/controller/NodeInformationFrame.js.map +1 -1
- package/build/cjs/lib/controller/ZWaveSDKVersions.js +3 -0
- package/build/cjs/lib/controller/ZWaveSDKVersions.js.map +1 -1
- package/build/cjs/lib/controller/utils.js +4 -0
- package/build/cjs/lib/controller/utils.js.map +1 -1
- package/build/cjs/lib/driver/Bootloader.js +4 -0
- package/build/cjs/lib/driver/Bootloader.js.map +1 -1
- package/build/cjs/lib/driver/Driver.js +63 -56
- package/build/cjs/lib/driver/Driver.js.map +1 -1
- package/build/cjs/lib/driver/DriverMock.js +6 -3
- package/build/cjs/lib/driver/DriverMock.js.map +1 -1
- package/build/cjs/lib/driver/MessageGenerators.js +26 -18
- package/build/cjs/lib/driver/MessageGenerators.js.map +1 -1
- package/build/cjs/lib/driver/NetworkCache.js +43 -23
- package/build/cjs/lib/driver/NetworkCache.js.map +1 -1
- package/build/cjs/lib/driver/Queue.js +6 -2
- package/build/cjs/lib/driver/Queue.js.map +1 -1
- package/build/cjs/lib/driver/SerialAPICommandMachine.js +45 -40
- package/build/cjs/lib/driver/SerialAPICommandMachine.js.map +1 -1
- package/build/cjs/lib/driver/StateMachineShared.js +5 -0
- package/build/cjs/lib/driver/StateMachineShared.js.map +1 -1
- package/build/cjs/lib/driver/Statistics.js +4 -0
- package/build/cjs/lib/driver/Statistics.js.map +1 -1
- package/build/cjs/lib/driver/Task.js +9 -2
- package/build/cjs/lib/driver/Task.js.map +1 -1
- package/build/cjs/lib/driver/Transaction.js +8 -4
- package/build/cjs/lib/driver/Transaction.js.map +1 -1
- package/build/cjs/lib/driver/TransportServiceMachine.js +9 -7
- package/build/cjs/lib/driver/TransportServiceMachine.js.map +1 -1
- package/build/cjs/lib/driver/UpdateConfig.js +8 -4
- package/build/cjs/lib/driver/UpdateConfig.js.map +1 -1
- package/build/cjs/lib/driver/UserAgent.js +4 -0
- package/build/cjs/lib/driver/UserAgent.js.map +1 -1
- package/build/cjs/lib/driver/mDNSDiscovery.js +2 -0
- package/build/cjs/lib/driver/mDNSDiscovery.js.map +1 -1
- package/build/cjs/lib/log/Driver.js +6 -2
- package/build/cjs/lib/log/Driver.js.map +1 -1
- package/build/cjs/lib/log/Zniffer.js +6 -2
- package/build/cjs/lib/log/Zniffer.js.map +1 -1
- package/build/cjs/lib/node/DeviceClass.js +4 -0
- package/build/cjs/lib/node/DeviceClass.js.map +1 -1
- package/build/cjs/lib/node/Endpoint.js +9 -5
- package/build/cjs/lib/node/Endpoint.js.map +1 -1
- package/build/cjs/lib/node/HealthCheck.js +6 -0
- package/build/cjs/lib/node/HealthCheck.js.map +1 -1
- package/build/cjs/lib/node/MockNodeBehaviors.js +2 -0
- package/build/cjs/lib/node/MockNodeBehaviors.js.map +1 -1
- package/build/cjs/lib/node/MultiCCAPIWrapper.js +10 -8
- package/build/cjs/lib/node/MultiCCAPIWrapper.js.map +1 -1
- package/build/cjs/lib/node/Node.js +51 -46
- package/build/cjs/lib/node/Node.js.map +1 -1
- package/build/cjs/lib/node/NodeReadyMachine.js +3 -1
- package/build/cjs/lib/node/NodeReadyMachine.js.map +1 -1
- package/build/cjs/lib/node/NodeStatistics.js +5 -0
- package/build/cjs/lib/node/NodeStatistics.js.map +1 -1
- package/build/cjs/lib/node/NodeStatusMachine.js +5 -2
- package/build/cjs/lib/node/NodeStatusMachine.js.map +1 -1
- package/build/cjs/lib/node/VirtualEndpoint.js +8 -4
- package/build/cjs/lib/node/VirtualEndpoint.js.map +1 -1
- package/build/cjs/lib/node/VirtualNode.js +7 -2
- package/build/cjs/lib/node/VirtualNode.js.map +1 -1
- package/build/cjs/lib/node/mixins/00_Base.js +4 -0
- package/build/cjs/lib/node/mixins/00_Base.js.map +1 -1
- package/build/cjs/lib/node/mixins/01_NetworkRole.js +4 -0
- package/build/cjs/lib/node/mixins/01_NetworkRole.js.map +1 -1
- package/build/cjs/lib/node/mixins/05_Security.js +7 -3
- package/build/cjs/lib/node/mixins/05_Security.js.map +1 -1
- package/build/cjs/lib/node/mixins/10_Events.js +4 -0
- package/build/cjs/lib/node/mixins/10_Events.js.map +1 -1
- package/build/cjs/lib/node/mixins/20_Status.js +4 -0
- package/build/cjs/lib/node/mixins/20_Status.js.map +1 -1
- package/build/cjs/lib/node/mixins/30_Wakeup.js +4 -0
- package/build/cjs/lib/node/mixins/30_Wakeup.js.map +1 -1
- package/build/cjs/lib/node/mixins/40_Values.js +4 -0
- package/build/cjs/lib/node/mixins/40_Values.js.map +1 -1
- package/build/cjs/lib/node/mixins/50_Endpoints.js +4 -0
- package/build/cjs/lib/node/mixins/50_Endpoints.js.map +1 -1
- package/build/cjs/lib/node/mixins/60_ScheduledPoll.js +4 -0
- package/build/cjs/lib/node/mixins/60_ScheduledPoll.js.map +1 -1
- package/build/cjs/lib/node/mixins/70_FirmwareUpdate.js +8 -3
- package/build/cjs/lib/node/mixins/70_FirmwareUpdate.js.map +1 -1
- package/build/cjs/lib/node/mixins/index.js +4 -0
- package/build/cjs/lib/node/mixins/index.js.map +1 -1
- package/build/cjs/lib/node/mockCCBehaviors/ColorSwitch.js +2 -1
- package/build/cjs/lib/node/mockCCBehaviors/ColorSwitch.js.map +1 -1
- package/build/cjs/lib/node/mockCCBehaviors/Configuration.js +2 -1
- package/build/cjs/lib/node/mockCCBehaviors/Configuration.js.map +1 -1
- package/build/cjs/lib/node/mockCCBehaviors/ScheduleEntryLock.js +2 -1
- package/build/cjs/lib/node/mockCCBehaviors/ScheduleEntryLock.js.map +1 -1
- package/build/cjs/lib/node/mockCCBehaviors/ThermostatSetpoint.js +3 -2
- package/build/cjs/lib/node/mockCCBehaviors/ThermostatSetpoint.js.map +1 -1
- package/build/cjs/lib/node/mockCCBehaviors/UserCode.js +3 -2
- package/build/cjs/lib/node/mockCCBehaviors/UserCode.js.map +1 -1
- package/build/cjs/lib/node/utils.js +22 -2
- package/build/cjs/lib/node/utils.js.map +1 -1
- package/build/cjs/lib/telemetry/deviceConfig.js +2 -0
- package/build/cjs/lib/telemetry/deviceConfig.js.map +1 -1
- package/build/cjs/lib/telemetry/statistics.js +3 -0
- package/build/cjs/lib/telemetry/statistics.js.map +1 -1
- package/build/cjs/lib/zniffer/MPDU.js +57 -0
- package/build/cjs/lib/zniffer/MPDU.js.map +1 -1
- package/build/cjs/lib/zniffer/Zniffer.js +10 -3
- package/build/cjs/lib/zniffer/Zniffer.js.map +1 -1
- package/build/cjs/mockServer.js +14 -0
- package/build/cjs/mockServer.js.map +1 -1
- package/build/esm/lib/_version.d.ts +1 -1
- package/build/esm/lib/_version.js +1 -1
- package/package.json +12 -12
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/lib/driver/Driver.ts"],
|
|
4
4
|
"sourcesContent": ["import { JsonlDB, type JsonlDBOptions } from \"@alcalzone/jsonl-db\";\nimport {\n\ttype CCAPIHost,\n\tCRC16CC,\n\tCRC16CCCommandEncapsulation,\n\tCommandClass,\n\ttype FirmwareUpdateResult,\n\ttype InterviewContext,\n\tInvalidCC,\n\tKEXFailType,\n\tMultiChannelCC,\n\tNoOperationCC,\n\ttype PersistValuesContext,\n\ttype Powerlevel,\n\ttype RefreshValuesContext,\n\tSecurity2CC,\n\tSecurity2CCCommandsSupportedGet,\n\tSecurity2CCCommandsSupportedReport,\n\tSecurity2CCMessageEncapsulation,\n\tSecurity2CCNonceReport,\n\tSecurity2Command,\n\tSecurityCC,\n\tSecurityCCCommandEncapsulation,\n\tSecurityCCCommandEncapsulationNonceGet,\n\tSecurityCCCommandsSupportedGet,\n\tSecurityCCCommandsSupportedReport,\n\tSecurityCommand,\n\tSupervisionCC,\n\ttype SupervisionCCGet,\n\tSupervisionCCReport,\n\tTransportServiceCC,\n\tTransportServiceCCFirstSegment,\n\tTransportServiceCCSegmentComplete,\n\tTransportServiceCCSegmentRequest,\n\tTransportServiceCCSegmentWait,\n\ttype TransportServiceCCSubsequentSegment,\n\tTransportServiceTimeouts,\n\tVersionCommand,\n\tWakeUpCCNoMoreInformation,\n\tWakeUpCCValues,\n\ttype ZWaveProtocolCC,\n\tgetImplementedVersion,\n\tisEncapsulatingCommandClass,\n\tisMultiEncapsulatingCommandClass,\n\tisTransportServiceEncapsulation,\n} from \"@zwave-js/cc\";\nimport { ConfigManager, type DeviceConfig } from \"@zwave-js/config\";\nimport {\n\ttype CCId,\n\tCommandClasses,\n\tControllerLogger,\n\tControllerRole,\n\tControllerStatus,\n\tDuration,\n\tEncapsulationFlags,\n\ttype KeyPair,\n\ttype LogConfig,\n\ttype LogNodeOptions,\n\tMAX_SUPERVISION_SESSION_ID,\n\tMAX_TRANSPORT_SERVICE_SESSION_ID,\n\tMPANState,\n\ttype MaybeNotKnown,\n\tMessagePriority,\n\ttype MessageRecord,\n\ttype MulticastDestination,\n\tNUM_NODEMASK_BYTES,\n\tNodeIDType,\n\tRFRegion,\n\tSPANState,\n\tSecurityClass,\n\tSecurityManager,\n\tSecurityManager2,\n\ttype SendCommandOptions,\n\ttype SendCommandReturnType,\n\ttype SendMessageOptions,\n\ttype SinglecastCC,\n\ttype SupervisionResult,\n\tSupervisionStatus,\n\ttype SupervisionUpdateHandler,\n\tTransactionState,\n\tTransmitOptions,\n\tTransmitStatus,\n\ttype ValueDB,\n\ttype ValueID,\n\ttype ValueMetadata,\n\tZWaveError,\n\tZWaveErrorCodes,\n\tZWaveLogContainer,\n\tdeserializeCacheValue,\n\textractRawECDHPrivateKeySync,\n\tgenerateECDHKeyPairSync,\n\tgetCCName,\n\thighResTimestamp,\n\tisEncapsulationCC,\n\tisLongRangeNodeId,\n\tisMissingControllerACK,\n\tisMissingControllerCallback,\n\tisMissingControllerResponse,\n\tisZWaveError,\n\tkeyPairFromRawECDHPrivateKeySync,\n\tmessageRecordToLines,\n\trandomBytes,\n\tsecurityClassIsS2,\n\tsecurityClassOrder,\n\tserializeCacheValue,\n\tstripUndefined,\n\ttimespan,\n\twasControllerReset,\n} from \"@zwave-js/core\";\nimport type {\n\tCCEncodingContext,\n\tCCParsingContext,\n\tHostIDs,\n\tNodeSchedulePollOptions,\n\tZWaveHostOptions,\n} from \"@zwave-js/host\";\nimport {\n\ttype BootloaderChunk,\n\tBootloaderChunkType,\n\tFunctionType,\n\ttype HasNodeId,\n\tMessage,\n\ttype MessageEncodingContext,\n\tMessageHeaders,\n\ttype MessageParsingContext,\n\tMessageType,\n\ttype SuccessIndicator,\n\tXModemMessageHeaders,\n\tZWaveSerialMode,\n\tZWaveSerialPort,\n\tZWaveSerialPortBase,\n\ttype ZWaveSerialPortImplementation,\n\tZWaveSocket,\n\tgetDefaultPriority,\n\thasNodeId,\n\tisSuccessIndicator,\n\tisZWaveSerialPortImplementation,\n} from \"@zwave-js/serial\";\nimport { ApplicationUpdateRequest } from \"@zwave-js/serial/serialapi\";\nimport {\n\tSerialAPIStartedRequest,\n\tSerialAPIWakeUpReason,\n} from \"@zwave-js/serial/serialapi\";\nimport { GetControllerVersionRequest } from \"@zwave-js/serial/serialapi\";\nimport { SoftResetRequest } from \"@zwave-js/serial/serialapi\";\nimport {\n\tSendDataBridgeRequest,\n\tSendDataMulticastBridgeRequest,\n} from \"@zwave-js/serial/serialapi\";\nimport {\n\tMAX_SEND_ATTEMPTS,\n\tSendDataAbort,\n\tSendDataMulticastRequest,\n\tSendDataRequest,\n} from \"@zwave-js/serial/serialapi\";\nimport {\n\ttype SendDataMessage,\n\thasTXReport,\n\tisSendData,\n\tisSendDataSinglecast,\n\tisSendDataTransmitReport,\n\tisTransmitReport,\n} from \"@zwave-js/serial/serialapi\";\nimport {\n\tAsyncQueue,\n\tBytes,\n\ttype ThrowingMap,\n\tTypedEventEmitter,\n\tareUint8ArraysEqual,\n\tbuffer2hex,\n\tcloneDeep,\n\tcreateWrappingCounter,\n\tgetErrorMessage,\n\tisUint8Array,\n\tmergeDeep,\n\tnoop,\n\tnum2hex,\n\tpathExists,\n\tpick,\n} from \"@zwave-js/shared\";\nimport { distinct } from \"alcalzone-shared/arrays\";\nimport { wait } from \"alcalzone-shared/async\";\nimport {\n\ttype DeferredPromise,\n\tcreateDeferredPromise,\n} from \"alcalzone-shared/deferred-promise\";\nimport { isArray, isObject } from \"alcalzone-shared/typeguards\";\nimport type { EventEmitter } from \"node:events\";\nimport fs from \"node:fs/promises\";\nimport os from \"node:os\";\nimport path from \"node:path\";\nimport { URL } from \"node:url\";\nimport * as util from \"node:util\";\nimport { SerialPort } from \"serialport\";\nimport { InterpreterStatus, interpret } from \"xstate\";\nimport { ZWaveController } from \"../controller/Controller.js\";\nimport { InclusionState, RemoveNodeReason } from \"../controller/Inclusion.js\";\nimport { DriverLogger } from \"../log/Driver.js\";\nimport type { Endpoint } from \"../node/Endpoint.js\";\nimport type { ZWaveNode } from \"../node/Node.js\";\nimport {\n\tInterviewStage,\n\tNodeStatus,\n\ttype ZWaveNodeEventCallbacks,\n\ttype ZWaveNotificationCallback,\n\tzWaveNodeEvents,\n} from \"../node/_Types.js\";\n\nimport {\n\tSendTestFrameRequest,\n\tSendTestFrameTransmitReport,\n} from \"@zwave-js/serial/serialapi\";\nimport {\n\ttype CommandRequest,\n\ttype ContainsCC,\n\tcontainsCC,\n\tcontainsSerializedCC,\n\tisCommandRequest,\n} from \"@zwave-js/serial/serialapi\";\nimport { PACKAGE_NAME, PACKAGE_VERSION } from \"../_version.js\";\nimport { type ZWaveNodeBase } from \"../node/mixins/00_Base.js\";\nimport { type NodeWakeup } from \"../node/mixins/30_Wakeup.js\";\nimport { type NodeValues } from \"../node/mixins/40_Values.js\";\nimport { type SchedulePoll } from \"../node/mixins/60_ScheduledPoll.js\";\nimport { reportMissingDeviceConfig } from \"../telemetry/deviceConfig.js\";\nimport {\n\ttype AppInfo,\n\tcompileStatistics,\n\tsendStatistics,\n} from \"../telemetry/statistics.js\";\nimport { Bootloader } from \"./Bootloader.js\";\nimport { createMessageGenerator } from \"./MessageGenerators.js\";\nimport {\n\tcacheKeys,\n\tdeserializeNetworkCacheValue,\n\tmigrateLegacyNetworkCache,\n\tserializeNetworkCacheValue,\n} from \"./NetworkCache.js\";\nimport { type SerialAPIQueueItem, TransactionQueue } from \"./Queue.js\";\nimport {\n\ttype SerialAPICommandDoneData,\n\ttype SerialAPICommandInterpreter,\n\tcreateSerialAPICommandMachine,\n} from \"./SerialAPICommandMachine.js\";\nimport {\n\ttype TransactionReducer,\n\ttype TransactionReducerResult,\n\tcreateMessageDroppedUnexpectedError,\n\tserialAPICommandErrorToZWaveError,\n} from \"./StateMachineShared.js\";\nimport { TaskScheduler } from \"./Task.js\";\nimport { throttlePresets } from \"./ThrottlePresets.js\";\nimport { Transaction } from \"./Transaction.js\";\nimport {\n\ttype TransportServiceRXInterpreter,\n\tcreateTransportServiceRXMachine,\n} from \"./TransportServiceMachine.js\";\nimport { checkForConfigUpdates, installConfigUpdate } from \"./UpdateConfig.js\";\nimport { mergeUserAgent, userAgentComponentsToString } from \"./UserAgent.js\";\nimport type {\n\tEditableZWaveOptions,\n\tPartialZWaveOptions,\n\tZWaveOptions,\n} from \"./ZWaveOptions.js\";\nimport { discoverRemoteSerialPorts } from \"./mDNSDiscovery.js\";\n\nexport const libVersion: string = PACKAGE_VERSION;\nexport const libName: string = PACKAGE_NAME;\n\n// This is made with cfonts:\nconst libNameString = `\n\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\n\u255A\u2550\u2550\u2588\u2588\u2588\u2554\u255D \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557 \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D \u2588\u2588\u2551 \u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D\n \u2588\u2588\u2588\u2554\u255D \u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2551 \u2588\u2557 \u2588\u2588\u2551 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2551 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\n \u2588\u2588\u2588\u2554\u255D \u255A\u2550\u2550\u2550\u2550\u255D \u2588\u2588\u2551\u2588\u2588\u2588\u2557\u2588\u2588\u2551 \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2551 \u255A\u2588\u2588\u2557 \u2588\u2588\u2554\u255D \u2588\u2588\u2554\u2550\u2550\u255D \u2588\u2588 \u2588\u2588\u2551 \u255A\u2550\u2550\u2550\u2550\u2588\u2588\u2551\n\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u255A\u2588\u2588\u2588\u2554\u2588\u2588\u2588\u2554\u255D \u2588\u2588\u2551 \u2588\u2588\u2551 \u255A\u2588\u2588\u2588\u2588\u2554\u255D \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u255A\u2588\u2588\u2588\u2588\u2588\u2554\u255D \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551\n\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u255D\u255A\u2550\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D\n`;\n\nconst defaultOptions: ZWaveOptions = {\n\ttimeouts: {\n\t\tack: 1000,\n\t\tbyte: 150,\n\t\t// Ideally we'd want to have this as low as possible, but some\n\t\t// 500 series controllers can take several seconds to respond sometimes.\n\t\tresponse: 10000,\n\t\treport: 1000, // ReportTime timeout SHOULD be set to CommandTime + 1 second\n\t\tnonce: 5000,\n\t\tsendDataAbort: 20000, // If a controller takes over 15s to reach a node, it's probably not going to happen\n\t\tsendDataCallback: 30000, // INS13954 defines this to be 65000 ms, but waiting that long causes issues with reporting devices\n\t\tsendToSleep: 250, // The default should be enough time for applications to react to devices waking up\n\t\tretryJammed: 1000,\n\t\trefreshValue: 5000, // Default should handle most slow devices until we have a better solution\n\t\trefreshValueAfterTransition: 1000, // To account for delays in the device\n\t\tserialAPIStarted: 5000,\n\t},\n\tattempts: {\n\t\topenSerialPort: 10,\n\t\tcontroller: 3,\n\t\tsendData: 3,\n\t\tsendDataJammed: 5,\n\t\tnodeInterview: 5,\n\t},\n\tdisableOptimisticValueUpdate: false,\n\tfeatures: {\n\t\t// By default enable soft reset unless the env variable is set\n\t\tsoftReset: !process.env.ZWAVEJS_DISABLE_SOFT_RESET,\n\t\t// By default enable the unresponsive controller recovery unless the env variable is set\n\t\tunresponsiveControllerRecovery: !process.env\n\t\t\t.ZWAVEJS_DISABLE_UNRESPONSIVE_CONTROLLER_RECOVERY,\n\t\t// By default enable the watchdog, unless the env variable is set\n\t\twatchdog: !process.env.ZWAVEJS_DISABLE_WATCHDOG,\n\t},\n\tinterview: {\n\t\tqueryAllUserCodes: false,\n\t},\n\tstorage: {\n\t\tdriver: {\n\t\t\tasync ensureDir(path) {\n\t\t\t\tawait fs.mkdir(path, { recursive: true });\n\t\t\t},\n\t\t\tpathExists(path) {\n\t\t\t\treturn pathExists(path);\n\t\t\t},\n\t\t\treadFile(file, encoding) {\n\t\t\t\treturn fs.readFile(file, { encoding });\n\t\t\t},\n\t\t\twriteFile(file, data, options) {\n\t\t\t\treturn fs.writeFile(file, data, options);\n\t\t\t},\n\t\t},\n\t\tcacheDir: path.join(process.cwd(), \"cache\"),\n\t\tlockDir: process.env.ZWAVEJS_LOCK_DIRECTORY,\n\t\tthrottle: \"normal\",\n\t},\n\tpreferences: {\n\t\tscales: {},\n\t},\n};\n\n/** Ensures that the options are valid */\nfunction checkOptions(options: ZWaveOptions): void {\n\tif (options.timeouts.ack < 1) {\n\t\tthrow new ZWaveError(\n\t\t\t`The ACK timeout must be positive!`,\n\t\t\tZWaveErrorCodes.Driver_InvalidOptions,\n\t\t);\n\t}\n\tif (options.timeouts.byte < 1) {\n\t\tthrow new ZWaveError(\n\t\t\t`The BYTE timeout must be positive!`,\n\t\t\tZWaveErrorCodes.Driver_InvalidOptions,\n\t\t);\n\t}\n\tif (options.timeouts.response < 500 || options.timeouts.response > 60000) {\n\t\tthrow new ZWaveError(\n\t\t\t`The Response timeout must be between 500 and 60000 milliseconds!`,\n\t\t\tZWaveErrorCodes.Driver_InvalidOptions,\n\t\t);\n\t}\n\tif (options.timeouts.report < 500 || options.timeouts.report > 10000) {\n\t\tthrow new ZWaveError(\n\t\t\t`The Report timeout must be between 500 and 10000 milliseconds!`,\n\t\t\tZWaveErrorCodes.Driver_InvalidOptions,\n\t\t);\n\t}\n\tif (options.timeouts.nonce < 3000 || options.timeouts.nonce > 20000) {\n\t\tthrow new ZWaveError(\n\t\t\t`The Nonce timeout must be between 3000 and 20000 milliseconds!`,\n\t\t\tZWaveErrorCodes.Driver_InvalidOptions,\n\t\t);\n\t}\n\tif (\n\t\toptions.timeouts.retryJammed < 10 || options.timeouts.retryJammed > 5000\n\t) {\n\t\tthrow new ZWaveError(\n\t\t\t`The timeout for retrying while jammed must be between 10 and 5000 milliseconds!`,\n\t\t\tZWaveErrorCodes.Driver_InvalidOptions,\n\t\t);\n\t}\n\tif (\n\t\toptions.timeouts.sendToSleep < 10 || options.timeouts.sendToSleep > 5000\n\t) {\n\t\tthrow new ZWaveError(\n\t\t\t`The Send To Sleep timeout must be between 10 and 5000 milliseconds!`,\n\t\t\tZWaveErrorCodes.Driver_InvalidOptions,\n\t\t);\n\t}\n\tif (options.timeouts.sendDataCallback < 10000) {\n\t\tthrow new ZWaveError(\n\t\t\t`The Send Data Callback timeout must be at least 10000 milliseconds!`,\n\t\t\tZWaveErrorCodes.Driver_InvalidOptions,\n\t\t);\n\t}\n\tif (\n\t\toptions.timeouts.sendDataAbort < 5000\n\t\t|| options.timeouts.sendDataAbort\n\t\t\t> options.timeouts.sendDataCallback - 5000\n\t) {\n\t\tthrow new ZWaveError(\n\t\t\t`The Send Data Abort Callback timeout must be between 5000 and ${\n\t\t\t\toptions.timeouts.sendDataCallback - 5000\n\t\t\t} milliseconds!`,\n\t\t\tZWaveErrorCodes.Driver_InvalidOptions,\n\t\t);\n\t}\n\tif (\n\t\toptions.timeouts.serialAPIStarted < 1000\n\t\t|| options.timeouts.serialAPIStarted > 30000\n\t) {\n\t\tthrow new ZWaveError(\n\t\t\t`The Serial API started timeout must be between 1000 and 30000 milliseconds!`,\n\t\t\tZWaveErrorCodes.Driver_InvalidOptions,\n\t\t);\n\t}\n\tif (options.securityKeys != undefined) {\n\t\tconst keys = Object.entries(options.securityKeys);\n\t\tfor (let i = 0; i < keys.length; i++) {\n\t\t\tconst [secClass, key] = keys[i];\n\t\t\tif (key.length !== 16) {\n\t\t\t\tthrow new ZWaveError(\n\t\t\t\t\t`The security key for class ${secClass} must be a buffer with length 16!`,\n\t\t\t\t\tZWaveErrorCodes.Driver_InvalidOptions,\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (keys.findIndex(([, k]) => areUint8ArraysEqual(k, key)) !== i) {\n\t\t\t\tthrow new ZWaveError(\n\t\t\t\t\t`The security key for class ${secClass} was used multiple times!`,\n\t\t\t\t\tZWaveErrorCodes.Driver_InvalidOptions,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\tif (options.attempts.controller < 1 || options.attempts.controller > 3) {\n\t\tthrow new ZWaveError(\n\t\t\t`The Controller attempts must be between 1 and 3!`,\n\t\t\tZWaveErrorCodes.Driver_InvalidOptions,\n\t\t);\n\t}\n\tif (\n\t\toptions.attempts.sendData < 1\n\t\t|| options.attempts.sendData > MAX_SEND_ATTEMPTS\n\t) {\n\t\tthrow new ZWaveError(\n\t\t\t`The SendData attempts must be between 1 and ${MAX_SEND_ATTEMPTS}!`,\n\t\t\tZWaveErrorCodes.Driver_InvalidOptions,\n\t\t);\n\t}\n\tif (\n\t\toptions.attempts.sendDataJammed < 1\n\t\t|| options.attempts.sendDataJammed > 10\n\t) {\n\t\tthrow new ZWaveError(\n\t\t\t`The SendData attempts while jammed must be between 1 and 10!`,\n\t\t\tZWaveErrorCodes.Driver_InvalidOptions,\n\t\t);\n\t}\n\tif (\n\t\toptions.attempts.nodeInterview < 1\n\t\t|| options.attempts.nodeInterview > 10\n\t) {\n\t\tthrow new ZWaveError(\n\t\t\t`The Node interview attempts must be between 1 and 10!`,\n\t\t\tZWaveErrorCodes.Driver_InvalidOptions,\n\t\t);\n\t}\n\n\tif (options.inclusionUserCallbacks) {\n\t\tif (!isObject(options.inclusionUserCallbacks)) {\n\t\t\tthrow new ZWaveError(\n\t\t\t\t`The inclusionUserCallbacks must be an object!`,\n\t\t\t\tZWaveErrorCodes.Driver_InvalidOptions,\n\t\t\t);\n\t\t} else if (\n\t\t\ttypeof options.inclusionUserCallbacks.grantSecurityClasses\n\t\t\t\t!== \"function\"\n\t\t\t|| typeof options.inclusionUserCallbacks.validateDSKAndEnterPIN\n\t\t\t\t!== \"function\"\n\t\t\t|| typeof options.inclusionUserCallbacks.abort !== \"function\"\n\t\t) {\n\t\t\tthrow new ZWaveError(\n\t\t\t\t`The inclusionUserCallbacks must contain the following functions: grantSecurityClasses, validateDSKAndEnterPIN, abort!`,\n\t\t\t\tZWaveErrorCodes.Driver_InvalidOptions,\n\t\t\t);\n\t\t}\n\t}\n\n\tif (options.joinNetworkUserCallbacks) {\n\t\tif (!isObject(options.joinNetworkUserCallbacks)) {\n\t\t\tthrow new ZWaveError(\n\t\t\t\t`The joinNetworkUserCallbacks must be an object!`,\n\t\t\t\tZWaveErrorCodes.Driver_InvalidOptions,\n\t\t\t);\n\t\t} else if (\n\t\t\ttypeof options.joinNetworkUserCallbacks.showDSK\n\t\t\t\t!== \"function\"\n\t\t\t|| typeof options.joinNetworkUserCallbacks.done\n\t\t\t\t!== \"function\"\n\t\t) {\n\t\t\tthrow new ZWaveError(\n\t\t\t\t`The joinNetworkUserCallbacks must contain the following functions: showDSK, done!`,\n\t\t\t\tZWaveErrorCodes.Driver_InvalidOptions,\n\t\t\t);\n\t\t}\n\t}\n\n\tif (options.rf != undefined) {\n\t\tif (options.rf.region != undefined) {\n\t\t\tif (\n\t\t\t\ttypeof options.rf.region !== \"number\"\n\t\t\t\t|| !(options.rf.region in RFRegion)\n\t\t\t\t|| options.rf.region === RFRegion.Unknown\n\t\t\t) {\n\t\t\t\tthrow new ZWaveError(\n\t\t\t\t\t`${options.rf.region} is not a valid RF region!`,\n\t\t\t\t\tZWaveErrorCodes.Driver_InvalidOptions,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tif (options.rf.txPower != undefined) {\n\t\t\tif (!isObject(options.rf.txPower)) {\n\t\t\t\tthrow new ZWaveError(\n\t\t\t\t\t`rf.txPower must be an object!`,\n\t\t\t\t\tZWaveErrorCodes.Driver_InvalidOptions,\n\t\t\t\t);\n\t\t\t} else if (\n\t\t\t\ttypeof options.rf.txPower.powerlevel !== \"number\"\n\t\t\t\t|| typeof options.rf.txPower.measured0dBm !== \"number\"\n\t\t\t) {\n\t\t\t\tthrow new ZWaveError(\n\t\t\t\t\t`rf.txPower must contain the following numeric properties: powerlevel, measured0dBm!`,\n\t\t\t\t\tZWaveErrorCodes.Driver_InvalidOptions,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Function signature for a message handler. The return type signals if the\n * message was handled (`true`) or further handlers should be called (`false`)\n */\nexport type RequestHandler<T extends Message = Message> = (\n\tmsg: T,\n) => boolean | Promise<boolean>;\ninterface RequestHandlerEntry<T extends Message = Message> {\n\tinvoke: RequestHandler<T>;\n\toneTime: boolean;\n}\n\ninterface AwaitedThing<T> {\n\thandler: (thing: T) => void;\n\ttimeout?: NodeJS.Timeout;\n\tpredicate: (msg: T) => boolean;\n\trefreshPredicate?: (msg: T) => boolean;\n}\n\ntype AwaitedMessageHeader = AwaitedThing<MessageHeaders>;\ntype AwaitedMessageEntry = AwaitedThing<Message>;\ntype AwaitedCommandEntry = AwaitedThing<CCId>;\nexport type AwaitedBootloaderChunkEntry = AwaitedThing<BootloaderChunk>;\n\ninterface TransportServiceSession {\n\tfragmentSize: number;\n\tinterpreter: TransportServiceRXInterpreter;\n}\n\ninterface Sessions {\n\t/** A map of all current Transport Service sessions that may still receive updates */\n\ttransportService: Map<number, TransportServiceSession>;\n\t/** A map of all current supervision sessions that may still receive updates */\n\tsupervision: Map<number, SupervisionUpdateHandler>;\n}\n\n// Used to add all node events to the driver event callbacks, but prefixed with \"node \"\ntype PrefixedNodeEvents = {\n\t[\n\t\tK in keyof ZWaveNodeEventCallbacks as K extends string ? `node ${K}`\n\t\t\t: never\n\t]: ZWaveNodeEventCallbacks[K];\n};\n\nconst enum ControllerRecoveryPhase {\n\tNone,\n\tACKTimeout,\n\tACKTimeoutAfterReset,\n\tCallbackTimeout,\n\tCallbackTimeoutAfterReset,\n\tJammed,\n\tJammedAfterReset,\n}\n\nfunction messageIsPing<T extends Message>(\n\tmsg: T,\n): msg is T & ContainsCC<NoOperationCC> {\n\treturn containsCC(msg) && msg.command instanceof NoOperationCC;\n}\n\nfunction assertValidCCs(container: ContainsCC): void {\n\tif (container.command instanceof InvalidCC) {\n\t\tif (typeof container.command.reason === \"number\") {\n\t\t\tthrow new ZWaveError(\n\t\t\t\t\"The message payload failed validation!\",\n\t\t\t\tcontainer.command.reason,\n\t\t\t);\n\t\t} else {\n\t\t\tthrow new ZWaveError(\n\t\t\t\t\"The message payload is invalid!\",\n\t\t\t\tZWaveErrorCodes.PacketFormat_InvalidPayload,\n\t\t\t\tcontainer.command.reason,\n\t\t\t);\n\t\t}\n\t} else if (containsCC(container.command)) {\n\t\tassertValidCCs(container.command);\n\t}\n}\n\n// Strongly type the event emitter events\nexport interface DriverEventCallbacks extends PrefixedNodeEvents {\n\t\"driver ready\": () => void;\n\t\"bootloader ready\": () => void;\n\t\"all nodes ready\": () => void;\n\terror: (err: Error) => void;\n}\n\nexport type DriverEvents = Extract<keyof DriverEventCallbacks, string>;\n\n/**\n * The driver is the core of this library. It controls the serial interface,\n * handles transmission and receipt of messages and manages the network cache.\n * Any action you want to perform on the Z-Wave network must go through a driver\n * instance or its associated nodes.\n */\nexport class Driver extends TypedEventEmitter<DriverEventCallbacks>\n\timplements\n\t\tCCAPIHost,\n\t\tInterviewContext,\n\t\tRefreshValuesContext,\n\t\tPersistValuesContext\n{\n\tpublic constructor(\n\t\tprivate port: string | ZWaveSerialPortImplementation,\n\t\t...optionsAndPresets: (PartialZWaveOptions | undefined)[]\n\t) {\n\t\tsuper();\n\n\t\t// Ensure the given serial port is valid\n\t\tif (\n\t\t\ttypeof port !== \"string\"\n\t\t\t&& !isZWaveSerialPortImplementation(port)\n\t\t) {\n\t\t\tthrow new ZWaveError(\n\t\t\t\t`The port must be a string or a valid custom serial port implementation!`,\n\t\t\t\tZWaveErrorCodes.Driver_InvalidOptions,\n\t\t\t);\n\t\t}\n\n\t\t// Deep-Merge all given options/presets\n\t\tconst definedOptionsAndPresets = optionsAndPresets.filter(\n\t\t\t(o): o is PartialZWaveOptions => !!o,\n\t\t);\n\t\tlet mergedOptions: PartialZWaveOptions = {};\n\t\tfor (const preset of definedOptionsAndPresets) {\n\t\t\tmergedOptions = mergeDeep(mergedOptions, preset, true);\n\t\t}\n\t\t// Finally apply the defaults, without overwriting any existing settings\n\t\tthis._options = mergeDeep(\n\t\t\tmergedOptions,\n\t\t\tcloneDeep(defaultOptions),\n\t\t) as ZWaveOptions;\n\n\t\t// And make sure they contain valid values\n\t\tcheckOptions(this._options);\n\t\tif (this._options.userAgent) {\n\t\t\tif (!isObject(this._options.userAgent)) {\n\t\t\t\tthrow new ZWaveError(\n\t\t\t\t\t`The userAgent property must be an object!`,\n\t\t\t\t\tZWaveErrorCodes.Driver_InvalidOptions,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tthis.updateUserAgent(this._options.userAgent);\n\t\t}\n\n\t\t// Initialize logging\n\t\tthis._logContainer = new ZWaveLogContainer(this._options.logConfig);\n\t\tthis._driverLog = new DriverLogger(this, this._logContainer);\n\t\tthis._controllerLog = new ControllerLogger(this._logContainer);\n\n\t\t// Initialize the cache\n\t\tthis.cacheDir = this._options.storage.cacheDir;\n\n\t\t// Initialize config manager\n\t\tthis.configManager = new ConfigManager({\n\t\t\tlogContainer: this._logContainer,\n\t\t\tdeviceConfigPriorityDir:\n\t\t\t\tthis._options.storage.deviceConfigPriorityDir,\n\t\t\tdeviceConfigExternalDir:\n\t\t\t\tthis._options.storage.deviceConfigExternalDir,\n\t\t});\n\n\t\tconst self = this;\n\t\tthis.messageEncodingContext = {\n\t\t\tgetHighestSecurityClass: (nodeId) =>\n\t\t\t\tthis.getHighestSecurityClass(nodeId),\n\t\t\thasSecurityClass: (nodeId, securityClass) =>\n\t\t\t\tthis.hasSecurityClass(nodeId, securityClass),\n\t\t\tsetSecurityClass: (nodeId, securityClass, granted) =>\n\t\t\t\tthis.setSecurityClass(nodeId, securityClass, granted),\n\t\t\tgetDeviceConfig: (nodeId) => this.getDeviceConfig(nodeId),\n\t\t\t// These are evaluated lazily, so we cannot spread messageParsingContext unfortunately\n\t\t\tget securityManager() {\n\t\t\t\treturn self.securityManager;\n\t\t\t},\n\t\t\tget securityManager2() {\n\t\t\t\treturn self.securityManager2;\n\t\t\t},\n\t\t\tget securityManagerLR() {\n\t\t\t\treturn self.securityManagerLR;\n\t\t\t},\n\t\t\tgetSupportedCCVersion: (cc, nodeId, endpointIndex) =>\n\t\t\t\tthis.getSupportedCCVersion(cc, nodeId, endpointIndex),\n\t\t};\n\n\t\tthis.immediateQueue = new TransactionQueue({\n\t\t\tname: \"immediate\",\n\t\t\tmayStartNextTransaction: (t) => {\n\t\t\t\t// While the controller is unresponsive, only soft resetting is allowed.\n\t\t\t\t// Since we use GetControllerVersionRequest to check if the controller responds after soft-reset,\n\t\t\t\t// allow that too.\n\t\t\t\tif (this.controller.status === ControllerStatus.Unresponsive) {\n\t\t\t\t\treturn t.message instanceof SoftResetRequest\n\t\t\t\t\t\t|| t.message instanceof GetControllerVersionRequest;\n\t\t\t\t}\n\n\t\t\t\t// While the controller is jammed, only soft resetting is allowed\n\t\t\t\tif (this.controller.status === ControllerStatus.Jammed) {\n\t\t\t\t\treturn t.message instanceof SoftResetRequest;\n\t\t\t\t}\n\n\t\t\t\t// All other messages on the immediate queue may always be sent as long as the controller is ready to send\n\t\t\t\treturn !this.queuePaused\n\t\t\t\t\t&& this.controller.status === ControllerStatus.Ready;\n\t\t\t},\n\t\t});\n\t\tthis.queue = new TransactionQueue({\n\t\t\tname: \"normal\",\n\t\t\tmayStartNextTransaction: (t) => this.mayStartTransaction(t),\n\t\t});\n\t\tthis.serialAPIQueue = new AsyncQueue();\n\t\tthis._queueIdle = false;\n\n\t\tthis._scheduler = new TaskScheduler();\n\t}\n\n\t/** The serial port instance */\n\tprivate serial: ZWaveSerialPortBase | undefined;\n\n\tprivate messageEncodingContext: Omit<\n\t\tMessageEncodingContext,\n\t\tkeyof HostIDs | \"nodeIdType\"\n\t>;\n\n\tprivate getEncodingContext(): MessageEncodingContext & CCEncodingContext {\n\t\treturn {\n\t\t\t...this.messageEncodingContext,\n\t\t\townNodeId: this.controller.ownNodeId!,\n\t\t\thomeId: this.controller.homeId!,\n\t\t\tnodeIdType: this._controller?.nodeIdType ?? NodeIDType.Short,\n\t\t};\n\t}\n\n\tprivate getMessageParsingContext(): MessageParsingContext {\n\t\treturn {\n\t\t\tgetDeviceConfig: (nodeId) => this.getDeviceConfig(nodeId),\n\t\t\tsdkVersion: this._controller?.sdkVersion,\n\t\t\trequestStorage: this._requestStorage,\n\t\t\townNodeId: this.controller.ownNodeId!,\n\t\t\thomeId: this.controller.homeId!,\n\t\t\tnodeIdType: this._controller?.nodeIdType ?? NodeIDType.Short,\n\t\t};\n\t}\n\n\tprivate getCCParsingContext(): Omit<\n\t\tCCParsingContext,\n\t\t\"sourceNodeId\" | \"frameType\"\n\t> {\n\t\treturn {\n\t\t\t...this.messageEncodingContext,\n\t\t\townNodeId: this.controller.ownNodeId!,\n\t\t\thomeId: this.controller.homeId!,\n\t\t};\n\t}\n\n\t// We have multiple queues to achieve multiple \"layers\" of communication priority:\n\t// The default queue for most messages\n\tprivate queue: TransactionQueue;\n\t// An immediate queue for handling queries that need to be handled ASAP, e.g. Nonce Get\n\tprivate immediateQueue: TransactionQueue;\n\t// And all of them feed into the serial API queue, which contains commands that will be sent ASAP\n\tprivate serialAPIQueue: AsyncQueue<SerialAPIQueueItem>;\n\n\t/** Gives access to the transaction queues, ordered by priority */\n\tprivate get queues(): TransactionQueue[] {\n\t\treturn [this.immediateQueue, this.queue];\n\t}\n\n\tprivate _scheduler: TaskScheduler;\n\tpublic get scheduler(): TaskScheduler {\n\t\treturn this._scheduler;\n\t}\n\n\tprivate queuePaused = false;\n\t/** The interpreter for the currently active Serial API command */\n\tprivate serialAPIInterpreter: SerialAPICommandInterpreter | undefined;\n\n\t// Keep track of which queues are currently busy\n\tprivate _queuesBusyFlags = 0;\n\tprivate _queueIdle: boolean;\n\t/** Whether the queue is currently idle */\n\tpublic get queueIdle(): boolean {\n\t\treturn this._queueIdle;\n\t}\n\tprivate set queueIdle(value: boolean) {\n\t\tif (this._queueIdle !== value) {\n\t\t\tthis.driverLog.print(\n\t\t\t\tvalue ? \"all queues idle\" : \"one or more queues busy\",\n\t\t\t);\n\t\t\tthis._queueIdle = value;\n\t\t\tthis.handleQueueIdleChange(value);\n\t\t}\n\t}\n\n\t/** A map of handlers for all sorts of requests */\n\tprivate requestHandlers = new Map<FunctionType, RequestHandlerEntry[]>();\n\t/** A list of awaited message headers */\n\tprivate awaitedMessageHeaders: AwaitedMessageHeader[] = [];\n\t/** A list of awaited messages */\n\tprivate awaitedMessages: AwaitedMessageEntry[] = [];\n\t/** A list of awaited commands */\n\tprivate awaitedCommands: AwaitedCommandEntry[] = [];\n\t/** A list of awaited chunks from the bootloader */\n\tprivate awaitedBootloaderChunks: AwaitedBootloaderChunkEntry[] = [];\n\n\t/** A map of Node ID -> ongoing sessions */\n\tprivate nodeSessions = new Map<number, Sessions>();\n\tprivate ensureNodeSessions(nodeId: number): Sessions {\n\t\tif (!this.nodeSessions.has(nodeId)) {\n\t\t\tthis.nodeSessions.set(nodeId, {\n\t\t\t\ttransportService: new Map(),\n\t\t\t\tsupervision: new Map(),\n\t\t\t});\n\t\t}\n\t\treturn this.nodeSessions.get(nodeId)!;\n\t}\n\n\tprivate _requestStorage: Map<FunctionType, Record<string, unknown>> =\n\t\tnew Map();\n\t/**\n\t * @internal\n\t * Stores data from Serial API command requests to be used by their responses\n\t */\n\tpublic get requestStorage(): Map<FunctionType, Record<string, unknown>> {\n\t\treturn this._requestStorage;\n\t}\n\n\tpublic readonly cacheDir: string;\n\n\tprivate _valueDB: JsonlDB | undefined;\n\t/** @internal */\n\tpublic get valueDB(): JsonlDB | undefined {\n\t\treturn this._valueDB;\n\t}\n\tprivate _metadataDB: JsonlDB<ValueMetadata> | undefined;\n\t/** @internal */\n\tpublic get metadataDB(): JsonlDB<ValueMetadata> | undefined {\n\t\treturn this._metadataDB;\n\t}\n\tprivate _networkCache: JsonlDB<any> | undefined;\n\t/** @internal */\n\tpublic get networkCache(): JsonlDB<any> {\n\t\tif (this._networkCache == undefined) {\n\t\t\tthrow new ZWaveError(\n\t\t\t\t\"The network cache was not yet initialized!\",\n\t\t\t\tZWaveErrorCodes.Driver_NotReady,\n\t\t\t);\n\t\t}\n\t\treturn this._networkCache;\n\t}\n\n\tpublic readonly configManager: ConfigManager;\n\tpublic get configVersion(): string {\n\t\treturn (\n\t\t\tthis.configManager?.configVersion\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-require-imports\n\t\t\t\t?? require(\"zwave-js/package.json\")?.dependencies\n\t\t\t\t\t?.[\"@zwave-js/config\"]\n\t\t\t\t?? libVersion\n\t\t);\n\t}\n\n\tprivate _logContainer: ZWaveLogContainer;\n\tprivate _driverLog: DriverLogger;\n\t/** @internal */\n\tpublic get driverLog(): DriverLogger {\n\t\treturn this._driverLog;\n\t}\n\n\tprivate _controllerLog: ControllerLogger;\n\t/** @internal */\n\tpublic get controllerLog(): ControllerLogger {\n\t\treturn this._controllerLog;\n\t}\n\n\tpublic logNode(\n\t\tnodeId: number,\n\t\tmessage: string,\n\t\tlevel?: LogNodeOptions[\"level\"],\n\t): void;\n\tpublic logNode(nodeId: number, options: LogNodeOptions): void;\n\tpublic logNode(...args: any[]): void {\n\t\t// @ts-expect-error\n\t\tthis._controllerLog.logNode(...args);\n\t}\n\n\tprivate _controller: ZWaveController | undefined;\n\t/** Encapsulates information about the Z-Wave controller and provides access to its nodes */\n\tpublic get controller(): ZWaveController {\n\t\tif (this._controller == undefined) {\n\t\t\tthrow new ZWaveError(\n\t\t\t\t\"The controller is not yet ready!\",\n\t\t\t\tZWaveErrorCodes.Driver_NotReady,\n\t\t\t);\n\t\t}\n\t\treturn this._controller;\n\t}\n\n\t/** While in bootloader mode, this encapsulates information about the bootloader and its state */\n\tprivate _bootloader: Bootloader | undefined;\n\t/** @internal */\n\tpublic get bootloader(): Bootloader {\n\t\tif (this._bootloader == undefined) {\n\t\t\tthrow new ZWaveError(\n\t\t\t\t\"The controller is not in bootloader mode!\",\n\t\t\t\tZWaveErrorCodes.Driver_NotReady,\n\t\t\t);\n\t\t}\n\t\treturn this._bootloader;\n\t}\n\n\tpublic isInBootloader(): boolean {\n\t\treturn this._bootloader != undefined;\n\t}\n\n\tprivate _recoveryPhase: ControllerRecoveryPhase =\n\t\tControllerRecoveryPhase.None;\n\n\tprivate _securityManager: SecurityManager | undefined;\n\t/**\n\t * **!!! INTERNAL !!!**\n\t *\n\t * Not intended to be used by applications\n\t */\n\tpublic get securityManager(): SecurityManager | undefined {\n\t\treturn this._securityManager;\n\t}\n\n\tprivate _securityManager2: SecurityManager2 | undefined;\n\t/**\n\t * **!!! INTERNAL !!!**\n\t *\n\t * Not intended to be used by applications\n\t */\n\tpublic get securityManager2(): SecurityManager2 | undefined {\n\t\treturn this._securityManager2;\n\t}\n\n\tprivate _securityManagerLR: SecurityManager2 | undefined;\n\t/**\n\t * **!!! INTERNAL !!!**\n\t *\n\t * Not intended to be used by applications\n\t */\n\tpublic get securityManagerLR(): SecurityManager2 | undefined {\n\t\treturn this._securityManagerLR;\n\t}\n\n\t/** @internal */\n\tpublic getSecurityManager2(\n\t\tdestination: number | MulticastDestination,\n\t): SecurityManager2 | undefined {\n\t\tconst nodeId = isArray(destination) ? destination[0] : destination;\n\t\tconst isLongRange = isLongRangeNodeId(nodeId);\n\t\treturn isLongRange ? this.securityManagerLR : this.securityManager2;\n\t}\n\n\tprivate _learnModeAuthenticatedKeyPair: KeyPair | undefined;\n\t/** @internal */\n\tpublic getLearnModeAuthenticatedKeyPair(): KeyPair {\n\t\tif (this._learnModeAuthenticatedKeyPair == undefined) {\n\t\t\t// Try restoring from cache\n\t\t\tconst privateKey = this.cacheGet<Uint8Array>(\n\t\t\t\tcacheKeys.controller.privateKey,\n\t\t\t);\n\t\t\tif (privateKey) {\n\t\t\t\tthis._learnModeAuthenticatedKeyPair =\n\t\t\t\t\tkeyPairFromRawECDHPrivateKeySync(privateKey);\n\t\t\t} else {\n\t\t\t\t// Not found in cache, create a new one and cache it\n\t\t\t\tthis._learnModeAuthenticatedKeyPair = generateECDHKeyPairSync();\n\t\t\t\tthis.cacheSet(\n\t\t\t\t\tcacheKeys.controller.privateKey,\n\t\t\t\t\textractRawECDHPrivateKeySync(\n\t\t\t\t\t\tthis._learnModeAuthenticatedKeyPair.privateKey,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\treturn this._learnModeAuthenticatedKeyPair;\n\t}\n\n\t/**\n\t * **!!! INTERNAL !!!**\n\t *\n\t * Not intended to be used by applications. Use `controller.homeId` instead!\n\t */\n\tpublic get homeId(): number {\n\t\t// This is needed for the ZWaveHost interface\n\t\treturn this.controller.homeId!;\n\t}\n\n\t/**\n\t * **!!! INTERNAL !!!**\n\t *\n\t * Not intended to be used by applications. Use `controller.ownNodeId` instead!\n\t */\n\tpublic get ownNodeId(): number {\n\t\t// This is needed for the ZWaveHost interface\n\t\treturn this.controller.ownNodeId!;\n\t}\n\n\t/** @internal Used for compatibility with the CCAPIHost interface */\n\tpublic getNode(nodeId: number): ZWaveNode | undefined {\n\t\treturn this.controller.nodes.get(nodeId);\n\t}\n\n\t/** @internal Used for compatibility with the CCAPIHost interface */\n\tpublic getNodeOrThrow(nodeId: number): ZWaveNode {\n\t\treturn this.controller.nodes.getOrThrow(nodeId);\n\t}\n\n\t/** @internal Used for compatibility with the CCAPIHost interface */\n\tpublic getAllNodes(): ZWaveNode[] {\n\t\treturn [...this.controller.nodes.values()];\n\t}\n\n\tpublic tryGetNode(msg: Message): ZWaveNode | undefined {\n\t\tconst nodeId = msg.getNodeId();\n\t\tif (nodeId != undefined) return this.controller.nodes.get(nodeId);\n\t}\n\n\tpublic tryGetEndpoint(cc: CommandClass): Endpoint | undefined {\n\t\tif (cc.isSinglecast()) {\n\t\t\treturn this.controller.nodes\n\t\t\t\t.get(cc.nodeId)\n\t\t\t\t?.getEndpoint(cc.endpointIndex);\n\t\t}\n\t}\n\n\t/**\n\t * **!!! INTERNAL !!!**\n\t *\n\t * Not intended to be used by applications\n\t */\n\tpublic getValueDB(nodeId: number): ValueDB {\n\t\t// This is needed for the ZWaveHost interface\n\t\tconst node = this.controller.nodes.getOrThrow(nodeId);\n\t\treturn node.valueDB;\n\t}\n\n\t/**\n\t * **!!! INTERNAL !!!**\n\t *\n\t * Not intended to be used by applications\n\t */\n\tpublic tryGetValueDB(nodeId: number): ValueDB | undefined {\n\t\t// This is needed for the ZWaveHost interface\n\t\tconst node = this.controller.nodes.get(nodeId);\n\t\treturn node?.valueDB;\n\t}\n\n\tpublic getDeviceConfig(nodeId: number): DeviceConfig | undefined {\n\t\t// This is needed for the ZWaveHost interface\n\t\treturn this.controller.nodes.get(nodeId)?.deviceConfig;\n\t}\n\n\tpublic lookupManufacturer(manufacturerId: number): string | undefined {\n\t\treturn this.configManager.lookupManufacturer(manufacturerId);\n\t}\n\n\tpublic getHighestSecurityClass(\n\t\tnodeId: number,\n\t): MaybeNotKnown<SecurityClass> {\n\t\t// This is needed for the ZWaveHost interface\n\t\tconst node = this.controller.nodes.getOrThrow(nodeId);\n\t\treturn node.getHighestSecurityClass();\n\t}\n\n\tpublic hasSecurityClass(\n\t\tnodeId: number,\n\t\tsecurityClass: SecurityClass,\n\t): MaybeNotKnown<boolean> {\n\t\t// This is needed for the ZWaveHost interface\n\t\tconst node = this.controller.nodes.getOrThrow(nodeId);\n\t\treturn node.hasSecurityClass(securityClass);\n\t}\n\n\t/**\n\t * **!!! INTERNAL !!!**\n\t *\n\t * Not intended to be used by applications\n\t */\n\tpublic setSecurityClass(\n\t\tnodeId: number,\n\t\tsecurityClass: SecurityClass,\n\t\tgranted: boolean,\n\t): void {\n\t\t// This is needed for the ZWaveHost interface\n\t\tconst node = this.controller.nodes.getOrThrow(nodeId);\n\t\tnode.setSecurityClass(securityClass, granted);\n\t}\n\n\t/** Updates the logging configuration without having to restart the driver. */\n\tpublic updateLogConfig(config: Partial<LogConfig>): void {\n\t\tthis._logContainer.updateConfiguration(config);\n\t}\n\n\t/** Returns the current logging configuration. */\n\tpublic getLogConfig(): LogConfig {\n\t\treturn this._logContainer.getConfiguration();\n\t}\n\n\t/** Updates the preferred sensor scales to use for node queries */\n\tpublic setPreferredScales(\n\t\tscales: ZWaveOptions[\"preferences\"][\"scales\"],\n\t): void {\n\t\tthis._options.preferences.scales = mergeDeep(\n\t\t\tdefaultOptions.preferences.scales,\n\t\t\tscales,\n\t\t);\n\t}\n\n\t/**\n\t * **!!! INTERNAL !!!**\n\t *\n\t * Not intended to be used by applications\n\t */\n\tpublic getUserPreferences(): ZWaveHostOptions[\"preferences\"] {\n\t\treturn this._options.preferences;\n\t}\n\n\t/**\n\t * **!!! INTERNAL !!!**\n\t *\n\t * Not intended to be used by applications\n\t */\n\tpublic getInterviewOptions(): ZWaveHostOptions[\"interview\"] {\n\t\treturn this._options.interview;\n\t}\n\n\t/**\n\t * **!!! INTERNAL !!!**\n\t *\n\t * Not intended to be used by applications\n\t */\n\tpublic getCommunicationTimeouts(): ZWaveHostOptions[\"timeouts\"] {\n\t\treturn this._options.timeouts;\n\t}\n\n\t/**\n\t * Enumerates all existing serial ports.\n\t * @param local Whether to include local serial ports\n\t * @param remote Whether to discover remote serial ports using an mDNS query for the `_zwave._tcp` domain\n\t */\n\tpublic static async enumerateSerialPorts({\n\t\tlocal = true,\n\t\tremote = true,\n\t}: {\n\t\tlocal?: boolean;\n\t\tremote?: boolean;\n\t} = {}): Promise<string[]> {\n\t\tconst symlinkedPorts: string[] = [];\n\t\tconst localPorts: string[] = [];\n\t\tconst remotePorts: string[] = [];\n\t\tif (local) {\n\t\t\t// Put symlinks to the serial ports first if possible\n\t\t\tif (os.platform() === \"linux\") {\n\t\t\t\tconst dir = \"/dev/serial/by-id\";\n\t\t\t\tconst symlinks = await fs.readdir(dir).catch(() => []);\n\n\t\t\t\tfor (const l of symlinks) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst fullPath = path.join(dir, l);\n\t\t\t\t\t\tconst target = path.join(\n\t\t\t\t\t\t\tdir,\n\t\t\t\t\t\t\tawait fs.readlink(fullPath),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif (!target.startsWith(\"/dev/tty\")) continue;\n\n\t\t\t\t\t\tsymlinkedPorts.push(fullPath);\n\t\t\t\t\t} catch {\n\t\t\t\t\t\t// Ignore. The target might not exist or we might not have access.\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Then the actual serial ports\n\t\t\tconst ports = await SerialPort.list();\n\t\t\tlocalPorts.push(...ports.map((port) => port.path));\n\t\t}\n\t\tif (remote) {\n\t\t\tconst ports = await discoverRemoteSerialPorts();\n\t\t\tif (ports) {\n\t\t\t\tremotePorts.push(...ports.map((p) => p.port));\n\t\t\t}\n\t\t}\n\n\t\treturn distinct([...symlinkedPorts, ...remotePorts, ...localPorts]);\n\t}\n\n\t/** Updates a subset of the driver options on the fly */\n\tpublic updateOptions(options: EditableZWaveOptions): void {\n\t\t// This code is called from user code, so we need to make sure no options were passed\n\t\t// which we are not able to update on the fly\n\t\tconst safeOptions = pick(options, [\n\t\t\t\"disableOptimisticValueUpdate\",\n\t\t\t\"emitValueUpdateAfterSetValue\",\n\t\t\t\"inclusionUserCallbacks\",\n\t\t\t\"joinNetworkUserCallbacks\",\n\t\t\t\"interview\",\n\t\t\t\"preferences\",\n\t\t\t\"vendor\",\n\t\t]);\n\n\t\t// Create a new deep-merged copy of the options so we can check them for validity\n\t\t// without affecting our own options. logConfig is potentially unsafe to clone, so just preserve it.\n\t\tconst { logConfig, ...rest } = this._options;\n\t\tconst newOptions = mergeDeep(\n\t\t\tcloneDeep(rest),\n\t\t\tsafeOptions,\n\t\t\ttrue,\n\t\t) as ZWaveOptions;\n\t\tnewOptions.logConfig = logConfig;\n\t\tcheckOptions(newOptions);\n\n\t\tif (options.userAgent && !isObject(options.userAgent)) {\n\t\t\tthrow new ZWaveError(\n\t\t\t\t`The userAgent property must be an object!`,\n\t\t\t\tZWaveErrorCodes.Driver_InvalidOptions,\n\t\t\t);\n\t\t}\n\n\t\t// All good, update the options\n\t\tthis._options = newOptions;\n\n\t\tif (options.logConfig) {\n\t\t\tthis.updateLogConfig(options.logConfig);\n\t\t}\n\n\t\tif (options.userAgent) {\n\t\t\tthis.updateUserAgent(options.userAgent);\n\t\t}\n\t}\n\n\tprivate _options: ZWaveOptions;\n\tpublic get options(): Readonly<ZWaveOptions> {\n\t\treturn this._options;\n\t}\n\n\tprivate _wasStarted: boolean = false;\n\tprivate _isOpen: boolean = false;\n\n\t/** Start the driver */\n\tpublic async start(): Promise<void> {\n\t\t// avoid starting twice\n\t\tif (this.wasDestroyed) {\n\t\t\tthrow new ZWaveError(\n\t\t\t\t\"The driver was destroyed. Create a new instance and start that one.\",\n\t\t\t\tZWaveErrorCodes.Driver_Destroyed,\n\t\t\t);\n\t\t}\n\t\tif (this._wasStarted) return Promise.resolve();\n\t\tthis._wasStarted = true;\n\n\t\t// Enforce that an error handler is attached, except for testing with a mocked serialport\n\t\tif (\n\t\t\t!this._options.testingHooks\n\t\t\t&& (this as unknown as EventEmitter).listenerCount(\"error\") === 0\n\t\t) {\n\t\t\tthrow new ZWaveError(\n\t\t\t\t`Before starting the driver, a handler for the \"error\" event must be attached.`,\n\t\t\t\tZWaveErrorCodes.Driver_NoErrorHandler,\n\t\t\t);\n\t\t}\n\n\t\tconst spOpenPromise = createDeferredPromise();\n\n\t\t// Log which version is running\n\t\tthis.driverLog.print(libNameString, \"info\");\n\t\tthis.driverLog.print(`version ${libVersion}`, \"info\");\n\t\tthis.driverLog.print(\"\", \"info\");\n\n\t\tthis.driverLog.print(\"starting driver...\");\n\n\t\t// Open the serial port\n\t\tif (typeof this.port === \"string\") {\n\t\t\tif (this.port.startsWith(\"tcp://\")) {\n\t\t\t\tconst url = new URL(this.port);\n\t\t\t\tthis.driverLog.print(`opening serial port ${this.port}`);\n\t\t\t\tthis.serial = new ZWaveSocket(\n\t\t\t\t\t{\n\t\t\t\t\t\thost: url.hostname,\n\t\t\t\t\t\tport: parseInt(url.port),\n\t\t\t\t\t},\n\t\t\t\t\tthis._logContainer,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tthis.driverLog.print(`opening serial port ${this.port}`);\n\t\t\t\tthis.serial = new ZWaveSerialPort(\n\t\t\t\t\tthis.port,\n\t\t\t\t\tthis._logContainer,\n\t\t\t\t\tthis._options.testingHooks?.serialPortBinding,\n\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\tthis.driverLog.print(\n\t\t\t\t\"opening serial port using the provided custom implementation\",\n\t\t\t);\n\t\t\tthis.serial = new ZWaveSerialPortBase(\n\t\t\t\tthis.port,\n\t\t\t\tthis._logContainer,\n\t\t\t);\n\t\t}\n\t\tthis.serial\n\t\t\t.on(\"data\", this.serialport_onData.bind(this))\n\t\t\t.on(\"bootloaderData\", this.serialport_onBootloaderData.bind(this))\n\t\t\t.on(\"error\", (err) => {\n\t\t\t\tif (this.isSoftResetting && !this.serial?.isOpen) {\n\t\t\t\t\t// A disconnection while soft resetting is to be expected\n\t\t\t\t\treturn;\n\t\t\t\t} else if (!this._isOpen) {\n\t\t\t\t\t// tryOpenSerialport takes care of error handling\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tvoid this.destroyWithMessage(\n\t\t\t\t\t`Serial port errored: ${err.message}`,\n\t\t\t\t);\n\t\t\t});\n\t\t// If the port is already open, close it first\n\t\tif (this.serial.isOpen) await this.serial.close();\n\n\t\t// IMPORTANT: Test code expects the open promise to be created and returned synchronously\n\t\t// Everything async (including opening the serial port) must happen in the setImmediate callback\n\n\t\t// asynchronously open the serial port\n\t\tsetImmediate(async () => {\n\t\t\ttry {\n\t\t\t\tawait this.openSerialport();\n\t\t\t} catch (e) {\n\t\t\t\tspOpenPromise.reject(e as Error);\n\t\t\t\tvoid this.destroy();\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tthis.driverLog.print(\"serial port opened\");\n\t\t\tthis._isOpen = true;\n\t\t\tspOpenPromise.resolve();\n\n\t\t\t// Start draining the queues\n\t\t\tfor (const queue of this.queues) {\n\t\t\t\tvoid this.drainTransactionQueue(queue);\n\t\t\t}\n\n\t\t\t// Start the serial API queue\n\t\t\tvoid this.drainSerialAPIQueue();\n\n\t\t\t// Start the task scheduler\n\t\t\tthis._scheduler.start();\n\n\t\t\tif (\n\t\t\t\ttypeof this._options.testingHooks?.onSerialPortOpen\n\t\t\t\t\t=== \"function\"\n\t\t\t) {\n\t\t\t\tawait this._options.testingHooks.onSerialPortOpen(this.serial!);\n\t\t\t}\n\n\t\t\t// Perform initialization sequence\n\t\t\tawait this.writeHeader(MessageHeaders.NAK);\n\t\t\t// Per the specs, this should be followed by a soft-reset but we need to be able\n\t\t\t// to handle sticks that don't support the soft reset command. Therefore we do it\n\t\t\t// after opening the value DBs\n\n\t\t\tif (!this._options.testingHooks?.skipBootloaderCheck) {\n\t\t\t\t// After an incomplete firmware upgrade, we might be stuck in the bootloader\n\t\t\t\t// Therefore wait a short amount of time to see if the serialport detects bootloader mode.\n\t\t\t\t// If we are, the bootloader will reply with its menu.\n\t\t\t\tawait wait(1000);\n\t\t\t\tif (this._bootloader) {\n\t\t\t\t\tthis.driverLog.print(\n\t\t\t\t\t\t\"Controller is in bootloader, attempting to recover...\",\n\t\t\t\t\t\t\"warn\",\n\t\t\t\t\t);\n\t\t\t\t\tawait this.leaveBootloaderInternal();\n\n\t\t\t\t\t// Wait a short time again. If we're in bootloader mode again, we're stuck\n\t\t\t\t\tawait wait(1000);\n\t\t\t\t\tif (this._bootloader) {\n\t\t\t\t\t\tif (this._options.allowBootloaderOnly) {\n\t\t\t\t\t\t\tthis.driverLog.print(\n\t\t\t\t\t\t\t\t\"Failed to recover from bootloader. Staying in bootloader mode as requested.\",\n\t\t\t\t\t\t\t\t\"warn\",\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t// Needed for the OTW feature to be available\n\t\t\t\t\t\t\tthis._controller = new ZWaveController(this, true);\n\t\t\t\t\t\t\tthis.emit(\"bootloader ready\");\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tvoid this.destroyWithMessage(\n\t\t\t\t\t\t\t\t\"Failed to recover from bootloader. Please flash a new firmware to continue...\",\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Try to create the cache directory. This can fail, in which case we should expose a good error message\n\t\t\ttry {\n\t\t\t\tawait this._options.storage.driver.ensureDir(this.cacheDir);\n\t\t\t} catch (e) {\n\t\t\t\tlet message: string;\n\t\t\t\tif (\n\t\t\t\t\t/\\.yarn[/\\\\]cache[/\\\\]zwave-js/i.test(\n\t\t\t\t\t\tgetErrorMessage(e, true),\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\tmessage =\n\t\t\t\t\t\t`Failed to create the cache directory. When using Yarn PnP, you need to change the location with the \"storage.cacheDir\" driver option.`;\n\t\t\t\t} else {\n\t\t\t\t\tmessage =\n\t\t\t\t\t\t`Failed to create the cache directory. Please make sure that it is writable or change the location with the \"storage.cacheDir\" driver option.`;\n\t\t\t\t}\n\n\t\t\t\tvoid this.destroyWithMessage(message);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Load the necessary configuration\n\t\t\tif (this._options.testingHooks?.loadConfiguration !== false) {\n\t\t\t\tthis.driverLog.print(\"loading configuration...\");\n\t\t\t\ttry {\n\t\t\t\t\tawait this.configManager.loadAll();\n\t\t\t\t} catch (e) {\n\t\t\t\t\tconst message = `Failed to load the configuration: ${\n\t\t\t\t\t\tgetErrorMessage(\n\t\t\t\t\t\t\te,\n\t\t\t\t\t\t)\n\t\t\t\t\t}`;\n\t\t\t\t\tvoid this.destroyWithMessage(message);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis.driverLog.print(\"beginning interview...\");\n\t\t\ttry {\n\t\t\t\tawait this.initializeControllerAndNodes();\n\t\t\t} catch (e) {\n\t\t\t\tlet message: string;\n\t\t\t\tif (\n\t\t\t\t\tisZWaveError(e)\n\t\t\t\t\t&& e.code === ZWaveErrorCodes.Controller_MessageDropped\n\t\t\t\t) {\n\t\t\t\t\tmessage =\n\t\t\t\t\t\t`Failed to initialize the driver, no response from the controller. Are you sure this is a Z-Wave controller?`;\n\t\t\t\t} else {\n\t\t\t\t\tmessage = `Failed to initialize the driver: ${\n\t\t\t\t\t\tgetErrorMessage(\n\t\t\t\t\t\t\te,\n\t\t\t\t\t\t\ttrue,\n\t\t\t\t\t\t)\n\t\t\t\t\t}`;\n\t\t\t\t}\n\t\t\t\tthis.driverLog.print(message, \"error\");\n\t\t\t\tthis.emit(\n\t\t\t\t\t\"error\",\n\t\t\t\t\tnew ZWaveError(message, ZWaveErrorCodes.Driver_Failed),\n\t\t\t\t);\n\t\t\t\tvoid this.destroy();\n\t\t\t\treturn;\n\t\t\t}\n\t\t});\n\n\t\treturn spOpenPromise;\n\t}\n\n\tprivate _controllerInterviewed: boolean = false;\n\tprivate _nodesReady = new Set<number>();\n\tprivate _nodesReadyEventEmitted: boolean = false;\n\n\tprivate async openSerialport(): Promise<void> {\n\t\tlet lastError: unknown;\n\t\t// After a reset, the serial port may need a few seconds until we can open it - try a few times\n\t\tfor (\n\t\t\tlet attempt = 1;\n\t\t\tattempt <= this._options.attempts.openSerialPort;\n\t\t\tattempt++\n\t\t) {\n\t\t\ttry {\n\t\t\t\tawait this.serial!.open();\n\t\t\t\treturn;\n\t\t\t} catch (e) {\n\t\t\t\tlastError = e;\n\t\t\t}\n\t\t\tif (attempt < this._options.attempts.openSerialPort) {\n\t\t\t\tawait wait(1000);\n\t\t\t}\n\t\t}\n\n\t\tconst message = `Failed to open the serial port: ${\n\t\t\tgetErrorMessage(\n\t\t\t\tlastError,\n\t\t\t)\n\t\t}`;\n\t\tthis.driverLog.print(message, \"error\");\n\n\t\tthrow new ZWaveError(message, ZWaveErrorCodes.Driver_Failed);\n\t}\n\n\t/** Indicates whether all nodes are ready, i.e. the \"all nodes ready\" event has been emitted */\n\tpublic get allNodesReady(): boolean {\n\t\treturn this._nodesReadyEventEmitted;\n\t}\n\n\tprivate getJsonlDBOptions(): JsonlDBOptions<any> {\n\t\tconst options: JsonlDBOptions<any> = {\n\t\t\tignoreReadErrors: true,\n\t\t\t...throttlePresets[this._options.storage.throttle],\n\t\t};\n\t\tif (this._options.storage.lockDir) {\n\t\t\toptions.lockfile = {\n\t\t\t\tdirectory: this._options.storage.lockDir,\n\t\t\t};\n\t\t}\n\t\treturn options;\n\t}\n\n\tprivate async initNetworkCache(homeId: number): Promise<void> {\n\t\tconst options = this.getJsonlDBOptions();\n\n\t\tconst networkCacheFile = path.join(\n\t\t\tthis.cacheDir,\n\t\t\t`${homeId.toString(16)}.jsonl`,\n\t\t);\n\t\tthis._networkCache = new JsonlDB(networkCacheFile, {\n\t\t\t...options,\n\t\t\tserializer: serializeNetworkCacheValue,\n\t\t\treviver: deserializeNetworkCacheValue,\n\t\t});\n\t\tawait this._networkCache.open();\n\n\t\tif (process.env.NO_CACHE === \"true\") {\n\t\t\t// Since the network cache is append-only, we need to\n\t\t\t// clear it if the cache should be ignored\n\t\t\tthis._networkCache.clear();\n\t\t}\n\t}\n\n\tprivate async initValueDBs(homeId: number): Promise<void> {\n\t\tconst options = this.getJsonlDBOptions();\n\n\t\tconst valueDBFile = path.join(\n\t\t\tthis.cacheDir,\n\t\t\t`${homeId.toString(16)}.values.jsonl`,\n\t\t);\n\t\tthis._valueDB = new JsonlDB(valueDBFile, {\n\t\t\t...options,\n\t\t\tenableTimestamps: true,\n\t\t\treviver: (key, value) => deserializeCacheValue(value),\n\t\t\tserializer: (key, value) => serializeCacheValue(value),\n\t\t});\n\t\tawait this._valueDB.open();\n\n\t\tconst metadataDBFile = path.join(\n\t\t\tthis.cacheDir,\n\t\t\t`${homeId.toString(16)}.metadata.jsonl`,\n\t\t);\n\t\tthis._metadataDB = new JsonlDB(metadataDBFile, options);\n\t\tawait this._metadataDB.open();\n\n\t\tif (process.env.NO_CACHE === \"true\") {\n\t\t\t// Since value/metadata DBs are append-only, we need to\n\t\t\t// clear them if the cache should be ignored\n\t\t\tthis._valueDB.clear();\n\t\t\tthis._metadataDB.clear();\n\t\t}\n\t}\n\n\tprivate async performCacheMigration(): Promise<void> {\n\t\tif (\n\t\t\t!this._controller\n\t\t\t|| !this.controller.homeId\n\t\t\t|| !this._networkCache\n\t\t\t|| !this._valueDB\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\t// In v9, the network cache was switched from a json file to use a Jsonl-DB\n\t\t// Therefore the legacy cache file must be migrated to the new format\n\t\tif (this._networkCache.size === 0) {\n\t\t\t// version the cache format, so migrations in the future are easier\n\t\t\tthis._networkCache.set(\"cacheFormat\", 1);\n\n\t\t\ttry {\n\t\t\t\tawait migrateLegacyNetworkCache(\n\t\t\t\t\tthis.controller.homeId,\n\t\t\t\t\tthis._networkCache,\n\t\t\t\t\tthis._valueDB,\n\t\t\t\t\tthis._options.storage.driver,\n\t\t\t\t\tthis.cacheDir,\n\t\t\t\t);\n\n\t\t\t\t// Go through the value DB and remove all keys referencing commandClass -1, which used to be a\n\t\t\t\t// hacky way to store non-CC specific values\n\t\t\t\tfor (const key of this._valueDB.keys()) {\n\t\t\t\t\tif (-1 === key.indexOf(`,\"commandClass\":-1,`)) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tthis._valueDB.delete(key);\n\t\t\t\t}\n\t\t\t} catch (e) {\n\t\t\t\tconst message =\n\t\t\t\t\t`Migrating the legacy cache file to jsonl failed: ${\n\t\t\t\t\t\tgetErrorMessage(\n\t\t\t\t\t\t\te,\n\t\t\t\t\t\t\ttrue,\n\t\t\t\t\t\t)\n\t\t\t\t\t}`;\n\t\t\t\tthis.driverLog.print(message, \"error\");\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Initializes the variables for controller and nodes,\n\t * adds event handlers and starts the interview process.\n\t */\n\tprivate async initializeControllerAndNodes(): Promise<void> {\n\t\tif (this._controller == undefined) {\n\t\t\tthis._controller = new ZWaveController(this);\n\t\t\tthis._controller\n\t\t\t\t.on(\"node added\", this.onNodeAdded.bind(this))\n\t\t\t\t.on(\"node removed\", this.onNodeRemoved.bind(this))\n\t\t\t\t.on(\n\t\t\t\t\t\"status changed\",\n\t\t\t\t\tthis.onControllerStatusChanged.bind(this),\n\t\t\t\t)\n\t\t\t\t.on(\"network found\", this.onNetworkFound.bind(this))\n\t\t\t\t.on(\"network joined\", this.onNetworkJoined.bind(this))\n\t\t\t\t.on(\"network left\", this.onNetworkLeft.bind(this));\n\t\t}\n\n\t\tif (!this._options.testingHooks?.skipControllerIdentification) {\n\t\t\t// Determine what the controller can do\n\t\t\tconst { nodeIds } = await this.controller.queryCapabilities();\n\n\t\t\t// Configure the radio\n\t\t\tawait this.controller.queryAndConfigureRF();\n\n\t\t\t// Soft-reset the stick if possible.\n\t\t\t// On 700+ series, we'll also learn about whether the stick supports\n\t\t\t// Z-Wave Long Range in the current region.\n\t\t\tconst maySoftReset = this.maySoftReset();\n\t\t\tif (this._options.features.softReset && !maySoftReset) {\n\t\t\t\tthis.driverLog.print(\n\t\t\t\t\t`Soft reset is enabled through config, but this stick does not support it.`,\n\t\t\t\t\t\"warn\",\n\t\t\t\t);\n\t\t\t\tthis._options.features.softReset = false;\n\t\t\t}\n\n\t\t\tif (maySoftReset) {\n\t\t\t\tawait this.softResetInternal(false);\n\t\t\t}\n\n\t\t\tlet lrNodeIds: readonly number[] | undefined;\n\t\t\tif (this.controller.supportsLongRange) {\n\t\t\t\t// If the controller supports ZWLR, we need to query the node IDs again\n\t\t\t\t// to get the full list of nodes\n\t\t\t\tlrNodeIds = (await this.controller.queryLongRangeCapabilities())\n\t\t\t\t\t.lrNodeIds;\n\t\t\t}\n\n\t\t\t// If the controller supports ZWLR in the current region, switch to\n\t\t\t// 16-bit node IDs. Otherwise, make sure that it is actually using 8-bit node IDs.\n\t\t\tawait this.controller.trySetNodeIDType(\n\t\t\t\tthis.controller.supportsLongRange\n\t\t\t\t\t? NodeIDType.Long\n\t\t\t\t\t: NodeIDType.Short,\n\t\t\t);\n\n\t\t\t// Now that we know the node ID type, we can identify the controller\n\t\t\tawait this.controller.identify();\n\n\t\t\t// Perform additional configuration\n\t\t\tawait this.controller.configure();\n\n\t\t\t// now that we know the home ID, we can open the databases\n\t\t\tawait this.initNetworkCache(this.controller.homeId!);\n\t\t\tawait this.initValueDBs(this.controller.homeId!);\n\t\t\tawait this.performCacheMigration();\n\n\t\t\t// Initialize all nodes and restore the data from cache\n\t\t\tawait this.controller.initNodes(\n\t\t\t\tnodeIds,\n\t\t\t\tlrNodeIds ?? [],\n\t\t\t\tasync () => {\n\t\t\t\t\t// Try to restore the network information from the cache\n\t\t\t\t\tif (process.env.NO_CACHE !== \"true\") {\n\t\t\t\t\t\tawait this.restoreNetworkStructureFromCache();\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t);\n\n\t\t\tif (this.controller.role === ControllerRole.Primary) {\n\t\t\t\t// Auto-enable smart start inclusion\n\t\t\t\tthis.controller.autoProvisionSmartStart();\n\t\t\t}\n\t\t} else {\n\t\t\t// When skipping the controller identification, set the flags to consider the controller a primary\n\t\t\tthis.controller[\"_wasRealPrimary\"] = true;\n\t\t\tthis.controller[\"_isSUC\"] = true;\n\t\t\tthis.controller[\"_isSISPresent\"] = true;\n\t\t\tthis.controller[\"_sucNodeId\"] = 1;\n\t\t}\n\n\t\tif (this.controller.role === ControllerRole.Primary) {\n\t\t\t// Set up the S0 security manager. We can only do that after the controller\n\t\t\t// interview because we need to know the controller node id.\n\t\t\tconst S0Key = this._options.securityKeys?.S0_Legacy;\n\t\t\tif (S0Key) {\n\t\t\t\tthis.driverLog.print(\n\t\t\t\t\t\"Network key for S0 configured, enabling S0 security manager...\",\n\t\t\t\t);\n\t\t\t\tthis._securityManager = new SecurityManager({\n\t\t\t\t\tnetworkKey: S0Key,\n\t\t\t\t\townNodeId: this._controller.ownNodeId!,\n\t\t\t\t\tnonceTimeout: this._options.timeouts.nonce,\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tthis.driverLog.print(\n\t\t\t\t\t\"No network key for S0 configured, communication with secure (S0) devices won't work!\",\n\t\t\t\t\t\"warn\",\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// The S2 security manager could be initialized earlier, but we do it here for consistency\n\t\t\tif (\n\t\t\t\tthis._options.securityKeys\n\t\t\t\t// Only set it up if we have security keys for at least one S2 security class\n\t\t\t\t&& Object.keys(this._options.securityKeys).some(\n\t\t\t\t\t(key) =>\n\t\t\t\t\t\tkey.startsWith(\"S2_\")\n\t\t\t\t\t\t&& key in SecurityClass\n\t\t\t\t\t\t&& securityClassIsS2((SecurityClass as any)[key]),\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\tthis.driverLog.print(\n\t\t\t\t\t\"At least one network key for S2 configured, enabling S2 security manager...\",\n\t\t\t\t);\n\t\t\t\tthis._securityManager2 = await SecurityManager2.create();\n\t\t\t\t// Set up all keys\n\t\t\t\tfor (\n\t\t\t\t\tconst secClass of [\n\t\t\t\t\t\t\"S2_Unauthenticated\",\n\t\t\t\t\t\t\"S2_Authenticated\",\n\t\t\t\t\t\t\"S2_AccessControl\",\n\t\t\t\t\t\t\"S0_Legacy\",\n\t\t\t\t\t] as const\n\t\t\t\t) {\n\t\t\t\t\tconst key = this._options.securityKeys[secClass];\n\t\t\t\t\tif (key) {\n\t\t\t\t\t\tawait this._securityManager2.setKeyAsync(\n\t\t\t\t\t\t\tSecurityClass[secClass],\n\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tthis.driverLog.print(\n\t\t\t\t\t\"No network key for S2 configured, communication with secure (S2) devices won't work!\",\n\t\t\t\t\t\"warn\",\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\tthis._options.securityKeysLongRange?.S2_AccessControl\n\t\t\t\t|| this._options.securityKeysLongRange?.S2_Authenticated\n\t\t\t) {\n\t\t\t\tthis.driverLog.print(\n\t\t\t\t\t\"At least one network key for Z-Wave Long Range configured, enabling security manager...\",\n\t\t\t\t);\n\t\t\t\tthis._securityManagerLR = await SecurityManager2.create();\n\t\t\t\tif (this._options.securityKeysLongRange?.S2_AccessControl) {\n\t\t\t\t\tawait this._securityManagerLR.setKeyAsync(\n\t\t\t\t\t\tSecurityClass.S2_AccessControl,\n\t\t\t\t\t\tthis._options.securityKeysLongRange.S2_AccessControl,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (this._options.securityKeysLongRange?.S2_Authenticated) {\n\t\t\t\t\tawait this._securityManagerLR.setKeyAsync(\n\t\t\t\t\t\tSecurityClass.S2_Authenticated,\n\t\t\t\t\t\tthis._options.securityKeysLongRange.S2_Authenticated,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tthis.driverLog.print(\n\t\t\t\t\t\"No network key for Z-Wave Long Range configured, communication won't work!\",\n\t\t\t\t\t\"warn\",\n\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\t// Secondary controller - load security keys from cache.\n\t\t\t// Either LR or S2+S0, not both\n\t\t\t// FIXME: The fallback code duplicates the logic from the primary controller above. Find a nicer solution.\n\t\t\tif (isLongRangeNodeId(this.controller.ownNodeId!)) {\n\t\t\t\tconst securityKeysLongRange = [\n\t\t\t\t\tSecurityClass.S2_AccessControl,\n\t\t\t\t\tSecurityClass.S2_Authenticated,\n\t\t\t\t].map(\n\t\t\t\t\t(sc) => ([\n\t\t\t\t\t\tsc,\n\t\t\t\t\t\tthis.cacheGet<Uint8Array>(\n\t\t\t\t\t\t\tcacheKeys.controller.securityKeysLongRange(sc),\n\t\t\t\t\t\t),\n\t\t\t\t\t] as [SecurityClass, Uint8Array | undefined]),\n\t\t\t\t).filter((v): v is [SecurityClass, Uint8Array] =>\n\t\t\t\t\tv[1] != undefined\n\t\t\t\t);\n\t\t\t\tif (securityKeysLongRange.length) {\n\t\t\t\t\tthis.driverLog.print(\n\t\t\t\t\t\t\"At least one network key for Z-Wave Long Range found in cache, enabling security manager...\",\n\t\t\t\t\t);\n\t\t\t\t\tthis._securityManagerLR = await SecurityManager2.create();\n\t\t\t\t\tfor (const [sc, key] of securityKeysLongRange) {\n\t\t\t\t\t\tawait this._securityManagerLR.setKeyAsync(sc, key);\n\t\t\t\t\t}\n\t\t\t\t} else if (\n\t\t\t\t\tthis._options.securityKeysLongRange?.S2_AccessControl\n\t\t\t\t\t|| this._options.securityKeysLongRange?.S2_Authenticated\n\t\t\t\t) {\n\t\t\t\t\tthis.driverLog.print(\n\t\t\t\t\t\t\"Fallback to configured network keys for Z-Wave Long Range, enabling security manager...\",\n\t\t\t\t\t);\n\t\t\t\t\tthis._securityManagerLR = await SecurityManager2.create();\n\t\t\t\t\tif (this._options.securityKeysLongRange?.S2_AccessControl) {\n\t\t\t\t\t\tawait this._securityManagerLR.setKeyAsync(\n\t\t\t\t\t\t\tSecurityClass.S2_AccessControl,\n\t\t\t\t\t\t\tthis._options.securityKeysLongRange\n\t\t\t\t\t\t\t\t.S2_AccessControl,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tif (this._options.securityKeysLongRange?.S2_Authenticated) {\n\t\t\t\t\t\tawait this._securityManagerLR.setKeyAsync(\n\t\t\t\t\t\t\tSecurityClass.S2_Authenticated,\n\t\t\t\t\t\t\tthis._options.securityKeysLongRange\n\t\t\t\t\t\t\t\t.S2_Authenticated,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tthis.driverLog.print(\n\t\t\t\t\t\t\"No network key for Z-Wave Long Range configured, communication won't work!\",\n\t\t\t\t\t\t\"warn\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tconst s0Key = this.cacheGet<Uint8Array>(\n\t\t\t\t\tcacheKeys.controller.securityKeys(SecurityClass.S0_Legacy),\n\t\t\t\t);\n\t\t\t\tif (s0Key) {\n\t\t\t\t\tthis.driverLog.print(\n\t\t\t\t\t\t\"Network key for S0 found in cache, enabling S0 security manager...\",\n\t\t\t\t\t);\n\t\t\t\t\tthis._securityManager = new SecurityManager({\n\t\t\t\t\t\tnetworkKey: s0Key,\n\t\t\t\t\t\townNodeId: this._controller.ownNodeId!,\n\t\t\t\t\t\tnonceTimeout: this._options.timeouts.nonce,\n\t\t\t\t\t});\n\t\t\t\t} else if (this._options.securityKeys?.S0_Legacy) {\n\t\t\t\t\tthis.driverLog.print(\n\t\t\t\t\t\t\"Fallback to configured S0 network key, enabling S0 security manager...\",\n\t\t\t\t\t);\n\t\t\t\t\tthis._securityManager = new SecurityManager({\n\t\t\t\t\t\tnetworkKey: this._options.securityKeys.S0_Legacy,\n\t\t\t\t\t\townNodeId: this._controller.ownNodeId!,\n\t\t\t\t\t\tnonceTimeout: this._options.timeouts.nonce,\n\t\t\t\t\t});\n\t\t\t\t} else {\n\t\t\t\t\tthis.driverLog.print(\n\t\t\t\t\t\t\"No network key for S0 found in cache, communication with secure (S0) devices won't work!\",\n\t\t\t\t\t\t\"warn\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tconst securityKeys = securityClassOrder.map(\n\t\t\t\t\t(sc) => ([\n\t\t\t\t\t\tsc,\n\t\t\t\t\t\tthis.cacheGet<Uint8Array>(\n\t\t\t\t\t\t\tcacheKeys.controller.securityKeys(sc),\n\t\t\t\t\t\t),\n\t\t\t\t\t] as [SecurityClass, Uint8Array | undefined]),\n\t\t\t\t).filter((v): v is [SecurityClass, Uint8Array] =>\n\t\t\t\t\tv[1] != undefined\n\t\t\t\t);\n\t\t\t\tif (securityKeys.length) {\n\t\t\t\t\tthis.driverLog.print(\n\t\t\t\t\t\t\"At least one network key for S2 found in cache, enabling S2 security manager...\",\n\t\t\t\t\t);\n\t\t\t\t\tthis._securityManager2 = await SecurityManager2.create();\n\t\t\t\t\tfor (const [sc, key] of securityKeys) {\n\t\t\t\t\t\tawait this._securityManager2.setKeyAsync(sc, key);\n\t\t\t\t\t}\n\t\t\t\t} else if (\n\t\t\t\t\tthis._options.securityKeys\n\t\t\t\t\t&& Object.keys(this._options.securityKeys).some(\n\t\t\t\t\t\t(key) =>\n\t\t\t\t\t\t\tkey.startsWith(\"S2_\")\n\t\t\t\t\t\t\t&& key in SecurityClass\n\t\t\t\t\t\t\t&& securityClassIsS2((SecurityClass as any)[key]),\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\tthis.driverLog.print(\n\t\t\t\t\t\t\"Fallback to configured network keys for S2, enabling S2 security manager...\",\n\t\t\t\t\t);\n\t\t\t\t\tthis._securityManager2 = await SecurityManager2.create();\n\t\t\t\t\t// Set up all keys\n\t\t\t\t\tfor (\n\t\t\t\t\t\tconst secClass of [\n\t\t\t\t\t\t\t\"S2_Unauthenticated\",\n\t\t\t\t\t\t\t\"S2_Authenticated\",\n\t\t\t\t\t\t\t\"S2_AccessControl\",\n\t\t\t\t\t\t\t\"S0_Legacy\",\n\t\t\t\t\t\t] as const\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst key = this._options.securityKeys[secClass];\n\t\t\t\t\t\tif (key) {\n\t\t\t\t\t\t\tawait this._securityManager2.setKeyAsync(\n\t\t\t\t\t\t\t\tSecurityClass[secClass],\n\t\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tthis.driverLog.print(\n\t\t\t\t\t\t\"No network key for S2 found in cache, communication with secure (S2) devices won't work!\",\n\t\t\t\t\t\t\"warn\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// in any case we need to emit the driver ready event here\n\t\tthis._controllerInterviewed = true;\n\t\tthis.driverLog.print(\"driver ready\");\n\t\tthis.emit(\"driver ready\");\n\n\t\t// Add event handlers for the nodes\n\t\tfor (const node of this._controller.nodes.values()) {\n\t\t\tthis.addNodeEventHandlers(node);\n\t\t}\n\n\t\tif (this.controller.role === ControllerRole.Primary) {\n\t\t\t// Before interviewing nodes reset our knowledge about their ready state\n\t\t\tthis._nodesReady.clear();\n\t\t\tthis._nodesReadyEventEmitted = false;\n\n\t\t\tif (!this._options.testingHooks?.skipNodeInterview) {\n\t\t\t\t// Now interview all nodes\n\t\t\t\t// First complete the controller interview\n\t\t\t\tconst controllerNode = this._controller.nodes.get(\n\t\t\t\t\tthis._controller.ownNodeId!,\n\t\t\t\t)!;\n\t\t\t\tawait this.interviewNodeInternal(controllerNode);\n\t\t\t\t// The controller node is always alive\n\t\t\t\tcontrollerNode.markAsAlive();\n\n\t\t\t\t// Then do all the nodes in parallel, but prioritize nodes that are more likely to be ready\n\t\t\t\tconst nodeInterviewOrder = [...this._controller.nodes.values()]\n\t\t\t\t\t.filter((n) => n.id !== this._controller!.ownNodeId)\n\t\t\t\t\t.sort((a, b) =>\n\t\t\t\t\t\t// Fully-interviewed devices first (need the least amount of communication now)\n\t\t\t\t\t\t(b.interviewStage - a.interviewStage)\n\t\t\t\t\t\t// Always listening -> FLiRS -> sleeping\n\t\t\t\t\t\t|| (\n\t\t\t\t\t\t\t(b.isListening ? 2 : b.isFrequentListening ? 1 : 0)\n\t\t\t\t\t\t\t- (a.isListening\n\t\t\t\t\t\t\t\t? 2\n\t\t\t\t\t\t\t\t: a.isFrequentListening\n\t\t\t\t\t\t\t\t? 1\n\t\t\t\t\t\t\t\t: 0)\n\t\t\t\t\t\t)\n\t\t\t\t\t\t// Then by last seen, more recently first\n\t\t\t\t\t\t|| (\n\t\t\t\t\t\t\t(b.lastSeen?.getTime() ?? 0)\n\t\t\t\t\t\t\t- (a.lastSeen?.getTime() ?? 0)\n\t\t\t\t\t\t)\n\t\t\t\t\t\t// Lastly ascending by node ID\n\t\t\t\t\t\t|| (a.id - b.id)\n\t\t\t\t\t);\n\n\t\t\t\tif (nodeInterviewOrder.length) {\n\t\t\t\t\tthis.controllerLog.print(\n\t\t\t\t\t\t`Interviewing nodes and/or determining their status: ${\n\t\t\t\t\t\t\tnodeInterviewOrder.map((n) => n.id).join(\", \")\n\t\t\t\t\t\t}`,\n\t\t\t\t\t);\n\t\t\t\t\tfor (const node of nodeInterviewOrder) {\n\t\t\t\t\t\tif (node.canSleep) {\n\t\t\t\t\t\t\t// A node that can sleep should be assumed to be sleeping after resuming from cache\n\t\t\t\t\t\t\tnode.markAsAsleep();\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tvoid (async () => {\n\t\t\t\t\t\t\t// Continue the interview if necessary. If that is not necessary, at least\n\t\t\t\t\t\t\t// determine the node's status\n\t\t\t\t\t\t\tif (node.interviewStage < InterviewStage.Complete) {\n\t\t\t\t\t\t\t\tawait this.interviewNodeInternal(node);\n\t\t\t\t\t\t\t} else if (\n\t\t\t\t\t\t\t\tnode.isListening || node.isFrequentListening\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t// Ping non-sleeping nodes to determine their status\n\t\t\t\t\t\t\t\tawait node.ping();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t})();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tif (!this._options.testingHooks?.skipNodeInterview) {\n\t\t\t\t// We're a secondary controller. Just determine if nodes are ready and do the interview at another time.\n\n\t\t\t\t// First complete the controller \"interview\"\n\t\t\t\tconst controllerNode = this._controller.nodes.get(\n\t\t\t\t\tthis._controller.ownNodeId!,\n\t\t\t\t)!;\n\t\t\t\tawait this.interviewNodeInternal(controllerNode);\n\t\t\t\t// The controller node is always alive\n\t\t\t\tcontrollerNode.markAsAlive();\n\n\t\t\t\t// Query the protocol information from the controller\n\t\t\t\tfor (const node of this._controller.nodes.values()) {\n\t\t\t\t\tif (node.isControllerNode) continue;\n\t\t\t\t\tawait node[\"queryProtocolInfo\"]();\n\t\t\t\t}\n\n\t\t\t\t// Then ping (frequently) listening nodes to determine their status\n\t\t\t\tconst nodeInterviewOrder = [...this._controller.nodes.values()]\n\t\t\t\t\t.filter((n) => n.id !== this._controller!.ownNodeId)\n\t\t\t\t\t.filter((n) => n.isListening || n.isFrequentListening)\n\t\t\t\t\t.sort((a, b) =>\n\t\t\t\t\t\t// Always listening -> FLiRS\n\t\t\t\t\t\t(\n\t\t\t\t\t\t\t(b.isListening ? 1 : 0)\n\t\t\t\t\t\t\t- (a.isListening ? 1 : 0)\n\t\t\t\t\t\t)\n\t\t\t\t\t\t// Then by last seen, more recently first\n\t\t\t\t\t\t|| (\n\t\t\t\t\t\t\t(b.lastSeen?.getTime() ?? 0)\n\t\t\t\t\t\t\t- (a.lastSeen?.getTime() ?? 0)\n\t\t\t\t\t\t)\n\t\t\t\t\t\t// Lastly ascending by node ID\n\t\t\t\t\t\t|| (a.id - b.id)\n\t\t\t\t\t);\n\n\t\t\t\tif (nodeInterviewOrder.length) {\n\t\t\t\t\tthis.controllerLog.print(\n\t\t\t\t\t\t`Determining node status: ${\n\t\t\t\t\t\t\tnodeInterviewOrder.map((n) => n.id).join(\", \")\n\t\t\t\t\t\t}`,\n\t\t\t\t\t);\n\t\t\t\t\tfor (const node of nodeInterviewOrder) {\n\t\t\t\t\t\tvoid node.ping();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// If we only have sleeping nodes or a controller-only network, the send\n\t\t// thread is idle before the driver gets marked ready, the idle tasks won't be triggered.\n\t\t// So do it manually.\n\t\tthis.handleQueueIdleChange(this.queueIdle);\n\t}\n\n\tprivate autoRefreshNodeValueTimers = new Map<number, NodeJS.Timeout>();\n\n\tprivate retryNodeInterviewTimeouts = new Map<number, NodeJS.Timeout>();\n\t/**\n\t * @internal\n\t * Starts or resumes the interview of a Z-Wave node. It is advised to NOT\n\t * await this method as it can take a very long time (minutes to hours)!\n\t *\n\t * WARNING: Do not call this method from application code. To refresh the information\n\t * for a specific node, use `node.refreshInfo()` instead\n\t */\n\tpublic async interviewNodeInternal(node: ZWaveNode): Promise<void> {\n\t\tif (node.interviewStage === InterviewStage.Complete) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Avoid having multiple restart timeouts active\n\t\tif (this.retryNodeInterviewTimeouts.has(node.id)) {\n\t\t\tclearTimeout(this.retryNodeInterviewTimeouts.get(node.id));\n\t\t\tthis.retryNodeInterviewTimeouts.delete(node.id);\n\t\t}\n\n\t\t// Drop all pending messages that come from a previous interview attempt\n\t\tthis.rejectTransactions(\n\t\t\t(t) =>\n\t\t\t\tt.message.getNodeId() === node.id\n\t\t\t\t&& (t.priority === MessagePriority.NodeQuery\n\t\t\t\t\t|| t.tag === \"interview\"),\n\t\t\t\"The interview was restarted\",\n\t\t\tZWaveErrorCodes.Controller_InterviewRestarted,\n\t\t);\n\n\t\tconst maxInterviewAttempts = this._options.attempts.nodeInterview;\n\n\t\ttry {\n\t\t\tif (!(await node.interviewInternal())) {\n\t\t\t\t// Find out if we may retry the interview\n\t\t\t\tif (node.status === NodeStatus.Dead) {\n\t\t\t\t\tthis.controllerLog.logNode(\n\t\t\t\t\t\tnode.id,\n\t\t\t\t\t\t`Interview attempt (${node.interviewAttempts}/${maxInterviewAttempts}) failed, node is dead.`,\n\t\t\t\t\t\t\"warn\",\n\t\t\t\t\t);\n\t\t\t\t\tnode.emit(\"interview failed\", node, {\n\t\t\t\t\t\terrorMessage: \"The node is dead\",\n\t\t\t\t\t\tisFinal: true,\n\t\t\t\t\t});\n\t\t\t\t} else if (node.interviewAttempts < maxInterviewAttempts) {\n\t\t\t\t\t// This is most likely because the node is unable to handle our load of requests now. Give it some time\n\t\t\t\t\tconst retryTimeout = Math.min(\n\t\t\t\t\t\t30000,\n\t\t\t\t\t\tnode.interviewAttempts * 5000,\n\t\t\t\t\t);\n\t\t\t\t\tthis.controllerLog.logNode(\n\t\t\t\t\t\tnode.id,\n\t\t\t\t\t\t`Interview attempt ${node.interviewAttempts}/${maxInterviewAttempts} failed, retrying in ${retryTimeout} ms...`,\n\t\t\t\t\t\t\"warn\",\n\t\t\t\t\t);\n\t\t\t\t\tnode.emit(\"interview failed\", node, {\n\t\t\t\t\t\terrorMessage:\n\t\t\t\t\t\t\t`Attempt ${node.interviewAttempts}/${maxInterviewAttempts} failed`,\n\t\t\t\t\t\tisFinal: false,\n\t\t\t\t\t\tattempt: node.interviewAttempts,\n\t\t\t\t\t\tmaxAttempts: maxInterviewAttempts,\n\t\t\t\t\t});\n\t\t\t\t\t// Schedule the retry and remember the timeout instance\n\t\t\t\t\tthis.retryNodeInterviewTimeouts.set(\n\t\t\t\t\t\tnode.id,\n\t\t\t\t\t\tsetTimeout(() => {\n\t\t\t\t\t\t\tthis.retryNodeInterviewTimeouts.delete(node.id);\n\t\t\t\t\t\t\tvoid this.interviewNodeInternal(node);\n\t\t\t\t\t\t}, retryTimeout).unref(),\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tthis.controllerLog.logNode(\n\t\t\t\t\t\tnode.id,\n\t\t\t\t\t\t`Failed all interview attempts, giving up.`,\n\t\t\t\t\t\t\"warn\",\n\t\t\t\t\t);\n\t\t\t\t\tnode.emit(\"interview failed\", node, {\n\t\t\t\t\t\terrorMessage: `Maximum interview attempts reached`,\n\t\t\t\t\t\tisFinal: true,\n\t\t\t\t\t\tattempt: maxInterviewAttempts,\n\t\t\t\t\t\tmaxAttempts: maxInterviewAttempts,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t} else if (\n\t\t\t\tnode.manufacturerId != undefined\n\t\t\t\t&& node.productType != undefined\n\t\t\t\t&& node.productId != undefined\n\t\t\t\t&& node.firmwareVersion != undefined\n\t\t\t\t&& !node.deviceConfig\n\t\t\t\t&& process.env.NODE_ENV !== \"test\"\n\t\t\t) {\n\t\t\t\t// The interview succeeded, but we don't have a device config for this node.\n\t\t\t\t// Report it, so we can add a config file\n\n\t\t\t\tvoid reportMissingDeviceConfig(this, node as any).catch(noop);\n\t\t\t}\n\t\t} catch (e) {\n\t\t\tif (isZWaveError(e)) {\n\t\t\t\tif (\n\t\t\t\t\te.code === ZWaveErrorCodes.Driver_NotReady\n\t\t\t\t\t|| e.code === ZWaveErrorCodes.Controller_NodeRemoved\n\t\t\t\t) {\n\t\t\t\t\t// This only happens when a node is removed during the interview - we don't log this\n\t\t\t\t\treturn;\n\t\t\t\t} else if (\n\t\t\t\t\te.code === ZWaveErrorCodes.Controller_InterviewRestarted\n\t\t\t\t) {\n\t\t\t\t\t// The interview was restarted by a user - we don't log this\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tthis.controllerLog.logNode(\n\t\t\t\t\tnode.id,\n\t\t\t\t\t`Error during node interview: ${e.message}`,\n\t\t\t\t\t\"error\",\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tthrow e;\n\t\t\t}\n\t\t}\n\t}\n\n\t/** Adds the necessary event handlers for a node instance */\n\tprivate addNodeEventHandlers(node: ZWaveNode): void {\n\t\tnode.on(\"wake up\", this.onNodeWakeUp.bind(this))\n\t\t\t.on(\"sleep\", this.onNodeSleep.bind(this))\n\t\t\t.on(\"alive\", this.onNodeAlive.bind(this))\n\t\t\t.on(\"dead\", this.onNodeDead.bind(this))\n\t\t\t.on(\"interview completed\", this.onNodeInterviewCompleted.bind(this))\n\t\t\t.on(\"ready\", this.onNodeReady.bind(this))\n\t\t\t.on(\n\t\t\t\t\"firmware update finished\",\n\t\t\t\tthis.onNodeFirmwareUpdated.bind(this),\n\t\t\t)\n\t\t\t.on(\"notification\", this.onNodeNotification.bind(this));\n\n\t\t// Add forwarders for all node events\n\t\tfor (const event of zWaveNodeEvents) {\n\t\t\tnode.on(event, (...args: any[]) => {\n\t\t\t\t// @ts-expect-error We made sure that args matches\n\t\t\t\tthis.emit(`node ${event}`, ...args);\n\t\t\t});\n\t\t}\n\t}\n\n\t/** Removes a node's event handlers that were added with addNodeEventHandlers */\n\tprivate removeNodeEventHandlers(node: ZWaveNode): void {\n\t\tnode.removeAllListeners();\n\t}\n\n\t/** Is called when a node wakes up */\n\tprivate onNodeWakeUp(node: ZWaveNode, oldStatus: NodeStatus): void {\n\t\tthis.controllerLog.logNode(\n\t\t\tnode.id,\n\t\t\t`The node is ${\n\t\t\t\toldStatus === NodeStatus.Unknown ? \"\" : \"now \"\n\t\t\t}awake.`,\n\t\t);\n\n\t\t// Make sure to handle the pending messages as quickly as possible\n\t\tif (oldStatus === NodeStatus.Asleep) {\n\t\t\tthis.reduceQueues(({ message }) => {\n\t\t\t\t// Ignore messages that are not for this node\n\t\t\t\tif (message.getNodeId() !== node.id) return { type: \"keep\" };\n\t\t\t\t// Resolve pings, so we don't need to send them (we know the node is awake)\n\t\t\t\tif (messageIsPing(message)) {\n\t\t\t\t\treturn { type: \"resolve\", message: undefined };\n\t\t\t\t}\n\t\t\t\t// Re-queue all other transactions for this node, so they get added in front of the others\n\t\t\t\treturn { type: \"requeue\" };\n\t\t\t});\n\t\t}\n\t}\n\n\t/** Is called when a node goes to sleep */\n\tprivate onNodeSleep(node: ZWaveNode, oldStatus: NodeStatus): void {\n\t\tthis.controllerLog.logNode(\n\t\t\tnode.id,\n\t\t\t`The node is ${\n\t\t\t\toldStatus === NodeStatus.Unknown ? \"\" : \"now \"\n\t\t\t}asleep.`,\n\t\t);\n\n\t\t// Move all its pending messages to the WakeupQueue\n\t\t// This clears the current transaction and continues sending the next messages\n\t\tthis.moveMessagesToWakeupQueue(node.id);\n\t}\n\n\t/** Is called when a previously dead node starts communicating again */\n\tprivate onNodeAlive(node: ZWaveNode, oldStatus: NodeStatus): void {\n\t\tthis.controllerLog.logNode(\n\t\t\tnode.id,\n\t\t\t`The node is ${\n\t\t\t\toldStatus === NodeStatus.Unknown ? \"\" : \"now \"\n\t\t\t}alive.`,\n\t\t);\n\t\tif (\n\t\t\toldStatus === NodeStatus.Dead\n\t\t\t&& node.interviewStage !== InterviewStage.Complete\n\t\t\t&& !this._options.testingHooks?.skipNodeInterview\n\t\t) {\n\t\t\tvoid this.interviewNodeInternal(node);\n\t\t}\n\t}\n\n\t/** Is called when a node is marked as dead */\n\tprivate onNodeDead(node: ZWaveNode, oldStatus: NodeStatus): void {\n\t\tthis.controllerLog.logNode(\n\t\t\tnode.id,\n\t\t\t`The node is ${\n\t\t\t\toldStatus === NodeStatus.Unknown ? \"\" : \"now \"\n\t\t\t}dead.`,\n\t\t);\n\n\t\t// This could mean that we need to ignore it in the all nodes ready check,\n\t\t// so perform the check again\n\t\tthis.checkAllNodesReady();\n\t}\n\n\t/** Is called when a node is ready to be used */\n\tprivate onNodeReady(node: ZWaveNode): void {\n\t\tthis._nodesReady.add(node.id);\n\t\tthis.controllerLog.logNode(node.id, \"The node is ready to be used\");\n\n\t\t// Regularly check if values of non-sleeping nodes need to be refreshed per the specs\n\t\t// For sleeping nodes this is done on wakeup\n\t\tif (this.autoRefreshNodeValueTimers.has(node.id)) {\n\t\t\tclearInterval(this.autoRefreshNodeValueTimers.get(node.id));\n\t\t\tthis.autoRefreshNodeValueTimers.delete(node.id);\n\t\t}\n\t\tif (!node.canSleep) {\n\t\t\t// Randomize the interval so we don't get a flood of queries for all listening nodes\n\t\t\tconst intervalMinutes = 50 + Math.random() * 20;\n\t\t\tthis.autoRefreshNodeValueTimers.set(\n\t\t\t\tnode.id,\n\t\t\t\tsetInterval(() => {\n\t\t\t\t\tvoid node.autoRefreshValues().catch(() => {\n\t\t\t\t\t\t// ignore errors\n\t\t\t\t\t});\n\t\t\t\t}, timespan.minutes(intervalMinutes)).unref(),\n\t\t\t);\n\t\t}\n\n\t\tthis.checkAllNodesReady();\n\t}\n\n\t/** Checks if all nodes are ready and emits the \"all nodes ready\" event if they are */\n\tprivate checkAllNodesReady(): void {\n\t\t// Only emit \"all nodes ready\" once\n\t\tif (this._nodesReadyEventEmitted) return;\n\n\t\tfor (const [id, node] of this.controller.nodes) {\n\t\t\t// Ignore dead nodes or the all nodes ready event will never be emitted without physical user interaction\n\t\t\tif (node.status === NodeStatus.Dead) continue;\n\n\t\t\tif (!this._nodesReady.has(id)) return;\n\t\t}\n\t\t// All nodes are ready\n\t\tthis.controllerLog.print(\"All nodes are ready to be used\");\n\t\tthis.emit(\"all nodes ready\");\n\t\tthis._nodesReadyEventEmitted = true;\n\n\t\t// We know we have all data, this is the time to send statistics (when enabled)\n\t\tvoid this.compileAndSendStatistics().catch(() => {\n\t\t\t/* ignore */\n\t\t});\n\t}\n\n\tprivate _statisticsEnabled: boolean = false;\n\t/** Whether reporting usage statistics is currently enabled */\n\tpublic get statisticsEnabled(): boolean {\n\t\treturn this._statisticsEnabled;\n\t}\n\n\tprivate statisticsAppInfo:\n\t\t| Pick<AppInfo, \"applicationName\" | \"applicationVersion\">\n\t\t| undefined;\n\n\tprivate userAgentComponents = new Map<string, string>();\n\n\t/**\n\t * Updates individual components of the user agent. Versions for individual applications can be added or removed.\n\t * @param components An object with application/module/component names and their versions. Set a version to `null` or `undefined` explicitly to remove it from the user agent.\n\t */\n\tpublic updateUserAgent(\n\t\tcomponents: Record<string, string | null | undefined>,\n\t): void {\n\t\tthis.userAgentComponents = mergeUserAgent(\n\t\t\tthis.userAgentComponents,\n\t\t\tcomponents,\n\t\t);\n\t\tthis._userAgent = this.getEffectiveUserAgentString(\n\t\t\tthis.userAgentComponents,\n\t\t);\n\t}\n\n\t/**\n\t * Returns the effective user agent string for the given components.\n\t * The driver name and version is automatically prepended and the statisticsAppInfo data is automatically appended if no components were given.\n\t */\n\tprivate getEffectiveUserAgentString(\n\t\tcomponents: Map<string, string>,\n\t): string {\n\t\tconst effectiveComponents = new Map([\n\t\t\t[libName, libVersion],\n\t\t\t...components,\n\t\t]);\n\t\tif (\n\t\t\teffectiveComponents.size === 1\n\t\t\t&& this.statisticsAppInfo\n\t\t\t&& this.statisticsAppInfo.applicationName !== \"node-zwave-js\"\n\t\t) {\n\t\t\teffectiveComponents.set(\n\t\t\t\tthis.statisticsAppInfo.applicationName,\n\t\t\t\tthis.statisticsAppInfo.applicationVersion,\n\t\t\t);\n\t\t}\n\t\treturn userAgentComponentsToString(effectiveComponents);\n\t}\n\n\tprivate _userAgent: string = `node-zwave-js/${libVersion}`;\n\t/** Returns the user agent string used for service requests */\n\tpublic get userAgent(): string {\n\t\treturn this._userAgent;\n\t}\n\n\t/** Returns the user agent string combined with the additional components (if given) */\n\tpublic getUserAgentStringWithComponents(\n\t\tcomponents?: Record<string, string | null | undefined>,\n\t): string {\n\t\tif (!components || Object.keys(components).length === 0) {\n\t\t\treturn this._userAgent;\n\t\t}\n\n\t\tconst merged = mergeUserAgent(\n\t\t\tthis.userAgentComponents,\n\t\t\tcomponents,\n\t\t\tfalse,\n\t\t);\n\t\treturn this.getEffectiveUserAgentString(merged);\n\t}\n\n\t/**\n\t * Enable sending usage statistics. Although this does not include any sensitive information, we expect that you\n\t * inform your users before enabling statistics.\n\t */\n\tpublic enableStatistics(\n\t\tappInfo: Pick<AppInfo, \"applicationName\" | \"applicationVersion\">,\n\t): void {\n\t\tif (this._statisticsEnabled) return;\n\n\t\tif (\n\t\t\t!isObject(appInfo)\n\t\t\t|| typeof appInfo.applicationName !== \"string\"\n\t\t\t|| typeof appInfo.applicationVersion !== \"string\"\n\t\t) {\n\t\t\tthrow new ZWaveError(\n\t\t\t\t`The application statistics must be an object with two string properties \"applicationName\" and \"applicationVersion\"!`,\n\t\t\t\tZWaveErrorCodes.Driver_InvalidOptions,\n\t\t\t);\n\t\t} else if (appInfo.applicationName.length > 100) {\n\t\t\tthrow new ZWaveError(\n\t\t\t\t`The applicationName for statistics must be maximum 100 characters long!`,\n\t\t\t\tZWaveErrorCodes.Driver_InvalidOptions,\n\t\t\t);\n\t\t} else if (appInfo.applicationVersion.length > 100) {\n\t\t\tthrow new ZWaveError(\n\t\t\t\t`The applicationVersion for statistics must be maximum 100 characters long!`,\n\t\t\t\tZWaveErrorCodes.Driver_InvalidOptions,\n\t\t\t);\n\t\t}\n\n\t\tthis._statisticsEnabled = true;\n\t\tthis.statisticsAppInfo = appInfo;\n\n\t\t// If we're already ready, send statistics\n\t\tif (this._nodesReadyEventEmitted) {\n\t\t\tvoid this.compileAndSendStatistics().catch(() => {\n\t\t\t\t/* ignore */\n\t\t\t});\n\t\t}\n\t}\n\n\t/**\n\t * Disable sending usage statistics\n\t */\n\tpublic disableStatistics(): void {\n\t\tthis._statisticsEnabled = false;\n\t\tthis.statisticsAppInfo = undefined;\n\t\tif (this.statisticsTimeout) {\n\t\t\tclearTimeout(this.statisticsTimeout);\n\t\t\tthis.statisticsTimeout = undefined;\n\t\t}\n\t}\n\n\t/** @internal */\n\t// eslint-disable-next-line @typescript-eslint/require-await\n\tpublic async getUUID(): Promise<string> {\n\t\t// To anonymously identify a network, we create a unique ID and use it to salt the Home ID\n\t\tif (!this._valueDB!.has(\"uuid\")) {\n\t\t\tthis._valueDB!.set(\n\t\t\t\t\"uuid\",\n\t\t\t\tBytes.view(randomBytes(32)).toString(\"hex\"),\n\t\t\t);\n\t\t}\n\t\tconst ret = this._valueDB!.get(\"uuid\") as string;\n\t\treturn ret;\n\t}\n\n\tprivate statisticsTimeout: NodeJS.Timeout | undefined;\n\tprivate async compileAndSendStatistics(): Promise<void> {\n\t\t// Don't send anything if statistics are not enabled\n\t\tif (!this.statisticsEnabled || !this.statisticsAppInfo) return;\n\n\t\tif (this.statisticsTimeout) {\n\t\t\tclearTimeout(this.statisticsTimeout);\n\t\t\tthis.statisticsTimeout = undefined;\n\t\t}\n\n\t\tlet success: number | boolean = false;\n\t\ttry {\n\t\t\tconst statistics = await compileStatistics(this, {\n\t\t\t\tdriverVersion: libVersion,\n\t\t\t\t...this.statisticsAppInfo,\n\t\t\t\tnodeVersion: process.versions.node,\n\t\t\t\tos: process.platform,\n\t\t\t\tarch: process.arch,\n\t\t\t});\n\t\t\tsuccess = await sendStatistics(statistics);\n\t\t} catch {\n\t\t\t// Didn't work - try again in a few hours\n\t\t\tsuccess = false;\n\t\t} finally {\n\t\t\tif (typeof success === \"number\") {\n\t\t\t\tthis.driverLog.print(\n\t\t\t\t\t`Sending usage statistics was rate limited - next attempt scheduled in ${success} seconds.`,\n\t\t\t\t\t\"verbose\",\n\t\t\t\t);\n\t\t\t\t// Wait at most 6 hours to try again\n\t\t\t\tconst retryMs = Math.max(\n\t\t\t\t\ttimespan.minutes(1),\n\t\t\t\t\tMath.min(success * 1000, timespan.hours(6)),\n\t\t\t\t);\n\t\t\t\tthis.statisticsTimeout = setTimeout(() => {\n\t\t\t\t\tvoid this.compileAndSendStatistics();\n\t\t\t\t}, retryMs).unref();\n\t\t\t} else {\n\t\t\t\tthis.driverLog.print(\n\t\t\t\t\tsuccess\n\t\t\t\t\t\t? `Usage statistics sent - next transmission scheduled in 23 hours.`\n\t\t\t\t\t\t: `Failed to send usage statistics - next transmission scheduled in 6 hours.`,\n\t\t\t\t\t\"verbose\",\n\t\t\t\t);\n\t\t\t\tthis.statisticsTimeout = setTimeout(() => {\n\t\t\t\t\tvoid this.compileAndSendStatistics();\n\t\t\t\t}, timespan.hours(success ? 23 : 6)).unref();\n\t\t\t}\n\t\t}\n\t}\n\n\t/** Is called when a node interview is completed */\n\tprivate onNodeInterviewCompleted(node: ZWaveNode): void {\n\t\tthis.debounceSendNodeToSleep(node);\n\t}\n\n\t/** This is called when a new node has been added to the network */\n\tprivate onNodeAdded(node: ZWaveNode): void {\n\t\tthis.addNodeEventHandlers(node);\n\n\t\tif (this._options.interview?.disableOnNodeAdded) return;\n\t\tif (this._options.testingHooks?.skipNodeInterview) return;\n\n\t\t// Interview the node\n\t\t// don't await the interview, because it may take a very long time\n\t\t// if a node is asleep\n\t\tvoid this.interviewNodeInternal(node);\n\t}\n\n\t/** This is called when a node was removed from the network */\n\tprivate onNodeRemoved(node: ZWaveNode, reason: RemoveNodeReason): void {\n\t\t// Remove all listeners and timers\n\t\tthis.removeNodeEventHandlers(node);\n\t\tif (this.sendNodeToSleepTimers.has(node.id)) {\n\t\t\tclearTimeout(this.sendNodeToSleepTimers.get(node.id));\n\t\t\tthis.sendNodeToSleepTimers.delete(node.id);\n\t\t}\n\t\tif (this.retryNodeInterviewTimeouts.has(node.id)) {\n\t\t\tclearTimeout(this.retryNodeInterviewTimeouts.get(node.id));\n\t\t\tthis.retryNodeInterviewTimeouts.delete(node.id);\n\t\t}\n\t\tif (this.autoRefreshNodeValueTimers.has(node.id)) {\n\t\t\tclearTimeout(this.autoRefreshNodeValueTimers.get(node.id));\n\t\t\tthis.autoRefreshNodeValueTimers.delete(node.id);\n\t\t}\n\n\t\t// purge node values from the DB\n\t\tnode.valueDB.clear();\n\t\tthis.cachePurge(cacheKeys.node(node.id)._baseKey);\n\n\t\t// Remove the node from all security manager instances\n\t\tthis.securityManager?.deleteAllNoncesForReceiver(node.id);\n\t\tthis.securityManager2?.deleteNonce(node.id);\n\t\tthis.securityManagerLR?.deleteNonce(node.id);\n\n\t\tthis.rejectAllTransactionsForNode(\n\t\t\tnode.id,\n\t\t\t\"The node was removed from the network\",\n\t\t\tZWaveErrorCodes.Controller_NodeRemoved,\n\t\t);\n\n\t\tconst replaced = reason === RemoveNodeReason.Replaced\n\t\t\t|| reason === RemoveNodeReason.ProxyReplaced;\n\t\tif (!replaced) {\n\t\t\t// Asynchronously remove the node from all possible associations, ignore potential errors\n\t\t\t// but only if the node is not getting replaced, because the removal will interfere with\n\t\t\t// bootstrapping the new node\n\t\t\tthis.controller\n\t\t\t\t.removeNodeFromAllAssociations(node.id)\n\t\t\t\t.catch((err) => {\n\t\t\t\t\tthis.driverLog.print(\n\t\t\t\t\t\t`Failed to remove node ${node.id} from all associations: ${err.message}`,\n\t\t\t\t\t\t\"error\",\n\t\t\t\t\t);\n\t\t\t\t});\n\t\t}\n\n\t\t// And clean up all remaining resources used by the node\n\t\tnode.destroy();\n\n\t\t// If this was a failed node it could mean that all nodes are now ready\n\t\tthis.checkAllNodesReady();\n\t}\n\n\tprivate onControllerStatusChanged(_status: ControllerStatus): void {\n\t\tthis.triggerQueues();\n\t}\n\n\tprivate async onNetworkFound(\n\t\thomeId: number,\n\t\t_ownNodeId: number,\n\t): Promise<void> {\n\t\ttry {\n\t\t\tthis.driverLog.print(\n\t\t\t\t`Joined network with home ID ${\n\t\t\t\t\tnum2hex(homeId)\n\t\t\t\t}, switching to new network cache...`,\n\t\t\t);\n\t\t\tawait this.recreateNetworkCacheAndValueDBs();\n\t\t} catch (e) {\n\t\t\tthis.driverLog.print(\n\t\t\t\t`Recreating the network cache and value DBs failed: ${\n\t\t\t\t\tgetErrorMessage(e)\n\t\t\t\t}`,\n\t\t\t\t\"error\",\n\t\t\t);\n\t\t}\n\t}\n\n\tprivate onNetworkJoined(): void {\n\t\tthis.driverLog.print(`Finished joining network`);\n\t}\n\n\tprivate async onNetworkLeft(): Promise<void> {\n\t\ttry {\n\t\t\tthis.driverLog.print(\n\t\t\t\t`Left the previous network, switching network cache to new home ID ${\n\t\t\t\t\tnum2hex(this.controller.homeId)\n\t\t\t\t}...`,\n\t\t\t);\n\t\t\tawait this.recreateNetworkCacheAndValueDBs();\n\t\t} catch (e) {\n\t\t\tthis.driverLog.print(\n\t\t\t\t`Recreating the network cache and value DBs failed: ${\n\t\t\t\t\tgetErrorMessage(e)\n\t\t\t\t}`,\n\t\t\t\t\"error\",\n\t\t\t);\n\t\t}\n\t}\n\n\tprivate async recreateNetworkCacheAndValueDBs(): Promise<void> {\n\t\tawait this._networkCache?.close();\n\t\tawait this._valueDB?.close();\n\t\tawait this._metadataDB?.close();\n\n\t\t// Reopen with the new home ID\n\t\tawait this.initNetworkCache(this.controller.homeId!);\n\t\tawait this.initValueDBs(this.controller.homeId!);\n\t\tawait this.performCacheMigration();\n\t}\n\n\t/**\n\t * Returns the time in seconds to actually wait after a firmware upgrade, depending on what the device said.\n\t * This number will always be a bit greater than the advertised duration, because devices have been found to take longer to actually reboot.\n\t */\n\tpublic getConservativeWaitTimeAfterFirmwareUpdate(\n\t\tadvertisedWaitTime: number | undefined,\n\t): number {\n\t\t// Wait the specified time plus a bit, so the device is actually ready to use\n\t\tif (!advertisedWaitTime) {\n\t\t\t// Wait at least 5 seconds\n\t\t\treturn 5;\n\t\t} else if (advertisedWaitTime < 20) {\n\t\t\treturn advertisedWaitTime + 5;\n\t\t} else if (advertisedWaitTime < 60) {\n\t\t\treturn advertisedWaitTime + 10;\n\t\t} else {\n\t\t\treturn advertisedWaitTime + 30;\n\t\t}\n\t}\n\n\t/** This is called when the firmware on one of a node's firmware targets was updated */\n\tprivate async onNodeFirmwareUpdated(\n\t\tnode: ZWaveNode,\n\t\tresult: FirmwareUpdateResult,\n\t): Promise<void> {\n\t\tconst { success, reInterview } = result;\n\n\t\t// Nothing to do for non-successful updates\n\t\tif (!success) return;\n\n\t\t// TODO: Add support for delayed activation\n\n\t\t// Reset nonces etc. to prevent false-positive duplicates after the update\n\t\tthis.securityManager?.deleteAllNoncesForReceiver(node.id);\n\t\tthis.securityManager2?.deleteNonce(node.id);\n\t\tthis.securityManagerLR?.deleteNonce(node.id);\n\n\t\t// waitTime should always be defined, but just to be sure\n\t\tconst waitTime = result.waitTime ?? 5;\n\n\t\tif (reInterview) {\n\t\t\tthis.controllerLog.logNode(\n\t\t\t\tnode.id,\n\t\t\t\t`Firmware updated, scheduling interview in ${waitTime} seconds...`,\n\t\t\t);\n\t\t\t// We reuse the retryNodeInterviewTimeouts here because they serve a similar purpose\n\t\t\tthis.retryNodeInterviewTimeouts.set(\n\t\t\t\tnode.id,\n\t\t\t\tsetTimeout(() => {\n\t\t\t\t\tthis.retryNodeInterviewTimeouts.delete(node.id);\n\t\t\t\t\tvoid node.refreshInfo({\n\t\t\t\t\t\t// After a firmware update, we need to refresh the node info\n\t\t\t\t\t\twaitForWakeup: false,\n\t\t\t\t\t});\n\t\t\t\t}, waitTime * 1000).unref(),\n\t\t\t);\n\t\t} else {\n\t\t\tthis.controllerLog.logNode(\n\t\t\t\tnode.id,\n\t\t\t\t`Firmware updated. No restart or re-interview required. Refreshing version information in ${waitTime} seconds...`,\n\t\t\t);\n\n\t\t\tawait wait(waitTime * 1000, true);\n\n\t\t\ttry {\n\t\t\t\tconst versionAPI = node.commandClasses.Version;\n\t\t\t\tawait versionAPI.get();\n\t\t\t\tif (\n\t\t\t\t\tversionAPI.supportsCommand(VersionCommand.CapabilitiesGet)\n\t\t\t\t) {\n\t\t\t\t\tawait versionAPI.getCapabilities();\n\t\t\t\t}\n\t\t\t\tif (\n\t\t\t\t\tversionAPI.supportsCommand(VersionCommand.ZWaveSoftwareGet)\n\t\t\t\t) {\n\t\t\t\t\tawait versionAPI.getZWaveSoftware();\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\t// ignore\n\t\t\t}\n\n\t\t\t// No need to keep the node awake longer than necessary\n\t\t\tnode.keepAwake = false;\n\t\t\tthis.debounceSendNodeToSleep(node);\n\t\t}\n\t}\n\n\t/** This is called when a node emits a `\"notification\"` event */\n\tprivate onNodeNotification: ZWaveNotificationCallback = (\n\t\tendpoint,\n\t\tccId,\n\t\tccArgs,\n\t) => {\n\t\tlet prefix: string;\n\t\tlet details: string[];\n\t\tif (ccId === CommandClasses.Notification) {\n\t\t\tconst msg: MessageRecord = {\n\t\t\t\ttype: ccArgs.label,\n\t\t\t\tevent: ccArgs.eventLabel,\n\t\t\t};\n\t\t\tif (ccArgs.parameters) {\n\t\t\t\tif (isUint8Array(ccArgs.parameters)) {\n\t\t\t\t\tmsg.parameters = buffer2hex(ccArgs.parameters);\n\t\t\t\t} else if (Duration.isDuration(ccArgs.parameters)) {\n\t\t\t\t\tmsg.duration = ccArgs.parameters.toString();\n\t\t\t\t} else if (isObject(ccArgs.parameters)) {\n\t\t\t\t\tObject.assign(msg, ccArgs.parameters);\n\t\t\t\t}\n\t\t\t}\n\t\t\tprefix = \"[Notification]\";\n\t\t\tdetails = messageRecordToLines(msg);\n\t\t} else if (ccId === CommandClasses[\"Entry Control\"]) {\n\t\t\tprefix = \"[Notification] Entry Control\";\n\t\t\tdetails = messageRecordToLines({\n\t\t\t\t\"event type\": ccArgs.eventTypeLabel,\n\t\t\t\t\"data type\": ccArgs.dataTypeLabel,\n\t\t\t});\n\t\t} else if (ccId === CommandClasses[\"Multilevel Switch\"]) {\n\t\t\tprefix = \"[Notification] Multilevel Switch\";\n\t\t\tdetails = messageRecordToLines(\n\t\t\t\tstripUndefined({\n\t\t\t\t\t\"event type\": ccArgs.eventTypeLabel,\n\t\t\t\t\tdirection: ccArgs.direction,\n\t\t\t\t}),\n\t\t\t);\n\t\t} /*if (ccId === CommandClasses.Powerlevel)*/ else {\n\t\t\t// Don't bother logging this\n\t\t\treturn;\n\t\t}\n\n\t\tthis.controllerLog.logNode(endpoint.nodeId, {\n\t\t\tendpoint: endpoint.index,\n\t\t\tmessage: [prefix, ...details.map((d) => ` ${d}`)].join(\"\\n\"),\n\t\t});\n\t};\n\n\t/** Checks if there are any pending messages for the given node */\n\tprivate hasPendingMessages(node: ZWaveNodeBase & SchedulePoll): boolean {\n\t\t// First check if there are messages in the queue\n\t\tif (\n\t\t\tthis.hasPendingTransactions(\n\t\t\t\t(t) => t.message.getNodeId() === node.id,\n\t\t\t)\n\t\t) {\n\t\t\treturn true;\n\t\t}\n\n\t\t// Then check if there are scheduled polls\n\t\treturn node.hasScheduledPolls();\n\t}\n\n\t/** Checks if there are any pending transactions that match the given predicate */\n\tpublic hasPendingTransactions(\n\t\tpredicate: (t: Transaction) => boolean,\n\t): boolean {\n\t\t// Queue is not an array\n\t\t// eslint-disable-next-line unicorn/prefer-array-some\n\t\tif (!!this.queue.find((t) => predicate(t))) return true;\n\t\treturn this.queues.some(\n\t\t\t(q) => q.currentTransaction && predicate(q.currentTransaction),\n\t\t);\n\t}\n\n\t/**\n\t * Retrieves the maximum version of a command class the given endpoint supports.\n\t * Returns 0 when the CC is not supported. Also returns 0 when the node was not found.\n\t * Falls back to querying the root endpoint if an endpoint was not found on the node\n\t *\n\t * @param cc The command class whose version should be retrieved\n\t * @param nodeId The node for which the CC version should be retrieved\n\t * @param endpointIndex The endpoint in question\n\t */\n\tpublic getSupportedCCVersion(\n\t\tcc: CommandClasses,\n\t\tnodeId: number,\n\t\tendpointIndex: number = 0,\n\t): number {\n\t\tif (!this._controller?.nodes.has(nodeId)) {\n\t\t\treturn 0;\n\t\t}\n\t\tconst node = this.controller.nodes.get(nodeId)!;\n\t\tconst endpoint = node.getEndpoint(endpointIndex);\n\t\tif (endpoint) return endpoint.getCCVersion(cc);\n\t\t// We sometimes receive messages from an endpoint, but can't find that endpoint.\n\t\t// In that case fall back to the root endpoint to determine the supported version.\n\t\treturn node.getCCVersion(cc);\n\t}\n\n\t/**\n\t * Retrieves the maximum version of a command class that can be used to communicate with a node.\n\t * Returns the highest implemented version if the node's CC version is unknown.\n\t * Returns `undefined` for CCs that are not implemented in this library yet.\n\t *\n\t * @param cc The command class whose version should be retrieved\n\t * @param nodeId The node for which the CC version should be retrieved\n\t * @param endpointIndex The endpoint for which the CC version should be retrieved\n\t */\n\tpublic getSafeCCVersion(\n\t\tcc: CommandClasses,\n\t\tnodeId: number,\n\t\tendpointIndex: number = 0,\n\t): number | undefined {\n\t\tconst implementedVersion = getImplementedVersion(cc);\n\t\tif (\n\t\t\timplementedVersion === 0\n\t\t\t|| implementedVersion === Number.POSITIVE_INFINITY\n\t\t) {\n\t\t\treturn undefined;\n\t\t}\n\t\tconst supportedVersion = this.getSupportedCCVersion(\n\t\t\tcc,\n\t\t\tnodeId,\n\t\t\tendpointIndex,\n\t\t);\n\t\tif (supportedVersion === 0) {\n\t\t\t// Unknown, use the highest implemented version\n\t\t\treturn implementedVersion;\n\t\t}\n\n\t\treturn Math.min(supportedVersion, implementedVersion);\n\t}\n\n\t/**\n\t * Determines whether a CC must be secure for a given node and endpoint.\n\t *\n\t * @param ccId The command class in question\n\t * @param nodeId The node for which the CC security should be determined\n\t * @param endpointIndex The endpoint for which the CC security should be determined\n\t */\n\tisCCSecure(\n\t\tccId: CommandClasses,\n\t\tnodeId: number,\n\t\tendpointIndex: number = 0,\n\t): boolean {\n\t\t// This is obvious\n\t\tif (\n\t\t\tccId === CommandClasses.Security\n\t\t\t|| ccId === CommandClasses[\"Security 2\"]\n\t\t) {\n\t\t\treturn true;\n\t\t}\n\n\t\tconst node = this.controller.nodes.get(nodeId);\n\t\t// Node is unknown, don't use secure communication\n\t\tif (!node) return false;\n\n\t\tconst endpoint = node.getEndpoint(endpointIndex);\n\n\t\tconst securityClass = node.getHighestSecurityClass();\n\t\t// Node is not secure, don't use secure communication\n\t\tif (\n\t\t\tsecurityClass === undefined || securityClass === SecurityClass.None\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Special case for Basic CC, which we sometimes hide:\n\t\t// A securely included node MAY support the Basic Command Class at the highest security level but it\n\t\t// MUST NOT support the Basic Command Class at any lower security level or non-securely.\n\t\tconst isBasicCC = ccId === CommandClasses.Basic;\n\n\t\t// Security S2 specs also mandate that all non-securely supported CCs MUST also be supported securely\n\t\t// so we can just shortcut if the node is using S2\n\t\tif (securityClassIsS2(securityClass)) {\n\t\t\t// Use secure communication if the CC is supported. This avoids silly things like S2-encapsulated pings\n\t\t\treturn (\n\t\t\t\t!!this.getSecurityManager2(nodeId)\n\t\t\t\t&& (isBasicCC || (endpoint ?? node).supportsCC(ccId))\n\t\t\t);\n\t\t}\n\n\t\t// Security S0 can be a little more complicated, with secure and non-secure endpoints\n\t\tif (securityClass === SecurityClass.S0_Legacy) {\n\t\t\t// Therefore actually check if the CC is marked as secure\n\t\t\treturn (\n\t\t\t\t!!this.securityManager\n\t\t\t\t&& (isBasicCC || (endpoint ?? node).isCCSecure(ccId))\n\t\t\t);\n\t\t}\n\n\t\t// We shouldn't be here\n\t\treturn false;\n\t}\n\n\t/**\n\t * **!!! INTERNAL !!!**\n\t *\n\t * Not intended to be used by applications.\n\t * Needed for compatibility with CCAPIHost\n\t */\n\tpublic schedulePoll(\n\t\tnodeId: number,\n\t\tvalueId: ValueID,\n\t\toptions: NodeSchedulePollOptions,\n\t): boolean {\n\t\tconst node = this.controller.nodes.getOrThrow(nodeId);\n\t\treturn node.schedulePoll(valueId, options);\n\t}\n\n\tprivate isSoftResetting: boolean = false;\n\n\tprivate maySoftReset(): boolean {\n\t\t// 700+ series controllers have no problems with soft reset and MUST even be soft reset in some cases\n\t\tif (this._controller?.sdkVersionGt(\"7.0\")) return true;\n\n\t\t// Blacklist some sticks that are known to not support soft reset\n\t\tconst { manufacturerId, productType, productId } = this.controller;\n\n\t\t// Z-Wave.me UZB1\n\t\tif (\n\t\t\tmanufacturerId === 0x0115\n\t\t\t&& productType === 0x0000\n\t\t\t&& productId === 0x0000\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Z-Wave.me UZB\n\t\tif (\n\t\t\tmanufacturerId === 0x0115\n\t\t\t&& productType === 0x0400\n\t\t\t&& productId === 0x0001\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Vision Gen5 USB Stick\n\t\tif (\n\t\t\tmanufacturerId === 0x0109\n\t\t\t&& productType === 0x1001\n\t\t\t&& productId === 0x0201\n\t\t\t// firmware version 15.1 (GH#3730)\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// No clear indication, make the result depend on the config option\n\t\treturn !!this._options.features.softReset;\n\t}\n\n\t/**\n\t * Soft-resets the controller if the feature is enabled\n\t */\n\tpublic async trySoftReset(): Promise<void> {\n\t\tif (this.maySoftReset()) {\n\t\t\tawait this.softReset();\n\t\t} else {\n\t\t\tconst message =\n\t\t\t\t`The controller should not or cannot be soft reset, skipping API call.`;\n\t\t\tthis.controllerLog.print(message, \"warn\");\n\t\t}\n\t}\n\n\t/**\n\t * Instruct the controller to soft-reset.\n\t *\n\t * **Warning:** USB modules will reconnect, meaning that they might get a new address.\n\t *\n\t * **Warning:** This call will throw if soft-reset is not enabled.\n\t */\n\tpublic async softReset(): Promise<void> {\n\t\tif (!this.maySoftReset()) {\n\t\t\tconst message =\n\t\t\t\t`The controller does not support soft reset or the soft reset feature has been disabled with a config option or the ZWAVEJS_DISABLE_SOFT_RESET environment variable.`;\n\t\t\tthis.controllerLog.print(message, \"error\");\n\t\t\tthrow new ZWaveError(\n\t\t\t\tmessage,\n\t\t\t\tZWaveErrorCodes.Driver_FeatureDisabled,\n\t\t\t);\n\t\t}\n\n\t\tif (this._controller?.isAnyOTAFirmwareUpdateInProgress()) {\n\t\t\tconst message =\n\t\t\t\t`Failed to soft reset controller: A firmware update is in progress on this network.`;\n\t\t\tthis.controllerLog.print(message, \"error\");\n\t\t\tthrow new ZWaveError(\n\t\t\t\tmessage,\n\t\t\t\tZWaveErrorCodes.FirmwareUpdateCC_NetworkBusy,\n\t\t\t);\n\t\t}\n\n\t\treturn this.softResetInternal(true);\n\t}\n\n\tprivate async softResetInternal(destroyOnError: boolean): Promise<void> {\n\t\tthis.controllerLog.print(\"Performing soft reset...\");\n\n\t\ttry {\n\t\t\tthis.isSoftResetting = true;\n\t\t\tawait this.sendMessage(new SoftResetRequest(), {\n\t\t\t\tsupportCheck: false,\n\t\t\t\tpauseSendThread: true,\n\t\t\t});\n\t\t} catch (e) {\n\t\t\tthis.controllerLog.print(\n\t\t\t\t`Soft reset failed: ${getErrorMessage(e)}`,\n\t\t\t\t\"error\",\n\t\t\t);\n\t\t\t// Don't continue if the controller is unresponsive\n\t\t\tif (isMissingControllerACK(e)) throw e;\n\t\t}\n\n\t\tif (this._controller) {\n\t\t\t// Soft-reset resets the node ID type back to 8 bit\n\t\t\tthis._controller[\"_nodeIdType\"] = NodeIDType.Short;\n\n\t\t\t// Soft-resetting disables any ongoing inclusion, so we need to reset\n\t\t\t// the state that is tracked in the controller\n\t\t\tthis._controller.setInclusionState(InclusionState.Idle);\n\t\t}\n\n\t\t// Make sure we're able to communicate with the controller again\n\t\tif (!(await this.ensureSerialAPI())) {\n\t\t\tif (destroyOnError) {\n\t\t\t\tawait this.destroy();\n\t\t\t} else {\n\t\t\t\tthrow new ZWaveError(\n\t\t\t\t\t\"The Serial API did not respond after soft-reset\",\n\t\t\t\t\tZWaveErrorCodes.Driver_Failed,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tthis.isSoftResetting = false;\n\n\t\t// This is a bit hacky, but what the heck...\n\t\tif (!this._enteringBootloader) {\n\t\t\t// Start the watchdog again, unless disabled\n\t\t\tif (this.options.features.watchdog) {\n\t\t\t\tvoid this._controller?.startWatchdog();\n\t\t\t}\n\n\t\t\t// If desired, re-configure the controller to use 16 bit node IDs\n\t\t\tvoid this._controller?.trySetNodeIDType(NodeIDType.Long);\n\n\t\t\t// Resume sending\n\t\t\tthis.unpauseSendQueue();\n\t\t}\n\t}\n\n\t/** @internal */\n\tpublic async softResetAndRestart(\n\t\trestartLogMessage: string,\n\t\trestartReason: string,\n\t): Promise<void> {\n\t\tthis.controllerLog.print(\"Performing soft reset...\");\n\n\t\ttry {\n\t\t\tthis.isSoftResetting = true;\n\t\t\tawait this.sendMessage(new SoftResetRequest(), {\n\t\t\t\tsupportCheck: false,\n\t\t\t\tpauseSendThread: true,\n\t\t\t});\n\t\t} catch (e) {\n\t\t\tthis.controllerLog.print(\n\t\t\t\t`Soft reset failed: ${getErrorMessage(e)}`,\n\t\t\t\t\"error\",\n\t\t\t);\n\t\t}\n\t\tthis.isSoftResetting = false;\n\n\t\tthis.controllerLog.print(restartLogMessage);\n\n\t\tawait this.destroy();\n\n\t\t// Let the async calling context finish before emitting the error\n\t\tprocess.nextTick(() => {\n\t\t\tthis.emit(\n\t\t\t\t\"error\",\n\t\t\t\tnew ZWaveError(restartReason, ZWaveErrorCodes.Driver_Failed),\n\t\t\t);\n\t\t});\n\t}\n\n\t/**\n\t * Checks whether recovering an unresponsive controller is enabled\n\t * and whether the driver is in a state where it makes sense.\n\t */\n\tprivate mayRecoverUnresponsiveController(): boolean {\n\t\tif (!this._options.features.unresponsiveControllerRecovery) {\n\t\t\treturn false;\n\t\t}\n\t\t// Only recover after we know the controller has been responsive\n\t\treturn this._controllerInterviewed;\n\t}\n\n\tprivate async ensureSerialAPI(): Promise<boolean> {\n\t\t// Wait 1.5 seconds after reset to ensure that the module is ready for communication again\n\t\t// Z-Wave 700 sticks are relatively fast, so we also wait for the Serial API started command\n\t\t// to bail early\n\t\tthis.controllerLog.print(\"Waiting for the controller to reconnect...\");\n\t\tlet waitResult = await this.waitForMessage<SerialAPIStartedRequest>(\n\t\t\t(msg) => msg.functionType === FunctionType.SerialAPIStarted,\n\t\t\t1500,\n\t\t).catch(() => false as const);\n\n\t\tif (waitResult) {\n\t\t\t// Serial API did start\n\t\t\tthis.controllerLog.print(\"reconnected and restarted\");\n\t\t\tthis.controller[\"_supportsLongRange\"] =\n\t\t\t\twaitResult.supportsLongRange;\n\t\t\treturn true;\n\t\t}\n\n\t\t// If the controller disconnected the serial port during the soft reset, we need to re-open it\n\t\tif (!this.serial!.isOpen) {\n\t\t\tthis.controllerLog.print(\"Re-opening serial port...\");\n\t\t\ttry {\n\t\t\t\tawait this.openSerialport();\n\t\t\t} catch {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\t// Wait the configured amount of time for the Serial API started command to be received\n\t\tthis.controllerLog.print(\"Waiting for the Serial API to start...\");\n\t\twaitResult = await this.waitForMessage<SerialAPIStartedRequest>(\n\t\t\t(msg) => {\n\t\t\t\treturn msg.functionType === FunctionType.SerialAPIStarted;\n\t\t\t},\n\t\t\tthis._options.timeouts.serialAPIStarted,\n\t\t).catch(() => false as const);\n\n\t\tif (waitResult) {\n\t\t\t// Serial API did start, maybe do something with the information?\n\t\t\tthis.controllerLog.print(\"Serial API started\");\n\t\t\tthis.controller[\"_supportsLongRange\"] =\n\t\t\t\twaitResult.supportsLongRange;\n\t\t\treturn true;\n\t\t}\n\n\t\tthis.controllerLog.print(\n\t\t\t\"Did not receive notification that Serial API has started, checking if it responds...\",\n\t\t);\n\n\t\t// We don't need to use any specific command here. However we're going to use this one in the interview\n\t\t// anyways, so we might aswell use it here too\n\t\tconst pollController = async () => {\n\t\t\ttry {\n\t\t\t\t// And resume sending - this requires us to unpause the send thread\n\t\t\t\tthis.unpauseSendQueue();\n\t\t\t\tawait this.sendMessage(new GetControllerVersionRequest(), {\n\t\t\t\t\tsupportCheck: false,\n\t\t\t\t\tpriority: MessagePriority.ControllerImmediate,\n\t\t\t\t});\n\t\t\t\tthis.pauseSendQueue();\n\t\t\t\tthis.controllerLog.print(\"Serial API responded\");\n\t\t\t\treturn true;\n\t\t\t} catch {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t};\n\t\t// Poll the controller with increasing backoff delay\n\t\tif (await pollController()) return true;\n\t\tfor (const backoff of [2, 5, 10, 15]) {\n\t\t\tthis.controllerLog.print(\n\t\t\t\t`Serial API did not respond, trying again in ${backoff} seconds...`,\n\t\t\t);\n\t\t\tawait wait(backoff * 1000);\n\t\t\tif (await pollController()) return true;\n\t\t}\n\n\t\tthis.controllerLog.print(\n\t\t\t\"Serial API did not respond, giving up\",\n\t\t\t\"error\",\n\t\t);\n\t\treturn false;\n\t}\n\n\t/**\n\t * Performs a hard reset on the controller. This wipes out all configuration!\n\t *\n\t * The returned Promise resolves when the hard reset has been performed.\n\t * It does not wait for the initialization process which is started afterwards.\n\t */\n\tpublic async hardReset(): Promise<void> {\n\t\tthis.ensureReady(true);\n\n\t\tif (this.controller.isAnyOTAFirmwareUpdateInProgress()) {\n\t\t\tconst message =\n\t\t\t\t`Failed to hard reset controller: A firmware update is in progress on this network.`;\n\t\t\tthis.controllerLog.print(message, \"error\");\n\t\t\tthrow new ZWaveError(\n\t\t\t\tmessage,\n\t\t\t\tZWaveErrorCodes.FirmwareUpdateCC_NetworkBusy,\n\t\t\t);\n\t\t}\n\n\t\t// Preserve the private key for the authenticated learn mode ECDH key pair\n\t\tconst oldPrivateKey = this.cacheGet<Uint8Array>(\n\t\t\tcacheKeys.controller.privateKey,\n\t\t);\n\n\t\t// Drop all scheduled tasks - they don't make sense after a hard reset\n\t\tawait this.scheduler.removeTasks(\n\t\t\t() => true,\n\t\t\tnew ZWaveError(\n\t\t\t\t\"The controller is being hard-reset\",\n\t\t\t\tZWaveErrorCodes.Driver_TaskRemoved,\n\t\t\t),\n\t\t);\n\n\t\t// Update the controller NIF prior to hard resetting\n\t\tawait this.controller.setControllerNIF();\n\t\tawait this.controller.hardReset();\n\n\t\t// Clean up\n\t\tthis.rejectTransactions(() => true, `The controller was hard-reset`);\n\t\tthis.sendNodeToSleepTimers.forEach((timeout) => clearTimeout(timeout));\n\t\tthis.sendNodeToSleepTimers.clear();\n\t\tthis.retryNodeInterviewTimeouts.forEach((timeout) =>\n\t\t\tclearTimeout(timeout)\n\t\t);\n\t\tthis.retryNodeInterviewTimeouts.clear();\n\t\tthis.autoRefreshNodeValueTimers.forEach((timeout) =>\n\t\t\tclearTimeout(timeout)\n\t\t);\n\t\tthis.autoRefreshNodeValueTimers.clear();\n\t\tif (this.pollBackgroundRSSITimer) {\n\t\t\tclearTimeout(this.pollBackgroundRSSITimer);\n\t\t\tthis.pollBackgroundRSSITimer = undefined;\n\t\t}\n\n\t\tthis._controllerInterviewed = false;\n\t\tvoid this.initializeControllerAndNodes();\n\n\t\t// Save the key pair in the new cache again\n\t\tif (oldPrivateKey) {\n\t\t\tthis.once(\"driver ready\", () => {\n\t\t\t\tthis.cacheSet(cacheKeys.controller.privateKey, oldPrivateKey);\n\t\t\t});\n\t\t}\n\t}\n\n\t/**\n\t * Instructs the Z-Wave API to shut down in order to safely remove the power.\n\t * This will destroy the driver instance if it succeeds.\n\t */\n\tpublic async shutdown(): Promise<boolean> {\n\t\tthis.ensureReady(true);\n\n\t\t// Not a good idea to abort firmware updates this way\n\t\tif (this.controller.isAnyOTAFirmwareUpdateInProgress()) {\n\t\t\tconst message =\n\t\t\t\t`Failed to shut down controller: A firmware update is in progress on this network.`;\n\t\t\tthis.controllerLog.print(message, \"error\");\n\t\t\tthrow new ZWaveError(\n\t\t\t\tmessage,\n\t\t\t\tZWaveErrorCodes.FirmwareUpdateCC_NetworkBusy,\n\t\t\t);\n\t\t}\n\n\t\tconst result = await this.controller.shutdown();\n\t\ttry {\n\t\t\tif (result) await this.destroy();\n\t\t} finally {\n\t\t\treturn result;\n\t\t}\n\t}\n\n\tprivate _destroyPromise: DeferredPromise<void> | undefined;\n\tprivate get wasDestroyed(): boolean {\n\t\treturn !!this._destroyPromise;\n\t}\n\n\t/**\n\t * Ensures that the driver is ready to communicate (serial port open and not destroyed).\n\t * If desired, also checks that the controller interview has been completed.\n\t */\n\tprivate ensureReady(includingController: boolean = false): void {\n\t\tif (!this._wasStarted || !this._isOpen || this.wasDestroyed) {\n\t\t\tthrow new ZWaveError(\n\t\t\t\t\"The driver is not ready or has been destroyed\",\n\t\t\t\tZWaveErrorCodes.Driver_NotReady,\n\t\t\t);\n\t\t}\n\t\tif (includingController && !this._controllerInterviewed) {\n\t\t\tthrow new ZWaveError(\n\t\t\t\t\"The controller is not ready yet\",\n\t\t\t\tZWaveErrorCodes.Driver_NotReady,\n\t\t\t);\n\t\t}\n\t\tif (this._bootloader) {\n\t\t\tthrow new ZWaveError(\n\t\t\t\t\"Cannot do this while in bootloader mode\",\n\t\t\t\tZWaveErrorCodes.Driver_NotReady,\n\t\t\t);\n\t\t}\n\t}\n\n\t/** Indicates whether the driver is ready, i.e. the \"driver ready\" event was emitted */\n\tpublic get ready(): boolean {\n\t\treturn (\n\t\t\tthis._wasStarted\n\t\t\t&& this._isOpen\n\t\t\t&& !this.wasDestroyed\n\t\t\t&& this._controllerInterviewed\n\t\t);\n\t}\n\n\tprivate async destroyWithMessage(message: string): Promise<void> {\n\t\tthis.driverLog.print(message, \"error\");\n\n\t\tconst error = new ZWaveError(\n\t\t\tmessage,\n\t\t\tZWaveErrorCodes.Driver_Failed,\n\t\t);\n\t\tthis.emit(\"error\", error);\n\n\t\tawait this.destroy();\n\t}\n\n\t/**\n\t * Terminates the driver instance and closes the underlying serial connection.\n\t * Must be called under any circumstances.\n\t */\n\tpublic async destroy(): Promise<void> {\n\t\t// Ensure this is only called once and all subsequent calls block\n\t\tif (this._destroyPromise) return this._destroyPromise;\n\t\tthis._destroyPromise = createDeferredPromise();\n\n\t\tthis.driverLog.print(\"destroying driver instance...\");\n\n\t\t// First stop the scheduler, all queues and close the serial port, so nothing happens anymore\n\t\tawait this._scheduler.stop();\n\n\t\tthis.serialAPIQueue.abort();\n\t\tfor (const queue of this.queues) {\n\t\t\tqueue.abort();\n\t\t}\n\t\tif (this.serialAPIInterpreter?.status === InterpreterStatus.Running) {\n\t\t\tthis.serialAPIInterpreter.stop();\n\t\t}\n\t\tif (this.serial != undefined) {\n\t\t\t// Avoid spewing errors if the port was in the middle of receiving something\n\t\t\tthis.serial.removeAllListeners();\n\t\t\tif (this.serial.isOpen) await this.serial.close();\n\t\t\tthis.serial = undefined;\n\t\t}\n\n\t\t// Attempt to close the value DBs and network cache\n\t\ttry {\n\t\t\tawait this._valueDB?.close();\n\t\t} catch (e) {\n\t\t\tthis.driverLog.print(\n\t\t\t\t`Closing the value DB failed: ${getErrorMessage(e)}`,\n\t\t\t\t\"error\",\n\t\t\t);\n\t\t}\n\t\ttry {\n\t\t\tawait this._metadataDB?.close();\n\t\t} catch (e) {\n\t\t\tthis.driverLog.print(\n\t\t\t\t`Closing the metadata DB failed: ${getErrorMessage(e)}`,\n\t\t\t\t\"error\",\n\t\t\t);\n\t\t}\n\t\ttry {\n\t\t\tawait this._networkCache?.close();\n\t\t} catch (e) {\n\t\t\tthis.driverLog.print(\n\t\t\t\t`Closing the network cache failed: ${getErrorMessage(e)}`,\n\t\t\t\t\"error\",\n\t\t\t);\n\t\t}\n\n\t\t// Remove all timeouts\n\t\tfor (\n\t\t\tconst timeout of [\n\t\t\t\t...this.sendNodeToSleepTimers.values(),\n\t\t\t\t...this.retryNodeInterviewTimeouts.values(),\n\t\t\t\t...this.autoRefreshNodeValueTimers.values(),\n\t\t\t\tthis.statisticsTimeout,\n\t\t\t\tthis.pollBackgroundRSSITimer,\n\t\t\t\t...this.awaitedCommands.map((c) => c.timeout),\n\t\t\t\t...this.awaitedMessages.map((m) => m.timeout),\n\t\t\t\t...this.awaitedMessageHeaders.map((h) => h.timeout),\n\t\t\t\t...this.awaitedBootloaderChunks.map((b) => b.timeout),\n\t\t\t\tthis._powerlevelTestNodeContext?.timeout,\n\t\t\t]\n\t\t) {\n\t\t\tif (timeout) clearTimeout(timeout);\n\t\t}\n\n\t\t// Destroy all nodes and the controller\n\t\tif (this._controller) {\n\t\t\tthis._controller.nodes.forEach((n) => n.destroy());\n\t\t\t(this._controller.nodes as ThrowingMap<any, any>).clear();\n\n\t\t\tthis._controller.removeAllListeners();\n\t\t\tthis._controller = undefined;\n\t\t}\n\n\t\tthis.driverLog.print(`driver instance destroyed`);\n\n\t\t// destroy loggers as the very last thing\n\t\tthis._logContainer.destroy();\n\n\t\tthis._destroyPromise.resolve();\n\t}\n\n\t/**\n\t * Is called when the serial port has received a single-byte message or a complete message buffer\n\t */\n\tprivate async serialport_onData(\n\t\tdata:\n\t\t\t| Uint8Array\n\t\t\t| MessageHeaders.ACK\n\t\t\t| MessageHeaders.CAN\n\t\t\t| MessageHeaders.NAK,\n\t): Promise<void> {\n\t\tif (typeof data === \"number\") {\n\t\t\tswitch (data) {\n\t\t\t\t// single-byte messages - just forward them to the send thread\n\t\t\t\tcase MessageHeaders.ACK: {\n\t\t\t\t\tif (\n\t\t\t\t\t\tthis.serialAPIInterpreter?.status\n\t\t\t\t\t\t\t=== InterpreterStatus.Running\n\t\t\t\t\t) {\n\t\t\t\t\t\tthis.serialAPIInterpreter.send(\"ACK\");\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tcase MessageHeaders.NAK: {\n\t\t\t\t\tif (\n\t\t\t\t\t\tthis.serialAPIInterpreter?.status\n\t\t\t\t\t\t\t=== InterpreterStatus.Running\n\t\t\t\t\t) {\n\t\t\t\t\t\tthis.serialAPIInterpreter.send(\"NAK\");\n\t\t\t\t\t}\n\t\t\t\t\tthis._controller?.incrementStatistics(\"NAK\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tcase MessageHeaders.CAN: {\n\t\t\t\t\tif (\n\t\t\t\t\t\tthis.serialAPIInterpreter?.status\n\t\t\t\t\t\t\t=== InterpreterStatus.Running\n\t\t\t\t\t) {\n\t\t\t\t\t\tthis.serialAPIInterpreter.send(\"CAN\");\n\t\t\t\t\t}\n\t\t\t\t\tthis._controller?.incrementStatistics(\"CAN\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tlet msg: Message | undefined;\n\t\ttry {\n\t\t\t// Parse the message while remembering potential decoding errors in embedded CCs\n\t\t\t// This way we can log the invalid CC contents\n\t\t\tmsg = Message.parse(\n\t\t\t\tdata,\n\t\t\t\tthis.getMessageParsingContext(),\n\t\t\t);\n\n\t\t\t// Parse embedded CCs\n\t\t\tif (isCommandRequest(msg) && containsSerializedCC(msg)) {\n\t\t\t\tmsg.command = await CommandClass.parseAsync(\n\t\t\t\t\tmsg.serializedCC,\n\t\t\t\t\t{\n\t\t\t\t\t\t...this.getCCParsingContext(),\n\t\t\t\t\t\tsourceNodeId: msg.getNodeId()!,\n\t\t\t\t\t\tframeType: msg.frameType,\n\t\t\t\t\t},\n\t\t\t\t);\n\n\t\t\t\t// Whether successful or not, a message from a node should update last seen\n\t\t\t\tconst node = this.tryGetNode(msg);\n\t\t\t\tif (node) node.lastSeen = new Date();\n\n\t\t\t\t// Ensure there are no errors\n\t\t\t\tassertValidCCs(msg as ContainsCC);\n\t\t\t}\n\t\t\t// And update statistics\n\t\t\tif (!!this._controller) {\n\t\t\t\tif (containsCC(msg)) {\n\t\t\t\t\tthis.tryGetNode(msg)?.incrementStatistics(\"commandsRX\");\n\t\t\t\t} else {\n\t\t\t\t\tthis._controller.incrementStatistics(\"messagesRX\");\n\t\t\t\t}\n\t\t\t}\n\t\t\t// all good, send ACK\n\t\t\tawait this.writeHeader(MessageHeaders.ACK);\n\t\t} catch (e: any) {\n\t\t\ttry {\n\t\t\t\tif (await this.handleSecurityS2DecodeError(e, msg)) {\n\t\t\t\t\t// TODO\n\t\t\t\t} else {\n\t\t\t\t\tconst response = this.handleDecodeError(e, data, msg);\n\t\t\t\t\tif (response) await this.writeHeader(response);\n\t\t\t\t\tif (!!this._controller) {\n\t\t\t\t\t\tif (containsCC(msg)) {\n\t\t\t\t\t\t\tthis.tryGetNode(msg)?.incrementStatistics(\n\t\t\t\t\t\t\t\t\"commandsDroppedRX\",\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t// Figure out if the command was received with supervision encapsulation\n\t\t\t\t\t\t\tconst supervisionSessionId = SupervisionCC\n\t\t\t\t\t\t\t\t.getSessionId(msg.command);\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tsupervisionSessionId !== undefined\n\t\t\t\t\t\t\t\t&& msg.command instanceof InvalidCC\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t// If it was, we need to notify the sender that we couldn't decode the command\n\t\t\t\t\t\t\t\tconst node = this.tryGetNode(msg);\n\t\t\t\t\t\t\t\tif (node) {\n\t\t\t\t\t\t\t\t\tconst endpoint = node.getEndpoint(\n\t\t\t\t\t\t\t\t\t\tmsg.command.endpointIndex,\n\t\t\t\t\t\t\t\t\t) ?? node;\n\t\t\t\t\t\t\t\t\tconst encapsulationFlags =\n\t\t\t\t\t\t\t\t\t\tmsg.command.encapsulationFlags;\n\t\t\t\t\t\t\t\t\tawait endpoint\n\t\t\t\t\t\t\t\t\t\t.createAPI(\n\t\t\t\t\t\t\t\t\t\t\tCommandClasses.Supervision,\n\t\t\t\t\t\t\t\t\t\t\tfalse,\n\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t.sendReport({\n\t\t\t\t\t\t\t\t\t\t\tsessionId: supervisionSessionId,\n\t\t\t\t\t\t\t\t\t\t\tmoreUpdatesFollow: false,\n\t\t\t\t\t\t\t\t\t\t\tstatus: SupervisionStatus.NoSupport,\n\t\t\t\t\t\t\t\t\t\t\trequestWakeUpOnDemand: this\n\t\t\t\t\t\t\t\t\t\t\t\t.shouldRequestWakeupOnDemand(\n\t\t\t\t\t\t\t\t\t\t\t\t\tnode,\n\t\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\tencapsulationFlags,\n\t\t\t\t\t\t\t\t\t\t\tlowPriority: this\n\t\t\t\t\t\t\t\t\t\t\t\t.shouldUseLowPriorityForSupervisionReport(\n\t\t\t\t\t\t\t\t\t\t\t\t\tnode,\n\t\t\t\t\t\t\t\t\t\t\t\t\tencapsulationFlags,\n\t\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tthis._controller.incrementStatistics(\n\t\t\t\t\t\t\t\t\"messagesDroppedRX\",\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} catch (ee) {\n\t\t\t\tif (ee instanceof Error) {\n\t\t\t\t\tif (/serial port is not open/.test(ee.message)) {\n\t\t\t\t\t\tthis.emit(\"error\", ee);\n\t\t\t\t\t\tvoid this.destroy();\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\t// Print something, so we know what is wrong\n\t\t\t\t\tthis._driverLog.print(ee.stack ?? ee.message, \"error\");\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Don't keep handling the message\n\t\t\tmsg = undefined;\n\t\t}\n\n\t\t// If we receive a CC from a node while the controller is not ready yet,\n\t\t// we can't do anything with it, but logging it may assume that it can access the controller.\n\t\t// To prevent this problem, we just ignore CCs until the controller is ready\n\t\tif (!this._controller && containsCC(msg)) return;\n\n\t\t// If the message could be decoded, forward it to the send thread\n\t\tif (msg) {\n\t\t\tlet wasMessageLogged = false;\n\t\t\tif (isCommandRequest(msg) && containsCC(msg)) {\n\t\t\t\t// SecurityCCCommandEncapsulationNonceGet is two commands in one, but\n\t\t\t\t// we're not set up to handle things like this. Reply to the nonce get\n\t\t\t\t// and handle the encapsulation part normally\n\t\t\t\tif (\n\t\t\t\t\tmsg.command\n\t\t\t\t\t\tinstanceof SecurityCCCommandEncapsulationNonceGet\n\t\t\t\t) {\n\t\t\t\t\tvoid this.tryGetNode(msg)?.handleSecurityNonceGet();\n\t\t\t\t}\n\n\t\t\t\t// Transport Service commands must be handled before assembling partial CCs\n\t\t\t\tif (isTransportServiceEncapsulation(msg.command)) {\n\t\t\t\t\t// Log Transport Service commands before doing anything else\n\t\t\t\t\tthis.driverLog.logMessage(msg, {\n\t\t\t\t\t\tsecondaryTags: [\"partial\"],\n\t\t\t\t\t\tdirection: \"inbound\",\n\t\t\t\t\t});\n\t\t\t\t\twasMessageLogged = true;\n\n\t\t\t\t\tvoid this.handleTransportServiceCommand(msg.command).catch(\n\t\t\t\t\t\t() => {\n\t\t\t\t\t\t\t// Don't care about errors in incoming transport service commands\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\t// Assemble partial CCs on the driver level. Only forward complete messages to the send thread machine\n\t\t\t\tif (!(await this.assemblePartialCCs(msg))) {\n\t\t\t\t\t// Check if a message timer needs to be refreshed.\n\t\t\t\t\tfor (const entry of this.awaitedMessages) {\n\t\t\t\t\t\tif (entry.refreshPredicate?.(msg)) {\n\t\t\t\t\t\t\tentry.timeout?.refresh();\n\t\t\t\t\t\t\t// Since this is a partial message there may be no clear 1:1 match.\n\t\t\t\t\t\t\t// Therefore we loop through all awaited messages\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Make sure we are allowed to handle this command\n\t\t\t\tif (\n\t\t\t\t\tthis.isSecurityLevelTooLow(msg.command)\n\t\t\t\t\t|| this.shouldDiscardCC(msg.command)\n\t\t\t\t) {\n\t\t\t\t\tif (!wasMessageLogged) {\n\t\t\t\t\t\tthis.driverLog.logMessage(msg, {\n\t\t\t\t\t\t\tdirection: \"inbound\",\n\t\t\t\t\t\t\tsecondaryTags: [\"discarded\"],\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// When we have a complete CC, save its values\n\t\t\t\ttry {\n\t\t\t\t\tthis.persistCCValues(msg.command);\n\t\t\t\t} catch (e) {\n\t\t\t\t\t// Indicate invalid payloads with a special CC type\n\t\t\t\t\tif (\n\t\t\t\t\t\tisZWaveError(e)\n\t\t\t\t\t\t&& e.code\n\t\t\t\t\t\t\t=== ZWaveErrorCodes.PacketFormat_InvalidPayload\n\t\t\t\t\t) {\n\t\t\t\t\t\tthis.driverLog.print(\n\t\t\t\t\t\t\t`dropping CC with invalid values${\n\t\t\t\t\t\t\t\ttypeof e.context === \"string\"\n\t\t\t\t\t\t\t\t\t? ` (Reason: ${e.context})`\n\t\t\t\t\t\t\t\t\t: \"\"\n\t\t\t\t\t\t\t}`,\n\t\t\t\t\t\t\t\"warn\",\n\t\t\t\t\t\t);\n\t\t\t\t\t\t// TODO: We may need to do the S2 MOS dance here - or we can deal with it when the next valid CC arrives\n\t\t\t\t\t\treturn;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthrow e;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Transport Service CC can be eliminated from the encapsulation stack, since it is always the outermost CC\n\t\t\t\tif (isTransportServiceEncapsulation(msg.command)) {\n\t\t\t\t\tmsg.command = msg.command.encapsulated;\n\t\t\t\t\t// Now we do want to log the command again, so we can see what was inside\n\t\t\t\t\twasMessageLogged = false;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (!wasMessageLogged) {\n\t\t\t\ttry {\n\t\t\t\t\tthis.driverLog.logMessage(msg, {\n\t\t\t\t\t\tdirection: \"inbound\",\n\t\t\t\t\t});\n\t\t\t\t} catch (e) {\n\t\t\t\t\t// We shouldn't throw just because logging a message fails\n\t\t\t\t\tthis.driverLog.print(\n\t\t\t\t\t\t`Logging a message failed: ${getErrorMessage(e)}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Check if this message is unsolicited by passing it to the Serial API command interpreter if possible\n\t\t\tif (\n\t\t\t\tthis.serialAPIInterpreter?.status === InterpreterStatus.Running\n\t\t\t) {\n\t\t\t\tthis.serialAPIInterpreter.send({\n\t\t\t\t\ttype: \"message\",\n\t\t\t\t\tmessage: msg,\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tvoid this.handleUnsolicitedMessage(msg);\n\t\t\t}\n\t\t}\n\t}\n\n\t/** Handles a decoding error and returns the desired reply to the stick */\n\tprivate handleDecodeError(\n\t\te: Error,\n\t\tdata: Uint8Array,\n\t\tmsg: Message | undefined,\n\t): MessageHeaders | undefined {\n\t\tif (isZWaveError(e)) {\n\t\t\tswitch (e.code) {\n\t\t\t\tcase ZWaveErrorCodes.PacketFormat_Invalid:\n\t\t\t\tcase ZWaveErrorCodes.PacketFormat_Checksum:\n\t\t\t\tcase ZWaveErrorCodes.PacketFormat_Truncated:\n\t\t\t\t\tthis.driverLog.print(\n\t\t\t\t\t\t`Dropping message because it contains invalid data`,\n\t\t\t\t\t\t\"warn\",\n\t\t\t\t\t);\n\t\t\t\t\treturn MessageHeaders.NAK;\n\n\t\t\t\tcase ZWaveErrorCodes.Deserialization_NotImplemented:\n\t\t\t\tcase ZWaveErrorCodes.CC_NotImplemented:\n\t\t\t\t\tthis.driverLog.print(\n\t\t\t\t\t\t`Dropping message because it could not be deserialized: ${e.message}`,\n\t\t\t\t\t\t\"warn\",\n\t\t\t\t\t);\n\t\t\t\t\treturn MessageHeaders.ACK;\n\n\t\t\t\tcase ZWaveErrorCodes.Driver_NotReady:\n\t\t\t\t\tthis.driverLog.print(\n\t\t\t\t\t\t`Dropping message because the driver is not ready to handle it yet.`,\n\t\t\t\t\t\t\"warn\",\n\t\t\t\t\t);\n\t\t\t\t\treturn MessageHeaders.ACK;\n\n\t\t\t\tcase ZWaveErrorCodes.PacketFormat_InvalidPayload:\n\t\t\t\t\tif (msg) {\n\t\t\t\t\t\tthis.driverLog.print(\n\t\t\t\t\t\t\t`Dropping message with invalid payload`,\n\t\t\t\t\t\t\t\"warn\",\n\t\t\t\t\t\t);\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tthis.driverLog.logMessage(msg, {\n\t\t\t\t\t\t\t\tdirection: \"inbound\",\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t} catch (e) {\n\t\t\t\t\t\t\t// We shouldn't throw just because logging a message fails\n\t\t\t\t\t\t\tthis.driverLog.print(\n\t\t\t\t\t\t\t\t`Logging a message failed: ${\n\t\t\t\t\t\t\t\t\tgetErrorMessage(\n\t\t\t\t\t\t\t\t\t\te,\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t}`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.driverLog.print(\n\t\t\t\t\t\t\t`Dropping message with invalid payload${\n\t\t\t\t\t\t\t\ttypeof e.context === \"string\"\n\t\t\t\t\t\t\t\t\t? ` (Reason: ${e.context})`\n\t\t\t\t\t\t\t\t\t: \"\"\n\t\t\t\t\t\t\t}:\\n${buffer2hex(data)}`,\n\t\t\t\t\t\t\t\"warn\",\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\treturn MessageHeaders.ACK;\n\n\t\t\t\tcase ZWaveErrorCodes.Driver_NoSecurity:\n\t\t\t\tcase ZWaveErrorCodes.Security2CC_NotInitialized:\n\t\t\t\t\tthis.driverLog.print(\n\t\t\t\t\t\t`Dropping message because network keys are not set or the driver is not yet ready to receive secure messages.`,\n\t\t\t\t\t\t\"warn\",\n\t\t\t\t\t);\n\t\t\t\t\treturn MessageHeaders.ACK;\n\n\t\t\t\tcase ZWaveErrorCodes.Controller_NodeNotFound:\n\t\t\t\t\tthis.driverLog.print(\n\t\t\t\t\t\t`Dropping message because ${\n\t\t\t\t\t\t\ttypeof e.context === \"number\"\n\t\t\t\t\t\t\t\t? `node ${e.context}`\n\t\t\t\t\t\t\t\t: \"the node\"\n\t\t\t\t\t\t} does not exist.`,\n\t\t\t\t\t\t\"warn\",\n\t\t\t\t\t);\n\t\t\t\t\treturn MessageHeaders.ACK;\n\t\t\t}\n\t\t} else {\n\t\t\tif (/database is not open/.test(e.message)) {\n\t\t\t\t// The JSONL-DB is not open yet\n\t\t\t\tthis.driverLog.print(\n\t\t\t\t\t`Dropping message because the driver is not ready to handle it yet.`,\n\t\t\t\t\t\"warn\",\n\t\t\t\t);\n\t\t\t\treturn MessageHeaders.ACK;\n\t\t\t}\n\t\t}\n\t\t// Pass all other errors through\n\t\tthrow e;\n\t}\n\n\tprivate mustReplyWithSecurityS2MOS(\n\t\tmsg: ContainsCC & CommandRequest,\n\t): boolean {\n\t\t// We're looking for a singlecast S2-encapsulated request\n\t\tif (msg.frameType !== \"singlecast\") return false;\n\t\tconst encapS2 = msg.command.getEncapsulatingCC(\n\t\t\tCommandClasses[\"Security 2\"],\n\t\t\tSecurity2Command.MessageEncapsulation,\n\t\t) as Security2CCMessageEncapsulation | undefined;\n\t\tif (!encapS2) return false;\n\n\t\t// With the MGRP extension present\n\t\tconst node = this.tryGetNode(msg);\n\t\tif (!node) return false;\n\t\tconst groupId = encapS2.getMulticastGroupId();\n\t\tif (groupId == undefined) return false;\n\t\tconst securityManager = this.getSecurityManager2(node.id);\n\t\tif (\n\t\t\t// but where we don't have an MPAN stored\n\t\t\tsecurityManager?.getPeerMPAN(\n\t\t\t\tmsg.command.nodeId as number,\n\t\t\t\tgroupId,\n\t\t\t).type !== MPANState.MPAN\n\t\t) {\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\tprivate async handleSecurityS2DecodeError(\n\t\te: Error,\n\t\tmsg: Message | undefined,\n\t): Promise<boolean> {\n\t\tif (!isZWaveError(e)) return false;\n\t\tif (\n\t\t\t(e.code === ZWaveErrorCodes.Security2CC_NoSPAN\n\t\t\t\t|| e.code === ZWaveErrorCodes.Security2CC_CannotDecode)\n\t\t\t&& containsCC(msg)\n\t\t) {\n\t\t\t// Decoding the command failed because no SPAN has been established with the other node\n\t\t\tconst nodeId = msg.getNodeId()!;\n\t\t\t// If the node isn't known, ignore this error\n\t\t\tconst node = this._controller?.nodes.get(nodeId);\n\t\t\tif (!node) return false;\n\n\t\t\t// Before we can send anything, ACK the command\n\t\t\tawait this.writeHeader(MessageHeaders.ACK);\n\n\t\t\tthis.driverLog.logMessage(msg, { direction: \"inbound\" });\n\t\t\tnode.incrementStatistics(\"commandsDroppedRX\");\n\n\t\t\t// We might receive this before the node has been interviewed. If that case, we need to mark Security S2 as\n\t\t\t// supported or we won't ever be able to communicate with the node\n\t\t\tif (node.interviewStage < InterviewStage.NodeInfo) {\n\t\t\t\tnode.addCC(CommandClasses[\"Security 2\"], {\n\t\t\t\t\tisSupported: true,\n\t\t\t\t\tversion: 1,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\t// Ensure that we're not flooding the queue with unnecessary NonceReports\n\t\t\tconst isS2NonceReport = (t: Transaction) =>\n\t\t\t\tt.message.getNodeId() === nodeId\n\t\t\t\t&& containsCC(t.message)\n\t\t\t\t&& t.message.command instanceof Security2CCNonceReport;\n\n\t\t\tconst message: string =\n\t\t\t\te.code === ZWaveErrorCodes.Security2CC_CannotDecode\n\t\t\t\t\t? \"Message authentication failed\"\n\t\t\t\t\t: \"No SPAN is established yet\";\n\n\t\t\tif (this.controller.bootstrappingS2NodeId === nodeId) {\n\t\t\t\t// The node is currently being bootstrapped.\n\t\t\t\tconst securityManager = this.getSecurityManager2(nodeId);\n\t\t\t\tif (securityManager?.tempKeys.has(nodeId)) {\n\t\t\t\t\t// The DSK has been verified, so we should be able to decode this command.\n\t\t\t\t\t// If this is the first attempt, we need to request a nonce first\n\t\t\t\t\tif (\n\t\t\t\t\t\tsecurityManager.getSPANState(nodeId).type\n\t\t\t\t\t\t\t=== SPANState.None\n\t\t\t\t\t) {\n\t\t\t\t\t\tthis.controllerLog.logNode(nodeId, {\n\t\t\t\t\t\t\tmessage:\n\t\t\t\t\t\t\t\t`${message}, cannot decode command. Requesting a nonce...`,\n\t\t\t\t\t\t\tlevel: \"verbose\",\n\t\t\t\t\t\t\tdirection: \"outbound\",\n\t\t\t\t\t\t});\n\t\t\t\t\t\t// Send the node our nonce\n\t\t\t\t\t\tnode.commandClasses[\"Security 2\"]\n\t\t\t\t\t\t\t.sendNonce()\n\t\t\t\t\t\t\t.catch(() => {\n\t\t\t\t\t\t\t\t// Ignore errors\n\t\t\t\t\t\t\t});\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// Us repeatedly not being able to decode the command means we need to abort the bootstrapping process\n\t\t\t\t\t\t// because the PIN is wrong\n\t\t\t\t\t\tthis.controllerLog.logNode(nodeId, {\n\t\t\t\t\t\t\tmessage:\n\t\t\t\t\t\t\t\t`${message}, cannot decode command. Aborting the S2 bootstrapping process...`,\n\t\t\t\t\t\t\tlevel: \"error\",\n\t\t\t\t\t\t\tdirection: \"inbound\",\n\t\t\t\t\t\t});\n\t\t\t\t\t\tthis.controller.cancelSecureBootstrapS2(\n\t\t\t\t\t\t\tKEXFailType.BootstrappingCanceled,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tthis.controllerLog.logNode(nodeId, {\n\t\t\t\t\t\tmessage:\n\t\t\t\t\t\t\t`Ignoring KEXSet because the DSK has not been verified yet`,\n\t\t\t\t\t\tlevel: \"verbose\",\n\t\t\t\t\t\tdirection: \"inbound\",\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t} else if (!this.hasPendingTransactions(isS2NonceReport)) {\n\t\t\t\tthis.controllerLog.logNode(nodeId, {\n\t\t\t\t\tmessage:\n\t\t\t\t\t\t`${message}, cannot decode command. Requesting a nonce...`,\n\t\t\t\t\tlevel: \"verbose\",\n\t\t\t\t\tdirection: \"outbound\",\n\t\t\t\t});\n\t\t\t\t// Send the node our nonce, and use the chance to re-sync the MPAN if necessary\n\t\t\t\tconst s2MulticastOutOfSync = isCommandRequest(msg)\n\t\t\t\t\t&& this.mustReplyWithSecurityS2MOS(msg);\n\n\t\t\t\tnode.commandClasses[\"Security 2\"]\n\t\t\t\t\t.withOptions({ s2MulticastOutOfSync })\n\t\t\t\t\t.sendNonce()\n\t\t\t\t\t.catch(() => {\n\t\t\t\t\t\t// Ignore errors\n\t\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tthis.controllerLog.logNode(nodeId, {\n\t\t\t\t\tmessage: `${message}, cannot decode command.`,\n\t\t\t\t\tlevel: \"verbose\",\n\t\t\t\t\tdirection: \"none\",\n\t\t\t\t});\n\t\t\t}\n\n\t\t\treturn true;\n\t\t} else if (\n\t\t\t(e.code === ZWaveErrorCodes.Security2CC_NoMPAN\n\t\t\t\t|| e.code === ZWaveErrorCodes.Security2CC_CannotDecodeMulticast)\n\t\t\t&& containsCC(msg)\n\t\t) {\n\t\t\t// Decoding the command failed because the MPAN used by the other node\n\t\t\t// is not known to us yet\n\t\t\tconst nodeId = msg.getNodeId()!;\n\t\t\t// If the node isn't known, ignore this error\n\t\t\tconst node = this._controller?.nodes.get(nodeId);\n\t\t\tif (!node) return false;\n\n\t\t\t// Before we can send anything, ACK the command\n\t\t\tawait this.writeHeader(MessageHeaders.ACK);\n\n\t\t\tthis.driverLog.logMessage(msg, { direction: \"inbound\" });\n\t\t\tnode.incrementStatistics(\"commandsDroppedRX\");\n\n\t\t\tthis.controllerLog.logNode(nodeId, {\n\t\t\t\tmessage:\n\t\t\t\t\t`Cannot decode S2 multicast command, since MPAN is not known yet. Will attempt re-sync after the next singlecast.`,\n\t\t\t\tlevel: \"verbose\",\n\t\t\t});\n\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\t/** Checks if a transaction failed because a node didn't respond in time */\n\tprivate isMissingNodeACK(\n\t\ttransaction: Transaction,\n\t\te: ZWaveError,\n\t): transaction is Transaction & {\n\t\tmessage: SendDataRequest | SendDataBridgeRequest;\n\t} {\n\t\treturn (\n\t\t\t// If the node does not acknowledge our request, it is either asleep or dead\n\t\t\te.code === ZWaveErrorCodes.Controller_CallbackNOK\n\t\t\t&& (transaction.message instanceof SendDataRequest\n\t\t\t\t|| transaction.message instanceof SendDataBridgeRequest)\n\t\t);\n\t}\n\n\t/**\n\t * @internal\n\t * Handles the case that a node failed to respond in time.\n\t * Returns `true` if the transaction failure was handled, `false` if it needs to be rejected.\n\t */\n\tpublic handleMissingNodeACK(\n\t\ttransaction: Transaction & {\n\t\t\tmessage: HasNodeId;\n\t\t},\n\t\terror: ZWaveError,\n\t): boolean {\n\t\tconst node = this.tryGetNode(transaction.message);\n\t\tif (!node) return false; // This should never happen, but whatever\n\n\t\tconst messagePart1 = isSendData(transaction.message)\n\t\t\t? `The node did not respond after ${transaction.message.maxSendAttempts} attempts`\n\t\t\t: `The node did not respond`;\n\n\t\tif (!transaction.changeNodeStatusOnTimeout) {\n\t\t\t// The sender of this transaction doesn't want it to change the status of the node\n\t\t\treturn false;\n\t\t} else if (node.canSleep) {\n\t\t\tif (node.status === NodeStatus.Asleep) {\n\t\t\t\t// We already moved the messages to the wakeup queue before. If we end up here, this means a command\n\t\t\t\t// was sent that may be sent to potentially asleep nodes - including pings.\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tthis.controllerLog.logNode(\n\t\t\t\tnode.id,\n\t\t\t\t`${messagePart1}. It is probably asleep, moving its messages to the wakeup queue.`,\n\t\t\t\t\"warn\",\n\t\t\t);\n\n\t\t\t// There is no longer a reference to the current transaction. If it should be moved to the wakeup queue,\n\t\t\t// it temporarily needs to be added to the queue again.\n\t\t\tconst handled = this.mayMoveToWakeupQueue(transaction);\n\t\t\tif (handled) {\n\t\t\t\tthis.queue.add(transaction);\n\t\t\t}\n\n\t\t\t// Mark the node as asleep. This will move the messages to the wakeup queue\n\t\t\tnode.markAsAsleep();\n\n\t\t\treturn handled;\n\t\t} else {\n\t\t\tconst errorMsg = `${messagePart1}, it is presumed dead`;\n\t\t\tthis.controllerLog.logNode(node.id, errorMsg, \"warn\");\n\n\t\t\tnode.markAsDead();\n\n\t\t\t// There is no longer a reference to the current transaction on the queue, so we need to reject it separately.\n\t\t\ttransaction.setProgress({\n\t\t\t\tstate: TransactionState.Failed,\n\t\t\t\treason: errorMsg,\n\t\t\t});\n\n\t\t\ttransaction.abort(error);\n\t\t\tthis.rejectAllTransactionsForNode(node.id, errorMsg);\n\n\t\t\treturn true;\n\t\t}\n\t}\n\n\t/**\n\t * @internal\n\t * Handles the case that the controller didn't acknowledge a command in time\n\t * Returns `true` if the transaction failure was handled, `false` if it needs to be rejected.\n\t */\n\tprivate handleMissingControllerACK(\n\t\ttransaction: Transaction,\n\t\terror: ZWaveError & {\n\t\t\tcode: ZWaveErrorCodes.Controller_Timeout;\n\t\t\tcontext: \"ACK\";\n\t\t},\n\t): boolean {\n\t\tif (!this._controller || !this.mayRecoverUnresponsiveController()) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst recoverByReopeningSerialport = async () => {\n\t\t\tif (!this.serial) return;\n\t\t\tthis.driverLog.print(\n\t\t\t\t\"Attempting to recover unresponsive controller by reopening the serial port...\",\n\t\t\t\t\"warn\",\n\t\t\t);\n\t\t\tif (this.serial.isOpen) await this.serial.close();\n\t\t\tawait wait(1000);\n\t\t\tawait this.openSerialport();\n\n\t\t\tthis.driverLog.print(\n\t\t\t\t\"Serial port reopened. Returning to normal operation and hoping for the best...\",\n\t\t\t\t\"warn\",\n\t\t\t);\n\n\t\t\t// We don't know if this worked\n\t\t\t// Go back to normal operation and hope for the best.\n\t\t\tthis._controller?.setStatus(ControllerStatus.Ready);\n\t\t\tthis._recoveryPhase = ControllerRecoveryPhase.None;\n\t\t};\n\n\t\tif (\n\t\t\t(this._controller.status !== ControllerStatus.Unresponsive\n\t\t\t\t&& !this.maySoftReset())\n\t\t\t|| this._recoveryPhase\n\t\t\t\t=== ControllerRecoveryPhase.ACKTimeoutAfterReset\n\t\t) {\n\t\t\t// Either we can/could not do a soft reset or the controller is still timing out afterwards\n\t\t\tvoid recoverByReopeningSerialport().catch(noop);\n\n\t\t\treturn true;\n\t\t} else if (this._controller.status !== ControllerStatus.Unresponsive) {\n\t\t\t// The controller was responsive before this transaction failed.\n\t\t\t// Mark it as unresponsive and try to soft-reset it.\n\t\t\tthis.controller.setStatus(\n\t\t\t\tControllerStatus.Unresponsive,\n\t\t\t);\n\n\t\t\tthis._recoveryPhase = ControllerRecoveryPhase.ACKTimeout;\n\n\t\t\tthis.driverLog.print(\n\t\t\t\t\"Attempting to recover unresponsive controller by restarting it...\",\n\t\t\t\t\"warn\",\n\t\t\t);\n\n\t\t\t// Execute the soft-reset asynchronously\n\t\t\tvoid this.softReset().then(() => {\n\t\t\t\t// The controller responded. It is no longer unresponsive\n\n\t\t\t\t// Re-queue the transaction, so it can get handled next.\n\t\t\t\t// Its message generator may have finished, so reset that too.\n\t\t\t\ttransaction.reset();\n\t\t\t\tthis.getQueueForTransaction(transaction).add(\n\t\t\t\t\ttransaction.clone(),\n\t\t\t\t);\n\n\t\t\t\tthis._controller?.setStatus(ControllerStatus.Ready);\n\t\t\t\tthis._recoveryPhase = ControllerRecoveryPhase.None;\n\t\t\t}).catch(() => {\n\t\t\t\t// Soft-reset failed. Reject the transaction\n\t\t\t\tthis.rejectTransaction(transaction, error);\n\n\t\t\t\t// and reopen the serial port\n\t\t\t\treturn recoverByReopeningSerialport();\n\t\t\t});\n\n\t\t\treturn true;\n\t\t} else {\n\t\t\t// Not sure what to do here\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t/**\n\t * @internal\n\t * Handles the case that the controller didn't send the callback for a SendData in time\n\t * Returns `true` if the transaction failure was handled, `false` if it needs to be rejected.\n\t */\n\tprivate handleMissingSendDataResponseOrCallback(\n\t\ttransaction: Transaction,\n\t\terror: ZWaveError & {\n\t\t\tcode: ZWaveErrorCodes.Controller_Timeout;\n\t\t\tcontext: \"callback\" | \"response\";\n\t\t},\n\t): boolean {\n\t\tif (!this._controller || !this.mayRecoverUnresponsiveController()) {\n\t\t\treturn false;\n\t\t}\n\n\t\tif (\n\t\t\t// The SendData response can time out on older controllers trying to reach a dead node.\n\t\t\t// In this case, we do not want to reset the controller, but just mark the node as dead.\n\t\t\terror.context === \"response\"\n\t\t\t// Also do this if the callback is timing out even after restarting the controller\n\t\t\t|| this._recoveryPhase\n\t\t\t\t=== ControllerRecoveryPhase.CallbackTimeoutAfterReset\n\t\t) {\n\t\t\tconst node = this.tryGetNode(transaction.message);\n\t\t\tif (!node) return false; // This should never happen, but whatever\n\n\t\t\t// The controller is still timing out transmitting after a soft reset, don't try again.\n\t\t\t// Real-world experience has shown that for older controllers this situation can be caused by unresponsive nodes.\n\n\t\t\t// The following is essentially a copy of handleMissingNodeACK, but with updated error messages\n\t\t\tconst messagePart1 =\n\t\t\t\t\"The node is causing the controller to become unresponsive\";\n\n\t\t\tlet handled: boolean;\n\n\t\t\tif (node.canSleep) {\n\t\t\t\tif (node.status === NodeStatus.Asleep) {\n\t\t\t\t\t// We already moved the messages to the wakeup queue before. If we end up here, this means a command\n\t\t\t\t\t// was sent that may be sent to potentially asleep nodes - including pings.\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tthis.controllerLog.logNode(\n\t\t\t\t\tnode.id,\n\t\t\t\t\t`${messagePart1}. It is probably asleep, moving its messages to the wakeup queue.`,\n\t\t\t\t\t\"warn\",\n\t\t\t\t);\n\n\t\t\t\t// There is no longer a reference to the current transaction. If it should be moved to the wakeup queue,\n\t\t\t\t// it temporarily needs to be added to the queue again.\n\t\t\t\thandled = this.mayMoveToWakeupQueue(transaction);\n\t\t\t\tif (handled) {\n\t\t\t\t\tthis.queue.add(transaction);\n\t\t\t\t}\n\n\t\t\t\t// Mark the node as asleep. This will move the messages to the wakeup queue\n\t\t\t\tnode.markAsAsleep();\n\t\t\t} else {\n\t\t\t\tconst errorMsg = `${messagePart1}, it is presumed dead`;\n\t\t\t\tthis.controllerLog.logNode(node.id, errorMsg, \"warn\");\n\n\t\t\t\tnode.markAsDead();\n\n\t\t\t\t// There is no longer a reference to the current transaction on the queue, so we need to reject it separately.\n\t\t\t\ttransaction.setProgress({\n\t\t\t\t\tstate: TransactionState.Failed,\n\t\t\t\t\treason: errorMsg,\n\t\t\t\t});\n\n\t\t\t\ttransaction.abort(error);\n\t\t\t\tthis.rejectAllTransactionsForNode(node.id, errorMsg);\n\n\t\t\t\thandled = true;\n\t\t\t}\n\n\t\t\t// If the controller is still timing out, reset it once more\n\t\t\tif (\n\t\t\t\tthis._recoveryPhase\n\t\t\t\t\t=== ControllerRecoveryPhase.CallbackTimeoutAfterReset\n\t\t\t) {\n\t\t\t\tthis.driverLog.print(\n\t\t\t\t\t\"Attempting to recover controller again...\",\n\t\t\t\t\t\"warn\",\n\t\t\t\t);\n\t\t\t\tvoid this.softResetInternal(true).catch(() => {\n\t\t\t\t\tthis.driverLog.print(\n\t\t\t\t\t\t\"Automatic controller recovery failed. Returning to normal operation and hoping for the best.\",\n\t\t\t\t\t\t\"warn\",\n\t\t\t\t\t);\n\t\t\t\t}).finally(() => {\n\t\t\t\t\tthis._recoveryPhase = ControllerRecoveryPhase.None;\n\t\t\t\t\tthis._controller?.setStatus(ControllerStatus.Ready);\n\t\t\t\t});\n\t\t\t}\n\n\t\t\treturn handled;\n\t\t} else if (this._controller.status !== ControllerStatus.Unresponsive) {\n\t\t\t// The controller was responsive before this transaction failed.\n\n\t\t\tif (this.maySoftReset()) {\n\t\t\t\t// Mark it as unresponsive and try to soft-reset it.\n\t\t\t\tthis.controller.setStatus(\n\t\t\t\t\tControllerStatus.Unresponsive,\n\t\t\t\t);\n\n\t\t\t\tthis._recoveryPhase = ControllerRecoveryPhase.CallbackTimeout;\n\n\t\t\t\tthis.driverLog.print(\n\t\t\t\t\t\"Controller missed Send Data callback. Attempting to recover...\",\n\t\t\t\t\t\"warn\",\n\t\t\t\t);\n\n\t\t\t\t// Execute the soft-reset asynchronously\n\t\t\t\tvoid this.softResetInternal(true).then(() => {\n\t\t\t\t\t// The controller responded. It is no longer unresponsive.\n\n\t\t\t\t\t// Re-queue the transaction, so it can get handled next.\n\t\t\t\t\t// Its message generator may have finished, so reset that too.\n\t\t\t\t\ttransaction.reset();\n\t\t\t\t\tthis.getQueueForTransaction(transaction).add(\n\t\t\t\t\t\ttransaction.clone(),\n\t\t\t\t\t);\n\n\t\t\t\t\tthis._controller?.setStatus(ControllerStatus.Ready);\n\t\t\t\t\tthis._recoveryPhase =\n\t\t\t\t\t\tControllerRecoveryPhase.CallbackTimeoutAfterReset;\n\t\t\t\t}).catch(() => {\n\t\t\t\t\t// Soft-reset failed. Just reject the transaction\n\t\t\t\t\tthis.rejectTransaction(transaction, error);\n\n\t\t\t\t\tthis.driverLog.print(\n\t\t\t\t\t\t\"Automatic controller recovery failed. Returning to normal operation and hoping for the best.\",\n\t\t\t\t\t\t\"warn\",\n\t\t\t\t\t);\n\t\t\t\t\tthis._recoveryPhase = ControllerRecoveryPhase.None;\n\t\t\t\t\tthis._controller?.setStatus(ControllerStatus.Ready);\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tthis.driverLog.print(\n\t\t\t\t\t\"Controller missed Send Data callback. Cannot recover automatically because the soft reset feature is unsupported or disabled. Returning to normal operation and hoping for the best...\",\n\t\t\t\t\t\"warn\",\n\t\t\t\t);\n\t\t\t\tthis.rejectTransaction(transaction, error);\n\t\t\t}\n\n\t\t\treturn true;\n\t\t} else {\n\t\t\t// Not sure what to do here\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t/**\n\t * @internal\n\t * Handles the case that the controller locks up and fails to transmit continuously\n\t */\n\tprivate handleJammedController(\n\t\ttransaction: Transaction,\n\t\terror: ZWaveError,\n\t): boolean {\n\t\tif (!this._controller || !this.mayRecoverUnresponsiveController()) {\n\t\t\treturn false;\n\t\t}\n\n\t\tif (\n\t\t\t// Transmits still fail even after restarting the controller\n\t\t\tthis._recoveryPhase\n\t\t\t\t=== ControllerRecoveryPhase.JammedAfterReset\n\t\t) {\n\t\t\t// Maybe this isn't actually the controller being jammed. Give up on this command.\n\t\t\tthis.driverLog.print(\n\t\t\t\t\"Automatic controller recovery failed. Returning to normal operation and hoping for the best.\",\n\t\t\t\t\"warn\",\n\t\t\t);\n\t\t\tthis._recoveryPhase = ControllerRecoveryPhase.None;\n\t\t\tthis._controller.setStatus(ControllerStatus.Ready);\n\n\t\t\treturn false;\n\t\t} else if (this._controller.status === ControllerStatus.Jammed) {\n\t\t\t// The controller failed to transmit continuously. Try to soft-reset it if we can.\n\t\t\tif (this.controller.sdkVersionLt(\"7.0\")) {\n\t\t\t\t// The workaround only makes sense on 700/800 series\n\t\t\t\tthis.driverLog.print(\n\t\t\t\t\t\"Cannot recover jammed controller automatically. Returning to normal operation and hoping for the best...\",\n\t\t\t\t\t\"warn\",\n\t\t\t\t);\n\t\t\t\tthis._controller?.setStatus(ControllerStatus.Ready);\n\t\t\t\tthis.rejectTransaction(transaction, error);\n\t\t\t} else if (this.maySoftReset()) {\n\t\t\t\tthis._recoveryPhase = ControllerRecoveryPhase.Jammed;\n\n\t\t\t\tthis.driverLog.print(\n\t\t\t\t\t\"Attempting to recover jammed controller...\",\n\t\t\t\t\t\"warn\",\n\t\t\t\t);\n\n\t\t\t\t// Execute the soft-reset asynchronously\n\t\t\t\tvoid this.softReset().then(() => {\n\t\t\t\t\t// The controller responded. It is no longer unresponsive.\n\n\t\t\t\t\t// Re-queue the transaction, so it can get handled next.\n\t\t\t\t\t// Its message generator may have finished, so reset that too.\n\t\t\t\t\ttransaction.reset();\n\t\t\t\t\tthis.getQueueForTransaction(transaction).add(\n\t\t\t\t\t\ttransaction.clone(),\n\t\t\t\t\t);\n\n\t\t\t\t\tthis._recoveryPhase =\n\t\t\t\t\t\tControllerRecoveryPhase.JammedAfterReset;\n\t\t\t\t}).catch(() => {\n\t\t\t\t\t// Soft-reset failed. Just reject the transaction\n\t\t\t\t\tthis.rejectTransaction(transaction, error);\n\n\t\t\t\t\tthis.driverLog.print(\n\t\t\t\t\t\t\"Automatic controller recovery failed. Returning to normal operation and hoping for the best.\",\n\t\t\t\t\t\t\"warn\",\n\t\t\t\t\t);\n\t\t\t\t\tthis._recoveryPhase = ControllerRecoveryPhase.None;\n\t\t\t\t\tthis._controller?.setStatus(ControllerStatus.Ready);\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tthis.driverLog.print(\n\t\t\t\t\t\"Cannot recover jammed controller automatically because the soft reset feature is unsupported or disabled. Returning to normal operation and hoping for the best...\",\n\t\t\t\t\t\"warn\",\n\t\t\t\t);\n\t\t\t\tthis._controller?.setStatus(ControllerStatus.Ready);\n\t\t\t\tthis.rejectTransaction(transaction, error);\n\t\t\t}\n\n\t\t\treturn true;\n\t\t} else {\n\t\t\t// Not sure what to do here\n\t\t\treturn false;\n\t\t}\n\t}\n\n\tprivate shouldRequestWakeupOnDemand(node: ZWaveNode): boolean {\n\t\treturn (\n\t\t\t!!node.supportsWakeUpOnDemand\n\t\t\t&& node.status === NodeStatus.Asleep\n\t\t\t&& this.hasPendingTransactions(\n\t\t\t\t(t) =>\n\t\t\t\t\tt.requestWakeUpOnDemand\n\t\t\t\t\t&& t.message.getNodeId() === node.id,\n\t\t\t)\n\t\t);\n\t}\n\n\tprivate partialCCSessions = new Map<string, CommandClass[]>();\n\tprivate getPartialCCSession(\n\t\tcommand: CommandClass,\n\t\tcreateIfMissing: false,\n\t): { partialSessionKey: string; session?: CommandClass[] } | undefined;\n\tprivate getPartialCCSession(\n\t\tcommand: CommandClass,\n\t\tcreateIfMissing: true,\n\t): { partialSessionKey: string; session: CommandClass[] } | undefined;\n\tprivate getPartialCCSession(\n\t\tcommand: CommandClass,\n\t\tcreateIfMissing: boolean,\n\t): { partialSessionKey: string; session?: CommandClass[] } | undefined {\n\t\tconst sessionId = command.getPartialCCSessionId();\n\n\t\tif (sessionId) {\n\t\t\t// This CC belongs to a partial session\n\t\t\tconst partialSessionKey = JSON.stringify({\n\t\t\t\tnodeId: command.nodeId,\n\t\t\t\tccId: command.ccId,\n\t\t\t\tccCommand: command.ccCommand!,\n\t\t\t\t...sessionId,\n\t\t\t});\n\t\t\tif (\n\t\t\t\tcreateIfMissing\n\t\t\t\t&& !this.partialCCSessions.has(partialSessionKey)\n\t\t\t) {\n\t\t\t\tthis.partialCCSessions.set(partialSessionKey, []);\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tpartialSessionKey,\n\t\t\t\tsession: this.partialCCSessions.get(partialSessionKey),\n\t\t\t};\n\t\t}\n\t}\n\t/**\n\t * Assembles partial CCs of in a message body. Returns `true` when the message is complete and can be handled further.\n\t * If the message expects another partial one, this returns `false`.\n\t */\n\tprivate async assemblePartialCCs(\n\t\tmsg: CommandRequest & ContainsCC,\n\t): Promise<boolean> {\n\t\tlet command: CommandClass | undefined = msg.command;\n\t\t// We search for the every CC that provides us with a session ID\n\t\t// There might be newly-completed CCs that contain a partial CC,\n\t\t// so investigate the entire CC encapsulation stack.\n\t\twhile (true) {\n\t\t\tconst { partialSessionKey, session } =\n\t\t\t\tthis.getPartialCCSession(command, true) ?? {};\n\t\t\tif (session) {\n\t\t\t\t// This CC belongs to a partial session\n\t\t\t\tif (command.expectMoreMessages(session)) {\n\t\t\t\t\t// this is not the final one, store it\n\t\t\t\t\tsession.push(command);\n\t\t\t\t\tif (!isTransportServiceEncapsulation(msg.command)) {\n\t\t\t\t\t\t// and don't handle the command now\n\t\t\t\t\t\tthis.driverLog.logMessage(msg, {\n\t\t\t\t\t\t\tsecondaryTags: [\"partial\"],\n\t\t\t\t\t\t\tdirection: \"inbound\",\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\treturn false;\n\t\t\t\t} else {\n\t\t\t\t\t// this is the final one, merge the previous responses\n\t\t\t\t\tthis.partialCCSessions.delete(partialSessionKey!);\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait command.mergePartialCCsAsync(session, {\n\t\t\t\t\t\t\t...this.getCCParsingContext(),\n\t\t\t\t\t\t\tsourceNodeId: msg.command.nodeId as number,\n\t\t\t\t\t\t\tframeType: msg.frameType,\n\t\t\t\t\t\t});\n\t\t\t\t\t\t// Ensure there are no errors\n\t\t\t\t\t\tassertValidCCs(msg);\n\t\t\t\t\t} catch (e) {\n\t\t\t\t\t\tif (isZWaveError(e)) {\n\t\t\t\t\t\t\tswitch (e.code) {\n\t\t\t\t\t\t\t\tcase ZWaveErrorCodes\n\t\t\t\t\t\t\t\t\t.Deserialization_NotImplemented:\n\t\t\t\t\t\t\t\tcase ZWaveErrorCodes.CC_NotImplemented:\n\t\t\t\t\t\t\t\t\tthis.driverLog.print(\n\t\t\t\t\t\t\t\t\t\t`Dropping message because it could not be deserialized: ${e.message}`,\n\t\t\t\t\t\t\t\t\t\t\"warn\",\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t// Don't continue handling this message\n\t\t\t\t\t\t\t\t\treturn false;\n\n\t\t\t\t\t\t\t\tcase ZWaveErrorCodes\n\t\t\t\t\t\t\t\t\t.PacketFormat_InvalidPayload:\n\t\t\t\t\t\t\t\t\tthis.driverLog.print(\n\t\t\t\t\t\t\t\t\t\t`Could not assemble partial CCs because the payload is invalid. Dropping them.`,\n\t\t\t\t\t\t\t\t\t\t\"warn\",\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t// Don't continue handling this message\n\t\t\t\t\t\t\t\t\treturn false;\n\n\t\t\t\t\t\t\t\tcase ZWaveErrorCodes.Driver_NotReady:\n\t\t\t\t\t\t\t\t\tthis.driverLog.print(\n\t\t\t\t\t\t\t\t\t\t`Could not assemble partial CCs because the driver is not ready yet. Dropping them`,\n\t\t\t\t\t\t\t\t\t\t\"warn\",\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t// Don't continue handling this message\n\t\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tthrow e;\n\t\t\t\t\t}\n\t\t\t\t\t// Assembling this CC was successful - but it might contain another partial CC\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// No partial CC, just continue\n\t\t\t}\n\n\t\t\t// If this is an encapsulating CC, we need to look one level deeper\n\t\t\tif (isEncapsulatingCommandClass(command)) {\n\t\t\t\tcommand = command.encapsulated;\n\t\t\t} else {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\n\t/** Is called when a Transport Service command is received */\n\tprivate async handleTransportServiceCommand(\n\t\tcommand:\n\t\t\t| TransportServiceCCFirstSegment\n\t\t\t| TransportServiceCCSubsequentSegment,\n\t): Promise<void> {\n\t\tconst nodeSessions = this.ensureNodeSessions(command.nodeId);\n\t\t// If this command belongs to an existing session, just forward it to the state machine\n\t\tconst transportSession = nodeSessions.transportService.get(\n\t\t\tcommand.sessionId,\n\t\t);\n\t\tif (command instanceof TransportServiceCCFirstSegment) {\n\t\t\t// This is the first message in a sequence. Create or re-initialize the session\n\t\t\t// We don't delete finished sessions when the last message is received in order to be able to\n\t\t\t// handle when the SegmentComplete message gets lost. As soon as the node initializes a new session,\n\t\t\t// we do know that the previous one is finished.\n\t\t\tif (transportSession) {\n\t\t\t\ttransportSession.interpreter.stop();\n\t\t\t}\n\t\t\tnodeSessions.transportService.clear();\n\n\t\t\tthis.controllerLog.logNode(command.nodeId, {\n\t\t\t\tmessage:\n\t\t\t\t\t`Beginning Transport Service RX session #${command.sessionId}...`,\n\t\t\t\tlevel: \"debug\",\n\t\t\t\tdirection: \"inbound\",\n\t\t\t});\n\n\t\t\tconst RXStateMachine = createTransportServiceRXMachine(\n\t\t\t\t{\n\t\t\t\t\trequestMissingSegment: async (offset: number) => {\n\t\t\t\t\t\tthis.controllerLog.logNode(command.nodeId, {\n\t\t\t\t\t\t\tmessage:\n\t\t\t\t\t\t\t\t`Transport Service RX session #${command.sessionId}: Segment with offset ${offset} missing - requesting it...`,\n\t\t\t\t\t\t\tlevel: \"debug\",\n\t\t\t\t\t\t\tdirection: \"outbound\",\n\t\t\t\t\t\t});\n\t\t\t\t\t\tconst cc = new TransportServiceCCSegmentRequest({\n\t\t\t\t\t\t\tnodeId: command.nodeId,\n\t\t\t\t\t\t\tsessionId: command.sessionId,\n\t\t\t\t\t\t\tdatagramOffset: offset,\n\t\t\t\t\t\t});\n\t\t\t\t\t\tawait this.sendCommand(cc, {\n\t\t\t\t\t\t\tmaxSendAttempts: 1,\n\t\t\t\t\t\t\tpriority: MessagePriority.Immediate,\n\t\t\t\t\t\t});\n\t\t\t\t\t},\n\t\t\t\t\tsendSegmentsComplete: async () => {\n\t\t\t\t\t\tthis.controllerLog.logNode(command.nodeId, {\n\t\t\t\t\t\t\tmessage:\n\t\t\t\t\t\t\t\t`Transport Service RX session #${command.sessionId} complete`,\n\t\t\t\t\t\t\tlevel: \"debug\",\n\t\t\t\t\t\t\tdirection: \"outbound\",\n\t\t\t\t\t\t});\n\t\t\t\t\t\tconst cc = new TransportServiceCCSegmentComplete({\n\t\t\t\t\t\t\tnodeId: command.nodeId,\n\t\t\t\t\t\t\tsessionId: command.sessionId,\n\t\t\t\t\t\t});\n\t\t\t\t\t\tawait this.sendCommand(cc, {\n\t\t\t\t\t\t\tmaxSendAttempts: 1,\n\t\t\t\t\t\t\tpriority: MessagePriority.Immediate,\n\t\t\t\t\t\t});\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t// TODO: Figure out how to know which timeout is the correct one. For now use the larger one\n\t\t\t\t\tmissingSegmentTimeout:\n\t\t\t\t\t\tTransportServiceTimeouts.requestMissingSegmentR2,\n\t\t\t\t\tdatagramSize: command.datagramSize,\n\t\t\t\t\tfirstSegmentSize: command.partialDatagram.length,\n\t\t\t\t},\n\t\t\t);\n\n\t\t\tconst interpreter = interpret(RXStateMachine).start();\n\t\t\tnodeSessions.transportService.set(command.sessionId, {\n\t\t\t\tfragmentSize: command.partialDatagram.length,\n\t\t\t\tinterpreter,\n\t\t\t});\n\n\t\t\tinterpreter.onTransition((state) => {\n\t\t\t\tif (state.changed && state.value === \"failure\") {\n\t\t\t\t\tthis.controllerLog.logNode(command.nodeId, {\n\t\t\t\t\t\tmessage:\n\t\t\t\t\t\t\t`Transport Service RX session #${command.sessionId} failed`,\n\t\t\t\t\t\tlevel: \"error\",\n\t\t\t\t\t\tdirection: \"none\",\n\t\t\t\t\t});\n\t\t\t\t\t// TODO: Update statistics\n\t\t\t\t\tinterpreter.stop();\n\t\t\t\t\tnodeSessions.transportService.delete(command.sessionId);\n\t\t\t\t}\n\t\t\t});\n\t\t} else {\n\t\t\t// This is a subsequent message in a sequence. Just forward it to the state machine if there is one\n\t\t\tif (transportSession) {\n\t\t\t\ttransportSession.interpreter.send({\n\t\t\t\t\ttype: \"segment\",\n\t\t\t\t\toffset: command.datagramOffset,\n\t\t\t\t\tlength: command.partialDatagram.length,\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\t// This belongs to a session we don't know... tell the sending node to try again\n\t\t\t\tconst cc = new TransportServiceCCSegmentWait({\n\t\t\t\t\tnodeId: command.nodeId,\n\t\t\t\t\tpendingSegments: 0,\n\t\t\t\t});\n\t\t\t\tawait this.sendCommand(cc, {\n\t\t\t\t\tmaxSendAttempts: 1,\n\t\t\t\t\tpriority: MessagePriority.Immediate,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Is called when a message is received that does not belong to any ongoing transactions\n\t * @param msg The decoded message\n\t */\n\tprivate async handleUnsolicitedMessage(msg: Message): Promise<void> {\n\t\tif (msg.type === MessageType.Request) {\n\t\t\t// This is a request we might have registered handlers for\n\t\t\ttry {\n\t\t\t\tawait this.handleRequest(msg);\n\t\t\t} catch (e) {\n\t\t\t\tif (\n\t\t\t\t\tisZWaveError(e)\n\t\t\t\t\t&& e.code === ZWaveErrorCodes.Driver_NotReady\n\t\t\t\t) {\n\t\t\t\t\tthis.driverLog.print(\n\t\t\t\t\t\t`Cannot handle message because the driver is not ready to handle it yet.`,\n\t\t\t\t\t\t\"warn\",\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tthrow e;\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tthis.driverLog.transactionResponse(msg, undefined, \"unexpected\");\n\t\t\tthis.driverLog.print(\"unexpected response, discarding...\", \"warn\");\n\t\t}\n\t}\n\n\t/**\n\t * Is called when the Serial API restart unexpectedly.\n\t */\n\tprivate async handleSerialAPIStartedUnexpectedly(\n\t\tmsg: SerialAPIStartedRequest,\n\t): Promise<boolean> {\n\t\t// Normally, the soft reset command includes waiting for this message.\n\t\t// If we end up here, it is unexpected.\n\n\t\tswitch (msg.wakeUpReason) {\n\t\t\t// All wakeup reasons that indicate a reset of the Serial API\n\t\t\t// need to be handled here, so we interpret node IDs correctly.\n\t\t\tcase SerialAPIWakeUpReason.Reset:\n\t\t\tcase SerialAPIWakeUpReason.WatchdogReset:\n\t\t\tcase SerialAPIWakeUpReason.SoftwareReset:\n\t\t\tcase SerialAPIWakeUpReason.EmergencyWatchdogReset:\n\t\t\tcase SerialAPIWakeUpReason.BrownoutCircuit: {\n\t\t\t\t// The Serial API restarted unexpectedly\n\t\t\t\tthis.controllerLog.print(\n\t\t\t\t\t`Serial API restarted unexpectedly.`,\n\t\t\t\t\t\"warn\",\n\t\t\t\t);\n\n\t\t\t\t// In this situation, we may be executing a Serial API command, which will never complete.\n\t\t\t\t// Bail out of it, without rejecting the actual transaction\n\t\t\t\tif (\n\t\t\t\t\tthis.serialAPIInterpreter?.status\n\t\t\t\t\t\t=== InterpreterStatus.Running\n\t\t\t\t) {\n\t\t\t\t\tthis.serialAPIInterpreter.stop();\n\t\t\t\t}\n\t\t\t\tif (this._currentSerialAPICommandPromise) {\n\t\t\t\t\tthis.controllerLog.print(\n\t\t\t\t\t\t`Currently active command will be retried...`,\n\t\t\t\t\t\t\"warn\",\n\t\t\t\t\t);\n\t\t\t\t\tthis._currentSerialAPICommandPromise.reject(\n\t\t\t\t\t\tnew ZWaveError(\n\t\t\t\t\t\t\t\"The Serial API restarted unexpectedly\",\n\t\t\t\t\t\t\tZWaveErrorCodes.Controller_Reset,\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\t// Restart the watchdog unless disabled\n\t\t\t\tif (this.options.features.watchdog) {\n\t\t\t\t\tawait this._controller?.startWatchdog();\n\t\t\t\t}\n\n\t\t\t\tif (this._controller?.nodeIdType === NodeIDType.Long) {\n\t\t\t\t\t// We previously used 16 bit node IDs, but the controller was reset.\n\t\t\t\t\t// Remember this and try to go back to 16 bit.\n\t\t\t\t\tthis._controller.nodeIdType = NodeIDType.Short;\n\t\t\t\t\tawait this._controller.trySetNodeIDType(NodeIDType.Long);\n\t\t\t\t}\n\n\t\t\t\treturn true; // Don't invoke any more handlers\n\t\t\t}\n\t\t}\n\n\t\treturn false; // Not handled\n\t}\n\n\t/**\n\t * Registers a handler for messages that are not handled by the driver as part of a message exchange.\n\t * The handler function needs to return a boolean indicating if the message has been handled.\n\t * Registered handlers are called in sequence until a handler returns `true`.\n\t *\n\t * @param fnType The function type to register the handler for\n\t * @param handler The request handler callback\n\t * @param oneTime Whether the handler should be removed after its first successful invocation\n\t */\n\tpublic registerRequestHandler<T extends Message>(\n\t\tfnType: FunctionType,\n\t\thandler: RequestHandler<T>,\n\t\toneTime: boolean = false,\n\t): void {\n\t\tconst handlers: RequestHandlerEntry<T>[] = this.requestHandlers.has(\n\t\t\t\tfnType,\n\t\t\t)\n\t\t\t? this.requestHandlers.get(fnType)!\n\t\t\t: [];\n\t\tconst entry: RequestHandlerEntry<T> = { invoke: handler, oneTime };\n\t\thandlers.push(entry);\n\t\tthis.driverLog.print(\n\t\t\t`added${oneTime ? \" one-time\" : \"\"} request handler for ${\n\t\t\t\tFunctionType[fnType]\n\t\t\t} (${num2hex(fnType)})...\n${handlers.length} registered`,\n\t\t);\n\t\tthis.requestHandlers.set(fnType, handlers as RequestHandlerEntry[]);\n\t}\n\n\t/**\n\t * Unregisters a message handler that has been added with `registerRequestHandler`\n\t * @param fnType The function type to unregister the handler for\n\t * @param handler The previously registered request handler callback\n\t */\n\tpublic unregisterRequestHandler(\n\t\tfnType: FunctionType,\n\t\thandler: RequestHandler,\n\t): void {\n\t\tconst handlers = this.requestHandlers.has(fnType)\n\t\t\t? this.requestHandlers.get(fnType)!\n\t\t\t: [];\n\t\tfor (let i = 0, entry = handlers[i]; i < handlers.length; i++) {\n\t\t\t// remove the handler if it was found\n\t\t\tif (entry.invoke === handler) {\n\t\t\t\thandlers.splice(i, 1);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tthis.driverLog.print(\n\t\t\t`removed request handler for ${FunctionType[fnType]} (${fnType})...\n${handlers.length} left`,\n\t\t);\n\t\tthis.requestHandlers.set(fnType, handlers);\n\t}\n\n\t/**\n\t * Checks whether a CC has a lower than expected security level and needs to be discarded\n\t */\n\tprivate isSecurityLevelTooLow(cc: CommandClass): boolean {\n\t\t// With Security S0, some commands may be accepted without encryption, some require it\n\t\t// With Security S2, a node MUST support its command classes only when communication is using its\n\t\t// highest Security Class granted during security bootstrapping.\n\n\t\t// We already discard lower S2 keys when decrypting, so all that's left here to check is if the\n\t\t// CC is encrypted at all.\n\n\t\tconst node = this._controller?.nodes.get(cc.nodeId as number);\n\t\tif (!node) {\n\t\t\t// Node does not exist, don't accept the CC\n\t\t\tthis.controllerLog.logNode(\n\t\t\t\tcc.nodeId as number,\n\t\t\t\t`is unknown - discarding received command...`,\n\t\t\t\t\"warn\",\n\t\t\t);\n\t\t\treturn true;\n\t\t}\n\n\t\t// Transport Service has a special handler\n\t\tif (cc instanceof TransportServiceCC) return false;\n\t\t// CRC16 belongs outside of Security encapsulation\n\t\tif (cc instanceof CRC16CCCommandEncapsulation) {\n\t\t\treturn this.isSecurityLevelTooLow(cc.encapsulated);\n\t\t}\n\n\t\tconst secClass = node.getHighestSecurityClass();\n\t\tif (\n\t\t\tsecClass === SecurityClass.None\n\t\t\t|| secClass === SecurityClass.Temporary\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst expectedSecurityCC = securityClassIsS2(secClass)\n\t\t\t? CommandClasses[\"Security 2\"]\n\t\t\t: secClass === SecurityClass.S0_Legacy\n\t\t\t? CommandClasses.Security\n\t\t\t: undefined;\n\n\t\tconst isCCConsideredSecure = (\n\t\t\tcmd: CommandClass,\n\t\t): MaybeNotKnown<boolean> => {\n\t\t\t// Some CCs are always accepted, regardless of security class\n\t\t\tif (cmd instanceof SecurityCC) {\n\t\t\t\tswitch (cmd.ccCommand) {\n\t\t\t\t\t// Cannot be sent encapsulated:\n\t\t\t\t\tcase SecurityCommand.NonceGet:\n\t\t\t\t\tcase SecurityCommand.NonceReport:\n\t\t\t\t\tcase SecurityCommand.SchemeGet:\n\t\t\t\t\tcase SecurityCommand.SchemeReport:\n\t\t\t\t\t\treturn true;\n\t\t\t\t}\n\n\t\t\t\tif (cmd instanceof SecurityCCCommandEncapsulation) {\n\t\t\t\t\t// CommandsSupportedReport is always accepted to be able to learn security classes and interview nodes\n\t\t\t\t\t// CommandsSupportedGet is always accepted, so others can learn our security classes\n\t\t\t\t\tif (\n\t\t\t\t\t\tcmd.encapsulated\n\t\t\t\t\t\t\tinstanceof SecurityCCCommandsSupportedReport\n\t\t\t\t\t\t|| cmd.encapsulated\n\t\t\t\t\t\t\tinstanceof SecurityCCCommandsSupportedGet\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Other S0 commands are only accepted if S0 is the highest security class\n\t\t\t\t\treturn secClass === SecurityClass.S0_Legacy;\n\t\t\t\t}\n\t\t\t} else if (cmd instanceof Security2CC) {\n\t\t\t\tif (cmd instanceof Security2CCMessageEncapsulation) {\n\t\t\t\t\t// CommandsSupportedReport is always accepted to be able to learn security classes and interview nodes\n\t\t\t\t\tif (\n\t\t\t\t\t\tcmd.encapsulated\n\t\t\t\t\t\t\tinstanceof Security2CCCommandsSupportedReport\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\n\t\t\t\t\t// CommandsSupportedGet is always accepted, so others can learn our security classes\n\t\t\t\t\tif (\n\t\t\t\t\t\tcmd.encapsulated\n\t\t\t\t\t\t\tinstanceof Security2CCCommandsSupportedGet\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Multicast commands are always accepted\n\t\t\t\t\tif (cmd.getMulticastGroupId() != undefined) return true;\n\n\t\t\t\t\t// This shouldn't happen, but better be sure\n\t\t\t\t\tif (cmd.securityClass == undefined) return false;\n\n\t\t\t\t\t// All other commands are only accepted if the highest security class is used\n\t\t\t\t\treturn cmd.securityClass === secClass;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn cmd.ccId === expectedSecurityCC;\n\t\t};\n\n\t\tlet requiresSecurity = securityClassIsS2(secClass);\n\t\tconst isSecure = isCCConsideredSecure(cc);\n\n\t\twhile (true) {\n\t\t\tif (isEncapsulatingCommandClass(cc)) {\n\t\t\t\tcc = cc.encapsulated;\n\t\t\t} else if (isMultiEncapsulatingCommandClass(cc)) {\n\t\t\t\trequiresSecurity ||= cc.encapsulated.some((cmd) =>\n\t\t\t\t\tnode.isCCSecure(cmd.ccId)\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\t} else {\n\t\t\t\trequiresSecurity ||= node.isCCSecure(cc.ccId)\n\t\t\t\t\t&& cc.ccId !== CommandClasses.Security\n\t\t\t\t\t&& cc.ccId !== CommandClasses[\"Security 2\"];\n\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (requiresSecurity && !isSecure) {\n\t\t\t// none found, don't accept the CC\n\t\t\tthis.controllerLog.logNode(\n\t\t\t\tcc.nodeId as number,\n\t\t\t\t`command was received at a lower security level than expected - discarding it...`,\n\t\t\t\t\"warn\",\n\t\t\t);\n\t\t\treturn true;\n\t\t}\n\n\t\treturn false;\n\t}\n\n\t/** Checks whether a CC should be discarded */\n\tprivate shouldDiscardCC(cc: CommandClass): boolean {\n\t\tif (isEncapsulatingCommandClass(cc)) {\n\t\t\treturn this.shouldDiscardCC(cc.encapsulated);\n\t\t}\n\n\t\tconst node = this._controller?.nodes.get(cc.nodeId as number);\n\t\t// We should have checked this before, but better be safe than sorry\n\t\tif (!node) {\n\t\t\t// Node does not exist, don't accept the CC\n\t\t\tthis.controllerLog.logNode(\n\t\t\t\tcc.nodeId as number,\n\t\t\t\t`is unknown - discarding received command...`,\n\t\t\t\t\"warn\",\n\t\t\t);\n\t\t\treturn true;\n\t\t}\n\n\t\tif (\n\t\t\tcc.constructor.name.endsWith(\"Get\")\n\t\t\t&& (cc.frameType === \"multicast\" || cc.frameType === \"broadcast\")\n\t\t) {\n\t\t\tthis.controllerLog.logNode(\n\t\t\t\tcc.nodeId as number,\n\t\t\t\t`received GET-type command via ${cc.frameType} - discarding...`,\n\t\t\t\t\"warn\",\n\t\t\t);\n\t\t\treturn true;\n\t\t}\n\n\t\t// Do not accept Meter CC and/or Multilevel Sensor CC if the node does not support them\n\t\t// https://github.com/zwave-js/node-zwave-js/issues/5510\n\t\t// TODO: Consider expanding this to all CCs and not only reports\n\t\tif (\n\t\t\tcc.ccId === CommandClasses.Meter\n\t\t\t|| cc.ccId === CommandClasses[\"Multilevel Sensor\"]\n\t\t) {\n\t\t\tconst endpoint = node.getEndpoint(cc.endpointIndex) ?? node;\n\t\t\tif (\n\t\t\t\t!endpoint.supportsCC(cc.ccId) && !endpoint.controlsCC(cc.ccId)\n\t\t\t) {\n\t\t\t\tthis.controllerLog.logNode(\n\t\t\t\t\tcc.nodeId as number,\n\t\t\t\t\t`${\n\t\t\t\t\t\tcc.endpointIndex > 0\n\t\t\t\t\t\t\t? `Endpoint ${cc.endpointIndex} `\n\t\t\t\t\t\t\t: \"\"\n\t\t\t\t\t}does not support CC ${\n\t\t\t\t\t\tgetCCName(\n\t\t\t\t\t\t\tcc.ccId,\n\t\t\t\t\t\t)\n\t\t\t\t\t} - discarding received command...`,\n\t\t\t\t\t\"warn\",\n\t\t\t\t);\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\n\t\treturn false;\n\t}\n\n\t/**\n\t * Is called when a Request-type message was received\n\t */\n\tprivate async handleRequest(msg: Message): Promise<void> {\n\t\tlet handlers: RequestHandlerEntry[] | undefined;\n\n\t\tif (hasNodeId(msg) || containsCC(msg)) {\n\t\t\tconst node = this.tryGetNode(msg);\n\t\t\tif (node) {\n\t\t\t\t// We have received an unsolicited message from a dead node, bring it back to life\n\t\t\t\tif (node.status === NodeStatus.Dead) {\n\t\t\t\t\tnode.markAsAlive();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Check if we have a dynamic handler waiting for this message\n\t\tfor (const entry of this.awaitedMessages) {\n\t\t\tif (entry.predicate(msg)) {\n\t\t\t\t// We do\n\t\t\t\tentry.handler(msg);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\tif (isCommandRequest(msg) && containsCC(msg)) {\n\t\t\tconst nodeId = msg.getNodeId()!;\n\n\t\t\t// It could also be that this is the node's response for a CC that we sent, but where the ACK is delayed\n\t\t\tconst currentMessage = this.queue.currentTransaction\n\t\t\t\t?.getCurrentMessage();\n\t\t\tif (\n\t\t\t\tcurrentMessage\n\t\t\t\t&& currentMessage.expectsNodeUpdate()\n\t\t\t\t&& currentMessage.isExpectedNodeUpdate(msg)\n\t\t\t) {\n\t\t\t\t// The message we're currently sending is still in progress but expects this message in response.\n\t\t\t\t// Remember the message there.\n\t\t\t\tthis.controllerLog.logNode(msg.getNodeId()!, {\n\t\t\t\t\tmessage:\n\t\t\t\t\t\t`received expected response prematurely, remembering it...`,\n\t\t\t\t\tlevel: \"verbose\",\n\t\t\t\t\tdirection: \"inbound\",\n\t\t\t\t});\n\t\t\t\tcurrentMessage.prematureNodeUpdate = msg;\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// For further actions, we are only interested in the innermost CC\n\t\t\tthis.unwrapCommands(msg);\n\n\t\t\t// cannot handle ApplicationCommandRequests without a controller\n\t\t\tif (this._controller == undefined) {\n\t\t\t\tthis.driverLog.print(\n\t\t\t\t\t` the controller is not ready yet, discarding...`,\n\t\t\t\t\t\"warn\",\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t} else if (!this.controller.nodes.has(nodeId)) {\n\t\t\t\tthis.driverLog.print(\n\t\t\t\t\t` the node is unknown or not initialized yet, discarding...`,\n\t\t\t\t\t\"warn\",\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst node = this.controller.nodes.get(nodeId)!;\n\t\t\tconst nodeSessions = this.nodeSessions.get(nodeId);\n\t\t\t// Check if we need to handle the command ourselves\n\t\t\tif (\n\t\t\t\tmsg.command.ccId === CommandClasses.Supervision\n\t\t\t\t&& msg.command instanceof SupervisionCCReport\n\t\t\t\t&& nodeSessions?.supervision.has(msg.command.sessionId)\n\t\t\t) {\n\t\t\t\t// Supervision commands are handled here\n\t\t\t\tthis.controllerLog.logNode(msg.command.nodeId, {\n\t\t\t\t\tmessage: `Received update for a Supervision session`,\n\t\t\t\t\tdirection: \"inbound\",\n\t\t\t\t});\n\n\t\t\t\t// Call the update handler\n\t\t\t\tnodeSessions.supervision.get(msg.command.sessionId)!({\n\t\t\t\t\tstatus: msg.command.status,\n\t\t\t\t\tremainingDuration: msg.command.duration,\n\t\t\t\t} as SupervisionResult);\n\t\t\t\t// If this was a final report, remove the handler\n\t\t\t\tif (!msg.command.moreUpdatesFollow) {\n\t\t\t\t\tnodeSessions.supervision.delete(msg.command.sessionId);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// Figure out if the command was received with supervision encapsulation and we need to respond accordingly\n\t\t\t\tconst supervisionSessionId = SupervisionCC.getSessionId(\n\t\t\t\t\tmsg.command,\n\t\t\t\t);\n\t\t\t\t// Figure out if this is an S2 multicast followup for a group that is out of sync\n\t\t\t\tconst s2MulticastOutOfSync = this.mustReplyWithSecurityS2MOS(\n\t\t\t\t\tmsg,\n\t\t\t\t);\n\n\t\t\t\tconst encapsulationFlags = msg.command.encapsulationFlags;\n\n\t\t\t\tlet reply: (\n\t\t\t\t\tstatus:\n\t\t\t\t\t\t| SupervisionStatus.Success\n\t\t\t\t\t\t| SupervisionStatus.Fail\n\t\t\t\t\t\t| SupervisionStatus.NoSupport,\n\t\t\t\t) => Promise<void>;\n\t\t\t\tif (supervisionSessionId != undefined) {\n\t\t\t\t\t// The command was supervised, and we must respond with a Supervision Report\n\t\t\t\t\tconst endpoint = node.getEndpoint(msg.command.endpointIndex)\n\t\t\t\t\t\t?? node;\n\t\t\t\t\treply = (status) =>\n\t\t\t\t\t\tendpoint\n\t\t\t\t\t\t\t.createAPI(CommandClasses.Supervision, false)\n\t\t\t\t\t\t\t.withOptions({ s2MulticastOutOfSync })\n\t\t\t\t\t\t\t.sendReport({\n\t\t\t\t\t\t\t\tsessionId: supervisionSessionId,\n\t\t\t\t\t\t\t\tmoreUpdatesFollow: false,\n\t\t\t\t\t\t\t\tstatus,\n\t\t\t\t\t\t\t\trequestWakeUpOnDemand: this\n\t\t\t\t\t\t\t\t\t.shouldRequestWakeupOnDemand(node),\n\t\t\t\t\t\t\t\tencapsulationFlags,\n\t\t\t\t\t\t\t\tlowPriority: this\n\t\t\t\t\t\t\t\t\t.shouldUseLowPriorityForSupervisionReport(\n\t\t\t\t\t\t\t\t\t\tnode,\n\t\t\t\t\t\t\t\t\t\tencapsulationFlags,\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t});\n\t\t\t\t} else {\n\t\t\t\t\t// Unsupervised, reply is a no-op\n\t\t\t\t\treply = () => Promise.resolve();\n\t\t\t\t}\n\t\t\t\t// DO NOT force-add support for the Supervision CC here. Some devices only support Supervision when sending,\n\t\t\t\t// so we need to trust the information we already have.\n\n\t\t\t\t// In the case where the command was unsupervised and we need to send a MOS, do it as soon as possible\n\t\t\t\tif (supervisionSessionId == undefined && s2MulticastOutOfSync) {\n\t\t\t\t\t// If the command was NOT received using Supervision,\n\t\t\t\t\t// we need to respond with an MOS nonce. Otherwise we'll set the flag\n\t\t\t\t\t// on the Supervision Report\n\t\t\t\t\tnode.commandClasses[\"Security 2\"].sendMOS().catch(() => {\n\t\t\t\t\t\t// Ignore errors\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\t// check if someone is waiting for this command\n\t\t\t\tfor (const entry of this.awaitedCommands) {\n\t\t\t\t\tif (entry.predicate(msg.command)) {\n\t\t\t\t\t\t// there is!\n\t\t\t\t\t\tentry.handler(msg.command);\n\n\t\t\t\t\t\t// and possibly reply to a supervised command\n\t\t\t\t\t\tawait reply(SupervisionStatus.Success);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// No one is waiting, dispatch the command to the node itself\n\t\t\t\ttry {\n\t\t\t\t\tawait node.handleCommand(msg.command);\n\t\t\t\t\tawait reply(SupervisionStatus.Success);\n\t\t\t\t} catch (e) {\n\t\t\t\t\tlet handled = false;\n\t\t\t\t\tif (isZWaveError(e)) {\n\t\t\t\t\t\tif (e.code === ZWaveErrorCodes.CC_OperationFailed) {\n\t\t\t\t\t\t\t// The sending node tried to do something that didn't work\n\t\t\t\t\t\t\tawait reply(SupervisionStatus.Fail);\n\t\t\t\t\t\t\thandled = true;\n\t\t\t\t\t\t} else if (e.code === ZWaveErrorCodes.CC_NotSupported) {\n\t\t\t\t\t\t\t// The sending node sent a command we could not handle\n\t\t\t\t\t\t\tawait reply(SupervisionStatus.NoSupport);\n\t\t\t\t\t\t\thandled = true;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (!handled) {\n\t\t\t\t\t\t// Something unexpected happened.\n\t\t\t\t\t\t// Report failure, then re-throw the error, so it can be handled accordingly\n\t\t\t\t\t\tawait reply(SupervisionStatus.Fail);\n\n\t\t\t\t\t\tthrow e;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn;\n\t\t} else if (msg instanceof ApplicationUpdateRequest) {\n\t\t\t// Make sure we're ready to handle this command\n\t\t\tthis.ensureReady(true);\n\t\t\treturn this.controller.handleApplicationUpdateRequest(msg);\n\t\t} else if (msg instanceof SerialAPIStartedRequest) {\n\t\t\tif (await this.handleSerialAPIStartedUnexpectedly(msg)) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t} else {\n\t\t\t// TODO: This deserves a nicer formatting\n\t\t\tthis.driverLog.print(\n\t\t\t\t`handling request ${\n\t\t\t\t\tFunctionType[msg.functionType]\n\t\t\t\t} (${msg.functionType})`,\n\t\t\t);\n\t\t\thandlers = this.requestHandlers.get(msg.functionType);\n\t\t}\n\n\t\tif (handlers != undefined && handlers.length > 0) {\n\t\t\tthis.driverLog.print(\n\t\t\t\t` ${handlers.length} handler${\n\t\t\t\t\thandlers.length !== 1 ? \"s\" : \"\"\n\t\t\t\t} registered!`,\n\t\t\t);\n\t\t\t// loop through all handlers and find the first one that returns true to indicate that it handled the message\n\t\t\tfor (let i = 0; i < handlers.length; i++) {\n\t\t\t\tthis.driverLog.print(` invoking handler #${i}`);\n\t\t\t\t// Invoke the handler and remember its result\n\t\t\t\tconst handler = handlers[i];\n\t\t\t\tlet handlerResult = handler.invoke(msg);\n\t\t\t\tif (handlerResult instanceof Promise) {\n\t\t\t\t\thandlerResult = await handlerResult;\n\t\t\t\t}\n\t\t\t\tif (handlerResult) {\n\t\t\t\t\tthis.driverLog.print(` the message was handled`);\n\t\t\t\t\tif (handler.oneTime) {\n\t\t\t\t\t\tthis.driverLog.print(\n\t\t\t\t\t\t\t\" one-time handler was successfully called, removing it...\",\n\t\t\t\t\t\t);\n\t\t\t\t\t\thandlers.splice(i, 1);\n\t\t\t\t\t}\n\t\t\t\t\t// don't invoke any more handlers\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tthis.driverLog.print(\" no handlers registered!\", \"warn\");\n\t\t}\n\t}\n\n\t/**\n\t * Returns the next callback ID. Callback IDs are used to correlate requests\n\t * to the controller/nodes with its response\n\t */\n\tpublic readonly getNextCallbackId = createWrappingCounter(0xff);\n\n\tprivate readonly supervisionSessionIDs = new Map<number, () => number>();\n\t/**\n\t * Returns the next session ID for Supervision CC\n\t */\n\tpublic getNextSupervisionSessionId(nodeId: number): number {\n\t\tif (!this.supervisionSessionIDs.has(nodeId)) {\n\t\t\tthis.supervisionSessionIDs.set(\n\t\t\t\tnodeId,\n\t\t\t\tcreateWrappingCounter(MAX_SUPERVISION_SESSION_ID, true),\n\t\t\t);\n\t\t}\n\t\treturn this.supervisionSessionIDs.get(nodeId)!();\n\t}\n\n\t/**\n\t * Returns the next session ID for Transport Service CC\n\t */\n\tpublic readonly getNextTransportServiceSessionId = createWrappingCounter(\n\t\tMAX_TRANSPORT_SERVICE_SESSION_ID,\n\t\ttrue,\n\t);\n\n\tprivate encapsulateCommands(\n\t\tcmd: CommandClass,\n\t\toptions: Omit<SendCommandOptions, keyof SendMessageOptions> = {},\n\t): CommandClass {\n\t\t// The encapsulation order (from outside to inside) is as follows:\n\t\t// 5. Any one of the following combinations:\n\t\t// a. Security (S0 or S2) followed by transport service\n\t\t// b. Transport Service\n\t\t// c. Security (S0 or S2)\n\t\t// d. CRC16\n\t\t// b and d are mutually exclusive, security is not\n\t\t// 4. Multi Channel\n\t\t// 3. Supervision\n\t\t// 2. Multi Command\n\t\t// 1. Encapsulated Command Class (payload), e.g. Basic Set\n\n\t\t// TODO: 2.\n\n\t\t// 3.\n\t\tif (SupervisionCC.requiresEncapsulation(cmd)) {\n\t\t\tcmd = SupervisionCC.encapsulate(\n\t\t\t\tcmd,\n\t\t\t\tthis.getNextSupervisionSessionId(cmd.nodeId as number),\n\t\t\t);\n\t\t}\n\n\t\t// 4.\n\t\tif (MultiChannelCC.requiresEncapsulation(cmd)) {\n\t\t\tconst multiChannelCCVersion = this.getSupportedCCVersion(\n\t\t\t\tCommandClasses[\"Multi Channel\"],\n\t\t\t\tcmd.nodeId as number,\n\t\t\t);\n\n\t\t\tcmd = multiChannelCCVersion === 1\n\t\t\t\t? MultiChannelCC.encapsulateV1(cmd)\n\t\t\t\t: MultiChannelCC.encapsulate(cmd);\n\t\t}\n\n\t\t// 5.\n\t\tif (CRC16CC.requiresEncapsulation(cmd)) {\n\t\t\tcmd = CRC16CC.encapsulate(cmd);\n\t\t} else {\n\t\t\t// The command must be S2-encapsulated, if ...\n\t\t\tlet maybeS2 = false;\n\t\t\tconst node = cmd.getNode(this);\n\t\t\tif (node?.supportsCC(CommandClasses[\"Security 2\"])) {\n\t\t\t\t// ... the node supports S2 and has a valid security class\n\t\t\t\tconst nodeSecClass = node.getHighestSecurityClass();\n\t\t\t\tconst securityManager = this.getSecurityManager2(node.id);\n\t\t\t\tmaybeS2 = securityClassIsS2(nodeSecClass)\n\t\t\t\t\t|| !!securityManager?.tempKeys.has(node.id);\n\t\t\t} else if (options.s2MulticastGroupId != undefined) {\n\t\t\t\t// ... or we're dealing with S2 multicast\n\t\t\t\tmaybeS2 = true;\n\t\t\t}\n\t\t\tif (maybeS2 && Security2CC.requiresEncapsulation(cmd)) {\n\t\t\t\tcmd = Security2CC.encapsulate(\n\t\t\t\t\tcmd,\n\t\t\t\t\tthis.ownNodeId,\n\t\t\t\t\tthis,\n\t\t\t\t\t{\n\t\t\t\t\t\tsecurityClass: options.s2OverrideSecurityClass,\n\t\t\t\t\t\tmulticastOutOfSync: !!options.s2MulticastOutOfSync,\n\t\t\t\t\t\tmulticastGroupId: options.s2MulticastGroupId,\n\t\t\t\t\t\tverifyDelivery: options.s2VerifyDelivery,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// This check will return false for S2-encapsulated commands\n\t\t\tif (SecurityCC.requiresEncapsulation(cmd)) {\n\t\t\t\tcmd = SecurityCC.encapsulate(\n\t\t\t\t\tthis.ownNodeId,\n\t\t\t\t\tthis.securityManager!,\n\t\t\t\t\tcmd,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\treturn cmd;\n\t}\n\n\tpublic unwrapCommands(msg: Message & ContainsCC): void {\n\t\t// Unwrap encapsulating CCs until we get to the core\n\t\twhile (\n\t\t\tisEncapsulatingCommandClass(msg.command)\n\t\t\t|| isMultiEncapsulatingCommandClass(msg.command)\n\t\t) {\n\t\t\tconst unwrapped = msg.command.encapsulated;\n\t\t\tif (isArray(unwrapped)) {\n\t\t\t\t// Multi Command CC cannot be further unwrapped. Preserve the encapsulation flags though.\n\t\t\t\tfor (const cmd of unwrapped) {\n\t\t\t\t\tcmd.toggleEncapsulationFlag(\n\t\t\t\t\t\tmsg.command.encapsulationFlags,\n\t\t\t\t\t\ttrue,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Copy the encapsulation flags and add the current encapsulation\n\t\t\tunwrapped.encapsulationFlags = msg.command.encapsulationFlags;\n\t\t\tswitch (msg.command.ccId) {\n\t\t\t\tcase CommandClasses.Supervision:\n\t\t\t\t\tunwrapped.toggleEncapsulationFlag(\n\t\t\t\t\t\tEncapsulationFlags.Supervision,\n\t\t\t\t\t\ttrue,\n\t\t\t\t\t);\n\t\t\t\t\tbreak;\n\t\t\t\tcase CommandClasses[\"Security 2\"]:\n\t\t\t\tcase CommandClasses.Security:\n\t\t\t\t\tunwrapped.toggleEncapsulationFlag(\n\t\t\t\t\t\tEncapsulationFlags.Security,\n\t\t\t\t\t\ttrue,\n\t\t\t\t\t);\n\t\t\t\t\tbreak;\n\t\t\t\tcase CommandClasses[\"CRC-16 Encapsulation\"]:\n\t\t\t\t\tunwrapped.toggleEncapsulationFlag(\n\t\t\t\t\t\tEncapsulationFlags.CRC16,\n\t\t\t\t\t\ttrue,\n\t\t\t\t\t);\n\t\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tmsg.command = unwrapped;\n\t\t}\n\t}\n\n\tprivate shouldPersistCCValues(cc: CommandClass): boolean {\n\t\t// Always persist encapsulation CCs, otherwise interviews don't work.\n\t\tif (isEncapsulationCC(cc.ccId)) return true;\n\n\t\t// Do not persist values for a node or endpoint that does not exist\n\t\tconst endpoint = this.tryGetEndpoint(cc);\n\t\tconst node = endpoint?.tryGetNode();\n\t\tif (!node) return false;\n\n\t\t// Do not persist values for a CC that was force-removed via config\n\t\tif (endpoint?.wasCCRemovedViaConfig(cc.ccId)) return false;\n\n\t\t// Do not persist values for a CC that's being mapped to another endpoint.\n\t\t// FIXME: This duplicates logic in Node.ts -> handleCommand\n\t\tconst compatConfig = node?.deviceConfig?.compat;\n\t\tif (\n\t\t\tcc.endpointIndex === 0\n\t\t\t&& cc.constructor.name.endsWith(\"Report\")\n\t\t\t&& node.getEndpointCount() >= 1\n\t\t\t// Only map reports from the root device to an endpoint if we know which one\n\t\t\t&& compatConfig?.mapRootReportsToEndpoint != undefined\n\t\t) {\n\t\t\tconst targetEndpoint = node.getEndpoint(\n\t\t\t\tcompatConfig.mapRootReportsToEndpoint,\n\t\t\t);\n\t\t\tif (targetEndpoint?.supportsCC(cc.ccId)) return false;\n\t\t}\n\n\t\treturn true;\n\t}\n\n\t/** Persists the values contained in a Command Class in the corresponding nodes's value DB */\n\tprivate persistCCValues(cc: CommandClass) {\n\t\tif (this.shouldPersistCCValues(cc)) {\n\t\t\tcc.persistValues(this);\n\t\t}\n\n\t\tif (isEncapsulatingCommandClass(cc)) {\n\t\t\tthis.persistCCValues(cc.encapsulated);\n\t\t} else if (isMultiEncapsulatingCommandClass(cc)) {\n\t\t\tfor (const encapsulated of cc.encapsulated) {\n\t\t\t\tthis.persistCCValues(encapsulated);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Gets called whenever any Serial API command succeeded or a SendData command had a negative callback.\n\t */\n\tprivate handleSerialAPICommandResult(\n\t\tmsg: Message,\n\t\toptions: SendMessageOptions,\n\t\tresult: Message | undefined,\n\t): void {\n\t\t// Update statistics\n\t\tconst node = this.tryGetNode(msg);\n\t\tlet success = true;\n\t\tif (isSendData(msg) || hasNodeId(msg)) {\n\t\t\t// This shouldn't happen, but just in case\n\t\t\tif (!node) return;\n\n\t\t\t// If this is a transmit report, use it to update statistics\n\t\t\tif (isTransmitReport(result)) {\n\t\t\t\tif (!result.isOK()) {\n\t\t\t\t\tsuccess = false;\n\t\t\t\t\tnode.incrementStatistics(\"commandsDroppedTX\");\n\t\t\t\t} else {\n\t\t\t\t\tnode.incrementStatistics(\"commandsTX\");\n\t\t\t\t\tnode.updateRTT(msg);\n\t\t\t\t\t// Update last seen state\n\t\t\t\t\tnode.lastSeen = new Date();\n\t\t\t\t}\n\n\t\t\t\t// Notify listeners about the status report if one was received\n\t\t\t\tif (hasTXReport(result)) {\n\t\t\t\t\toptions.onTXReport?.(result.txReport);\n\t\t\t\t\tnode.updateRouteStatistics(result.txReport);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Track and potentially update the status of the node when communication succeeds\n\t\t\tif (success) {\n\t\t\t\tif (node.canSleep) {\n\t\t\t\t\t// Do not update the node status when we only responded to a nonce/supervision request\n\t\t\t\t\tif (options.priority !== MessagePriority.Immediate) {\n\t\t\t\t\t\t// If the node is not meant to be kept awake, try to send it back to sleep\n\t\t\t\t\t\tif (!node.keepAwake) {\n\t\t\t\t\t\t\tsetImmediate(() =>\n\t\t\t\t\t\t\t\tthis.debounceSendNodeToSleep(node)\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// The node must be awake because it answered\n\t\t\t\t\t\tnode.markAsAwake();\n\t\t\t\t\t}\n\t\t\t\t} else if (node.status !== NodeStatus.Alive) {\n\t\t\t\t\t// The node status was unknown or dead - in either case it must be alive because it answered\n\t\t\t\t\tnode.markAsAlive();\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tthis._controller?.incrementStatistics(\"messagesTX\");\n\t\t}\n\t}\n\n\tprivate shouldUseLowPriorityForSupervisionReport(\n\t\ttargetNode: ZWaveNode,\n\t\tencapsulationFlags: EncapsulationFlags,\n\t): boolean {\n\t\t// To avoid S2 collisions, we reduce the priority of Supervision reports\n\t\t// when they are S2-encapsulated, and another S2-encapsulated transaction is in\n\t\t// progress for the same node\n\n\t\t// Use Immediate priority if there is no other transaction for this node in progress\n\t\tconst currentNormalMsg = this.queue.currentTransaction?.message;\n\t\tif (currentNormalMsg?.getNodeId() !== targetNode.id) {\n\t\t\treturn false;\n\t\t}\n\t\tif (!containsCC(currentNormalMsg)) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Use Immediate priority if the node isn't using Security S2\n\t\tif (!securityClassIsS2(targetNode.getHighestSecurityClass())) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Use Immediate priority unless both messages are S2-encapsulated\n\t\tconst currentMsgIsSecure = currentNormalMsg.command\n\t\t\tinstanceof Security2CCMessageEncapsulation;\n\t\tconst reportIsSecure = !!(\n\t\t\tencapsulationFlags & EncapsulationFlags.Security\n\t\t);\n\t\tif (!currentMsgIsSecure || !reportIsSecure) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// This has potential for a conflict, use low priority\n\t\tthis.controllerLog.logNode(targetNode.id, {\n\t\t\tmessage:\n\t\t\t\t\"S2 collision detected, reducing priority for Supervision report\",\n\t\t\tlevel: \"debug\",\n\t\t});\n\t\treturn true;\n\t}\n\n\tprivate mayStartTransaction(transaction: Transaction): boolean {\n\t\t// We may not send anything on the normal queue if the send thread is paused\n\t\t// or the controller is unresponsive\n\t\tif (\n\t\t\tthis.queuePaused\n\t\t\t|| this.controller.status === ControllerStatus.Unresponsive\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst message = transaction.message;\n\t\tconst targetNode = message.tryGetNode(this);\n\n\t\t// Messages to the controller may always be sent...\n\t\tif (!targetNode) return true;\n\n\t\t// The transaction queue is sorted automatically. If the first message is for a sleeping node, all messages in the queue are.\n\t\t// There are a few exceptions:\n\t\t// 1. Pings may be used to determine whether a node is really asleep.\n\t\t// 2. Responses to nonce requests must be sent independent of the node status, because some sleeping nodes may try to send us encrypted messages.\n\t\t// If we don't send them, they block the send queue\n\t\t// 3. Nodes that can sleep but do not support wakeup: https://github.com/zwave-js/node-zwave-js/discussions/1537\n\t\t// We need to try and send messages to them even if they are asleep, because we might never hear from them\n\n\t\t// 2. is handled by putting the message into the immediate queue\n\n\t\t// Pings may always be sent\n\t\tif (messageIsPing(message)) return true;\n\n\t\treturn (\n\t\t\ttargetNode.status !== NodeStatus.Asleep\n\t\t\t|| (!targetNode.supportsCC(CommandClasses[\"Wake Up\"])\n\t\t\t\t&& targetNode.interviewStage >= InterviewStage.NodeInfo)\n\t\t);\n\t}\n\n\tprivate markQueueBusy(queue: TransactionQueue, busy: boolean): void {\n\t\tconst index = this.queues.indexOf(queue);\n\t\tif (busy) {\n\t\t\tthis._queuesBusyFlags |= 1 << index;\n\t\t} else {\n\t\t\tthis._queuesBusyFlags &= ~(1 << index);\n\t\t}\n\t\tthis.queueIdle = this._queuesBusyFlags === 0;\n\t}\n\n\tprivate async drainTransactionQueue(\n\t\tqueue: TransactionQueue,\n\t): Promise<void> {\n\t\tlet setIdleTimer: NodeJS.Immediate | undefined;\n\t\tfor await (const transaction of queue) {\n\t\t\tif (setIdleTimer) {\n\t\t\t\tclearImmediate(setIdleTimer);\n\t\t\t\tsetIdleTimer = undefined;\n\t\t\t}\n\t\t\tthis.markQueueBusy(queue, true);\n\n\t\t\tlet error: ZWaveError | undefined;\n\t\t\ttry {\n\t\t\t\tawait this.executeTransaction(transaction);\n\t\t\t} catch (e) {\n\t\t\t\terror = e as ZWaveError;\n\t\t\t} finally {\n\t\t\t\tqueue.finalizeTransaction();\n\t\t\t}\n\n\t\t\t// Handle errors after clearing the current transaction.\n\t\t\t// Otherwise, it will get considered the active transaction and cause an unnecessary SendDataAbort\n\t\t\tif (error) {\n\t\t\t\tthis.handleFailedTransaction(transaction, error);\n\t\t\t}\n\n\t\t\tsetIdleTimer = setImmediate(() => {\n\t\t\t\tthis.markQueueBusy(queue, false);\n\t\t\t});\n\t\t}\n\t}\n\n\t/** Steps through the message generator of a transaction. Throws an error if the transaction should fail. */\n\tprivate async executeTransaction(transaction: Transaction): Promise<void> {\n\t\tlet prevResult: Message | undefined;\n\t\tlet msg: Message | undefined;\n\n\t\ttransaction.start();\n\t\ttransaction.setProgress({ state: TransactionState.Active });\n\n\t\tconst maxJammedAttempts =\n\t\t\tthis._recoveryPhase === ControllerRecoveryPhase.JammedAfterReset\n\t\t\t\t// After attempting soft-reset, only try sending once\n\t\t\t\t? 1\n\t\t\t\t: this.options.attempts.sendDataJammed;\n\n\t\t// Step through the transaction as long as it gives us a next message\n\t\twhile ((msg = await transaction.generateNextMessage(prevResult))) {\n\t\t\t// Keep track of how often the controller failed to send a command, to prevent ending up in an infinite loop\n\t\t\tlet jammedAttempts = 0;\n\t\t\tattemptMessage: for (let attemptNumber = 1;; attemptNumber++) {\n\t\t\t\ttry {\n\t\t\t\t\tprevResult = await this.queueSerialAPICommand(\n\t\t\t\t\t\tmsg,\n\t\t\t\t\t\ttransaction.stack,\n\t\t\t\t\t);\n\t\t\t\t\tif (isTransmitReport(prevResult)) {\n\t\t\t\t\t\t// Figure out if the controller is jammed. If it is, wait a second and try again.\n\t\t\t\t\t\t// https://github.com/zwave-js/node-zwave-js/issues/6199\n\t\t\t\t\t\t// In some cases, the transmit status can be Fail, even after transmitting for a couple of seconds.\n\t\t\t\t\t\t// Not sure what causes this, but it doesn't mean that the controller is jammed.\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tprevResult.transmitStatus === TransmitStatus.Fail\n\t\t\t\t\t\t\t&& \"txReport\" in prevResult\n\t\t\t\t\t\t\t// Ensure the controller didn't actually transmit\n\t\t\t\t\t\t\t&& prevResult.txReport?.txTicks === 0\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tjammedAttempts++;\n\t\t\t\t\t\t\tif (jammedAttempts < maxJammedAttempts) {\n\t\t\t\t\t\t\t\t// The controller is jammed. Wait a bit, then try again.\n\t\t\t\t\t\t\t\tthis.controller.setStatus(\n\t\t\t\t\t\t\t\t\tControllerStatus.Jammed,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tawait wait(\n\t\t\t\t\t\t\t\t\tthis.options.timeouts.retryJammed,\n\t\t\t\t\t\t\t\t\ttrue,\n\t\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t\tcontinue attemptMessage;\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t// Reject the transaction so we can attempt to recover\n\t\t\t\t\t\t\t\tthrow new ZWaveError(\n\t\t\t\t\t\t\t\t\t`Failed to send the command after ${jammedAttempts} attempts`,\n\t\t\t\t\t\t\t\t\tZWaveErrorCodes.Controller_MessageDropped,\n\t\t\t\t\t\t\t\t\tprevResult,\n\t\t\t\t\t\t\t\t\ttransaction.stack,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tthis.controller.status === ControllerStatus.Jammed\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t// A command could be sent, so the controller is no longer jammed\n\t\t\t\t\t\t\tthis.controller.setStatus(ControllerStatus.Ready);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (!prevResult.isOK()) {\n\t\t\t\t\t\t\tthrow new ZWaveError(\n\t\t\t\t\t\t\t\t\"The node did not acknowledge the command\",\n\t\t\t\t\t\t\t\tZWaveErrorCodes.Controller_CallbackNOK,\n\t\t\t\t\t\t\t\tprevResult,\n\t\t\t\t\t\t\t\ttransaction.stack,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t// We got a result - it will be passed to the next iteration\n\t\t\t\t\tbreak attemptMessage;\n\t\t\t\t} catch (e: any) {\n\t\t\t\t\tlet zwError: ZWaveError;\n\n\t\t\t\t\tif (!isZWaveError(e)) {\n\t\t\t\t\t\tzwError = createMessageDroppedUnexpectedError(e);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tisSendData(msg) && isMissingControllerCallback(e)\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t// The controller is unresponsive. Reject the transaction, so we can attempt to recover\n\t\t\t\t\t\t\tthrow e;\n\t\t\t\t\t\t} else if (isMissingControllerACK(e)) {\n\t\t\t\t\t\t\t// The controller is unresponsive. Reject the transaction, so we can attempt to recover\n\t\t\t\t\t\t\tthrow e;\n\t\t\t\t\t\t} else if (wasControllerReset(e)) {\n\t\t\t\t\t\t\t// The controller was reset unexpectedly. Reject the transaction, so we can attempt to recover\n\t\t\t\t\t\t\tthrow e;\n\t\t\t\t\t\t} else if (\n\t\t\t\t\t\t\te.code === ZWaveErrorCodes.Controller_MessageDropped\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t// We gave up on this command, so don't retry it\n\t\t\t\t\t\t\tthrow e;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tthis.mayRetrySerialAPICommand(\n\t\t\t\t\t\t\t\tmsg,\n\t\t\t\t\t\t\t\t// Ignore the number of attempts while jammed\n\t\t\t\t\t\t\t\tattemptNumber - jammedAttempts,\n\t\t\t\t\t\t\t\te,\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t// Retry the command\n\t\t\t\t\t\t\tcontinue attemptMessage;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tzwError = e;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Sending the command failed, reject the transaction\n\t\t\t\t\tthrow zwError;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// This transaction completed successfully, try the next one\n\t\ttransaction.setProgress({ state: TransactionState.Completed });\n\t}\n\n\t/**\n\t * Provides access to the result Promise for the currently executed serial API command\n\t */\n\tprivate _currentSerialAPICommandPromise:\n\t\t| DeferredPromise<Message | undefined>\n\t\t| undefined;\n\n\t/** Handles sequencing of queued Serial API commands */\n\tprivate async drainSerialAPIQueue(): Promise<void> {\n\t\tfor await (const item of this.serialAPIQueue) {\n\t\t\tconst { msg, transactionSource, result } = item;\n\t\t\ttry {\n\t\t\t\tconst ret = await this.executeSerialAPICommand(\n\t\t\t\t\tmsg,\n\t\t\t\t\ttransactionSource,\n\t\t\t\t);\n\t\t\t\tresult.resolve(ret);\n\t\t\t} catch (e) {\n\t\t\t\tresult.reject(e as Error);\n\t\t\t} finally {\n\t\t\t\tthis._currentSerialAPICommandPromise = undefined;\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate triggerQueues(): void {\n\t\tfor (const queue of this.queues) {\n\t\t\tqueue.trigger();\n\t\t}\n\t}\n\n\t/** Puts a message on the serial API queue and returns or throws the command result */\n\tprivate queueSerialAPICommand(\n\t\tmsg: Message,\n\t\ttransactionSource?: string,\n\t): Promise<Message | undefined> {\n\t\tconst result = createDeferredPromise<Message | undefined>();\n\t\tthis.serialAPIQueue.add({\n\t\t\tmsg,\n\t\t\ttransactionSource,\n\t\t\tresult,\n\t\t});\n\n\t\treturn result;\n\t}\n\n\tprivate mayRetrySerialAPICommand(\n\t\tmsg: Message,\n\t\tattemptNumber: number,\n\t\terror: ZWaveError,\n\t): boolean {\n\t\t// Only retry Send Data, nothing else\n\t\tif (!isSendData(msg)) return false;\n\n\t\t// Don't try to resend SendData commands when the response times out\n\t\tif (\n\t\t\terror.code === ZWaveErrorCodes.Controller_Timeout\n\t\t\t&& error.context === \"response\"\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Don't try to resend multicast messages if they were already transmitted.\n\t\t// One or more nodes might have already reacted\n\t\tif (\n\t\t\t(msg instanceof SendDataMulticastRequest\n\t\t\t\t|| msg instanceof SendDataMulticastBridgeRequest)\n\t\t\t&& error.code === ZWaveErrorCodes.Controller_CallbackNOK\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn attemptNumber < msg.maxSendAttempts;\n\t}\n\n\t/**\n\t * Executes a Serial API command and returns or throws the result.\n\t * This method should not be called outside of {@link drainSerialAPIQueue}.\n\t */\n\tprivate async executeSerialAPICommand(\n\t\tmsg: Message,\n\t\ttransactionSource?: string,\n\t): Promise<Message | undefined> {\n\t\t// Give the command a callback ID if it needs one\n\t\tif (msg.needsCallbackId() && !msg.hasCallbackId()) {\n\t\t\tmsg.callbackId = this.getNextCallbackId();\n\t\t}\n\n\t\tconst machine = createSerialAPICommandMachine(\n\t\t\tmsg,\n\t\t\tawait msg.serializeAsync(this.getEncodingContext()),\n\t\t\t{\n\t\t\t\tsendData: (data) => this.writeSerial(data),\n\t\t\t\tsendDataAbort: () => this.abortSendData(),\n\t\t\t\tnotifyUnsolicited: (msg) => {\n\t\t\t\t\tvoid this.handleUnsolicitedMessage(msg);\n\t\t\t\t},\n\t\t\t\tnotifyRetry: (\n\t\t\t\t\tlastError,\n\t\t\t\t\tmessage,\n\t\t\t\t\tattempts,\n\t\t\t\t\tmaxAttempts,\n\t\t\t\t\tdelay,\n\t\t\t\t) => {\n\t\t\t\t\t// Translate the error into a better one\n\t\t\t\t\tlet errorReason: string;\n\t\t\t\t\tswitch (lastError) {\n\t\t\t\t\t\tcase \"response timeout\":\n\t\t\t\t\t\t\terrorReason = \"No response from controller\";\n\t\t\t\t\t\t\tthis._controller?.incrementStatistics(\n\t\t\t\t\t\t\t\t\"timeoutResponse\",\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase \"callback timeout\":\n\t\t\t\t\t\t\terrorReason = \"No callback from controller\";\n\t\t\t\t\t\t\tthis._controller?.incrementStatistics(\n\t\t\t\t\t\t\t\t\"timeoutCallback\",\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase \"response NOK\":\n\t\t\t\t\t\t\terrorReason =\n\t\t\t\t\t\t\t\t\"The controller response indicated failure\";\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase \"callback NOK\":\n\t\t\t\t\t\t\terrorReason =\n\t\t\t\t\t\t\t\t\"The controller callback indicated failure\";\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase \"ACK timeout\":\n\t\t\t\t\t\t\tthis._controller?.incrementStatistics(\"timeoutACK\");\n\t\t\t\t\t\t// fall through\n\t\t\t\t\t\tcase \"CAN\":\n\t\t\t\t\t\tcase \"NAK\":\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\terrorReason =\n\t\t\t\t\t\t\t\t\"Failed to execute controller command\";\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tthis.controllerLog.print(\n\t\t\t\t\t\t`${errorReason} after ${attempts}/${maxAttempts} attempts. Scheduling next try in ${delay} ms.`,\n\t\t\t\t\t\t\"warn\",\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t\ttimestamp: highResTimestamp,\n\t\t\t\tlogOutgoingMessage: (msg: Message) => {\n\t\t\t\t\tthis.driverLog.logMessage(msg, {\n\t\t\t\t\t\tdirection: \"outbound\",\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t},\n\t\t\tpick(this._options, [\"timeouts\", \"attempts\"]),\n\t\t);\n\n\t\tconst result = createDeferredPromise<Message | undefined>();\n\n\t\t// Work around an issue in the 700 series firmware where the ACK after a soft-reset has a random high nibble.\n\t\t// This was broken in 7.19, not fixed so far\n\t\tif (\n\t\t\tmsg.functionType === FunctionType.SoftReset\n\t\t\t&& this.controller.sdkVersionGte(\"7.19.0\")\n\t\t) {\n\t\t\tthis.serial?.ignoreAckHighNibbleOnce();\n\t\t}\n\n\t\tthis.serialAPIInterpreter = interpret(machine).onDone((evt) => {\n\t\t\tthis.serialAPIInterpreter?.stop();\n\t\t\tthis.serialAPIInterpreter = undefined;\n\n\t\t\tconst cmdResult = evt.data as SerialAPICommandDoneData;\n\t\t\tif (cmdResult.type === \"success\") {\n\t\t\t\tresult.resolve(cmdResult.result);\n\t\t\t} else if (\n\t\t\t\tcmdResult.reason === \"callback NOK\"\n\t\t\t\t&& (isSendData(msg) || isTransmitReport(cmdResult.result))\n\t\t\t) {\n\t\t\t\t// For messages that were sent to a node, a NOK callback still contains useful info we need to evaluate\n\t\t\t\t// ... so we treat it as a result\n\t\t\t\tresult.resolve(cmdResult.result);\n\t\t\t} else {\n\t\t\t\t// Convert to a Z-Wave error\n\t\t\t\tresult.reject(\n\t\t\t\t\tserialAPICommandErrorToZWaveError(\n\t\t\t\t\t\tcmdResult.reason,\n\t\t\t\t\t\tmsg,\n\t\t\t\t\t\tcmdResult.result,\n\t\t\t\t\t\ttransactionSource,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t}\n\t\t});\n\n\t\t// Uncomment this for debugging state machine transitions\n\t\t// this.serialAPIInterpreter.onTransition((state) => {\n\t\t// \tif (state.changed) {\n\t\t// \t\tthis.driverLog.print(\n\t\t// \t\t\t`CMDMACHINE: ${JSON.stringify(state.toStrings())}`,\n\t\t// \t\t);\n\t\t// \t}\n\t\t// });\n\n\t\tthis.serialAPIInterpreter.start();\n\n\t\tthis._currentSerialAPICommandPromise = result;\n\t\treturn result;\n\t}\n\n\tprivate getQueueForTransaction(t: Transaction): TransactionQueue {\n\t\tif (\n\t\t\tt.priority === MessagePriority.Immediate\n\t\t\t|| t.priority === MessagePriority.ControllerImmediate\n\t\t) {\n\t\t\treturn this.immediateQueue;\n\t\t} else {\n\t\t\treturn this.queue;\n\t\t}\n\t}\n\n\t/**\n\t * Sends a message to the Z-Wave stick.\n\t * @param msg The message to send\n\t * @param options (optional) Options regarding the message transmission\n\t */\n\tpublic async sendMessage<TResponse extends Message = Message>(\n\t\tmsg: Message,\n\t\toptions: SendMessageOptions = {},\n\t): Promise<TResponse> {\n\t\tthis.ensureReady();\n\n\t\tlet node: ZWaveNode | undefined;\n\t\tif (hasNodeId(msg) || containsCC(msg)) {\n\t\t\tnode = this.tryGetNode(msg);\n\t\t}\n\n\t\tif (options.priority == undefined) {\n\t\t\toptions.priority = getDefaultPriority(msg);\n\t\t}\n\t\tif (options.priority == undefined) {\n\t\t\tconst className = msg.constructor.name;\n\t\t\tconst msgTypeName = FunctionType[msg.functionType];\n\t\t\tthrow new ZWaveError(\n\t\t\t\t`No default priority has been defined for ${className} (${msgTypeName}), so you have to provide one for your message`,\n\t\t\t\tZWaveErrorCodes.Driver_NoPriority,\n\t\t\t);\n\t\t}\n\n\t\tif (options.supportCheck == undefined) options.supportCheck = true;\n\t\tif (\n\t\t\toptions.supportCheck\n\t\t\t&& this._controller != undefined\n\t\t\t&& !this._controller.isFunctionSupported(msg.functionType)\n\t\t) {\n\t\t\tthrow new ZWaveError(\n\t\t\t\t`Your hardware does not support the ${\n\t\t\t\t\tFunctionType[msg.functionType]\n\t\t\t\t} function`,\n\t\t\t\tZWaveErrorCodes.Driver_NotSupported,\n\t\t\t);\n\t\t}\n\n\t\t// When sending a message to a node that is known to be sleeping,\n\t\t// the priority must be WakeUp, so the message gets deprioritized\n\t\t// in comparison with messages to awake nodes.\n\t\t// However there are a few exceptions...\n\t\tif (\n\t\t\t!!node\n\t\t\t// Pings can be used to check if a node is really asleep, so they should be sent regardless\n\t\t\t&& !messageIsPing(msg)\n\t\t\t// Nodes that can sleep and support the Wake Up CC should have their messages queued for wakeup\n\t\t\t&& node.canSleep\n\t\t\t&& (node.supportsCC(CommandClasses[\"Wake Up\"])\n\t\t\t\t// If we don't know the Wake Up support yet, also change the priority or RequestNodeInfoRequests will get stuck\n\t\t\t\t// in front of the queue\n\t\t\t\t|| node.interviewStage < InterviewStage.NodeInfo)\n\t\t\t// If we move multicasts to the wakeup queue, it is unlikely\n\t\t\t// that there is ever a points where all targets are awake\n\t\t\t&& !(msg instanceof SendDataMulticastRequest)\n\t\t\t&& !(msg instanceof SendDataMulticastBridgeRequest)\n\t\t\t// Nonces and responses to Supervision Get have to be sent immediately\n\t\t\t&& options.priority !== MessagePriority.Immediate\n\t\t) {\n\t\t\tif (options.priority === MessagePriority.NodeQuery) {\n\t\t\t\t// Remember that this transaction was part of an interview\n\t\t\t\toptions.tag = \"interview\";\n\t\t\t}\n\t\t\toptions.priority = MessagePriority.WakeUp;\n\t\t}\n\n\t\t// Create the transaction\n\t\tconst { generator, resultPromise } = createMessageGenerator(\n\t\t\tthis,\n\t\t\tthis.getEncodingContext(),\n\t\t\tmsg,\n\t\t\t(msg, _result) => {\n\t\t\t\tthis.handleSerialAPICommandResult(msg, options, _result);\n\t\t\t},\n\t\t);\n\t\tconst transaction = new Transaction(this, {\n\t\t\tmessage: msg,\n\t\t\tpriority: options.priority,\n\t\t\tparts: generator,\n\t\t\tpromise: resultPromise,\n\t\t\tlistener: options.onProgress,\n\t\t});\n\n\t\t// Configure its options\n\t\tif (options.changeNodeStatusOnMissingACK != undefined) {\n\t\t\ttransaction.changeNodeStatusOnTimeout =\n\t\t\t\toptions.changeNodeStatusOnMissingACK;\n\t\t}\n\t\tif (options.pauseSendThread === true) {\n\t\t\ttransaction.pauseSendThread = true;\n\t\t}\n\t\ttransaction.requestWakeUpOnDemand = !!options.requestWakeUpOnDemand;\n\t\ttransaction.tag = options.tag;\n\n\t\t// And queue it\n\t\tthis.getQueueForTransaction(transaction).add(transaction);\n\t\ttransaction.setProgress({ state: TransactionState.Queued });\n\n\t\t// If the transaction should expire, start the timeout\n\t\tlet expirationTimeout: NodeJS.Timeout | undefined;\n\t\tif (options.expire) {\n\t\t\texpirationTimeout = setTimeout(() => {\n\t\t\t\tthis.reduceQueues((t, _source) => {\n\t\t\t\t\tif (t === transaction) {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\ttype: \"reject\",\n\t\t\t\t\t\t\tmessage: `The message has expired`,\n\t\t\t\t\t\t\tcode: ZWaveErrorCodes.Controller_MessageExpired,\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\treturn { type: \"keep\" };\n\t\t\t\t});\n\t\t\t}, options.expire).unref();\n\t\t}\n\n\t\ttry {\n\t\t\tconst result = (await resultPromise) as TResponse;\n\n\t\t\t// If this was a successful non-nonce message to a sleeping node, make sure it goes to sleep again\n\t\t\tlet maybeSendToSleep: boolean;\n\t\t\tif (isSendData(msg)) {\n\t\t\t\t// For SendData messages, make sure the message is not a nonce\n\t\t\t\tmaybeSendToSleep =\n\t\t\t\t\toptions.priority !== MessagePriority.Immediate\n\t\t\t\t\t// And that the result is either a response from the node\n\t\t\t\t\t// or a transmit report indicating success\n\t\t\t\t\t&& result\n\t\t\t\t\t&& (result.functionType\n\t\t\t\t\t\t\t=== FunctionType.BridgeApplicationCommand\n\t\t\t\t\t\t|| result.functionType\n\t\t\t\t\t\t\t=== FunctionType.ApplicationCommand\n\t\t\t\t\t\t|| (isSendDataTransmitReport(result) && result.isOK()));\n\t\t\t} else {\n\t\t\t\t// For other messages to the node, just check for successful completion. If the callback is not OK,\n\t\t\t\t// we might not be able to communicate with the node. Sending another message is not a good idea.\n\t\t\t\tmaybeSendToSleep = hasNodeId(msg)\n\t\t\t\t\t&& result\n\t\t\t\t\t&& isSuccessIndicator(result)\n\t\t\t\t\t&& result.isOK();\n\t\t\t}\n\n\t\t\tif (maybeSendToSleep && node && node.canSleep && !node.keepAwake) {\n\t\t\t\tsetImmediate(() => this.debounceSendNodeToSleep(node));\n\t\t\t}\n\n\t\t\t// Set the transaction progress to completed before resolving the Promise\n\t\t\ttransaction.setProgress({ state: TransactionState.Completed });\n\n\t\t\treturn result;\n\t\t} catch (e) {\n\t\t\tif (isZWaveError(e)) {\n\t\t\t\tif (\n\t\t\t\t\t// If a controller command failed (that is not SendData), pass the response/callback through\n\t\t\t\t\t(e.code === ZWaveErrorCodes.Controller_ResponseNOK\n\t\t\t\t\t\t|| e.code === ZWaveErrorCodes.Controller_CallbackNOK)\n\t\t\t\t\t&& e.context instanceof Message\n\t\t\t\t\t// We need to check the function type here because context can be the transmit reports\n\t\t\t\t\t&& e.context.functionType !== FunctionType.SendData\n\t\t\t\t\t&& e.context.functionType !== FunctionType.SendDataMulticast\n\t\t\t\t\t&& e.context.functionType !== FunctionType.SendDataBridge\n\t\t\t\t\t&& e.context.functionType\n\t\t\t\t\t\t!== FunctionType.SendDataMulticastBridge\n\t\t\t\t) {\n\t\t\t\t\tthis._controller?.incrementStatistics(\"messagesDroppedTX\");\n\t\t\t\t\treturn e.context as TResponse;\n\t\t\t\t} else if (e.code === ZWaveErrorCodes.Controller_NodeTimeout) {\n\t\t\t\t\t// If the node failed to respond in time, remember this for the statistics\n\t\t\t\t\tnode?.incrementStatistics(\"timeoutResponse\");\n\t\t\t\t}\n\t\t\t\t// Enrich errors with the transaction's stack instead of the internal stack\n\t\t\t\tif (!e.transactionSource) {\n\t\t\t\t\tthrow new ZWaveError(\n\t\t\t\t\t\te.message,\n\t\t\t\t\t\te.code,\n\t\t\t\t\t\te.context,\n\t\t\t\t\t\ttransaction.stack,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t\tthrow e;\n\t\t} finally {\n\t\t\t// The transaction was handled, so it can no longer expire\n\t\t\tif (expirationTimeout) clearTimeout(expirationTimeout);\n\t\t}\n\t}\n\n\t/** Wraps a CC in the correct SendData message to use for sending */\n\tpublic createSendDataMessage(\n\t\tcommand: CommandClass,\n\t\toptions: Omit<SendCommandOptions, keyof SendMessageOptions> = {},\n\t): SendDataMessage & ContainsCC {\n\t\t// Automatically encapsulate commands before sending\n\t\tif (options.autoEncapsulate !== false) {\n\t\t\tcommand = this.encapsulateCommands(command, options);\n\t\t}\n\n\t\tlet msg: SendDataMessage;\n\t\tif (command.isSinglecast() || command.isBroadcast()) {\n\t\t\tif (\n\t\t\t\tthis.controller.isFunctionSupported(FunctionType.SendDataBridge)\n\t\t\t) {\n\t\t\t\t// Prioritize Bridge commands when they are supported\n\t\t\t\tmsg = new SendDataBridgeRequest({\n\t\t\t\t\tsourceNodeId: this.ownNodeId,\n\t\t\t\t\tcommand,\n\t\t\t\t\tmaxSendAttempts: this._options.attempts.sendData,\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tmsg = new SendDataRequest({\n\t\t\t\t\tcommand,\n\t\t\t\t\tmaxSendAttempts: this._options.attempts.sendData,\n\t\t\t\t});\n\t\t\t}\n\t\t} else if (command.isMulticast()) {\n\t\t\tif (\n\t\t\t\tthis.controller.isFunctionSupported(\n\t\t\t\t\tFunctionType.SendDataMulticastBridge,\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\t// Prioritize Bridge commands when they are supported\n\t\t\t\tmsg = new SendDataMulticastBridgeRequest({\n\t\t\t\t\tsourceNodeId: this.ownNodeId,\n\t\t\t\t\tcommand,\n\t\t\t\t\tmaxSendAttempts: this._options.attempts.sendData,\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tmsg = new SendDataMulticastRequest({\n\t\t\t\t\tcommand,\n\t\t\t\t\tmaxSendAttempts: this._options.attempts.sendData,\n\t\t\t\t});\n\t\t\t}\n\t\t} else {\n\t\t\tthrow new ZWaveError(\n\t\t\t\t`A CC must either be singlecast or multicast`,\n\t\t\t\tZWaveErrorCodes.Argument_Invalid,\n\t\t\t);\n\t\t}\n\t\t// Specify the number of send attempts for the request\n\t\tif (options.maxSendAttempts != undefined) {\n\t\t\tmsg.maxSendAttempts = options.maxSendAttempts;\n\t\t}\n\n\t\t// Specify transmit options for the request\n\t\tif (options.transmitOptions != undefined) {\n\t\t\tmsg.transmitOptions = options.transmitOptions;\n\t\t\tif (!(options.transmitOptions & TransmitOptions.ACK)) {\n\t\t\t\t// If no ACK is requested, set the callback ID to zero, because we won't get a controller callback\n\t\t\t\tmsg.callbackId = 0;\n\t\t\t}\n\t\t}\n\n\t\tif (!!options.reportTimeoutMs) {\n\t\t\tmsg.nodeUpdateTimeout = options.reportTimeoutMs;\n\t\t}\n\n\t\treturn msg as SendDataMessage & ContainsCC;\n\t}\n\n\t/**\n\t * Sends a command to a Z-Wave node. If the node returns a command in response, that command will be the return value.\n\t * If the command expects no response **or** the response times out, nothing will be returned\n\t * @param command The command to send. It will be encapsulated in a SendData[Multicast]Request.\n\t * @param options (optional) Options regarding the message transmission\n\t */\n\tprivate async sendCommandInternal<\n\t\tTResponse extends CCId = CCId,\n\t>(\n\t\tcommand: CommandClass,\n\t\toptions: Omit<\n\t\t\tSendCommandOptions,\n\t\t\t\"requestStatusUpdates\" | \"onUpdate\"\n\t\t> = {},\n\t): Promise<TResponse | undefined> {\n\t\tconst msg = this.createSendDataMessage(command, options);\n\t\ttry {\n\t\t\tconst resp = await this.sendMessage(msg, options);\n\n\t\t\t// And unwrap the response if there was any\n\t\t\tif (containsCC(resp)) {\n\t\t\t\tthis.unwrapCommands(resp);\n\t\t\t\treturn resp.command as unknown as TResponse;\n\t\t\t}\n\t\t} catch (e) {\n\t\t\t// A timeout always has to be expected. In this case return nothing.\n\t\t\tif (\n\t\t\t\tisZWaveError(e)\n\t\t\t\t&& e.code === ZWaveErrorCodes.Controller_NodeTimeout\n\t\t\t) {\n\t\t\t\tif (command.isSinglecast()) {\n\t\t\t\t\tthis.controllerLog.logNode(\n\t\t\t\t\t\tcommand.nodeId,\n\t\t\t\t\t\te.message,\n\t\t\t\t\t\t\"warn\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// We don't want to swallow any other errors\n\t\t\t\tthrow e;\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Sends a supervised command to a Z-Wave node. When status updates are requested, the passed callback will be executed for every non-final update.\n\t * @param command The command to send\n\t * @param options (optional) Options regarding the message transmission\n\t */\n\tprivate async sendSupervisedCommand(\n\t\tcommand: SinglecastCC<CommandClass>,\n\t\toptions: SendCommandOptions & { useSupervision?: \"auto\" } = {\n\t\t\trequestStatusUpdates: false,\n\t\t},\n\t): Promise<SupervisionResult | undefined> {\n\t\t// Create the encapsulating CC so we have a session ID\n\t\tconst sessionId = this.getNextSupervisionSessionId(command.nodeId);\n\t\tcommand = SupervisionCC.encapsulate(\n\t\t\tcommand,\n\t\t\tsessionId,\n\t\t\toptions.requestStatusUpdates,\n\t\t);\n\n\t\tconst resp = await this.sendCommandInternal<SupervisionCCReport>(\n\t\t\tcommand,\n\t\t\toptions,\n\t\t);\n\t\tif (!resp) return;\n\n\t\t// If future updates are expected, listen for them\n\t\tif (options.requestStatusUpdates && resp.moreUpdatesFollow) {\n\t\t\tthis.ensureNodeSessions(command.nodeId).supervision.set(\n\t\t\t\t(command as SupervisionCCGet).sessionId,\n\t\t\t\toptions.onUpdate,\n\t\t\t);\n\t\t}\n\t\t// In any case, return the status\n\t\treturn resp.toSupervisionResult();\n\t}\n\n\t/**\n\t * Sends a command to a Z-Wave node. The return value depends on several factors:\n\t * * If the node returns a command in response, that command will be the return value.\n\t * * If the command is a SET-type command and Supervision CC can and should be used, a {@link SupervisionResult} will be returned.\n\t * * If the command expects no response **or** the response times out, nothing will be returned.\n\t *\n\t * @param command The command to send. It will be encapsulated in a SendData[Multicast]Request.\n\t * @param options (optional) Options regarding the message transmission\n\t */\n\tpublic async sendCommand<\n\t\tTResponse extends CCId | undefined = undefined,\n\t>(\n\t\tcommand: CommandClass,\n\t\toptions?: SendCommandOptions,\n\t): Promise<SendCommandReturnType<TResponse>> {\n\t\tif (options?.encapsulationFlags != undefined) {\n\t\t\tcommand.encapsulationFlags = options.encapsulationFlags;\n\t\t}\n\n\t\t// Use security encapsulation for CCs that are only supported securely, and multicast commands\n\t\tif (\n\t\t\tthis.isCCSecure(\n\t\t\t\tcommand.ccId,\n\t\t\t\tcommand.nodeId as number,\n\t\t\t\tcommand.endpointIndex,\n\t\t\t)\n\t\t\t|| options?.s2MulticastGroupId != undefined\n\t\t) {\n\t\t\tcommand.toggleEncapsulationFlag(EncapsulationFlags.Security, true);\n\t\t}\n\n\t\t// Only use supervision if...\n\t\tif (\n\t\t\t// ... not disabled\n\t\t\toptions?.useSupervision !== false\n\t\t\t// ... and it is legal for the command\n\t\t\t&& SupervisionCC.mayUseSupervision(this, command)\n\t\t) {\n\t\t\tconst result = await this.sendSupervisedCommand(command, options);\n\t\t\tif (result?.status !== SupervisionStatus.NoSupport) {\n\t\t\t\t// @ts-expect-error TS doesn't know we've narrowed the return type to match\n\t\t\t\treturn result;\n\t\t\t}\n\n\t\t\t// The node should support supervision but it doesn't for this command. Remember this\n\t\t\tSupervisionCC.setCCSupportedWithSupervision(\n\t\t\t\tthis,\n\t\t\t\tcommand.getEndpoint(this)!,\n\t\t\t\tcommand.ccId,\n\t\t\t\tfalse,\n\t\t\t);\n\t\t\t// And retry the command without supervision\n\t\t}\n\n\t\t// Fall back to non-supervised commands\n\t\tconst result = await this.sendCommandInternal(command, options);\n\n\t\t// When sending S2 multicast commands to supporting nodes, the singlecast followups\n\t\t// may use supervision. In this case, the multicast message generator returns a\n\t\t// synthetic SupervisionCCReport.\n\t\t// sendCommand is supposed to return a SupervisionResult though.\n\t\tif (\n\t\t\toptions?.s2MulticastGroupId != undefined\n\t\t\t&& result instanceof SupervisionCCReport\n\t\t) {\n\t\t\t// @ts-expect-error TS doesn't know we've narrowed the return type to match\n\t\t\treturn result.toSupervisionResult();\n\t\t}\n\n\t\t// @ts-expect-error TS doesn't know we've narrowed the return type to match\n\t\treturn result;\n\t}\n\n\t/** @internal */\n\tpublic async sendZWaveProtocolCC(\n\t\tcommand: ZWaveProtocolCC,\n\t\toptions: Pick<\n\t\t\tSendCommandOptions,\n\t\t\t\"changeNodeStatusOnMissingACK\" | \"maxSendAttempts\"\n\t\t> = {},\n\t): Promise<void> {\n\t\tawait this.sendCommandInternal(command, {\n\t\t\tpriority: MessagePriority.Controller,\n\t\t\t// No shenanigans, just send the raw command\n\t\t\tautoEncapsulate: false,\n\t\t\tuseSupervision: false,\n\t\t\tchangeNodeStatusOnMissingACK: options.changeNodeStatusOnMissingACK\n\t\t\t\t?? false,\n\t\t\tmaxSendAttempts: options.maxSendAttempts || 1,\n\t\t\ttransmitOptions: TransmitOptions.AutoRoute | TransmitOptions.ACK,\n\t\t});\n\t}\n\n\tprivate async abortSendData(): Promise<void> {\n\t\ttry {\n\t\t\tconst abort = new SendDataAbort();\n\t\t\tawait this.writeSerial(\n\t\t\t\tawait abort.serializeAsync(this.getEncodingContext()),\n\t\t\t);\n\t\t\tthis.driverLog.logMessage(abort, {\n\t\t\t\tdirection: \"outbound\",\n\t\t\t});\n\n\t\t\t// We're bypassing the serial API machine, so we need to wait for the ACK ourselves\n\t\t\t// This could also cause a NAK or CAN, but we don't really care\n\t\t\tawait this.waitForMessageHeader(() => true, 500).catch(noop);\n\t\t} catch {\n\t\t\t// ignore\n\t\t}\n\t}\n\n\t/**\n\t * Sends a low-level message like ACK, NAK or CAN immediately\n\t * @param header The low-level message to send\n\t */\n\tprivate writeHeader(header: MessageHeaders): Promise<void> {\n\t\t// ACK, CAN, NAK\n\t\treturn this.writeSerial(Uint8Array.from([header]));\n\t}\n\n\t/** Sends a raw datagram to the serialport (if that is open) */\n\tprivate async writeSerial(data: Uint8Array): Promise<void> {\n\t\treturn this.serial?.writeAsync(data);\n\t}\n\n\t/**\n\t * Waits until a matching message header is received or a timeout has elapsed. Returns the received message.\n\t *\n\t * @param timeout The number of milliseconds to wait. If the timeout elapses, the returned promise will be rejected\n\t * @param predicate A predicate function to test all incoming message headers.\n\t */\n\tpublic waitForMessageHeader(\n\t\tpredicate: (header: MessageHeaders) => boolean,\n\t\ttimeout: number,\n\t): Promise<MessageHeaders> {\n\t\treturn new Promise<MessageHeaders>((resolve, reject) => {\n\t\t\tconst promise = createDeferredPromise<MessageHeaders>();\n\t\t\tconst entry: AwaitedMessageHeader = {\n\t\t\t\tpredicate,\n\t\t\t\thandler: (msg) => promise.resolve(msg),\n\t\t\t\ttimeout: undefined,\n\t\t\t};\n\t\t\tthis.awaitedMessageHeaders.push(entry);\n\t\t\tconst removeEntry = () => {\n\t\t\t\tif (entry.timeout) clearTimeout(entry.timeout);\n\t\t\t\tconst index = this.awaitedMessageHeaders.indexOf(entry);\n\t\t\t\tif (index !== -1) this.awaitedMessageHeaders.splice(index, 1);\n\t\t\t};\n\t\t\t// When the timeout elapses, remove the wait entry and reject the returned Promise\n\t\t\tentry.timeout = setTimeout(() => {\n\t\t\t\tremoveEntry();\n\t\t\t\treject(\n\t\t\t\t\tnew ZWaveError(\n\t\t\t\t\t\t`Received no matching serial frame within the provided timeout!`,\n\t\t\t\t\t\tZWaveErrorCodes.Controller_Timeout,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t}, timeout);\n\t\t\t// When the promise is resolved, remove the wait entry and resolve the returned Promise\n\t\t\tvoid promise.then((cc) => {\n\t\t\t\tremoveEntry();\n\t\t\t\tresolve(cc);\n\t\t\t});\n\t\t});\n\t}\n\n\t/**\n\t * Waits until an unsolicited serial message is received or a timeout has elapsed. Returns the received message.\n\t *\n\t * **Note:** To wait for a certain CommandClass, better use {@link waitForCommand}.\n\t * @param timeout The number of milliseconds to wait. If the timeout elapses, the returned promise will be rejected\n\t * @param predicate A predicate function to test all incoming messages.\n\t * @param refreshPredicate A predicate function to test partial messages. If this returns `true` for a message, the timer will be restarted.\n\t */\n\tpublic waitForMessage<T extends Message>(\n\t\tpredicate: (msg: Message) => boolean,\n\t\ttimeout: number,\n\t\trefreshPredicate?: (msg: Message) => boolean,\n\t): Promise<T> {\n\t\treturn new Promise<T>((resolve, reject) => {\n\t\t\tconst promise = createDeferredPromise<Message>();\n\t\t\tconst entry: AwaitedMessageEntry = {\n\t\t\t\tpredicate,\n\t\t\t\trefreshPredicate,\n\t\t\t\thandler: (msg) => promise.resolve(msg),\n\t\t\t\ttimeout: undefined,\n\t\t\t};\n\t\t\tthis.awaitedMessages.push(entry);\n\t\t\tconst removeEntry = () => {\n\t\t\t\tif (entry.timeout) clearTimeout(entry.timeout);\n\t\t\t\tconst index = this.awaitedMessages.indexOf(entry);\n\t\t\t\tif (index !== -1) this.awaitedMessages.splice(index, 1);\n\t\t\t};\n\t\t\t// When the timeout elapses, remove the wait entry and reject the returned Promise\n\t\t\tentry.timeout = setTimeout(() => {\n\t\t\t\tremoveEntry();\n\t\t\t\treject(\n\t\t\t\t\tnew ZWaveError(\n\t\t\t\t\t\t`Received no matching message within the provided timeout!`,\n\t\t\t\t\t\tZWaveErrorCodes.Controller_Timeout,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t}, timeout);\n\t\t\t// When the promise is resolved, remove the wait entry and resolve the returned Promise\n\t\t\tvoid promise.then((cc) => {\n\t\t\t\tremoveEntry();\n\t\t\t\tresolve(cc as T);\n\t\t\t});\n\t\t});\n\t}\n\n\t/**\n\t * Waits until a CommandClass is received or a timeout has elapsed. Returns the received command.\n\t * @param timeout The number of milliseconds to wait. If the timeout elapses, the returned promise will be rejected\n\t * @param predicate A predicate function to test all incoming command classes\n\t */\n\tpublic waitForCommand<T extends CCId>(\n\t\tpredicate: (cc: CCId) => boolean,\n\t\ttimeout: number,\n\t): Promise<T> {\n\t\treturn new Promise<T>((resolve, reject) => {\n\t\t\tconst promise = createDeferredPromise<CCId>();\n\t\t\tconst entry: AwaitedCommandEntry = {\n\t\t\t\tpredicate,\n\t\t\t\thandler: (cc) => promise.resolve(cc),\n\t\t\t\ttimeout: undefined,\n\t\t\t};\n\t\t\tthis.awaitedCommands.push(entry);\n\t\t\tconst removeEntry = () => {\n\t\t\t\tif (entry.timeout) clearTimeout(entry.timeout);\n\t\t\t\tconst index = this.awaitedCommands.indexOf(entry);\n\t\t\t\tif (index !== -1) this.awaitedCommands.splice(index, 1);\n\t\t\t};\n\t\t\t// When the timeout elapses, remove the wait entry and reject the returned Promise\n\t\t\tentry.timeout = setTimeout(() => {\n\t\t\t\tremoveEntry();\n\t\t\t\treject(\n\t\t\t\t\tnew ZWaveError(\n\t\t\t\t\t\t`Received no matching command within the provided timeout!`,\n\t\t\t\t\t\tZWaveErrorCodes.Controller_NodeTimeout,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t}, timeout);\n\t\t\t// When the promise is resolved, remove the wait entry and resolve the returned Promise\n\t\t\tvoid promise.then((cc) => {\n\t\t\t\tremoveEntry();\n\t\t\t\tresolve(cc as T);\n\t\t\t});\n\t\t});\n\t}\n\n\t/**\n\t * Calls the given handler function every time a CommandClass is received that matches the given predicate.\n\t * @param predicate A predicate function to test all incoming command classes\n\t */\n\tpublic registerCommandHandler<T extends CCId>(\n\t\tpredicate: (cc: CCId) => boolean,\n\t\thandler: (cc: T) => void,\n\t): {\n\t\tunregister: () => void;\n\t} {\n\t\tconst entry: AwaitedCommandEntry = {\n\t\t\tpredicate,\n\t\t\thandler: (cc) => handler(cc as T),\n\t\t\ttimeout: undefined,\n\t\t};\n\t\tthis.awaitedCommands.push(entry);\n\t\tconst removeEntry = () => {\n\t\t\tif (entry.timeout) clearTimeout(entry.timeout);\n\t\t\tconst index = this.awaitedCommands.indexOf(entry);\n\t\t\tif (index !== -1) this.awaitedCommands.splice(index, 1);\n\t\t};\n\n\t\treturn {\n\t\t\tunregister: removeEntry,\n\t\t};\n\t}\n\n\tprivate handleFailedTransaction(\n\t\ttransaction: Transaction,\n\t\terror: ZWaveError,\n\t): void {\n\t\t// If a node failed to respond in time, it might be sleeping\n\t\tif (this.isMissingNodeACK(transaction, error)) {\n\t\t\tif (this.handleMissingNodeACK(transaction as any, error)) return;\n\t\t} else if (isMissingControllerACK(error)) {\n\t\t\tif (this.handleMissingControllerACK(transaction, error)) return;\n\t\t} else if (\n\t\t\t// 700/800 series controllers can be jammed due to a bug,\n\t\t\t// which a soft-reset is supposed to work around\n\t\t\tisSendData(transaction.message)\n\t\t\t&& this.controller.status === ControllerStatus.Jammed\n\t\t) {\n\t\t\tif (this.handleJammedController(transaction, error)) return;\n\t\t} else if (\n\t\t\tisSendData(transaction.message)\n\t\t\t&& (isMissingControllerResponse(error)\n\t\t\t\t|| isMissingControllerCallback(error))\n\t\t) {\n\t\t\tif (\n\t\t\t\tthis.handleMissingSendDataResponseOrCallback(transaction, error)\n\t\t\t) return;\n\t\t} else if (wasControllerReset(error)) {\n\t\t\t// The controller was reset in the middle of a transaction.\n\t\t\t// Re-queue the transaction, so it can get handled again\n\t\t\t// Its message generator may have finished, so reset that too.\n\t\t\ttransaction.reset();\n\t\t\tthis.getQueueForTransaction(transaction).add(\n\t\t\t\ttransaction.clone(),\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tthis.rejectTransaction(transaction, error);\n\t}\n\n\tprivate rejectTransaction(\n\t\ttransaction: Transaction,\n\t\terror: ZWaveError,\n\t): void {\n\t\ttransaction.setProgress({\n\t\t\tstate: TransactionState.Failed,\n\t\t\treason: error.message,\n\t\t});\n\n\t\ttransaction.abort(error);\n\t}\n\n\tprivate resolveTransaction(\n\t\ttransaction: Transaction,\n\t\tresult?: Message,\n\t): void {\n\t\ttransaction.abort(result);\n\t}\n\n\t/** Checks if a message is allowed to go into the wakeup queue */\n\tprivate mayMoveToWakeupQueue(transaction: Transaction): boolean {\n\t\tconst msg = transaction.message;\n\t\tswitch (true) {\n\t\t\t// Pings, nonces and Supervision Reports will block the send queue until wakeup, so they must be dropped\n\t\t\tcase messageIsPing(msg):\n\t\t\tcase transaction.priority === MessagePriority.Immediate:\n\t\t\t// We also don't want to immediately send the node to sleep when it wakes up\n\t\t\tcase containsCC(msg)\n\t\t\t\t&& msg.command instanceof WakeUpCCNoMoreInformation:\n\t\t\t// compat queries because they will be recreated when the node wakes up\n\t\t\tcase transaction.tag === \"compat\":\n\t\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t}\n\n\t/** Moves all messages for a given node into the wakeup queue */\n\tprivate moveMessagesToWakeupQueue(nodeId: number): void {\n\t\tconst reject: TransactionReducerResult = {\n\t\t\ttype: \"reject\",\n\t\t\tmessage: `The node is asleep`,\n\t\t\tcode: ZWaveErrorCodes.Controller_MessageDropped,\n\t\t};\n\t\tconst requeue: TransactionReducerResult = {\n\t\t\ttype: \"requeue\",\n\t\t\tpriority: MessagePriority.WakeUp,\n\t\t\t// Reset the transaction so it doesn't simply resolve to `undefined` when we attempt to continue it\n\t\t\treset: true,\n\t\t};\n\t\tconst requeueAndTagAsInterview: TransactionReducerResult = {\n\t\t\t...requeue,\n\t\t\ttag: \"interview\",\n\t\t};\n\n\t\tthis.reduceQueues((transaction, _source) => {\n\t\t\tconst msg = transaction.message;\n\t\t\tif (msg.getNodeId() !== nodeId) return { type: \"keep\" };\n\t\t\t// Drop all messages that are not allowed in the wakeup queue\n\t\t\t// For all other messages, change the priority to wakeup\n\t\t\treturn this.mayMoveToWakeupQueue(transaction)\n\t\t\t\t? transaction.priority === MessagePriority.NodeQuery\n\t\t\t\t\t? requeueAndTagAsInterview\n\t\t\t\t\t: requeue\n\t\t\t\t: reject;\n\t\t});\n\t}\n\n\t/**\n\t * @internal\n\t * Rejects all pending transactions that match a predicate and removes them from the send queue\n\t */\n\tpublic rejectTransactions(\n\t\tpredicate: (t: Transaction) => boolean,\n\t\terrorMsg: string = `The message has been removed from the queue`,\n\t\terrorCode: ZWaveErrorCodes = ZWaveErrorCodes.Controller_MessageDropped,\n\t): void {\n\t\tthis.reduceQueues((transaction, _source) => {\n\t\t\tif (predicate(transaction)) {\n\t\t\t\treturn {\n\t\t\t\t\ttype: \"reject\",\n\t\t\t\t\tmessage: errorMsg,\n\t\t\t\t\tcode: errorCode,\n\t\t\t\t};\n\t\t\t} else {\n\t\t\t\treturn { type: \"keep\" };\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * @internal\n\t * Rejects all pending transactions for a node and removes them from the send queue\n\t */\n\tpublic rejectAllTransactionsForNode(\n\t\tnodeId: number,\n\t\terrorMsg: string = `The node is dead`,\n\t\terrorCode: ZWaveErrorCodes = ZWaveErrorCodes.Controller_MessageDropped,\n\t): void {\n\t\tthis.rejectTransactions(\n\t\t\t(t) => t.message.getNodeId() === nodeId,\n\t\t\terrorMsg,\n\t\t\terrorCode,\n\t\t);\n\t}\n\n\t/**\n\t * Pauses the send queue, avoiding commands to be sent to the controller\n\t */\n\tprivate pauseSendQueue(): void {\n\t\tthis.queuePaused = true;\n\t}\n\n\t/**\n\t * Unpauses the send queue, allowing commands to be sent to the controller again\n\t */\n\tprivate unpauseSendQueue(): void {\n\t\tthis.queuePaused = false;\n\t\tthis.triggerQueues();\n\t}\n\n\tprivate reduceQueues(reducer: TransactionReducer): void {\n\t\tfor (const queue of this.queues) {\n\t\t\tthis.reduceQueue(queue, reducer);\n\t\t}\n\t}\n\n\tprivate reduceQueue(\n\t\tqueue: TransactionQueue,\n\t\treducer: TransactionReducer,\n\t): void {\n\t\tconst dropQueued: Transaction[] = [];\n\t\tlet stopActive: Transaction | undefined;\n\t\tconst requeue: Transaction[] = [];\n\n\t\tconst reduceTransaction: (\n\t\t\t...args: Parameters<TransactionReducer>\n\t\t) => void = (transaction, source) => {\n\t\t\tconst reducerResult = reducer(transaction, source);\n\t\t\tswitch (reducerResult.type) {\n\t\t\t\tcase \"drop\":\n\t\t\t\t\tif (source === \"queue\") {\n\t\t\t\t\t\tdropQueued.push(transaction);\n\n\t\t\t\t\t\t// This will silently drop the transaction, so awaiting it will never resolve.\n\t\t\t\t\t\t// At least notify the listeners about it.\n\t\t\t\t\t\ttransaction.setProgress({\n\t\t\t\t\t\t\tstate: TransactionState.Failed,\n\t\t\t\t\t\t\treason: \"The message was dropped\",\n\t\t\t\t\t\t});\n\t\t\t\t\t} else {\n\t\t\t\t\t\tstopActive = transaction;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"requeue\":\n\t\t\t\t\tif (reducerResult.priority != undefined) {\n\t\t\t\t\t\ttransaction.priority = reducerResult.priority;\n\t\t\t\t\t}\n\t\t\t\t\tif (reducerResult.tag != undefined) {\n\t\t\t\t\t\ttransaction.tag = reducerResult.tag;\n\t\t\t\t\t}\n\t\t\t\t\tif (reducerResult.reset) {\n\t\t\t\t\t\ttransaction.reset();\n\t\t\t\t\t}\n\t\t\t\t\tif (source === \"active\") stopActive = transaction;\n\t\t\t\t\trequeue.push(transaction);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"resolve\":\n\t\t\t\t\tthis.resolveTransaction(transaction, reducerResult.message);\n\t\t\t\t\tif (source === \"queue\") {\n\t\t\t\t\t\tdropQueued.push(transaction);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tstopActive = transaction;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"reject\":\n\t\t\t\t\tthis.rejectTransaction(\n\t\t\t\t\t\ttransaction,\n\t\t\t\t\t\tnew ZWaveError(\n\t\t\t\t\t\t\treducerResult.message,\n\t\t\t\t\t\t\treducerResult.code,\n\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\ttransaction.stack,\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t\tif (source === \"queue\") {\n\t\t\t\t\t\tdropQueued.push(transaction);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tstopActive = transaction;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t};\n\n\t\tfor (const transaction of queue.transactions) {\n\t\t\treduceTransaction(transaction, \"queue\");\n\t\t}\n\n\t\tif (queue.currentTransaction) {\n\t\t\treduceTransaction(queue.currentTransaction, \"active\");\n\t\t}\n\n\t\t// Now we know what to do with the transactions\n\t\tqueue.remove(...dropQueued, ...requeue);\n\t\tconst requeued = requeue.map((t) => t.clone());\n\t\tqueue.add(...requeued);\n\n\t\t// Notify listeners about re-queued transactions\n\t\tfor (const t of requeued) {\n\t\t\tt.setProgress({ state: TransactionState.Queued });\n\t\t}\n\n\t\t// Abort ongoing SendData messages that should be dropped\n\t\tif (isSendData(stopActive?.message)) {\n\t\t\tvoid this.abortSendData();\n\t\t}\n\t}\n\n\t/** @internal */\n\tpublic resolvePendingPings(nodeId: number): void {\n\t\t// When a previously sleeping node sends a NIF after a ping was sent to it, but not acknowledged yet,\n\t\t// the node is awake, but the ping would fail. Resolve pending pings, so communication can continue.\n\t\tfor (const { currentTransaction } of this.queues) {\n\t\t\tif (!currentTransaction) continue;\n\t\t\tconst msg = currentTransaction.parts.current;\n\t\t\tif (!!msg && messageIsPing(msg) && msg.getNodeId() === nodeId) {\n\t\t\t\t// The pending transaction is a ping. Short-circuit its message generator by throwing something that's not an error\n\t\t\t\tcurrentTransaction.abort(undefined);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * @internal\n\t * Helper function to read and convert potentially existing values from the network cache\n\t */\n\tpublic cacheGet<T>(\n\t\tcacheKey: string,\n\t\toptions?: {\n\t\t\treviver?: (value: any) => T;\n\t\t},\n\t): T | undefined {\n\t\tlet ret = this.networkCache.get(cacheKey);\n\t\tif (ret !== undefined && typeof options?.reviver === \"function\") {\n\t\t\ttry {\n\t\t\t\tret = options.reviver(ret);\n\t\t\t} catch {\n\t\t\t\t// ignore, invalid entry\n\t\t\t}\n\t\t}\n\t\treturn ret;\n\t}\n\n\t/**\n\t * @internal\n\t * Helper function to convert values and write them to the network cache\n\t */\n\tpublic cacheSet<T>(\n\t\tcacheKey: string,\n\t\tvalue: T | undefined,\n\t\toptions?: {\n\t\t\tserializer?: (value: T) => any;\n\t\t},\n\t): void {\n\t\tif (value !== undefined && typeof options?.serializer === \"function\") {\n\t\t\tvalue = options.serializer(value);\n\t\t}\n\n\t\tif (value === undefined) {\n\t\t\tthis.networkCache.delete(cacheKey);\n\t\t} else {\n\t\t\tthis.networkCache.set(cacheKey, value);\n\t\t}\n\t}\n\n\t/**\n\t * @internal\n\t * Helper function to find multiple existing values from the network cache\n\t */\n\tpublic cacheList<T>(\n\t\tprefix: string,\n\t\toptions?: {\n\t\t\treviver?: (value: any) => T;\n\t\t},\n\t): Record<string, T> {\n\t\tconst ret: Record<string, T> = {};\n\t\tfor (const entry of this.networkCache.entries()) {\n\t\t\tconst key = entry[0];\n\t\t\tif (!key.startsWith(prefix)) continue;\n\t\t\tlet value = entry[1];\n\t\t\tif (value === undefined) continue;\n\t\t\tif (typeof options?.reviver === \"function\") {\n\t\t\t\ttry {\n\t\t\t\t\tvalue = options.reviver(value);\n\t\t\t\t} catch {\n\t\t\t\t\t// invalid entry\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\t\t\tret[key] = value;\n\t\t}\n\t\treturn ret;\n\t}\n\n\tprivate cachePurge(prefix: string): void {\n\t\tfor (const key of this.networkCache.keys()) {\n\t\t\tif (key.startsWith(prefix)) {\n\t\t\t\tthis.networkCache.delete(key);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Restores a previously stored Z-Wave network state from cache to speed up the startup process\n\t */\n\tpublic async restoreNetworkStructureFromCache(): Promise<void> {\n\t\tif (\n\t\t\t!this._controller\n\t\t\t|| !this.controller.homeId\n\t\t\t|| !this._networkCache\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (this._networkCache.size <= 1) {\n\t\t\t// If the size is 0 or 1, the cache is empty, so we cannot restore it\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tthis.driverLog.print(\n\t\t\t\t`Cache file for homeId ${\n\t\t\t\t\tnum2hex(\n\t\t\t\t\t\tthis.controller.homeId,\n\t\t\t\t\t)\n\t\t\t\t} found, attempting to restore the network from cache...`,\n\t\t\t);\n\t\t\tawait this.controller.deserialize();\n\t\t\tthis.driverLog.print(\n\t\t\t\t`Restoring the network from cache was successful!`,\n\t\t\t);\n\t\t} catch (e) {\n\t\t\tconst message = `Restoring the network from cache failed: ${\n\t\t\t\tgetErrorMessage(\n\t\t\t\t\te,\n\t\t\t\t\ttrue,\n\t\t\t\t)\n\t\t\t}`;\n\t\t\tthis.emit(\n\t\t\t\t\"error\",\n\t\t\t\tnew ZWaveError(message, ZWaveErrorCodes.Driver_InvalidCache),\n\t\t\t);\n\t\t\tthis.driverLog.print(message, \"error\");\n\t\t}\n\t}\n\n\tprivate sendNodeToSleepTimers = new Map<number, NodeJS.Timeout>();\n\t/**\n\t * @internal\n\t * Marks a node for a later sleep command. Every call refreshes the period until the node actually goes to sleep\n\t */\n\tpublic debounceSendNodeToSleep(\n\t\tnode: ZWaveNodeBase & SchedulePoll & NodeValues & NodeWakeup,\n\t): void {\n\t\t// TODO: This should be a single command to the send thread\n\t\t// Delete old timers if any exist\n\t\tif (this.sendNodeToSleepTimers.has(node.id)) {\n\t\t\tclearTimeout(this.sendNodeToSleepTimers.get(node.id));\n\t\t}\n\n\t\t// Sends a node to sleep if it has no more messages.\n\t\tconst sendNodeToSleep = (\n\t\t\tnode: ZWaveNodeBase & SchedulePoll & NodeWakeup,\n\t\t): void => {\n\t\t\tthis.sendNodeToSleepTimers.delete(node.id);\n\t\t\tif (!this.hasPendingMessages(node)) {\n\t\t\t\tvoid node.sendNoMoreInformation().catch(() => {\n\t\t\t\t\t/* ignore errors */\n\t\t\t\t});\n\t\t\t}\n\t\t};\n\n\t\t// If a sleeping node has no messages pending (and supports the Wake Up CC), we may send it back to sleep\n\t\tif (\n\t\t\tnode.supportsCC(CommandClasses[\"Wake Up\"])\n\t\t\t&& !this.hasPendingMessages(node)\n\t\t) {\n\t\t\tconst wakeUpInterval = node.getValue<number>(\n\t\t\t\tWakeUpCCValues.wakeUpInterval.id,\n\t\t\t);\n\t\t\t// GH#2179: when a device only wakes up manually, don't send it back to sleep\n\t\t\t// Best case, the user wanted to interact with it.\n\t\t\t// Worst case, the device won't ACK this and cause a delay\n\t\t\tif (wakeUpInterval !== 0) {\n\t\t\t\tthis.sendNodeToSleepTimers.set(\n\t\t\t\t\tnode.id,\n\t\t\t\t\tsetTimeout(\n\t\t\t\t\t\t() => sendNodeToSleep(node),\n\t\t\t\t\t\tthis.options.timeouts.sendToSleep,\n\t\t\t\t\t).unref(),\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\t/** Computes the maximum net CC payload size for the given CC or SendDataRequest */\n\tpublic computeNetCCPayloadSize(\n\t\tcommandOrMsg:\n\t\t\t| CommandClass\n\t\t\t| (SendDataRequest | SendDataBridgeRequest) & ContainsCC,\n\t\tignoreEncapsulation: boolean = false,\n\t): number {\n\t\t// Recreate the correct encapsulation structure\n\t\tlet msg: (SendDataRequest | SendDataBridgeRequest) & ContainsCC;\n\t\tif (isSendDataSinglecast(commandOrMsg)) {\n\t\t\tmsg = commandOrMsg;\n\t\t} else {\n\t\t\tconst SendDataConstructor = this.getSendDataSinglecastConstructor();\n\t\t\tmsg = new SendDataConstructor({\n\t\t\t\tsourceNodeId: this.ownNodeId,\n\t\t\t\tcommand: commandOrMsg,\n\t\t\t}) as (SendDataRequest | SendDataBridgeRequest) & ContainsCC;\n\t\t}\n\t\tif (!ignoreEncapsulation) {\n\t\t\tmsg.command = this.encapsulateCommands(\n\t\t\t\tmsg.command,\n\t\t\t) as SinglecastCC<CommandClass>;\n\t\t}\n\t\treturn msg.command.getMaxPayloadLength(this.getMaxPayloadLength(msg));\n\t}\n\n\t/** Computes the maximum payload size that can be transmitted with the given message */\n\tpublic getMaxPayloadLength(msg: SendDataMessage): number {\n\t\tconst nodeId = msg.getNodeId();\n\n\t\t// For ZWLR, the result is simply the maximum payload size\n\t\tif (\n\t\t\tnodeId != undefined\n\t\t\t&& isLongRangeNodeId(nodeId)\n\t\t\t&& this._controller?.maxPayloadSizeLR\n\t\t) {\n\t\t\treturn this._controller.maxPayloadSizeLR;\n\t\t}\n\n\t\t// For ZW Classic, it depends on the frame type and transmit options\n\t\tconst maxExplorerPayloadSinglecast = this._controller?.maxPayloadSize\n\t\t\t?? 46;\n\t\tif (isSendDataSinglecast(msg)) {\n\t\t\t// From INS13954-7, chapter 4.3.3.1.5\n\t\t\tif (msg.transmitOptions & TransmitOptions.Explore) {\n\t\t\t\treturn maxExplorerPayloadSinglecast;\n\t\t\t}\n\t\t\tif (msg.transmitOptions & TransmitOptions.AutoRoute) {\n\t\t\t\treturn maxExplorerPayloadSinglecast + 2;\n\t\t\t}\n\t\t\treturn maxExplorerPayloadSinglecast + 8;\n\t\t} else {\n\t\t\t// Multicast needs space for the nodes bitmask\n\t\t\tconst maxExplorerPayloadMulticast = maxExplorerPayloadSinglecast\n\t\t\t\t- NUM_NODEMASK_BYTES;\n\n\t\t\t// From INS13954-13, chapter 4.3.3.6\n\t\t\tif (msg.transmitOptions & TransmitOptions.ACK) {\n\t\t\t\tif (msg.transmitOptions & TransmitOptions.Explore) {\n\t\t\t\t\treturn maxExplorerPayloadMulticast;\n\t\t\t\t}\n\t\t\t\tif (msg.transmitOptions & TransmitOptions.AutoRoute) {\n\t\t\t\t\treturn maxExplorerPayloadMulticast + 2;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn maxExplorerPayloadMulticast + 8;\n\t\t}\n\t}\n\n\tpublic async exceedsMaxPayloadLength(\n\t\tmsg: SendDataMessage,\n\t): Promise<boolean> {\n\t\tconst serializedCC = await msg.serializeCCAsync(\n\t\t\tthis.getEncodingContext(),\n\t\t);\n\t\treturn serializedCC.length > this.getMaxPayloadLength(msg);\n\t}\n\n\t/** Determines time in milliseconds to wait for a report from a node */\n\tpublic getReportTimeout(msg: Message): number {\n\t\tconst node = this.tryGetNode(msg);\n\n\t\treturn (\n\t\t\t// If there's a message-specific timeout, use that\n\t\t\tmsg.nodeUpdateTimeout\n\t\t\t\t// If the node has a compat flag to override the timeout, use that\n\t\t\t\t?? node?.deviceConfig?.compat?.reportTimeout\n\t\t\t\t// otherwise use the driver option\n\t\t\t\t?? this._options.timeouts.report\n\t\t);\n\t}\n\n\t/** Returns the preferred constructor to use for singlecast SendData commands */\n\tpublic getSendDataSinglecastConstructor():\n\t\t| typeof SendDataRequest\n\t\t| typeof SendDataBridgeRequest\n\t{\n\t\treturn this._controller?.isFunctionSupported(\n\t\t\t\tFunctionType.SendDataBridge,\n\t\t\t)\n\t\t\t? SendDataBridgeRequest\n\t\t\t: SendDataRequest;\n\t}\n\n\t/** Returns the preferred constructor to use for multicast SendData commands */\n\tpublic getSendDataMulticastConstructor():\n\t\t| typeof SendDataMulticastRequest\n\t\t| typeof SendDataMulticastBridgeRequest\n\t{\n\t\treturn this._controller?.isFunctionSupported(\n\t\t\t\tFunctionType.SendDataMulticastBridge,\n\t\t\t)\n\t\t\t? SendDataMulticastBridgeRequest\n\t\t\t: SendDataMulticastRequest;\n\t}\n\n\t// This does not all need to be printed to the console\n\tpublic [util.inspect.custom](): string {\n\t\treturn \"[Driver]\";\n\t}\n\n\t/**\n\t * Checks whether there is a compatible update for the currently installed config package.\n\t * Returns the new version if there is an update, `undefined` otherwise.\n\t */\n\tpublic async checkForConfigUpdates(\n\t\tsilent: boolean = false,\n\t): Promise<string | undefined> {\n\t\tthis.ensureReady();\n\n\t\ttry {\n\t\t\tif (!silent) {\n\t\t\t\tthis.driverLog.print(\"Checking for configuration updates...\");\n\t\t\t}\n\t\t\tconst ret = await checkForConfigUpdates(this.configVersion);\n\t\t\tif (ret) {\n\t\t\t\tif (!silent) {\n\t\t\t\t\tthis.driverLog.print(\n\t\t\t\t\t\t`Configuration update available: ${ret}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (!silent) {\n\t\t\t\t\tthis.driverLog.print(\n\t\t\t\t\t\t\"No configuration update available...\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn ret;\n\t\t} catch (e) {\n\t\t\tthis.driverLog.print(getErrorMessage(e), \"error\");\n\t\t}\n\t}\n\n\t/**\n\t * Installs an update for the embedded configuration DB if there is a compatible one.\n\t * Returns `true` when an update was installed, `false` otherwise.\n\t *\n\t * **Note:** Bugfixes and changes to device configuration generally require a restart or re-interview to take effect.\n\t */\n\tpublic async installConfigUpdate(): Promise<boolean> {\n\t\tthis.ensureReady();\n\n\t\tconst newVersion = await this.checkForConfigUpdates(true);\n\t\tif (!newVersion) return false;\n\n\t\tconst extConfigDir = this.configManager.externalConfigDir;\n\t\tif (!this.configManager.useExternalConfig || !extConfigDir) {\n\t\t\tthis.driverLog.print(\n\t\t\t\t`Cannot update configuration DB update - external config directory is not set`,\n\t\t\t\t\"error\",\n\t\t\t);\n\t\t\treturn false;\n\t\t}\n\n\t\tthis.driverLog.print(\n\t\t\t`Installing version ${newVersion} of configuration DB...`,\n\t\t);\n\t\ttry {\n\t\t\tawait installConfigUpdate(newVersion, {\n\t\t\t\tcacheDir: this.cacheDir,\n\t\t\t\tconfigDir: extConfigDir,\n\t\t\t});\n\t\t} catch (e) {\n\t\t\tthis.driverLog.print(getErrorMessage(e), \"error\");\n\t\t\treturn false;\n\t\t}\n\t\tthis.driverLog.print(\n\t\t\t`Configuration DB updated to version ${newVersion}, activating...`,\n\t\t);\n\n\t\t// Reload the config files\n\t\tawait this.configManager.loadAll();\n\n\t\t// Now try to apply them to all known devices\n\t\tif (this._controller) {\n\t\t\tfor (const node of this._controller.nodes.values()) {\n\t\t\t\tif (node.ready) {\n\t\t\t\t\tawait node[\"loadDeviceConfig\"]();\n\t\t\t\t\t// TODO: If the device config did change, expose this information\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn true;\n\t}\n\n\tprivate _enteringBootloader: boolean = false;\n\tprivate _enterBootloaderPromise: DeferredPromise<void> | undefined;\n\n\t/** @internal */\n\tpublic async enterBootloader(): Promise<void> {\n\t\tthis.controllerLog.print(\"Entering bootloader...\");\n\t\tthis._enteringBootloader = true;\n\t\ttry {\n\t\t\t// await this.controller.toggleRF(false);\n\t\t\t// Avoid re-transmissions etc. communicating with the bootloader\n\t\t\tawait this.scheduler.removeTasks(\n\t\t\t\t() => true,\n\t\t\t\tnew ZWaveError(\n\t\t\t\t\t\"The controller is entering bootloader mode.\",\n\t\t\t\t\tZWaveErrorCodes.Driver_TaskRemoved,\n\t\t\t\t),\n\t\t\t);\n\n\t\t\tthis.rejectTransactions(\n\t\t\t\t(_t) => true,\n\t\t\t\t\"The controller is entering bootloader mode.\",\n\t\t\t);\n\n\t\t\tawait this.trySoftReset();\n\t\t\tthis.pauseSendQueue();\n\n\t\t\t// Again, just to be very sure\n\t\t\tthis.rejectTransactions(\n\t\t\t\t(_t) => true,\n\t\t\t\t\"The controller is entering bootloader mode.\",\n\t\t\t);\n\n\t\t\t// It would be nicer to not hardcode the command here, but since we're switching stream parsers\n\t\t\t// mid-command - thus ignoring the ACK, we can't really use the existing communication machinery\n\t\t\tconst promise = this.writeSerial(Bytes.from(\"01030027db\", \"hex\"));\n\t\t\tthis.serial!.mode = ZWaveSerialMode.Bootloader;\n\t\t\tawait promise;\n\n\t\t\t// Wait if the menu shows up\n\t\t\tthis._enterBootloaderPromise = createDeferredPromise();\n\t\t\tconst success = await Promise.race([\n\t\t\t\tthis._enterBootloaderPromise.then(() => true),\n\t\t\t\twait(5000, true).then(() => false),\n\t\t\t]);\n\t\t\tif (success) {\n\t\t\t\tthis.controllerLog.print(\"Entered bootloader\");\n\t\t\t} else {\n\t\t\t\tthrow new ZWaveError(\n\t\t\t\t\t\"Failed to enter bootloader\",\n\t\t\t\t\tZWaveErrorCodes.Controller_Timeout,\n\t\t\t\t);\n\t\t\t}\n\t\t} finally {\n\t\t\tthis._enteringBootloader = false;\n\t\t}\n\t}\n\n\tprivate leaveBootloaderInternal(): Promise<void> {\n\t\tconst promise = this.bootloader.runApplication();\n\t\t// Reset the known serial mode. We might end up in serial or bootloader mode afterwards.\n\t\tthis.serial!.mode = undefined;\n\t\tthis._bootloader = undefined;\n\t\treturn promise;\n\t}\n\n\t/**\n\t * @internal\n\t * Leaves the bootloader and destroys the driver instance if desired\n\t */\n\tpublic async leaveBootloader(destroy: boolean = false): Promise<void> {\n\t\tthis.controllerLog.print(\"Leaving bootloader...\");\n\t\tawait this.leaveBootloaderInternal();\n\n\t\t// TODO: do we need to wait here?\n\n\t\tif (destroy) {\n\t\t\tconst restartReason = \"Restarting driver after OTW update...\";\n\t\t\tthis.controllerLog.print(restartReason);\n\n\t\t\tawait this.destroy();\n\n\t\t\t// Let the async calling context finish before emitting the error\n\t\t\tprocess.nextTick(() => {\n\t\t\t\tthis.emit(\n\t\t\t\t\t\"error\",\n\t\t\t\t\tnew ZWaveError(\n\t\t\t\t\t\trestartReason,\n\t\t\t\t\t\tZWaveErrorCodes.Driver_Failed,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t});\n\t\t} else {\n\t\t\tthis.unpauseSendQueue();\n\t\t\tawait this.ensureSerialAPI();\n\t\t}\n\t}\n\n\tprivate serialport_onBootloaderData(data: BootloaderChunk): void {\n\t\tswitch (data.type) {\n\t\t\tcase BootloaderChunkType.Message: {\n\t\t\t\tthis.controllerLog.print(\n\t\t\t\t\t`[BOOTLOADER] ${data.message}`,\n\t\t\t\t\t\"verbose\",\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase BootloaderChunkType.FlowControl: {\n\t\t\t\tif (data.command === XModemMessageHeaders.C) {\n\t\t\t\t\tthis.controllerLog.print(\n\t\t\t\t\t\t`[BOOTLOADER] awaiting input...`,\n\t\t\t\t\t\t\"verbose\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\t// Check if there is a handler waiting for this chunk\n\t\tfor (const entry of this.awaitedBootloaderChunks) {\n\t\t\tif (entry.predicate(data)) {\n\t\t\t\t// there is!\n\t\t\t\tentry.handler(data);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\tif (!this._bootloader && data.type === BootloaderChunkType.Menu) {\n\t\t\t// We just entered the bootloader\n\t\t\tthis.controllerLog.print(\n\t\t\t\t`[BOOTLOADER] version ${data.version}`,\n\t\t\t\t\"verbose\",\n\t\t\t);\n\n\t\t\tthis._bootloader = new Bootloader(\n\t\t\t\tthis.writeSerial.bind(this),\n\t\t\t\tdata.version,\n\t\t\t\tdata.options,\n\t\t\t);\n\t\t\tif (this._enterBootloaderPromise) {\n\t\t\t\tthis._enterBootloaderPromise.resolve();\n\t\t\t\tthis._enterBootloaderPromise = undefined;\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Waits until a specific chunk is received from the bootloader or a timeout has elapsed. Returns the received chunk.\n\t * @param timeout The number of milliseconds to wait. If the timeout elapses, the returned promise will be rejected\n\t * @param predicate A predicate function to test all incoming chunks\n\t */\n\tpublic waitForBootloaderChunk<T extends BootloaderChunk>(\n\t\tpredicate: (chunk: BootloaderChunk) => boolean,\n\t\ttimeout: number,\n\t): Promise<T> {\n\t\treturn new Promise<T>((resolve, reject) => {\n\t\t\tconst promise = createDeferredPromise<BootloaderChunk>();\n\t\t\tconst entry: AwaitedBootloaderChunkEntry = {\n\t\t\t\tpredicate,\n\t\t\t\thandler: (chunk) => promise.resolve(chunk),\n\t\t\t\ttimeout: undefined,\n\t\t\t};\n\t\t\tthis.awaitedBootloaderChunks.push(entry);\n\t\t\tconst removeEntry = () => {\n\t\t\t\tif (entry.timeout) clearTimeout(entry.timeout);\n\t\t\t\tconst index = this.awaitedBootloaderChunks.indexOf(entry);\n\t\t\t\tif (index !== -1) this.awaitedBootloaderChunks.splice(index, 1);\n\t\t\t};\n\t\t\t// When the timeout elapses, remove the wait entry and reject the returned Promise\n\t\t\tentry.timeout = setTimeout(() => {\n\t\t\t\tremoveEntry();\n\t\t\t\treject(\n\t\t\t\t\tnew ZWaveError(\n\t\t\t\t\t\t`Received no matching chunk within the provided timeout!`,\n\t\t\t\t\t\tZWaveErrorCodes.Controller_Timeout,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t}, timeout);\n\t\t\t// When the promise is resolved, remove the wait entry and resolve the returned Promise\n\t\t\tvoid promise.then((chunk) => {\n\t\t\t\tremoveEntry();\n\t\t\t\tresolve(chunk as T);\n\t\t\t});\n\t\t});\n\t}\n\n\tprivate pollBackgroundRSSITimer: NodeJS.Timeout | undefined;\n\tprivate lastBackgroundRSSITimestamp = 0;\n\n\tprivate handleQueueIdleChange(idle: boolean): void {\n\t\tif (!this.ready) return;\n\t\tif (\n\t\t\tthis.controller.isFunctionSupported(FunctionType.GetBackgroundRSSI)\n\t\t) {\n\t\t\t// When the send thread stays idle for 5 seconds, poll the background RSSI, but at most every 30s\n\t\t\tif (idle) {\n\t\t\t\tconst timeout = Math.max(\n\t\t\t\t\t// Wait at least 5s\n\t\t\t\t\t5000,\n\t\t\t\t\t// and up to 30s if we recently queried the RSSI\n\t\t\t\t\t30_000 - (Date.now() - this.lastBackgroundRSSITimestamp),\n\t\t\t\t);\n\t\t\t\tthis.pollBackgroundRSSITimer = setTimeout(async () => {\n\t\t\t\t\t// Due to the timeout, the driver might have been destroyed in the meantime\n\t\t\t\t\tif (!this.ready) return;\n\n\t\t\t\t\tthis.lastBackgroundRSSITimestamp = Date.now();\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait this.controller.getBackgroundRSSI();\n\t\t\t\t\t} catch {\n\t\t\t\t\t\t// ignore errors\n\t\t\t\t\t}\n\t\t\t\t}, timeout).unref();\n\t\t\t} else {\n\t\t\t\tclearTimeout(this.pollBackgroundRSSITimer);\n\t\t\t\tthis.pollBackgroundRSSITimer = undefined;\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate _powerlevelTestNodeContext: {\n\t\ttestNodeId: number;\n\t\ttimeout: NodeJS.Timeout | undefined;\n\t\tacknowledgedFrames: number;\n\t} | undefined;\n\n\t/**\n\t * @internal\n\t * Begins a powerlevel test for the given node using NOP power frames\n\t */\n\tpublic async sendNOPPowerFrames(\n\t\ttestNodeId: number,\n\t\tpowerlevel: Powerlevel,\n\t\tframeCount: number,\n\t): Promise<number> {\n\t\tif (this._powerlevelTestNodeContext) {\n\t\t\t// Cancel the previous test\n\t\t\tclearTimeout(this._powerlevelTestNodeContext.timeout);\n\t\t\tthis._powerlevelTestNodeContext = undefined;\n\t\t}\n\n\t\tif (frameCount < 1) return 0;\n\n\t\tconst ret = createDeferredPromise<number>();\n\n\t\tconst context = {\n\t\t\ttestNodeId,\n\t\t\tacknowledgedFrames: 0,\n\t\t\t// This is set below after defining sendFrame\n\t\t\ttimeout: undefined as NodeJS.Timeout | undefined,\n\t\t};\n\t\tthis._powerlevelTestNodeContext = context;\n\n\t\t// We're expected to send these pretty quickly (260 frames in 25s for the CTT test)\n\t\tconst interval = 50;\n\n\t\tconst sendFrame = async () => {\n\t\t\tconst result = await this.sendTestFrame(testNodeId, powerlevel);\n\t\t\tif (result === TransmitStatus.OK) {\n\t\t\t\tcontext.acknowledgedFrames++;\n\t\t\t}\n\t\t\tframeCount--;\n\n\t\t\tif (frameCount > 0) {\n\t\t\t\tcontext.timeout = setTimeout(sendFrame, interval);\n\t\t\t} else {\n\t\t\t\tcontext.timeout = undefined;\n\t\t\t\tret.resolve(context.acknowledgedFrames);\n\t\t\t}\n\t\t};\n\n\t\tcontext.timeout = setTimeout(sendFrame, interval);\n\n\t\treturn ret;\n\t}\n\n\t/** Sends a NOP Power frame to the given node and returns the transmit status if the frame was sent */\n\tpublic async sendTestFrame(\n\t\tnodeId: number,\n\t\tpowerlevel: Powerlevel,\n\t): Promise<TransmitStatus | undefined> {\n\t\tconst result = await this.sendMessage<\n\t\t\tMessage & SuccessIndicator\n\t\t>(\n\t\t\tnew SendTestFrameRequest({\n\t\t\t\ttestNodeId: nodeId,\n\t\t\t\tpowerlevel,\n\t\t\t}),\n\t\t);\n\n\t\tif (result instanceof SendTestFrameTransmitReport) {\n\t\t\treturn result.transmitStatus;\n\t\t}\n\t}\n\n\t/**\n\t * @internal\n\t * Returns the status of a potentially ongoing NOP power test\n\t */\n\tpublic getNOPPowerTestStatus(): {\n\t\ttestNodeId: number;\n\t\tinProgress: boolean;\n\t\tacknowledgedFrames: number;\n\t} | undefined {\n\t\tif (this._powerlevelTestNodeContext) {\n\t\t\treturn {\n\t\t\t\tinProgress: !!this._powerlevelTestNodeContext.timeout,\n\t\t\t\ttestNodeId: this._powerlevelTestNodeContext.testNodeId,\n\t\t\t\tacknowledgedFrames:\n\t\t\t\t\tthis._powerlevelTestNodeContext.acknowledgedFrames,\n\t\t\t};\n\t\t}\n\t}\n\n\t/**\n\t * Resets the S2 singlecast encryption state (SPAN) for the given node, which forces\n\t * a re-synchronization on the next communication attempt.\n\t */\n\tpublic resetSPAN(nodeId: number): void {\n\t\tthis.getSecurityManager2(nodeId)?.deleteNonce(nodeId);\n\t}\n\n\t/**\n\t * Resets the S2 singlecast encryption state (SPAN) for all nodes, which forces\n\t * a re-synchronization on the next communication attempt.\n\t */\n\tpublic resetAllSPANs(): void {\n\t\tfor (const nodeId of this.controller.nodes.keys()) {\n\t\t\tthis.resetSPAN(nodeId);\n\t\t}\n\t}\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;AAAA,sBAA6C;AAC7C,g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