2 * Copyright (c) 2010-2022 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.plugwise.internal.protocol.field;
15 import java.util.HashMap;
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.eclipse.jdt.annotation.Nullable;
22 * Enumerates all Plugwise message types. Many are still missing, and require further protocol analysis.
24 * @author Wouter Born, Karel Goderis - Initial contribution
27 public enum MessageType {
29 ACKNOWLEDGEMENT_V1(0x0000),
30 NODE_AVAILABLE(0x0006),
31 NODE_AVAILABLE_RESPONSE(0x0007),
32 NETWORK_RESET_REQUEST(0x0008),
33 NETWORK_STATUS_REQUEST(0x000A),
35 PING_RESPONSE(0x000E),
36 NETWORK_STATUS_RESPONSE(0x0011),
37 POWER_INFORMATION_REQUEST(0x0012),
38 POWER_INFORMATION_RESPONSE(0x0013),
39 CLOCK_SET_REQUEST(0x0016),
40 POWER_CHANGE_REQUEST(0x0017),
41 DEVICE_ROLE_CALL_REQUEST(0x0018),
42 DEVICE_ROLE_CALL_RESPONSE(0x0019),
43 DEVICE_INFORMATION_REQUEST(0x0023),
44 DEVICE_INFORMATION_RESPONSE(0x0024),
45 POWER_CALIBRATION_REQUEST(0x0026),
46 POWER_CALIBRATION_RESPONSE(0x0027),
47 REAL_TIME_CLOCK_SET_REQUEST(0x0028),
48 REAL_TIME_CLOCK_GET_REQUEST(0x0029),
49 REAL_TIME_CLOCK_GET_RESPONSE(0x003A),
50 CLOCK_GET_REQUEST(0x003E),
51 CLOCK_GET_RESPONSE(0x003F),
52 POWER_BUFFER_REQUEST(0x0048),
53 POWER_BUFFER_RESPONSE(0x0049),
54 ANNOUNCE_AWAKE_REQUEST(0x004F),
55 SLEEP_SET_REQUEST(0x0050),
56 POWER_LOG_INTERVAL_SET_REQUEST(0x0057),
57 BROADCAST_GROUP_SWITCH_RESPONSE(0x0056),
58 MODULE_JOINED_NETWORK_REQUEST(0x0061),
59 ACKNOWLEDGEMENT_V2(0x0100),
60 SCAN_PARAMETERS_SET_REQUEST(0x0101),
61 LIGHT_CALIBRATION_REQUEST(0x0102),
62 SENSE_REPORT_INTERVAL_SET_REQUEST(0x0103),
63 SENSE_BOUNDARIES_SET_REQUEST(0x0104),
64 SENSE_REPORT_REQUEST(0x0105);
66 private static final Map<Integer, MessageType> TYPES_BY_VALUE = new HashMap<>();
69 for (MessageType type : MessageType.values()) {
70 TYPES_BY_VALUE.put(type.identifier, type);
74 private final int identifier;
76 MessageType(int value) {
80 public static @Nullable MessageType forValue(int value) {
81 return TYPES_BY_VALUE.get(value);