java Android蓝牙串口RFCOMM低波特率/慢传输
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14524866/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Android Bluetooth Serial RFCOMM low baud rate / slow transmission
提问by Saro Ta?ciyan
I'm working on an Android Bluetoothproject to send and receive data from a custom made hardware. I used Bluetooth Chat Samplein SDK as basis.
我正在开发一个Android 蓝牙项目,用于从定制硬件发送和接收数据。我使用SDK 中的蓝牙聊天示例作为基础。
I realized that there is no way to change baud rateon Client (Android phone) and baud rate will depend on hardware. I tried setting different baud rateson hardware and none met our expectations;
我意识到无法在客户端(Android 手机)上更改波特率,并且波特率取决于硬件。我尝试在硬件上设置不同的波特率,但没有一个符合我们的预期;
Fastest i can get is 91Kbps (when baud rate is set to 2.7Mbps ~ 910Kbps). Using minimum baud rate (115Kbps) i get 43Kbps. I tried using different phones and it's the same. I need to transfer 170KB data per second to hardware.
我能得到的最快速度是 91Kbps(当波特率设置为 2.7Mbps ~ 910Kbps 时)。使用最小波特率 (115Kbps) 我得到 43Kbps。我尝试使用不同的手机,结果都是一样的。我需要每秒向硬件传输 170KB 数据。
Specifications
Protocol: Synchronized or generated data is sent to hardware using packages of maximum 520 bytes size. Hardware sends verify command after each package recieved and approved then phone sends next data package.
Client: Android 2.3.3, Samsung galaxy w i8150, Bluetooth v3.0, RFCOMM
Hardware: Custom, Bluetooth v2.1 BlueGiga WT11i
规范
协议:同步或生成的数据使用最大 520 字节大小的包发送到硬件。硬件在收到并批准每个数据包后发送验证命令,然后手机发送下一个数据包。
客户端:Android 2.3.3、Samsung Galaxy w i8150、Bluetooth v3.0、RFCOMM
硬件:Custom、Bluetooth v2.1 BlueGiga WT11i
I'm totally confused.. Can it possibly be a problem caused by Android or Bluetooth device on the phone? I wonder what the maximum baud rate is? Is there a way to speed up the transmission (like increasing maximum package size, or sending all packages without waiting for hardware verify commands).
我完全糊涂了..这可能是手机上的Android或蓝牙设备引起的问题吗?我想知道最大波特率是多少?有没有办法加快传输速度(比如增加最大包大小,或发送所有包而不等待硬件验证命令)。
Edit
After changing the package size to 4160 Bytes, Throughput has increased to 254Kbps. I'm trying to figure out the optimum package size to reach 1.5Mbps. I appreciate any suggestions
编辑
将包大小更改为 4160 字节后,吞吐量增加到 254Kbps。我试图找出达到 1.5Mbps 的最佳封装尺寸。我很感激任何建议
回答by Dennis Mathews
Firstly changing the baud rateon the Bluetooth RFCOMM/ Serial Port protocol should not make a difference, since it is not a realserial port but just an emulation. (Specific manufacturers could so something special with it but Bluetooth in general or Android does not use the parameter to control over the air bit rates)
首先更改蓝牙RFCOMM/ 串行端口协议的波特率应该没有区别,因为它不是真正的串行端口,而只是一个仿真。(特定的制造商可以用它来做一些特别的事情,但一般来说蓝牙或 Android 不使用该参数来控制空中比特率)
The factors that effect the data rate over SPPwill be the size of the packets, the practicalmax data rate you can get over Bluetooth and how fast the receiver is reading / and how frequently the sender is sending. For the packet size you could look at internal documentations or try different sizes to reach an optimal number for your application. Also I would suggest sending multiple packets(or all) until the stream can send data continuously, similarly read continuously.
影响SPP数据速率的因素将是数据包的大小、您可以通过蓝牙获得的实际最大数据速率以及接收器读取的速度/发送器发送的频率。对于数据包大小,您可以查看内部文档或尝试不同的大小以达到适合您的应用程序的最佳数量。此外,我建议发送多个数据包(或全部),直到流可以连续发送数据,类似地连续读取。
The main issue here for you seems to be the practical throuputyou can achieve over Bluetooth. If you are using the non-EDRversions as you have mentioned in your question the theoretical speed at the very low level is 720Kbps, and adding protocol and application over heads as well as RFCOMMprotocol overhead you could get max around 450-500 Kbps.
对您来说,这里的主要问题似乎是您可以通过蓝牙实现的实际吞吐量。如果您使用的是您在问题中提到的非EDR版本,那么非常低级别的理论速度为720Kbps,并且添加协议和应用程序开销以及RFCOMM协议开销,您可以获得最大大约450-500 Kbps。
If you have access to both devices that are +EDRI.e Bluetooth version 2.0 or more + EDR then you can expect application throuputin the order of 1.2 to 1.5 Mbps ( theoretical over the air bit rate being 2.0 or 3.0 Mbps)
如果您可以访问 + EDR即蓝牙版本 2.0 或更高版本+ EDR 的两个设备,那么您可以预期应用程序吞吐量为 1.2 到 1.5 Mbps(理论上的空中比特率为 2.0 或 3.0 Mbps)