Problem with connecting multiple devices
Currently I'm trying to develop app which will collect multiple sensors data in realtime (streamming mode). Hardware which I'm using:
Boards: MetaMotion R
In my setup multiple hubs are discovering metamotion devices and then they try to connect and setup streaming mode. Hubs are Raspberry Pi 4 (Raspbian without GUI) but we were testing this app on PC (Ubuntu 20.04) and metamotion HUB with the same issues.
For now we encourage those few issues regarding connectivity.
First one is that when we discover a device and then call connectAndSetUp then there is let's say 50% chance that connection will be disconnected immediately. Code that I'm using and logs you could find in attachment (scan_and_connect_to_disco.txt and immediately_disconnect_log.txt).
Second issue is that connection sometimes hangs in the connectAndSetUp function. In that case I've implemented a timeout which you could see in attached code (scan_and_connect_to_disco.txt, lines 35-49). When timeout occurs then I'm calling
disconnect() function on
discovered_device and wait till the callback is called. Unfortunately sometimes the disconnect function also hangs and I'm unable to disconnect from the device at all. It is still connected to HUB as it is not advertising but I'm not able to reset connection in any way, than resetting the app and hci device.
Third issue is related to sensor setup. Sometimes sensors are not sending data in periods like I configure it (and it is not related to poor signal). I use the same setup code for all sensors and in example 3 sensors are sending 100 samples per second and 4th is sending 30 samples per second. There are also situations where the sensor after configuring it is not sending data at all (but in this case it is easy to trace and create some workaround). In attachment you could see my setup function (setup.txt)
Please help me with those issues as they make this product not usable for us.
It sounds like you are connecting more sensors than one dongle can handle. One dongle can handle 1-3 sensors (Depending on the make/model) but again, you are still limited by the Bluetooth bandwith (100Hz).
So you can do:
1sensor on 1dongle at 100Hz
3 sensors on 1dongle at 30Hz each.
Basically it seems like your setup is outside the supported range.
This is a little bit strange what you are saying. During our tests when there was no connection issues (very rare case) we were able to connect up to 5 sensors to one BT module (mostly to this embedded in RPi 4) with 100Hz data rate and keep stable data flow. The only issues was when we were reconnecting sensors which I described in first post.
Nevertheless even if we were connecting only one sensor to hub then sometimes we were occuring issue with low/zero sample rate.
I think you will have to do a few things:
1. Make sure you write smart auto reconnecting code
2. Make sure your dongles/setup is at acceptable BLE speeds
Ad 1. I cannot do "Smart auto reconnecting code" as when I'm calling yours API it hangs somewhere in the C++ lib.
Ad 2. I'm using USB dongles provided with MetaBase HUB so I'm assuming that you are selling something which is well tested with yours devices.
I've trace one issue during last night investigation. Aditional four BLE dongles that I buy had same MAC address. After changing it by using this tutorial some connection issues are gone but not all so Ad 1 is still valid.
I think you really need to beef up your setup. We give you the tools to get started but at the end of the day, you are responsible for creating a deployable device (we just sell development boards and give you some open source APIs with some examples).
The MetaHub is NOT meant for real life deployment...it's just a PI...essentially a computer for kids! If you are building something robust on a system for kids...well then...maybe you should rethink things.