蓝牙串口设置, 关于速率的问题
http://stackoverflow.com/questions/5576237/android-bluetooth-serial-rfcomm-spp-how-to-change-the-baud-rate
There'sno good information on the internet about this - and lots of it is wrong - don't trust anyone!
Inparticular, these two things are not true:
· RFCOMM and SPP (Serial Port Profile) aretwo names for the same thing. (They are however very closely related.)
· There's no need to set the baud rate of anRFCOMM / SPP connection.
Here is what I havefound:
Bluetoothserial connections are made as described in the SPP using RFCOMM. RFCOMMis a connection that runs over L2CAP and allows sending serial data and controlparameters in frames. It is heavily based on an ancient standard called TS 07.10. SPPis the bluetooth profile.
Thisframing also allows you to send out-of-band data for things like controllingserial signals (DTR, CTS, etc) and for setting the baud rate.
From the SPPspecification:
DevAmay inform DevB of RS232 port settings with the Remote Port NegotiationCommand, directly before DLC establishment. There is a requirement to do so ifthe API to the RFCOMM adaptation layer exposes those settings (e.g. baud rate,parity).
SadlyAndroid doesn't expose this functionality at all. I suppose it may be possibleto send the Remote Port Negotiation command ourselves but I'm pretty sure thatwould require reimplementing RFCOMM which requires access to L2CAP thatwe don't have.
TheRemote Port Negotiation command is detailed here page31. Note "There are default values assigned on all parameters, if no negotiation is performed, the default value is chosen."
Therefore it isimpossible to set the baud rate as desired on Android. It will use the defaultbaud rate that your bluetooth adapter uses (probably 9600).
Alsonote that Windows does support setting the baudrate of bluetooth adapters.