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.satel.internal.command;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.openhab.binding.satel.internal.event.EventDispatcher;
17 import org.openhab.binding.satel.internal.event.ModuleVersionEvent;
18 import org.openhab.binding.satel.internal.protocol.SatelMessage;
19 import org.slf4j.Logger;
20 import org.slf4j.LoggerFactory;
23 * Command class for command that returns communication module version.
25 * @author Krzysztof Goworek - Initial contribution
28 public class ModuleVersionCommand extends SatelCommandBase {
30 private final Logger logger = LoggerFactory.getLogger(ModuleVersionCommand.class);
32 public static final byte COMMAND_CODE = 0x7c;
35 * Creates new command class instance.
37 public ModuleVersionCommand() {
38 super(COMMAND_CODE, false);
42 * @return communication module firmware version and release date
44 public String getVersion() {
49 * @return <code>true</code> if the module supports extended (32-bit) payload for zones/outputs
51 public boolean hasExtPayloadSupport() {
52 return (getResponse().getPayload()[11] & 0x01) != 0;
56 protected boolean isResponseValid(SatelMessage response) {
58 if (response.getPayload().length != 12) {
59 logger.debug("Invalid payload length: {}", response.getPayload().length);
66 protected void handleResponseInternal(final EventDispatcher eventDispatcher) {
67 // dispatch version event
68 eventDispatcher.dispatchEvent(new ModuleVersionEvent(getVersion(), hasExtPayloadSupport()));