2

TL;博士;

我的问题是:

  1. 来自https://developer.mozilla.org/en-US/docs/Web/API/Bluetooth的 Web 蓝牙 API 目前是否不完全支持一些自定义设备,如 Arduino 板?因为DOMException: GATT Error: Not supported.当我尝试使用BluetoothRemoteGATTCharacteristic.startNotifications()我的 Bluno Beetle 板时出现异常。

  2. 如果startNotifications()完全实现。那么,我的 Bluno 板上是否需要配置任何额外设置才能使通知正常工作?从大多数在线示例中,没有提及在使用此方法之前设备上的额外设置。我已经检查了notify目标特征的属性是true在运行时。如https://webbluetoothcg.github.io/web-bluetooth/中所述,这不应该是出现此异常的原因:

    If neither of the Notify or Indicate bits are set in characteristic’s properties, reject promise with a NotSupportedError and abort these steps.
    

我的情况:

我正在尝试在 chrome 上构建一个小的网络演示,它可以输出从我的 Bluno Beetle v1.0 板传输的文本。

我的板子里面的程序很简单:

void setup() {
    Serial.begin(115200);  //initial the Serial
}

void loop() {
    Serial.write("hello world");
    Serial.println();
    delay(500);
}

我正在使用 developer.mozilla.org 的网络蓝牙 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 APP 来执行相同的任务,并且两个 APP 都在处理该特性更改的通知。所以我假设我的 Bluno 板在某些配置下工作正常。但是我找不到网络蓝牙 API 对我克服这个问题很有用。

任何帮助,将不胜感激!谢谢。

4

1 回答 1

0

网络蓝牙完全支持 GATT 通知。

根据https://evothings.com/writing-your-first-mobile-application-for-the-bluno-micro-controller-by-dfrobot/,看起来RXTX特征是0xdfb1no 0xdfb2

于 2017-05-04T07:15:16.067 回答