code: private int readVersion(final BluetoothGatt gatt, final BluetoothGattCharacteristic characteristic)
              throws DeviceDisconnectedException, DfuException, UploadAbortedException {
  		if (!mConnected)
  			throw new DeviceDisconnectedException("Unable to read version number: device disconnected");
  		if (mAborted)
  			throw new UploadAbortedException();
  		// If the DFU Version characteristic is not available we return 0.
  		if (characteristic == null)
  			return 0;
  
  		mReceivedData = null;
  		mError = 0;
  
  		logi("Reading DFU version number...");
  		mService.sendLogBroadcast(DfuBaseService.LOG_LEVEL_VERBOSE, "Reading DFU version number...");
  
  		characteristic.setValue((byte[]) null);
  		mService.sendLogBroadcast(DfuBaseService.LOG_LEVEL_DEBUG, "gatt.readCharacteristic(" + characteristic.getUuid() + ")");
  		gatt.readCharacteristic(characteristic);
  
  		// We have to wait until device receives a response or an error occur
  		try {
  			synchronized (mLock) {
  				while (((!mRequestCompleted || characteristic.getValue() == null) && mConnected && mError == 0 && !mAborted) || mPaused) {
  					mRequestCompleted = false;
  					mLock.wait();
  				}
  			}
  		} catch (final InterruptedException e) {
  			loge("Sleeping interrupted", e);
  		}
  		if (!mConnected)
  			throw new DeviceDisconnectedException("Unable to read version number: device disconnected");
  		if (mError != 0)
  			throw new DfuException("Unable to read version number", mError);
  
  		// The version is a 16-bit unsigned int
  		return characteristic.getIntValue(BluetoothGattCharacteristic.FORMAT_UINT16, 0);
  	}
docs: Reads the DFU Version characteristic if such exists. Otherwise it returns 0.
  
  @param gatt           the GATT device.
  @param characteristic the characteristic to read.
  @return a version number or 0 if not present on the bootloader.
  @throws DeviceDisconnectedException Thrown when the device will disconnect in the middle of
  the transmission.
  @throws DfuException                Thrown if DFU error occur.
  @throws UploadAbortedException      Thrown if DFU operation was aborted by user.