@Override
 protected void onDestroy() {
   if (mGatt == null) {
     return;
   }
   mGatt.close();
   mGatt = null;
   super.onDestroy();
 }
 @Override
 public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState) {
   Log.i("onConnectionStateChange", "Status: " + status);
   switch (newState) {
     case BluetoothProfile.STATE_CONNECTED:
       Log.i("gattCallback", "STATE_CONNECTED");
       gatt.discoverServices();
       break;
     case BluetoothProfile.STATE_DISCONNECTED:
       Log.e("gattCallback", "STATE_DISCONNECTED");
       break;
     default:
       Log.e("gattCallback", "STATE_OTHER");
   }
 }
 @Override
 public void onCharacteristicRead(
     BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) {
   Log.i("onCharacteristicRead", characteristic.toString());
   gatt.disconnect();
 }
 @Override
 public void onServicesDiscovered(BluetoothGatt gatt, int status) {
   List<BluetoothGattService> services = gatt.getServices();
   Log.i("onServicesDiscovered", services.toString());
   gatt.readCharacteristic(services.get(1).getCharacteristics().get(0));
 }