]> git.basschouten.com Git - openhab-addons.git/blob
8b2c9543aab579d21b703d53f44bc12c64ac7530
[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.enocean.internal.messages.Responses;
14
15 import org.openhab.binding.enocean.internal.Helper;
16 import org.openhab.binding.enocean.internal.messages.Response;
17
18 /**
19  *
20  * @author Daniel Weber - Initial contribution
21  */
22 public class RDBaseIdResponse extends Response {
23
24     private byte[] baseId = null;
25     private int remainingWriteCycles = 0;
26
27     public RDBaseIdResponse(Response response) {
28         this(response.getPayload().length, response.getOptionalPayload().length,
29                 Helper.concatAll(response.getPayload(), response.getOptionalPayload()));
30     }
31
32     RDBaseIdResponse(int dataLength, int optionalDataLength, byte[] payload) {
33         super(dataLength, optionalDataLength, payload);
34
35         if (this.data == null || this.data.length != 5 || this.optionalData == null || this.optionalData.length != 1) {
36             return;
37         }
38
39         baseId = getPayload(1, 4);
40         remainingWriteCycles = optionalData[0] & 0xFF;
41
42         _isValid = true;
43     }
44
45     public final byte[] getBaseId() {
46         return baseId;
47     }
48
49     public int getRemainingWriteCycles() {
50         return remainingWriteCycles;
51     }
52 }