pl.grzeslowski.jsupla.protocol.api.encoders.ds.SuplaDeviceChannelValueBEncoder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of protocol Show documentation
Show all versions of protocol Show documentation
Uploads all artifacts belonging to configuration ':protocol:archives'
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.SuplaDeviceChannelValueB;
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_SuplaDeviceChannelValue_B", date = "2024-07-06T18:57:04.643Z[Etc/UTC]")
@lombok.NoArgsConstructor(access = lombok.AccessLevel.PRIVATE)
public class SuplaDeviceChannelValueBEncoder implements pl.grzeslowski.jsupla.protocol.api.encoders.ds.DeviceServerEncoder {
public static final SuplaDeviceChannelValueBEncoder INSTANCE = new SuplaDeviceChannelValueBEncoder();
@Override
public byte[] encode(SuplaDeviceChannelValueB proto) {
final byte[] bytes = new byte[proto.size()];
int offset = 0;
offset += PrimitiveEncoder.INSTANCE.writeUnsignedByte(proto.channelNumber, bytes, offset);
offset += PrimitiveEncoder.INSTANCE.writeUnsignedByte(proto.offline, bytes, offset);
offset += PrimitiveEncoder.INSTANCE.writeByteArray(proto.value, bytes, offset);
return bytes;
}
}