Multiple bluetooth connection
Asked Answered
S

8

60

I want to connect 3 devices via bluetooth (My Droid must connect to 2 bluetooth devices). I 've connected my Droid to 1 device using Bluetooth chat.

How should I modify it for multiple bluetooth devices?

Sandy answered 15/10, 2010 at 14:28 Comment(0)
P
23

I was searching a way to connect 4 devices with bluetooth and I found the following.

http://groups.google.com/group/android-developers/browse_thread/thread/69d7810f6ef9bb7d

I'm not sure that this is what you want.

But in order to connect more than 2 devices using bluetooth you have to create a different UUID for each device you want to connect.

Follow the link to see code examples and a better explanation.

Picaresque answered 23/2, 2011 at 23:9 Comment(1)
The link in this answer is now dead.Laryngeal
A
12

You can try my lib for multiple bluetooth connection :

http://arissa34.github.io/Android-Multi-Bluetooth-Library/

Astrid answered 17/4, 2015 at 1:36 Comment(3)
Hey @Rami, Can you check this issue #46928473 , it's a kinda problem with the git project what u postedJolie
There is no problem with the git. There is only bad use of it :)Astrid
Thanks for your reply @Rami, Could you please help us to use it correctly, TIAJolie
A
6

Have you looked into the BluetoothAdapter Android class? You set up one device as a server and the other as a client. It may be possible (although I haven't looked into it myself) to connect multiple clients to the server.

I have had success connecting a BlueTooth audio device to a phone while it also had this BluetoothAdapter connection to another phone, but I haven't tried with three phones. At least this tells me that the Bluetooth radio can tolerate multiple simultaneous connections :)

Acidulous answered 15/10, 2010 at 21:16 Comment(1)
so you mean developer.android.com/guide/topics/connectivity/… is a mustSchertz
V
5

Please take a look at the Android documentation.

Using the Bluetooth APIs, an Android application can perform the following:

  • Scan for other Bluetooth devices
  • Query the local Bluetooth adapter for paired Bluetooth devices
  • Establish RFCOMM channels
  • Connect to other devices through service discovery
  • Transfer data to and from other devices
  • Manage multiple connections
Vinny answered 21/5, 2013 at 1:15 Comment(0)
B
5

Yes, your device can simultaneously connect to 7 other Bluetooth devices at the same time, in theory. Such a connection is called a piconet. A more complex connection pattern is the scatternet.

The reason it is limited to 7 other devices is because the assigned bit field for LT_ADDR in L2CAP protocol is only 3.

Bowerbird answered 21/8, 2015 at 21:29 Comment(0)
P
4

Two UE Boom Bluetooth speakers can form a stereo, which means the phone can stream simultaneously to two Bluetooth devices. The reason is Bluetooth 4.0 can support up to two synchronous connection oriented (SCO) links on the same piconet, and A2DP is based on SCO link.

Your demand "bluetooth chat" is based on SPP profile, and SPP is based on RFCOMM protocol. Luckily even Bluetooth 2.1 can support multiple RFCOMM channels, so yes, you can have multiple bluetooth connection to chat with each other.

Palembang answered 3/3, 2015 at 4:46 Comment(0)
M
2

You can take a look here ( this is not a solution but the idea is here)

sample multi client with the google chat example

what you have to change/do :

  • separate server and client logique in different classes

  • for the client you need an object to manage one connect thread and on connected thread

  • for the server you need an object to manage one listening thread per client, and one connected thread per client

  • the server open a listening thread on each UUID (one per client)

  • each client try to connect to each uuid (the uuid already taken will fail the connection => first come first served)

Any question ?

Mcdougal answered 9/2, 2015 at 15:23 Comment(0)
P
1

Not exactly true -- take a look at the specs summary

Logical link control and adaptation protocol (L2CAP)

L2CAP is used within the Bluetooth protocol stack. It passes packets to either the Host Controller Interface (HCI) or on a hostless system, directly to the Link Manager/ACL link. L2CAP's functions include:

  • Multiplexing data between different higher layer protocols.
  • Segmentation and reassembly of packets.
  • Providing one-way transmission management of multicast data to a group of other Bluetooth devices.
  • Quality of service (QoS) management for higher layer protocols.

L2CAP is used to communicate over the host ACL link. Its connection is established after the ACL link has been set up.

Polycythemia answered 1/1, 2013 at 14:16 Comment(1)
What exactly is "Not exactly true"? If you are commenting on another answer, you need to specify which one, or use the "add a comment" link.Inpour

© 2022 - 2024 — McMap. All rights reserved.