@ RequiresApi ( api = Build . VERSION_CODES . LOLLIPOP ) void requestMtu ( @ IntRange ( from = 0 , to = 517 ) final int mtu ) throws DeviceDisconnectedException , UploadAbortedException { if ( mAborted ) throw new UploadAbortedException ( ) ; mRequestCompleted = false ; mService . sendLogBroadcast ( DfuBaseService . LOG_LEVEL_VERBOSE , "Requesting new MTU..." ) ; mService . sendLogBroadcast ( DfuBaseService . LOG_LEVEL_DEBUG , "gatt.requestMtu(" + mtu + ")" ) ; if ( ! mGatt . requestMtu ( mtu ) ) return ; // We have to wait until the MTU exchange finishes try { synchronized ( mLock ) { while ( ( ! mRequestCompleted && mConnected && mError == 0 ) || mPaused ) mLock . wait ( ) ; } } catch ( final InterruptedException e ) { loge ( "Sleeping interrupted" , e ) ; } if ( ! mConnected ) throw new DeviceDisconnectedException ( "Unable to read Service Changed CCCD: device disconnected" ) ; }
Requests given MTU . This method is only supported on Android Lollipop or newer versions . Only DFU from SDK 14 . 1 or newer supports MTU > 23 .