]> git.basschouten.com Git - openhab-addons.git/blob
d222f4990e1743de2f61deb8ec687d30de447a39
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2022 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
18 /**
19  * Class to implement the BlueGiga command <b>deleteBonding</b>.
20  * <p>
21  * This command deletes a bonding from the local security database. There can be a maximum of 8
22  * bonded devices stored at the same time, and one of them must be deleted if you need bonding with
23  * a 9th device.
24  * <p>
25  * This class provides methods for processing BlueGiga API commands.
26  * <p>
27  * Note that this code is autogenerated. Manual changes may be overwritten.
28  *
29  * @author Chris Jackson - Initial contribution of Java code generator
30  */
31 @NonNullByDefault
32 public class BlueGigaDeleteBondingCommand extends BlueGigaCommand {
33     public static int COMMAND_CLASS = 0x05;
34     public static int COMMAND_METHOD = 0x02;
35
36     /**
37      * Bonding handle of a device. This handle can be obtained for example from events like: Scan
38      * Response Status - If handle is 0xFF, all bondings will be deleted
39      * <p>
40      * BlueGiga API type is <i>uint8</i> - Java type is {@link int}
41      */
42     private int handle;
43
44     /**
45      * Bonding handle of a device. This handle can be obtained for example from events like: Scan
46      * Response Status - If handle is 0xFF, all bondings will be deleted
47      *
48      * @param handle the handle to set as {@link int}
49      */
50     public void setHandle(int handle) {
51         this.handle = handle;
52     }
53
54     @Override
55     public int[] serialize() {
56         // Serialize the header
57         serializeHeader(COMMAND_CLASS, COMMAND_METHOD);
58
59         // Serialize the fields
60         serializeUInt8(handle);
61
62         return getPayload();
63     }
64
65     @Override
66     public String toString() {
67         final StringBuilder builder = new StringBuilder();
68         builder.append("BlueGigaDeleteBondingCommand [handle=");
69         builder.append(handle);
70         builder.append(']');
71         return builder.toString();
72     }
73 }