通过蓝牙连接多个设备到一个设备蓝牙、设备、多个

2023-09-05 00:02:39 作者:人生若如初見

我想创造一个游戏,你必须通过蓝牙连接多个设备(4+)到主设备(例如平板电脑)。会有两个应用程序,一主一来,所有数据将被发送的手机,并在手机。 是,即使可能吗?

I would like to create a game, where you must connect multiple devices (4+) to a main device (ex. a tablet) via Bluetooth. There would be two apps, a main one to which all data would be send from the phones, and to the phones. Is that even possible?

推荐答案

是的,这是可能的。在最低水平蓝牙可让您连接多达7设备连接到一个主设备。我已经做到了这一点,它已经为我工作很好,但只有在其他平台(Linux),在那里我有很多手动控制的 - 我从来没有试过,在Android上也有一些可能出现的并发症,所以你需要做一些测试是肯定的。

Yes, that is possible. At its lowest level Bluetooth allows you to connect up to 7 devices to one master device. I have done this and it has worked well for me, but only on other platforms (linux) where I had lots of manual control - I've never tried that on Android and there are some possible complications so you will need to do some testing to be certain.

其中一个问题是,你需要平板电脑的主机和Android不给你这个任何明确的控制权。很可能,这不会是因为一个问题 *当您尝试第二个设备连接到它的平板电脑将自动成为高手,或 *您将能够通过控制主/从角色如何设置您的套接字连接

One of the issues is that you need the tablet to the master and Android doesn't give you any explicit control of this. It is likely that this won't be a problem because * the tablet will automatically become the master when you try to connect a second device to it, or * you will be able to control the master/slave roles by how you setup your socket connection

我会警告虽然使用蓝牙手机的大多数应用程序都不会尝试多个连接和蓝牙可以是一个有点脆弱,如:如果两个设备已经有一些其他的应用程序,蓝牙连接 - 如何可能会影响角色

I will caution though that most apps using Bluetooth on mobile are not attempting many simultaneous connections and Bluetooth can be a bit fragile, e.g. what if two devices already have a Bluetooth connection for some other app - how might that affect the roles?