/**
   * Method to store temporarily the activity data values got from the Mi Band.
   *
   * <p>Since we expect chunks of 20 bytes each, we do not store the received bytes it the length is
   * different.
   *
   * @param value
   */
  private void bufferActivityData(byte[] value) {
    /*
            if (scheduledTask != null) {
                scheduledTask.cancel(true);
            }
    */
    if (activityStruct.hasRoomFor(value)) {
      if (activityStruct.isValidData(value)) {
        activityStruct.buffer(value);

        /*                scheduledTask = scheduleTaskExecutor.schedule(new Runnable() {
                            @Override
                            public void run() {
                                GB.toast(getContext(), "chiederei " + activityStruct.activityDataTimestampToAck + "   "+ activityStruct.activityDataUntilNextHeader, Toast.LENGTH_LONG, GB.ERROR);
                                //sendAckDataTransfer(activityStruct.activityDataTimestampToAck, activityStruct.activityDataUntilNextHeader);
                                LOG.debug("runnable called");
                            }
                        }, 10l, TimeUnit.SECONDS);
        */
        if (activityStruct.isBufferFull()) {
          flushActivityDataHolder();
        }
      } else {
        // the length of the chunk is not what we expect. We need to make sense of this data
        LOG.warn(
            "GOT UNEXPECTED ACTIVITY DATA WITH LENGTH: "
                + value.length
                + ", EXPECTED LENGTH: "
                + activityStruct.activityDataRemainingBytes);
        getSupport().logMessageContent(value);
      }
    } else {
      GB.toast(
          getContext(),
          "error buffering activity data: remaining bytes: "
              + activityStruct.activityDataRemainingBytes
              + ", received: "
              + value.length,
          Toast.LENGTH_LONG,
          GB.ERROR);
      try {
        TransactionBuilder builder = performInitialized("send stop sync data");
        builder.write(
            getCharacteristic(MiBandService.UUID_CHARACTERISTIC_CONTROL_POINT),
            new byte[] {MiBandService.COMMAND_STOP_SYNC_DATA});
        builder.queue(getQueue());
        GB.updateTransferNotification("Data transfer failed", false, 0, getContext());
        handleActivityFetchFinish();

      } catch (IOException e) {
        LOG.error("error stopping activity sync", e);
      }
    }
  }