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;
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.eclipse.jdt.annotation.Nullable;
22 * Class to implement the BlueGiga Enumeration <b>GapDiscoverMode</b>.
26 * Note that this code is autogenerated. Manual changes may be overwritten.
28 * @author Chris Jackson - Initial contribution of Java code generator
31 public enum GapDiscoverMode {
33 * Default unknown value
38 * [0] Discover only limited discoverable devices, that is, Slaves which have the LE Limited
39 * Discoverable Mode bit set in the AD type of their Flags advertisement packets.
41 GAP_DISCOVER_LIMITED(0x0000),
44 * [1] Discover limited and generic discoverable devices, that is, Slaves which have the LE
45 * Limited Discoverable Mode LE General or the Discoverable Mode bit set in the AD type of their
46 * advertisement Flags packets.
48 GAP_DISCOVER_GENERIC(0x0001),
51 * [2] Discover all devices regardless of the AD type, so also devices in Flags
52 * non-discoverable mode will be reported to host.
54 GAP_DISCOVER_OBSERVATION(0x0002),
57 * [3] Same as gap_non_discoverable.
59 GAP_BROADCAST(0x0003),
62 * [4] In this advertisement the advertisement and scan response data defined by user will be
63 * used. The user is responsible of building the advertisement data so that it also contains the
64 * appropriate desired Flags AD type.
66 GAP_USER_DATA(0x0004),
69 * [128] When turning the most highest bit on in GAP discoverable mode, the remote devices that
70 * send scan request packets to the advertiser are reported back to the application through
71 * Scan Response event. This is so called Enhanced Broadcasting mode.
73 GAP_ENHANCED_BROADCASTING(0x0080);
76 * A mapping between the integer code and its corresponding type to
77 * facilitate lookup by code.
79 private static @Nullable Map<Integer, GapDiscoverMode> codeMapping;
83 private GapDiscoverMode(int key) {
88 * Lookup function based on the type code. Returns {@link UNKNOWN} if the code does not exist.
90 * @param gapDiscoverMode
92 * @return enumeration value.
94 public static GapDiscoverMode getGapDiscoverMode(int gapDiscoverMode) {
95 Map<Integer, GapDiscoverMode> localCodeMapping = codeMapping;
96 if (localCodeMapping == null) {
97 localCodeMapping = new HashMap<>();
98 for (GapDiscoverMode s : values()) {
99 localCodeMapping.put(s.key, s);
101 codeMapping = localCodeMapping;
104 return localCodeMapping.getOrDefault(gapDiscoverMode, UNKNOWN);
108 * Returns the BlueGiga protocol defined value for this enum
110 * @return the BGAPI enumeration key
112 public int getKey() {