- 问题描述: ios version 12 版本的手机,写 ble 特征描述,有长度限制(maxium: 182 byte)
- 尝试过的方法: 分包发数据,但是写入后再读取,发现数据是不完整的,是最后一包的内容
if (@available(iOS 13.0, *)) {
[self.delegate bleDataWithData:textData];
} else {
NSInteger datacount = 160;
NSInteger number = textData.length / datacount + ((textData.length % datacount)>0? 1:0);
for(NSInteger i = 0; i < number; i++){
if (i == number-1){
[self.delegate bleDataWithData:textData];
} else {
NSData *data = [textData subdataWithRange:NSMakeRange(0, datacount)];
[self.delegate bleDataWithData:data];
textData = [textData subdataWithRange:NSMakeRange(datacount, textData.length-datacount)];
}
}
}
求助大神们怎么实现写入超过长度的数据?