Package 

Class Beacon

  • All Implemented Interfaces:
    android.os.Parcelable , java.io.Serializable

    
    public class Beacon
     implements Parcelable, Serializable
                        

    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.
    
    This class may only be instantiated from a BLE packet, and an RSSI measurement for
    the packet.  The class parses out the identifier, along with the calibrated
    tx power.  It then uses the measured RSSI and calibrated tx power to do a rough
    distance measurement (the mDistance field)
    • Method Detail

      • setHardwareEqualityEnforced

         static void setHardwareEqualityEnforced(boolean e)

        Configures whether a the bluetoothAddress (mac address) must be the same for two Beacons to be configured equal. This setting applies to all beacon instances in the same process. Defaults to false for backward compatibility.

      • setRssiMeasurementCount

         void setRssiMeasurementCount(int rssiMeasurementCount)

        Sets the measurement count that went into the rssi sample

      • getPacketCount

         int getPacketCount()

        Returns the number of packet detections in the last ranging cycle

      • setPacketCount

         void setPacketCount(int packetCount)

        Sets the packet detections in the last ranging cycle

      • setLastCycleDetectionTimestamp

         void setLastCycleDetectionTimestamp(long lastCycleDetectionTimestamp)

        Sets the timestamp of the last packet detected

      • getMeasurementCount

         int getMeasurementCount()

        Returns the number of packet detections that went in to the runningAverageRssi, if known. If not known or inapplicable for the rssi filter used, this is zero.

      • setRunningAverageRssi

         void setRunningAverageRssi(double rssi)

        Sets the running average rssi for use in distance calculations

        Parameters:
        rssi - the running average rssi
      • setRssi

         void setRssi(int rssi)

        Sets the most recently measured rssi for use in distance calculations if a running average is not available

      • getIdentifier

         Identifier getIdentifier(int i)

        Returns the specified identifier - 0 indexed Note: to read id1, call getIdentifier(0);

        Parameters:
        i - - index identfier
      • getDataFields

         List<Long> getDataFields()

        Returns the list of data fields transmitted with the advertisement

      • getDistance

         double getDistance()

        Provides a calculated estimate of the distance to the beacon based on a running average of the RSSI and the transmitted power calibration value included in the beacon advertisement. This value is specific to the type of Android device receiving the transmission.

      • hashCode

         int hashCode()

        Calculate a hashCode for this beacon

      • equals

         boolean equals(Object that)

        Two detected beacons are considered equal if they share the same three identifiers, regardless of their mDistance or RSSI.

      • requestData

         void requestData(BeaconDataNotifier notifier)

        Requests server-side data for this beacon. Requires that a BeaconDataFactory be set up with a backend service.

        Parameters:
        notifier - interface providing a callback when data are available
      • toString

         String toString()

        Formats a beacon as a string showing only its unique identifiers

      • writeToParcel

        @Deprecated() void writeToParcel(Parcel out, int flags)

        Required for making object Parcelable. If you override this class, you must override this method if you add any additional fields.

      • isExtraBeaconData

         boolean isExtraBeaconData()

        Indicates whether this beacon is an "Extra data beacon," meaning one that has no identifiers but has data fields.