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 * Assigned numbers are used in GAP for inquiry response, EIR data type values, manufacturer-specific data, advertising
22 * data, low energy UUIDs and appearance characteristics, and class of device.
24 * https://www.bluetooth.com/specifications/assigned-numbers/generic-access-profile
26 * @author Chris Jackson - Initial contribution
30 public enum EirDataType {
32 * Default unknown value
38 EIR_SVC_UUID16_INCOMPLETE(0x02),
39 EIR_SVC_UUID16_COMPLETE(0x03),
40 EIR_SVC_UUID32_INCOMPLETE(0x04),
41 EIR_SVC_UUID32_COMPLETE(0x05),
42 EIR_SVC_UUID128_INCOMPLETE(0x06),
43 EIR_SVC_UUID128_COMPLETE(0x07),
47 EIR_DEVICE_CLASS(0x0D),
48 EIR_SIMPLE_PAIRING_RANDOMIZER(0x0F),
49 EIR_SECMAN_TK_VALUE(0x10),
50 EIR_SECMAN_OOB_FLAGS(0x11),
51 EIR_SLAVEINTERVALRANGE(0x12),
52 EIR_SVC_SOLICIT_UUID16(0x14),
53 EIR_SVC_SOLICIT_UUID128(0x15),
54 EIR_SVC_DATA_UUID16(0x16),
55 EIR_PUBLIC_TARGET_ADDR(0x17),
56 EIR_RANDOM_TARGET_ADDR(0x18),
58 EIR_ADVERTISING_INTERVAL(0x1A),
59 EIR_LE_DEVICE_ADDRESS(0x1B),
61 EIR_SIMPLE_PAIRING_HASH(0x1D),
62 EIR_SVC_SOLICIT_UUID32(0x1F),
63 EIR_SVC_DATA_UUID32(0x20),
64 EIR_SVC_DATA_UUID128(0x21),
65 EIR_LE_SEC_CONFIRMATION_VALUE(0x22),
66 EIR_LE_CONNECTION_RANDOM_VALUE(0x23),
68 EIR_INDOOR_POSITIONING(0x25),
69 EIR_LE_SUPPORTED_FEATURES(0x27),
70 EIR_MANUFACTURER_SPECIFIC(0xFF);
73 * A mapping between the integer code and its corresponding type to
74 * facilitate lookup by code.
76 private static Map<Integer, EirDataType> codeMapping = new HashMap<>();
80 private EirDataType(int key) {
84 private static void initMapping() {
85 for (EirDataType s : values()) {
86 codeMapping.put(s.key, s);
91 * Lookup function based on the type code. Returns null if the code does not exist.
93 * @param bluetoothAddressType
95 * @return enumeration value.
97 @SuppressWarnings({ "null", "unused" })
98 public static EirDataType getEirPacketType(int eirDataType) {
99 if (codeMapping.isEmpty()) {
103 return codeMapping.getOrDefault(eirDataType, UNKNOWN);
107 * Returns the Bluetooth protocol defined value for this enum
109 * @return the EIR Data type key
111 public int getKey() {