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.bluetooth.bluegiga.internal.enumeration;
15 import java.util.HashMap;
19 * Class to implement the BlueGiga Enumeration <b>ConnectionStatusFlag</b>.
21 * The possible connection status flags are described in the table below. The flags field is a
22 * bit mask, so multiple flags can be set at a time. If the bit is 1 the flag is active and if the bit is
23 * 0 the flag is inactive.
25 * Note that this code is autogenerated. Manual changes may be overwritten.
27 * @author Chris Jackson - Initial contribution of Java code generator
29 public enum ConnectionStatusFlag {
31 * Default unknown value
36 * [1] This status flag tells the connection exists to a remote device.
38 CONNECTION_CONNECTED(0x0001),
41 * [2] This flag tells the connection is encrypted.
43 CONNECTION_ENCRYPTED(0x0002),
46 * [4] Connection completed flag, which is used to tell a new connection has been created.
48 CONNECTION_COMPLETED(0x0004),
51 * [8] This flag tells that connection parameters have changed and. It is set when connection
52 * parameters have changed due to a link layer operation.
54 CONNECTION_PARAMETERS_CHANGE(0x0008);
57 * A mapping between the integer code and its corresponding type to
58 * facilitate lookup by code.
60 private static Map<Integer, ConnectionStatusFlag> codeMapping;
64 private ConnectionStatusFlag(int key) {
68 private static void initMapping() {
69 codeMapping = new HashMap<>();
70 for (ConnectionStatusFlag s : values()) {
71 codeMapping.put(s.key, s);
76 * Lookup function based on the type code. Returns null if the code does not exist.
78 * @param connectionStatusFlag
80 * @return enumeration value.
82 public static ConnectionStatusFlag getConnectionStatusFlag(int connectionStatusFlag) {
83 if (codeMapping == null) {
87 if (codeMapping.get(connectionStatusFlag) == null) {
91 return codeMapping.get(connectionStatusFlag);
95 * Returns the BlueGiga protocol defined value for this enum
97 * @return the BGAPI enumeration key