private boolean scan(){
  if (btAdapter.startLeScan(mCallback)) {
    mScanning=true;
    Log.i(TAG,"BLE scan started successfully");
    if (mHandler.postDelayed(scanTimeoutCallback,scanTimeout * 1000)) {
      Log.i(TAG,String.format("Cancelling discovery in %d seconds",scanTimeout));
    }
 else {
      Log.e(TAG,"Failed to schedule discovery complete callback!");
    }
    return true;
  }
 else {
    Log.i(TAG,"BLE scan failed!");
    return false;
  }
}

private boolean scan ( ) { if ( btAdapter . startLeScan ( mCallback ) ) { mScanning = true ; Log . i ( TAG , "BLE scan started successfully" ) ; if ( mHandler . postDelayed ( scanTimeoutCallback , scanTimeout * 1000 ) ) { Log . i ( TAG , String . format ( "Cancelling discovery in %d seconds" , scanTimeout ) ) ; } else { Log . e ( TAG , "Failed to schedule discovery complete callback!" ) ; } return true ; } else { Log . i ( TAG , "BLE scan failed!" ) ; return false ; } }
helper function for starting scan and scheduling the scan timeout
