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.elerotransmitterstick.internal.stick;
15 import org.openhab.core.util.HexUtils;
18 * @author Volker Bier - Initial contribution
20 public class CommandPacket {
21 public static final byte EASY_CHECK = (byte) 0x4A;
22 public static final byte EASY_SEND = (byte) 0x4C;
23 public static final byte EASY_INFO = (byte) 0x4E;
27 public CommandPacket(byte[] bytes) {
28 data = new byte[bytes.length + 1];
29 System.arraycopy(bytes, 0, data, 0, bytes.length);
31 data[bytes.length] = checksum(bytes);
34 public byte[] getBytes() {
38 public long getResponseTimeout() {
46 private byte checksum(byte[] data) {
54 return (byte) (256 - val);
57 public boolean isEasyCheck() {
58 return data[2] == EASY_CHECK;
62 public String toString() {
63 return HexUtils.bytesToHex(data);