diff --git a/build.gradle b/build.gradle index d3ff69d..9405f3f 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:1.1.0' + classpath 'com.android.tools.build:gradle:1.2.3' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/dfu/build.gradle b/dfu/build.gradle index 818361b..a1d50e6 100644 --- a/dfu/build.gradle +++ b/dfu/build.gradle @@ -1,10 +1,10 @@ apply plugin: 'com.android.library' -ext { - PUBLISH_GROUP_ID = 'no.nordicsemi.android' - PUBLISH_ARTIFACT_ID = 'dfu-library' - PUBLISH_VERSION = '0.6.0' -} +//ext { +// PUBLISH_GROUP_ID = 'no.nordicsemi.android' +// PUBLISH_ARTIFACT_ID = 'dfu-library' +// PUBLISH_VERSION = '0.6.0' +//} android { compileSdkVersion 22 @@ -26,9 +26,9 @@ android { dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) - compile 'com.android.support:support-v4:22.1.1' + compile 'com.android.support:support-v4:22.2.0' compile 'com.google.code.gson:gson:2.3.1' } // Generate maven package: gradlew clean build generateRelease -apply from: 'https://raw.githubusercontent.com/blundell/release-android-library/master/android-release-aar.gradle' \ No newline at end of file +//apply from: 'https://raw.githubusercontent.com/blundell/release-android-library/master/android-release-aar.gradle' \ No newline at end of file diff --git a/dfu/dfu.iml b/dfu/dfu.iml index 66e07c6..40c4be3 100644 --- a/dfu/dfu.iml +++ b/dfu/dfu.iml @@ -70,6 +70,7 @@ + @@ -88,7 +89,7 @@ - - + + \ No newline at end of file diff --git a/dfu/src/main/java/no/nordicsemi/android/dfu/DfuBaseService.java b/dfu/src/main/java/no/nordicsemi/android/dfu/DfuBaseService.java index 41ebed4..d913e64 100644 --- a/dfu/src/main/java/no/nordicsemi/android/dfu/DfuBaseService.java +++ b/dfu/src/main/java/no/nordicsemi/android/dfu/DfuBaseService.java @@ -1740,9 +1740,13 @@ public abstract class DfuBaseService extends IntentService { * We could have save the fact of jumping as a parameter of the service but it ma be that some Android devices must first scan a device before connecting to it. * It a device with the address+1 has never been detected before the service could have failed on connection. */ - sendLogBroadcast(LOG_LEVEL_VERBOSE, "Scanning for the DFU bootloader..."); + sendLogBroadcast(LOG_LEVEL_VERBOSE, "Scanning for the DFU Bootloader..."); final String newAddress = BootloaderScannerFactory.getScanner().searchFor(mDeviceAddress); - sendLogBroadcast(LOG_LEVEL_INFO, "The Bootloader found (" + newAddress + ")"); + if (newAddress != null) + sendLogBroadcast(LOG_LEVEL_INFO, "DFU Bootloader found with address " + newAddress); + else { + sendLogBroadcast(LOG_LEVEL_INFO, "DFU Bootloader not found. Trying the same address..."); + } /* * The current service instance has uploaded the Soft Device and/or Bootloader. @@ -1753,7 +1757,8 @@ public abstract class DfuBaseService extends IntentService { newIntent.fillIn(intent, Intent.FILL_IN_COMPONENT | Intent.FILL_IN_PACKAGE); newIntent.putExtra(EXTRA_FILE_MIME_TYPE, MIME_TYPE_ZIP); // ensure this is set (e.g. for scripts) newIntent.putExtra(EXTRA_FILE_TYPE, TYPE_APPLICATION); // set the type to application only - newIntent.putExtra(EXTRA_DEVICE_ADDRESS, newAddress); + if (newAddress != null) + newIntent.putExtra(EXTRA_DEVICE_ADDRESS, newAddress); newIntent.putExtra(EXTRA_PART_CURRENT, mPartCurrent + 1); newIntent.putExtra(EXTRA_PARTS_TOTAL, mPartsTotal); startService(newIntent); diff --git a/dfu/src/main/java/no/nordicsemi/android/dfu/scanner/BootloaderScanner.java b/dfu/src/main/java/no/nordicsemi/android/dfu/scanner/BootloaderScanner.java index 4ff4aaa..47c422e 100644 --- a/dfu/src/main/java/no/nordicsemi/android/dfu/scanner/BootloaderScanner.java +++ b/dfu/src/main/java/no/nordicsemi/android/dfu/scanner/BootloaderScanner.java @@ -37,7 +37,7 @@ public interface BootloaderScanner { /** * After the buttonless jump from the application mode to the bootloader mode the service will wait this long for the advertising bootloader (in milliseconds). */ - public final static long TIMEOUT = 2000l; // ms + public final static long TIMEOUT = 5000l; // ms /** The bootloader may advertise with the same address or one with the last byte incremented by this value. F.e. 00:11:22:33:44:55 -> 00:11:22:33:44:56. FF changes to 00. */ public final static int ADDRESS_DIFF = 1; diff --git a/dfu/src/main/java/no/nordicsemi/android/dfu/scanner/BootloaderScannerLollipop.java b/dfu/src/main/java/no/nordicsemi/android/dfu/scanner/BootloaderScannerLollipop.java index bbd20e0..b562fd8 100644 --- a/dfu/src/main/java/no/nordicsemi/android/dfu/scanner/BootloaderScannerLollipop.java +++ b/dfu/src/main/java/no/nordicsemi/android/dfu/scanner/BootloaderScannerLollipop.java @@ -22,14 +22,10 @@ package no.nordicsemi.android.dfu.scanner; -import java.util.ArrayList; -import java.util.List; - import android.annotation.TargetApi; import android.bluetooth.BluetoothAdapter; import android.bluetooth.le.BluetoothLeScanner; import android.bluetooth.le.ScanCallback; -import android.bluetooth.le.ScanFilter; import android.bluetooth.le.ScanResult; import android.bluetooth.le.ScanSettings; import android.os.Build; @@ -81,11 +77,15 @@ public class BootloaderScannerLollipop extends ScanCallback implements Bootloade final BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter(); final BluetoothLeScanner scanner = adapter.getBluetoothLeScanner(); - final List filters = new ArrayList<>(); - filters.add(new ScanFilter.Builder().setDeviceAddress(mDeviceAddress).build()); - filters.add(new ScanFilter.Builder().setDeviceAddress(mDeviceAddressIncremented).build()); + /* + * Scanning with filters does not work on Nexus 9 (Android 5.1). No devices are found and scanner terminates on timeout. + * We will match the device address in the callback method instead. It's not like it should be, but at least it works. + */ + //final List filters = new ArrayList<>(); + //filters.add(new ScanFilter.Builder().setDeviceAddress(mDeviceAddress).build()); + //filters.add(new ScanFilter.Builder().setDeviceAddress(mDeviceAddressIncremented).build()); final ScanSettings settings = new ScanSettings.Builder().setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY).build(); - scanner.startScan(filters, settings, this); + scanner.startScan(/*filters*/ null, settings, this); try { synchronized (mLock) {