Class Beacon

java.lang.Object
com.irurueta.navigation.indoor.Beacon
All Implemented Interfaces:
RadioSource, Serializable
Direct Known Subclasses:
BeaconLocated, BeaconWithPower

public class Beacon extends Object implements Serializable, RadioSource
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.
 

Based on: https://github.com/AltBeacon/android-beacon-library/blob/master/src/main/java/org/altbeacon/beacon/Beacon.java

See Also:
  • Field Details

    • DEFAULT_FREQUENCY

      public static final double DEFAULT_FREQUENCY
      Default frequency used by a Beacon when none is specified (expressed in Hz).
      See Also:
    • identifiers

      private ArrayList<BeaconIdentifier> 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 transmittedPower
      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.
    • bluetoothAddress

      private String bluetoothAddress
      The Bluetooth mac address.
    • beaconTypeCode

      private int beaconTypeCode
      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.
    • manufacturer

      private int manufacturer
      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-identifiers

      If the beacon is a GATT-based beacon, this field will be set to -1.

    • serviceUuid

      private int serviceUuid
      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
    • bluetoothName

      private String bluetoothName
      The Bluetooth device name. This is a field transmitted by the remote beacon device separate from the advertisement data
    • frequency

      private double frequency
      Frequency used by this Beacon(expressed in Hz).
  • Constructor Details

    • Beacon

      public Beacon(List<BeaconIdentifier> identifiers, double transmittedPower)
      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

      public Beacon(List<BeaconIdentifier> identifiers, double transmittedPower, double frequency)
      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

      public BeaconIdentifier getIdentifier(int i)
      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

      public BeaconIdentifier getId1()
      Convenience method to get the first identifier.
      Returns:
      first identifier or null if not available.
    • getId2

      public BeaconIdentifier getId2()
      Convenience method to get the second identifier.
      Returns:
      second identifier or null if not available.
    • getId3

      public BeaconIdentifier getId3()
      Convenience method to get the third identifier.
      Returns:
      third identifier or null if not available.
    • getIdentifiers

      public List<BeaconIdentifier> 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

      public String 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

      public String 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-identifiers

      If 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:
      getFrequency in interface RadioSource
      Returns:
      frequency used by this radio source (expressed in Hz).
    • equals

      public boolean equals(Object that)
      Checks whether two beacons are considered equal if they share the same identifiers.
      Specified by:
      equals in interface RadioSource
      Overrides:
      equals in class Object
      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.
      Overrides:
      hashCode in class Object
      Returns:
      this instance hash code.
    • getType

      public RadioSourceType getType()
      Gets radio source type, which can be either a Wi-Fi Access point or a bluetooth Beacon.
      Specified by:
      getType in interface RadioSource
      Returns:
      radio source type.