Closed david-gettins closed 11 months ago
Did you ever get to the bottom of this @david-gettins ?
Yes, well sort of... On Android you can reduce the data loss by setting connection priority to high:
bleManager.requestConnectionPriorityForDevice(device.id, ConnectionPriority.High)
Although, I still found data loss but only at around 0.6%. This could be seen as acceptable for most cases but presents a bit of an issue if your trying to do something with ECG signals (or similar) e.g. R peak detection, as the missing data points could be your R peak.
I messed around for sometime, even created a new app with nothing going on but the data collection to no avail. I have now created my own native module with Android and iOS implementations that save raw data on the native side using cooroutines (Android) and a dispatch queue (iOS). Only the data I need for the UI gets parsed and sent across to React Native. With this set up I could reduce the number of calls across the RN bridge by sending an event with the UI relevant data every 1 second. This was sufficient for the UI and no raw data is lost.
Thanks - I had a hunch that is what you would say. Glad you were able to get things working over the bridge.
I'm excited to inform you that we've released a new version of react-native-ble-plx
. Many of the concerns and bugs have been addressed in this update.
If you encounter any issues or have further suggestions, please don't hesitate to open a new issue.
Prerequisites
Please answer the following questions for yourself before submitting an issue. YOU MAY DELETE THE PREREQUISITES SECTION.
Expected Behavior
All data received from a GATT server is accessible.
Current Behavior
With high update rates some data is missing. Not sure if it is due to bridge communication or too many callbacks queued or something else. This also happens at lower update rates but more characteristics notifying.
I have tried a few different approaches e.g. write staright to MMKV storage or buffer in an array then periodically save to storage.
Below are ECG (EKG) traces generated from a health and fitness device with an update rate of 2048Hz.
This is from an RN app using this library:
This is from a native app:
Steps to Reproduce
Please provide detailed steps for reproducing the issue.
Context
Please provide any relevant information about your setup. This is important in case the issue is not reproducible except for under certain conditions. Both JS and platform logs can be enabled via setLogLevel function call.
Library version: 2.0.2
Platform: Android and iOS.
Platform logs (logcat/XCode): react-native-ble-plx-issue-logs.txt
JS logs:
Contents of the
package.json
file: Part of an NX monorepo so here is the app's linked dependencies:Formatted code sample or link to a repository:
ble.notify - simply wraps the usual function so the consumer doesn't need to know about the ble manager
start notifications and write to a raw data store
rawData.push - using react-native-mmkv for the storage module