Skip to content

Commit 67a4b85

Browse files
authored
Merge pull request #260 from Mattel/feature/allow-requesting-mtu-for-legacy-dfu
request mtu in Legacy
2 parents b5d587b + 2a34621 commit 67a4b85

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

dfu/src/main/java/no/nordicsemi/android/dfu/LegacyButtonlessDfuImpl.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import android.bluetooth.BluetoothGattService;
2828
import android.content.Intent;
2929
import android.content.SharedPreferences;
30+
import android.os.Build;
3031
import android.preference.PreferenceManager;
3132

3233
import java.util.UUID;
@@ -147,6 +148,13 @@ public void performDfu(@NonNull final Intent intent) throws DfuException, Device
147148

148149
mService.sendLogBroadcast(DfuBaseService.LOG_LEVEL_VERBOSE, "Jumping to the DFU Bootloader...");
149150

151+
// Let's request the MTU requested by the user. It may be that a lower MTU will be used.
152+
if (intent.hasExtra(DfuBaseService.EXTRA_MTU) && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
153+
final int requiredMtu = intent.getIntExtra(DfuBaseService.EXTRA_MTU, 517);
154+
logi("Requesting MTU = " + requiredMtu);
155+
requestMtu(requiredMtu);
156+
}
157+
150158
// Enable notifications
151159
enableCCCD(mControlPointCharacteristic, NOTIFICATIONS);
152160
mService.sendLogBroadcast(DfuBaseService.LOG_LEVEL_APPLICATION, "Notifications enabled");

dfu/src/main/java/no/nordicsemi/android/dfu/LegacyDfuImpl.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import android.bluetooth.BluetoothGattCharacteristic;
2727
import android.bluetooth.BluetoothGattService;
2828
import android.content.Intent;
29+
import android.os.Build;
2930
import android.os.SystemClock;
3031

3132
import java.util.Locale;
@@ -169,6 +170,13 @@ public void performDfu(@NonNull final Intent intent)
169170
logw("Legacy DFU bootloader found");
170171
mProgressInfo.setProgress(DfuBaseService.PROGRESS_STARTING);
171172

173+
// Let's request the MTU requested by the user. It may be that a lower MTU will be used.
174+
if (intent.hasExtra(DfuBaseService.EXTRA_MTU) && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
175+
final int requiredMtu = intent.getIntExtra(DfuBaseService.EXTRA_MTU, 517);
176+
logi("Requesting MTU = " + requiredMtu);
177+
requestMtu(requiredMtu);
178+
}
179+
172180
// Add one second delay to avoid the traffic jam before the DFU mode is enabled
173181
// Related:
174182
// issue: https://github.com/NordicSemiconductor/Android-DFU-Library/issues/10

0 commit comments

Comments
 (0)