|
1 | | -package uk.co.alt236.bluetoothlelib.util; |
| 1 | +package uk.co.alt236.bluetoothlelib.device.beacon.ibeacon; |
2 | 2 |
|
3 | | -import uk.co.alt236.bluetoothlelib.device.BluetoothLeDevice; |
4 | | -import uk.co.alt236.bluetoothlelib.device.adrecord.AdRecord; |
| 3 | +import uk.co.alt236.bluetoothlelib.util.ByteUtils; |
5 | 4 |
|
6 | | -public class IBeaconUtils { |
| 5 | +final class IBeaconUtils { |
7 | 6 | private static final double DISTANCE_THRESHOLD_WTF = 0.0; |
8 | 7 | private static final double DISTANCE_THRESHOLD_IMMEDIATE = 0.5; |
9 | 8 | private static final double DISTANCE_THRESHOLD_NEAR = 3.0; |
10 | 9 |
|
11 | | - private static final byte[] MANUFACTURER_DATA_IBEACON_PREFIX = {0x4C, 0x00, 0x02, 0x15}; |
| 10 | + private IBeaconUtils(){ |
| 11 | + // TO AVOID INSTANTIATION |
| 12 | + } |
12 | 13 |
|
13 | 14 | /** |
14 | 15 | * Calculates the accuracy of an RSSI reading. |
@@ -75,38 +76,4 @@ public static IBeaconDistanceDescriptor getDistanceDescriptor(final double accur |
75 | 76 |
|
76 | 77 | return IBeaconDistanceDescriptor.FAR; |
77 | 78 | } |
78 | | - |
79 | | - /** |
80 | | - * Ascertains whether a Manufacturer Data byte array belongs to an iBeacon; |
81 | | - * |
82 | | - * @param manufacturerData a Bluetooth LE device's raw manufacturerData. |
83 | | - * @return true if the manufacturer data belong to an iBeacon |
84 | | - */ |
85 | | - public static boolean isThisAnIBeacon(final byte[] manufacturerData) { |
86 | | - if (manufacturerData == null) { |
87 | | - return false; |
88 | | - } |
89 | | - |
90 | | - // An iBeacon record must be at least 25 chars long |
91 | | - if (!(manufacturerData.length >= 25)) { |
92 | | - return false; |
93 | | - } |
94 | | - |
95 | | - if (ByteUtils.doesArrayBeginWith(manufacturerData, MANUFACTURER_DATA_IBEACON_PREFIX)) { |
96 | | - return true; |
97 | | - } |
98 | | - |
99 | | - return false; |
100 | | - } |
101 | | - |
102 | | - /** |
103 | | - * Ascertains whether a {@link uk.co.alt236.bluetoothlelib.device.BluetoothLeDevice} is an iBeacon; |
104 | | - * |
105 | | - * @param device a {@link uk.co.alt236.bluetoothlelib.device.BluetoothLeDevice} device. |
106 | | - * @return true if the device is an iBeacon, false otherwise |
107 | | - */ |
108 | | - public static boolean isThisAnIBeacon(final BluetoothLeDevice device) { |
109 | | - final int key = AdRecord.TYPE_MANUFACTURER_SPECIFIC_DATA; |
110 | | - return isThisAnIBeacon(device.getAdRecordStore().getRecordDataAsString(key).getBytes()); |
111 | | - } |
112 | 79 | } |
0 commit comments