GithubHelp home page GithubHelp logo

nordicsemiconductor / android-dfu-library Goto Github PK

View Code? Open in Web Editor NEW
752.0 56.0 263.0 5.26 MB

Device Firmware Update library and Android app

Home Page: http://www.nordicsemi.com/dfu

License: BSD 3-Clause "New" or "Revised" License

Java 72.42% Ruby 0.23% Shell 5.12% Kotlin 22.23%
dfu-library dfu bluetooth-le bluetooth-low-energy nrf5x nrf52 nrf51 ble

android-dfu-library's Introduction

Download

Device Firmware Update

Update nRF5 SDK firmware using Bluetooth LE.

This repository contains the source code of the DFU library (lib/dfu module) and nRF DFU app.

The DFU is design to update the firmware of nRF51 or nRF52 Series SoCs having an

  • nRF5 SDK Secure Bootloader (v12.0.0 or newer) or
  • nRF5 SDK Legacy Bootloader (v4.3.0-11.0.0).

Important

The DFU Library can't be used to update firmware developed with the nRF Connect SDK.

Use nRF Connect Device Manager instead.

Application

Get it on Google Play

nRF Device Firmware Update is a mobile app for updating nRF5 SDK firmware using Bluetooth Low Energy as a transport.

Welcome screen Main screen Settings

Supported files

The firmware should be in .zip file format, prepared using nRF Util. The firmware can be selected from the local storage on your Android or downloaded from the cloud using a deep-link.

Deep links

Application opens links with the provided format for both http and https. Clicking a link automatically opens the app. The downloaded will be saved in the Download folder on the phone. Downloaded file is displayed in the app and ready to use.

Link format: https://www.nordicsemi.com/dfu/?file=link_to_file

Note: Keep in mind to replace '&' with '%26' in the link_to_file.

Library

The lib_dfu module contains the source code of the DFU library for Android.

The DFU library is available on Maven Central repository. Add it to your project by adding the following dependency:

implementation 'no.nordicsemi.android:dfu:2.5.0'

Latest version targeting API lower than 31 is 1.11.1.

For projects not migrated to Android Jetpack, use version 1.8.1.

Note: Those versions are not maintained anymore. All new features and bug fixes will be released on the latest version only.

Proguard / R8

If you use proguard/R8, add the following line to your proguard rules (although this should be added automatically): -keep class no.nordicsemi.android.dfu.** { *; }

Required permissions

Android 4.3 - 11

To communicate with Bluetooth LE devices on Android version 4.3 until 11 two permissions were required: BLUETOOTH and BLUETOOTH_ADMIN. It is enough to put them in the AndroidManifest.xml file. If your app targets API 31 or newer set android:maxSdkVersion="30" as on API 31 they were replaced by BLUETOOTH_CONNECT and BLUETOOTH_SCAN runtime permissions (see below).

Android 6 - 11

If your device is using the Nordic Buttonless Service for switching from app mode to DFU bootloader mode, this library will handle switching automatically. In case your bootloader is configured to advertise with incremented MAC address (that is you use Secure DFU and the device is not bonded) this library will need to scan for the new BluetoothDevice. In Android 6-11, location permission is required and has to be granted in runtime before DFU is started.

Starting from Android 8.1.0, all scans done without a scan filter whilst the screen is turned off will not return any scan results.

Note: "ACCESS_BACKGROUND_LOCATION" permission would also be required to trigger a successful DFU whilst the device screen is turned off, mainly to receive the scan results when scanning and connecting to the peripheral in bootloader mode while the device screen is turned off.

Android 12+

Starting from Android 12 location permission is not needed, instead BLUETOOTH_CONNECT is required. When your device is using buttonless service and changes MAC address, it also requires BLUETOOTH_SCAN permission to be granted. This permission can be used with neverForLocation flag. Read more in Bluetooth permissions.

Retrying

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

Device Firmware Update (DFU)

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 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 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. This brings added security and flexibility to product development when using the nRF5x Series SoCs.

Device Firmware Update

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.

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.

Alt text for your video

Documentation

See the documentation for more information.

Requirements

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

DFU History

Legacy DFU

  • SDK 4.3.0 - First version of DFU over Bluetooth Smart. DFU supports Application update.
  • 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.
    • Buttonless update support for non-bonded devices.
  • 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.
  • 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.
    • Buttonless update support for bonded devices
    • sharing the LTK between an app and the bootloader.

Secure DFU

  • SDK 12.0.0 - New Secure DFU has been released. Buttonless service is experimental.
  • SDK 13.0.0 - Buttonless DFU (still experimental) uses different UUIDs. No bond sharing supported. Bootloader will use address +1.
  • 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).
  • SDK 15.0.0 - Support for higher MTUs added.

This library is fully backwards compatible and supports both the new and legacy DFU. 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, you have to call starter.setUnsafeExperimentalButtonlessServiceInSecureDfuEnabled(true) 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). Both are supported since DFU Library 1.3.0.

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

Related libraries

iOS version

iOS version of the same library can be found at IOS-DFU-Library.

React Native

A library for both iOS and Android that is based on this library is available for React Native: react-native-nordic-dfu

Flutter

A library for both iOS and Android that is based on this library is available for Flutter: nordic-dfu

Xamarin

Simple binding library for Android is available on nuget: Laerdal.Dfu

Resources

android-dfu-library's People

Contributors

alixwar avatar anas-ambri avatar brianherold avatar chris-guidry avatar cnbuff410 avatar colinmadere avatar crobertsbmw avatar dev-cqkct avatar domir avatar dwalkes avatar fbernaly avatar fengqiangboy avatar follower avatar hrldcpr avatar jrluppold avatar juliansteenbakker avatar kcttanxiaofeng avatar lachtanek avatar lopobo avatar marcbaldwin avatar pavlostze avatar philips77 avatar roshanrajaratnam avatar silverdark avatar skrabacz-michal avatar sylwester-zielinski avatar tobiasroeddiger avatar tompi avatar vikeri avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

android-dfu-library's Issues

EXTRA_RESTORE_BOND

Is this purposefully not exposed via DfuServiceInitiator? There doesn't appear to be any way to set it to true.

Transfer is stopped when sending data.

When I used the DFU to upgrading the firmware.The process before the transmission of Firmware packets is all normal.But,When Firmware packet being transmitted , progress will be stuck in such as 7% or 53% or 93%.This problem only occurs on my device,My Device is Samsung S7 Edge, Android 6.0.1.But when I use the nRF tools,this problem doesn‘t exist.

GATT Invalid Handle / unable to read version number on first attempt when bonded

@philips77

When we want to perform DFU while maintaining a bond, the first attempt always fails after the device has switched to bootloader (dual bank, s132) and we receive the error "GATT INVALID HANDLE" from the DFU library.
When we retry (while the device is still in bootloader) it succeeds. However the first attempt when starting from the application always fails after the bootloader has been entered (I have verified that the device is in bootloader mode at that time).

This issue does not occur when we don't use bonding and it also doesn't occur when we use nrfConnect to perform an update (either bonded or not bonded, both succeed in that case).

The Android log shows a connection state change error and an error on reading the version number:
D/ViewRootImpl: ViewPostImeInputStage processPointer 0
D/ViewRootImpl: ViewPostImeInputStage processPointer 1
D/BluetoothGatt: refresh() - device: FB:E5:EA:21:FC:CF
D/BluetoothGatt: onClientConnParamsChanged() - Device=FB:E5:EA:21:FC:CF interval=6 status=0
D/BluetoothGatt: onClientConnParamsChanged() - Device=FB:E5:EA:21:FC:CF interval=39 status=0
I/DfuBaseService: Connecting to the device...
D/BluetoothGatt: connect() - device: FB:E5:EA:21:FC:CF, auto: false
D/BluetoothGatt: registerApp()
D/BluetoothGatt: registerApp() - UUID=306917d8-60b2-4b06-a91a-6c3971e9f9e1
D/BluetoothGatt: onClientRegistered() - status=0 clientIf=6
D/BluetoothGatt: onClientConnectionState() - status=0 clientIf=6 device=FB:E5:EA:21:FC:CF
I/DfuBaseService: Connected to GATT server
I/DfuBaseService: Waiting 1600 ms for a possible Service Changed indication...
D/BluetoothGatt: discoverServices() - device: FB:E5:EA:21:FC:CF
I/DfuBaseService: Attempting to start service discovery... succeed
D/BluetoothGatt: onSearchComplete() = Device=FB:E5:EA:21:FC:CF Status=0
I/DfuBaseService: Services discovered
I/DfuBaseService: Services discovered
I/DfuImpl: Reading DFU version number...
I/DfuImpl: Version number read: 0.1
W/DfuImpl: Application with buttonless update found
I/DfuImpl: Enabling notifications...
D/BluetoothGatt: setCharacteristicNotification() - uuid: 00001531-1212-efde-1523-785feabcd123 enable: true
I/DfuImpl: Sending Start DFU command (Op Code = 1, Upload Mode = 4)
D/BluetoothGatt: onClientConnectionState() - status=19 clientIf=6 device=FB:E5:EA:21:FC:CF
D/BluetoothGatt: onClientConnectionState() - status=19 clientIf=8 device=FB:E5:EA:21:FC:CF
E/DfuBaseService: Connection state change error: 19 newState: 0
I/DfuBaseService: Cleaning up...
D/BluetoothGatt: close()
D/BluetoothGatt: unregisterApp() - mClientIf=6
I/DfuImpl: Starting service that will connect to the DFU bootloader
I/DfuBaseService: Action received: android.bluetooth.device.action.ACL_DISCONNECTED
I/DfuBaseService: Connecting to the device...
D/BluetoothGatt: connect() - device: FB:E5:EA:21:FC:CF, auto: false
D/BluetoothGatt: registerApp()
D/BluetoothGatt: registerApp() - UUID=ef88d4c9-2a71-4c43-b51c-b750b54337bd
D/BluetoothGatt: onClientRegistered() - status=0 clientIf=6
D/BluetoothGatt: onClientConnectionState() - status=0 clientIf=6 device=FB:E5:EA:21:FC:CF
I/DfuBaseService: Connected to GATT server
I/DfuBaseService: Waiting 1600 ms for a possible Service Changed indication...
D/BluetoothGatt: discoverServices() - device: FB:E5:EA:21:FC:CF
I/DfuBaseService: Attempting to start service discovery... succeed
D/BluetoothGatt: onSearchComplete() = Device=FB:E5:EA:21:FC:CF Status=0
I/DfuBaseService: Services discovered
I/DfuBaseService: Services discovered
I/DfuImpl: Reading DFU version number...
E/DfuImpl: Characteristic read error: 1
E/DfuBaseService: Unable to read version number (error 1)

