]> git.basschouten.com Git - openhab-addons.git/blob
7ed1336f706bf1ff9f7b199ea0835aeccae63169
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
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
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.plugwise.internal.protocol;
14
15 import static org.openhab.binding.plugwise.internal.protocol.field.MessageType.NODE_AVAILABLE_RESPONSE;
16
17 /**
18  * Response to a device when its {@link NodeAvailableMessage} is "accepted".
19  *
20  * @author Wouter Born, Karel Goderis - Initial contribution
21  */
22 public class NodeAvailableResponseMessage extends Message {
23
24     private boolean acceptanceCode;
25
26     private String destinationMAC;
27
28     public NodeAvailableResponseMessage(boolean code, String destination) {
29         super(NODE_AVAILABLE_RESPONSE);
30         acceptanceCode = code;
31         destinationMAC = destination;
32     }
33
34     public boolean isAcceptanceCode() {
35         return acceptanceCode;
36     }
37
38     @Override
39     protected String payloadToHexString() {
40         return String.format("%02X", acceptanceCode ? 1 : 0) + destinationMAC;
41     }
42 }