Connect multiple devices
Closed this issue · 5 comments
I have tried connecting to multiple BLE devices using one dongle to acquire in-sync data from my sensors.
However, the dongle first connects to one device, receives data for a brief moment, disconnects, and then connects to the other device, receiving data from it until stopped.
Here is the block design. What am I doing wrong?
Blocks for the BLE-Toolkit-LabVIEW are not designed to be executed in parallel, I think this is the root of the behaviour. Try to put all the blocks in series:
- Reset dongle:
INI
section (3 blocks) - Connect to Device1: Connect and get its table Table1 (2 blocks)
- Connect to Device2: Connect and get its table Table2 (2 blocks)
- Configure UUID for Device 1, using Table 1 (3 blocks)
- Configure UUID for Device 2, using Table 2 (3 blocks)
- While loop: Do only one reading, and depending on the payload, it's possible to identify which devices was the sender (Only one block in the while loop)
Thank you for the reply @rcassani ! Do you mean something like this?
I do send out sensor ID in the payload, I can use it to identify the received packet. However, sensors are sending at least 100Hz data each. Do you think this method can handle such a data rate?
Hi @selman-nus, after checking the code, I found that behaviour you see has its origin in the fact the connection handle is ignored to select the correct response to a command. The Toolkit assumes the same connection handle as it was developed thinking only in one device.
For example, in the VI ble_read_by_handle.vi
, the VI in charge to gettings the response is ble_rsp_attclient_read_by_handle.vi
, which calls ble_read_specific_message.vi
and this assumes the response message is the expected when three things are correct: MessageType
, CommandClass
and MessageID
. However, it is necessary to check also the payload to verify that it has the same connection handle as the one used to send the request command. Unfortunately, I won't be able to update this in the code for the next 2 or 3 weeks. As an temporary solution, your acquisition could be done with two dongles.