private void onNotificationBlock(BluetoothGattCharacteristic characteristic){
  int requestedBlock=Convert.twoBytesToInt(characteristic.getValue(),Constants.CC2540_BYTE_ORDER);
  if (requestedBlock == 0) {
    Log.i(TAG,String.format("Image accepted (Name: %s) (Size: %s bytes)",currentImage.name(),currentImage.sizeBytes()));
    blockTransferStarted=System.currentTimeMillis() / 1000L;
    setState(OADState.BLOCK_XFER);
    nextBlock=0;
  }
  while (oadState == OADState.BLOCK_XFER && nextBlock <= currentImage.blockCount() - 1 && nextBlock < (requestedBlock + MAX_IN_AIR_BLOCKS)) {
    writeToCharacteristic(oadBlock,currentImage.block(nextBlock));
    oadListener.progress(UploadProgress.create(nextBlock + 1,currentImage.blockCount()));
    nextBlock++;
    watchdog.poke();
  }
  if (requestedBlock == currentImage.blockCount() - 1) {
    long secondsElapsed=System.currentTimeMillis() / 1000L - blockTransferStarted;
    double KBs=0;
    if (secondsElapsed > 0) {
      KBs=(double)(currentImage.sizeBytes() / secondsElapsed) / 1000;
    }
    Log.i(TAG,String.format("Final OAD Block Requested: %s/%s",nextBlock,currentImage.blockCount()));
    Log.i(TAG,String.format("Sent %d blocks in %d seconds (%.2f KB/s)",currentImage.blockCount(),secondsElapsed,KBs));
  }
}

private void onNotificationBlock ( BluetoothGattCharacteristic characteristic ) { int requestedBlock = Convert . twoBytesToInt ( characteristic . getValue ( ) , Constants . CC2540_BYTE_ORDER ) ; if ( requestedBlock == 0 ) { Log . i ( TAG , String . format ( "Image accepted (Name: %s) (Size: %s bytes)" , currentImage . name ( ) , currentImage . sizeBytes ( ) ) ) ; blockTransferStarted = System . currentTimeMillis ( ) / 1000L ; setState ( OADState . BLOCK_XFER ) ; nextBlock = 0 ; } while ( oadState == OADState . BLOCK_XFER && nextBlock <= currentImage . blockCount ( ) - 1 && nextBlock < ( requestedBlock + MAX_IN_AIR_BLOCKS ) ) { writeToCharacteristic ( oadBlock , currentImage . block ( nextBlock ) ) ; oadListener . progress ( UploadProgress . create ( nextBlock + 1 , currentImage . blockCount ( ) ) ) ; nextBlock ++ ; watchdog . poke ( ) ; } if ( requestedBlock == currentImage . blockCount ( ) - 1 ) { long secondsElapsed = System . currentTimeMillis ( ) / 1000L - blockTransferStarted ; double KBs = 0 ; if ( secondsElapsed > 0 ) { KBs = ( double ) ( currentImage . sizeBytes ( ) / secondsElapsed ) / 1000 ; } Log . i ( TAG , String . format ( "Final OAD Block Requested: %s/%s" , nextBlock , currentImage . blockCount ( ) ) ) ; Log . i ( TAG , String . format ( "Sent %d blocks in %d seconds (%.2f KB/s)" , currentImage . blockCount ( ) , secondsElapsed , KBs ) ) ; } }
received a notification on block characteristic a notification to this characteristic means the bean has accepted the most recent firmware file we have offered , which is stored as ` this . currentimage ` . it is now time to start sending blocks of fw to the device .
