]> git.basschouten.com Git - openhab-addons.git/blob
9dd207ec96a7bc7adeeca16592b3954d819b56a4
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2022 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
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
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.bluetooth.notification;
14
15 /**
16  * The {@link BluetoothScanNotification} provides a notification of a received scan packet
17  *
18  * @author Chris Jackson - Initial contribution
19  */
20 public class BluetoothScanNotification extends BluetoothNotification {
21     /**
22      * The receive signal strength for this beacon packet
23      */
24     private int rssi = Integer.MIN_VALUE;
25
26     /**
27      * The raw data
28      */
29     private byte[] data = null;
30
31     /**
32      * The manufacturer specific data
33      */
34     private byte[] manufacturerData = null;
35
36     /**
37      * The beacon type
38      */
39     private BluetoothBeaconType beaconType = BluetoothBeaconType.BEACON_UNKNOWN;
40
41     /**
42      * The device name
43      */
44     private String name = new String();
45
46     /**
47      * An enumeration of basic beacon types
48      */
49     public enum BluetoothBeaconType {
50         BEACON_UNKNOWN,
51         BEACON_ADVERTISEMENT,
52         BEACON_SCANRESPONSE
53     }
54
55     /**
56      * Sets the receive signal strength RSSI value for the scan
57      *
58      * param rssi the RSSI value for the scan packet in dBm
59      */
60     public void setRssi(int rssi) {
61         this.rssi = rssi;
62     }
63
64     /**
65      * Gets the receive signal strength RSSI value for the scan
66      *
67      * @return the RSSI value for the scan packet in dBm or Integer.MIN_VALUE if no RSSI is available.
68      */
69     public int getRssi() {
70         return rssi;
71     }
72
73     /**
74      * Sets the scan packet data
75      *
76      * @param data a byte array containing the raw packet data;
77      */
78     public void setData(byte[] data) {
79         this.data = data;
80     }
81
82     /**
83      * Gets the scan packet data
84      *
85      * @return a byte array containing the data or null if none is set
86      */
87     public byte[] getData() {
88         return data;
89     }
90
91     /**
92      * Sets the scan packet manufacturer specific data
93      *
94      * @param manufacturerData a byte array containing the manufacturer specific data
95      */
96     public void setManufacturerData(byte[] manufacturerData) {
97         this.manufacturerData = manufacturerData;
98     }
99
100     /**
101      * Gets the scan packet manufacturer specific data
102      *
103      * @return a byte array containing the manufacturer specific data or null if none is set
104      */
105     public byte[] getManufacturerData() {
106         return manufacturerData;
107     }
108
109     /**
110      * Sets the beacon type for this packet
111      *
112      * @beaconType the {@link BluetoothBeaconType} for this packet
113      */
114     public void setBeaconType(BluetoothBeaconType beaconType) {
115         this.beaconType = beaconType;
116     }
117
118     /**
119      * Gets the beacon type for this packet
120      *
121      * @return the {@link BluetoothBeaconType} for this packet
122      */
123     public BluetoothBeaconType getBeaconType() {
124         return beaconType;
125     }
126
127     /**
128      * Sets the device name
129      *
130      * @param name {@link String} containing the device name
131      */
132     public void setDeviceName(String name) {
133         this.name = name;
134     }
135
136     /**
137      * Gets the device name
138      *
139      * @return {@link String} containing the device name
140      */
141     public String getDeviceName() {
142         return name;
143     }
144 }