问题
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.
来源:https://stackoverflow.com/questions/45467214/is-it-possible-to-persist-a-bluetooth-le-connection-on-browser-refresh