Javascript 不支持Bluno板上的Web bluetooth API特性通知?
TL;博士 我的问题是:Javascript 不支持Bluno板上的Web bluetooth API特性通知?,javascript,google-chrome,bluetooth,arduino,web-bluetooth,Javascript,Google Chrome,Bluetooth,Arduino,Web Bluetooth,TL;博士 我的问题是: Web bluetooth API目前是否不完全支持一些自定义设备,如Arduino板?因为我得到了一个domeException:GATT错误:不支持。当我尝试使用BluetoothRemoteGATTCharacteristic.startNotifications()到我的Bluno甲壳虫板时出现异常 如果完全实现了startNotifications()。那么,我的Bluno板上是否需要配置任何额外设置才能使通知正常工作?从大多数在线示例来看,在使用此方法之前,
domeException:GATT错误:不支持。
当我尝试使用BluetoothRemoteGATTCharacteristic.startNotifications()
到我的Bluno甲壳虫板时出现异常startNotifications()
。那么,我的Bluno板上是否需要配置任何额外设置才能使通知正常工作?从大多数在线示例来看,在使用此方法之前,没有提到设备上的额外设置。我已经在运行时检查了目标特征的notify
属性是否为true
。这不应成为出现以下例外情况的原因:
void setup() {
Serial.begin(115200); //initial the Serial
}
void loop() {
Serial.write("hello world");
Serial.println();
delay(500);
}
我正在使用developer.mozilla.org上的web bluetooth 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()
我试着用一个iOS/Android应用程序来完成同样的任务,两个应用程序都在处理该特性变化的通知。所以我假设我的Bluno板在某些配置下工作正常。但我找不到web bluetooth API有助于克服这一问题
任何帮助都将不胜感激!谢谢。Web蓝牙完全支持GATT通知
根据,它看起来像是
RXTX
特性是0xdfb1
no0xdfb2
您最终能让它工作吗?看起来更严重的问题是缺少描述符,这使得Bluno与Web Bluetooth(以及大多数BLE设备,因为它不符合协议)不兼容。看见
// 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); });
DOMException: GATT Error: Not supported.