public class ValueInterpreter
extends java.lang.Object
RxBleConnection.readCharacteristic(UUID) or
RxBleConnection.setupIndication(UUID). If the data in emitted byte arrays is stored using
a standardised Bluetooth Specification format
This class is a copied from BluetoothGattCharacteristic.getIntValue(int, int),
BluetoothGattCharacteristic.getFloatValue(int, int) and
BluetoothGattCharacteristic.getStringValue(int)| Modifier and Type | Class and Description |
|---|---|
static interface |
ValueInterpreter.FloatFormatType |
static interface |
ValueInterpreter.IntFormatType |
| Modifier and Type | Field and Description |
|---|---|
static int |
FORMAT_FLOAT
Characteristic value format type float (32-bit float)
|
static int |
FORMAT_SFLOAT
Characteristic value format type sfloat (16-bit float)
|
static int |
FORMAT_SINT16
Characteristic value format type sint16
|
static int |
FORMAT_SINT32
Characteristic value format type sint32
|
static int |
FORMAT_SINT8
Characteristic value format type sint8
|
static int |
FORMAT_UINT16
Characteristic value format type uint16
|
static int |
FORMAT_UINT32
Characteristic value format type uint32
|
static int |
FORMAT_UINT8
Characteristic value format type uint8
|
| Modifier and Type | Method and Description |
|---|---|
static java.lang.Float |
getFloatValue(byte[] value,
int formatType,
int offset)
Return the float value interpreted from the passed byte array.
|
static java.lang.Integer |
getIntValue(byte[] value,
int formatType,
int offset)
Return the integer value interpreted from the passed byte array.
|
static java.lang.String |
getStringValue(byte[] value,
int offset)
Return the string value interpreted from the passed byte array.
|
public static final int FORMAT_UINT8
public static final int FORMAT_UINT16
public static final int FORMAT_UINT32
public static final int FORMAT_SINT8
public static final int FORMAT_SINT16
public static final int FORMAT_SINT32
public static final int FORMAT_SFLOAT
public static final int FORMAT_FLOAT
public static java.lang.Integer getIntValue(byte[] value,
int formatType,
int offset)
The formatType parameter determines how the value
is to be interpreted. For example, setting formatType to
FORMAT_UINT16 specifies that the first two bytes of the
characteristic value at the given offset are interpreted to generate the
return value.
value - The byte array from which to interpret value.formatType - The format type used to interpret the value.offset - Offset at which the integer value can be found.public static java.lang.Float getFloatValue(byte[] value,
int formatType,
int offset)
value - The byte array from which to interpret value.formatType - The format type used to interpret the value.offset - Offset at which the float value can be found.public static java.lang.String getStringValue(byte[] value,
int offset)
offset - Offset at which the string value can be found.