import { MessageOrCCLogEntry , ZWaveError , ZWaveErrorCodes , } from "@zwave-js/core" ; import { num2hex } from "@zwave-js/shared" ; import type { Driver } from "../../driver/Driver" ; import { FunctionType , MessagePriority , MessageType , } from "../../message/Constants" ; import { expectedResponse , gotDeserializationOptions , Message , MessageBaseOptions , MessageDeserializationOptions , messageTypes , priority , } from "../../message/Message" ; export interface ExtNVMReadLongByteRequestOptions extends MessageBaseOptions { offset : number ; } @ messageTypes ( MessageType . Request , FunctionType . ExtNVMReadLongByte ) @ priority ( MessagePriority . Controller ) @ expectedResponse ( FunctionType . ExtNVMReadLongByte ) export class ExtNVMReadLongByteRequest extends Message { public constructor ( driver , options ) { super ( driver , options ) ; if ( gotDeserializationOptions ( options ) ) { throw new ZWaveError ( `${ this . constructor . name }: deserialization not implemented` , ZWaveErrorCodes . Deserialization_NotImplemented ) ; } else { if ( options . offset < 0 || options . offset > 0xffffff ) { throw new ZWaveError ( "The offset must be a 24-bit number!" , ZWaveErrorCodes . Argument_Invalid ) ; } this . offset = options . offset ; } } public offset : number ; public serialize ( ) { this . payload = Buffer . allocUnsafe ( 3 ) ; this . payload . writeUIntBE ( this . offset , 0 , 3 ) ; return super . serialize ( ) ; } public toLogEntry ( ) { return { ... super . toLogEntry ( ) , message : { offset : num2hex ( this . offset ) } } ; } } @ messageTypes ( MessageType . Response , FunctionType . ExtNVMReadLongByte ) export class ExtNVMReadLongByteResponse extends Message { public constructor ( driver , options ) { super ( driver , options ) ; this . byte = this . payload [ 0 ] ; } public readonly byte : number ; public toLogEntry ( ) { return { ... super . toLogEntry ( ) , message : { byte : num2hex ( this . byte ) } } ; } }