Multiple bluetooth connection

后端 未结 8 1855
后悔当初
后悔当初 2020-11-28 19:46

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 f

相关标签:
8条回答
  • 2020-11-28 20:03

    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 ?

    0 讨论(0)
  • 2020-11-28 20:05

    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.

    0 讨论(0)
  • 2020-11-28 20:15

    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.

    0 讨论(0)
  • 2020-11-28 20:17

    You can try my lib for multiple bluetooth connection :

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

    0 讨论(0)
  • 2020-11-28 20:17

    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 :)

    0 讨论(0)
  • 2020-11-28 20:17

    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
    0 讨论(0)
提交回复
热议问题