MuSAELab/BLE-Toolkit-LabVIEW

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?

labview

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:

  1. Reset dongle: INI section (3 blocks)
  2. Connect to Device1: Connect and get its table Table1 (2 blocks)
  3. Connect to Device2: Connect and get its table Table2 (2 blocks)
  4. Configure UUID for Device 1, using Table 1 (3 blocks)
  5. Configure UUID for Device 2, using Table 2 (3 blocks)
  6. 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?

image

Currently, it fills "Device name 2" textbox with a random payload instead of the device's name.

And the actual Payload textbox doesn't work at all when I just click run. But if I enable the "highlight execution" mode on the block diagram panel, then it works but of course extremely slow.

image

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.

I have found a way to connect multiple devices one by one. I had to change the order of the blocks and delete unnecessary blocks. It does work and can receive 200 Hz data pretty well.

Thanks again for providing such an amazing library and helping out!

image