问题:做小程序项目的时候碰到往蓝牙设备写数据超过20个字节,ios没有返回结果
解答:在社区和网上搜了一圈都说要分包发送但是没有完整的示例,以下代码是我亲测有效的
function writeTest(msg){
let buffer = hexStringToArrayBuffer(msg);
let pos = 0;
let bytes = buffer.byteLength;
console.log("bytes", bytes)
while (bytes > 0) {
let tmpBuffer;
if (bytes > 20) {
return delay(0.25).then(() => {
tmpBuffer = buffer.slice(pos, pos + 20);
pos += 20;
bytes -= 20;
console.log("tmpBuffer",