I tried to advertise a BluetoothLE service using Qt today. I started by testing the Bluetooth Low Energy Heart Rate Server Example and it worked just fine on my Android phone. On my Ubuntu 18.04 Laptop though, I could not get it to work.
When I run the example as root, I get the error qt.bluetooth.bluez: received advertising error
.
After enabling debug messages, I got this log:
qt.bluetooth: Using BlueZ kernel ATT interface
qt.bluetooth.bluez: Bluez 5 detected.
qt.bluetooth.bluez: Starting to advertise
qt.bluetooth.bluez: sending command; ogf: 8 ocf: 7
qt.bluetooth.bluez: command sent successfully
qt.bluetooth.bluez: HCI event triggered, type: e
qt.bluetooth.bluez: command 7 failed with status 12
qt.bluetooth.bluez: reading power level failed, leaving it out of the advertising data
qt.bluetooth.bluez: advertising parameters: "000800080000000000000000000700"
qt.bluetooth.bluez: advertising data: "18020106100948656172745261746553657276657203030d1800000000000000"
qt.bluetooth.bluez: scan response data: "15100948656172745261746553657276657203030d1800000000000000000000"
qt.bluetooth.bluez: sending command; ogf: 8 ocf: 10
qt.bluetooth.bluez: command sent successfully
qt.bluetooth.bluez: HCI event triggered, type: e
qt.bluetooth.bluez: command 10 failed with status 12
qt.bluetooth.bluez: Advertising disable failed, ignoring
qt.bluetooth.bluez: sending command; ogf: 8 ocf: 6
qt.bluetooth.bluez: command sent successfully
qt.bluetooth.bluez: HCI event triggered, type: e
qt.bluetooth.bluez: command 6 failed with status 12
qt.bluetooth.bluez: received advertising error
Does anybody know what all these error messages mean?
Thanks for help!
I ran into a similar issue when attempting to use https://github.com/nymea/nymea-networkmanager on Intel NUC devices. Any time it attempted to issue Bluetooth LE commands I would see 'command disallowed' via btmon.
Issuing hcitool cmd 0x03 0x000
would reset the device and get it to start advertising, but it would soon crash again right after. It appears that a lot of bluetooth changes were introduced in the 4.19 kernel and have been causing issues with LE system calls.
I was able to get it to work by using an older Ubuntu version with 4.15 kernel.
More details here https://github.com/nymea/nymea-networkmanager/issues/46