Skip to content

Commit bbecebe

Browse files
authored
Merge pull request NordicSemiconductor#170 from NordicSemiconductor/feature/retries
New feature: retrying DFU in case of undesired disconnection
2 parents dd95111 + 1a40f78 commit bbecebe

33 files changed

+1503
-871
lines changed

README.md

Lines changed: 45 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,14 @@
44

55
### Usage
66

7-
The compat library may be found on jcenter and Maven Central repository. Add it to your project by adding the following dependency:
7+
The DFU library may be found on jcenter and Maven Central repository. Add it to your project by
8+
adding the following dependency:
9+
10+
```Groovy
11+
implementation 'no.nordicsemi.android:dfu:1.9.0'
12+
```
13+
14+
For projects not migrated to Android Jetpack, use:
815

916
```Groovy
1017
implementation 'no.nordicsemi.android:dfu:1.8.1'
@@ -13,18 +20,28 @@ implementation 'no.nordicsemi.android:dfu:1.8.1'
1320
If you use proguard, add the following line to your proguard rules:
1421
```-keep class no.nordicsemi.android.dfu.** { *; }```
1522

23+
Starting from version 1.9.0 the library is able to retry a DFU update in case of an unwanted
24+
disconnection. However, to maintain backward compatibility, this feature is by default disabled.
25+
Call `initiator.setNumberOfRetries(int)` to set how many attempts the service should perform.
26+
Secure DFU will be resumed after it has been interrupted from the point it stopped, while the
27+
Legacy DFU will start again.
28+
1629
### Device Firmware Update (DFU)
1730

18-
The nRF5x Series chips are flash-based SoCs, and as such they represent the most flexible solution available. A key feature of the nRF5x Series and their associated software architecture
19-
and S-Series SoftDevices is the possibility for Over-The-Air Device Firmware Upgrade (OTA-DFU). See Figure 1. OTA-DFU allows firmware upgrades to be issued and downloaded to products
20-
in the field via the cloud and so enables OEMs to fix bugs and introduce new features to products that are already out on the market.
31+
The nRF5x Series chips are flash-based SoCs, and as such they represent the most flexible solution available.
32+
A key feature of the nRF5x Series and their associated software architecture and S-Series SoftDevices
33+
is the possibility for Over-The-Air Device Firmware Upgrade (OTA-DFU). See Figure 1.
34+
OTA-DFU allows firmware upgrades to be issued and downloaded to products in the field via the cloud
35+
and so enables OEMs to fix bugs and introduce new features to products that are already out on the market.
2136
This brings added security and flexibility to product development when using the nRF5x Series SoCs.
2237

2338
![Device Firmware Update](resources/dfu.png)
2439

25-
This repository contains a tested library for Android 4.3+ platform which may be used to perform Device Firmware Update on the nRF5x device using a phone or a tablet.
40+
This repository contains a tested library for Android 4.3+ platform which may be used to perform
41+
Device Firmware Update on the nRF5x device using a phone or a tablet.
2642

27-
DFU library has been designed to make it very easy to include these devices into your application. It is compatible with all Bootloader/DFU versions.
43+
DFU library has been designed to make it very easy to include these devices into your application.
44+
It is compatible with all Bootloader/DFU versions.
2845

2946
[![Alt text for your video](http://img.youtube.com/vi/LdY2m_bZTgE/0.jpg)](http://youtu.be/LdY2m_bZTgE)
3047

@@ -34,38 +51,50 @@ See the [documentation](documentation) for more information.
3451

3552
### Requirements
3653

37-
The library is compatible with nRF51 and nRF52 devices with S-Series Soft Device and the DFU Bootloader flashed on.
54+
The library is compatible with nRF51 and nRF52 devices with S-Series Soft Device and the
55+
DFU Bootloader flashed on.
3856

3957
### DFU History
4058

4159
#### Legacy DFU
4260

4361
* **SDK 4.3.0** - First version of DFU over Bluetooth Smart. DFU supports Application update.
44-
* **SDK 6.1.0** - DFU Bootloader supports Soft Device and Bootloader update. As the updated Bootloader may be dependent on the new Soft Device, those two may be sent and installed together.
62+
* **SDK 6.1.0** - DFU Bootloader supports Soft Device and Bootloader update. As the updated
63+
Bootloader may be dependent on the new Soft Device, those two may be sent and
64+
installed together.
4565
- Buttonless update support for non-bonded devices.
46-
* **SDK 7.0.0** - The extended init packet is required. The init packet contains additional validation information: device type and revision, application version, compatible Soft Devices and the firmware CRC.
47-
* **SDK 8.0.0** - The bond information may be preserved after an application update. The new application, when first started, will send the Service Change indication to the phone to refresh the services.
66+
* **SDK 7.0.0** - The extended init packet is required. The init packet contains additional
67+
validation information: device type and revision, application version, compatible
68+
Soft Devices and the firmware CRC.
69+
* **SDK 8.0.0** - The bond information may be preserved after an application update.
70+
The new application, when first started, will send the Service Change indication
71+
to the phone to refresh the services.
4872
- Buttonless update support for bonded devices
4973
- sharing the LTK between an app and the bootloader.
5074

5175
#### Secure DFU
5276

5377
* **SDK 12.0.0** - New Secure DFU has been released. Buttonless service is experimental.
54-
* **SDK 13.0.0** - Buttonless DFU (still experimental) uses different UUIDs. No bond sharing supported. Bootloader will use address +1.
55-
* **SDK 14.0.0** - Buttonless DFU is no longer experimental. A new UUID (0004) added for bonded only devices (previous one (0003) is for non-bonded only).
78+
* **SDK 13.0.0** - Buttonless DFU (still experimental) uses different UUIDs. No bond sharing
79+
supported. Bootloader will use address +1.
80+
* **SDK 14.0.0** - Buttonless DFU is no longer experimental. A new UUID (0004) added for bonded
81+
only devices (previous one (0003) is for non-bonded only).
5682
* **SDK 15.0.0** - Support for higher MTUs added.
5783

5884
This library is fully backwards compatible and supports both the new and legacy DFU.
59-
The experimental buttonless DFU service from SDK 12 is supported since version 1.1.0. Due to the fact, that this experimental service from SDK 12 is not safe,
60-
you have to call [starter.setUnsafeExperimentalButtonlessServiceInSecureDfuEnabled(true)](https://github.com/NordicSemiconductor/Android-DFU-Library/blob/release/dfu/src/main/java/no/nordicsemi/android/dfu/DfuServiceInitiator.java#L376)
61-
to enable it. Read the method documentation for details. It is recommended to use the Buttonless service from SDK 13 (for non-bonded devices, or 14 for bonded).
85+
The experimental buttonless DFU service from SDK 12 is supported since version 1.1.0.
86+
Due to the fact, that this experimental service from SDK 12 is not safe, you have to call
87+
[starter.setUnsafeExperimentalButtonlessServiceInSecureDfuEnabled(true)](https://github.com/NordicSemiconductor/Android-DFU-Library/blob/release/dfu/src/main/java/no/nordicsemi/android/dfu/DfuServiceInitiator.java#L376)
88+
to enable it. Read the method documentation for details. It is recommended to use the Buttonless
89+
service from SDK 13 (for non-bonded devices, or 14 for bonded).
6290
Both are supported since DFU Library 1.3.0.
6391

6492
Check platform folders for mode details about compatibility for each library.
6593

6694
### React Native
6795

68-
A library for both iOS and Android that is based on this library is available for React Native: [react-native-nordic-dfu](https://github.com/Pilloxa/react-native-nordic-dfu)
96+
A library for both iOS and Android that is based on this library is available for React Native:
97+
[react-native-nordic-dfu](https://github.com/Pilloxa/react-native-nordic-dfu)
6998

7099
### Resources
71100

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ buildscript {
66
google()
77
}
88
dependencies {
9-
classpath 'com.android.tools.build:gradle:3.2.1'
9+
classpath 'com.android.tools.build:gradle:3.3.1'
1010

1111
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4"
1212
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'

dfu/build.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ apply plugin: 'com.jfrog.bintray'
1515
ext {
1616
PUBLISH_GROUP_ID = 'no.nordicsemi.android'
1717
PUBLISH_ARTIFACT_ID = 'dfu'
18-
PUBLISH_VERSION = '1.8.1'
18+
PUBLISH_VERSION = '1.9.0'
1919
2020
bintrayRepo = 'android'
2121
bintrayName = 'dfu-library'
@@ -45,8 +45,8 @@ android {
4545
defaultConfig {
4646
minSdkVersion 18
4747
targetSdkVersion 28
48-
versionCode 22
49-
versionName "1.8.1"
48+
versionCode 23
49+
versionName "1.9.0"
5050
}
5151

5252
buildTypes {
@@ -58,7 +58,7 @@ android {
5858
}
5959

6060
dependencies {
61-
implementation 'androidx.core:core:1.1.0-alpha02'
61+
implementation 'androidx.core:core:1.1.0-alpha04'
6262
implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.0.0'
6363
implementation 'androidx.annotation:annotation:1.0.1'
6464
implementation 'com.google.code.gson:gson:2.8.5'

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
import android.bluetooth.BluetoothGattCharacteristic;
2828
import android.content.Intent;
2929

30+
import androidx.annotation.NonNull;
31+
3032
/**
3133
* A base implementation of a buttonless service. The purpose of a buttonless service is to
3234
* switch a device into the DFU bootloader mode.
@@ -51,7 +53,7 @@ public void onCharacteristicWrite(final BluetoothGatt gatt, final BluetoothGattC
5153
}
5254
}
5355

54-
BaseButtonlessDfuImpl(final Intent intent, final DfuBaseService service) {
56+
BaseButtonlessDfuImpl(@NonNull final Intent intent, @NonNull final DfuBaseService service) {
5557
super(intent, service);
5658
}
5759

@@ -68,7 +70,8 @@ public BaseBluetoothGattCallback getGattCallback() {
6870
* @param forceRefresh true, if cache should be cleared even for a bonded device. Usually the Service Changed indication should be used for this purpose.
6971
* @param scanForBootloader true to scan for advertising bootloader, false to keep the same address
7072
*/
71-
protected void finalize(final Intent intent, final boolean forceRefresh, final boolean scanForBootloader) {
73+
@SuppressWarnings("SameParameterValue")
74+
void finalize(@NonNull final Intent intent, final boolean forceRefresh, final boolean scanForBootloader) {
7275
/*
7376
* We are done with DFU. Now the service may refresh device cache and clear stored services.
7477
* For bonded device this is required only if if doesn't support Service Changed indication.

0 commit comments

Comments
 (0)