This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

several uart device send data to one android phone simultaneously

Sorry,my English is poor. I Now,I have four uart BLE device. Every device sends data in frequency 20Hz. And I also have a android phone. I hope that the phone could receive the data from the four devices simultaneously. I read this question link text . And I add 3 BluetoothGatt objects and callbacks , so every device has a BluetoothGatt object and a callback. I modify the nrfUARTv2.apk to achieve it. But I failed. Phone only reveived data from one device that I connected recently. And am I doing this right? Please give me some suggestions. I'm looking forward to your help. Thank you!

Parents
  • Hi, I don't think there is anything 'tricky' to be done. It should work as you described. You scan for devices, connect to the first one and provide a callback object, then connect to another one and give a different callback object (it may be a second object of the same class, I don't know if it can be the same object), and repeat it for all your devices. Enable notifications for all devices, remember to keep all BluetoothGatt instances, as you have to send 0x0100 to a descriptor on each of them. Maybe you passed the same callback object in connectGatt method and that's why it's not working? It's hard to say without a code.

Reply
  • Hi, I don't think there is anything 'tricky' to be done. It should work as you described. You scan for devices, connect to the first one and provide a callback object, then connect to another one and give a different callback object (it may be a second object of the same class, I don't know if it can be the same object), and repeat it for all your devices. Enable notifications for all devices, remember to keep all BluetoothGatt instances, as you have to send 0x0100 to a descriptor on each of them. Maybe you passed the same callback object in connectGatt method and that's why it's not working? It's hard to say without a code.

Children
  • Thanks for your reply. The code of nrfUARTv2.apk, there is a mDevice(BluetoothDevice), a mBluetoothGatt(BluetoothGatt) and a mGattCallback(BluetoothGattCallback). So I copy it and use the mDevice2, mBluetoothGatt2 and mGattCallback2 to connect another BLE device. The two GattCallback use the same broadcastUpdate. Maybe my android skill is not good, so I neglect other error. And another question, "simultaneously" means really simultaneously or in turn.Thank you.

  • @mosiyao:

    Could you let me know which error did you have as you mentioned " I neglect other error".

    Have you made sure you have enabled CCCD (call enableTXNotification() ) on both devices ?

    Also when you fetch the event to broadcastUpdate, you need to have a way to distinguish between two device (you can use different action string)

    If you try to read a characteristic's value, would you receive any value ?

  • Thank you very much. "Other error" means basic android rules, not bluetooth. I copy the code of enableTXNotification() and put the copy in enableTXNotification(), and I change names "RxService2, mBluetoothGatt2, TxChar2, descriptor2".But I use the same action string. I didn't receive anything. I'll try out more. Thanks for your suggestions.-.-

Related