/**
   * This function is called when the user selects 'Start Logging' from the device menu. When
   * pressed, we will start streaming data from the device if it is not already streaming data. We
   * will then save data to a text file on the users phone or tablet. TODO: make logging compatible
   * with the profiles
   */
  private void startLogging() {
    if (isDeviceConnected()) {
      if (!isDeviceStreaming()) // to log data we must first be streaming the data
      startStreaming();

      if (!isDeviceLogging()) serviceshim.setLogging(true, btAddress);
    }

    updateInterface();
  }
  /**
   * this function is called when the user wants to disconnect the device. This could happen if the
   * user choosen the wrong shimmer
   */
  private void disconnectDevice() {
    if (isDeviceConnected()) {
      serviceshim.disconnectShimmer(btAddress);
      serviceshim.stopStreaming(btAddress);
      serviceshim.setLogging(false, btAddress);
    } else
      Toast.makeText(ShimmerDevicesMenu.this, " No device to disconnect ", Toast.LENGTH_SHORT)
          .show();

    SystemClock.sleep(200);
    updateInterface();
  }
  /**
   * This function gets called when the user hits the 'Stop Streaming' button on the menu of this
   * activity. This will only be called if the device is currently streaming, and it will stop the
   * streaming of data from the currently connected device.
   */
  private void stopStreaming() {
    if (isDeviceConnected()) {
      if (isDeviceStreaming()) {
        // since we can't save data that we aren't streaming, set the logging to false
        if (isDeviceLogging()) serviceshim.setLogging(false, btAddress);

        serviceshim.stopStreaming(btAddress);
        Log.d(logName, "ShimmerDevicesMenu: " + devicename + " stopped streaming");
      } else
        Toast.makeText(
                ShimmerDevicesMenu.this, devicename + " is not streaming", Toast.LENGTH_SHORT)
            .show();
    } // end if is the device is connected
    else
      Toast.makeText(ShimmerDevicesMenu.this, " Must Connect a Device first", Toast.LENGTH_SHORT)
          .show();

    SystemClock.sleep(200);
    updateInterface();
  }
 /** This function stops the application from logging data from a shimmer device to a text file */
 private void stopLogging() {
   if (isDeviceConnected()) {
     if (isDeviceLogging()) serviceshim.setLogging(false, btAddress);
   }
   updateInterface();
 }