I/DfuBaseService: Disconnecting from the device...
D/BluetoothGatt: cancelOpen() - device: FB:E5:EA:21:FC:CF
D/BluetoothGatt: onClientConnectionState() - status=0 clientIf=6 device=FB:E5:EA:21:FC:CF
I/DfuBaseService: Disconnected from GATT server
I/DfuBaseService: Cleaning up...
D/BluetoothGatt: close()
D/BluetoothGatt: unregisterApp() - mClientIf=6
I/DfuBaseService: Action received: android.bluetooth.device.action.ACL_DISCONNECTED

I am suspecting a disconnect in the bootloader for some reason, however nrfConnect does not seem to have any issues with this (or is simply performing a retry in the background?) . As mentioned, the issue does not occur when we don't bond with the device. Any ideas what might be causing this?

Gradle error: "Configuration with name 'default' not found."

Just got this when following your instructions for adding this to an existing project in Android Studio. I'm on the latest Android Studio (2.2.2) and gradle 2.14.1.

I can add this line to the dependencies bit of my app/build.gradle and it will build fine:

compile 'no.nordicsemi.android:dfu:1.0.4'

But when I add this:

compile project(':..:DFULibrary:dfu')

I get the error.

build tools version

Hi, I'm using this wonderful library, but recently ran into some troubles due to other libraries working with build tools version 23 and crashes with version 25.
So I now cloned the dfu library, changed the build tools to version 23, and it works again.

My question: is there any reason you upgraded to build tools version 25? Or is it just to stay up to date? Any project including this library via maven will be forced to use build tools 25, with which many projects seem to have issues.

DFU does not restart when device is in Invalid State

In Legacy DFU, when the DFU process has been interrupted and is being repeated, the device is in "Resume sending" state. Resuming is not supported by this lib (nor iOS DFU Library) for Legacy DFU (there is no CRC check on the firmware so no way to check what fw was sent before). Instead the lib should reset the device and start new DFU again. It does it, but only in 1 of 3 cases (here). It fails when the ZIP contains SD/BL and App or when the bootloader is from SDK 6.1 or older.
It should do similar restart in all 3 cases.

I can't OAD success!

the callback message:OnError=4096,errorType=0,Message:DFU DEVICE DISCONNECTED!
I try many time,every time is fail.

Cannot listen for DFU updates in non activity class

Hi folks,

I am currently writing a wrapper around the Android DFU Library aiming at simplify the Bluetooth communication with an electronic device (nRF51822) I am working on.

The idea is the following: having a class (not an Activity) called DeviceManager which exposes a few methods such as:

  • powerOn()
  • powerOff()
  • executeDFU()

and an interface called DeviceInterface which requires the following methods to be overwritten:

  • onPowerOn(boolean, String)
  • onPowerOff(boolean, String)
  • onDfuDone(boolean, String)

All the code managing the Bluetooth communication with the device is therefore embedded in the DeviceManagerclass.

I am now working on the DFU part, to let developers updating the firmware of our device therefore, I let the DeviceManager class extending the DfuBaseService class to be able to perform the DFU on my device. The issue I am facing is the following:

after calling the start() method of the DfuServiceInitiator I am not able to get any update either in the DfuProgressListener nor in the DfuLogListener.

Below I am reporting the piece of code that is supposed to start the DFU process (called inside the onLeScan() callback of the Android BluetoothAdapter).

private final BluetoothAdapter.LeScanCallback mScanCallback = new BluetoothAdapter.LeScanCallback() {
    @Override
    public void onLeScan(final BluetoothDevice device, final int rssi, final byte[] scanRecord) {

        // Code for filter the device based on address and name ....

        final DfuServiceInitiator dfuStarter =
                            new DfuServiceInitiator(device.getAddress())
                            .setKeepBond(true)
                            .setZip(mDfuZipUri)
                            .setDeviceName(device.getName());
        dfuStarter.start(mContext, ShDeviceManager.class);
    }
};

In addition, when my DeviceManager class is being instantiated I set the DfuProgressListener and DfuLogListener as follows.

public DeviceManager(String deviceName, DeviceInterface delegate, Context context) {
    mDeviceName = deviceName;
    bleDelegate = delegate;
    mContext = context;

    final BluetoothManager btManager = (BluetoothManager) mContext.getSystemService(Context.BLUETOOTH_SERVICE);
    mBluetoothAdapter = btManager.getAdapter();

    DfuServiceListenerHelper.registerLogListener(mContext, mDfuLogListener);
    DfuServiceListenerHelper.registerProgressListener(mContext, mDfuProgressListener);
}

The 2 listeners are declared in the DeviceManager class as follows:

private final DfuLogListener mDfuLogListener = new DfuLogListener() {
    @Override
    public void onLogEvent(String deviceAddress, int level, String message) {
        Log.d("DfuLogListener", String.valueOf(level) + " " + message);
    }
};

private final DfuProgressListener mDfuProgressListener = new DfuProgressListenerAdapter() {
    @Override
    public void onDeviceConnecting(final String deviceAddress) {
        Log.d("DFU", "onDeviceConnecting " + deviceAddress);
    }

    @Override
    public void onDfuProcessStarting(final String deviceAddress) {
        Log.d("DFU", "onDfuProcessStarting " + deviceAddress);
    }

    @Override
    public void onDfuCompleted(final String deviceAddress) {
        Log.d("DFU", "onDfuCompleted " + deviceAddress);
    }

    @Override
    public void onError(final String deviceAddress, final int error, final int errorType, final String message) {
        Log.d("DFU", "onError " + deviceAddress + " " + message);
    }
};

Finally, given that my DeviceManager extends the DfuBaseService class I needed to override the protected Class<? extends Activity> getNotificationTarget() method which in my case I made it returning null. Would this be the issue?

To sum up, given the configuration described above, I cannot see any call to any of the listeners methods.

Hope you guys could drive me toward the right way in overcoming such issue.

Best,
Nallo

The Second DFU process Failed

Hi,

My application is a little bit different with others. We do two DFU process at the same time since our big app size. Normally our first DFU process would succeed. But the second one would fail. This issue would only be present in some special Android phones. Most Android phones work. But even for the same failed Android phone, it would succeed sometimes. The following log was reported by Android system. Please advise.

by the way we are using SDK9 with S110 softdevice. And single bank is used for bootloader.

11-25 18:02:11.525 19306-19306/com.putao.wd E/BluetoothFuncManager: onProgressChanged info:C7:6B:39:0C:26:9A percent98
11-25 18:02:12.285 19306-19306/com.putao.wd E/BluetoothFuncManager: onProgressChanged info:C7:6B:39:0C:26:9A percent99
11-25 18:02:13.165 19306-19306/com.putao.wd E/BluetoothFuncManager: onProgressChanged info:C7:6B:39:0C:26:9A percent100
11-25 18:02:13.525 19306-19306/com.putao.wd E/BluetoothFuncManager: onDeviceDisconnecting info:C7:6B:39:0C:26:9A
11-25 18:02:13.725 19306-19317/com.putao.wd E/BluetoothFuncManager: onConnectionStateChange()status:0 newState:0
11-25 18:02:13.735 19306-19306/com.putao.wd E/BluetoothFuncManager: onDfuCompleted info:C7:6B:39:0C:26:9A
11-25 18:02:14.775 19306-20534/com.putao.wd E/BluetoothFuncManager: disconnect()
11-25 18:02:35.435 19306-19306/com.putao.wd E/BluetoothFuncManager: disconnect()
11-25 18:02:35.535 19306-19317/com.putao.wd E/BluetoothFuncManager: onLeScan bluetoothDevice:C7:6B:39:0C:26:99
11-25 18:02:35.655 19306-21052/com.putao.wd E/BluetoothFuncManager: onConnectionStateChange()status:0 newState:2
11-25 18:02:35.665 19306-19641/com.putao.wd E/BluetoothFuncManager: onServicesDiscovered()status:0
11-25 18:02:35.775 19306-20534/com.putao.wd E/OtaUpgradeActivity: startOTA()
11-25 18:02:35.775 19306-20534/com.putao.wd W/ContextImpl: Failed to ensure directory: /storage/sdcard1/Android/data/com.putao.wd/files
11-25 18:02:35.785 19306-20534/com.putao.wd W/ContextImpl: Failed to ensure directory: /storage/sdcard1/Android/data/com.putao.wd/files
11-25 18:02:37.725 19306-19306/com.putao.wd E/BluetoothFuncManager: startOTAUpgrade()
11-25 18:02:39.795 19306-19306/com.putao.wd E/BluetoothFuncManager: onDfuProcessStarting info:C7:6B:39:0C:26:99
11-25 18:02:42.095 19306-21052/com.putao.wd E/DfuImpl: Characteristic write error: 3
11-25 18:02:42.095 19306-22790/com.putao.wd E/DfuBaseService: Unable to write Op Code 1 (error 3)
11-25 18:02:42.095 19306-19306/com.putao.wd E/BluetoothFuncManager: onDeviceDisconnecting info:C7:6B:39:0C:26:99
11-25 18:02:42.705 19306-19306/com.putao.wd E/BluetoothFuncManager: onError error:3 message:GATT WRITE NOT PERMIT
11-25 18:02:42.775 19306-19306/com.putao.wd E/BluetoothFuncManager: disconnect()

