private ObjectInfo selectObject ( final int type ) throws DeviceDisconnectedException , DfuException , UploadAbortedException , RemoteDfuException , UnknownResponseException { if ( ! mConnected ) throw new DeviceDisconnectedException ( "Unable to read object info: device disconnected" ) ; OP_CODE_SELECT_OBJECT [ 1 ] = ( byte ) type ; writeOpCode ( mControlPointCharacteristic , OP_CODE_SELECT_OBJECT ) ; final byte [ ] response = readNotificationResponse ( ) ; final int status = getStatusCode ( response , OP_CODE_SELECT_OBJECT_KEY ) ; if ( status == SecureDfuError . EXTENDED_ERROR ) throw new RemoteDfuExtendedErrorException ( "Selecting object failed" , response [ 3 ] ) ; if ( status != DFU_STATUS_SUCCESS ) throw new RemoteDfuException ( "Selecting object failed" , status ) ; final ObjectInfo info = new ObjectInfo ( ) ; info . maxSize = mControlPointCharacteristic . getIntValue ( BluetoothGattCharacteristic . FORMAT_UINT32 , 3 ) ; info . offset = mControlPointCharacteristic . getIntValue ( BluetoothGattCharacteristic . FORMAT_UINT32 , 3 + 4 ) ; info . CRC32 = mControlPointCharacteristic . getIntValue ( BluetoothGattCharacteristic . FORMAT_UINT32 , 3 + 8 ) ; return info ; }
Selects the current object and reads its metadata . The object info contains the max object size and the offset and CRC32 of the whole object until now .