]> git.basschouten.com Git - openhab-addons.git/blob
ab1db8140b9607c22d366eef2d0d25622e94c17d
[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.sinope.internal.core;
14
15 import java.io.IOException;
16 import java.io.InputStream;
17
18 import org.openhab.binding.sinope.internal.core.base.SinopeRequest;
19 import org.openhab.binding.sinope.internal.util.ByteUtil;
20
21 /**
22  * The Class SinopeAuthenticationKeyRequest.
23  *
24  * @author Pascal Larin - Initial contribution
25  */
26 public class SinopeAuthenticationKeyRequest extends SinopeRequest {
27
28     /** The id. */
29     private byte[] id;
30
31     /**
32      * Instantiates a new sinope authentication key request.
33      *
34      * @param id the id
35      */
36     public SinopeAuthenticationKeyRequest(byte[] id) {
37         this.id = id;
38     }
39
40     /**
41      * @see org.openhab.binding.sinope.internal.core.base.SinopeFrame#getCommand()
42      */
43     @Override
44     protected byte[] getCommand() {
45         return new byte[] { 0x01, 0x0a };
46     }
47
48     /**
49      * @see org.openhab.binding.sinope.internal.core.base.SinopeFrame#getFrameData()
50      */
51     @Override
52     protected byte[] getFrameData() {
53         return ByteUtil.reverse(this.id);
54     }
55
56     /**
57      * @see org.openhab.binding.sinope.internal.core.base.SinopeRequest#getReplyAnswer(java.io.InputStream)
58      */
59     @Override
60     public SinopeAuthenticationKeyAnswer getReplyAnswer(InputStream r) throws IOException {
61         return new SinopeAuthenticationKeyAnswer(r);
62     }
63
64     /**
65      * Gets the id.
66      *
67      * @return the id
68      */
69     public byte[] getId() {
70         return id;
71     }
72 }