首先需要在此说明一下,我们这儿有需要要在企业微信中调用打签机,然后看了文档,文档中说是可以支持蓝牙。
所以我就开始尝试,但是尝试过程中发现用官方的那种(wx.writeBLECharacteristicValue({})这样)调用方法根本不能用,所以我就用invoke的方法去调用,发现可以正常使用,但是在最后输出进制流数据到打签机时,总是会报err_msg"writeBLECharacteristicValue:fail_systemerr"'errCode":10008的错误。
之后怀疑是因为特征值和服务ID有问题,遂把设备所有支持write的都试了一遍还是不行,绝望了,请求帮助。
PS:但是有一个特征值在小程序中用了就可以正常打签
截出部分关键代码:
//打签时候调用的方法
let data = {
deviceId: that.deviceId,
serviceId:that.writeServiceId,
characteristicId:that.writeCharaterId,
value: buf,
}
console.log('deviceId:' + that.deviceId)
console.log('serviceId:' + that.writeServiceId)
console.log('characteristicId:' + that.writeCharaterId)
console.log('value:' + buf)
this.$wx.writeBLECharacteristicValue(data).then(res => {
if (currentPrint == printNum) {
uni.showToast({
title: '已打印第' + currentPrint + '张成功',
})
}
})
/* 写入数据调用方法 */
writeBLECharacteristicValue({deviceId,serviceId,characteristicId,value}){
return new Promise((resolve,reject) => {
wx.invoke('writeBLECharacteristicValue', {deviceId,serviceId,characteristicId,value}, res => {
console.log(JSON.stringify(res))
if (res.err_msg == "writeBLECharacteristicValue:ok") {
resolve(res)
}else {
reject('失败')
}
});
})
}
你好,这个报错 10008 其余所有系统上报的异常应该是设备问题,需要自行排查下