-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sending float values from Arduino Nano 33 BLE doesn't seem to work #6
Comments
So it looks like the corresponding values are indeed correlated according to this reply. What we need to figure out is how to swap the endianness of the data we receive. |
Making the following changes in the code makes it work - case 'float32':
result = data.getFloat32(0, true); //'littleEndian' works too
break; |
I think @tigoe might make a pull request to solve the same. Feel free to close this now or later once the PR is merged. |
Haven't made a PR yet, but @armsp is correct in that the issue is that the current API doesn't give you a way to set the endianness of your data types, even though the functions it uses (e.g. getFloat32()) do. So it's more of a feature request, adding the ability to set endianness in the API. This is actually the same issue as #4, which I originally thought was about float64, because I didn't pay enough attention. |
@tigoe let me know if you need any assistance. I would be glad to contribute. |
If you want to make a PR that adds the ability to set endianness on all the functions in parseData.js, that would be helpful. My feeling would be that maybe it could be an optional parameter in startNotifications() around line 83 and following of p5.ble.js? I would defer to @yining1023 on whether that's the best place, or if there's somewhere better, though. |
@yining1023 thanks for your wonderful work. Just wanted to check with you on @tigoe 's suggestions. You can take a look at this issue (the title is bit of a misnomer)and #4 to gain some insight into the discussion. Please do let me know what approach you'd like to prefer and I'd try my best to come up with a decent PR to close this. |
Hi @armsp, Thank you so much for reporting and solving the issue! It would be amazing if you could add a PR to allow users to set the endianness of the data types when they are calling myble.read(myCharacteristic, 'float32', 'bigEndian', gotValue);
myble. startNotifications(myCharacteristic, handleNotifications, 'float32', 'bigEndian'); then in the data.getFloat32(0, true);
data.getFloat64(0, true); so it uses Thank you for your contribution! please let me know if you have any questions. |
@yining1023 okay then, I will make a quick PR by changing the |
Awesome! Thank you! |
Quick fix for issue #6 float data little endian
The changes are in p5.ble.js@0.0.5 now! Please let me know if it works for you. I also added support for big-endian: #4 (comment) |
@yining1023 I tested the code with the latest release. It works as expected. Thanks a lot for the support. |
I got this wonderful library working with the new Arduino Nano 33 BLE. However sending float values seems to have an issue. For example these are the float values as reported in my serial montior and the corresponding float values received by p5.ble.js
I am using the ArduinoBLE library. And sending float values using
BLEFloatCharacteristic
and receiving them in p5.ble.js usingmyBLE.read(myCharacteristic, 'float32', gotValue);
The text was updated successfully, but these errors were encountered: