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.notification;
15 import java.util.HashMap;
18 import org.eclipse.jdt.annotation.NonNullByDefault;
21 * The {@link BluetoothScanNotification} provides a notification of a received scan packet
23 * @author Chris Jackson - Initial contribution
24 * @author Peter Rosenberg - Add support for ServiceData
27 public class BluetoothScanNotification extends BluetoothNotification {
29 * The receive signal strength for this beacon packet
31 private int rssi = Integer.MIN_VALUE;
36 private byte[] data = new byte[0];
39 * The manufacturer specific data
41 private byte[] manufacturerData = new byte[0];
45 * Key: UUID of the service
46 * Value: Data of the characteristic
48 private Map<String, byte[]> serviceData = new HashMap<String, byte[]>();
53 private BluetoothBeaconType beaconType = BluetoothBeaconType.BEACON_UNKNOWN;
58 private String name = new String();
61 * An enumeration of basic beacon types
63 public enum BluetoothBeaconType {
70 * Sets the receive signal strength RSSI value for the scan
72 * param rssi the RSSI value for the scan packet in dBm
74 public void setRssi(int rssi) {
79 * Gets the receive signal strength RSSI value for the scan
81 * @return the RSSI value for the scan packet in dBm or Integer.MIN_VALUE if no RSSI is available.
83 public int getRssi() {
88 * Sets the scan packet data
90 * @param data a byte array containing the raw packet data;
92 public void setData(byte[] data) {
97 * Gets the scan packet data
99 * @return a byte array containing the data or null if none is set
101 public byte[] getData() {
106 * Sets the scan packet manufacturer specific data
108 * @param manufacturerData a byte array containing the manufacturer specific data
110 public void setManufacturerData(byte[] manufacturerData) {
111 this.manufacturerData = manufacturerData;
115 * Gets the scan packet manufacturer specific data
117 * @return a byte array containing the manufacturer specific data or null if none is set
119 public byte[] getManufacturerData() {
120 return manufacturerData;
123 public void setServiceData(Map<String, byte[]> serviceData) {
124 this.serviceData = serviceData;
127 public Map<String, byte[]> getServiceData() {
132 * Sets the beacon type for this packet
134 * @beaconType the {@link BluetoothBeaconType} for this packet
136 public void setBeaconType(BluetoothBeaconType beaconType) {
137 this.beaconType = beaconType;
141 * Gets the beacon type for this packet
143 * @return the {@link BluetoothBeaconType} for this packet
145 public BluetoothBeaconType getBeaconType() {
150 * Sets the device name
152 * @param name {@link String} containing the device name
154 public void setDeviceName(String name) {
159 * Gets the device name
161 * @return {@link String} containing the device name
163 public String getDeviceName() {