TL;DR;
我的问题是:
DOMException: GATT Error: Not supported.时,我得到了一个BluetoothRemoteGATTCharacteristic.startNotifications()异常。startNotifications()是完全实现的。那么,是否需要在我的Bluno板上配置任何额外的设置才能使通知正常工作?在大多数在线示例中,在使用此方法之前,没有提到设备上的额外设置。并在运行时检查了目标特性为true的true属性。正如https://webbluetoothcg.github.io/web-bluetooth/中所述,这不应该是出现此例外的原因:
如果在特性的属性中没有设置通知或指示位,则使用NotSupportedError拒绝允诺并中止这些步骤。My:
我正在尝试建立一个小小的网络演示,在铬上,可以输出从我的Bluno甲虫v1.0板传送的文本。
我董事会内部的程序非常简单:
void setup() {
Serial.begin(115200); //initial the Serial
}
void loop() {
Serial.write("hello world");
Serial.println();
delay(500);
}我正在使用来自developer.mozilla.org的web蓝牙API。
// UUID using by Bluno Beetle
var RXTX_SERVICE = 0xdfb0;
var RXTX_CHARACTERISTIC = 0xdfb2;
function handleCharacteristicValueChanged(event) {
var value = event.target.value;
}
navigator.bluetooth.requestDevice({ acceptAllDevices: true, optionalServices: [RXTX_SERVICE] })
.then(device => { console.log(device); return device.gatt.connect(); })
.then(server => { return server.getPrimaryService(RXTX_SERVICE); })
.then(service => { return service.getCharacteristic(RXTX_CHARACTERISTIC); })
.then(ch => { console.log(ch);
ch.addEventListener('characteristicvaluechanged', handleCharacteristicValueChanged);
console.log('Notifications have been started.');
return ch;
})
.then(ch => { return ch.startNotifications() })
.catch(error => { console.log(error); });但是,在执行行:ch.startNotifications()时,我得到了这个异常。
DOMException: GATT Error: Not supported.我尝试使用iOS/Android应用程序来完成相同的任务,这两个应用程序都在处理这一特性变化的通知。所以我假设我的Bluno板在某种配置下正常工作。但是我发现网络蓝牙API对我克服这个问题是有用的。
任何帮助都将不胜感激!谢谢。
发布于 2017-05-04 07:15:16
Web蓝牙完全支持GATT通知。
根据https://evothings.com/writing-your-first-mobile-application-for-the-bluno-micro-controller-by-dfrobot/的说法,RXTX的特点似乎是0xdfb1 no 0xdfb2。
https://stackoverflow.com/questions/43724964
复制相似问题