29 lines
811 B
Java
29 lines
811 B
Java
package nodomain.freeyourgadget.gadgetbridge.btle;
|
|
|
|
import android.bluetooth.BluetoothGatt;
|
|
import android.bluetooth.BluetoothGattCallback;
|
|
import android.bluetooth.BluetoothGattCharacteristic;
|
|
|
|
/**
|
|
* Invokes a write operation on a given GATT characteristic.
|
|
* The result status will be made available asynchronously through the
|
|
* {@link BluetoothGattCallback}
|
|
*/
|
|
public class WriteAction extends BtLEAction {
|
|
|
|
private byte[] value;
|
|
|
|
public WriteAction(BluetoothGattCharacteristic characteristic, byte[] value) {
|
|
super(characteristic);
|
|
this.value = value;
|
|
}
|
|
|
|
@Override
|
|
public boolean run(BluetoothGatt gatt) {
|
|
if (getCharacteristic().setValue(value)) {
|
|
return gatt.writeCharacteristic(getCharacteristic());
|
|
}
|
|
return false;
|
|
}
|
|
}
|