-
Notifications
You must be signed in to change notification settings - Fork 2
/
renderer.js
29 lines (23 loc) · 819 Bytes
/
renderer.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
const bleDeviceList = document.getElementById("deviceList");
async function testIt() {
let options = {
// filters: [
// { services: [xyz] },
// { name: 'xyz' }, // only devices with ''
// { namePrefix: 'xyz' }, // only devices starts with ''
// ],
// optionalServices: [
// xyzServiceUuid,
// ],
acceptAllDevices: true, // show all
};
const device = await navigator.bluetooth.requestDevice(options);
document.getElementById("device-name").innerHTML =
device.name || `ID: ${device.id}`;
if (device.name) {
listItem = document.createElement("li");
listItem.innerHTML = device.name || `ID: ${device.id}`;
bleDeviceList.appendChild(listItem);
}
}
document.getElementById("clickme").addEventListener("click", testIt);