public class Ucode extends ADManufacturerSpecific
ucode (written in lower case) is a global ID system defined by T-Engine Forum. The specification has been adopted as ITU-T H.642.
This class represents Bluetooth LE ucode Marker which is an AD structure to convey a ucode in BLE advertising packets.
Constructor and Description |
---|
Ucode()
Constructor which creates an instance with version=3,
ucode=all-zeros, status=0, power=0, count=0.
|
Ucode(int length,
int type,
byte[] data,
int companyId)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
static Ucode |
create(int length,
int type,
byte[] data,
int companyId)
Create a
Ucode instance. |
int |
getCount()
Get the transmission count.
|
int |
getInterval()
Get the transmission interval in milliseconds.
|
int |
getPower()
Get the transmission power in dBm.
|
int |
getStatus()
Get the status.
|
String |
getUcode()
Get the ucode.
|
int |
getVersion()
Get the version of the packet format of Bluetooth LE ucode Marker.
|
boolean |
isBatteryLow()
Get the flag value that indicates whether the battery is low or not.
|
void |
setCount(int count)
Set the transmission count.
|
void |
setPower(int power)
Set the transmission power in dBm.
|
void |
setStatus(int status)
Set the status.
|
void |
setUcode(String ucode)
Set the ucode.
|
void |
setVersion(int version)
Set the version of the packet format of Bluetooth LE ucode Marker.
|
String |
toString() |
getCompanyId, setCompanyId
public Ucode()
public Ucode(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 Bluetooth LE ucode Marker.companyId
- The company ID. The value should always be 0x019A
(T-Engine Forum).IllegalArgumentException
- data
is null
or the length of
data
is less than 22.public int getVersion()
public void setVersion(int version)
version
- The version number. The value should be in the range
from 0 to 255.IllegalArgumentException
- The given value is out of the valid range.public String getUcode()
public void setUcode(String ucode)
ucode
- The string representation of the ucode. It must consist
of 32 hex letters.IllegalArgumentException
- ucode
is null
or it does not consist of
32 hex letters.public int getStatus()
The meanings of the bits are as follows.
7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
Reserved | Reserved | Low Battery |
1 | Transmission Interval |
Combinations of the bits of Transmission Interval have the following meanings.
Bits | Interval (ms) |
---|---|
0b0000 |
10 |
0b0001 |
20 |
0b0010 |
40 |
0b0011 |
80 |
0b0100 |
160 |
0b0101 |
320 |
0b0110 |
640 |
0b0111 |
1280 |
0b1000 |
2560 |
0b1001 |
5120 |
Others | 10240 |
public void setStatus(int status)
status
- The status.public boolean isBatteryLow()
The returned value is the boolean representation of the Low Battery bit of the status.
public int getInterval()
The returned value is calculated from the bits of Transmission Interval in the status.
public int getPower()
public void setPower(int power)
power
- The transmission power in dBm. The valid range is from -128 to 127.IllegalArgumentException
- The given value is out of the valid range.public int getCount()
The value of the transmission count field is incremented per transmission. Note that the next value of 0xFF is 0x00.
public void setCount(int count)
count
- The transmission count. The value should be in
the range from 0x00 to 0xFF.IllegalArgumentException
- The given value is out of the valid range.public static Ucode create(int length, int type, byte[] data, int companyId)
Ucode
instance.
The format of data
should be as described in the following table.
Value | Description | |
---|---|---|
Company ID | 0x9A 0x01 |
The company ID assigned to T-Engine Forum. (Little Endian) |
Version | 1-byte unsigned number | The version number of Bluetooth LE ucode Marker. |
Ucode | 16-byte data | Ucode in the little endian order. |
Status | 1-byte data | Bit flags that represents the status of the peripheral device. |
Transmission Power | 1-byte signed number. | Transmission power in dBm. |
Transmission Count | 1-byte unsigned number. | The counter value incremented per transmission. |
Reserved | 3-byte zeros. | Reserved for future use. |
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 0x019A which represents
T-Engine ForumUcode
instance. null
is returned if the
length of data
is less than 22.public String toString()
toString
in class ADManufacturerSpecific
Copyright © 2016. All rights reserved.