public boolean connect(final String address){
  if (mBluetoothAdapter == null || address == null) {
    Log.w(TAG,"BluetoothAdapter not initialized or unspecified address.");
    return false;
  }
  if (mBluetoothDeviceAddress != null && address.equals(mBluetoothDeviceAddress) && mBluetoothGatt != null) {
    Log.d(TAG,"Trying to use an existing mBluetoothGatt for connection.");
    if (mBluetoothGatt.connect()) {
      mConnectionState=STATE_CONNECTING;
      return true;
    }
 else {
      return false;
    }
  }
  final BluetoothDevice device=mBluetoothAdapter.getRemoteDevice(address);
  if (device == null) {
    Log.w(TAG,"Device not found.  Unable to connect.");
    return false;
  }
  mBluetoothGatt=device.connectGatt(this,false,mGattCallback);
  Log.d(TAG,"Trying to create a new connection.");
  mBluetoothDeviceAddress=address;
  mConnectionState=STATE_CONNECTING;
  return true;
}

public boolean connect ( final String address ) { if ( mBluetoothAdapter == null || address == null ) { Log . w ( TAG , "BluetoothAdapter not initialized or unspecified address." ) ; return false ; } if ( mBluetoothDeviceAddress != null && address . equals ( mBluetoothDeviceAddress ) && mBluetoothGatt != null ) { Log . d ( TAG , "Trying to use an existing mBluetoothGatt for connection." ) ; if ( mBluetoothGatt . connect ( ) ) { mConnectionState = STATE_CONNECTING ; return true ; } else { return false ; } } final BluetoothDevice device = mBluetoothAdapter . getRemoteDevice ( address ) ; if ( device == null ) { Log . w ( TAG , "Device not found.  Unable to connect." ) ; return false ; } mBluetoothGatt = device . connectGatt ( this , false , mGattCallback ) ; Log . d ( TAG , "Trying to create a new connection." ) ; mBluetoothDeviceAddress = address ; mConnectionState = STATE_CONNECTING ; return true ; }
connects to the gatt server hosted on the bluetooth le device .
