Bluetooth
The GM-3568JHF development board integrates the RTL8723DU wireless communication module, which not only provides WIFI functionality but also integrates Bluetooth functionality. The Bluetooth module supports Classic Bluetooth and Bluetooth Low Energy (BLE) protocols, providing rich short-range wireless communication capabilities for the development board.
1 Bluetooth Module Overview
1.1 RTL8723DU Bluetooth Technical Specifications
| Parameter | Specification |
|---|---|
| Chip Model | Realtek RTL8723DU |
| Bluetooth Version | Bluetooth 4.2 |
| Protocol Support | Classic Bluetooth + BLE (Bluetooth Low Energy) |
| Operating Frequency Band | 2.4GHz ISM band (2.402~2.480GHz) |
| Modulation | FHSS (Frequency-Hopping Spread Spectrum) |
| Transmit Power | Class 2 (up to 4dBm) |
| Receive Sensitivity | -90dBm @ 0.1% BER |
| Transmission Range | 10 meters (Class 2) |
| Data Rate | Up to 3Mbps (EDR) |
1.2 Driver and Software Support
Linux Bluetooth Protocol Stack
- BlueZ: Standard Linux Bluetooth protocol stack
- Kernel Support: Native kernel driver support
- User-space Tools: bluetoothctl, hciconfig, hcitool, etc.
- D-Bus Interface: Standard D-Bus API interface
Supported Application Scenarios
- Audio Devices: Bluetooth headset and speaker connections
- Input Devices: Bluetooth keyboard and mouse
- File Transfer: File transfer between phones and computers
- Serial Communication: Bluetooth serial data transmission
- IoT Applications: BLE sensor data collection
2 Bluetooth Connection Configuration
The development board has been adapted for the RTL8723DU module, and the Bluetooth driver and protocol stack have been configured.
2.1 Connection Test
The test requires a smartphone (an Android phone is used in this section). Turn on the Bluetooth function of the phone, turn on the Bluetooth function of the development board, and then connect, as shown in the figure below:

Development board side:

Phone side:

2.2 Data Send/Receive Test
First, create a bluetooth_test.txt file in the home/linaro folder with the content: bluetooth_test

1) File Sending
The development board sends bluetooth_test.txt to the phone via Bluetooth, and the phone receives it
Development board side:

Phone side:

Check whether the file contents are consistent:

2) File Receiving
The phone sends bluetooth_test.txt to the development board via Bluetooth, and the development board receives it
Phone side:


Development board side:


2.3 Command-line Bluetooth Configuration
hciconfig and hcitool
# 查看蓝牙适配器信息
hciconfig -a
# 启用蓝牙适配器
sudo hciconfig hci0 up
# 设置可发现模式
sudo hciconfig hci0 piscan
# 扫描附近设备
hcitool scan
# 查看设备信息
hcitool info XX:XX:XX:XX:XX:XX
# 检查连接状态
hcitool conPairing and Authentication
# 使用 simple-agent 配对
sudo simple-agent hci0 XX:XX:XX:XX:XX:XX
# 或使用 bluez-simple-agent
bluez-simple-agent hci0 XX:XX:XX:XX:XX:XX3 Bluetooth Audio Applications
3.1 Connecting Bluetooth Audio Devices
Install Audio Support Packages
# 安装 PulseAudio 蓝牙模块
sudo apt-get install pulseaudio-module-bluetooth
# 重启 PulseAudio
pulseaudio -k
pulseaudio --startConfigure Audio Devices
# 查看音频设备
pactl list short sinks
# 设置默认音频输出
pactl set-default-sink bluez_sink.XX_XX_XX_XX_XX_XX.a2dp_sink
# 播放测试音频
speaker-test -t wav -c 2
# 使用 aplay 播放音频文件
aplay /usr/share/sounds/alsa/Front_Left.wav3.2 A2DP Audio Streaming
# 连接 A2DP 设备后,检查音频配置
bluetoothctl
[bluetooth]# info XX:XX:XX:XX:XX:XX
# 在 PulseAudio 中查看蓝牙音频设备
pactl list sinks | grep -A 10 bluez
# 播放音频到蓝牙设备
mpg123 -a bluez_sink.XX_XX_XX_XX_XX_XX.a2dp_sink music.mp34 BLE (Bluetooth Low Energy) Applications
BLE Device Scanning and Connection
Using gatttool
# 扫描 BLE 设备
sudo hcitool lescan
# 连接 BLE 设备
gatttool -b XX:XX:XX:XX:XX:XX -I
# 在 gatttool 交互模式中:
[XX:XX:XX:XX:XX:XX][LE]> connect
[XX:XX:XX:XX:XX:XX][LE]> primary # 列出主要服务
[XX:XX:XX:XX:XX:XX][LE]> characteristics # 列出特征值
[XX:XX:XX:XX:XX:XX][LE]> char-read-hnd 0x0010 # 读取特征值
[XX:XX:XX:XX:XX:XX][LE]> char-write-req 0x0010 0100 # 写入特征值Using bluetoothctl for BLE Operations
bluetoothctl
[bluetooth]# scan on
[bluetooth]# connect XX:XX:XX:XX:XX:XX
[bluetooth]# gatt list-attributes
[bluetooth]# gatt select-attribute /org/bluez/hci0/dev_XX_XX_XX_XX_XX_XX/service0010/char0011
[bluetooth]# gatt read
[bluetooth]# gatt write "0x01 0x02"5 Troubleshooting
5.1 Bluetooth Module Cannot Be Recognized
Inspection Steps:
# 检查 USB 设备
lsusb | grep Realtek
# 检查蓝牙适配器
hciconfig -a
# 检查内核模块
lsmod | grep bluetooth
# 手动加载蓝牙模块
sudo modprobe bluetooth
sudo modprobe btusb
# 检查蓝牙服务状态
sudo systemctl status bluetooth5.2 Device Pairing Failed
Possible Causes and Solutions:
# 重置蓝牙适配器
sudo hciconfig hci0 reset
# 清除配对缓存
sudo rm -rf /var/lib/bluetooth/*/cache
# 重启蓝牙服务
sudo systemctl restart bluetooth
# 检查认证代理
ps aux | grep agent5.3 Audio Connection Issues
Resolution Steps:
# 检查 PulseAudio 模块
pactl list modules | grep bluetooth
# 重新加载蓝牙模块
pactl unload-module module-bluetooth-discover
pactl load-module module-bluetooth-discover
# 检查音频配置文件
bluetoothctl
[bluetooth]# info XX:XX:XX:XX:XX:XX5.4 Unstable Connection
Optimization Suggestions:
# 检查信号强度
hcitool rssi XX:XX:XX:XX:XX:XX
# 调整功率管理
echo 'SUBSYSTEM=="usb", ATTRS{idVendor}=="0bda", ATTRS{idProduct}=="d723", ATTR{power/autosuspend}="-1"' | sudo tee /etc/udev/rules.d/50-usb-bluetooth.rules
# 重启 udev 服务
sudo udevadm control --reload-rules5.5 File Transfer Failed
Inspection and Repair:
# 检查 OBEX 服务
sudo systemctl status obex
# 安装 OBEX 工具
sudo apt-get install obexftp obex-data-server
# 启动 OBEX 服务
obex-data-server --auto-accept