【蓝牙】发送数据时偶尔会发送错误
发布于 6 年前 作者 litao 10249 次浏览 来自 问答
  • 当前 Bug 的表现(可附上截图)
  • 预期表现    在多次发送后出现这种问题,在此之前发送、接收正常。发送报错10012,蓝牙连接也断开了,之后一直是10006未连接。
  • 复现路径
  • 提供一个最简复现 Demo

//向设备发送数据

Write: function (str, uuid, suuid, wuuid,nuuid) {

var that = this;

var value = str;

//console.log(‘需要发送的值为:’, value);

/* 将数值转为ArrayBuffer类型数据 */

var typedArray = new Uint8Array(value.match(/[\da-f]{2}/gi).map(function (h) {

return parseInt(h, 16)

}));

var buffer = typedArray.buffer;

console.log(“写入设备ID:”, uuid);

console.log(“写入服务ID:”, suuid);

console.log(“写入特征值ID:”,wuuid);

wx.writeBLECharacteristicValue({

deviceId: uuid,

serviceId: suuid,

characteristicId: wuuid,

value: buffer,

success: function (res) {

console.log(‘数据发送成功:’,res);

console.log(str);

},

fail: function (res) {

console.log(‘Fail:数据发送失败’,res);

console.log(str);

}

});

},

4 回复

提供一下出现问题的机型和微信版本,以及能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。

相同的问题,但是只有小米手机会出现这种情况,请问楼主是怎么解决的??一般是设备不稳定,说的是接收端吗??

同样的问题,偶尔返回10012错误码,请问楼主知道什么原因了么?

机型:nubia z11minis,微信客户端:6.6.7,复现代码太多了,要和我们的硬件通信。想知道为什么偶尔会发生这种情况,原因是什么?

回到顶部