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.loxone.internal.types;
16 * A header of a binary message received from Loxone Miniserver on a websocket connection.
18 * @author Pawel Pieczul - initial contribution
21 public class LxWsBinaryHeader {
23 * Type of a binary message received from the Miniserver
25 * @author Pawel Pieczul
28 public enum LxWsMessageType {
30 * Text message - jetty websocket client will pass it on automatically to a callback
38 * A set of value states for controls that changed their state
40 EVENT_TABLE_OF_VALUE_STATES,
42 * A set of text states for controls that changed their state
44 EVENT_TABLE_OF_TEXT_STATES,
45 EVENT_TABLE_OF_DAYTIMER_STATES,
46 OUT_OF_SERVICE_INDICATOR,
48 * Response to keepalive request message
51 EVENT_TABLE_OF_WEATHER_STATES,
58 private LxWsMessageType type = LxWsMessageType.UNKNOWN;
61 * Create header from binary buffer at a given offset
63 * @param buffer buffer with received message
64 * @param offset offset in bytes at which header is expected
66 public LxWsBinaryHeader(byte[] buffer, int offset) throws IndexOutOfBoundsException {
67 if (buffer[offset] != 0x03) {
70 switch (buffer[offset + 1]) {
72 type = LxWsMessageType.TEXT_MESSAGE;
75 type = LxWsMessageType.BINARY_FILE;
78 type = LxWsMessageType.EVENT_TABLE_OF_VALUE_STATES;
81 type = LxWsMessageType.EVENT_TABLE_OF_TEXT_STATES;
84 type = LxWsMessageType.EVENT_TABLE_OF_DAYTIMER_STATES;
87 type = LxWsMessageType.OUT_OF_SERVICE_INDICATOR;
90 type = LxWsMessageType.KEEPALIVE_RESPONSE;
93 type = LxWsMessageType.EVENT_TABLE_OF_WEATHER_STATES;
96 type = LxWsMessageType.UNKNOWN;
99 // These fields are not used today , but left it for future reference
100 // estimated = ((buffer[offset + 2] & 0x01) != 0);
101 // length = ByteBuffer.wrap(buffer, offset + 3, 4).getInt();
104 public LxWsMessageType getType() {