【发布时间】:2020-12-11 21:48:00
【问题描述】:
我正在尝试使用 Web 蓝牙 API 将长度为 490 的数据写入设备。当我尝试编写时,我得到 NotSupportedError: GATT Error Unknown。
我在安卓上使用 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);
});
有人可以帮忙吗?
【问题讨论】:
标签: bluetooth-gatt web-bluetooth