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.eir;
15 import java.util.HashMap;
18 import org.eclipse.jdt.annotation.NonNullByDefault;
21 * Definition of the EIR Flags field
23 * @author Chris Jackson - Initial contribution
27 public enum EirFlags {
29 LE_LIMITED_DISCOVERABLE_MODE(0),
30 LE_GENERAL_DISCOVERABLE_MODE(1),
31 BR_EDR_NOT_SUPPORTED(2),
32 SIMULTANEOUS_LE_BDR_CONTROLLER(3),
33 SIMULTANEOUS_LE_BDR_HOST(4),
47 * A mapping between the integer code and its corresponding type to
48 * facilitate lookup by code.
50 private static Map<Integer, EirFlags> codeMapping = new HashMap<>();
54 private EirFlags(int key) {
58 private static void initMapping() {
59 codeMapping = new HashMap<>();
60 for (EirFlags s : values()) {
61 codeMapping.put(s.key, s);
66 * Lookup function based on the type code. Returns null if the code does not exist.
68 * @param bluetoothAddressType
70 * @return enumeration value.
72 @SuppressWarnings({ "null", "unused" })
73 public static EirFlags getEirFlag(int eirFlag) {
74 if (codeMapping.isEmpty()) {
78 return codeMapping.getOrDefault(eirFlag, UNKNOWN);
82 * Returns the Bluetooth protocol defined value for this enum
84 * @return the EIR Data type key