diff --git a/wear/src/main/java/no/nordicsemi/android/nrftoolbox/ble/BleManager.java b/wear/src/main/java/no/nordicsemi/android/nrftoolbox/ble/BleManager.java index cb3c0f26..9c2ed89a 100644 --- a/wear/src/main/java/no/nordicsemi/android/nrftoolbox/ble/BleManager.java +++ b/wear/src/main/java/no/nordicsemi/android/nrftoolbox/ble/BleManager.java @@ -583,27 +583,13 @@ public class BleManager implements BleProfileApi { return Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && enqueue(Request.newMtuRequest(mtu)); } - /** - * Returns the current MTU (Maximum Transfer Unit). MTU specifies the maximum number of bytes that can - * be sent in a single write operation. 3 bytes are used for internal purposes, so the maximum size is MTU-3. - * The value will changed only if requested with {@link #requestMtu(int)} and a successful callback is received. - * If the peripheral requests MTU change, the {@link BluetoothGattCallback#onMtuChanged(BluetoothGatt, int, int)} - * callback is not invoked, therefor the returned MTU value will not be correct. - * Use {@link android.bluetooth.BluetoothGattServerCallback#onMtuChanged(BluetoothDevice, int)} to get the - * callback with right value requested from the peripheral side. - * @return the current MTU value. Default to 23. - */ - protected final int getMtu() { + @Override + public final int getMtu() { return mMtu; } - /** - * This method overrides the MTU value. Use it only when the peripheral has changed MTU and you - * received the {@link android.bluetooth.BluetoothGattServerCallback#onMtuChanged(BluetoothDevice, int)} - * callback. If you want to set MTU as a master, use {@link #requestMtu(int)} instead. - * @param mtu the MTU value set by the peripheral. - */ - protected final void overrideMtu(final int mtu) { + @Override + public final void overrideMtu(final int mtu) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) mMtu = mtu; } diff --git a/wear/src/main/java/no/nordicsemi/android/nrftoolbox/ble/BleProfileApi.java b/wear/src/main/java/no/nordicsemi/android/nrftoolbox/ble/BleProfileApi.java index 3a87c8f6..2f0c0c14 100644 --- a/wear/src/main/java/no/nordicsemi/android/nrftoolbox/ble/BleProfileApi.java +++ b/wear/src/main/java/no/nordicsemi/android/nrftoolbox/ble/BleProfileApi.java @@ -22,7 +22,9 @@ package no.nordicsemi.android.nrftoolbox.ble; +import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothGatt; +import android.bluetooth.BluetoothGattCallback; import android.bluetooth.BluetoothGattCharacteristic; import android.bluetooth.BluetoothGattDescriptor; import android.content.Context; @@ -394,6 +396,26 @@ public interface BleProfileApi { */ boolean requestMtu(final int mtu); + /** + * Returns the current MTU (Maximum Transfer Unit). MTU specifies the maximum number of bytes that can + * be sent in a single write operation. 3 bytes are used for internal purposes, so the maximum size is MTU-3. + * The value will changed only if requested with {@link #requestMtu(int)} and a successful callback is received. + * If the peripheral requests MTU change, the {@link BluetoothGattCallback#onMtuChanged(BluetoothGatt, int, int)} + * callback is not invoked, therefor the returned MTU value will not be correct. + * Use {@link android.bluetooth.BluetoothGattServerCallback#onMtuChanged(BluetoothDevice, int)} to get the + * callback with right value requested from the peripheral side. + * @return the current MTU value. Default to 23. + */ + int getMtu(); + + /** + * This method overrides the MTU value. Use it only when the peripheral has changed MTU and you + * received the {@link android.bluetooth.BluetoothGattServerCallback#onMtuChanged(BluetoothDevice, int)} + * callback. If you want to set MTU as a master, use {@link #requestMtu(int)} instead. + * @param mtu the MTU value set by the peripheral. + */ + void overrideMtu(final int mtu); + /** * Requests the new connection priority. Acceptable values are: *