mirror of
https://github.com/servo/servo
synced 2026-05-01 20:07:22 +02:00
requestDevice update
This commit is contained in:
28
tests/html/bluetooth/bluetooth_request_all_devices.html
Normal file
28
tests/html/bluetooth/bluetooth_request_all_devices.html
Normal file
@@ -0,0 +1,28 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<title>Request All Devices</title>
|
||||
<body>
|
||||
<button type="button" onclick="onButtonClick()">Request All Devices</button>
|
||||
<pre id="log"></pre>
|
||||
<script src="bluetooth_functions.js"></script>
|
||||
<script>
|
||||
function onButtonClick() {
|
||||
clear();
|
||||
var options = {optionalServices: ['generic_access'], acceptAllDevices:true};
|
||||
try {
|
||||
log('Requesting Bluetooth Device...');
|
||||
var bluetooth = window.navigator.bluetooth;
|
||||
var device = bluetooth.requestDevice(options);
|
||||
|
||||
log('Connecting to GATT Server on device...');
|
||||
var server = device.gatt.connect();
|
||||
|
||||
log('Getting Generic Access Service...');
|
||||
var service = server.getPrimaryService('generic_access');
|
||||
} catch(err) {
|
||||
log(err);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user