mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2025-01-27 10:07:32 +01:00
added mtu transactions
This commit is contained in:
parent
98ea9be5cd
commit
64b407da92
@ -351,6 +351,11 @@ public abstract class AbstractBTLEDeviceSupport extends AbstractDeviceSupport im
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMtuChanged(BluetoothGatt gatt, int mtu, int status) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSetFmFrequency(float frequency) {
|
||||
|
||||
|
@ -209,4 +209,9 @@ public abstract class AbstractBTLEOperation<T extends AbstractBTLEDeviceSupport>
|
||||
public void onReadRemoteRssi(BluetoothGatt gatt, int rssi, int status) {
|
||||
mSupport.onReadRemoteRssi(gatt, rssi, status);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMtuChanged(BluetoothGatt gatt, int mtu, int status) {
|
||||
mSupport.onMtuChanged(gatt, mtu, status);
|
||||
}
|
||||
}
|
||||
|
@ -60,4 +60,8 @@ public abstract class AbstractGattCallback implements GattCallback {
|
||||
@Override
|
||||
public void onReadRemoteRssi(BluetoothGatt gatt, int rssi, int status) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMtuChanged(BluetoothGatt gatt, int mtu, int status) {
|
||||
}
|
||||
}
|
||||
|
@ -533,6 +533,19 @@ public final class BtLEQueue {
|
||||
checkWaitingCharacteristic(characteristic, status);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void onMtuChanged(BluetoothGatt gatt, int mtu, int status) {
|
||||
super.onMtuChanged(gatt, mtu, status);
|
||||
|
||||
if(getCallbackToUse() != null){
|
||||
getCallbackToUse().onMtuChanged(gatt, mtu, status);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void onCharacteristicRead(BluetoothGatt gatt,
|
||||
BluetoothGattCharacteristic characteristic,
|
||||
|
@ -104,6 +104,8 @@ public interface GattCallback {
|
||||
*/
|
||||
void onReadRemoteRssi(BluetoothGatt gatt, int rssi, int status);
|
||||
|
||||
void onMtuChanged(BluetoothGatt gatt, int mtu, int status);
|
||||
|
||||
// /**
|
||||
// * @see BluetoothGattCallback#onMtuChanged(BluetoothGatt, int, int)
|
||||
// * @param gatt
|
||||
|
@ -18,13 +18,17 @@
|
||||
package nodomain.freeyourgadget.gadgetbridge.service.btle;
|
||||
|
||||
import android.bluetooth.BluetoothGattCharacteristic;
|
||||
import android.os.Build;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.RequiresApi;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.actions.NotifyAction;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.actions.ReadAction;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.actions.RequestMtuAction;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.actions.WaitAction;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.actions.WriteAction;
|
||||
|
||||
@ -56,6 +60,13 @@ public class TransactionBuilder {
|
||||
return add(action);
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
public TransactionBuilder requestMtu(int mtu){
|
||||
return add(
|
||||
new RequestMtuAction(mtu)
|
||||
);
|
||||
}
|
||||
|
||||
public TransactionBuilder notify(BluetoothGattCharacteristic characteristic, boolean enable) {
|
||||
if (characteristic == null) {
|
||||
LOG.warn("Unable to notify characteristic: null");
|
||||
|
@ -0,0 +1,31 @@
|
||||
package nodomain.freeyourgadget.gadgetbridge.service.btle.actions;
|
||||
|
||||
import android.bluetooth.BluetoothGatt;
|
||||
import android.bluetooth.BluetoothGattCharacteristic;
|
||||
import android.os.Build;
|
||||
|
||||
import androidx.annotation.RequiresApi;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.BtLEAction;
|
||||
|
||||
public class RequestMtuAction extends BtLEAction {
|
||||
private int mtu;
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
public RequestMtuAction(int mtu) {
|
||||
super(null);
|
||||
this.mtu = mtu;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean expectsResult() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
@Override
|
||||
public boolean run(BluetoothGatt gatt) {
|
||||
return gatt.requestMtu(this.mtu);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user