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.sinope.internal.core;
15 import java.io.IOException;
16 import java.io.InputStream;
17 import java.nio.ByteBuffer;
19 import org.openhab.binding.sinope.internal.core.base.SinopeRequest;
20 import org.openhab.binding.sinope.internal.util.ByteUtil;
23 * The Class SinopeApiLoginRequest.
25 * @author Pascal Larin - Initial contribution
27 public class SinopeApiLoginRequest extends SinopeRequest {
30 private byte[] apiKey;
36 * Instantiates a new sinope api login request.
39 * @param apiKey the api key
41 public SinopeApiLoginRequest(byte[] id, byte[] apiKey) {
47 * @see org.openhab.binding.sinope.internal.core.base.SinopeFrame#getCommand()
50 protected byte[] getCommand() {
51 return new byte[] { 0x01, 0x10 };
55 * @see org.openhab.binding.sinope.internal.core.base.SinopeFrame#getFrameData()
58 protected byte[] getFrameData() {
59 byte[] b = new byte[id.length + apiKey.length];
61 ByteBuffer bb = ByteBuffer.wrap(b);
63 bb.put(ByteUtil.reverse(id));
64 bb.put(ByteUtil.reverse(apiKey));
66 // System.out.println(toString(bb.array()));
75 public byte[] getId() {
80 * @see org.openhab.binding.sinope.internal.core.base.SinopeRequest#getReplyAnswer(java.io.InputStream)
83 public SinopeApiLoginAnswer getReplyAnswer(InputStream r) throws IOException {
84 return new SinopeApiLoginAnswer(r);