public final class BleWrite extends BleOp<BleWrite>
BleDevice.write(BleWrite)
,
or BleDevice.write(BleWrite, ReadWriteListener)
. Note that all BleOp
classes assume
the device you're talking to is ByteOrder.BIG_ENDIAN
. While Java is ByteOrder.BIG_ENDIAN
by
default, android actually is ByteOrder.LITTLE_ENDIAN
, so the convenience methods take this into
account by reversing the bytes. If you don't want this to happen, the call setIsBigEndian(boolean)
to
false
.Modifier and Type | Class and Description |
---|---|
static class |
BleWrite.Builder
Builder class to build out a list (or array) of
BleWrite instances. |
Modifier and Type | Field and Description |
---|---|
static BleWrite |
INVALID
"Invalid" static instance used when doing things like setting connection parameters
|
Constructor and Description |
---|
BleWrite() |
BleWrite(BleWrite write)
Constructor which creates a new
BleWrite from an existing one. |
BleWrite(boolean bigEndian) |
BleWrite(java.util.UUID characteristicUuid) |
BleWrite(java.util.UUID serviceUuid,
java.util.UUID characteristicUuid) |
Modifier and Type | Method and Description |
---|---|
ReadWriteListener.Type |
getWriteType_safe()
This is almost the same as
getWriteType() , only that this will never return null . |
ReadWriteListener.Type |
getWriteType() |
boolean |
isValid()
Returns
true if the minimum values have been set for this operation |
BleWrite |
setBoolean(boolean value)
Set the boolean to write.
|
BleWrite |
setBytes(byte[] data)
Set the raw bytes to write.
|
BleWrite |
setInt(int val)
Set an int to be written.
|
BleWrite |
setIsBigEndian(boolean isBigEndian)
Tells SweetBlue the endianness of the BLE device you want to perform a write to.
|
BleWrite |
setLong(long val)
Set a long to be written.
|
BleWrite |
setShort(short val)
Set a short to be written.
|
BleWrite |
setString(java.lang.String value)
Set a string to be written.
|
BleWrite |
setString(java.lang.String value,
java.lang.String stringEncoding)
Set a string to be written.
|
BleWrite |
setWriteType(ReadWriteListener.Type writeType)
Set the
ReadWriteListener.Type of the write to perform. |
getCharacteristicUuid, getData, getDescriptorFilter, getDescriptorUuid, getReadWriteListener, getServiceUuid, isCharUuidValid, isNotify, isRead, isServiceUuidValid, isWrite, setCharacteristicUUID, setData, setDescriptorFilter, setReadWriteListener, setServiceUUID
public static final BleWrite INVALID
public BleWrite()
public BleWrite(java.util.UUID serviceUuid, java.util.UUID characteristicUuid)
public BleWrite(java.util.UUID characteristicUuid)
public BleWrite(boolean bigEndian)
public final boolean isValid()
BleOp
true
if the minimum values have been set for this operationpublic final BleWrite setIsBigEndian(boolean isBigEndian)
setBoolean(boolean)
setInt(int)
setLong(long)
setShort(short)
setString(String)
setString(String, String)
public final BleWrite setWriteType(ReadWriteListener.Type writeType)
ReadWriteListener.Type
of the write to perform. This is here in the case that the
characteristic you are writing to has more than one write type associated with it eg. BluetoothGattCharacteristic.WRITE_TYPE_NO_RESPONSE
,
BluetoothGattCharacteristic.WRITE_TYPE_SIGNED
along with standard writes.public final ReadWriteListener.Type getWriteType()
public final ReadWriteListener.Type getWriteType_safe()
getWriteType()
, only that this will never return null
. If the writetype wasn't
explicitly set, it will be null
, in this case, this method will return the type as ReadWriteListener.Type.WRITE
.public final BleWrite setBytes(byte[] data)
public final BleWrite setBoolean(boolean value)
public final BleWrite setInt(int val)
public final BleWrite setShort(short val)
public final BleWrite setLong(long val)
public final BleWrite setString(java.lang.String value, java.lang.String stringEncoding)
String.getBytes()
is used instead, which uses "UTF-8" by default.public final BleWrite setString(java.lang.String value)