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;
19 import org.eclipse.jdt.annotation.Nullable;
22 * Assigned numbers are used in GAP for inquiry response, EIR data type values, manufacturer-specific data, advertising
23 * data, low energy UUIDs and appearance characteristics, and class of device.
25 * https://www.bluetooth.com/specifications/assigned-numbers/generic-access-profile
27 * @author Chris Jackson - Initial contribution
31 public enum EirDataType {
33 * Default unknown value
39 EIR_SVC_UUID16_INCOMPLETE(0x02),
40 EIR_SVC_UUID16_COMPLETE(0x03),
41 EIR_SVC_UUID32_INCOMPLETE(0x04),
42 EIR_SVC_UUID32_COMPLETE(0x05),
43 EIR_SVC_UUID128_INCOMPLETE(0x06),
44 EIR_SVC_UUID128_COMPLETE(0x07),
48 EIR_DEVICE_CLASS(0x0D),
49 EIR_SIMPLE_PAIRING_RANDOMIZER(0x0F),
50 EIR_SECMAN_TK_VALUE(0x10),
51 EIR_SECMAN_OOB_FLAGS(0x11),
52 EIR_SLAVEINTERVALRANGE(0x12),
53 EIR_SVC_SOLICIT_UUID16(0x14),
54 EIR_SVC_SOLICIT_UUID128(0x15),
55 EIR_SVC_DATA_UUID16(0x16),
56 EIR_PUBLIC_TARGET_ADDR(0x17),
57 EIR_RANDOM_TARGET_ADDR(0x18),
59 EIR_ADVERTISING_INTERVAL(0x1A),
60 EIR_LE_DEVICE_ADDRESS(0x1B),
62 EIR_SIMPLE_PAIRING_HASH(0x1D),
63 EIR_SVC_SOLICIT_UUID32(0x1F),
64 EIR_SVC_DATA_UUID32(0x20),
65 EIR_SVC_DATA_UUID128(0x21),
66 EIR_LE_SEC_CONFIRMATION_VALUE(0x22),
67 EIR_LE_CONNECTION_RANDOM_VALUE(0x23),
69 EIR_INDOOR_POSITIONING(0x25),
70 EIR_LE_SUPPORTED_FEATURES(0x27),
71 EIR_MANUFACTURER_SPECIFIC(0xFF);
74 * A mapping between the integer code and its corresponding type to
75 * facilitate lookup by code.
77 private static @Nullable Map<Integer, EirDataType> codeMapping;
81 private EirDataType(int key) {
86 * Lookup function based on the type code. Returns {@link UNKNOWN} if the code does not exist.
90 * @return enumeration value.
92 public static EirDataType getEirPacketType(int eirDataType) {
93 Map<Integer, EirDataType> localCodeMapping = codeMapping;
94 if (localCodeMapping == null) {
95 localCodeMapping = new HashMap<>();
96 for (EirDataType s : values()) {
97 localCodeMapping.put(s.key, s);
99 codeMapping = localCodeMapping;
102 return localCodeMapping.getOrDefault(eirDataType, UNKNOWN);
106 * Returns the Bluetooth protocol defined value for this enum
108 * @return the EIR Data type key
110 public int getKey() {