All Downloads are FREE. Search and download functionalities are using the official Maven repository.

pl.grzeslowski.jsupla.protocol.api.decoders.ChannelConfigOCRDecoder Maven / Gradle / Ivy

The newest version!
package pl.grzeslowski.jsupla.protocol.api.decoders;

import lombok.val;
import pl.grzeslowski.jsupla.protocol.api.decoders.PrimitiveDecoder;
import pl.grzeslowski.jsupla.protocol.api.structs.ChannelConfigOCR;
import static pl.grzeslowski.jsupla.protocol.api.JavaConsts.*;
import static pl.grzeslowski.jsupla.protocol.api.consts.ProtoConsts.*;

@javax.annotation.Generated(value="Struct original name: TChannelConfig_OCR", date = "2024-09-06T08:44:37.664Z[Etc/UTC]")
@lombok.NoArgsConstructor(access = lombok.AccessLevel.PRIVATE)
public class ChannelConfigOCRDecoder implements pl.grzeslowski.jsupla.protocol.api.decoders.ProtoWithSizeDecoder {
	public static final ChannelConfigOCRDecoder INSTANCE = new ChannelConfigOCRDecoder();

    @Override
	public ChannelConfigOCR decode(byte[] bytes, int offset) {
		val authKey = PrimitiveDecoder.INSTANCE.copyOfRangeByte(bytes, offset, offset + (int) SUPLA_OCR_AUTHKEY_SIZE);
		offset += SUPLA_OCR_AUTHKEY_SIZE * BYTE_SIZE;

		val host = PrimitiveDecoder.INSTANCE.copyOfRangeByte(bytes, offset, offset + (int) SUPLA_URL_HOST_MAXSIZE);
		offset += SUPLA_URL_HOST_MAXSIZE * BYTE_SIZE;

		val photoIntervalSec = PrimitiveDecoder.INSTANCE.parseUnsignedInt(bytes, offset);
		offset += INT_SIZE;

		val lightingMode = PrimitiveDecoder.INSTANCE.parseUnsignedLong(bytes, offset);
		offset += LONG_SIZE;

		val lightingLevel = PrimitiveDecoder.INSTANCE.parseUnsignedByte(bytes, offset);
		offset += BYTE_SIZE;

		val maximumIncrement = PrimitiveDecoder.INSTANCE.parseUnsignedLong(bytes, offset);
		offset += LONG_SIZE;

		val availableLightingModes = PrimitiveDecoder.INSTANCE.parseUnsignedLong(bytes, offset);
		offset += LONG_SIZE;

		val reserved = PrimitiveDecoder.INSTANCE.copyOfRangeByteUnsigned(bytes, offset, offset + (int) 128);
		offset += 128 * BYTE_SIZE;
		
	    return new ChannelConfigOCR(authKey, host, photoIntervalSec, lightingMode, lightingLevel, maximumIncrement, availableLightingModes, reserved);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy