[web-bluetooth] Mechanism for passing a Bluetooth service to a ServiceWorker

mfoltzgoogle has just created a new issue for 
https://github.com/WebBluetoothCG/web-bluetooth:

== Mechanism for passing a Bluetooth service to a ServiceWorker ==
[Recording my question/request from the F2F yesterday.]

The UC illustrated in the spec seems like it would work much better if
 the Web application could monitor the heart_rate service in the 
background: otherwise, closing the tab accidentally would stop data 
collection.  The right mechanism would be a ServiceWorker: but I don't
 see a way to access a previously paired device/service from that 
context, since requestDevice() can only be called in a context that 
can show a popup.

Possible avenues forward:
* Make BluetoothDevice or BluetoothGATTRemoteServer implement 
Transferable [1] and pass it from the SW client to the SW via 
postMessage().
* Add an API to (re)connect to a service already obtained from a 
BluetoothDevice by a specific origin.  This would also facilitate use 
during within-origin navigation.

Of course the permissions and privacy issues also need to be 
addressed: background use of a BT service may require an additional 
user prompt or notification. 

[1] 
https://html.spec.whatwg.org/multipage/infrastructure.html#transferable

See https://github.com/WebBluetoothCG/web-bluetooth/issues/184

Received on Tuesday, 27 October 2015 02:42:27 UTC