Web蓝牙特征数据缓存

Web蓝牙特征数据缓存,web,bluetooth,Web,Bluetooth,我正在尝试在windows 10上使用带有chrome浏览器的web蓝牙。当我从特征中读取值时,每次都会得到相同的数据,这是不正确的。我在c#UWP应用程序中使用了相同的BLE硬件,并且得到了相同的结果,直到我将其更改为以未缓存模式读取。那么,在从特征读取值时,有没有一种方法不使用web bluetooth的缓存模式 下面的代码每秒轮询一次特征。这是一个蓝牙温度计,温度应该随着温度的升降而变化 ngOnInit() { navigator.bluetooth.requestDevice({

我正在尝试在windows 10上使用带有chrome浏览器的web蓝牙。当我从特征中读取值时,每次都会得到相同的数据,这是不正确的。我在c#UWP应用程序中使用了相同的BLE硬件,并且得到了相同的结果,直到我将其更改为以未缓存模式读取。那么,在从特征读取值时,有没有一种方法不使用web bluetooth的缓存模式

下面的代码每秒轮询一次特征。这是一个蓝牙温度计,温度应该随着温度的升降而变化

ngOnInit() {
navigator.bluetooth.requestDevice({
  filters: [{services: ['battery_service']}],
  optionalServices: ['f2b32c77-ea68-464b-9cd7-a22cbffb98bd']
})
  .then(device => device.gatt.connect())
  .then(server => {
    // Getting Temp Service...
    return server.getPrimaryService('f2b32c77-ea68-464b-9cd7-a22cbffb98bd');
  })
  .then(service => {
    // Getting Battery Level Characteristic...
    return service.getCharacteristic('78544003-4394-4fc2-8cfd-be6a00aa701b');
  })
  .then(characteristic => {
    // Reading Battery Level...
    this.tempChar = characteristic;
    setInterval(() => {
      this.readOverAndOver(characteristic);
    }, 1000);

    return characteristic.readValue();
  })
  .then(value => {
    console.log('Battery percentage is ' + value.getUint8(0));
  })
  .catch(error => {
    console.log(error);
  });
}

readOverAndOver(特征:任意){ const textcoder=新的textdecover()


}

您可能希望在Chrome中以bug的形式将其归档

this.tempChar.readValue().then(value => {
  const stringThing = textEncoder.decode(value);
  console.log(stringThing);
  console.log('new value: ', value);
});