2 * Copyright (c) 2010-2021 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() {
38 setResponseRequired(true);
41 public GetColorZonesRequest(int index) {
45 public GetColorZonesRequest(int startIndex, int endIndex) {
47 this.startIndex = startIndex;
48 this.endIndex = endIndex;
51 public int getStartIndex() {
55 public int getEndIndex() {
60 public int packetType() {
65 protected int packetLength() {
70 protected void parsePacket(ByteBuffer bytes) {
71 startIndex = FIELD_START_INDEX.value(bytes);
72 endIndex = FIELD_END_INDEX.value(bytes);
76 protected ByteBuffer packetBytes() {
77 return ByteBuffer.allocate(packetLength()).put(FIELD_START_INDEX.bytes(startIndex))
78 .put(FIELD_END_INDEX.bytes(endIndex));
82 public int[] expectedResponses() {
83 return new int[] { StateMultiZoneResponse.TYPE, StateZoneResponse.TYPE };