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