Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tkomde/electron-webbluetooth
Connection sample of webbluetooth in electron
https://github.com/tkomde/electron-webbluetooth
electron electron-webbluetooth webbluetooth
Last synced: about 1 month ago
JSON representation
Connection sample of webbluetooth in electron
- Host: GitHub
- URL: https://github.com/tkomde/electron-webbluetooth
- Owner: tkomde
- Created: 2019-05-15T23:50:55.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-04-26T10:38:55.000Z (8 months ago)
- Last Synced: 2024-04-26T11:42:02.923Z (8 months ago)
- Topics: electron, electron-webbluetooth, webbluetooth
- Language: HTML
- Size: 119 KB
- Stars: 5
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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.
1. The devices list is notified periodically via IPC to main process.
1. If you find the deviceId you want to connect, select and notify to main.
1. Connection callback called only once in main.
1. 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](https://electronjs.org/docs/api/web-contents#event-select-bluetooth-device)
[Electron Documentation - webContents - executejavascriptcode-usergesture](https://electronjs.org/docs/api/web-contents#contentsexecutejavascriptcode-usergesture)## License
MIT