Is it possible to persist a Bluetooth LE connectio

2019-08-22 07:16发布

问题:

Is it possible to persist a Bluetooth LE connection on browser refresh? Or at least minimize the pairing time?

回答1:

Eventually navigator.permissions.query would support this. Sample code from Web Bluetooth Specification

navigator.permissions.query({
  name: "bluetooth",
  deviceId: sessionStorage.lastDevice,
}).then(result => {
  if (result.devices.length == 1) {
    return result.devices[0];
  } else {
    throw new DOMException("Lost permission", "NotFoundError");
  }
}).then(...);

However, no browser currently implements this.

As of Q3 2017 the chromium implementation is actively working on Web Bluetooth but not this feature.