Error in Documentation

  1. Clone the project, or just the DFULibrary folder (using sparse-checkout) to a temporary location.

There is no DFULibrary folder in the project.

BLE status = 133 problem

I am facing the ble status = 133 in android BluetoothGatt .
the log follow:
D/BluetoothGatt(16840): connect() - device: F0:13:C3:80:AA:C6, auto: false
D/BluetoothGatt(16840): registerApp()
D/BluetoothGatt(16840): registerApp() - UUID=653ae82e-5199-4ff2-8897-27b6ae925f3c
I/BluetoothGatt(16840): Client registered, waiting for callback
D/BluetoothGatt(16840): onClientRegistered() - status=0 clientIf=5
D/BluetoothGatt(16840): onClientConnectionState() - status=133 clientIf=5 device=F0:13:C3:80:AA:C6
In the sourcode the 133 means GATT ERROR .
And in my code i have user the refresh() before the gatt.close();
And I have use close() after disconnect();
But there are not any AndroidPhone have this problem .the Samsung S4 had meet much time.
and the Moto X is very nice in BLE.
How about try to reconnect the device while we meet the status == 133 or 129?
For some AndroidPhone the Ble develpment is no good.
Maybe my english is no good , Hope you can help me ,Thank you very much .

Bonding information removed on phone side after combined BL+SD+APP update

Hi Aleksander,

I just noticed that when we perform a full update (zip package with bl, sd and app) while having a bond between phone and device, the bond appears to be removed on the phone side after the update.
I think it is removed after the download of the BL+SD and before reconnecting to the bootloader for uploading the application.
I've tested it also in nrfConnect and the behaviour is the same (even though we set 'Keep bonding information' to true in the settings tab).
My assumption is that the bond is erased by the DFU library? Is this a necessity and/or can we prevent it from happening?

Thanks in advance!

Jarno

Confused about connection state

I'm implementing DFU OTA for a peripheral app for the nRF51822. My device is motion-activated and the behaviour of my firmware is that when there's a BLE disconnection, is simply goes into sys off. Motion will wake it up again.

Looks like this may cause a problem for me with the DFU service. Does the service expect to start from a point of NOT being connected to the peripheral and to have to create its own connection afresh? If so and I disconnect before calling DfuServiceInitiator.start(), my peripheral won't be advertising.

Is the service configurable or extensible to change this?

Initial DfuTarg Connection Issue

I've been able to limit the number of 133 errors for the most part except for one specific case.

When updating a "virgin" device (one that just came out of programming from production), our app using the DFU library is not able to connect to the DfuTarg. If that device has previously been connected to the smartphone to perform a DFU update, then it will perform fine. If the device is "new" to the phone (e.g. the phone does not yet have bonding information for the DfuTarg), then it will fail.

The only way to catch the issue is to test with a device that has never been bonded to the phone before using NRF connect. Even if the device is re-programmed, the phone will hold onto bonding information that masks the issue if the device has been bonded in the past. It likely has to do with the DfuTarg bonding.

For a virgin device - If you put the device in DFU mode and then connect to the DfuTarg using NRF connect, then the app can complete the actual update process. Our app is able to successfully connect to the DFU target to complete future updates. I believe this is because connection information allowing the phone to connect to the DfuTarg is stored on the phone and then can be reused by the app.

Has anyone else experienced this initial DfuTarg connection issue for devices that have just been programmed? Any suggestions?

Custom characteristics

We use custom characteristics UUID on bluetooth device to upload firmware (or bootloader)

Problem:
We can't use this library from maven center repository, we must checkout it from github and change characteristics manually.

Could you implement in additional methods in DfuServiceInitiator to set custom characteristics UUID.
Example.:

final DfuServiceInitiator starter = new DfuServiceInitiator(mSelectedDevice.getAddress())
    .setDeviceName(mSelectedDevice.getName())
    .setKeepBond(keepBond)
    .setCustomService("MY CUSTOM SERVICE CHARACTERISTIC UUID")
    .setCustomControlPoint("MY CUSTOM CONTROL POINT CHARACTERISTIC UUID")
    .setCustomDataPoint("MY CUSTOM DATA POINT CHARACTERISTIC UUID")
    ...

Thanks.

DFU fails due to timing

Sometimes DFU fails directly due to timing. The DFUBaseService registers itself as BluetoothGattCallback for all BluetootGatt objects and does not keep track from who the onConnectionStateChange is called.

Check for instance the log that is attached. That log shows that DFU is started and while LegacyDfuImpl is waiting for the first Connection to disconnect (waitUntilDisconnect) ACL_DISCONNECT is received which results in mConnectionState = STATE_DISCONNECTED, i.e. the thread waiting in waitUntilDisconnected is notified and running again. Then the new connection is tried and connecting and suddenly the first onConnectionStateChanged (disconnected) is received. The DfuBaseService Thinks that one belongs to the new gatt object and fails the DFU...

This one in the log

05-10 10:03:42.362 11457-11471/com.kronaby.watch.debug I/DfuBaseService: onConnectionStateChange newstate 2

belongs to the new Connection attempt (second GattObject), hence the DFU should have continued...

This issue happens once in a while, but it is very easy to reproduce, just dubugging and adding some breakpoints in onConnectionStateChanged, which Changes the timing a little bit. The DFU library is way too timing dependent.

05-10 10:03:11.566 11457-13299/com.kronaby.watch.debug I/DfuImpl: Version number read: 0.1
05-10 10:03:11.567 11457-13299/com.kronaby.watch.debug W/DfuImpl: Application with buttonless update found
05-10 10:03:11.568 11457-13299/com.kronaby.watch.debug I/DfuImpl: Enabling notifications...
05-10 10:03:13.384 11457-13299/com.kronaby.watch.debug I/DfuImpl: Sending Start DFU command (Op Code = 1, Upload Mode = 4)
05-10 10:03:33.060 11457-11457/com.kronaby.watch.debug I/DfuBaseService: Action received: android.bluetooth.device.action.ACL_DISCONNECTED
05-10 10:03:33.068 11457-13299/com.kronaby.watch.debug I/DfuBaseService: Refreshing result: true
05-10 10:03:33.069 11457-13299/com.kronaby.watch.debug I/DfuBaseService: Cleaning up...
05-10 10:03:33.070 11457-13299/com.kronaby.watch.debug I/DfuImpl: Starting service that will connect to the DFU bootloader
05-10 10:03:35.143 11457-13299/com.kronaby.watch.debug I/DfuBaseService: Connecting to the device...
05-10 10:03:38.174 11457-11498/com.kronaby.watch.debug I/DfuBaseService: onConnectionStateChange newstate 0
05-10 10:03:38.174 11457-11498/com.kronaby.watch.debug E/DfuBaseService: Connection state change error: 8 newState: 0
05-10 10:03:38.174 11457-13299/com.kronaby.watch.debug E/DfuBaseService: Device got disconnected before service discovery finished
05-10 10:03:42.362 11457-11471/com.kronaby.watch.debug I/DfuBaseService: onConnectionStateChange newstate 2
05-10 10:03:42.363 11457-11471/com.kronaby.watch.debug I/DfuBaseService: Connected to GATT server
05-10 10:03:42.374 11457-11471/com.kronaby.watch.debug I/DfuBaseService: Attempting to start service discovery... succeed
05-10 10:03:42.386 11457-11472/com.kronaby.watch.debug I/DfuBaseService: Services discovered
05-10 10:03:44.430 11457-13299/com.kronaby.watch.debug I/DfuBaseService: Disconnecting from the device...
05-10 10:03:44.447 11457-13299/com.kronaby.watch.debug I/DfuBaseService: Refreshing result: true
05-10 10:03:44.447 11457-13299/com.kronaby.watch.debug I/DfuBaseService: Cleaning up...
05-10 10:03:46.054 11457-11457/com.kronaby.watch.debug D/WatchDfuProvider: state: 4, message: DFU error: DFU DEVICE DISCONNECTED
05-10 10:03:46.055 11457-11457/com.kronaby.watch.debug D/DfuStatusController: updating: DFU failed

Connection state change error: 8 problem

Hi:

I am facing a problem during the OTA. So the error is

E/DfuBaseService: Connection state change error: 8 newState: 0
E/DfuBaseService: Unable to write Op Code (error 32776)

It generally doesn't happen for the first time user using it, but happens every single time afterwards.

My firmware update process is

  1. Find device
  2. Send command to put device into DFUTarg mode
  3. Wait for disconnection signal, once it comes, I refresh the Gatt cache and close Gatt, then rescan for "DFUTarg"
  4. Once I find it, I create DfuServiceInitiator and start the process

Besides this error, the onError method in DfuProgressListenerAdapter will be called and the error type is 1, error is 8.

One thing to add, during my test I would run into the same error sometimes(5-6 out of 10) by using nRF Toolbox, but not always.

