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.alarmdecoder.internal.protocol;
15 import java.util.List;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
20 * The {@link RFXMessage} class represents a parsed RF zone (RFX) message.
21 * Based partly on code from the OH1 alarmdecoder binding by Bernd Pfrommer.
23 * @author Bob Adair - Initial contribution
26 public class RFXMessage extends ADMessage {
28 // Example: !RFX:0180036,80
30 public static final int BIT_LOWBAT = 0x02;
31 public static final int BIT_SUPER = 0x04;
32 public static final int BIT_LOOP3 = 0x10;
33 public static final int BIT_LOOP2 = 0x20;
34 public static final int BIT_LOOP4 = 0x40;
35 public static final int BIT_LOOP1 = 0x80;
37 /** Address serial number */
38 public final int serial;
41 public final int data;
43 public RFXMessage(String message) throws IllegalArgumentException {
46 String[] topLevel = message.split(":");
47 if (topLevel.length != 2) {
48 throw new IllegalArgumentException("Multiple colons found in RFX message");
51 List<String> parts = splitMsg(topLevel[1]);
53 if (parts.size() != 2) {
54 throw new IllegalArgumentException("Invalid number of parts in RFX message");
58 serial = Integer.parseInt(parts.get(0));
59 data = Integer.parseInt(parts.get(1), 16);
60 } catch (NumberFormatException e) {
61 throw new IllegalArgumentException("RFX message contains invalid number: " + e.getMessage(), e);