Electronic – Difference between RFCOMM and L2CAP Protocol in Bluetooth Communication

bluetooth low energyraspberry pi

I just started learning the essentials of Bluetooth Programming since it is heavily used in my project.

I have an nRF52 Development Board and a Raspberry Pi 3 – Model B (with built-in bluetooth). I want to make the 2 devices communicate with one another for now for prototype development (e.g., Exchange single bytes of data).

In section 1.2.1 Choosing a communication partner of a useful PDF that I have come across: (https://people.csail.mit.edu/rudolph/Teaching/Articles/BTBook-march.pdf), it introduced 2 transport protocols:

  • RFCOMM
  • L2CAP

I want to know the main comparison points between the two so I may be able to decide which of them is the suitable protocol to be used. The resource above, of course, stated important information about the two but as a novice bluetooth developer, I may not able to visualize them that much.

Can anyone compare and contrast the two? Thank you in advance.

Best Answer

I'm afraid your reference is outdated. It details Bluetooth related matters as of 2005 (if date is correct). You are working with nRF52, a BLE SoC from 2015. They are both from the Bluetooth family, but have nothing in common.

Bluetooth as of 2005 was using L2CAP as a transport layer (think TCP), and RFCOMM was a protocol above L2CAP for serial port emulation (roughly).

Bluetooth Low Energy (or BLE, marketed as Bluetooth Smart), is a protocol introduced by Bluetooth SIG in 2010 for Bluetooth 4.0. BLE uses L2CAP, but not the upper layers like RFCOMM, only ATT and GATT protocols. This is what is implemented in nRF52.

You should probably create a custom GATT Service with a Characteristic holding the bytes of data you want to exchange. There are numerous examples in the Nordic SDK about this.