我正在尝试使用Web Bluetooth API将长度为490的数据写入设备。当我尝试写的时候,我得到了NotSupportedError: GATT错误未知。
我使用的是android上的chrome浏览器。
我的应用程序是Angular 7,我使用的是@types/web-bluetooth。
代码如下:
navigator.bluetooth
.requestDevice({
filters: [{ name: this.deviceName }],
optionalServices: [this.GATT_SERVICE],
})
.then((device) => {
return device.gatt.connect();
})
.then((server) => {
return server.getPrimaryService(this.GATT_SERVICE);
})
.then((service) => {
this.gattService = service;
return this.gattService.getCharacteristic(this.GATT_CHAR);
})
.then((characteristic) => {
characteristic.writeValueWithResponse(this.arraybufferdata);
})
.catch(async (err) => {
console.log(err);
});有人能帮帮忙吗?
发布于 2020-12-11 21:48:01
这个问题与长度有关吗?你能用更少的字节在this.arraybufferdata中重现错误吗?
Nit:您可能希望返回promise,以便传播错误。
.then((characteristic) => {
return characteristic.writeValueWithResponse(this.arraybufferdata);
})https://stackoverflow.com/questions/64998584
复制相似问题