pl.grzeslowski.jsupla.protocol.api.encoders.ds.SuplaDeviceChannelExtendedValueEncoder Maven / Gradle / Ivy
package pl.grzeslowski.jsupla.protocol.api.encoders.ds;
import lombok.val;
import pl.grzeslowski.jsupla.protocol.api.encoders.PrimitiveEncoder;
import pl.grzeslowski.jsupla.protocol.api.structs.ds.SuplaDeviceChannelExtendedValue;
import static pl.grzeslowski.jsupla.protocol.api.JavaConsts.*;
import static pl.grzeslowski.jsupla.protocol.api.consts.ProtoConsts.*;
@javax.annotation.Generated(value="Struct original name: TDS_SuplaDeviceChannelExtendedValue", date = "2024-08-03T11:49:42.065Z[Etc/UTC]")
@lombok.NoArgsConstructor(access = lombok.AccessLevel.PRIVATE)
public class SuplaDeviceChannelExtendedValueEncoder implements pl.grzeslowski.jsupla.protocol.api.encoders.ds.DeviceServerEncoder {
public static final SuplaDeviceChannelExtendedValueEncoder INSTANCE = new SuplaDeviceChannelExtendedValueEncoder();
@Override
public byte[] encode(SuplaDeviceChannelExtendedValue proto) {
final byte[] bytes = new byte[proto.size()];
int offset = 0;
offset += PrimitiveEncoder.INSTANCE.writeUnsignedByte(proto.channelNumber, bytes, offset);
byte[] valueBytes = pl.grzeslowski.jsupla.protocol.api.encoders.SuplaChannelExtendedValueEncoder.INSTANCE.encode(proto.value);
offset += valueBytes.length;
return bytes;
}
}