title: Android: Bluetooth LE connection terminates automatically
body: <p>I'm testing a  Bluetooth LE connection between two Android devices (Nexus 6 with Android 6.0 and Samsung Galaxy S6 with Android 5.1). The Nexus is setup as the Peripheral and the Samsung connects as the central. The connection is always correctly established but then the connection is closed after a few seconds without any apparent reason. This is the GattServerCallback code:</p>
  
  <pre><code>  public class MyServerCallBack extends BluetoothGattServerCallback
  {
  
  
      @Override
      public void onConnectionStateChange(BluetoothDevice device, int status, int newState) {
          super.onConnectionStateChange(device, status, newState);
  
  
          if (newState == BluetoothProfile.STATE_CONNECTED) {
  
  
           Log.i(TAG,"SOMEONE CONNECTED TO OUR SERVER "+device.getName()+" "+device.getAddress());
  
  
          }
  
          else if (newState== BluetoothProfile.STATE_DISCONNECTED)
          {
  
              Log.i(TAG,"SOMEONE DISCONNECTED FROM OUR SERVER");
          }
  
  
      }
  
  }
  </code></pre>
  
  <p>And this is the BluetoothGattCallback for the central:</p>
  
  <p>public class MyCallBack extends BluetoothGattCallback
      {</p>
  
  <pre><code>    @Override
      public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState) {
          super.onConnectionStateChange(gatt, status, newState);
  
          if (status!=133)
          {
  
              if (newState == BluetoothProfile.STATE_CONNECTED) {
  
  
                  if (mConnectionState!=STATE_CONNECTED)
                  {
  
                      mConnectionState = STATE_CONNECTED;
  
                      }
  
  
  
  
              } else if (newState == BluetoothProfile.STATE_DISCONNECTED) {
  
  
  
                  Log.i(TAG, "RECEIVED DISCONNECTED SIGNAL.");
  
              }
  
          }
          else
          {
              Log.e(TAG,"STATUS IS 133");
              //gatt.close();
              //gatt.connect();
              mConnectionState = STATE_DISCONNECTED;
              mDiscoveryState = STATE_IDLE;
  
          }
  
      }
  </code></pre>
  
  <p>A few seconds after establishing a connection. The log will indicate a disconnection without any apparent reason. Is this a known bug for Android?</p>