From 7684e0ce7d236af11a4d96392068d1ff1e3e835f Mon Sep 17 00:00:00 2001 From: Aleksander Nowakowski Date: Wed, 1 Oct 2014 16:52:28 +0200 Subject: [PATCH] DFU error numbers changed to distinguish them from TOO MANY CONNECTIONS error (0x101). One bit has been added to ERROR_MASK. --- src/no/nordicsemi/android/dfu/DfuBaseService.java | 6 +++--- src/no/nordicsemi/android/error/GattError.java | 6 ++++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/no/nordicsemi/android/dfu/DfuBaseService.java b/src/no/nordicsemi/android/dfu/DfuBaseService.java index 714e641..bfd9f31 100644 --- a/src/no/nordicsemi/android/dfu/DfuBaseService.java +++ b/src/no/nordicsemi/android/dfu/DfuBaseService.java @@ -223,7 +223,7 @@ public abstract class DfuBaseService extends IntentService { /** * If this bit is set than the progress value indicates an error. Use {@link GattError#parse(int)} to obtain error name. */ - public static final int ERROR_MASK = 0x0100; + public static final int ERROR_MASK = 0x1100; public static final int ERROR_DEVICE_DISCONNECTED = ERROR_MASK | 0x00; public static final int ERROR_FILE_NOT_FOUND = ERROR_MASK | 0x01; /** Thrown if service was unable to open the file ({@link IOException} has been thrown). */ @@ -243,9 +243,9 @@ public abstract class DfuBaseService extends IntentService { /** Thrown when the the service does not support given type or mime-type. */ public static final int ERROR_FILE_TYPE_UNSUPPORTED = ERROR_MASK | 0x09; /** Flag set then the DFU target returned a DFU error. Look for DFU specification to get error codes. */ - public static final int ERROR_REMOTE_MASK = 0x0200; + public static final int ERROR_REMOTE_MASK = 0x1200; /** The flag set when one of {@link BluetoothGattCallback} methods was called with status other than {@link BluetoothGatt#GATT_SUCCESS}. */ - public static final int ERROR_CONNECTION_MASK = 0x0400; + public static final int ERROR_CONNECTION_MASK = 0x1400; /** * The log events are only broadcasted when there is no nRF Logger installed. The broadcast contains 2 extras: diff --git a/src/no/nordicsemi/android/error/GattError.java b/src/no/nordicsemi/android/error/GattError.java index bc9d2cc..21db06e 100644 --- a/src/no/nordicsemi/android/error/GattError.java +++ b/src/no/nordicsemi/android/error/GattError.java @@ -78,8 +78,10 @@ public class GattError { return "GATT ENCRYPED NO MITM"; case 0x008e: return "GATT NOT ENCRYPTED"; + case 0x0101: + return "TOO MANY OPEN CONNECTIONS"; case 0x00FF: - return "DFU SERVICE DSCOVERY NOT STARTED"; + return "DFU SERVICE DISCOVERY NOT STARTED"; case DfuBaseService.ERROR_DEVICE_DISCONNECTED: return "DFU DEVICE DISCONNECTED"; case DfuBaseService.ERROR_FILE_ERROR: @@ -113,7 +115,7 @@ public class GattError { return "REMOTE DFU OPERATION FAILED"; } } - return String.format("UNKNOWN (0x%02X)", error & 0xFF); + return "UNKNOWN (" + error + ")"; } } }