public ClientBlockContext(CoapBlockOption blockOption, CoapBlockSize maxBlocksize) { /* determine the right blocksize (min of remote and max)*/ if (maxBlocksize == null) { blockSize = blockOption.getBlockSize(); } else { int max = maxBlocksize.getSize(); int remote = blockOption.getBlockSize().getSize(); if (remote < max) { blockSize = blockOption.getBlockSize(); } else { blockSize = maxBlocksize; } } }
public CoapBlockOption getNextBlock() { int num = payload.size() / blockSize.getSize(); // ignore the rest (no rest should be there) return new CoapBlockOption(num, false, blockSize); }