More documentation added.
This commit is contained in:
parent
ad79ce7f02
commit
1ef13dc712
|
@ -57,10 +57,11 @@ import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.security.InvalidParameterException;
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import no.nordicsemi.android.dfu.internal.ArchiveInputStream;
|
||||||
|
import no.nordicsemi.android.dfu.internal.HexInputStream;
|
||||||
import no.nordicsemi.android.dfu.internal.exception.DeviceDisconnectedException;
|
import no.nordicsemi.android.dfu.internal.exception.DeviceDisconnectedException;
|
||||||
import no.nordicsemi.android.dfu.internal.exception.DfuException;
|
import no.nordicsemi.android.dfu.internal.exception.DfuException;
|
||||||
import no.nordicsemi.android.dfu.internal.exception.HexFileValidationException;
|
import no.nordicsemi.android.dfu.internal.exception.HexFileValidationException;
|
||||||
|
@ -68,8 +69,6 @@ import no.nordicsemi.android.dfu.internal.exception.RemoteDfuException;
|
||||||
import no.nordicsemi.android.dfu.internal.exception.UnknownResponseException;
|
import no.nordicsemi.android.dfu.internal.exception.UnknownResponseException;
|
||||||
import no.nordicsemi.android.dfu.internal.exception.UploadAbortedException;
|
import no.nordicsemi.android.dfu.internal.exception.UploadAbortedException;
|
||||||
import no.nordicsemi.android.dfu.internal.scanner.BootloaderScannerFactory;
|
import no.nordicsemi.android.dfu.internal.scanner.BootloaderScannerFactory;
|
||||||
import no.nordicsemi.android.dfu.internal.ArchiveInputStream;
|
|
||||||
import no.nordicsemi.android.dfu.internal.HexInputStream;
|
|
||||||
import no.nordicsemi.android.error.GattError;
|
import no.nordicsemi.android.error.GattError;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -79,25 +78,18 @@ import no.nordicsemi.android.error.GattError;
|
||||||
* 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.
|
* 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.
|
||||||
* </p>
|
* </p>
|
||||||
* <p>
|
* <p>
|
||||||
* Start the service with the following parameters:
|
* The {@link DfuServiceInitiator} object should be used to start the DFU Service.
|
||||||
* <p/>
|
* <p/>
|
||||||
* <pre>
|
* <pre>
|
||||||
* final Intent service = new Intent(this, yourClass);
|
* final DfuServiceInitiator starter = new DfuServiceInitiator(mSelectedDevice.getAddress())
|
||||||
* service.putExtra(EXTRA_DEVICE_ADDRESS, mSelectedDevice.getAddress()); // Target device address
|
* .setDeviceName(mSelectedDevice.getName())
|
||||||
* service.putExtra(EXTRA_DEVICE_NAME, mSelectedDevice.getName()); // This name will be shown on the notification
|
* .setKeepBond(keepBond)
|
||||||
* service.putExtra(EXTRA_FILE_MIME_TYPE, mFileType == TYPE_AUTO ? YourMIME_TYPE_ZIP : YourMIME_TYPE_OCTET_STREAM);
|
* .setZip(mFileStreamUri, mFilePath)
|
||||||
* service.putExtra(EXTRA_FILE_TYPE, mFileType);
|
* .start(this, DfuService.class);
|
||||||
* service.putExtra(EXTRA_FILE_PATH, mFilePath);
|
|
||||||
* service.putExtra(EXTRA_FILE_URI, mFileStreamUri);
|
|
||||||
* // optionally
|
|
||||||
* service.putExtra(EXTRA_INIT_FILE_PATH, mInitFilePath);
|
|
||||||
* service.putExtra(EXTRA_INIT_FILE_URI, mInitFileStreamUri);
|
|
||||||
* service.putExtra(EXTRA_RESTORE_BOND, mRestoreBond);
|
|
||||||
* startService(service);
|
|
||||||
* </pre>
|
* </pre>
|
||||||
* <p/>
|
* <p>
|
||||||
* 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.
|
* You may register the progress and log listeners using the {@link DfuServiceListenerHelper} helper class. See {@link DfuProgressListener} and {@link DfuLogListener} for
|
||||||
* The service API is compatible with previous versions.
|
* more information.
|
||||||
* </p>
|
* </p>
|
||||||
* <p>
|
* <p>
|
||||||
* The service will show its progress on the notification 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.
|
||||||
|
|
|
@ -22,6 +22,10 @@
|
||||||
|
|
||||||
package no.nordicsemi.android.dfu;
|
package no.nordicsemi.android.dfu;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Listener for log events. This listener should be used instead of creating the BroadcastReceiver on your own.
|
||||||
|
* @see DfuServiceListenerHelper
|
||||||
|
*/
|
||||||
public interface DfuLogListener {
|
public interface DfuLogListener {
|
||||||
/**
|
/**
|
||||||
* Method called when a log event was sent from the DFU service.
|
* Method called when a log event was sent from the DFU service.
|
||||||
|
|
|
@ -22,6 +22,10 @@
|
||||||
|
|
||||||
package no.nordicsemi.android.dfu;
|
package no.nordicsemi.android.dfu;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Listener for status, progress and error events. This listener should be used instead of creating the BroadcastReceiver on your own.
|
||||||
|
* @see DfuServiceListenerHelper
|
||||||
|
*/
|
||||||
public interface DfuProgressListener {
|
public interface DfuProgressListener {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -33,6 +33,15 @@ import java.util.Map;
|
||||||
|
|
||||||
import no.nordicsemi.android.error.GattError;
|
import no.nordicsemi.android.error.GattError;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A helper class that should be used to register listeners for DFU Service broadcast events.
|
||||||
|
* The {@link DfuProgressListener} should be registered to listen for DFU status updates and errors, while the {@link DfuLogListener} listener receives the log updates.
|
||||||
|
* Listeners may be registered for a specified device (given with device address) or for any device. Keep in mind, that while updating the SoftDevice using the buttonless update
|
||||||
|
* the device may change its address in the bootloader mode.
|
||||||
|
*
|
||||||
|
* <p>Use {@link #registerProgressListener(Context, DfuProgressListener)} or {@link #registerLogListener(Context, DfuLogListener)} to register your listeners. Remember about unregistering them
|
||||||
|
* when your context is destroyed.</p>
|
||||||
|
*/
|
||||||
public class DfuServiceListenerHelper {
|
public class DfuServiceListenerHelper {
|
||||||
private static LogBroadcastReceiver mLogBroadcastReceiver;
|
private static LogBroadcastReceiver mLogBroadcastReceiver;
|
||||||
private static ProgressBroadcastsReceiver mProgressBroadcastReceiver;
|
private static ProgressBroadcastsReceiver mProgressBroadcastReceiver;
|
||||||
|
|
Loading…
Reference in New Issue