This is blocking all our Android users from getting firmware update. It could be something wrong on my side and I'm still debugging it, but any hint or suggestions would be very helpful at this time.

Can't use with external storage zip file

Hello!
I'm always getting the following error when passing an external storage Uri (of a freshly downloaded .zip file).
I've tried many Uris constructed with:

file:///storage/emulated/0/dfu3.zip
/storage/emulated/0/dfu3.zip
Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator+ "dfu"+ serverVersion +".zip"
content://com.android.externalstorage.documents/document/primary:dfu3.zip

only this worked (after importing the .zip into project raw res folder):
android.resource://my.package.name/" + R.raw.dfu

the error :

E/DfuBaseService: An exception occurred while calculating file size no.nordicsemi.android.dfu.internal.exception.HexFileValidationException: Not a HEX file at no.nordicsemi.android.dfu.internal.HexInputStream.checkComma(HexInputStream.java:324) at no.nordicsemi.android.dfu.internal.HexInputStream.calculateBinSize(HexInputStream.java:97) at no.nordicsemi.android.dfu.internal.HexInputStream.<init>(HexInputStream.java:83) at no.nordicsemi.android.dfu.internal.ArchiveInputStream.parseZip(ArchiveInputStream.java:273) at no.nordicsemi.android.dfu.internal.ArchiveInputStream.<init>(ArchiveInputStream.java:113) at no.nordicsemi.android.dfu.DfuBaseService.openInputStream(DfuBaseService.java:2091) at no.nordicsemi.android.dfu.DfuBaseService.onHandleIntent(DfuBaseService.java:1196) at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:66) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:148) at android.os.HandlerThread.run(HandlerThread.java:61)

Keep Existing Connection?

We are experiencing a lot of DFU failures. I'm wondering if there's any best practice advice on

Thanks for any help!!

How I add Dfu library into my project?

I follow below steps:
Clone the project into DFULibrary folder (by default it will be cloned into Android-DFU-Library folder) to your projects root, for example to AndroidstudioProjects.
Add the dfu module to your project:
Add '..:DFULibrary:dfu' to the settings.gradle file:
include ':dfu'
project(':dfu').projectDir = file('../DFULibrary/dfu')
Open Project Structure -> Modules -> app -> Dependencies tab and add dfu module dependency. You may also edit the build.gradle file in your app module manually by adding the following dependency: compile project(':..:DFULibrary:dfu')

I rename Android-DFU-Library to DFULibrary and my
settings.gradle:

include ':app'
include ':dfu'
project(':dfu').projectDir = file('../DFULibrary/dfu')

build.gradle(Module:app):

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.2.0'
    compile 'com.android.support:design:25.2.0'
    compile 'com.android.support:cardview-v7:25.2.0'
    compile 'com.android.support:recyclerview-v7:25.2.0'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'no.nordicsemi.android.support.v18:scanner:1.0.0'
    compile 'com.github.machinarius:preferencefragment:0.1.1'
    compile 'com.github.PhilJay:MPAndroidChart:v3.0.2'
    compile project(':..:DFULibrary:dfu')
    testCompile 'junit:junit:4.12'
}

and the error is shown in build.gradle(Module:app)

Gradle sync failed: Project with path ':..:DFULibrary:dfu' could not be found in project ':app'.
					Consult IDE log for more details (Help | Show Log)

and the error is shown in settings.gradle(Project Settings)

Gradle sync failed: Project with path ':..:DFULibrary:dfu' could not be found in project ':app'.
					Consult IDE log for more details (Help | Show Log)

I need modify code with DFU library. Thank you.

Device does not enter DFU mode

I've tried using this library in an Android project, but have had no luck with the device entering DFU mode. I downloaded and tried the Android Library Toolbox, but that also does not get the device into DFU mode. Digging through the code, I see that the value 0x04 is being send to the device to set it to DFU, but it looks like that isn't happening. This is using legacy DFU, not secure.

The nrf Connect Android app, on the other hand, successfully updated the firmware of the device. What would be the reason for this?

GATT Error 133 retry policy

Hello there. It's not that much of an issue but maybe an improvement idea.

Shouldn't there be some kind of auto-retry policy while connecting to a device and receiving GATT 133 error?

Right now, when update process is initialised, we try to connect to a device and if we receive GATT 133 error, the update error broadcast is being send and connection is terminated. During my work with BLE devices I encounter GATT 133 error a lot of time (mostly on lower-end devices) so I came up with some auto-retry policies that try reconnecting 2-3 times before throwing an actual 133 error. Most of the time the connection is successful on 2nd try.

That might be a nice improvement for DfuBaseService or maybe there are some drawbacks that I'm not aware of or retries are already there and I can't see them?

Best Regards

shutdown device after failed DFU

Is there any way to reboot the device after a failed dfu operation from my end ? i've seen this somewhere deep in the code "legacyDfuImpl.java" was wondering if i can do this from the controller or any other way.

DfuService has leaked IntentReceiver

Using the Android DFU Library 1.0.0, I receive the following error when the DFU successfully finishes:

09-05 13:19:43.407 29695-29695/no.nordicsemi.android.nrftoolbox E/ActivityThread: Service no.nordicsemi.android.nrftoolbox.dfu.DfuService has leaked IntentReceiver no.nordicsemi.android.dfu.BaseDfuImpl$1@96850a2 that was originally registered here. Are you missing a call to unregisterReceiver()?
android.app.IntentReceiverLeaked: Service no.nordicsemi.android.nrftoolbox.dfu.DfuService has leaked IntentReceiver no.nordicsemi.android.dfu.BaseDfuImpl$1@96850a2 that was originally registered here. Are you missing a call to unregisterReceiver()?
at android.app.LoadedApk$ReceiverDispatcher.<init>(LoadedApk.java:918)
at android.app.LoadedApk.getReceiverDispatcher(LoadedApk.java:719)
at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1172)
at android.app.ContextImpl.registerReceiver(ContextImpl.java:1152)
at android.app.ContextImpl.registerReceiver(ContextImpl.java:1146)
at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:554)
at no.nordicsemi.android.dfu.BaseDfuImpl.<init>(BaseDfuImpl.java:218)
at no.nordicsemi.android.dfu.BaseCustomDfuImpl.<init>(BaseCustomDfuImpl.java:225)
at no.nordicsemi.android.dfu.LegacyDfuImpl.<init>(LegacyDfuImpl.java:127)
at no.nordicsemi.android.dfu.DfuServiceProvider.getDfuImpl(DfuServiceProvider.java:37)
at no.nordicsemi.android.dfu.DfuBaseService.onHandleIntent(DfuBaseService.java:963)
at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:66)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.os.HandlerThread.run(HandlerThread.java:61)

This error occurs with the nRF Toolbox and also with my own application that uses the Android DFU Library. The tests have been ran with a Nexus 5X on Android 6.0.1.

Should something be done with the DFU library? Or with the apps using it?

Device got disconnected before service discovery finished

Hi,phillip

I have met another problem. The twice dfu is on same MAC address. Becasue they are same Mac address,so does not do gatt.refresh(). At second dfu happend

Device got disconnected before service discovery finished

Could you help me?

