public class IBeacon extends ADManufacturerSpecific
Constructor and Description |
---|
IBeacon()
Constructor which creates an instance with UUID=all-zeros,
major=0, minor=0, and power=0.
|
IBeacon(int length,
int type,
byte[] data,
int companyId)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
static IBeacon |
create(int length,
int type,
byte[] data,
int companyId)
Create an
IBeacon instance. |
int |
getMajor()
Get the major number.
|
int |
getMinor()
Get the minor number.
|
int |
getPower()
Get the power.
|
UUID |
getUUID()
Get the proximity UUID.
|
void |
setMajor(int major)
Set the major number.
|
void |
setMinor(int minor)
Set the minor number.
|
void |
setPower(int power)
Set the power.
|
void |
setUUID(UUID uuid)
Set the proximity UUID.
|
String |
toString() |
getCompanyId, setCompanyId
public IBeacon()
public IBeacon(int length, int type, byte[] data, int companyId)
length
- The length of the AD structure.type
- The AD type. The value should always be 0xFF
(Manufacturer Specific Data).data
- The AD data whose format is iBeacon.companyId
- The company ID. The value should always be 0x004C
(Apple, Inc.).IllegalArgumentException
- data
is null
or the length of
data
is less than 25.public UUID getUUID()
public void setUUID(UUID uuid)
uuid
- The proximity UUID. The value must not be null
.IllegalArgumentException
- The given value is null
.public int getMajor()
public void setMajor(int major)
major
- The major number. The value should be in the range from 0 to 65535.IllegalArgumentException
- The given value is out of the valid range.public int getMinor()
public void setMinor(int minor)
minor
- The minor number. The value should be in the range from 0 to 65535.IllegalArgumentException
- The given value is out of the valid range.public int getPower()
public void setPower(int power)
power
- The power. The value should be in the range from -128 to 127.IllegalArgumentException
- The given value is out of the valid range.public static IBeacon create(int length, int type, byte[] data, int companyId)
IBeacon
instance.
The format of data
should be as described in the following table.
Value | Description | |
---|---|---|
Company ID | 0x4C 0x00 |
The company ID assigned to Apple, Inc. (Little Endian) |
Format ID | 0x02 0x15 |
The format ID which represents iBeacon |
Proximity UUID | 16-byte data | Proximity UUID |
Major number | 2-byte data | Major number (Big Endian) |
Minor number | 2-byte data | Minor number (Big Endian) |
Power | 1-byte data | The 2's complement of the calibrated Tx Power |
length
- The length of the AD structure.type
- The AD type. The value should always be 0xFF which represents
Manufacturer Specific Data.data
- The AD type. The value of the first two bytes is the company ID.companyId
- The company ID. The value should always be 0x004C which represents
Apple, Inc.IBeacon
instance. null
is returned if the
length of data
is less than 25.public String toString()
toString
in class ADManufacturerSpecific
Copyright © 2016. All rights reserved.