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.communication.messages;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.openhab.binding.paradoxalarm.internal.exceptions.ParadoxException;
17 import org.openhab.binding.paradoxalarm.internal.util.ParadoxUtil;
18 import org.slf4j.Logger;
19 import org.slf4j.LoggerFactory;
22 * The {@link EpromRequestPayload} Object representing payload of IP packet which retrieves data from Paradox EPROM
24 * @author Konstantin Polihronov - Initial contribution
27 public class EpromRequestPayload extends MemoryRequestPayload implements IPayload {
29 private final Logger logger = LoggerFactory.getLogger(EpromRequestPayload.class);
31 public EpromRequestPayload(int address, byte bytesToRead) throws ParadoxException {
32 super(address, bytesToRead);
36 protected byte calculateControlByte() {
37 int address = getAddress();
38 logTraceHexFormatted("Address: {}", address);
40 byte controlByte = 0x00;
41 byte[] shortToByteArray = ParadoxUtil.intToByteArray(address);
42 if (shortToByteArray.length > 2) {
43 byte bit16 = ParadoxUtil.getBit(address, 16);
44 controlByte |= bit16 << 0;
45 byte bit17 = ParadoxUtil.getBit(address, 17);
46 controlByte |= bit17 << 1;
48 logger.trace("ControlByte value: {}", controlByte);