https://github.com/tkomde/electron-webbluetooth-auto
Automatically connect BLE device with electron
https://github.com/tkomde/electron-webbluetooth-auto
Last synced: 8 months ago
JSON representation
Automatically connect BLE device with electron
- Host: GitHub
- URL: https://github.com/tkomde/electron-webbluetooth-auto
- Owner: tkomde
- License: mit
- Created: 2024-04-25T22:19:03.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-04-28T09:59:16.000Z (about 2 years ago)
- Last Synced: 2025-07-24T12:24:15.125Z (11 months ago)
- Language: JavaScript
- Size: 26.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# electron-webbluetooth-auto
- Automatically connect BLE device at startup with electron.
- Automatically reconnect BLE device with electron.
## Run
- npm i
- npx electron .
## How it works
- In main process, call renderer scanAndConnect() function by executeJavaScript() with userGesture = true
- Reconnection is done using a different approach because of the different behavior of each OS platform as follows
- In the case of Windows
- It is necessary to reconnect to a device instance that has already been obtained (even if another requestDevice() is made, it is not found).
- In case of Mac
- Devices that have been disconnected for a while are forgotten, so it is necessary to restart over again from requestDevice().
## 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)
[Web Bluetooth / Automatic Reconnect Sample](https://googlechrome.github.io/samples/web-bluetooth/automatic-reconnect.html)
## License
MIT