-
- All Implemented Interfaces:
-
android.os.Parcelable
public class Data implements Parcelable
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public @interfaceData.ValueFormatpublic @interfaceData.IntFormatpublic @interfaceData.LongFormatpublic @interfaceData.FloatFormat
-
Field Summary
Fields Modifier and Type Field Description public final static intFORMAT_UINT8public final static intFORMAT_UINT16public final static intFORMAT_UINT16_LEpublic final static intFORMAT_UINT16_BEpublic final static intFORMAT_UINT24public final static intFORMAT_UINT24_LEpublic final static intFORMAT_UINT24_BEpublic final static intFORMAT_UINT32public final static intFORMAT_UINT32_LEpublic final static intFORMAT_UINT32_BEpublic final static intFORMAT_SINT8public final static intFORMAT_SINT16public final static intFORMAT_SINT16_LEpublic final static intFORMAT_SINT16_BEpublic final static intFORMAT_SINT24public final static intFORMAT_SINT24_LEpublic final static intFORMAT_SINT24_BEpublic final static intFORMAT_SINT32public final static intFORMAT_SINT32_LEpublic final static intFORMAT_SINT32_BEpublic final static intFORMAT_SFLOATpublic final static intFORMAT_FLOATpublic final static Parcelable.Creator<Data>CREATOR
-
Method Summary
Modifier and Type Method Description static Datafrom(@NonNull() String value)static Datafrom(@NonNull() BluetoothGattCharacteristic characteristic)static Datafrom(@NonNull() BluetoothGattDescriptor descriptor)static DataopCode(byte opCode)static DataopCode(byte opCode, byte parameter)Array<byte>getValue()Returns the underlying byte array. StringgetStringValue(@IntRange(from = 0) int offset)Return the stored value of this characteristic. intsize()Returns the size of underlying byte array. StringtoString()BytegetByte(@IntRange(from = 0) int offset)Returns a byte at the given offset from the byte array. IntegergetIntValue(int formatType, @IntRange(from = 0) int offset)Returns an integer value from the byte array. LonggetLongValue(int formatType, @IntRange(from = 0) int offset)Returns a long value from the byte array. FloatgetFloatValue(int formatType, @IntRange(from = 0) int offset)Returns an float value from the given byte array. static intgetTypeLen(int formatType)Returns the size of a give value type. voidwriteToParcel(Parcel dest, int flags)intdescribeContents()-
-
Constructor Detail
-
Data
Data()
-
Data
Data(Array<byte> value)
-
-
Method Detail
-
from
static Data from(@NonNull() BluetoothGattCharacteristic characteristic)
-
from
static Data from(@NonNull() BluetoothGattDescriptor descriptor)
-
getStringValue
@Nullable() String getStringValue(@IntRange(from = 0) int offset)
Return the stored value of this characteristic.
See getValue for details.
- Parameters:
offset- Offset at which the string value can be found.
-
size
int size()
Returns the size of underlying byte array.
-
getByte
@Nullable() Byte getByte(@IntRange(from = 0) int offset)
Returns a byte at the given offset from the byte array.
- Parameters:
offset- Offset at which the byte value can be found.
-
getIntValue
@Nullable() Integer getIntValue(int formatType, @IntRange(from = 0) int offset)
Returns an integer value from the byte array.
The formatType parameter determines how the valueis to be interpreted. For example, setting formatType to FORMAT_UINT16_LE specifies that the first two bytes of thevalue at the given offset are interpreted to generate thereturn value.
- Parameters:
formatType- The format type used to interpret the value.offset- Offset at which the integer value can be found.
-
getLongValue
@Nullable() Long getLongValue(int formatType, @IntRange(from = 0) int offset)
Returns a long value from the byte array.
Only FORMAT_UINT32_LE and FORMAT_SINT32_LE are supported.
The formatType parameter determines how the valueis to be interpreted. For example, setting formatType to FORMAT_UINT32_LE specifies that the first four bytes of thevalue at the given offset are interpreted to generate thereturn value.
- Parameters:
formatType- The format type used to interpret the value.offset- Offset at which the integer value can be found.
-
getFloatValue
@Nullable() Float getFloatValue(int formatType, @IntRange(from = 0) int offset)
Returns an float value from the given byte array.
- Parameters:
formatType- The format type used to interpret the value.offset- Offset at which the float value can be found.
-
getTypeLen
static int getTypeLen(int formatType)
Returns the size of a give value type.
-
writeToParcel
void writeToParcel(Parcel dest, int flags)
-
describeContents
int describeContents()
-
-
-
-