ITPNYU / p5.ble.js

A Javascript library that enables communication between BLE devices and a p5 sketch using Web Bluetooth API. https://itpnyu.github.io/p5ble-website.
MIT License
42 stars 29 forks source link

Auto Reconnect? #10

Open krdarrah opened 4 years ago

krdarrah commented 4 years ago

Great library, but been trying to get a reconnect project working. Occasionally, my device will disconnect, so I'd like it to just reconnect as soon as possible. On the Chrome BLE sample projects, they do have an example, and that does work... only problem is that the service and characteristics need to be retrieved again? And how can you do this without relaunching the scanner window?
https://googlechrome.github.io/samples/web-bluetooth/automatic-reconnect.html

So upon a successful reconnect, I tried to start notifications on a characteristic, but get an error: p5.ble.js:11166 Uncaught (in promise) DOMException: Characteristic with UUID c97f391f-a6c4-4778-afac-05f797bbdc5f is no longer valid. Remember to retrieve the characteristic again after reconnecting.

Any ideas how this can work? Thanks!