Closed tigoe closed 4 years ago
Thank you for filing the issue! I’ll look into it this week.
On Wed, Aug 14, 2019 at 9:37 AM Tom Igoe notifications@github.com wrote:
Calling for .read() or .startNotifications() using 'float64' as the data type causes a sketch to fail.
Sample:
myBLE.startNotifications(characteristic, myHandler, 'float64');
error:
crashes on line 40 of p5.ble.js
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ITPNYU/p5.ble.js/issues/4?email_source=notifications&email_token=ACCC2ZCVDT652IQWT66A6TDQEQC7XA5CNFSM4ILU7E22YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HFGU6EA, or mute the thread https://github.com/notifications/unsubscribe-auth/ACCC2ZDQHGOEZ6YO2372CJLQEQC7XANCNFSM4ILU7E2Q .
Update: by adding the littleEndian flag on getFloat32(), the problem goes away. So I'd suggest adding in an option to use that flag for notifications, and the problem will be generally solvable.
https://github.com/ITPNYU/physcomp/tree/master/Labs/LabIMUs/Nano33MadgwickBLE and https://github.com/ITPNYU/physcomp/tree/master/Labs/LabIMUs/MadgwickVisualizerBLE with a modified p5.ble.min.js show the example working. Use the non-modified p5.ble.min.js to see the issue.
Hi @tigoe, I published a new version of p5.ble.js 0.0.5 that fixes this issue.
Now it reads data in little-Endian by default, so the following code will be working:
myBLE.startNotifications(characteristic, myHandler, 'float64');
And if people would like to read data in big-endian format, they can pass float64-bigEndian
or float32-bigEndian
.
myBLE.startNotifications(characteristic, myHandler, 'float64-bigEndian');
myBLE.read
works the same as myBLE.startNotifications
. I added a note to the website.
Please let me know if it works for you. :)
Works great, thanks @yining1023 I updated this example for both the Nano 33 IoT and BLE Sense as well, and it works pretty well.
Yay! Thank you for testing it! ❤️
Calling for .read() or .startNotifications() using 'float64' as the data type causes a sketch to fail.
Sample:
error:
crashes on line 40 of p5.ble.js