问题
I'm working on an Android Bluetooth project to send and receive data from a custom made hardware. I used Bluetooth Chat Sample in SDK as basis.
I realized that there is no way to change baud rate on Client (Android phone) and baud rate will depend on hardware. I tried setting different baud rates on hardware and none met our expectations;
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.
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
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).
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
回答1:
Firstly changing the baud rate on the Bluetooth RFCOMM / Serial Port protocol should not make a difference, since it is not a real serial 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)
The factors that effect the data rate over SPP will be the size of the packets, the practical max 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.
The main issue here for you seems to be the practical throuput you can achieve over Bluetooth. If you are using the non-EDR versions 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 RFCOMM protocol overhead you could get max around 450-500 Kbps.
If you have access to both devices that are +EDR I.e Bluetooth version 2.0 or more + EDR then you can expect application throuput in the order of 1.2 to 1.5 Mbps ( theoretical over the air bit rate being 2.0 or 3.0 Mbps)
来源:https://stackoverflow.com/questions/14524866/android-bluetooth-serial-rfcomm-low-baud-rate-slow-transmission