1. Introduction
RFCOMM provides a serial (9-pin RS-232) Simulation Based on The L2CAP protocol, the latest specification is v1.2, supporting up to 60-channel communication connections between two bluetooth devices
RFCOMM supports two device types, but does not differentiate them
Type 1: DTE, communication terminal (such as computer or printer)
Type 2: DCE, Communication Node (modem)
Shows the connection method.
2. Overview of services 2.1 RS-232 control signals
RFCOMM simulates the 9-pin RS-232 interface, as shown below
Pin |
Circuit name |
102 |
Signal common |
103 |
Transmit data (TD) |
104 |
Initialized ed 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.2 null modem emulation
When the status information of the non-data path is transmitted, the DTE and DCE devices are not differentiated,
The corresponding signal is replaced by the control signal.
GSM 07.10 Signal |
Corresponding RS-232 control signal |
RTS |
DSR, DTr |
RTR |
RTS, CTS |
IC |
Ri |
DV |
DCD |
When two similar devices (such as DTE) are interconnected, a null modem is created when GSM 07.10 transmits control signals.
Displays the null modem created when two DTE devices are connected.
2.3 multi-serial port simulation 2.3.1 multi-serial port Simulation Between Two devices
Two Bluetooth devices that use RFCOMM can enable multiple serial port simulation at the same time
RFCOMM supports 60 channels, but the actual data that a device can open depends on the implementation.
A Data Link identifier (dlci: Reference address field D + serverchannel in the frame format) identifies a persistent connection between a customer and the server
Dlci is consistent in RFCOMM sessions between two devices
The dlci length is 6 bits, and its available value range in RFCOMM is 2 ~ 61
Dlci 0 is the Control CHannel
Dlci 1 cannot be used because of the server channel Concept
Dlci 62-63 Reserved
In an RFCOMM Session, the customer and the server can be distributed at both ends of the communication, and each end of the customer can independently initiate a communication connection.
Therefore, the concept of RFCOMM server channel can be used to divide the dlci value range space between two devices that are in communication.
2.3.2 multi-simulation serial port and multi-Bluetooth device (optional)
If the bluetooth device supports multi-serial simulation, different BT devices can be used at both ends of the communication connection.
The RFCOMM entity must be able to run multiplexing sessions. Each multiplexing uses L2CAP channel identifier (CID) to distinguish
3. Service Interface Description
RFCOMM aims to define a protocol that can utilize the simulated serial port.
RFCOMM Reference Model and corresponding description
4. RFCOMM Frame Type
RFCOMM supports the following frame types:
Frame types |
Sabm-set asynchronous balanced mode (startup command) |
UA-Unnumbered acknowledgement (response when connected) |
Disc-Disconnect (disconect command) |
DM-disconnected mode (response to a command when disconected) |
Uih-Unnumbered information with header check |
Sabm, UA, DM and disc are "low-level" Control Frames
Uih frames with dlci 0 are used to transmit control information, while uih frames with dlci not 0 are used to transmit data.
5. RFCOMM frame format
RFCOMM frame format:
5.1 address field
EA (extern address) field: In RFCOMM, it is 1
C/R (command/Response) field: indicates whether the frame is a command or response. The setting method is shown in.
Dcli: Direction bit and server channel. Generally, initator sets the D bit (that is, the second bit) to 1, while the responser sets it to 0.
Therefore, the dcli value of initator is always the base (, 7 ,..., 61), while responser is an even number (2, 4, 6 ,..., 60)
5.2 Control Field
The control field is used to identify the frame type and is a correlation value.
Where P/F is the poll/final bit, in commands, it is called the P bit, while in responses it is called the f bit
When the sent Command requires a phase, Set P to 1. When receiving such a command, the receiver needs to immediately respond and set F to 1.
If a sabm or disc frame with P/F position 0 is received, the receiver discards them.
The setting of P/F is not considered for DM frames.
5.3 length field
The length field is determined by the length Expert Advisor.
When EA is 1, the length is 7 bits (0 ~ 127)
When EA is 0, the length is 15 bits (0 ~ 32767)
The default RFCOMM frame length is 127, and the maximum length is 32767.
5.4 Data Field
The data field only exists in the uih frame, and its length is limited by the MTU of L2CAP.
5.5 FCS Field
It is used for the receiver to check whether the received data is correct, and the verification principle adopts the Cyclic Redundancy verification CRC-8.
For sabm, disc, UA, and DM frames, the address, control, and length fields are calculated using the FCS.
For a uih frame, the address and control field is calculated by the FCS.
6. multiplexor Frames
Multiplexorm commands and responses in dlci = 0 in the send is used to control RFCOMM connection
There are seven types of commands or responses
Commands/responses |
PN-DLC parameter negotiation |
Test-test command |
Fcon/fcoff-Flow Control on/off command |
MSC-modem STATUS Command, used for Flow Control |
RPN-remote port negotiation |
RLS-remote line status |
NSC-Non supported command (response only) |
Note: When receiving an unsupported command, it should respond to NSC
These commands are encapsulated by using the uih frame (dlci = 0 ).
You can encapsulate multiple commands in one rfcomm frame, or you can split one command into multiple RFCOMM frames.
The format of multiplexor frames is as follows:
Tip: For details about the multiplexor frames format, see Section 10.6 of <rfcomm_tutorial>.