80,351
社区成员
发帖
与我相关
我的任务
分享
protected Queue<DataInfo> splitPacketFor20Byte(byte[] data) {
Queue<DataInfo> dataInfoQueue = new LinkedList<>();
if (data != null) {
int index = 0;
do {
byte[] surplusData = new byte[data.length - index];
byte[] currentData;
System.arraycopy(data, index, surplusData, 0, data.length - index);
if (surplusData.length <= 20) {
currentData = new byte[surplusData.length];
System.arraycopy(surplusData, 0, currentData, 0, surplusData.length);
index += surplusData.length;
} else {
currentData = new byte[20];
System.arraycopy(data, index, currentData, 0, 20);
index += 20;
}
DataInfo dataInfo = new DataInfo();
dataInfo.setData(currentData);
dataInfo.setDataType(DataInfo.DataType.SEND);
dataInfoQueue.offer(dataInfo);
} while (index < data.length);
}
return dataInfoQueue;
}