11-30 18:42:53.392 22344-27217/com.putao.wd I/DfuBaseService: Connecting to the device...
11-30 18:42:53.403 22344-22394/com.putao.wd I/DfuBaseService: Connected to GATT server
11-30 18:42:53.406 22344-22394/com.putao.wd I/DfuBaseService: Attempting to start service discovery... succeed
11-30 18:42:54.828 22344-22355/com.putao.wd I/DfuBaseService: Services discovered
11-30 18:42:55.844 22344-27217/com.putao.wd I/DfuImpl: Reading DFU version number...
11-30 18:42:56.048 22344-27217/com.putao.wd I/DfuImpl: Version number read: 0.1
11-30 18:42:56.048 22344-27217/com.putao.wd W/DfuImpl: Application with buttonless update found
11-30 18:42:56.048 22344-27217/com.putao.wd I/DfuImpl: Enabling notifications...
11-30 18:42:57.241 22344-27217/com.putao.wd I/DfuImpl: Sending Start DFU command (Op Code = 1, Upload Mode = 4)
11-30 18:42:57.801 22344-22356/com.putao.wd E/DfuBaseService: Connection state change error: 19 newState: 0
11-30 18:42:57.809 22344-27217/com.putao.wd I/DfuBaseService: Refreshing result: true
11-30 18:42:57.809 22344-27217/com.putao.wd I/DfuBaseService: Cleaning up...
11-30 18:42:57.811 22344-27217/com.putao.wd I/DfuImpl: Starting service that will connect to the DFU bootloader
11-30 18:42:57.821 22344-22344/com.putao.wd I/DfuBaseService: Action received: android.bluetooth.device.action.ACL_DISCONNECTED
11-30 18:42:59.863 22344-27217/com.putao.wd I/DfuBaseService: Connecting to the device...
11-30 18:43:00.190 22344-22356/com.putao.wd I/DfuBaseService: Connected to GATT server
11-30 18:43:00.195 22344-22356/com.putao.wd I/DfuBaseService: Attempting to start service discovery... succeed
11-30 18:43:01.222 22344-22394/com.putao.wd I/DfuBaseService: Services discovered
11-30 18:43:02.229 22344-27217/com.putao.wd I/DfuImpl: Reading DFU version number...
11-30 18:43:02.293 22344-27217/com.putao.wd I/DfuImpl: Version number read: 0.8
11-30 18:43:02.293 22344-27217/com.putao.wd I/DfuImpl: Enabling notifications...
11-30 18:43:03.353 22344-27217/com.putao.wd I/DfuImpl: Sending Start DFU command (Op Code = 1, Upload Mode = 4)
11-30 18:43:03.412 22344-27217/com.putao.wd I/DfuImpl: Sending image size array to DFU Packet (0b, 0b, 142544b)
11-30 18:43:07.634 22344-27217/com.putao.wd I/DfuImpl: Sending the Initialize DFU Parameters START (Op Code = 2, Value = 0)
11-30 18:43:07.701 22344-27217/com.putao.wd I/DfuImpl: Sending 142544 bytes of init packet
11-30 18:43:07.702 22344-27217/com.putao.wd I/DfuImpl: Sending init packet (Value = FF-FF-FF-FF-FF-FF-00-00-01-00-64-00-84-17)
11-30 18:43:07.704 22344-27217/com.putao.wd I/DfuImpl: Sending the Initialize DFU Parameters COMPLETE (Op Code = 2, Value = 1)
11-30 18:43:07.763 22344-27217/com.putao.wd I/DfuImpl: Sending Receive Firmware Image request (Op Code = 3)
11-30 18:43:07.822 22344-27217/com.putao.wd I/DfuImpl: Uploading firmware...
11-30 18:43:48.613 22344-27217/com.putao.wd I/DfuImpl: Response received. Op Code: 16 Req Op Code = 3, Status = 1
11-30 18:43:48.614 22344-27217/com.putao.wd I/DfuImpl: Transfer of 142544 bytes has taken 39790 ms
11-30 18:43:48.614 22344-27217/com.putao.wd I/DfuImpl: Sending Validate request (Op Code = 4)
11-30 18:43:48.853 22344-27217/com.putao.wd I/DfuImpl: Response received. Op Code: 16 Req Op Code = 4, Status = 1
11-30 18:43:48.854 22344-27217/com.putao.wd I/DfuImpl: Sending Activate and Reset request (Op Code = 5)
11-30 18:43:48.984 22344-22394/com.putao.wd E/DfuBaseService: Connection state change error: 19 newState: 0
11-30 18:43:48.986 22344-27217/com.putao.wd I/DfuBaseService: Refreshing result: true
11-30 18:43:48.986 22344-27217/com.putao.wd I/DfuBaseService: Cleaning up...
11-30 18:43:49.000 22344-22344/com.putao.wd I/DfuBaseService: Action received: android.bluetooth.device.action.ACL_DISCONNECTED
11-30 18:44:16.007 22344-28502/com.putao.wd I/DfuBaseService: Connecting to the device...
11-30 18:44:16.021 22344-22355/com.putao.wd I/DfuBaseService: Connected to GATT server
11-30 18:44:16.025 22344-22355/com.putao.wd I/DfuBaseService: Attempting to start service discovery... succeed
11-30 18:44:16.771 22344-22356/com.putao.wd I/DfuBaseService: Services discovered
11-30 18:44:17.776 22344-28502/com.putao.wd I/DfuImpl: Reading DFU version number...
11-30 18:44:17.863 22344-28502/com.putao.wd I/DfuImpl: Version number read: 0.1
11-30 18:44:17.863 22344-28502/com.putao.wd W/DfuImpl: Application with buttonless update found
11-30 18:44:17.864 22344-28502/com.putao.wd I/DfuImpl: Enabling notifications...
11-30 18:44:19.014 22344-28502/com.putao.wd I/DfuImpl: Sending Start DFU command (Op Code = 1, Upload Mode = 4)
11-30 18:44:19.296 22344-22394/com.putao.wd E/DfuBaseService: Connection state change error: 19 newState: 0
11-30 18:44:19.303 22344-28502/com.putao.wd I/DfuBaseService: Refreshing result: true
11-30 18:44:19.303 22344-28502/com.putao.wd I/DfuBaseService: Cleaning up...
11-30 18:44:19.306 22344-28502/com.putao.wd I/DfuImpl: Starting service that will connect to the DFU bootloader
11-30 18:44:19.314 22344-22344/com.putao.wd I/DfuBaseService: Action received: android.bluetooth.device.action.ACL_DISCONNECTED
11-30 18:44:21.349 22344-28502/com.putao.wd I/DfuBaseService: Connecting to the device...
11-30 18:44:21.656 22344-22394/com.putao.wd I/DfuBaseService: Connected to GATT server
11-30 18:44:21.662 22344-22394/com.putao.wd I/DfuBaseService: Attempting to start service discovery... succeed
11-30 18:44:24.018 22344-22400/com.putao.wd E/DfuBaseService: Connection state change error: 34 newState: 0
11-30 18:44:24.018 22344-28502/com.putao.wd E/DfuBaseService: Device got disconnected before service discovery finished
11-30 18:44:24.023 22344-28502/com.putao.wd I/DfuBaseService: Refreshing result: true
11-30 18:44:24.023 22344-28502/com.putao.wd I/DfuBaseService: Cleaning up...
11-30 18:44:24.028 22344-22344/com.putao.wd I/DfuBaseService: Action received: android.bluetooth.device.action.ACL_DISCONNECTED

Is there any plane to port to React-Native lib in someday?

I am about to create our next project base on React-Native tech. It's easy to get normal BLE functions to work but the DFU is a little difficult for me. I try port it by myself but get many more insolubility problems.

I posted this issue on IOS-Pods-DFU-Library repository also. see here.

Error 4097 dfu file not found

Hi,
I know that the message is clear...but I try to get .zip file through 2 ways, saving this .zip into asset folder and into raw folder

  Uri mFileStreamUri;
 mFileStreamUri=Uri.fromFile(new File("///android_asset/vit2_10_20170207.zip"));
 mFileStreamUri=Uri.parse("android.resource://"+mContext.getPackageName()+"/raw/vit2_10_20170207.zip");

and then... I do
final DfuServiceInitiator starter = new DfuServiceInitiator(dongle.getMac())
.setDeviceName(dongle.getName())
.setKeepBond(false)
.setForceDfu(false)
.setPacketsReceiptNotificationsEnabled(false)
.setPacketsReceiptNotificationsValue(12)
.setDisableNotification(true)
.setUnsafeExperimentalButtonlessServiceInSecureDfuEnabled(true);
starter.setZip(mFileStreamUri,null);
starter.start(mContext, DfuService.class);
Always get the same error

DFU FILE NOT FOUND
4097.

What wrong with me code???

Thanks
Regards

(BL/SD)+App update fails on App update process with 133

I've prevented 133 errors from occurring by scanning for the DFU target address, getting a scan result, and then starting the DFU service. However, I experienced a 133 error in the middle of a (BL/SD)+App update. The library breaks up the update into two parts, first the BL/SD followed by the App. After BL/SD part finishes updating, a 133 error occurs when trying to reconnect for the App update portion. We end up having a partial update, where BL/SD is new and App old.

A mismatched BL/SD and App could become problematic.

GATT Invalid Handle

Hello,

We are currently using your Android lib and we are experiencing the following behaviour:

  1. When we connect after starting the DFU with a "button", we don't have any issue. We connect to our device on the Mac Address (+1) and device name "DfuTarg".
  2. When we use the method "button less", we always get the same following issue: "GATT INVALID HANDLE".

We are using the following method:

  • With our BLE lib, we connect to the GATT peripheral.
  • We list the services.
  • We write an own defined characteristic to allow the DFU.
  • The device is then ready to start in DFU mode.
  • We disconnect from the peripheral.

Thereafter, we use you library in the following way (same code as the one use in behaviour 1):

public void startUpdate(String macAddress, String deviceName, String filePath)
{
    if (m_dfuServiceController == null)
    {
        final DfuServiceInitiator starter = new DfuServiceInitiator(macAddress)
                .setDeviceName(deviceName)
                .setKeepBond(false);    // keep bond??

        starter.setZip(null, filePath);
        m_dfuServiceController = starter.start(m_context, DfuService.class);
    }
}

We have tried several other solutions found around the web but with no luck.

We have checked the following:

  • The peripheral exposes correctly the characteristic "Service Update" in the firmware.
  • If we activate our own flag through a generic app (like lightblue) and we only do the call to your library, the outcome is the same.
  • If we use the NRF Connect app, it works correctly.

Here are some logs:
02-15 16:12:53.784 INFO: 15-02-2017 04:12:53 : Scan started
02-15 16:12:58.812 INFO: 15-02-2017 04:12:58 : Scan interrupted
02-15 16:13:05.025 DEBUG: 15-02-2017 04:13:05 : Updater state : StartingDFU
02-15 16:13:07.389 DEBUG: 15-02-2017 04:13:07 : Updater state : EnablingDFU
02-15 16:13:09.825 DEBUG: 15-02-2017 04:13:09 : Updater state : DeviceConnecting
02-15 16:13:11.971 DEBUG: 15-02-2017 04:13:11 : Updater state : StartingDFU
02-15 16:13:13.069 DEBUG: 15-02-2017 04:13:13 : Updater state : DeviceDisconnecting
02-15 16:13:13.788 ERROR: 15-02-2017 04:13:13 : Updater Error : GATT INVALID HANDLE

Do you have any idea why we get such error?
What's the difference between what we do and what is done on the NRF Connect app? Are we missing any steps?

Thank you in advance for your help.

19 errors: toast show"Upload failed: DFU SERVICE NOT FOUND"

when i press the update button,this is the logcat info:

