import type { JSONObject } from "@zwave-js/shared" ; import { ApplicationUpdateRequestNodeInfoReceived , ApplicationUpdateRequestNodeInfoRequestFailed , } from "../controller/ApplicationUpdateRequest" ; import type { Driver } from "../driver/Driver" ; import { FunctionType , MessagePriority , MessageType , } from "../message/Constants" ; import { expectedCallback , expectedResponse , Message , MessageBaseOptions , MessageDeserializationOptions , messageTypes , priority , } from "../message/Message" ; import type { SuccessIndicator } from "../message/SuccessIndicator" ; import type { INodeQuery } from "./INodeQuery" ; function testCallbackForRequestNodeInfoRequest ( sent , received ) { return ( ( received instanceof ApplicationUpdateRequestNodeInfoReceived && received . nodeId === sent . nodeId ) || received instanceof ApplicationUpdateRequestNodeInfoRequestFailed ) ; } interface RequestNodeInfoRequestOptions extends MessageBaseOptions { nodeId : number ; } @ messageTypes ( MessageType . Response , FunctionType . RequestNodeInfo ) export class RequestNodeInfoResponse extends Message implements SuccessIndicator { public constructor ( driver , options ) { super ( driver , options ) ; this . _wasSent = this . payload [ 0 ] !== 0 ; if ( ! this . _wasSent ) this . _errorCode = this . payload [ 0 ] ; } public isOK ( ) { return this . _wasSent ; } private _wasSent : boolean ; public get wasSent ( ) : boolean { return this . _wasSent ; } private _errorCode : number | undefined ; public get errorCode ( ) : number | undefined { return this . _errorCode ; } public toJSON ( ) { return super . toJSONInherited ( { wasSent : this . wasSent , errorCode : this . errorCode } ) ; } } @ messageTypes ( MessageType . Request , FunctionType . RequestNodeInfo ) @ expectedResponse ( RequestNodeInfoResponse ) @ expectedCallback ( testCallbackForRequestNodeInfoRequest ) @ priority ( MessagePriority . NodeQuery ) export class RequestNodeInfoRequest extends Message implements INodeQuery { public constructor ( driver , options ) { super ( driver , options ) ; this . nodeId = options . nodeId ; } public nodeId : number ; public needsCallbackId ( ) { return false ; } public serialize ( ) { this . payload = Buffer . from ( [ this . nodeId ] ) ; return super . serialize ( ) ; } public toJSON ( ) { return super . toJSONInherited ( { nodeId : this . nodeId } ) ; } }