Skip to content

tkomde/electron-webbluetooth

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 

Repository files navigation

electron-WebBluetooth

WebBluetooth integration sample with electron. Supports selecting multiple device.

Prerequisites

  • electron(>=3 will work)
  • bootstrap(included)

Run

  • npm i
  • npx electron .

How it works

  1. In renderer, scan() to get device list.
  2. The devices list is notified periodically via IPC to main process.
  3. If you find the deviceId you want to connect, select and notify to main.
  4. Connection callback called only once in main.
  5. When disconnected, automatically reconnect former connected device.

Restrictions to implement WebBluetooth in electron

  • If event.preventDefault is not called, first available device will be selected.
  • Callback should be called with deviceId to be selected, passing empty string to callback will cancel the request.
  • Calling requestDevice twice causes automatically cancel the former one.

Link

Electron Documentation - webContents - select-bluetooth-device Electron Documentation - webContents - executejavascriptcode-usergesture

License

MIT

About

Connection sample of webbluetooth in electron

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published