public abstract class DfuBaseService
extends android.app.IntentService
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.
The DfuServiceInitiator
object should be used to start the DFU Service.
final DfuServiceInitiator starter = new DfuServiceInitiator(mSelectedDevice.getAddress()) .setDeviceName(mSelectedDevice.getName()) .setKeepBond(keepBond) .setZip(mFileStreamUri, mFilePath) .start(this, DfuService.class);
You may register the progress and log listeners using the DfuServiceListenerHelper
helper class. See DfuProgressListener
and DfuLogListener
for
more information.
The service will show its progress on the notification bar and will send local broadcasts to the application.
Modifier and Type | Field and Description |
---|---|
static int |
ACTION_ABORT
Aborts the upload.
|
static int |
ACTION_PAUSE
Pauses the upload.
|
static int |
ACTION_RESUME
Resumes the upload that has been paused before using
ACTION_PAUSE . |
static java.lang.String |
BROADCAST_ACTION
Activity may broadcast this broadcast in order to pause, resume or abort DFU process.
|
static java.lang.String |
BROADCAST_ERROR
The broadcast error message contains the following extras:
EXTRA_DATA - the error number. |
static java.lang.String |
BROADCAST_LOG
The log events are only broadcast when there is no nRF Logger installed.
|
static java.lang.String |
BROADCAST_PROGRESS
The broadcast message contains the following extras:
EXTRA_DATA - the progress value (percentage 0-100) or:
PROGRESS_CONNECTING
PROGRESS_STARTING
PROGRESS_ENABLING_DFU_MODE
PROGRESS_VALIDATING
PROGRESS_DISCONNECTING
PROGRESS_COMPLETED
PROGRESS_ABORTED
EXTRA_DEVICE_ADDRESS - the target device address
EXTRA_PART_CURRENT - the number of currently transmitted part
EXTRA_PARTS_TOTAL - total number of parts that are being sent, f.e. |
static int |
DFU_STATUS_CRC_ERROR
Deprecated.
|
static int |
DFU_STATUS_DATA_SIZE_EXCEEDS_LIMIT
Deprecated.
|
static int |
DFU_STATUS_INVALID_STATE
Deprecated.
|
static int |
DFU_STATUS_NOT_SUPPORTED
Deprecated.
|
static int |
DFU_STATUS_OPERATION_FAILED
Deprecated.
|
static int |
DFU_STATUS_SUCCESS
Deprecated.
|
static int |
ERROR_BLUETOOTH_DISABLED
Thrown when the the Bluetooth adapter is disabled.
|
static int |
ERROR_CHARACTERISTICS_NOT_FOUND
Thrown when the required DFU service has been found but at least one of the DFU characteristics is absent.
|
static int |
ERROR_CONNECTION_MASK
The flag set when one of
BluetoothGattCallback methods was called with status other than BluetoothGatt.GATT_SUCCESS . |
static int |
ERROR_CONNECTION_STATE_MASK
The flag set when the
BluetoothGattCallback.onConnectionStateChange(android.bluetooth.BluetoothGatt, int, int) method was called with
status other than BluetoothGatt.GATT_SUCCESS . |
static int |
ERROR_CRC_ERROR
Thrown when the received CRC does not match with the calculated one.
|
static int |
ERROR_DEVICE_DISCONNECTED |
static int |
ERROR_FILE_ERROR
Thrown if service was unable to open the file (
IOException has been thrown). |
static int |
ERROR_FILE_INVALID
Thrown when input file is not a valid HEX or ZIP file.
|
static int |
ERROR_FILE_IO_EXCEPTION
Thrown when
IOException occurred when reading from file. |
static int |
ERROR_FILE_NOT_FOUND |
static int |
ERROR_FILE_SIZE_INVALID
Thrown when the firmware file is not word-aligned.
|
static int |
ERROR_FILE_TYPE_UNSUPPORTED
Thrown when the the service does not support given type or mime-type.
|
static int |
ERROR_INIT_PACKET_REQUIRED
DFU Bootloader version 0.6+ requires sending the Init packet.
|
static int |
ERROR_INVALID_RESPONSE
Thrown when unknown response has been obtained from the target.
|
static int |
ERROR_MASK
If this bit is set than the progress value indicates an error.
|
static int |
ERROR_REMOTE_MASK
Flag set when the DFU target returned a DFU error.
|
static int |
ERROR_SERVICE_DISCOVERY_NOT_STARTED
Error thrown when
gatt.discoverServices(); returns false. |
static int |
ERROR_SERVICE_NOT_FOUND
Thrown when the service discovery has finished but the DFU service has not been found.
|
static int |
ERROR_TYPE_COMMUNICATION |
static int |
ERROR_TYPE_COMMUNICATION_STATE |
static int |
ERROR_TYPE_DFU_REMOTE |
static int |
ERROR_TYPE_OTHER |
static java.lang.String |
EXTRA_ACTION
The action extra.
|
static java.lang.String |
EXTRA_AVG_SPEED_B_PER_MS
The average upload speed in bytes/millisecond for the current part.
|
static java.lang.String |
EXTRA_DATA
An extra field with progress and error information used in broadcast events.
|
static java.lang.String |
EXTRA_DEVICE_ADDRESS
The address of the device to update.
|
static java.lang.String |
EXTRA_DEVICE_NAME
The optional device name.
|
static java.lang.String |
EXTRA_DISABLE_NOTIFICATION
A boolean indicating whether to disable the progress notification in the status bar.
|
static java.lang.String |
EXTRA_ERROR_TYPE
The type of the error.
|
static java.lang.String |
EXTRA_FILE_MIME_TYPE
The input file mime-type.
|
static java.lang.String |
EXTRA_FILE_PATH
A path to the file with the new firmware.
|
static java.lang.String |
EXTRA_FILE_RES_ID
See
EXTRA_FILE_PATH for details. |
static java.lang.String |
EXTRA_FILE_TYPE
This optional extra parameter may contain a file type.
|
static java.lang.String |
EXTRA_FILE_URI
See
EXTRA_FILE_PATH for details. |
static java.lang.String |
EXTRA_INIT_FILE_PATH
The Init packet URI.
|
static java.lang.String |
EXTRA_INIT_FILE_RES_ID
The Init packet URI.
|
static java.lang.String |
EXTRA_INIT_FILE_URI
The Init packet URI.
|
static java.lang.String |
EXTRA_KEEP_BOND
This flag indicated whether the bond information should be kept or removed after an upgrade of the Application.
|
static java.lang.String |
EXTRA_LOG_LEVEL |
static java.lang.String |
EXTRA_LOG_MESSAGE |
static java.lang.String |
EXTRA_PART_CURRENT
The number of currently transferred part.
|
static java.lang.String |
EXTRA_PARTS_TOTAL
Number of parts in total.
|
static java.lang.String |
EXTRA_PROGRESS
An extra field to send the progress or error information in the DFU notification.
|
static java.lang.String |
EXTRA_RESTORE_BOND
If the new firmware (application) does not share the bond information with the old one, the bond information is lost.
|
static java.lang.String |
EXTRA_SPEED_B_PER_MS
The current upload speed in bytes/millisecond.
|
static int |
LOG_LEVEL_APPLICATION
Log entries level for applications
|
static int |
LOG_LEVEL_DEBUG
Level used just for debugging purposes.
|
static int |
LOG_LEVEL_ERROR
Log entries with very high importance, like errors
|
static int |
LOG_LEVEL_INFO
Default logging level for important entries
|
static int |
LOG_LEVEL_VERBOSE
Log entries with minor importance
|
static int |
LOG_LEVEL_WARNING
Log entries with high importance
|
protected int |
mConnectionState
The current connection state.
|
static java.lang.String |
MIME_TYPE_OCTET_STREAM |
static java.lang.String |
MIME_TYPE_ZIP |
static int |
NOTIFICATION_ID |
static int |
PROGRESS_ABORTED
The upload has been aborted.
|
static int |
PROGRESS_COMPLETED
The connection is successful.
|
static int |
PROGRESS_CONNECTING
Service is connecting to the remote DFU target.
|
static int |
PROGRESS_DISCONNECTING
Service is disconnecting from the DFU target.
|
static int |
PROGRESS_ENABLING_DFU_MODE
Service has triggered a switch to bootloader mode.
|
static int |
PROGRESS_STARTING
Service is enabling notifications and starting transmission.
|
static int |
PROGRESS_VALIDATING
Service is sending validation request to the remote DFU target.
|
protected static int |
STATE_CLOSED |
protected static int |
STATE_CONNECTED |
protected static int |
STATE_CONNECTED_AND_READY |
protected static int |
STATE_CONNECTING |
protected static int |
STATE_DISCONNECTED |
protected static int |
STATE_DISCONNECTING |
static int |
TYPE_APPLICATION
The file contains a new version of Application.
|
static int |
TYPE_AUTO
A ZIP file that consists of more than 1 file.
|
static int |
TYPE_BOOTLOADER
The file contains a new version of Bootloader.
|
static int |
TYPE_SOFT_DEVICE
The file contains a new version of Soft Device.
|
START_CONTINUATION_MASK, START_FLAG_REDELIVERY, START_FLAG_RETRY, START_NOT_STICKY, START_REDELIVER_INTENT, START_STICKY, START_STICKY_COMPATIBILITY, STOP_FOREGROUND_DETACH, STOP_FOREGROUND_REMOVE
ACCESSIBILITY_SERVICE, ACCOUNT_SERVICE, ACTIVITY_SERVICE, ALARM_SERVICE, APP_OPS_SERVICE, APPWIDGET_SERVICE, AUDIO_SERVICE, BATTERY_SERVICE, BIND_ABOVE_CLIENT, BIND_ADJUST_WITH_ACTIVITY, BIND_ALLOW_OOM_MANAGEMENT, BIND_AUTO_CREATE, BIND_DEBUG_UNBIND, BIND_EXTERNAL_SERVICE, BIND_IMPORTANT, BIND_NOT_FOREGROUND, BIND_WAIVE_PRIORITY, BLUETOOTH_SERVICE, CAMERA_SERVICE, CAPTIONING_SERVICE, CARRIER_CONFIG_SERVICE, CLIPBOARD_SERVICE, CONNECTIVITY_SERVICE, CONSUMER_IR_SERVICE, CONTEXT_IGNORE_SECURITY, CONTEXT_INCLUDE_CODE, CONTEXT_RESTRICTED, DEVICE_POLICY_SERVICE, DISPLAY_SERVICE, DOWNLOAD_SERVICE, DROPBOX_SERVICE, FINGERPRINT_SERVICE, HARDWARE_PROPERTIES_SERVICE, INPUT_METHOD_SERVICE, INPUT_SERVICE, JOB_SCHEDULER_SERVICE, KEYGUARD_SERVICE, LAUNCHER_APPS_SERVICE, LAYOUT_INFLATER_SERVICE, LOCATION_SERVICE, MEDIA_PROJECTION_SERVICE, MEDIA_ROUTER_SERVICE, MEDIA_SESSION_SERVICE, MIDI_SERVICE, MODE_APPEND, MODE_ENABLE_WRITE_AHEAD_LOGGING, MODE_MULTI_PROCESS, MODE_NO_LOCALIZED_COLLATORS, MODE_PRIVATE, MODE_WORLD_READABLE, MODE_WORLD_WRITEABLE, NETWORK_STATS_SERVICE, NFC_SERVICE, NOTIFICATION_SERVICE, NSD_SERVICE, POWER_SERVICE, PRINT_SERVICE, RESTRICTIONS_SERVICE, SEARCH_SERVICE, SENSOR_SERVICE, STORAGE_SERVICE, SYSTEM_HEALTH_SERVICE, TELECOM_SERVICE, TELEPHONY_SERVICE, TELEPHONY_SUBSCRIPTION_SERVICE, TEXT_SERVICES_MANAGER_SERVICE, TV_INPUT_SERVICE, UI_MODE_SERVICE, USAGE_STATS_SERVICE, USB_SERVICE, USER_SERVICE, VIBRATOR_SERVICE, WALLPAPER_SERVICE, WIFI_P2P_SERVICE, WIFI_SERVICE, WINDOW_SERVICE
Constructor and Description |
---|
DfuBaseService() |
Modifier and Type | Method and Description |
---|---|
protected void |
close(android.bluetooth.BluetoothGatt gatt)
Closes the GATT device and cleans up.
|
protected android.bluetooth.BluetoothGatt |
connect(java.lang.String address)
Connects to the BLE device with given address.
|
protected void |
disconnect(android.bluetooth.BluetoothGatt gatt)
Disconnects from the device.
|
protected abstract java.lang.Class<? extends android.app.Activity> |
getNotificationTarget()
This method must return the activity class that will be used to create the pending intent used as a content intent in the notification showing the upload progress.
|
void |
onCreate() |
void |
onDestroy() |
protected void |
onHandleIntent(android.content.Intent intent) |
protected void |
refreshDeviceCache(android.bluetooth.BluetoothGatt gatt,
boolean force)
Clears the device cache.
|
protected void |
terminateConnection(android.bluetooth.BluetoothGatt gatt,
int error)
Disconnects from the device and cleans local variables in case of error.
|
void |
updateProgressNotification()
Creates or updates the notification in the Notification Manager.
|
protected void |
waitFor(int millis)
Wait for given number of milliseconds.
|
protected void |
waitUntilDisconnected()
Wait until the connection state will change to
STATE_DISCONNECTED or until an error occurs. |
onBind, onStart, onStartCommand, setIntentRedelivery
dump, getApplication, onConfigurationChanged, onLowMemory, onRebind, onTaskRemoved, onTrimMemory, onUnbind, startForeground, stopForeground, stopForeground, stopSelf, stopSelf, stopSelfResult
attachBaseContext, bindService, checkCallingOrSelfPermission, checkCallingOrSelfUriPermission, checkCallingPermission, checkCallingUriPermission, checkPermission, checkSelfPermission, checkUriPermission, checkUriPermission, clearWallpaper, createConfigurationContext, createDeviceProtectedStorageContext, createDisplayContext, createPackageContext, databaseList, deleteDatabase, deleteFile, deleteSharedPreferences, enforceCallingOrSelfPermission, enforceCallingOrSelfUriPermission, enforceCallingPermission, enforceCallingUriPermission, enforcePermission, enforceUriPermission, enforceUriPermission, fileList, getApplicationContext, getApplicationInfo, getAssets, getBaseContext, getCacheDir, getClassLoader, getCodeCacheDir, getContentResolver, getDatabasePath, getDataDir, getDir, getExternalCacheDir, getExternalCacheDirs, getExternalFilesDir, getExternalFilesDirs, getExternalMediaDirs, getFilesDir, getFileStreamPath, getMainLooper, getNoBackupFilesDir, getObbDir, getObbDirs, getPackageCodePath, getPackageManager, getPackageName, getPackageResourcePath, getResources, getSharedPreferences, getSystemService, getSystemServiceName, getTheme, getWallpaper, getWallpaperDesiredMinimumHeight, getWallpaperDesiredMinimumWidth, grantUriPermission, isDeviceProtectedStorage, isRestricted, moveDatabaseFrom, moveSharedPreferencesFrom, openFileInput, openFileOutput, openOrCreateDatabase, openOrCreateDatabase, peekWallpaper, registerReceiver, registerReceiver, removeStickyBroadcast, removeStickyBroadcastAsUser, revokeUriPermission, sendBroadcast, sendBroadcast, sendBroadcastAsUser, sendBroadcastAsUser, sendOrderedBroadcast, sendOrderedBroadcast, sendOrderedBroadcastAsUser, sendStickyBroadcast, sendStickyBroadcastAsUser, sendStickyOrderedBroadcast, sendStickyOrderedBroadcastAsUser, setTheme, setWallpaper, setWallpaper, startActivities, startActivities, startActivity, startActivity, startInstrumentation, startIntentSender, startIntentSender, startService, stopService, unbindService, unregisterReceiver
public static final int NOTIFICATION_ID
public static final java.lang.String EXTRA_DEVICE_ADDRESS
public static final java.lang.String EXTRA_DEVICE_NAME
public static final java.lang.String EXTRA_DISABLE_NOTIFICATION
public static final java.lang.String EXTRA_RESTORE_BOND
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 the application is always removed together with the bond information.
Search for occurrences of EXTRA_RESTORE_BOND in this file to check the implementation and get more details.
public static final java.lang.String EXTRA_KEEP_BOND
This flag indicated whether the bond information should be kept or removed after an upgrade of the Application.
If an application is being updated on a bonded device with the DFU Bootloader that has been configured to preserve the bond information for the new application,
set it to true
.
By default the DFU Bootloader clears the whole application's memory. It may be however configured in the \Nordic\nrf51\components\libraries\bootloader_dfu\dfu_types.h
file (sdk 11, line 76: #define DFU_APP_DATA_RESERVED 0x0000
) to preserve some pages. The BLE_APP_HRM_DFU sample app stores the LTK and System Attributes in the first
two pages, so in order to preserve the bond information this value should be changed to 0x0800 or more.
When those data are preserved, the new Application will notify the app with the Service Changed indication when launched for the first time. Otherwise this
service will remove the bond information from the phone and force to refresh the device cache (see refreshDeviceCache(android.bluetooth.BluetoothGatt, boolean)
).
In contrast to EXTRA_RESTORE_BOND
this flag will not remove the old bonding and recreate a new one, but will keep the bond information untouched.
The default value of this flag is false
public static final java.lang.String EXTRA_FILE_PATH
EXTRA_FILE_URI
in the later case.
For files included in /res/raw resource directory please use EXTRA_FILE_RES_ID
instead.public static final java.lang.String EXTRA_FILE_URI
EXTRA_FILE_PATH
for details.public static final java.lang.String EXTRA_FILE_RES_ID
EXTRA_FILE_PATH
for details.public static final java.lang.String EXTRA_INIT_FILE_PATH
public static final java.lang.String EXTRA_INIT_FILE_URI
public static final java.lang.String EXTRA_INIT_FILE_RES_ID
public static final java.lang.String EXTRA_FILE_MIME_TYPE
public static final java.lang.String MIME_TYPE_OCTET_STREAM
public static final java.lang.String MIME_TYPE_ZIP
public static final java.lang.String EXTRA_FILE_TYPE
TYPE_SOFT_DEVICE
- only Soft Device updateTYPE_BOOTLOADER
- only Bootloader updateTYPE_APPLICATION
- only application updateTYPE_AUTO
- the file is a ZIP file that may contain more than one HEX/BIN + DAT files. Since SDK 8.0 the ZIP Distribution packet is a recommended
way of delivering firmware files. Please, see the DFU documentation for more details. A ZIP distribution packet may be created using the 'nrf utility'
command line application, that is a part of Master Control Panel 3.8.0.The ZIP file MAY contain only the following files:
softdevice.hex/bin, bootloader.hex/bin, application.hex/bin to determine the type based on its name. At lease one of them MUST be present.
EXTRA_FILE_MIME_TYPE
field is null
or is equal to "application/octet-stream" - the TYPE_APPLICATION
is assumed.EXTRA_FILE_MIME_TYPE
field is equal to "application/zip" - the TYPE_AUTO
is assumed.public static final int TYPE_SOFT_DEVICE
The file contains a new version of Soft Device.
Since DFU Library 7.0 all firmware may contain an Init packet. The Init packet is required if Extended Init Packet is used by the DFU bootloader (SDK 7.0+).. The Init packet for the bootloader must be placed in the .dat file.
EXTRA_FILE_TYPE
,
Constant Field Valuespublic static final int TYPE_BOOTLOADER
The file contains a new version of Bootloader.
Since DFU Library 7.0 all firmware may contain an Init packet. The Init packet is required if Extended Init Packet is used by the DFU bootloader (SDK 7.0+). The Init packet for the bootloader must be placed in the .dat file.
EXTRA_FILE_TYPE
,
Constant Field Valuespublic static final int TYPE_APPLICATION
The file contains a new version of Application.
Since DFU Library 0.5 all firmware may contain an Init packet. The Init packet is required if Extended Init Packet is used by the DFU bootloader (SDK 7.0+). The Init packet for the application must be placed in the .dat file.
EXTRA_FILE_TYPE
,
Constant Field Valuespublic static final int TYPE_AUTO
A ZIP file that consists of more than 1 file. Since SDK 8.0 the ZIP Distribution packet is a recommended way of delivering firmware files. Please, see the DFU documentation for more details. A ZIP distribution packet may be created using the 'nrf utility' command line application, that is a part of Master Control Panel 3.8.0. For backwards compatibility this library supports also ZIP files without the manifest file. Instead they must follow the fixed naming convention: The names of files in the ZIP must be: softdevice.hex (or .bin), bootloader.hex (or .bin), application.hex (or .bin) in order to be read correctly. Using the Soft Device v7.0.0+ the Soft Device and Bootloader may be updated and sent together. In case of additional application file included, the service will try to send Soft Device, Bootloader and Application together (which is not supported currently) and if it fails, send first SD+BL, reconnect and send the application in the following connection.
Since the DFU Library 0.5 you may specify the Init packet, that will be send prior to the firmware. The init packet contains some verification data, like a device type and revision, application version or a list of supported Soft Devices. The Init packet is required if Extended Init Packet is used by the DFU bootloader (SDK 7.0+). In case of using the compatibility ZIP files the Init packet for the Soft Device and Bootloader must be in the 'system.dat' file while for the application in the 'application.dat' file (included in the ZIP). The CRC in the 'system.dat' must be a CRC of both BIN contents if both a Soft Device and a Bootloader is present.
EXTRA_FILE_TYPE
,
Constant Field Valuespublic static final java.lang.String EXTRA_DATA
public static final java.lang.String EXTRA_PROGRESS
ERROR_MASK
if initialization error occurredERROR_REMOTE_MASK
if remote DFU target returned an errorERROR_CONNECTION_MASK
if connection error occurred (f.e. GATT error (133) or Internal GATT Error (129))boolean error = progressValue >= DfuBaseService.ERROR_MASK;
public static final java.lang.String EXTRA_PART_CURRENT
EXTRA_PARTS_TOTAL
,
Constant Field Valuespublic static final java.lang.String EXTRA_PARTS_TOTAL
EXTRA_PART_CURRENT
,
Constant Field Valuespublic static final java.lang.String EXTRA_SPEED_B_PER_MS
public static final java.lang.String EXTRA_AVG_SPEED_B_PER_MS
public static final java.lang.String BROADCAST_PROGRESS
EXTRA_DATA
- the progress value (percentage 0-100) or:
EXTRA_DEVICE_ADDRESS
- the target device addressEXTRA_PART_CURRENT
- the number of currently transmitted partEXTRA_PARTS_TOTAL
- total number of parts that are being sent, f.e. if a ZIP file contains a Soft Device, a Bootloader and an Application,
the SoftDevice and Bootloader will be send together as one part. Then the service will disconnect and reconnect to the new Bootloader and send the
application as part number two.EXTRA_SPEED_B_PER_MS
- current speed in bytes/millisecond as floatEXTRA_AVG_SPEED_B_PER_MS
- the average transmission speed in bytes/millisecond as floatpublic static final int PROGRESS_CONNECTING
public static final int PROGRESS_STARTING
public static final int PROGRESS_ENABLING_DFU_MODE
public static final int PROGRESS_VALIDATING
public static final int PROGRESS_DISCONNECTING
public static final int PROGRESS_COMPLETED
public static final int PROGRESS_ABORTED
public static final java.lang.String BROADCAST_ERROR
EXTRA_DATA
- the error number. Use GattError.parse(int)
to get String representationEXTRA_DEVICE_ADDRESS
- the target device addresspublic static final java.lang.String EXTRA_ERROR_TYPE
BluetoothGattCallback.onCharacteristicWrite(BluetoothGatt, BluetoothGattCharacteristic, int)
method may return a status code 8 (GATT INSUF AUTHORIZATION),
while the status code 8 returned by BluetoothGattCallback.onConnectionStateChange(BluetoothGatt, int, int)
is a GATT CONN TIMEOUT error.public static final int ERROR_TYPE_OTHER
public static final int ERROR_TYPE_COMMUNICATION_STATE
public static final int ERROR_TYPE_COMMUNICATION
public static final int ERROR_TYPE_DFU_REMOTE
public static final int ERROR_MASK
GattError.parse(int)
to obtain error name.public static final int ERROR_DEVICE_DISCONNECTED
public static final int ERROR_FILE_NOT_FOUND
public static final int ERROR_FILE_ERROR
IOException
has been thrown).public static final int ERROR_FILE_INVALID
public static final int ERROR_FILE_IO_EXCEPTION
IOException
occurred when reading from file.public static final int ERROR_SERVICE_DISCOVERY_NOT_STARTED
gatt.discoverServices();
returns false.public static final int ERROR_SERVICE_NOT_FOUND
public static final int ERROR_CHARACTERISTICS_NOT_FOUND
public static final int ERROR_INVALID_RESPONSE
public static final int ERROR_FILE_TYPE_UNSUPPORTED
public static final int ERROR_BLUETOOTH_DISABLED
public static final int ERROR_INIT_PACKET_REQUIRED
public static final int ERROR_FILE_SIZE_INVALID
public static final int ERROR_CRC_ERROR
public static final int ERROR_REMOTE_MASK
public static final int ERROR_CONNECTION_MASK
BluetoothGattCallback
methods was called with status other than BluetoothGatt.GATT_SUCCESS
.public static final int ERROR_CONNECTION_STATE_MASK
BluetoothGattCallback.onConnectionStateChange(android.bluetooth.BluetoothGatt, int, int)
method was called with
status other than BluetoothGatt.GATT_SUCCESS
.public static final java.lang.String BROADCAST_LOG
EXTRA_LOG_LEVEL
- The log level, one of following: LOG_LEVEL_DEBUG
, LOG_LEVEL_VERBOSE
, LOG_LEVEL_INFO
,
LOG_LEVEL_APPLICATION
, LOG_LEVEL_WARNING
, LOG_LEVEL_ERROR
EXTRA_LOG_MESSAGE
- The log messagepublic static final java.lang.String EXTRA_LOG_MESSAGE
public static final java.lang.String EXTRA_LOG_LEVEL
public static final int LOG_LEVEL_DEBUG
public static final int LOG_LEVEL_VERBOSE
public static final int LOG_LEVEL_INFO
public static final int LOG_LEVEL_APPLICATION
public static final int LOG_LEVEL_WARNING
public static final int LOG_LEVEL_ERROR
public static final java.lang.String BROADCAST_ACTION
EXTRA_ACTION
extra to pass the action.public static final java.lang.String EXTRA_ACTION
ACTION_PAUSE
, ACTION_RESUME
, ACTION_ABORT
.public static final int ACTION_PAUSE
ACTION_RESUME
or ACTION_ABORT
.public static final int ACTION_RESUME
ACTION_PAUSE
.public static final int ACTION_ABORT
BROADCAST_ACTION
with extra EXTRA_ACTION
set to this value the DFU bootloader will restore the old application
(if there was already an application). Be aware that uploading the Soft Device will erase the application in order to make space in the memory.
In case there is no application, or the application has been removed, the DFU bootloader will be started and user may try to send the application again.
The bootloader may advertise with the address incremented by 1 to prevent caching services.@Deprecated public static final int DFU_STATUS_SUCCESS
@Deprecated public static final int DFU_STATUS_INVALID_STATE
@Deprecated public static final int DFU_STATUS_NOT_SUPPORTED
@Deprecated public static final int DFU_STATUS_DATA_SIZE_EXCEEDS_LIMIT
@Deprecated public static final int DFU_STATUS_CRC_ERROR
@Deprecated public static final int DFU_STATUS_OPERATION_FAILED
protected int mConnectionState
protected static final int STATE_DISCONNECTED
protected static final int STATE_CONNECTING
protected static final int STATE_CONNECTED
protected static final int STATE_CONNECTED_AND_READY
protected static final int STATE_DISCONNECTING
protected static final int STATE_CLOSED
public void onCreate()
onCreate
in class android.app.IntentService
public void onDestroy()
onDestroy
in class android.app.IntentService
protected void onHandleIntent(android.content.Intent intent)
onHandleIntent
in class android.app.IntentService
protected android.bluetooth.BluetoothGatt connect(java.lang.String address)
STATE_CONNECTING
to STATE_CONNECTED_AND_READY
or an
error occurs. This method returns null
if Bluetooth adapter is disabled.address
- the device addressnull
if Bluetooth adapter is disabled.protected void terminateConnection(android.bluetooth.BluetoothGatt gatt, int error)
gatt
- the GATT device to be disconnectederror
- error numberprotected void disconnect(android.bluetooth.BluetoothGatt gatt)
terminateConnection(android.bluetooth.BluetoothGatt, int)
instead.gatt
- the GATT device that has to be disconnectedprotected void waitUntilDisconnected()
STATE_DISCONNECTED
or until an error occurs.protected void waitFor(int millis)
millis
- waiting periodprotected void close(android.bluetooth.BluetoothGatt gatt)
gatt
- the GATT device to be closedprotected void refreshDeviceCache(android.bluetooth.BluetoothGatt gatt, boolean force)
gatt
- the GATT device to be refreshedforce
- true
to force the refreshpublic void updateProgressNotification()
protected abstract java.lang.Class<? extends android.app.Activity> getNotificationTarget()
Intent.FLAG_ACTIVITY_NEW_TASK
flag and the following extras:
EXTRA_DEVICE_ADDRESS
- target device addressEXTRA_DEVICE_NAME
- target device nameEXTRA_PROGRESS
- the connection state (values < 0)*, current progress (0-100) or error number if ERROR_MASK
bit set.