2 * Copyright (c) 2010-2024 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.insteon.internal.message;
15 import java.util.HashMap;
18 import org.eclipse.jdt.annotation.NonNullByDefault;
21 * Represents insteon message type flags
23 * @author Daniel Pfrommer - Initial contribution
24 * @author Rob Nielsen - Port to openHAB 2 insteon binding
29 * From the official Insteon docs: the message flags are as follows:
31 * Bit 0 max hops low bit
32 * Bit 1 max hops high bit
33 * Bit 2 hops left low bit
34 * Bit 3 hops left high bit
35 * Bit 4 0: is standard message, 1: is extended message
37 * Bit 6 0: not link related, 1: is ALL-Link message
44 ALL_LINK_BROADCAST(0xc0),
45 ALL_LINK_CLEANUP(0x40),
46 ALL_LINK_CLEANUP_ACK(0x60),
47 ALL_LINK_CLEANUP_NACK(0xe0),
48 INVALID(0xff); // should never happen
50 private static Map<Integer, MsgType> hash = new HashMap<>();
52 private byte byteValue = 0;
57 * @param b byte with insteon message type flags set
60 this.byteValue = (byte) b;
64 for (MsgType t : MsgType.values()) {
65 int i = t.getByteValue() & 0xff;
70 private int getByteValue() {
74 public static MsgType fromValue(byte b) throws IllegalArgumentException {
76 MsgType mt = hash.get(i);
78 throw new IllegalArgumentException("msg type of byte value " + i + " not found");