手机型号为华为荣耀10 及一加6

97170f24f7049b0d8a74a0fcccad2ad1.png        复现问题的简单代码片段    都是按照官网给到API   初始化---》 搜索蓝牙---》连接蓝牙---》获取蓝牙serivergetBLEDeviceServices--->获取蓝牙getBLEDeviceCharacteristics

---》发送指令

let hex1 = '0e,7e,00,00,00,00,00,00,00,00,00,00,00,ff,5a';

//     //let hex1 = '0e,7e,01,00,05,0d,0c,00,00,00,00,00,00,e0,5a';

console.log(hex1)

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

return parseInt(h, 16)

})).buffer

wx.writeBLECharacteristicValue({

deviceId: that.data.connectedDeviceId,

serviceId: that.data.writeServicweId,

characteristicId: that.data.writeCharacteristicsId,

value: buffer1,

success: function (res) {

// success

console.log("success  指令发送成功");

console.log(res);

},

fail: function (res) {

console.log("调用失败");

},

complete: function (res) {

console.log("调用结束");

// complete

}

})

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