11-01 13:53:16.611 20786-20786/xxxxos E/ContentValues: mFileStreamUri=: file:///storage/emulated/0/firmware.zipmFilePath=/storage/emulated/0/firmware.zip
11-01 13:53:18.731 20786-22447/xxxxos D/BluetoothGatt: connect() - device: DA:7B:4D:51:CB:4C, auto: false
11-01 13:53:18.731 20786-22447/xxxxos D/BluetoothGatt: registerApp()
11-01 13:53:18.731 20786-22447/xxxxos D/BluetoothGatt: registerApp() - UUID=f3542e4f-e512-4aa0-9dd7-aebc94646e55
11-01 13:53:18.781 20786-21076/xxxxos D/BluetoothGatt: onClientRegistered() - status=0 clientIf=6
11-01 13:53:18.791 20786-20799/xxxxos D/BluetoothGatt: onClientConnectionState() - status=0 clientIf=6 device=DA:7B:4D:51:CB:4C
11-01 13:53:20.391 20786-20799/xxxxos D/BluetoothGatt: discoverServices() - device: DA:7B:4D:51:CB:4C
11-01 13:53:20.421 20786-20799/xxxxos D/BluetoothGatt: onSearchComplete() = Device=DA:7B:4D:51:CB:4C Status=0
11-01 13:53:20.591 20786-22447/xxxxos D/BluetoothGatt: setCharacteristicNotification() - uuid: 00002a05-0000-1000-8000-00805f9b34fb enable: true
11-01 13:53:20.891 20786-22447/xxxxos D/BluetoothGatt: cancelOpen() - device: DA:7B:4D:51:CB:4C
11-01 13:53:20.901 20786-20799/xxxxos D/BluetoothGatt: onClientConnectionState() - status=0 clientIf=6 device=DA:7B:4D:51:CB:4C
11-01 13:53:20.901 20786-22447/xxxxos D/BluetoothGatt: close()
11-01 13:53:20.901 20786-22447/xxxxos D/BluetoothGatt: unregisterApp() - mClientIf=6
11-01 13:53:22.991 20786-22447/xxxxos D/BluetoothGatt: connect() - device: DA:7B:4D:51:CB:4C, auto: false
11-01 13:53:22.991 20786-22447/xxxxos D/BluetoothGatt: registerApp()
11-01 13:53:22.991 20786-22447/xxxxos D/BluetoothGatt: registerApp() - UUID=f3b56e3d-39ec-4232-a554-f01cda9335cb
11-01 13:53:23.041 20786-20801/xxxxos D/BluetoothGatt: onClientRegistered() - status=0 clientIf=6
11-01 13:53:23.051 20786-20801/xxxxos D/BluetoothGatt: onClientConnectionState() - status=0 clientIf=6 device=DA:7B:4D:51:CB:4C
11-01 13:53:24.651 20786-20801/xxxxos D/BluetoothGatt: discoverServices() - device: DA:7B:4D:51:CB:4C
11-01 13:53:24.681 20786-20801/xxxxos D/BluetoothGatt: onSearchComplete() = Device=DA:7B:4D:51:CB:4C Status=0
11-01 13:53:24.891 20786-20786/xxxxos E/ContentValues: onDeviceConnected: DA:7B:4D:51:CB:4C
11-01 13:53:26.051 20786-22447/xxxxos D/BluetoothGatt: setCharacteristicNotification() - uuid: 00001531-1212-efde-1523-785feabcd123 enable: true
11-01 13:53:28.201 20786-21076/xxxxos D/BluetoothGatt: onClientConnectionState() - status=19 clientIf=6 device=DA:7B:4D:51:CB:4C
11-01 13:53:28.201 20786-21076/xxxxos E/DfuBaseService: Connection state change error: 19 newState: 0
11-01 13:53:28.201 20786-22447/xxxxos D/BluetoothGatt: close()
11-01 13:53:28.201 20786-22447/xxxxos D/BluetoothGatt: unregisterApp() - mClientIf=6
11-01 13:53:28.661 20786-20786/xxxxos D/MultiPhoneWindow: MinimizeAnimator::removeWindow
11-01 13:53:28.671 20786-20786/xxxxos D/MultiPhoneWindow: MinimizeAnimator::removeWindow
11-01 13:53:30.361 20786-22447/xxxxos D/BluetoothGatt: connect() - device: DA:7B:4D:51:CB:4C, auto: false
11-01 13:53:30.361 20786-22447/xxxxos D/BluetoothGatt: registerApp()
11-01 13:53:30.361 20786-22447/xxxxos D/BluetoothGatt: registerApp() - UUID=c534be4e-f0f0-463b-9f86-33b1d775e489
11-01 13:53:30.421 20786-20799/xxxxos D/BluetoothGatt: onClientRegistered() - status=0 clientIf=6
11-01 13:53:30.421 20786-20801/xxxxos D/BluetoothGatt: onClientConnectionState() - status=0 clientIf=6 device=DA:7B:4D:51:CB:4C
11-01 13:53:32.031 20786-20801/xxxxos D/BluetoothGatt: discoverServices() - device: DA:7B:4D:51:CB:4C
11-01 13:53:32.031 20786-20799/xxxxos D/BluetoothGatt: onSearchComplete() = Device=DA:7B:4D:51:CB:4C Status=0
11-01 13:53:32.061 20786-22447/xxxxos D/BluetoothGatt: cancelOpen() - device: DA:7B:4D:51:CB:4C
11-01 13:53:32.071 20786-20799/xxxxos D/BluetoothGatt: onClientConnectionState() - status=0 clientIf=6 device=DA:7B:4D:51:CB:4C
11-01 13:53:32.091 20786-22447/xxxxos D/BluetoothGatt: close()
11-01 13:53:32.091 20786-22447/xxxxos D/BluetoothGatt: unregisterApp() - mClientIf=6
11-01 13:53:32.871 20786-20786/xxxxos D/SRIB_DCS: log_dcs ThreadedRenderer::initialize entered!
11-01 13:53:32.871 20786-21374/xxxxos D/mali_winsys: new_window_surface returns 0x3000, [1071x154]-format:1
11-01 13:53:32.911 20786-21374/xxxxos V/RenderScript: 0xeec11000 Launching thread(s), CPUs 8

1,I doubt why I have call the DfuServiceInitiator,start() method, it still show me "Upload failed:DFU SERVICE NOT FOUND",Is it necessary to keep the dfuservice alive longly or How to initial the dfuservice? Do you have any ideas?

2,I want to show my thought,Anybody can show me ,is there a problem or mistake I have made?
I copy the DFU package(firmware.zip) to the res/raw ,i call a method to copy the .zip to the phone root directory, when i get the fileStreamUri and mFilePath base on the .zip file. Finaly, i copy these codes:

DfuServiceInitiator starter = new DfuServiceInitiator(DEVICE_ADDRESS)
.setDeviceName(DEVICE_NAME)
.setKeepBond(true);

    // Init packet is required by Bootloader/DFU from SDK 7.0+ if HEX or BIN file is given above.
    // In case of a ZIP file, the init packet (a DAT file) must be included inside the ZIP file.
    if (mFileType == TYPE_AUTO) {
        starter.setZip(mFileStreamUri, mFilePath);
        Log.e(TAG, "mFileStreamUri=: " + mFileStreamUri + "mFilePath=" + mFilePath);
    } else {
        starter.setBinOrHex(mFileType, mFileStreamUri, mFilePath).setInitFile(mInitFileStreamUri, mInitFilePath);
        Log.e(TAG, "mFileStreamUri=: " + mFileStreamUri + "mFilePath=" + mFilePath + " mInitFileStreamUri=" + mInitFileStreamUri + " mInitFilePath=" + mInitFilePath);
    }
    starter.start(DFUActivity.this, DfuService.class);

This is the parameters of starter.setZip();
fileStreamUri=: file:///storage/emulated/0/firmware.zip
mFilePath=/storage/emulated/0/firmware.zip

2,when i search in the "storage/emulated/0/",there is no firmware.zip ,but there is one in the root dirctory.is it I got the wrong path? Next is the code to copy the firmware.zip and get the uri and path ,is there some mistakes?please help...

File f = new File(Environment.getExternalStorageDirectory(), "firmware.zip");
copyRawResource(R.raw.firmware, f);
Log.e(TAG, "url=" + f.getAbsolutePath());
mFileTypeTmp = TYPE_AUTO;

    mFileStreamUri = Uri.fromFile(f);
    mFilePath = f.getAbsolutePath();

Sending SD+BL+App on Secure DFU fails

The new nrfutil does not write sd_size and bl_size in the manifest file (which is correct, they are not required in Secure DFU, as this information is inside the Init packet). Although the DFU Library 1.0.3 fails to select the correct fw type without them. The fix is coming and will be released as 1.0.4.

Buttonless jump for Secure DFU

Hello All DFU Users,

Currently the buttonless jump to DFU mode is not supported for Secure DFU on Android or iOS DFU Libraries. In the SDK 12.1 this feature is experimental and it may change in the future until it's stable.
As far as I know the final characteristic will have the following UUID:
8EC90003-F315-4F60-9FB8-838830DAEA50
and will be inside a service with DFU service UUID (so 16-bit 0xFE59 for Secure DFU).

This characteristic will have Write and Notify properties.
To protect from DOS attack writing to it will require encryption (so bonded devices only).

Accepted write value:
0x01 = Enter Bootloader on next reset (application specific to handle reset).
Response Codes:
- These values are not settled yet.

So the DFULibrary for both Android and iOS fill eventually support such buttonless service, not the one from the SDK 12.1. The ETA is somewhere in the "beginning" of 2017, hopefully.

See also this comment below: #33 (comment)

correct if im wrong pls

hi
i don't know if i allow to ask such a q in here . if i should not please tell me . thanks .

i use sdk v6 and it can be updated with hex file so i put .hex file in asset folder.

