feat: add support for Web Bluetooth pin pairing (#35416)
* feat: add bluetooth pairing handler * Update docs/api/session.md Co-authored-by: Charles Kerr <charles@charleskerr.com> * Update docs/api/session.md Co-authored-by: Charles Kerr <charles@charleskerr.com> * docs: update based on review * Apply suggestions from code review Co-authored-by: Erick Zhao <erick@hotmail.ca> Co-authored-by: Charles Kerr <charles@charleskerr.com> * chore: update docs per review * chore: cleanup callback per review Co-authored-by: Charles Kerr <charles@charleskerr.com> Co-authored-by: Erick Zhao <erick@hotmail.ca>
This commit is contained in:
parent
f8077cc004
commit
697a219bcb
11 changed files with 234 additions and 6 deletions
|
@ -5,4 +5,30 @@ async function testIt() {
|
|||
document.getElementById('device-name').innerHTML = device.name || `ID: ${device.id}`
|
||||
}
|
||||
|
||||
document.getElementById('clickme').addEventListener('click',testIt)
|
||||
document.getElementById('clickme').addEventListener('click',testIt)
|
||||
|
||||
window.electronAPI.bluetoothPairingRequest((event, details) => {
|
||||
const response = {}
|
||||
|
||||
switch (details.pairingKind) {
|
||||
case 'confirm': {
|
||||
response.confirmed = confirm(`Do you want to connect to device ${details.deviceId}?`)
|
||||
break
|
||||
}
|
||||
case 'confirmPin': {
|
||||
response.confirmed = confirm(`Does the pin ${details.pin} match the pin displayed on device ${details.deviceId}?`)
|
||||
break
|
||||
}
|
||||
case 'providePin': {
|
||||
const pin = prompt(`Please provide a pin for ${details.deviceId}.`)
|
||||
if (pin) {
|
||||
response.pin = pin
|
||||
response.confirmed = true
|
||||
} else {
|
||||
response.confirmed = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
window.electronAPI.bluetoothPairingResponse(response)
|
||||
})
|
Loading…
Add table
Add a link
Reference in a new issue