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.paradoxalarm.internal.model;
15 import java.util.Arrays;
17 import org.openhab.binding.paradoxalarm.internal.parsers.IParadoxParser;
18 import org.openhab.core.util.HexUtils;
21 * The {@link ParadoxInformation} Class that provides the basic panel
22 * information (serial number, panel type, application, hardware and bootloader
23 * versions. It's the object representation of 37 bytes 0x72 serial response.
25 * @author Konstantin Polihronov - Initial contribution
27 public class ParadoxInformation {
29 private PanelType panelType;
30 private String serialNumber;
31 private Version applicationVersion;
32 private Version hardwareVersion;
33 private Version bootloaderVersion;
35 public ParadoxInformation(byte[] panelInfoBytes, IParadoxParser parser) {
36 panelType = ParadoxInformationConstants.parsePanelType(panelInfoBytes);
38 applicationVersion = parser.parseApplicationVersion(panelInfoBytes);
39 hardwareVersion = parser.parseHardwareVersion(panelInfoBytes);
40 bootloaderVersion = parser.parseBootloaderVersion(panelInfoBytes);
42 byte[] serialNumberBytes = Arrays.copyOfRange(panelInfoBytes, 12, 16);
43 serialNumber = HexUtils.bytesToHex(serialNumberBytes);
46 public PanelType getPanelType() {
50 public Version getApplicationVersion() {
51 return applicationVersion;
54 public Version getHardwareVersion() {
55 return hardwareVersion;
58 public Version getBootLoaderVersion() {
59 return bootloaderVersion;
62 public String getSerialNumber() {
67 public String toString() {
68 return "ParadoxInformation [panelType=" + panelType + ", serialNumber=" + serialNumber + ", applicationVersion="
69 + applicationVersion + ", hardwareVersion=" + hardwareVersion + ", bootloaderVersion="
70 + bootloaderVersion + "]";