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 java.nio.ByteBuffer;
17 import org.openhab.binding.lifx.internal.fields.Field;
18 import org.openhab.binding.lifx.internal.fields.HSBK;
19 import org.openhab.binding.lifx.internal.fields.HSBKField;
20 import org.openhab.binding.lifx.internal.fields.UInt8Field;
23 * @author Wouter Born - Initial contribution
25 public class StateZoneResponse extends Packet {
27 public static final int TYPE = 0x1F7;
29 public static final Field<Integer> FIELD_COUNT = new UInt8Field();
30 public static final Field<Integer> FIELD_INDEX = new UInt8Field();
31 public static final HSBKField FIELD_COLOR = new HSBKField();
38 public String toString() {
39 return "count=" + count + ", index=" + index + ", " + color.toString("color");
42 public int getCount() {
46 public int getIndex() {
50 public HSBK getColor() {
55 public int packetType() {
60 protected int packetLength() {
65 protected void parsePacket(ByteBuffer bytes) {
66 count = FIELD_COUNT.value(bytes);
67 index = FIELD_INDEX.value(bytes);
68 color = FIELD_COLOR.value(bytes);
72 protected ByteBuffer packetBytes() {
73 return ByteBuffer.allocate(packetLength()).put(FIELD_COUNT.bytes(count)).put(FIELD_INDEX.bytes(index))
74 .put(FIELD_COLOR.bytes(color));
78 public int[] expectedResponses() {