You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Ubuntu(BlueZ)下Qt Bluetooth LE广播功能失效问题求助

Troubleshooting Qt BLE Advertising Errors on Ubuntu 18.04

Hey there! Let's break down why your Qt Bluetooth Low Energy Heart Rate Server example is failing on Ubuntu 18.04, even though it works fine on Android. The key error in your logs is command X failed with status 12—this corresponds to the HCI error code 0x0C, which means COMMAND_DISALLOWED. In plain terms, your Bluetooth adapter is rejecting the advertising commands Qt is sending. Here's what's likely going on and how to fix it:

Common Causes & Fixes

1. Your Bluetooth Adapter Doesn't Support BLE Peripheral Mode

Many older laptop Bluetooth adapters only support acting as a BLE "central" (client/device that connects to peripherals) and not as a "peripheral" (server/device that advertises services).

To check this:

bluetoothctl show

Look for Supported Features in the output. If you don't see LE Peripheral listed, your hardware can't act as a BLE server—you'll need to use a USB Bluetooth 4.0+ adapter that explicitly supports peripheral mode.

2. Outdated BlueZ Version

Ubuntu 18.04 ships with BlueZ 5.48 by default, which has known bugs and limitations with BLE advertising. Updating to a newer BlueZ version often fixes these issues.

To upgrade BlueZ:

  1. Add the official BlueZ PPA:
    sudo add-apt-repository ppa:bluetooth/bluez
    
  2. Update and install the latest version:
    sudo apt update && sudo apt install bluez
    
  3. Restart the Bluetooth service:
    sudo systemctl restart bluetooth
    

After upgrading, re-run your Qt example as root and see if the error persists.

3. Bluetooth Adapter Is In Use By Another Process

Background apps like Blueman or even the default Bluetooth manager might be locking your adapter, preventing Qt from sending advertising commands.

To fix this:

  1. Stop any Bluetooth-related processes:
    sudo systemctl stop blueman-applet
    sudo systemctl stop bluetooth
    
  2. Restart the Bluetooth service:
    sudo systemctl start bluetooth
    
  3. Run your Qt example immediately after, without opening any other Bluetooth tools.

4. Qt Backend Compatibility Issues

Older Qt versions (pre-5.12) have limited support for BlueZ 5.x's BLE peripheral features. If you're using an older Qt release, try upgrading to Qt 5.15 LTS or newer—this version has significant improvements to the BlueZ backend.

Advanced Debugging

If the above steps don't work, capture more detailed HCI logs to pinpoint the issue:

sudo hcidump -X

Run this command in one terminal, then start your Qt example in another. The hcidump output will show the exact HCI commands being sent and the adapter's responses, which can help identify if the problem is hardware-specific or a BlueZ/Qt bug.

内容的提问来源于stack exchange,提问作者Dorian Zedler

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.09 18:27:45