/**
 * Copyright (c) 2010-2019 Contributors to the openHAB project
 *
 * See the NOTICE file(s) distributed with this work for additional
 * information.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License 2.0 which is available at
 * http://www.eclipse.org/legal/epl-2.0
 *
 * SPDX-License-Identifier: EPL-2.0
 */
package org.openhab.binding.velbus.internal.packets;

import static org.openhab.binding.velbus.internal.VelbusBindingConstants.COMMAND_STATUS_REQUEST;

import org.openhab.binding.velbus.internal.VelbusChannelIdentifier;

/**
 * The {@link VelbusStatusRequestPacket} represents a Velbus packet that can be used to
 * request the state of the given Velbus module.
 *
 * @author Cedric Boon - Initial contribution
 */
public class VelbusStatusRequestPacket extends VelbusPacket {
    private static final byte ALL_CHANNELS = (byte) 0xFF;

    private byte channel;

    public VelbusStatusRequestPacket(byte address) {
        this(new VelbusChannelIdentifier(address, ALL_CHANNELS));
    }

    public VelbusStatusRequestPacket(VelbusChannelIdentifier velbusChannelIdentifier) {
        super(velbusChannelIdentifier.getAddress(), PRIO_LOW);

        this.channel = velbusChannelIdentifier.getChannelByte();
    }

    @Override
    protected byte[] getDataBytes() {
        return new byte[] { COMMAND_STATUS_REQUEST, channel };
    }

}
