Package com.irurueta.navigation.indoor
Class Beacon
java.lang.Object
com.irurueta.navigation.indoor.Beacon
- All Implemented Interfaces:
RadioSource,Serializable
- Direct Known Subclasses:
BeaconLocated,BeaconWithPower
The
Beacon class represents a single hardware Beacon detected by
an Android device.
A Beacon is identified by a unique multi-part identifier, with the first of the ordered identifiers being more significant for the purposes of grouping beacons. A Beacon sends a Bluetooth Low Energy (BLE) advertisement that contains these three identifiers, along with the calibrated tx power (in RSSI) of the Beacon's Bluetooth transmitter.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate intThe two byte value indicating the type of beacon that this is, which is used for figuring out the byte layout of the beacon advertisement.private StringThe Bluetooth mac address.private StringThe Bluetooth device name.static final doubleDefault frequency used by a Beacon when none is specified (expressed in Hz).private doubleFrequency used by this Beacon(expressed in Hz).private ArrayList<BeaconIdentifier> The list of the multipart identifiers of the beacon.private intA two byte code indicating the beacon manufacturer.private intA 32 bit service uuid for the beacon.private doubleThe calibrated measured Tx power of the Beacon in RSSI (expressed in dBm's). -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedBeacon()Empty constructor.Beacon(List<BeaconIdentifier> identifiers, double transmittedPower) Constructor.Beacon(List<BeaconIdentifier> identifiers, double transmittedPower, double frequency) Constructor.Beacon(List<BeaconIdentifier> identifiers, double transmittedPower, double frequency, String bluetoothAddress, int beaconTypeCode, int manufacturer, int serviceUuid, String bluetoothName) Constructor.Beacon(List<BeaconIdentifier> identifiers, double transmittedPower, String bluetoothAddress, int beaconTypeCode, int manufacturer, int serviceUuid, String bluetoothName) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionbooleanChecks whether two beacons are considered equal if they share the same identifiers.intGets the two byte value indicating the type of beacon that this is, which is used for figuring out the byte layout of the beacon advertisement.Gets the bluetooth mac address.Gets the Bluetooth device name.doubleGets frequency used by this radio source (expressed in Hz).getId1()Convenience method to get the first identifier.getId2()Convenience method to get the second identifier.getId3()Convenience method to get the third identifier.getIdentifier(int i) Returns the specified identifier - 0 indexed.Gets the list of the multipart identifiers of the beacon.intGets a two byte code indicating the beacon manufacturer.intGets a 32 bit service uuid for the beacon.doubleReturns the calibrated measured Tx power of the Beacon in RSSI (expressed in dBm's).getType()Gets radio source type, which can be either a Wi-Fi Access point or a bluetooth Beacon.inthashCode()Computes hash code for this instance.
-
Field Details
-
DEFAULT_FREQUENCY
public static final double DEFAULT_FREQUENCYDefault frequency used by a Beacon when none is specified (expressed in Hz).- See Also:
-
identifiers
The list of the multipart identifiers of the beacon. Together, these identifiers signify a unique beacon. The identifiers are ordered by significance for the purpose of grouping beacons. -
transmittedPower
private double transmittedPowerThe calibrated measured Tx power of the Beacon in RSSI (expressed in dBm's). This value is baked into a Beacon when it is manufactured, and it is transmitted with each packet to aid in the distance estimate. -
bluetoothAddress
The Bluetooth mac address. -
beaconTypeCode
private int beaconTypeCodeThe two byte value indicating the type of beacon that this is, which is used for figuring out the byte layout of the beacon advertisement. -
manufacturer
private int manufacturerA two byte code indicating the beacon manufacturer. A list of registered manufacturer codes may be found here: https://www.bluetooth.org/en-us/specification/assigned-numbers/company-identifiersIf the beacon is a GATT-based beacon, this field will be set to -1.
-
serviceUuid
private int serviceUuidA 32 bit service uuid for the beacon. This is valid only for GATT-based beacons. If the beacon is a manufacturer data-based beacon, this field will be -1 -
bluetoothName
The Bluetooth device name. This is a field transmitted by the remote beacon device separate from the advertisement data -
frequency
private double frequencyFrequency used by this Beacon(expressed in Hz).
-
-
Constructor Details
-
Beacon
Constructor.- Parameters:
identifiers- list of the multipart identifiers of the beacon.transmittedPower- calibrated measured Tx power of the Beacon in RSSI (expressed in dBm's).- Throws:
IllegalArgumentException- if identifiers is null.
-
Beacon
public Beacon(List<BeaconIdentifier> identifiers, double transmittedPower, String bluetoothAddress, int beaconTypeCode, int manufacturer, int serviceUuid, String bluetoothName) Constructor.- Parameters:
identifiers- list of the multipart identifiers of the beacon.transmittedPower- calibrated measured Tx power of the Beacon in RSSI (expressed in dBm's).bluetoothAddress- the bluetooth mac address.beaconTypeCode- the two byte value indicating the type of beacon.manufacturer- a two byte code indicating the beacon manufacturer.serviceUuid- a 32 bit service uuid for the beacon.bluetoothName- the bluetooth device name.- Throws:
IllegalArgumentException- if identifiers is null.
-
Beacon
Constructor.- Parameters:
identifiers- list of the multipart identifiers of the beacon.transmittedPower- calibrated measured Tx power of the Beacon in RSSI (expressed in dBm's).frequency- frequency used by this Beacon.- Throws:
IllegalArgumentException- if identifiers is null or frequency is negative.
-
Beacon
public Beacon(List<BeaconIdentifier> identifiers, double transmittedPower, double frequency, String bluetoothAddress, int beaconTypeCode, int manufacturer, int serviceUuid, String bluetoothName) Constructor.- Parameters:
identifiers- list of the multipart identifiers of the beacon.transmittedPower- calibrated measured Tx power of the Beacon in RSSI (expressed in dBm's).frequency- frequency used by this Beacon.bluetoothAddress- the bluetooth mac address.beaconTypeCode- the two byte value indicating the type of beacon.manufacturer- a two byte code indicating the beacon manufacturer.serviceUuid- a 32 bit service uuid for the beacon.bluetoothName- the bluetooth device name.- Throws:
IllegalArgumentException- if identifiers is null.
-
Beacon
protected Beacon()Empty constructor.
-
-
Method Details
-
getIdentifier
Returns the specified identifier - 0 indexed. Note: to read id1, call getIdentifier(0);- Parameters:
i- index identifier.- Returns:
- identifier or null if not available.
-
getId1
Convenience method to get the first identifier.- Returns:
- first identifier or null if not available.
-
getId2
Convenience method to get the second identifier.- Returns:
- second identifier or null if not available.
-
getId3
Convenience method to get the third identifier.- Returns:
- third identifier or null if not available.
-
getIdentifiers
Gets the list of the multipart identifiers of the beacon. Together, these identifiers signify a unique beacon. The identifiers are ordered by significance for the purpose of grouping beacons.- Returns:
- list of identifiers of the beacon or null if not available.
-
getTransmittedPower
public double getTransmittedPower()Returns the calibrated measured Tx power of the Beacon in RSSI (expressed in dBm's). This value is baked into a Beacon when it is manufactured, and it is transmitted with each packet to aid in the distance estimate.- Returns:
- the calibrated measured Tx power.
-
getBluetoothAddress
Gets the bluetooth mac address.- Returns:
- bluetooth mac address.
-
getBeaconTypeCode
public int getBeaconTypeCode()Gets the two byte value indicating the type of beacon that this is, which is used for figuring out the byte layout of the beacon advertisement.- Returns:
- two byte value indicating the type of beacon.
-
getBluetoothName
Gets the Bluetooth device name. This is a field transmitted by the remote beacon device separate from the advertisement data.- Returns:
- bluetooth device name.
-
getManufacturer
public int getManufacturer()Gets a two byte code indicating the beacon manufacturer. A list of registered manufacturer codes may be found here: https://www.bluetooth.org/en-us/specification/assigned-numbers/company-identifiersIf the beacon is a GATT-based beacon, this field will be set to -1.
- Returns:
- a two byte code indicating the beacon manufacturer.
-
getServiceUuid
public int getServiceUuid()Gets a 32 bit service uuid for the beacon. This is valid only for GATT-based beacons. If the beacon is a manufacturer data-based beacon, this field will be -1- Returns:
- service uuid.
-
getFrequency
public double getFrequency()Gets frequency used by this radio source (expressed in Hz).- Specified by:
getFrequencyin interfaceRadioSource- Returns:
- frequency used by this radio source (expressed in Hz).
-
equals
Checks whether two beacons are considered equal if they share the same identifiers.- Specified by:
equalsin interfaceRadioSource- Overrides:
equalsin classObject- Parameters:
that- beacon to be compared.- Returns:
- true if both beacons are considered equal, false otherwise.
-
hashCode
public int hashCode()Computes hash code for this instance. -
getType
Gets radio source type, which can be either a Wi-Fi Access point or a bluetooth Beacon.- Specified by:
getTypein interfaceRadioSource- Returns:
- radio source type.
-