@Override
        public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState) {
          Log.d(
              "status="
                  + LogUtil.getConstantName(BluetoothGatt.class, status, "GATT_")
                  + " newState="
                  + LogUtil.getConstantName(BluetoothProfile.class, newState, "STATE_"));
          switch (newState) {
            case BluetoothProfile.STATE_CONNECTED:
              mBluetoothGatt.discoverServices();
              break;

            case BluetoothProfile.STATE_DISCONNECTED:
              onDisconnect();
              break;
          }
        }
 @Override
 public void onServicesDiscovered(BluetoothGatt gatt, int status) {
   Log.d("status=" + LogUtil.getConstantName(BluetoothGatt.class, status, "GATT_"));
   List<BluetoothGattService> services = gatt.getServices();
   boolean found = false;
   for (BluetoothGattService service : services) {
     Log.d(service.getUuid().toString());
     if (getAssignedNumber(service.getUuid()) == GATT_SERVICE_HEART_RATE) {
       // Found heart rate service
       onHeartRateServiceFound(service);
       found = true;
       break;
     }
   }
   if (!found) {
     onHeartRateServiceNotFound();
   }
 }