最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【基本解决】android中是否支持蓝牙的串口的RTS/CTS

Bluetooth crifan 4929浏览 0评论

【背景】

需要折腾在android上通过蓝牙模块,然后外接HART猫,连接HART设备。

想要发送HART数据的话,需要物理上支持流控制。

所以需要去搞懂Android中的蓝牙,是否支持RTS/CTS。

【折腾过程】

1.网上找了半天,关于蓝牙支持串口的,好像是

RFCOMM

相关的内容:

Bluetooth protocols – Wikipedia, the free encyclopedia

RFCOMM | Bluetooth Development Portal

RFCOMM Protocol – Marko Bundalo

Serial Port Profile

得知:

蓝牙的SSP中,本身协议上是支持,模拟出来串口的各个引脚的功能的,包括流控制:

Pin

Circuit Name

102

Signal Common

103

Transmit Data (TD)

104

Received Data (RD)

105

Request to Send (RTS)

106

Clear to Send (CTS)

107

Data Set Ready (DSR)

108

Data Terminal Ready (DTR)

109

Data Carrier Detect (CD)

125

Ring Indicator (RI)

但是却不知道具体如何使用。

2.android中的蓝牙的解释:

Bluetooth | Android Developers

其中,默认好像就是:RFCOMM

但是后面,没搞懂:

两个设备,wired配对后,如何传输数据的。

3.去API:

BluetoothClass | Android Developers

BluetoothProfile | Android Developers

中找RTS等信息,也找不到。

4.貌似这里:

Serial Port Profile Emulation? – Free2move F2M01 Bluetooth RS-232 Plug Support Forum – Expansys USA

提到的就是:

"The F2M01 does support RTS/CTS signals for local hardware flow control. The Bluetooth specification has no support for sending the RTS/CTS signals over the air interface and this is because the RTS/CTS signals are only used locally. Each end is responsible for controlling the UART flow to prevent buffers from being overwritten."

即,蓝牙协议中的串口,不支持通过软件协议来控制RTS/CTS,而是要你自己的硬件这一端自己去控制。

不过,貌似看到协议中的解释,也没有完全看懂:

或许,本身也是可以通过协议控制RTS/CTS的,只是自己暂时没搞懂如何去做而已。

5.看了:

VIATOR Bluetooth Interface

中的“ COM port interface (virtual COM port in Windows) using Windows Bluetooth Serial Port Profile (SPP)”

才知道:

原来前面看到的Bluetooth Serial Port Profile,就是SSP。

然后再去找了下,结果还是找不到相关的资料,没有找到介绍如何在android中的用SSP这个profile去实现RTS/CTS的控制的。

6.唯一一个相关的帖子只有一个人去问的:

[android-developers] Bluetooth SPP control signals (DTR, DSR, RTS, CTS)

但是没有有效的解决办法。 

7.最后的最后是:

在android上使用蓝牙的ssp协议,当做串口处理,直接发送和接受数据即可。

而对应的HART协议所需要的流控制处理,本身已经有外接的蓝牙接口的HART猫,自动处理了。无需程序关心,即可正常的实现:

发送HART的command 0的数据,然后接收到对应的command 0返回的数据。

 

【总结】

目前的结论是:

无需android的app操心蓝牙的SSP中的流控制,即可写程序发送和接受HART协议的数据。

至于其他组合中,是否需要操心SSP模拟的出来的串口的流控制,就不太清楚了。

 

注:

已经实现的可工作的代码,可参考:

【记录】编写Android中的蓝牙模块驱动和底层HART设备

转载请注明:在路上 » 【基本解决】android中是否支持蓝牙的串口的RTS/CTS

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
83 queries in 0.168 seconds, using 22.10MB memory