Closed idea--list closed 3 years ago
Thank you for raising this detailed GitHub issue. I am now notifying our internal issue triagers. Internal Jira reference: https://jira.arm.com/browse/IOTOSM-3744
Thanks for sharing @idea--list . I don't think the issue has anything to do with the event queue which should be fast enough to handle any kind of transfer at the highest rate offered by BLE (every 6 ms). In the example posted above, the issue seems to lie in data queuing which is unconditional of the link configuration. By default Android connection interval is set to 50ms. If you push new data every 30ms of course it will saturate the transfer queue.
My recommendation is to split sampling rate from transfer rate: At a regular interval set locally the data you want to send. Then use GattServer::EventHandle::onDataSent
to send new data through the BLE link: when it is called, it is safe to send new data. You can use a CircularBuffer If you want to store more than one sample.
Store samples and send them in a batch. The frequency of updates doubles after reconnection because you call _event_queue.call_every(UPDATEINTV, [this] { update_sensor_value(); });
a second time (the one from before is still running).
We're happy to help but this is not the place to ask these questions. This repository is for bugs with example code. If you have a general mbed-os bug to report please use the mbed-os repo. If you have programming questions then the forum is the better venue and will gather a wider audience.
Description of defect
Based on the BLE_GattServer_AddService example i wrote a really basic signal generator that streams values to another BLE device after a connection is established. The intention of this was to see how many packets get lost and how reliable is BLE API in general. The nRF Connect (and similar) apps are simply not fit for such evaluations... so i designed an app for scoping the BLE stream with App Inventor.
Major conclusions:
event_queue.call_every()
. Until now i could not find any means to circumvent that...except forsystem_reset()
which is not a viable option in real world applications)The last 2 points simply render Mbed BLE API completely unusable for almost anything beyond unit tests on some developers workbench that should only run for some seconds. I mean in any real application chances are high that the BLE connection will get lost and the devices will reconnect...which will cause the BLE signal ripple apart.
I wonder what i might be missing, so any hint is welcome.
Target(s) affected by this defect ?
Artemis Thing Plus
Toolchain(s) (name and version) displaying this defect ?
ARMC 6.15
What version of Mbed-os are you using (tag or sha) ?
Mbed OS V6.9
What version(s) of tools are you using. List all that apply (E.g. mbed-cli)
Mbed Studio V1.4
How is this defect reproduced ?
Code for the BLE signal generator:
Import this project into App Inventor and use your phone as a scope.