final DfuServiceInitiator starter = new DfuServiceInitiator(mdevice.getAddress())
                    .setDeviceName(mdevice.getName())
                    .setKeepBond(true);

with above code i init the service initiator adn then

starter.setZip("file:///android_asset/bleapp.hex");

in code above i set the file in asset folder

but in code below it show me a null exception
starter.start(this, DfuService.class);

my DfuService class is copy of documentation code.

NPE on openInputStream()

You are not checking for a null Cursor instance on this line:

https://github.com/NordicSemiconductor/Android-DFU-Library/blob/release/dfu/src/main/java/no/nordicsemi/android/dfu/DfuBaseService.java#L1881

In my case I'm using a hex file which is bundled in with the Android app under res/raw. The input stream URI for it looks like this:

android.resource://cc.biketracker.android/2131099651

That URI has been built like this:

Uri firmwareHex = Uri.parse("android.resource://" + getPackageName() + "/"
+ R.raw.bike_s110);

You are querying for "_display_name". Does that always exist?

Proposal/Improvement: checking version dependent requirements

Trying the DFU with SDK-8.1 and this DFU android library, I stuck with “general error numbers” report by the device. Finally I found the comments (DfuBaseService, line 1570, above comment Send DFU Init Packet) that clarifies the usage of the init packet.

Though the DFU library knowns the DFU version at this point, wouldn’t it be an improvement to report the missing “init packet” as error (“since DF0 v0.6 the init packet is required!”)?

And, maybe you can also extend the Makefiles to call the “nrf dfu” to create the zip (e.g. “examples\ble_peripheral\ble_app_hrs\pca10028\s110_with_dfu”)

what is this error?

#25 i fix this problem by sending contex of my app .

now i have this problem that cam from DFU Lib

10-24 15:00:30.442 13364-13656/com.asidesigner.smartlamp E/DfuBaseService: An exception occurred while calculating file size
                                                                           java.io.IOException: The ZIP file must contain an Application, a Soft Device and/or a Bootloader.
                                                                               at no.nordicsemi.android.dfu.internal.ArchiveInputStream.<init>(ArchiveInputStream.java:245)
                                                                               at no.nordicsemi.android.dfu.DfuBaseService.openInputStream(DfuBaseService.java:1148)
                                                                               at no.nordicsemi.android.dfu.DfuBaseService.onHandleIntent(DfuBaseService.java:877)
                                                                               at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
                                                                               at android.os.Handler.dispatchMessage(Handler.java:110)
                                                                               at android.os.Looper.loop(Looper.java:193)
                                                                               at android.os.HandlerThread.run(HandlerThread.java:61)

it suppose to work with hex file in sdk v6 then i put hex file in program to work with

Notification click not working

Hello, thanks for your great library.

I have a small problem. When I extend your DfuBaseService and implement a getNotificationTarget method, my NotificationActivity is not created (not even instantiated) when clicking on the notification. On the other hand, the Abort action works fine. My NotificationActivity is almost a copy-paste from your example. I have traced down the problem here, but I am an Android noob, so sorry that I cannot propose a solution.

Tested on Sony Xperia Z5 (Android 6.0.1) and Nexus 5 (Android 7.1.1).

Proguard configuration missing

I'm using proguard and minifyEnabled in my project in the release build and I'm not able to get the device in DFU mode. The debug build has minifyEnabled set to false and works as expected.

My question is, what should I add to the proguard-rules for this library?

DFU disconnecting on Nougat, LG Nexus 5X

Version of DFU library is 1.0.3. OS build number on Nexus 5x is NRD90R, which is last official update.

Short after beggining of DFU process, when sending firmware to device, device disconnects from phone with status 8. According to Androids BLE api, it's a status for error A remote device connection is congested.

Comit before adef02a, it's working fine.
So far this is happening only with Nougat on LG Nexus 5X. On the other hand, Nexus 6P, running Nougat, is working quite fine.

Here is part of stack trace, when error occures:

E/DfuActivity: Extras: DFU_PROGRESS_CHANGED; 14;
D/BluetoothGatt: onClientConnectionState() - status=8 clientIf=5 device=DD:46:F1:C7:CE:F2
E/DfuBaseService: Connection state change error: 8 newState: 0
E/DfuImpl: Disconnected while sending data
E/DfuBaseService: Uploading Firmware Image failed: device disconnected
I/DfuBaseService: Cleaning up...
D/BluetoothGatt: close()
D/BluetoothGatt: unregisterApp() - mClientIf=5

Currently we are fixing it by setting PRN in Androids SharedPreference, before every DFU, like so:

PreferenceManager.getDefaultSharedPreferences(this)
        .edit()
        .putBoolean(DfuSettingsConstants.SETTINGS_PACKET_RECEIPT_NOTIFICATION_ENABLED, true)
        .putString(DfuSettingsConstants.SETTINGS_NUMBER_OF_PACKETS, String.valueOf(12))
        .commit();

If not reverting commit adef02a, could PRN setting be an extra for an intent that's starting DfuBaseService, instead of value in preferences?

[ANDROID] DFU file error 4098 while initializing DFU service / An exception occurred while calculating file size

Hi all,

I get an error while trying to make a DFU on my device, but the thing is that it only happens with the RELEASE APK. In debug apk, it works like a charm.

I get this error : E/DfuBaseService: An exception occurred while calculating file size.
It seems to be corresponding to an error code 4098.

I checked if the firmware file was correctly found in release mode by simply displaying the raw content and file size in the LOG. And it does appear in the log, meaning that the file is found,with the correct size.

This is the first project on which I get this weird behavior....

Here is how I call the DFU service :
new DfuServiceInitiator(adress)
.setDeviceName(device.getName())
.setKeepBond(true)
.setZip(R.raw.my_firmware)
.start(context, DfuService.class);

Any idea ? Am I missing a stupid thing like a permission in the manifest, that only breaks when in release mode?

Thanks in advance for your help :)

133 errors

Hello

I'm getting a lot of the GATT 133 errors when trying to do a DFU. We've implemented the buttonless DFU and it works perfectly on IOS, but I keep getting the 133 in the DFUService. See attached logs:
Any hints on what can be done to minimise this issue?

10-31 18:46:29.557 31469-31469/xxx D/BluetoothGatt: close()
10-31 18:46:29.567 31469-31469/xxx D/BluetoothGatt: unregisterApp() - mClientIf=9
10-31 18:46:30.037 31469-31469/xxx I/DfuService: DfuService onCreate
10-31 18:46:32.087 31469-31748/xxx I/DfuBaseService: Connecting to the device...
10-31 18:46:32.087 31469-31748/xxx D/BluetoothGatt: connect() - device: CD:B0:6F:A2:39:6E, auto: false
10-31 18:46:32.097 31469-31748/xxx D/BluetoothGatt: registerApp()
10-31 18:46:32.097 31469-31748/xxx D/BluetoothGatt: registerApp() - UUID=991273b2-06c7-4c4b-b129-c3282904c6e7
10-31 18:46:32.137 31469-31496/xxx D/BluetoothGatt: onClientRegistered() - status=0 clientIf=9
10-31 18:46:32.537 31469-31481/xxx D/BluetoothGattServer: onServerConnectionState() - status=0 serverIf=8 device=CD:B0:6F:A2:39:6E
10-31 18:46:32.537 31469-31481/xxx D/BluetoothGattServer: Server disconnected, update device to list
10-31 18:46:32.547 31469-31481/xxx D/AppManager: Server onConnectionStateChange DISCONNECTED DFU-H41J Address: CD:B0:6F:A2:39:6E
10-31 18:46:32.547 31469-31480/xxx D/BluetoothGatt: onClientConnectionState() - status=133 clientIf=9 device=CD:B0:6F:A2:39:6E
10-31 18:46:32.557 31469-31480/xxx E/DfuBaseService: Connection state change error: 133 newState: 0
10-31 18:46:32.557 31469-31748/xxx E/DfuBaseService: Device got disconnected before service discovery finished
10-31 18:46:32.567 31469-31748/xxx D/BluetoothGatt: refresh() - device: CD:B0:6F:A2:39:6E
10-31 18:46:32.567 31469-31748/xxx I/DfuBaseService: Refreshing result: true
10-31 18:46:32.567 31469-31748/xxx I/DfuBaseService: Cleaning up...
10-31 18:46:32.567 31469-31748/xxx D/BluetoothGatt: close()
10-31 18:46:32.577 31469-31748/xxx D/BluetoothGatt: unregisterApp() - mClientIf=9
10-31 18:46:33.257 31469-31469/xxx I/DfuService: DfuService onDestroy

dsiconnect while sending data

I/DfuBaseService﹕ mBytesSent:29140
I/DfuBaseService﹕ mImageSizeInBytes:51732
D/BluetoothGatt﹕ writeCharacteristic() - uuid: 31552658-1212-efde-1523-785feabcd123
D/BluetoothGatt﹕ onCharacteristicWrite() - Device=F1:11:11:11:11:11 UUID=31552658-1212-efde-1523-785feabcd123 Status=0
I/DfuBaseService﹕ mBytesSent:29160
I/DfuBaseService﹕ mImageSizeInBytes:51732
D/BluetoothGatt﹕ writeCharacteristic() - uuid: 31552658-1212-efde-1523-785feabcd123
D/BluetoothGatt﹕ onCharacteristicWrite() - Device=F1:11:11:11:11:11 UUID=31552658-1212-efde-1523-785feabcd123 Status=0
I/DfuBaseService﹕ mBytesSent:29180
I/DfuBaseService﹕ mImageSizeInBytes:51732
D/BluetoothGatt﹕ writeCharacteristic() - uuid: 31552658-1212-efde-1523-785feabcd123
D/BluetoothGatt﹕ onCharacteristicWrite() - Device=F1:11:11:11:11:11 UUID=31552658-1212-efde-1523-785feabcd123 Status=0
I/DfuBaseService﹕ mBytesSent:29200
I/DfuBaseService﹕ mImageSizeInBytes:51732
D/BluetoothGatt﹕ onClientConnectionState() - status=0 clientIf=5 device=F1:11:11:11:11:11
I/DfuBaseService﹕ Connection state change: 0 newState: 0
I/DfuBaseService﹕ Disconnected from GATT server
E/DfuBaseService﹕ Disconnected while sending data
E/DfuBaseService﹕ Uploading Firmware Image failed: device disconnected (connection state: 0)
I/DfuBaseService﹕ Cleaning up...
D/BluetoothGatt﹕ close()
D/BluetoothGatt﹕ unregisterApp() - mClientIf=5

