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>ScanResponseType</b>.
21 * Defines the packet types received during a scan response
23 * Note that this code is autogenerated. Manual changes may be overwritten.
25 * @author Chris Jackson - Initial contribution of Java code generator
27 public enum ScanResponseType {
29 * Default unknown value
34 * [0] Connectable Advertisement packet
36 CONNECTABLE_ADVERTISEMENT(0x0000),
39 * [2] Non Connectable Advertisement packet
41 NON_CONNECTABLE_ADVERTISEMENT(0x0002),
44 * [4] Scan response packet
46 SCAN_RESPONSE(0x0004),
49 * [6] Discoverable advertisement packet
51 DISCOVERABLE_ADVERTISEMENT(0x0006);
54 * A mapping between the integer code and its corresponding type to
55 * facilitate lookup by code.
57 private static Map<Integer, ScanResponseType> codeMapping;
61 private ScanResponseType(int key) {
65 private static void initMapping() {
66 codeMapping = new HashMap<>();
67 for (ScanResponseType s : values()) {
68 codeMapping.put(s.key, s);
73 * Lookup function based on the type code. Returns null if the code does not exist.
75 * @param scanResponseType
77 * @return enumeration value.
79 public static ScanResponseType getScanResponseType(int scanResponseType) {
80 if (codeMapping == null) {
84 if (codeMapping.get(scanResponseType) == null) {
88 return codeMapping.get(scanResponseType);
92 * Returns the BlueGiga protocol defined value for this enum
94 * @return the BGAPI enumeration key