var buffer = new ArrayBuffer(that.inputText.length);
var dataView = new Uint8Array(buffer);
console.log(buffer, dataView)
for (var i = 0; i < that.inputText.length; i++) {
dataView[i] = that.inputText.charCodeAt(i);
}
uni.writeBLECharacteristicValue({
deviceId: that.connectedDeviceId,
serviceId: that.serviceId,
characteristicId: that.characteristicId,
value: buffer,
success: function(res) {
console.log('发送指令成功:' + res.errMsg);
uni.showModal({
title: '数据发送成功',
content: ''
});
},
fail: function(res) {
// fail
//console.log(that.data.services)
that.connected = false
console.log('message发送失败:' + res.errMsg);
uni.showToast({
title: '数据发送失败,请稍后重试',
icon: 'none'
});
}
});
上面是我的代码片段,已经成功执行成功了,但是蓝牙设备就是没反应, 但是我用这套代码去运行小程序 ,小程序也发送一样的指令 蓝牙设备是有反应的 我想知道是需要处理什么呢
1 个回复
g***@163.com
你好,请问解决了吗?