Package org.altbeacon.beacon
Class BeaconTransmitter
- java.lang.Object
-
- org.altbeacon.beacon.BeaconTransmitter
-
public class BeaconTransmitter extends Object
Provides a mechanism for transmitting as a beacon. Requires Android 5.0
-
-
Field Summary
Fields Modifier and Type Field Description static intNOT_SUPPORTED_BLEstatic intNOT_SUPPORTED_CANNOT_GET_ADVERTISERstatic intNOT_SUPPORTED_CANNOT_GET_ADVERTISER_MULTIPLE_ADVERTISEMENTSstatic intNOT_SUPPORTED_MIN_SDKstatic intNOT_SUPPORTED_MULTIPLE_ADVERTISEMENTSDeprecated.static intSUPPORTED
-
Constructor Summary
Constructors Constructor Description BeaconTransmitter(Context context, BeaconParser parser)Creates a new beacon transmitter capable of transmitting beacons with the format specified in the BeaconParser and with the data fields specified in the Beacon object
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static intcheckTransmissionSupported(Context context)Checks to see if this device supports beacon advertisingintgetAdvertiseMode()intgetAdvertiseTxPowerLevel()booleanisConnectable()booleanisStarted()Tells if transmission has startedvoidsetAdvertiseMode(int mAdvertiseMode)AdvertiseSettings.ADVERTISE_MODE_BALANCED 3 Hz AdvertiseSettings.ADVERTISE_MODE_LOW_LATENCY 10 Hz AdvertiseSettings.ADVERTISE_MODE_LOW_POWER 1 HzvoidsetAdvertiseTxPowerLevel(int mAdvertiseTxPowerLevel)AdvertiseSettings.ADVERTISE_TX_POWER_HIGH -56 dBm @ 1 meter with Nexus 5 AdvertiseSettings.ADVERTISE_TX_POWER_LOW -75 dBm @ 1 meter with Nexus 5 AdvertiseSettings.ADVERTISE_TX_POWER_MEDIUM -66 dBm @ 1 meter with Nexus 5 AdvertiseSettings.ADVERTISE_TX_POWER_ULTRA_LOW not detected with Nexus 5voidsetBeacon(Beacon beacon)Sets the beacon whose fields will be transmittedvoidsetBeaconParser(BeaconParser beaconParser)Sets the beaconParsser used for formatting the transmissionvoidsetConnectable(boolean connectable)Whether the advertisement should indicate the device is connectable.voidstartAdvertising()Starts this beacon advertisingvoidstartAdvertising(Beacon beacon)Starts advertising with fields from the passed beaconvoidstartAdvertising(Beacon beacon, AdvertiseCallback callback)Starts advertising with fields from the passed beaconvoidstopAdvertising()Stops this beacon from advertising
-
-
-
Field Detail
-
SUPPORTED
public static final int SUPPORTED
- See Also:
- Constant Field Values
-
NOT_SUPPORTED_MIN_SDK
public static final int NOT_SUPPORTED_MIN_SDK
- See Also:
- Constant Field Values
-
NOT_SUPPORTED_BLE
public static final int NOT_SUPPORTED_BLE
- See Also:
- Constant Field Values
-
NOT_SUPPORTED_MULTIPLE_ADVERTISEMENTS
@Deprecated public static final int NOT_SUPPORTED_MULTIPLE_ADVERTISEMENTS
Deprecated.- See Also:
- Constant Field Values
-
NOT_SUPPORTED_CANNOT_GET_ADVERTISER
public static final int NOT_SUPPORTED_CANNOT_GET_ADVERTISER
- See Also:
- Constant Field Values
-
NOT_SUPPORTED_CANNOT_GET_ADVERTISER_MULTIPLE_ADVERTISEMENTS
public static final int NOT_SUPPORTED_CANNOT_GET_ADVERTISER_MULTIPLE_ADVERTISEMENTS
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
BeaconTransmitter
public BeaconTransmitter(Context context, BeaconParser parser)
Creates a new beacon transmitter capable of transmitting beacons with the format specified in the BeaconParser and with the data fields specified in the Beacon object- Parameters:
context-parser- specifies the format of the beacon transmission
-
-
Method Detail
-
isStarted
public boolean isStarted()
Tells if transmission has started- Returns:
-
setBeacon
public void setBeacon(Beacon beacon)
Sets the beacon whose fields will be transmitted- Parameters:
beacon-
-
setBeaconParser
public void setBeaconParser(BeaconParser beaconParser)
Sets the beaconParsser used for formatting the transmission- Parameters:
beaconParser-
-
getAdvertiseMode
public int getAdvertiseMode()
- Returns:
- advertiseMode
- See Also:
setAdvertiseMode(int)
-
setAdvertiseMode
public void setAdvertiseMode(int mAdvertiseMode)
AdvertiseSettings.ADVERTISE_MODE_BALANCED 3 Hz AdvertiseSettings.ADVERTISE_MODE_LOW_LATENCY 10 Hz AdvertiseSettings.ADVERTISE_MODE_LOW_POWER 1 Hz- Parameters:
mAdvertiseMode-
-
getAdvertiseTxPowerLevel
public int getAdvertiseTxPowerLevel()
- Returns:
- txPowerLevel
- See Also:
setAdvertiseTxPowerLevel(int mAdvertiseTxPowerLevel)
-
setAdvertiseTxPowerLevel
public void setAdvertiseTxPowerLevel(int mAdvertiseTxPowerLevel)
AdvertiseSettings.ADVERTISE_TX_POWER_HIGH -56 dBm @ 1 meter with Nexus 5 AdvertiseSettings.ADVERTISE_TX_POWER_LOW -75 dBm @ 1 meter with Nexus 5 AdvertiseSettings.ADVERTISE_TX_POWER_MEDIUM -66 dBm @ 1 meter with Nexus 5 AdvertiseSettings.ADVERTISE_TX_POWER_ULTRA_LOW not detected with Nexus 5- Parameters:
mAdvertiseTxPowerLevel-
-
setConnectable
public void setConnectable(boolean connectable)
Whether the advertisement should indicate the device is connectable.- Parameters:
connectable-
-
isConnectable
public boolean isConnectable()
- Returns:
- connectable
- See Also:
setConnectable(boolean)
-
startAdvertising
public void startAdvertising(Beacon beacon)
Starts advertising with fields from the passed beacon- Parameters:
beacon-
-
startAdvertising
public void startAdvertising(Beacon beacon, AdvertiseCallback callback)
Starts advertising with fields from the passed beacon- Parameters:
beacon-
-
startAdvertising
public void startAdvertising()
Starts this beacon advertising
-
stopAdvertising
public void stopAdvertising()
Stops this beacon from advertising
-
checkTransmissionSupported
public static int checkTransmissionSupported(Context context)
Checks to see if this device supports beacon advertising- Returns:
- SUPPORTED if yes, otherwise: NOT_SUPPORTED_MIN_SDK NOT_SUPPORTED_BLE NOT_SUPPORTED_MULTIPLE_ADVERTISEMENTS NOT_SUPPORTED_CANNOT_GET_ADVERTISER
-
-