diff --git a/dfu/dfu.iml b/dfu/dfu.iml
index 90a2c9a..b126957 100644
--- a/dfu/dfu.iml
+++ b/dfu/dfu.iml
@@ -1,5 +1,5 @@
-
- * To run the service to your application inherit it and overwrite the missing method. Remember to it to the AndroidManifest.xml file. Start the service with the following parameters:
+ * To run the service to your application extend it in your project and overwrite the missing method. Remember to add your class to the AndroidManifest.xml file.
+ *
+ * Start the service with the following parameters:
*
- * With the Soft Device 7.0.0+ it allows to upload a new Soft Device, new Bootloader and a new Application (marked here as DFU v2.0). For older soft devices only the Application update is supported.
+ * The DFU Service provides full support for Over-the-Air (OTA) Device Firmware Update (DFU) by Nordic Semiconductor.
+ * With the Soft Device 7.0.0+ it allows to upload a new Soft Device, new Bootloader and a new Application. For older soft devices only the Application update is supported.
*
* final Intent service = new Intent(this, YourDfuService.class);
- * service.putExtra(DfuService.EXTRA_DEVICE_ADDRESS, mSelectedDevice.getAddress());
- * service.putExtra(DfuService.EXTRA_DEVICE_NAME, mSelectedDevice.getName());
+ * service.putExtra(DfuService.EXTRA_DEVICE_ADDRESS, mSelectedDevice.getAddress()); // Target device address
+ * service.putExtra(DfuService.EXTRA_DEVICE_NAME, mSelectedDevice.getName()); // This name will be shown on the notification
* service.putExtra(DfuService.EXTRA_FILE_MIME_TYPE, mFileType == DfuService.TYPE_AUTO ? YourDfuService.MIME_TYPE_ZIP : YourDfuService.MIME_TYPE_OCTET_STREAM);
* service.putExtra(DfuService.EXTRA_FILE_TYPE, mFileType);
* service.putExtra(DfuService.EXTRA_FILE_PATH, mFilePath);
@@ -79,17 +92,14 @@ import no.nordicsemi.android.log.Logger;
* startService(service);
*
*
- * The {@link #EXTRA_FILE_MIME_TYPE} and {@link #EXTRA_FILE_TYPE} parameters are optional. If not provided the application upload from HEX/BIN file is assumed. The service API is compatible with
- * previous versions.
+ * The {@link #EXTRA_FILE_MIME_TYPE} and {@link #EXTRA_FILE_TYPE} parameters are optional. If not provided the application upload from HEX/BIN file is assumed.
+ * The service API is compatible with previous versions.
*
- * The service will show its progress in the notifications bar and will send local broadcasts to the application. + * The service will show its progress on the notification bar and will send local broadcasts to the application. *
*/ public abstract class DfuBaseService extends IntentService { - private static final String TAG = "DfuService"; - private static final char[] HEX_ARRAY = "0123456789ABCDEF".toCharArray(); - /** * The address of the device to update. */ @@ -100,45 +110,55 @@ public abstract class DfuBaseService extends IntentService { public static final String EXTRA_DEVICE_NAME = "no.nordicsemi.android.dfu.extra.EXTRA_DEVICE_NAME"; /** *
- * If the new firmware does not share the bond information with the old one the bond information is lost. Set this flag to true
to make the service create new bond with the new
- * application when the upload is done (and remove the old one). When set to false
(default), the DFU service assumes that the LTK is shared between them. Currently it is not possible
- * to remove the old bond and not creating a new one so if your old application supported bonding while the new one does not you have to modify the source code yourself.
+ * If the new firmware (application) does not share the bond information with the old one, the bond information is lost. Set this flag to true
+ * to make the service create new bond with the new application when the upload is done (and remove the old one). When set to false
(default),
+ * the DFU service assumes that the LTK is shared between them. Note: currently it is not possible to remove the old bond without creating a new one so if
+ * your old application supported bonding while the new one does not you have to modify the source code yourself.
*
- * In case of updating the soft device and bootloader the application is always removed so the bond information with it. + * In case of updating the soft device the application is always removed so the bond information with it. *
** Search for occurrences of EXTRA_RESTORE_BOND in this file to check the implementation and get more details. *
*/ public static final String EXTRA_RESTORE_BOND = "no.nordicsemi.android.dfu.extra.EXTRA_RESTORE_BOND"; - public static final String EXTRA_LOG_URI = "no.nordicsemi.android.dfu.extra.EXTRA_LOG_URI"; + /** + * A path to the file with the new firmware. It may point to a HEX, BIN or a ZIP file. + * Some file manager applications return the path as a String while other return a Uri. Use the {@link #EXTRA_FILE_URI} in the later case. + */ public static final String EXTRA_FILE_PATH = "no.nordicsemi.android.dfu.extra.EXTRA_FILE_PATH"; + /** + * See {@link #EXTRA_FILE_PATH} for details. + */ public static final String EXTRA_FILE_URI = "no.nordicsemi.android.dfu.extra.EXTRA_FILE_URI"; /** - * The Init packet URI. This file is required if Extended Init Packet is required. Must point to a 'dat' file corresponding with the selected firmware. The Init packet may contain just the CRC - * (in case of older versions of DFU) or the Extended Init Packet in binary format. + * The Init packet URI. This file is required if the Extended Init Packet is required (SDK 7.0+). Must point to a 'dat' file corresponding with the selected firmware. + * The Init packet may contain just the CRC (in case of older versions of DFU) or the Extended Init Packet in binary format (SDK 7.0+). */ public static final String EXTRA_INIT_FILE_PATH = "no.nordicsemi.android.dfu.extra.EXTRA_INIT_FILE_PATH"; /** - * The Init packet path. This file is required if Extended Init Packet is required. Must point to a 'dat' file corresponding with the selected firmware. The Init packet may contain just the CRC - * (in case of older versions of DFU) or the Extended Init Packet in binary format. + * The Init packet URI. This file is required if the Extended Init Packet is required (SDK 7.0+). Must point to a 'dat' file corresponding with the selected firmware. + * The Init packet may contain just the CRC (in case of older versions of DFU) or the Extended Init Packet in binary format (SDK 7.0+). */ public static final String EXTRA_INIT_FILE_URI = "no.nordicsemi.android.dfu.extra.EXTRA_INIT_FILE_URI"; - /** - * The input file mime-type. Currently only "application/zip" (ZIP) or "application/octet-stream" (HEX or BIN) are supported. If this parameter is empty the "application/octet-stream" is assumed. + * The input file mime-type. Currently only "application/zip" (ZIP) or "application/octet-stream" (HEX or BIN) are supported. If this parameter is + * empty the "application/octet-stream" is assumed. */ public static final String EXTRA_FILE_MIME_TYPE = "no.nordicsemi.android.dfu.extra.EXTRA_MIME_TYPE"; - + // Since the DFU Library version 7.0 both HEX and BIN files are supported. As both files have the same MIME TYPE the distinction is made based on the file extension. + public static final String MIME_TYPE_OCTET_STREAM = "application/octet-stream"; + public static final String MIME_TYPE_ZIP = "application/zip"; /** * This optional extra parameter may contain a file type. Currently supported are: *
- * Flag set to true
when the DFU target had send any notification with status other than {@link #DFU_STATUS_SUCCESS}. Setting it to true
will abort sending firmware and
- * stop logging notifications (read below for explanation).
- *
- * The onCharacteristicWrite(..) callback is written when Android puts the packet to the outgoing queue, not when it physically send the data. Therefore, in case of invalid state of the DFU - * target, Android will first put up to N* packets, one by one, while in fact the first will be transmitted. In case the DFU target is in an invalid state it will notify Android with a - * notification 10-03-02 for each packet of firmware that has been sent. However, just after receiving the first one this service will try to send the reset command while still getting more - * 10-03-02 notifications. This flag will prevent from logging "Notification received..." more than once. - *
- *- * Additionally, sometimes after writing the command 6 ({@link #OP_CODE_RESET}), Android will receive a notification and update the characteristic value with 10-03-02 and the callback for write - * reset command will log "[DFU] Data written to ..., value (0x): 10-03-02" instead of "...(x0): 06". But this does not matter for the DFU process. - *
- *- * N* - Value of Packet Receipt Notification, 10 by default. - *
- */ - private boolean mRemoteErrorOccurred; - - /** - * Latest data received from device using notification. - */ - private byte[] mReceivedData = null; - private static final int OP_CODE_START_DFU_KEY = 0x01; // 1 - private static final int OP_CODE_INIT_DFU_PARAMS_KEY = 0x02; // 2 - private static final int OP_CODE_RECEIVE_FIRMWARE_IMAGE_KEY = 0x03; // 3 - private static final int OP_CODE_VALIDATE_KEY = 0x04; // 4 - private static final int OP_CODE_ACTIVATE_AND_RESET_KEY = 0x05; // 5 - private static final int OP_CODE_RESET_KEY = 0x06; // 6 - // private static final int OP_CODE_PACKET_REPORT_RECEIVED_IMAGE_SIZE_KEY = 0x07; // 7 - private static final int OP_CODE_PACKET_RECEIPT_NOTIF_REQ_KEY = 0x08; // 8 - private static final int OP_CODE_RESPONSE_CODE_KEY = 0x10; // 16 - private static final int OP_CODE_PACKET_RECEIPT_NOTIF_KEY = 0x11; // 11 - private static final byte[] OP_CODE_START_DFU = new byte[]{OP_CODE_START_DFU_KEY, 0x00}; - private static final byte[] OP_CODE_INIT_DFU_PARAMS_START = new byte[]{OP_CODE_INIT_DFU_PARAMS_KEY, 0x00}; - private static final byte[] OP_CODE_INIT_DFU_PARAMS_COMPLETE = new byte[]{OP_CODE_INIT_DFU_PARAMS_KEY, 0x01}; - private static final byte[] OP_CODE_RECEIVE_FIRMWARE_IMAGE = new byte[]{OP_CODE_RECEIVE_FIRMWARE_IMAGE_KEY}; - private static final byte[] OP_CODE_VALIDATE = new byte[]{OP_CODE_VALIDATE_KEY}; - private static final byte[] OP_CODE_ACTIVATE_AND_RESET = new byte[]{OP_CODE_ACTIVATE_AND_RESET_KEY}; - private static final byte[] OP_CODE_RESET = new byte[]{OP_CODE_RESET_KEY}; - // private static final byte[] OP_CODE_REPORT_RECEIVED_IMAGE_SIZE = new byte[] { OP_CODE_PACKET_REPORT_RECEIVED_IMAGE_SIZE_KEY }; - private static final byte[] OP_CODE_PACKET_RECEIPT_NOTIF_REQ = new byte[]{OP_CODE_PACKET_RECEIPT_NOTIF_REQ_KEY, 0x00, 0x00}; - - public static final int DFU_STATUS_SUCCESS = 1; - public static final int DFU_STATUS_INVALID_STATE = 2; - public static final int DFU_STATUS_NOT_SUPPORTED = 3; - public static final int DFU_STATUS_DATA_SIZE_EXCEEDS_LIMIT = 4; - public static final int DFU_STATUS_CRC_ERROR = 5; - public static final int DFU_STATUS_OPERATION_FAILED = 6; - - private static final UUID GENERIC_ATTRIBUTE_SERVICE_UUID = new UUID(0x0000180100001000l, 0x800000805F9B34FBl); - private static final UUID SERVICE_CHANGED_UUID = new UUID(0x00002A0500001000l, 0x800000805F9B34FBl); - - private static final UUID DFU_SERVICE_UUID = new UUID(0x000015301212EFDEl, 0x1523785FEABCD123l); - private static final UUID DFU_CONTROL_POINT_UUID = new UUID(0x000015311212EFDEl, 0x1523785FEABCD123l); - private static final UUID DFU_PACKET_UUID = new UUID(0x000015321212EFDEl, 0x1523785FEABCD123l); - private static final UUID DFU_VERSION = new UUID(0x000015341212EFDEl, 0x1523785FEABCD123l); - private static final UUID CLIENT_CHARACTERISTIC_CONFIG = new UUID(0x0000290200001000l, 0x800000805f9b34fbl); - - private static final int NOTIFICATIONS = 1; - private static final int INDICATIONS = 2; - - // Since the DFU Library version 7.0 both HEX and BIN files are supported. As both files have the same MIME TYPE the distinction is made based on the file extension. - public static final String MIME_TYPE_OCTET_STREAM = "application/octet-stream"; - public static final String MIME_TYPE_ZIP = "application/zip"; - private final BroadcastReceiver mDfuActionReceiver = new BroadcastReceiver() { @Override public void onReceive(final Context context, final Intent intent) { @@ -568,27 +584,24 @@ public abstract class DfuBaseService extends IntentService { } } }; - - private final BroadcastReceiver mConnectionStateBroadcastReceiver = new BroadcastReceiver() { - @Override - public void onReceive(final Context context, final Intent intent) { - // obtain the device and check it this is the one that we are connected to - final BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE); - if (!device.getAddress().equals(mDeviceAddress)) - return; - - final String action = intent.getAction(); - - logi("Action received: " + action); - mConnectionState = STATE_DISCONNECTED; - - // notify waiting thread - synchronized (mLock) { - mLock.notifyAll(); - } - } - }; - + private long mLastProgressTime, mStartTime; + /** + * Flag sent when a request has been sent that will cause the DFU target to reset. Often, after sending such command, Android throws a connection state error. If this flag is set the error will be + * ignored. + */ + private boolean mResetRequestSent; + /** + * Flag indicating whether the image size has been already transferred or not + */ + private boolean mImageSizeSent; + /** + * Flag indicating whether the init packet has been already transferred or not + */ + private boolean mInitPacketSent; + /** + * Flag indicating whether the request was completed or not + */ + private boolean mRequestCompleted; private final BroadcastReceiver mBondStateBroadcastReceiver = new BroadcastReceiver() { @Override public void onReceive(final Context context, final Intent intent) { @@ -610,7 +623,30 @@ public abstract class DfuBaseService extends IntentService { } } }; - + /** + *
+ * Flag set to true
when the DFU target had send any notification with status other than {@link #DFU_STATUS_SUCCESS}. Setting it to true
will abort sending firmware and
+ * stop logging notifications (read below for explanation).
+ *
+ * The onCharacteristicWrite(..) callback is written when Android puts the packet to the outgoing queue, not when it physically send the data. Therefore, in case of invalid state of the DFU + * target, Android will first put up to N* packets, one by one, while in fact the first will be transmitted. In case the DFU target is in an invalid state it will notify Android with a + * notification 10-03-02 for each packet of firmware that has been sent. However, just after receiving the first one this service will try to send the reset command while still getting more + * 10-03-02 notifications. This flag will prevent from logging "Notification received..." more than once. + *
+ *+ * Additionally, sometimes after writing the command 6 ({@link #OP_CODE_RESET}), Android will receive a notification and update the characteristic value with 10-03-02 and the callback for write + * reset command will log "[DFU] Data written to ..., value (0x): 10-03-02" instead of "...(x0): 06". But this does not matter for the DFU process. + *
+ *+ * N* - Value of Packet Receipt Notification, 10 by default. + *
+ */ + private boolean mRemoteErrorOccurred; + /** + * Latest data received from device using notification. + */ + private byte[] mReceivedData = null; private final BluetoothGattCallback mGattCallback = new BluetoothGattCallback() { @Override public void onConnectionStateChange(final BluetoothGatt gatt, final int status, final int newState) { @@ -749,7 +785,7 @@ public abstract class DfuBaseService extends IntentService { if (mAborted || mError != 0 || mRemoteErrorOccurred || mResetRequestSent) { // notify waiting thread synchronized (mLock) { - sendLogBroadcast(Level.WARNING, "Upload terminated"); + sendLogBroadcast(LOG_LEVEL_WARNING, "Upload terminated"); mLock.notifyAll(); return; } @@ -769,16 +805,16 @@ public abstract class DfuBaseService extends IntentService { } } else if (!mImageSizeSent) { // we've got confirmation that the image size was sent - sendLogBroadcast(Level.INFO, "Data written to " + characteristic.getUuid() + ", value (0x): " + parse(characteristic)); + sendLogBroadcast(LOG_LEVEL_INFO, "Data written to " + characteristic.getUuid() + ", value (0x): " + parse(characteristic)); mImageSizeSent = true; } else { // we've got confirmation that the init packet was sent - sendLogBroadcast(Level.INFO, "Data written to " + characteristic.getUuid() + ", value (0x): " + parse(characteristic)); + sendLogBroadcast(LOG_LEVEL_INFO, "Data written to " + characteristic.getUuid() + ", value (0x): " + parse(characteristic)); mInitPacketSent = true; } } else { // if the CONTROL POINT characteristic was written just set the flag to true - sendLogBroadcast(Level.INFO, "Data written to " + characteristic.getUuid() + ", value (0x): " + parse(characteristic)); + sendLogBroadcast(LOG_LEVEL_INFO, "Data written to " + characteristic.getUuid() + ", value (0x): " + parse(characteristic)); mRequestCompleted = true; } } else { @@ -806,7 +842,7 @@ public abstract class DfuBaseService extends IntentService { /* * This method is called when the DFU Version characteristic has been read. */ - sendLogBroadcast(Level.INFO, "Read Response received from " + characteristic.getUuid() + ", value (0x): " + parse(characteristic)); + sendLogBroadcast(LOG_LEVEL_INFO, "Read Response received from " + characteristic.getUuid() + ", value (0x): " + parse(characteristic)); mReceivedData = characteristic.getValue(); mRequestCompleted = true; } else { @@ -836,7 +872,7 @@ public abstract class DfuBaseService extends IntentService { // The writing might have been aborted (mAborted = true), an error might have occurred. // In that case quit sending. if (mAborted || mError != 0 || mRemoteErrorOccurred || mResetRequestSent) { - sendLogBroadcast(Level.WARNING, "Upload terminated"); + sendLogBroadcast(LOG_LEVEL_WARNING, "Upload terminated"); break; } @@ -866,7 +902,7 @@ public abstract class DfuBaseService extends IntentService { if (status != DFU_STATUS_SUCCESS) mRemoteErrorOccurred = true; - sendLogBroadcast(Level.INFO, "Notification received from " + characteristic.getUuid() + ", value (0x): " + parse(characteristic)); + sendLogBroadcast(LOG_LEVEL_INFO, "Notification received from " + characteristic.getUuid() + ", value (0x): " + parse(characteristic)); mReceivedData = characteristic.getValue(); break; } @@ -896,11 +932,21 @@ public abstract class DfuBaseService extends IntentService { return new String(out); } }; + /** + * Stores the last progress percent. Used to lower number of calls of {@link #updateProgressNotification(int)}. + */ + private int mLastProgress = -1; public DfuBaseService() { super(TAG); } + private static IntentFilter makeDfuActionIntentFilter() { + final IntentFilter intentFilter = new IntentFilter(); + intentFilter.addAction(DfuBaseService.BROADCAST_ACTION); + return intentFilter; + } + @Override public void onCreate() { super.onCreate(); @@ -943,26 +989,24 @@ public abstract class DfuBaseService extends IntentService { final Uri fileUri = intent.getParcelableExtra(EXTRA_FILE_URI); final String initFilePath = intent.getStringExtra(EXTRA_INIT_FILE_PATH); final Uri initFileUri = intent.getParcelableExtra(EXTRA_INIT_FILE_URI); - final Uri logUri = intent.getParcelableExtra(EXTRA_LOG_URI); int fileType = intent.getIntExtra(EXTRA_FILE_TYPE, TYPE_AUTO); if (filePath != null && fileType == TYPE_AUTO) fileType = filePath.toLowerCase(Locale.US).endsWith("zip") ? TYPE_AUTO : TYPE_APPLICATION; String mimeType = intent.getStringExtra(EXTRA_FILE_MIME_TYPE); mimeType = mimeType != null ? mimeType : (fileType == TYPE_AUTO ? MIME_TYPE_ZIP : MIME_TYPE_OCTET_STREAM); // FIXME check if it's better - mLogSession = Logger.openSession(this, logUri); mPartCurrent = intent.getIntExtra(EXTRA_PART_CURRENT, 1); mPartsTotal = intent.getIntExtra(EXTRA_PARTS_TOTAL, 1); // Check file type and mime-type if ((fileType & ~(TYPE_SOFT_DEVICE | TYPE_BOOTLOADER | TYPE_APPLICATION)) > 0 || !(MIME_TYPE_ZIP.equals(mimeType) || MIME_TYPE_OCTET_STREAM.equals(mimeType))) { logw("File type or file mime-type not supported"); - sendLogBroadcast(Level.WARNING, "File type or file mime-type not supported"); + sendLogBroadcast(LOG_LEVEL_WARNING, "File type or file mime-type not supported"); sendErrorBroadcast(ERROR_FILE_TYPE_UNSUPPORTED); return; } if (MIME_TYPE_OCTET_STREAM.equals(mimeType) && fileType != TYPE_SOFT_DEVICE && fileType != TYPE_BOOTLOADER && fileType != TYPE_APPLICATION) { logw("Unable to determine file type"); - sendLogBroadcast(Level.WARNING, "Unable to determine file type"); + sendLogBroadcast(LOG_LEVEL_WARNING, "Unable to determine file type"); sendErrorBroadcast(ERROR_FILE_TYPE_UNSUPPORTED); return; } @@ -997,7 +1041,7 @@ public abstract class DfuBaseService extends IntentService { if (!packetReceiptNotificationEnabled) numberOfPackets = 0; mPacketsBeforeNotification = numberOfPackets; - // The Soft Device starts where MBR ends (by default from the address 0x1000). Before there is a MBR section, which should not be transmitted over DFU. + // The Soft Device starts where MBR ends (by default from the address 0x1000). Before there is a MBR section, which should not be transmitted over DFU. // Applications and bootloader starts from bigger address. However, in custom DFU implementations, user may want to transmit the whole whole data, even from address 0x0000. value = preferences.getString(DfuSettingsConstants.SETTINGS_MBR_SIZE, String.valueOf(DfuSettingsConstants.SETTINGS_DEFAULT_MBR_SIZE)); int mbrSize; @@ -1009,7 +1053,7 @@ public abstract class DfuBaseService extends IntentService { mbrSize = DfuSettingsConstants.SETTINGS_DEFAULT_MBR_SIZE; } - sendLogBroadcast(Level.VERBOSE, "Starting DFU service"); + sendLogBroadcast(LOG_LEVEL_VERBOSE, "Starting DFU service"); /* * First the service is trying to read the firmware and init packet files. @@ -1020,7 +1064,7 @@ public abstract class DfuBaseService extends IntentService { try { // Prepare data to send, calculate stream size try { - sendLogBroadcast(Level.VERBOSE, "Opening file..."); + sendLogBroadcast(LOG_LEVEL_VERBOSE, "Opening file..."); if (fileUri != null) { is = openInputStream(fileUri, mimeType, mbrSize, fileType); } else { @@ -1054,7 +1098,7 @@ public abstract class DfuBaseService extends IntentService { initIs = new ByteArrayInputStream(zhis.getSystemInit()); } } - sendLogBroadcast(Level.INFO, "Image file opened (" + mImageSizeInBytes + " bytes in total)"); + sendLogBroadcast(LOG_LEVEL_INFO, "Image file opened (" + mImageSizeInBytes + " bytes in total)"); } catch (final SecurityException e) { loge("A security exception occurred while opening file", e); updateProgressNotification(ERROR_FILE_NOT_FOUND); @@ -1073,27 +1117,27 @@ public abstract class DfuBaseService extends IntentService { * Now let's connect to the device. * All the methods below are synchronous. The mLock object is used to wait for asynchronous calls. */ - sendLogBroadcast(Level.VERBOSE, "Connecting to DFU target..."); + sendLogBroadcast(LOG_LEVEL_VERBOSE, "Connecting to DFU target..."); updateProgressNotification(PROGRESS_CONNECTING); final BluetoothGatt gatt = connect(deviceAddress); // Are we connected? if (gatt == null) { loge("Bluetooth adapter disabled"); - sendLogBroadcast(Level.ERROR, "Bluetooth adapter disabled"); + sendLogBroadcast(LOG_LEVEL_ERROR, "Bluetooth adapter disabled"); updateProgressNotification(ERROR_BLUETOOTH_DISABLED); return; } if (mError > 0) { // error occurred final int error = mError & ~ERROR_CONNECTION_MASK; loge("An error occurred while connecting to the device:" + error); - sendLogBroadcast(Level.ERROR, String.format("Connection failed (0x%02X): %s", error, GattError.parse(error))); + sendLogBroadcast(LOG_LEVEL_ERROR, String.format("Connection failed (0x%02X): %s", error, GattError.parse(error))); terminateConnection(gatt, mError); return; } if (mAborted) { logi("Upload aborted"); - sendLogBroadcast(Level.WARNING, "Upload aborted"); + sendLogBroadcast(LOG_LEVEL_WARNING, "Upload aborted"); terminateConnection(gatt, PROGRESS_ABORTED); return; } @@ -1102,7 +1146,7 @@ public abstract class DfuBaseService extends IntentService { final BluetoothGattService dfuService = gatt.getService(DFU_SERVICE_UUID); // there was a case when the service was null. I don't know why if (dfuService == null) { loge("DFU service does not exists on the device"); - sendLogBroadcast(Level.WARNING, "Connected. DFU Service not found"); + sendLogBroadcast(LOG_LEVEL_WARNING, "Connected. DFU Service not found"); terminateConnection(gatt, ERROR_SERVICE_NOT_FOUND); return; } @@ -1110,29 +1154,28 @@ public abstract class DfuBaseService extends IntentService { final BluetoothGattCharacteristic packetCharacteristic = dfuService.getCharacteristic(DFU_PACKET_UUID); if (controlPointCharacteristic == null || packetCharacteristic == null) { loge("DFU characteristics not found in the DFU service"); - sendLogBroadcast(Level.WARNING, "Connected. DFU Characteristics not found"); + sendLogBroadcast(LOG_LEVEL_WARNING, "Connected. DFU Characteristics not found"); terminateConnection(gatt, ERROR_CHARACTERISTICS_NOT_FOUND); return; } /* * The DFU Version characteristic has been added in SDK 7.0. - * + * * It may return version number in 2 bytes (f.e. 0x05-00), where the first one is the minor version and the second one is the major version. * In case of 0x05-00 the DFU has the version 0.5. - * + * * Currently the following version numbers are supported: - * + * * - 0.1 (0x01-00) - Device is connected to the application, not to the Bootloader. The application supports Long Term Key (LTK) sharing and buttonless update. - * Enable notifications on the DFU Control Point characteristic and write 0x01-04 into it to jump to the Bootloader. + * Enable notifications on the DFU Control Point characteristic and write 0x01-04 into it to jump to the Bootloader. * Check the Bootloader version again for more info about the Bootloader version. - * + * * - 0.5 (0x05-00) - Device is in OTA-DFU Bootloader. The Bootloader supports LTK sharing and required the Extended Init Packet. It supports * a SoftDevice, Bootloader or an Application update. SoftDevice and a Bootloader may be sent together. - * */ final BluetoothGattCharacteristic versionCharacteristic = dfuService.getCharacteristic(DFU_VERSION); // this may be null for older versions of the Bootloader - sendLogBroadcast(Level.INFO, "Connected. Services discovered"); + sendLogBroadcast(LOG_LEVEL_INFO, "Connected. Services discovered"); try { updateProgressNotification(PROGRESS_STARTING); @@ -1143,21 +1186,21 @@ public abstract class DfuBaseService extends IntentService { final int minor = (version & 0x0F); final int major = (version >> 8); logi("Version number read: " + major + "." + minor); - sendLogBroadcast(Level.APPLICATION, "Version number read: " + major + "." + minor); + sendLogBroadcast(LOG_LEVEL_APPLICATION, "Version number read: " + major + "." + minor); } /* * Check if we are in the DFU Bootloader or in the Application that supports the buttonless update. - * + * * In the DFU from SDK 6.1, which was also supporting the buttonless update, there was no DFU Version characteristic. In that case we may find out whether - * we are in the bootloader or application by simply checking the number of characteristics. + * we are in the bootloader or application by simply checking the number of characteristics. */ if (version == 1 || (version == 0 && gatt.getServices().size() > 3 /* No DFU Version char but more services than Generic Access, Generic Attribute, DFU Service */)) { // The service is connected to the application, not to the bootloader logw("Application with buttonless update found"); - sendLogBroadcast(Level.WARNING, "Application with buttonless update found"); + sendLogBroadcast(LOG_LEVEL_WARNING, "Application with buttonless update found"); - // If we are bonded we may want to enable Service Changed characteristic indications. + // If we are bonded we may want to enable Service Changed characteristic indications. // Note: This feature will be introduced in the SDK 8.0 as this is the proper way to refresh attribute list on the phone. boolean hasServiceChanged = false; if (gatt.getDevice().getBondState() == BluetoothDevice.BOND_BONDED) { @@ -1166,41 +1209,41 @@ public abstract class DfuBaseService extends IntentService { final BluetoothGattCharacteristic serviceChangedCharacteristic = genericAttributeService.getCharacteristic(SERVICE_CHANGED_UUID); if (serviceChangedCharacteristic != null) { enableCCCD(gatt, serviceChangedCharacteristic, INDICATIONS); - sendLogBroadcast(Level.APPLICATION, "Service Changed indications enabled"); + sendLogBroadcast(LOG_LEVEL_APPLICATION, "Service Changed indications enabled"); hasServiceChanged = true; } } } - sendLogBroadcast(Level.VERBOSE, "Jumping to the DFU Bootloader..."); + sendLogBroadcast(LOG_LEVEL_VERBOSE, "Jumping to the DFU Bootloader..."); // Enable notifications enableCCCD(gatt, controlPointCharacteristic, NOTIFICATIONS); - sendLogBroadcast(Level.APPLICATION, "Notifications enabled"); + sendLogBroadcast(LOG_LEVEL_APPLICATION, "Notifications enabled"); // Send 'jump to bootloader command' (Start DFU) updateProgressNotification(PROGRESS_ENABLING_DFU_MODE); OP_CODE_START_DFU[1] = 0x04; logi("Sending Start DFU command (Op Code = 1, Upload Mode = 4)"); writeOpCode(gatt, controlPointCharacteristic, OP_CODE_START_DFU, true); - sendLogBroadcast(Level.APPLICATION, "Jump to bootloader sent (Op Code = 1, Upload Mode = 4)"); + sendLogBroadcast(LOG_LEVEL_APPLICATION, "Jump to bootloader sent (Op Code = 1, Upload Mode = 4)"); // The device will reset so we don't have to send Disconnect signal. waitUntilDisconnected(); - sendLogBroadcast(Level.INFO, "Disconnected by the remote device"); + sendLogBroadcast(LOG_LEVEL_INFO, "Disconnected by the remote device"); /* - * We would like to avoid using the hack with refreshing the device (refresh method is not in the public API). The refresh method clears the cached services and causes a - * service discovery afterwards (when connected). Android, however, does it itself when receive the Service Changed indication when bonded. + * We would like to avoid using the hack with refreshing the device (refresh method is not in the public API). The refresh method clears the cached services and causes a + * service discovery afterwards (when connected). Android, however, does it itself when receive the Service Changed indication when bonded. * In case of unpaired device we may either refresh the services manually (using the hack), or include the Service Changed characteristic. - * + * * According to Bluetooth Core 4.0 (and 4.1) specification: - * + * * [Vol. 3, Part G, 2.5.2 - Attribute Caching] * Note: Clients without a trusted relationship must perform service discovery on each connection if the server supports the Services Changed characteristic. - * + * * However, as up to Android 5 the system does NOT respect this requirement and servers are cached for every device, even if Service Changed is enabled -> Android BUG? - * For bonded devices Android performs service re-discovery when SC indication is received. + * For bonded devices Android performs service re-discovery when SC indication is received. */ refreshDeviceCache(gatt, !hasServiceChanged); @@ -1216,7 +1259,7 @@ public abstract class DfuBaseService extends IntentService { // Enable notifications enableCCCD(gatt, controlPointCharacteristic, NOTIFICATIONS); - sendLogBroadcast(Level.APPLICATION, "Notifications enabled"); + sendLogBroadcast(LOG_LEVEL_APPLICATION, "Notifications enabled"); try { // Set up the temporary variable that will hold the responses @@ -1242,7 +1285,7 @@ public abstract class DfuBaseService extends IntentService { * If
* __________
* * - connection state constants:
@@ -2457,8 +2489,6 @@ public abstract class DfuBaseService extends IntentService {
broadcast.putExtra(EXTRA_PARTS_TOTAL, mPartsTotal);
broadcast.putExtra(EXTRA_SPEED_B_PER_MS, speed);
broadcast.putExtra(EXTRA_AVG_SPEED_B_PER_MS, avgSpeed);
- if (mLogSession != null)
- broadcast.putExtra(EXTRA_LOG_URI, mLogSession.getSessionUri());
LocalBroadcastManager.getInstance(this).sendBroadcast(broadcast);
}
@@ -2466,25 +2496,16 @@ public abstract class DfuBaseService extends IntentService {
final Intent broadcast = new Intent(BROADCAST_ERROR);
broadcast.putExtra(EXTRA_DATA, error & ~ERROR_CONNECTION_MASK);
broadcast.putExtra(EXTRA_DEVICE_ADDRESS, mDeviceAddress);
- if (mLogSession != null)
- broadcast.putExtra(EXTRA_LOG_URI, mLogSession.getSessionUri());
LocalBroadcastManager.getInstance(this).sendBroadcast(broadcast);
}
private void sendLogBroadcast(final int level, final String message) {
- final ILogSession session = mLogSession;
final String fullMessage = "[DFU] " + message;
- if (session == null) {
- // the log provider is not installed, use broadcast action
- final Intent broadcast = new Intent(BROADCAST_LOG);
- broadcast.putExtra(EXTRA_LOG_MESSAGE, fullMessage);
- broadcast.putExtra(EXTRA_LOG_LEVEL, level);
- broadcast.putExtra(EXTRA_DEVICE_ADDRESS, mDeviceAddress);
- LocalBroadcastManager.getInstance(this).sendBroadcast(broadcast);
- } else {
- // the log provider is installed, we can use logger
- Logger.log(session, level, fullMessage);
- }
+ final Intent broadcast = new Intent(BROADCAST_LOG);
+ broadcast.putExtra(EXTRA_LOG_MESSAGE, fullMessage);
+ broadcast.putExtra(EXTRA_LOG_LEVEL, level);
+ broadcast.putExtra(EXTRA_DEVICE_ADDRESS, mDeviceAddress);
+ LocalBroadcastManager.getInstance(this).sendBroadcast(broadcast);
}
/**
@@ -2510,12 +2531,6 @@ public abstract class DfuBaseService extends IntentService {
return true;
}
- private static IntentFilter makeDfuActionIntentFilter() {
- final IntentFilter intentFilter = new IntentFilter();
- intentFilter.addAction(DfuBaseService.BROADCAST_ACTION);
- return intentFilter;
- }
-
private void loge(final String message) {
if (BuildConfig.DEBUG)
Log.e(TAG, message);
diff --git a/dfu/src/main/java/no/nordicsemi/android/dfu/DfuSettingsConstants.java b/dfu/src/main/java/no/nordicsemi/android/dfu/DfuSettingsConstants.java
index 246616b..f6f483c 100644
--- a/dfu/src/main/java/no/nordicsemi/android/dfu/DfuSettingsConstants.java
+++ b/dfu/src/main/java/no/nordicsemi/android/dfu/DfuSettingsConstants.java
@@ -1,3 +1,25 @@
+/*************************************************************************************************************************************************
+ * Copyright (c) 2015, Nordic Semiconductor
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ ************************************************************************************************************************************************/
+
package no.nordicsemi.android.dfu;
public interface DfuSettingsConstants {
diff --git a/dfu/src/main/java/no/nordicsemi/android/dfu/HexInputStream.java b/dfu/src/main/java/no/nordicsemi/android/dfu/HexInputStream.java
index f3dfe25..be7c702 100644
--- a/dfu/src/main/java/no/nordicsemi/android/dfu/HexInputStream.java
+++ b/dfu/src/main/java/no/nordicsemi/android/dfu/HexInputStream.java
@@ -1,11 +1,25 @@
-/*******************************************************************************
- * Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved.
- *
- * The information contained herein is property of Nordic Semiconductor ASA.
- * Terms and conditions of usage are described in detail in NORDIC SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
- * Licensees are granted free, non-transferable use of the information. NO WARRANTY of ANY KIND is provided.
- * This heading must NOT be removed from the file.
- ******************************************************************************/
+/*************************************************************************************************************************************************
+ * Copyright (c) 2015, Nordic Semiconductor
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ ************************************************************************************************************************************************/
+
package no.nordicsemi.android.dfu;
import java.io.BufferedInputStream;
diff --git a/dfu/src/main/java/no/nordicsemi/android/dfu/ZipHexInputStream.java b/dfu/src/main/java/no/nordicsemi/android/dfu/ZipHexInputStream.java
index ad2d642..1cd659a 100644
--- a/dfu/src/main/java/no/nordicsemi/android/dfu/ZipHexInputStream.java
+++ b/dfu/src/main/java/no/nordicsemi/android/dfu/ZipHexInputStream.java
@@ -1,3 +1,25 @@
+/*************************************************************************************************************************************************
+ * Copyright (c) 2015, Nordic Semiconductor
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ ************************************************************************************************************************************************/
+
package no.nordicsemi.android.dfu;
import java.io.ByteArrayOutputStream;
diff --git a/dfu/src/main/java/no/nordicsemi/android/dfu/exception/DeviceDisconnectedException.java b/dfu/src/main/java/no/nordicsemi/android/dfu/exception/DeviceDisconnectedException.java
index b24f89d..f19d14c 100644
--- a/dfu/src/main/java/no/nordicsemi/android/dfu/exception/DeviceDisconnectedException.java
+++ b/dfu/src/main/java/no/nordicsemi/android/dfu/exception/DeviceDisconnectedException.java
@@ -1,11 +1,25 @@
-/*******************************************************************************
- * Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved.
- *
- * The information contained herein is property of Nordic Semiconductor ASA.
- * Terms and conditions of usage are described in detail in NORDIC SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
- * Licensees are granted free, non-transferable use of the information. NO WARRANTY of ANY KIND is provided.
- * This heading must NOT be removed from the file.
- ******************************************************************************/
+/*************************************************************************************************************************************************
+ * Copyright (c) 2015, Nordic Semiconductor
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ ************************************************************************************************************************************************/
+
package no.nordicsemi.android.dfu.exception;
public class DeviceDisconnectedException extends Exception {
diff --git a/dfu/src/main/java/no/nordicsemi/android/dfu/exception/DfuException.java b/dfu/src/main/java/no/nordicsemi/android/dfu/exception/DfuException.java
index a1caab5..1d51b42 100644
--- a/dfu/src/main/java/no/nordicsemi/android/dfu/exception/DfuException.java
+++ b/dfu/src/main/java/no/nordicsemi/android/dfu/exception/DfuException.java
@@ -1,11 +1,25 @@
-/*******************************************************************************
- * Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved.
- *
- * The information contained herein is property of Nordic Semiconductor ASA.
- * Terms and conditions of usage are described in detail in NORDIC SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
- * Licensees are granted free, non-transferable use of the information. NO WARRANTY of ANY KIND is provided.
- * This heading must NOT be removed from the file.
- ******************************************************************************/
+/*************************************************************************************************************************************************
+ * Copyright (c) 2015, Nordic Semiconductor
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ ************************************************************************************************************************************************/
+
package no.nordicsemi.android.dfu.exception;
import no.nordicsemi.android.dfu.DfuBaseService;
diff --git a/dfu/src/main/java/no/nordicsemi/android/dfu/exception/HexFileValidationException.java b/dfu/src/main/java/no/nordicsemi/android/dfu/exception/HexFileValidationException.java
index 04305c4..e389268 100644
--- a/dfu/src/main/java/no/nordicsemi/android/dfu/exception/HexFileValidationException.java
+++ b/dfu/src/main/java/no/nordicsemi/android/dfu/exception/HexFileValidationException.java
@@ -1,11 +1,25 @@
-/*******************************************************************************
- * Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved.
- *
- * The information contained herein is property of Nordic Semiconductor ASA.
- * Terms and conditions of usage are described in detail in NORDIC SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
- * Licensees are granted free, non-transferable use of the information. NO WARRANTY of ANY KIND is provided.
- * This heading must NOT be removed from the file.
- ******************************************************************************/
+/*************************************************************************************************************************************************
+ * Copyright (c) 2015, Nordic Semiconductor
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ ************************************************************************************************************************************************/
+
package no.nordicsemi.android.dfu.exception;
import java.io.IOException;
diff --git a/dfu/src/main/java/no/nordicsemi/android/dfu/exception/RemoteDfuException.java b/dfu/src/main/java/no/nordicsemi/android/dfu/exception/RemoteDfuException.java
index 50edbca..fe5ed67 100644
--- a/dfu/src/main/java/no/nordicsemi/android/dfu/exception/RemoteDfuException.java
+++ b/dfu/src/main/java/no/nordicsemi/android/dfu/exception/RemoteDfuException.java
@@ -1,11 +1,25 @@
-/*******************************************************************************
- * Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved.
- *
- * The information contained herein is property of Nordic Semiconductor ASA.
- * Terms and conditions of usage are described in detail in NORDIC SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
- * Licensees are granted free, non-transferable use of the information. NO WARRANTY of ANY KIND is provided.
- * This heading must NOT be removed from the file.
- ******************************************************************************/
+/*************************************************************************************************************************************************
+ * Copyright (c) 2015, Nordic Semiconductor
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ ************************************************************************************************************************************************/
+
package no.nordicsemi.android.dfu.exception;
public class RemoteDfuException extends Exception {
diff --git a/dfu/src/main/java/no/nordicsemi/android/dfu/exception/UnknownResponseException.java b/dfu/src/main/java/no/nordicsemi/android/dfu/exception/UnknownResponseException.java
index 28a59bd..813db50 100644
--- a/dfu/src/main/java/no/nordicsemi/android/dfu/exception/UnknownResponseException.java
+++ b/dfu/src/main/java/no/nordicsemi/android/dfu/exception/UnknownResponseException.java
@@ -1,11 +1,25 @@
-/*******************************************************************************
- * Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved.
- *
- * The information contained herein is property of Nordic Semiconductor ASA.
- * Terms and conditions of usage are described in detail in NORDIC SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
- * Licensees are granted free, non-transferable use of the information. NO WARRANTY of ANY KIND is provided.
- * This heading must NOT be removed from the file.
- ******************************************************************************/
+/*************************************************************************************************************************************************
+ * Copyright (c) 2015, Nordic Semiconductor
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ ************************************************************************************************************************************************/
+
package no.nordicsemi.android.dfu.exception;
public class UnknownResponseException extends Exception {
diff --git a/dfu/src/main/java/no/nordicsemi/android/dfu/exception/UploadAbortedException.java b/dfu/src/main/java/no/nordicsemi/android/dfu/exception/UploadAbortedException.java
index 7c482a1..8f3a02b 100644
--- a/dfu/src/main/java/no/nordicsemi/android/dfu/exception/UploadAbortedException.java
+++ b/dfu/src/main/java/no/nordicsemi/android/dfu/exception/UploadAbortedException.java
@@ -1,11 +1,25 @@
-/*******************************************************************************
- * Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved.
- *
- * The information contained herein is property of Nordic Semiconductor ASA.
- * Terms and conditions of usage are described in detail in NORDIC SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
- * Licensees are granted free, non-transferable use of the information. NO WARRANTY of ANY KIND is provided.
- * This heading must NOT be removed from the file.
- ******************************************************************************/
+/*************************************************************************************************************************************************
+ * Copyright (c) 2015, Nordic Semiconductor
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ ************************************************************************************************************************************************/
+
package no.nordicsemi.android.dfu.exception;
public class UploadAbortedException extends Exception {
diff --git a/dfu/src/main/java/no/nordicsemi/android/error/GattError.java b/dfu/src/main/java/no/nordicsemi/android/error/GattError.java
index 47d438c..9082711 100644
--- a/dfu/src/main/java/no/nordicsemi/android/error/GattError.java
+++ b/dfu/src/main/java/no/nordicsemi/android/error/GattError.java
@@ -1,11 +1,25 @@
-/*******************************************************************************
- * Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved.
+/*************************************************************************************************************************************************
+ * Copyright (c) 2015, Nordic Semiconductor
+ * All rights reserved.
*
- * The information contained herein is property of Nordic Semiconductor ASA.
- * Terms and conditions of usage are described in detail in NORDIC SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
- * Licensees are granted free, non-transferable use of the information. NO WARRANTY of ANY KIND is provided.
- * This heading must NOT be removed from the file.
- ******************************************************************************/
+ * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ ************************************************************************************************************************************************/
+
package no.nordicsemi.android.error;
import no.nordicsemi.android.dfu.DfuBaseService;