pl.grzeslowski.jsupla.protocol.api.decoders.scs.DeviceConfigDecoder 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'
The newest version!
package pl.grzeslowski.jsupla.protocol.api.decoders.scs;
import lombok.val;
import pl.grzeslowski.jsupla.protocol.api.decoders.PrimitiveDecoder;
import pl.grzeslowski.jsupla.protocol.api.structs.scs.DeviceConfig;
import static pl.grzeslowski.jsupla.protocol.api.JavaConsts.*;
import static pl.grzeslowski.jsupla.protocol.api.consts.ProtoConsts.*;
@javax.annotation.Generated(value="Struct original name: TSCS_DeviceConfig", date = "2024-09-06T08:44:37.700Z[Etc/UTC]")
@lombok.NoArgsConstructor(access = lombok.AccessLevel.PRIVATE)
public class DeviceConfigDecoder implements pl.grzeslowski.jsupla.protocol.api.decoders.scs.ServerClientServerDecoder {
public static final DeviceConfigDecoder INSTANCE = new DeviceConfigDecoder();
@Override
public DeviceConfig decode(byte[] bytes, int offset) {
val deviceId = PrimitiveDecoder.INSTANCE.parseInt(bytes, offset);
offset += INT_SIZE;
val endOfDataFlag = PrimitiveDecoder.INSTANCE.parseUnsignedByte(bytes, offset);
offset += BYTE_SIZE;
val zero = PrimitiveDecoder.INSTANCE.copyOfRangeByteUnsigned(bytes, offset, offset + (int) 8);
offset += 8 * BYTE_SIZE;
val availableFields = PrimitiveDecoder.INSTANCE.parseUnsignedLong(bytes, offset);
offset += LONG_SIZE;
val fields = PrimitiveDecoder.INSTANCE.parseUnsignedLong(bytes, offset);
offset += LONG_SIZE;
val configSize = PrimitiveDecoder.INSTANCE.parseUnsignedShort(bytes, offset);
offset += SHORT_SIZE;
val config = PrimitiveDecoder.INSTANCE.copyOfRangeByte(bytes, offset, offset + (int) configSize);
offset += configSize * BYTE_SIZE;
return new DeviceConfig(deviceId, endOfDataFlag, zero, availableFields, fields, configSize, config);
}
}