private void reboot() {
    final List<BLEAction> list = new ArrayList<>();

    list.add(reboot);

    final BLETask task = new BLETask(list);
    mBLEComms.queueTask(task);
  }
        public void onReceive(Context context, Intent intent) {
          final String action = intent.getAction();

          if (action.equals(BluetoothAdapter.ACTION_STATE_CHANGED)) {
            if (intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, -1)
                == BluetoothAdapter.STATE_OFF) {
              Log.d(TAG, "Bluetooth switched off");
              if (mBLEComms != null) {
                mBLEComms.mBluetoothAdapterStatus = false;
                mBLEComms.setupComplete = false;
              }
            } else if (intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, -1)
                == BluetoothAdapter.STATE_ON) {
              Log.d(TAG, "Bluetooth switched on, initialising");
              if (mBLEComms != null) {
                mBLEComms.mBluetoothAdapterStatus = true;
                mBLEComms.setupBluetooth();
              }
            }
          }
        }
  @Override
  public void onDestroy() {
    super.onDestroy();

    LocalBroadcastManager.getInstance(this).unregisterReceiver(mVibrateReceiver);
    LocalBroadcastManager.getInstance(this).unregisterReceiver(mGoalReceiver);
    LocalBroadcastManager.getInstance(this).unregisterReceiver(mRebootReceiver);
    LocalBroadcastManager.getInstance(this).unregisterReceiver(mColourReceiver);
    LocalBroadcastManager.getInstance(this).unregisterReceiver(mBandNotificationReceiver);

    unregisterReceiver(bluetoothStatusChangeReceiver);

    mBLEComms.disconnectGatt();
  }
  private void vibrate(final long duration) {
    final List<BLEAction> list = new ArrayList<>();

    list.add(startVibrate);
    // list.add(new WaitAction(duration));
    // list.add(stopVibrate);

    final BLETask task = new BLETask(list);

    try {
      mBLEComms.queueTask(task);
    } catch (NullPointerException e) {
      Toast.makeText(getApplicationContext(), "Vibrate: MiBand not paired", Toast.LENGTH_SHORT)
          .show();
    }
  }
  private void setColor(byte r, byte g, byte b, boolean display) {
    final List<BLEAction> list = new ArrayList<>();

    list.add(
        new WriteAction(
            MiBandConstants.UUID_CHARACTERISTIC_CONTROL_POINT,
            new byte[] {14, r, g, b, display ? (byte) 1 : (byte) 0}));

    final BLETask task = new BLETask(list);

    try {
      mBLEComms.queueTask(task);
    } catch (NullPointerException e) {
      Toast.makeText(getApplicationContext(), "SetColor: MiBand not paired", Toast.LENGTH_SHORT)
          .show();
    }
  }
  private void setGoal(int goal) {
    final List<BLEAction> list = new ArrayList<>();

    list.add(
        new WriteAction(
            MiBandConstants.UUID_CHARACTERISTIC_CONTROL_POINT,
            new byte[] {(byte) 5, (byte) 0, (byte) (goal & 0xff), (byte) ((goal >>> 8) & 0xff)}));

    final BLETask task = new BLETask(list);

    try {
      mBLEComms.queueTask(task);
    } catch (NullPointerException e) {
      Toast.makeText(getApplicationContext(), "SetGoal: MiBand not paired", Toast.LENGTH_SHORT)
          .show();
    }
  }
  private synchronized void notifyBand(
      long vibrateDuration,
      int vibrateTimes,
      int flashTimes,
      int flashColour,
      int originalColour,
      long flashDuration) {
    final List<BLEAction> list = new ArrayList<>();

    final byte[] flashColours = convertRgb(flashColour);
    final byte[] originalColours = convertRgb(originalColour);

    for (int i = 1; i <= vibrateTimes; i++) {
      list.add(startVibrate);
      // list.add(new WaitAction(vibrateDuration));
      // list.add(stopVibrate);
    }
    for (int i = 1; i <= flashTimes; i++) {
      list.add(
          new WriteAction(
              MiBandConstants.UUID_CHARACTERISTIC_CONTROL_POINT,
              new byte[] {14, flashColours[0], flashColours[1], flashColours[2], (byte) 1}));
      list.add(new WaitAction(500L));
      list.add(
          new WriteAction(
              MiBandConstants.UUID_CHARACTERISTIC_CONTROL_POINT,
              new byte[] {
                14, originalColours[0], originalColours[1], originalColours[2], (byte) 0
              }));
      list.add(new WaitAction(500L));
    }

    final BLETask task = new BLETask(list);

    try {
      mBLEComms.queueTask(task);
    } catch (NullPointerException ignored) {

    }
  }