2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.lifx.internal.dto;
15 import static org.openhab.binding.lifx.internal.LifxBindingConstants.*;
17 import java.nio.ByteBuffer;
19 import org.openhab.binding.lifx.internal.fields.Field;
20 import org.openhab.binding.lifx.internal.fields.UInt8Field;
23 * @author Wouter Born - Initial contribution
25 public class GetColorZonesRequest extends Packet {
27 public static final int TYPE = 0x1F6;
29 public static final Field<Integer> FIELD_START_INDEX = new UInt8Field();
30 public static final Field<Integer> FIELD_END_INDEX = new UInt8Field();
32 private int startIndex = MIN_ZONE_INDEX;
33 private int endIndex = MAX_ZONE_INDEX;
35 public GetColorZonesRequest() {
37 setResponseRequired(true);
40 public GetColorZonesRequest(int index) {
44 public GetColorZonesRequest(int startIndex, int endIndex) {
46 this.startIndex = startIndex;
47 this.endIndex = endIndex;
50 public int getStartIndex() {
54 public int getEndIndex() {
59 public int packetType() {
64 protected int packetLength() {
69 protected void parsePacket(ByteBuffer bytes) {
70 startIndex = FIELD_START_INDEX.value(bytes);
71 endIndex = FIELD_END_INDEX.value(bytes);
75 protected ByteBuffer packetBytes() {
76 return ByteBuffer.allocate(packetLength()).put(FIELD_START_INDEX.bytes(startIndex))
77 .put(FIELD_END_INDEX.bytes(endIndex));
81 public int[] expectedResponses() {
82 return new int[] { StateMultiZoneResponse.TYPE, StateZoneResponse.TYPE };