import { MessageOrCCLogEntry , ZWaveError , ZWaveErrorCodes , } from "@zwave-js/core" ; import { getEnumMemberName , JSONObject } from "@zwave-js/shared" ; import type { Driver } from "../driver/Driver" ; import { FunctionType , MessagePriority , MessageType , } from "../message/Constants" ; import { expectedCallback , expectedResponse , gotDeserializationOptions , Message , MessageBaseOptions , MessageDeserializationOptions , MessageOptions , messageTypes , priority , } from "../message/Message" ; import type { SuccessIndicator } from "../message/SuccessIndicator" ; import type { INodeQuery } from "../node/INodeQuery" ; import { TransmitStatus } from "./SendDataShared" ; @ messageTypes ( MessageType . Request , FunctionType . DeleteReturnRoute ) @ priority ( MessagePriority . Normal ) export class DeleteReturnRouteRequestBase extends Message { public constructor ( driver , options ) { if ( gotDeserializationOptions ( options ) && ( new . target as any ) !== DeleteReturnRouteRequestTransmitReport ) { return new DeleteReturnRouteRequestTransmitReport ( driver , options ) ; } super ( driver , options ) ; } } export interface DeleteReturnRouteRequestOptions extends MessageBaseOptions { nodeId : number ; } @ expectedResponse ( FunctionType . DeleteReturnRoute ) @ expectedCallback ( FunctionType . DeleteReturnRoute ) export class DeleteReturnRouteRequest extends DeleteReturnRouteRequestBase implements INodeQuery { public constructor ( driver , options ) { super ( driver , options ) ; if ( gotDeserializationOptions ( options ) ) { throw new ZWaveError ( `${ this . constructor . name }: deserialization not implemented` , ZWaveErrorCodes . Deserialization_NotImplemented ) ; } else { this . nodeId = options . nodeId ; } } public nodeId : number ; public serialize ( ) { this . payload = Buffer . from ( [ this . nodeId , this . callbackId ] ) ; return super . serialize ( ) ; } } @ messageTypes ( MessageType . Response , FunctionType . DeleteReturnRoute ) export class DeleteReturnRouteResponse extends Message implements SuccessIndicator { public constructor ( driver , options ) { super ( driver , options ) ; this . hasStarted = this . payload [ 0 ] !== 0 ; } public isOK ( ) { return this . hasStarted ; } public readonly hasStarted : boolean ; public toJSON ( ) { return super . toJSONInherited ( { hasStarted : this . hasStarted } ) ; } public toLogEntry ( ) { return { ... super . toLogEntry ( ) , message : { "has started" : this . hasStarted } } ; } } export class DeleteReturnRouteRequestTransmitReport extends DeleteReturnRouteRequestBase implements SuccessIndicator { public constructor ( driver , options ) { super ( driver , options ) ; this . callbackId = this . payload [ 0 ] ; this . _transmitStatus = this . payload [ 1 ] ; } private _transmitStatus : TransmitStatus ; public get transmitStatus ( ) : TransmitStatus { return this . _transmitStatus ; } public isOK ( ) { return this . _transmitStatus === TransmitStatus . OK ; } public toJSON ( ) { return super . toJSONInherited ( { callbackId : this . callbackId , transmitStatus : this . transmitStatus } ) ; } public toLogEntry ( ) { return { ... super . toLogEntry ( ) , message : { "callback id" : this . callbackId , "transmit status" : getEnumMemberName ( TransmitStatus , this . transmitStatus ) } } ; } }