]> git.basschouten.com Git - openhab-addons.git/blob
8fa299fdf3b4b382f1cd496e37f194eeb93f4bb1
[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.bluetooth.bluegiga.internal.command.security;
14
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.openhab.binding.bluetooth.bluegiga.internal.BlueGigaCommand;
17 import org.openhab.binding.bluetooth.bluegiga.internal.enumeration.SmpIoCapabilities;
18
19 /**
20  * Class to implement the BlueGiga command <b>setParameters</b>.
21  * <p>
22  * This command is used to configure the local Security Manager and its features
23  * <p>
24  * This class provides methods for processing BlueGiga API commands.
25  * <p>
26  * Note that this code is autogenerated. Manual changes may be overwritten.
27  *
28  * @author Chris Jackson - Initial contribution of Java code generator
29  */
30 @NonNullByDefault
31 public class BlueGigaSetParametersCommand extends BlueGigaCommand {
32     public static final int COMMAND_CLASS = 0x05;
33     public static final int COMMAND_METHOD = 0x03;
34
35     /**
36      * 1: Man-in-the-middle protection required. 0: No Man-in-the-middle protection. Default:
37      * 0
38      * <p>
39      * BlueGiga API type is <i>boolean</i> - Java type is {@link boolean}
40      */
41     private boolean requireMitm;
42
43     /**
44      * Minimum key size in Bytes. Range: 7-16. Default: 7 (56bits)
45      * <p>
46      * BlueGiga API type is <i>uint8</i> - Java type is {@link int}
47      */
48     private int minKeySize;
49
50     /**
51      * Configures the local devices I/O capabilities. See: SMP IO Capabilities for options.
52      * Default: No Input and No Output
53      * <p>
54      * BlueGiga API type is <i>SmpIoCapabilities</i> - Java type is {@link SmpIoCapabilities}
55      */
56     private SmpIoCapabilities ioCapabilities = SmpIoCapabilities.UNKNOWN;
57
58     /**
59      * 1: Man-in-the-middle protection required. 0: No Man-in-the-middle protection. Default:
60      * 0
61      *
62      * @param requireMitm the requireMitm to set as {@link boolean}
63      */
64     public void setRequireMitm(boolean requireMitm) {
65         this.requireMitm = requireMitm;
66     }
67
68     /**
69      * Minimum key size in Bytes. Range: 7-16. Default: 7 (56bits)
70      *
71      * @param minKeySize the minKeySize to set as {@link int}
72      */
73     public void setMinKeySize(int minKeySize) {
74         this.minKeySize = minKeySize;
75     }
76
77     /**
78      * Configures the local devices I/O capabilities. See: SMP IO Capabilities for options.
79      * Default: No Input and No Output
80      *
81      * @param ioCapabilities the ioCapabilities to set as {@link SmpIoCapabilities}
82      */
83     public void setIoCapabilities(SmpIoCapabilities ioCapabilities) {
84         this.ioCapabilities = ioCapabilities;
85     }
86
87     @Override
88     public int[] serialize() {
89         // Serialize the header
90         serializeHeader(COMMAND_CLASS, COMMAND_METHOD);
91
92         // Serialize the fields
93         serializeBoolean(requireMitm);
94         serializeUInt8(minKeySize);
95         serializeSmpIoCapabilities(ioCapabilities);
96
97         return getPayload();
98     }
99
100     @Override
101     public String toString() {
102         final StringBuilder builder = new StringBuilder();
103         builder.append("BlueGigaSetParametersCommand [requireMitm=");
104         builder.append(requireMitm);
105         builder.append(", minKeySize=");
106         builder.append(minKeySize);
107         builder.append(", ioCapabilities=");
108         builder.append(ioCapabilities);
109         builder.append(']');
110         return builder.toString();
111     }
112 }