Android的蓝牙聊天示例应用程序 - 多个连接 [英] Android Bluetooth Chat sample app - multiple connections

查看:444
本文介绍了Android的蓝牙聊天示例应用程序 - 多个连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能建立在Android蓝牙聊天示例应用程序连接多一个人的时间,并有一个迷你聊天室?那能意味着什么?

Is it possible to set up the Android Bluetooth Chat sample app to connect more than one person at a time, and have a mini chat room? What would that entail?

推荐答案

TL;博士版本:蓝牙很烂这一点,不使用它,用wifi相反,可能是由网络后台支持

tl;dr version: Bluetooth sucks for this, don't use it, use wifi instead, probably backed by a web backend.

我在一个社交无线网络的研究项目的利益,这些年来彻底调查这一问题。我一般建议是:它不会超过两/三个人的工作。蓝牙只是没有设计与无线对等网络的初衷。

I have investigated this issue thoroughly throughout the years in the interests of a social wireless network research project. My general advice is: it doesn't work with more than two / three people. Bluetooth just isn't designed with wireless peer to peer networks in mind.

在一般情况下,它似乎是廉价的蓝牙控制器包括在Android设备(尤其的HTC的设备,IIRC)真的不处理任何超过两个或三个连接的时间。我不能确定这是否是硬件或固件问题,但我可以讲述一些基本的轶事。我正在努力实现这个想法在SDK水平(即无固件的修改)在2011年左右的开始,能够得到同行获得两个额外的连接(即,三个设备,每个连接到其他二)一段几分钟到一个小时的连接工作之前会突然死去,插座将无法使用,需要重新连接。不幸的是,20个分钟是一个上限,并且通常这是不可能得到超过连接的 1 的其它设备都可靠地

In general, it seems that the cheap Bluetooth controllers included on Android devices (especially HTC's devices, iirc) don't really handle any more than two or three connections at a time. I'm unsure if this is a hardware or firmware problem, but I can recount some basic anecdotes. I was working to implement this idea at the SDK level (i.e., without firmware modifications) around the beginning of 2011, and was able to get a peer to get two additional connections (i.e., three devices, each connecting to the other two) to work for a period of a few minutes to an hour before the connections would suddenly die and the socket would become unusable, requiring reconnection. Unfortunately, 20 minutes was an upper bound, and generally it was impossible to get connections to more than one other device at all reliably.

该项目的目标是支持多人互相在后台默默的互动,但是这没有实现,相反,我们抛弃了蓝牙和去带wifi来代替,该工作太多的的更好。在抽象的,我觉得人认为蓝牙作为一种可能的媒介可靠的点对点通信,但它是不是真的这样设计的:它更多用于小型设备(想想耳机)之间的短距离通信的媒介

The goal of the project was to support multiple people interacting with each other silently in the background, but this never materialized, instead we ditched Bluetooth and went with wifi instead, which worked much much better. In the abstract, I think people view Bluetooth as a possible medium for reliable peer to peer communication, but it wasn't really designed that way: it's more of a medium used for short range communication between small devices (think headsets).

请注意,如果你想这样做,设备可连接的最大数目是固定的,因为根据蓝牙规范,一个微微网最多支持七个设备。 (见维基百科的文章。)

Be aware that if you want to do this, the maximum number of devices to which you can connect is fixed, because as per the Bluetooth spec, a piconet supports a maximum of seven devices. (See the wikipedia article.)

要求的变化很简单:你使用的不同的的UUID的每个设备。这可以实现多种方式,使用出在哪里,你在越来越时尚分配的UUID和连接到网络时,尝试每陆续带交换机制,或简单的方案。

The required change is simple: you use a different UUID for each device. This can be implemented a number of ways, using an out of band exchange mechanism, or simple scheme where you assign UUIDs in an increasing fashion and when connecting to the network, try each in succession.

下面是一些有关谷歌组线程:

Here are some relevant Google groups threads:

  • <一个href="https://groups.google.com/forum/?fromgroups#!searchin/android-developers/bluetooth%2420micinski/android-developers/u5oPF2ZkxlI/RkOXR2A3PtYJ">Bluetooth点对点网络
  • 多在Android蓝牙
  • 连接
  • Bluetooth peer to peer networks
  • Multiple connections on Android Bluetooth

我记得张贴一个更复杂,详细说明如何做到这一点(与code),我可能会挖掘以及..如果我能找到它。它应该是从2010年年底或2011年初。

I remember posting a more elaborate one detailing how to do this (with code) that I might dig up as well.., if I can find it. It should be from late 2010 or early 2011.

因此​​,答案是,在抽象的,是的,你可以的尝试的做到这一点,通过使用多个的UUID(使用一前一后,就是这样,你必须使用一些分配,尝试其他协议)。然而,在实践中,大量的试验和错误之后,这并不能真正为你可能想用它来工作,这是一个的很多的更好的去与互联网后端来代替。顺便说一句,这也是很好的另一个原因是,大多数用户并不真正喜欢打开他们的蓝牙,生怕自己的电池被抽干。

So the answer is, in the abstract, yes, you can try to do this, by using multiple UUIDs (after you use one, that's it, and you have to try another using some assignment protocol). However, in practice, after a lot of trial and error, this doesn't really work for what you probably want to use it for, and it's a lot better to go with an internet backend instead. By the way, this is also good for another reason, most users don't really like to turn on their Bluetooth for fear of their battery being drained..

这篇关于Android的蓝牙聊天示例应用程序 - 多个连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