Device returned error after sending file (error 6)

12-14 13:47:42.991 6069-6797/no.nordicsemi.android.nrftoolbox I/DfuBaseService: Connecting to the device...
12-14 13:47:43.033 6069-6091/no.nordicsemi.android.nrftoolbox I/DfuBaseService: Connected to GATT server
12-14 13:47:43.040 6069-6091/no.nordicsemi.android.nrftoolbox I/DfuBaseService: Attempting to start service discovery... succeed
12-14 13:47:43.558 6069-6090/no.nordicsemi.android.nrftoolbox I/DfuBaseService: Services discovered
12-14 13:47:44.610 6069-6797/no.nordicsemi.android.nrftoolbox I/DfuImpl: Reading DFU version number...
12-14 13:47:44.651 6069-6797/no.nordicsemi.android.nrftoolbox I/DfuImpl: Version number read: 0.8
12-14 13:47:44.651 6069-6797/no.nordicsemi.android.nrftoolbox I/DfuImpl: Enabling notifications...
12-14 13:47:45.691 6069-6797/no.nordicsemi.android.nrftoolbox I/DfuImpl: Sending Start DFU command (Op Code = 1, Upload Mode = 4)
12-14 13:47:45.726 6069-6797/no.nordicsemi.android.nrftoolbox I/DfuImpl: Sending image size array to DFU Packet (0b, 0b, 142752b)
12-14 13:47:56.271 6069-6797/no.nordicsemi.android.nrftoolbox I/DfuImpl: Sending the Initialize DFU Parameters START (Op Code = 2, Value = 0)
12-14 13:47:56.300 6069-6797/no.nordicsemi.android.nrftoolbox I/DfuImpl: Sending 142752 bytes of init packet
12-14 13:47:56.300 6069-6797/no.nordicsemi.android.nrftoolbox I/DfuImpl: Sending init packet (Value = FF-FF-FF-FF-FF-FF-00-00-01-00-64-00-AB-E9)
12-14 13:47:56.304 6069-6797/no.nordicsemi.android.nrftoolbox I/DfuImpl: Sending the Initialize DFU Parameters COMPLETE (Op Code = 2, Value = 1)
12-14 13:47:56.361 6069-6797/no.nordicsemi.android.nrftoolbox I/DfuImpl: Sending the number of packets before notifications (Op Code = 8, Value = 12)
12-14 13:47:56.392 6069-6797/no.nordicsemi.android.nrftoolbox I/DfuImpl: Sending Receive Firmware Image request (Op Code = 3)
12-14 13:47:56.430 6069-6797/no.nordicsemi.android.nrftoolbox I/DfuImpl: Uploading firmware...
12-14 13:47:57.891 6069-6797/no.nordicsemi.android.nrftoolbox I/DfuImpl: Response received. Op Code: 16 Req Op Code = 3, Status = 6
12-14 13:47:57.891 6069-6797/no.nordicsemi.android.nrftoolbox E/DfuImpl: Device returned error after sending file (error 6)
12-14 13:47:57.892 6069-6797/no.nordicsemi.android.nrftoolbox I/DfuImpl: Sending Reset command (Op Code = 6)
12-14 13:48:10.723 6069-6110/no.nordicsemi.android.nrftoolbox I/DfuBaseService: Disconnected from GATT server
12-14 13:48:10.728 6069-6069/no.nordicsemi.android.nrftoolbox I/DfuBaseService: Action received: android.bluetooth.device.action.ACL_DISCONNECTED
12-14 13:48:10.750 6069-6797/no.nordicsemi.android.nrftoolbox I/DfuBaseService: Disconnecting from the device...

OTA update filed

HI,my phone is Nexus 5X,I found recently when the progressbar is running about 30%-50% percents,It will stop to update the rom.but log is ok,I can't figure out what's going on.Could you please to check my problem.Other phones like HUAWEI honor and China native phone are no problems.
here is my usage:

    final String path = StorageUtil.getSDPath() + StorageUtil.SDRootName + romName;
    final DfuServiceInitiator starter = new DfuServiceInitiator(
            device.getAddress()).
            setDisableNotification(true).// close  notifications
            setDeviceName(device.getName()).
            setKeepBond(true);
    starter.setZip(null, path);
    starter.start(context, DfuService.class);

here is my log:

09-26 13:51:44.703 10000-25142/DfuImpl: Reading DFU version number...
09-26 13:51:44.763 10000-25142/DfuImpl: Version number read: 0.8
09-26 13:51:44.764 10000-25142/DfuImpl: Enabling notifications...
09-26 13:51:44.764 10000-25142/BluetoothGatt: setCharacteristicNotification() - uuid: 00001531-1212-efde-1523-785feabcd123 enable: true
09-26 13:51:45.850 10000-25142/DfuImpl: Sending Start DFU command (Op Code = 1, Upload Mode = 4)
09-26 13:51:45.910 10000-25142/DfuImpl: Sending image size array to DFU Packet (0b, 0b, 49804b)
09-26 13:51:51.898 10000-25142/DfuImpl: Sending the Initialize DFU Parameters START (Op Code = 2, Value = 0)
09-26 13:51:51.963 10000-25142/DfuImpl: Sending 49804 bytes of init packet
09-26 13:51:51.963 10000-25142/DfuImpl: Sending init packet (Value = 03-00-03-00-11-00-00-01-01-00-64-00-02-00-00-00-8C-C2-00-00)
09-26 13:51:51.969 10000-25142/DfuImpl: Sending init packet (Value = 69-24-C9-DC-F1-A8-7E-3B-61-89-EC-26-DB-27-9F-BF-C9-07-17-70)
09-26 13:51:51.974 10000-25142/DfuImpl: Sending init packet (Value = 79-A1-B7-46-19-71-CB-1E-E5-F0-60-20-78-3D-71-96-63-D2-D4-FB)
09-26 13:51:51.980 10000-25142/DfuImpl: Sending init packet (Value = F4-D7-C3-F6-DF-57-DF-1F-26-CB-2B-20-C4-B8-38-D9-29-78-8B-1A)
09-26 13:51:51.983 10000-25142/DfuImpl: Sending init packet (Value = C3-70-B4-85-F8-0D-21-9D-FE-F9-97-35-C9-6F-4A-66-31-D8-9E-F8)
09-26 13:51:51.987 10000-25142/DfuImpl: Sending init packet (Value = 47-68-8B-62-FF-F7-42-41-71-0C-00-28-F3-F6-0E-E8)
09-26 13:51:51.992 10000-25142/DfuImpl: Sending the Initialize DFU Parameters COMPLETE (Op Code = 2, Value = 1)
09-26 13:52:19.754 10000-25142/DfuImpl: Sending Receive Firmware Image request (Op Code = 3)
09-26 13:52:19.815 10000-25142/DfuImpl: Uploading firmware...

i cant download dfu lib

hi
in this step

    Clone the project, or just the DFULibrary folder (using sparse-checkout) to a temporary location.
    Copy the DFULibrary folder to your projects root, for example to AndroidstudioProjects.
    Add the dfu module to your project:
        Add '..:DFULibrary:dfu' to the settings.gradle file: include ':app', '..:DFULibrary:dfu'
        Open Project Structure -> Modules -> app -> Dependencies tab and add dfu module dependency. You may also edit the build.gradle file in your app module manually by adding the following dependency: compile project(':..:DFULibrary:dfu')

i did not find DFULibrary folder to copy it to my project.where can i download it?
there is not direct download in here

onClientConnectionState() - status=8

hi,Philips
I am facing a problem in ota, the error message is

2017-03-21 02:12:55.271  03-21 02:12:55.257 11619 11632 D BluetoothGatt: onClientConnectionState() - status=8 clientIf=8 device=D7:EB:D9:A5:2D:B8
2017-03-21 02:12:55.273  03-21 02:12:55.257 11619 11632 E DfuBaseService: Connection state change error: 8 newState: 0
2017-03-21 02:12:55.274  03-21 02:12:55.257 11619 12087 E DfuImpl : Disconnected while sending data
2017-03-21 02:12:55.278  03-21 02:12:55.257 11619 12087 E DfuBaseService: Uploading Firmware Image failed: device disconnected
2017-03-21 02:12:55.280  03-21 02:12:55.257 11619 12087 D BluetoothGatt: close()
2017-03-21 02:12:55.282  03-21 02:12:55.257 11619 12087 D BluetoothGatt: unregisterApp() - mClientIf=8

our dfu sdk in version 1.1.1, in s7 edge Android 6.0.1, the error occurs every time in dfu percent 40%, and another phone MI NOTE Pro Android 7.0 occurs every time in 37%. I found error 8 in GATTError is timeout, how i fix this problem。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.