80,349
社区成员
发帖
与我相关
我的任务
分享
protected Queue<DataInfo> splitPacketFor20Byte(byte[] data) {
LinkedList dataInfoQueue = new LinkedList();
if(data != null) {
int index = 0;
do {
byte[] surplusData = new byte[data.length - index];
System.arraycopy(data, index, surplusData, 0, data.length - index);
byte[] currentData;
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(DataType.SEND);
dataInfoQueue.offer(dataInfo);
} while(index < data.length);
}
return dataInfoQueue;
}
我整理过针对BLE的基础操作框架,在Github上有源码和使用demo,希望对你有所帮助!使用介绍地址:http://blog.csdn.net/xiaoyaoyou1212/article/details/52346904