BLE Android send data to multiple connected devices

Viewed 273

I am connecting my Android device to two ble Arduino devices, they get the connection, but from my app side, just only one has discovered the Service and it has the Tx/Rx features activated, so I can not send data to both devices at the same time.

I am not sure if the best way it would be creating different Bluetooth services for each connection but using the same client UUID and Bluetooth UUID tx characteristic. How it would be the best way to send data to both?

Should I update also my Arduino code? Currently, the only difference of each Arduino code is the device name (AT+GAPDEVNAME) that I am assigning

Thanks in advance.

EDIT: The problem I meant to describe is that the method from the BluetoothLeService

@Override
public void onServicesDiscovered(final BluetoothGatt gatt, final int status) {...

It was not called for my two devices, so it was working fine just for one discovered service (not to confuse with the two connected devices). So, I had two properly connected devices, but only one of them it could to have the service connected and that device continued the flow: read/assign characteristics, properties, descriptors...

SOLUTION: After debugging and trying different ways for the above commented, the only thing that it works for me is to create a specific service for each device I want to connect. So I have created a BluetoothLeService1 and a BluetoothLeService2 and now I can send data to them.

0 Answers
Related