Introduction

Bluetooth in RDK, provides short range wireless connectivity between RDK devices and consumer electronics devices. RDK Bluetooth architecture is designed to support any Bluetooth stack.
The Bluetooth stack currently supports common Bluetooth profile such as A2DP, AVRCP, and can be extended to various profiles such as HID, PAN, etc.. Bluetooth may be enabled directly on capable RDK boxes or indirectly via USB-to-Bluetooth adaptor.

Features supported in RDK

Bluetooth feature in RDKFeature Descriptions
Audio EncodingDetail SBC (sub-band coding) and aptX encoding (Bluetooth chip, in software, or in SoC hardware).
Audio Output MutingThe Bluetooth audio output may be muted independently of other audio outputs (e.g. HDMI)
Audio Input (Settop as AD2P SNK)Using RDK device speakers over bluetooth i.e transmitting audio input back to a speaker connected with RDK device.
Audio Output RoutingDetail PCM audio routing to Bluetooth A2DP SRC, It uses H/W accelerations, S/W processing, RMF involvement on streaming audio/video contents.
Audio Output SourcesBluetooth audio may be different than HDMI audio (e.g. secondary audio program, application sourced audio such as Pandora, voice navigation audio, etc).
Dual DecodeSupports ability to simultaneously output one audio stream to HDMI and a different audio stream to Bluetooth
Power ControlIn future, the power state of each Bluetooth connected device and the Bluetooth subsystem can be controlled
Audio/Video Remote Control Profile (AVRCP)Controller (Remote Control) sends mute and volume commands to target. AV/C commands are defined by the 1394 trade association

Bluetooth in RDK - Block Diagram

Bluetooth in RDK provides Interface API and implementation to abstract Bluetooth stack and it provides 5 layers in the BTR (Bluetooth-RDK) stack.

1. Bluetooth daemon (Bluez based) - Interacts with kernel layer bluetooth modules
2. Bt-Ifce (Abstracts Bluez versions and servers as a HAL for other Bluetooth stacks) - Interacts with Bluez over DBus
3. Bluetooth HAL (BTRCore) - Provide API to perform Bluetooth operations by abstracting and simplifying the complexities of Bt-Ifce (& BLuez)
4. BTRMgr -  Utilize API's exposed by BTRCore to perform high level Bluetooth ops like Scan, Pair, Connect and achieve usecases like AudioOut. 
                       Exposes interfaces for external entities to perform BTRMgr related operation using IARM
5. ServiceManager [BluetoothService] - Interacts with BTRMgr based on Application requirements using IARM. Guide applications are interact with Service Manager.

6. RDK Apps/Diagnostics - HTML-5 based UI applications to make use of Bluetooth service using Service Manager APIs.


Bluetooth Architecture

Bluetooth Manager and Bluetooth HAL [BTRCore] is that Bluetooth Manager implements the BT HAL [BTRCore] API.  Then BT HAL [BTRCore] integrates and manages the BlueZ stack though the D-BUS interface.



BlueZ D-Bus Communication


Bluetooth - Service Manager

Bluetooth Service Manager component in RDK exposes Java scripts APIs against each of the Core Bluetooth features supported in the current implementation Javascript API's have been exposed to invoke IARM communication in the context of a browser which have a Javascript engine when we have HTML/HTML5/Browser based applications. Applications which don't have a Java-script engine should also be able to invoke Service manager methods/IARM methods to communicate with BTRMgr.

Provides methods and events to support the following features,

Contains Methods and Events to communicate with the Bluetooth manager
Service Manager will send event in case external Bluetooth adapter is inserted or removed, or it is requested for pairing.

List of API & Events

Refer to Bluetooth APIs for a complete list of Bluetooth APIs and events exposed by service manager.

Bluetooth Manager (BTRMgr)

Bluetooth Manager (An RDK component) interfaces with BlueZ through the D-Bus API, so there is no direct linking of the BlueZ library with Bluetooth Manager. BTRCore uses Bt-Ifce (which serves as Bluetooth HAL) interfaces with BlueZ.

BTRMgr Provides an interface to port any Bluetooth stack on RDK Provides an interface to port any Bluetooth application on RDK

The bluetooth_mgr daemon manages Bluetooth services in RDK. It uses IARM Bus to facilitate communication between the application and Bluetooth driver through Bluetooth Manager component. 

Bluetooth HAL Interface:

Bluetooth HAL interface Provides an software abstraction layer that interfaces with the actual Bluetooth implementation and/or drivers. RDK Bluetooth HAL layer enables projects to pick whatever Bluetooth profiles as per their requirements. Bluetooth HAL uses BlueZ5.42 stack which is a quite popular Linux Bluetooth library.

BlueZ In RDK

Some Bluetooth supported gstreamer plugins used by BlueZ 5:


Gstreamer Elements

Descriptions

sbcenc

Bluetooth SBC (sub-band coding) encoder

sbcdec

Bluetooth SBC (sub-band coding) decoder

sbcparse

The sbcparse element will parse a Bluetooth SBC audio stream into frames and timestamp them properly

avdtpsink

Bluetooth AVDTP sink

a2dpsink

Bluetooth A2DP sink for streaming audio

rtpsbcpay

RTP packet payload maker

Use Case : Bluetooth Device Discovery



RDK Bluetooth A2DP Use Case - Audio Streaming

API Documentation

 To know more about SoC/Application level APIs details use in RDK, refer the link  BLUETOOTH API Documentation