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.velbus.internal.packets;
15 import static org.openhab.binding.velbus.internal.VelbusBindingConstants.COMMAND_TEXT;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
20 * The {@link VelbusMemoTextPacket} represents a Velbus packet that can be used to
21 * set the mode (comfort/day/night/safe) of the given Velbus thermostat module.
23 * @author Cedric Boon - Initial contribution
26 public class VelbusMemoTextPacket extends VelbusPacket {
27 private byte textStartPosition;
28 private byte character1;
29 private byte character2;
30 private byte character3;
31 private byte character4;
32 private byte character5;
34 public VelbusMemoTextPacket(byte address, byte textStartPosition, char[] text) {
35 super(address, PRIO_LOW);
37 if (textStartPosition < 0 || textStartPosition > 63) {
38 throw new IllegalArgumentException("The text start position '" + textStartPosition
39 + "' is invalid, because it should be between 0 and 63.");
42 if (text.length > 5) {
43 throw new IllegalArgumentException(
44 "The text '" + text.toString() + "' is invalid, because it cannot be longer than 5 characters.");
47 this.textStartPosition = textStartPosition;
48 this.character1 = text.length > 0 ? (byte) text[0] : 0x00;
49 this.character2 = text.length > 1 ? (byte) text[1] : 0x00;
50 this.character3 = text.length > 2 ? (byte) text[2] : 0x00;
51 this.character4 = text.length > 3 ? (byte) text[3] : 0x00;
52 this.character5 = text.length > 4 ? (byte) text[4] : 0x00;
56 protected byte[] getDataBytes() {
57 return new byte[] { COMMAND_TEXT, 0x00, textStartPosition, character1, character2, character3, character4,