I cannot get Chrome to scan for devices on my Windows 10 PC (Windows surface book). However my application is working on an Andriod phone using Chrome. In Windows I have enabled the
in Chrome on the Windows PC and Bluetooth is enabled on my laptop. The BLE device (ESP-32) is discoverable through the Windows "Add a device" function so I know the PC can see my device. When my application calls the requestDevice function there is a popup in Chrome that comes up with "xyz website wants to pair" and there is a "Pair" and "Cancel" button at the bottom but no devices ever appear in the list and it times out after 60 seconds. I get the same results using the chrome://bluetooth-internals/#devices scan.
$(function(){
var requestDeviceParms = {
filters: [
{
name: ["MyESP32"]
}
],
optionalServices: ["4fafc201-1fb5-459e-8fcc-c5c9c331914b"]
};
const options = { acceptAllDevices: true };
$("#test").click(() => {
console.log("Running VLE Code");
$("#notifiedValue").text("Connecting");
navigator.bluetooth.requestDevice(options).then(device => {
$("#notifiedValue").text("Requesting connections...");
device.gatt.connect().then(gattServer=>{
gattServer.getPrimaryService("4fafc201-1fb5-459e-8fcc-c5c9c331914b").then(gattService=>{
gattService.getCharacteristic("beb5483e-36e1-4688-b7f5-ea07361b26a8").then(gattCharacteristic=>{
gattCharacteristic.startNotifications().then(gattCharacteristic=>{
gattCharacteristic.addEventListener("characteristicvaluechanged", event=>{
var value = event.target.value.getUint8(0);
$("#notifiedValue").text("" + value);
});
})
.catch(error => { $("#notifiedValue").text(error); });
})
.catch(error => { $("#notifiedValue").text(error); });
})
.catch(error => { $("#notifiedValue").text(error); });
})
.catch(error => { $("#notifiedValue").text(error); });
})
.catch(error => { $("#notifiedValue").text(error); });
});
});