蓝牙串口设置

蓝牙串口设置, 关于速率的问题


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.

 


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值