I use web bluetooth in my project, I connect to the device using this code
async function requestDevice() {
bluetoothDevice = await navigator.bluetooth.requestDevice({
// filters: [ { name: 'Device test' } ],
acceptAllDevices: true,
optionalServices: [
'battery_service',
'03b80e5a-ede8-4b33-a751-6ce34ec4c700'
]
});
bluetoothDevice.addEventListener('gattserverdisconnected', onDisconnected);
}
Always to connect, I call the dialog box and there I select the device I need. Can I programmatically get a list of already connected devices? In order not to invoke a dialog box each time?
Aucun commentaire:
Enregistrer un commentaire