Bluetooth not working for Qt6 snap with kde-neon?

Hello,

I have built my Qt6 snap so far using

build-packages
  - pkg-config
  - qt6-base-dev
  - qt6-tools-dev
  - qt6-connectivity-dev
  - libqt6charts6-dev
  - libqt6opengl6-dev
  - libqt6serialport6-dev
  - libqt6svg6-dev
stage-packages:
  - libqt6core6
  - libqt6gui6
  - libqt6widgets6
  - libqt6charts6
  - libqt6serialport6
  - libqt6bluetooth6
  - libqt6help6
  - libqt6sql6-sqlite
  - libqt6svg6
  - libqt6printsupport6
plugs:
  - bluez
  - bluetooth-control

Now I want to switch to the KDE Neon 6 extension. This works, but Bluetooth fails there.

The connection shows

Interface                Plug                    Slot                            Notes
bluetooth-control        ubpm:bluetooth-control  -                               -
bluez                    ubpm:bluez              -                               -

I also already added

stage-packages:
  - bluez
  - dbus

but unfortunately this did not change anything.

What else is needed in KDE Neon environment to enable Bluetooth for Qt6?

No controller is detected when calling “QBluetoothLocalDevice::allDevices()” at the moment.

Thank you!

Are there any logs suggesting what may be wrong? If no, is there a way to enable logs from Qt?

The working variant shows

qt.bluetooth.bluez: Bluez 5 detected.

in the log.

This is missing in the neon version, so I guess it’s bluez related.

I can’t see any other errors/warnings.

Maybe sdpscanner is missing in kde neon?

On Linux, Qt Bluetooth uses a separate executable, sdpscanner, to integrate with the official Linux Bluetooth protocol stack (BlueZ).

https://doc.qt.io/qt-6/qtbluetooth-attribution-bluez.html

Edit: adding libqt6bluetooth6-bin includes sdpscanner but doesn’t work.

Really no one with any idea?

After including sdpscanner, did you observe any denials in the logs? Anything fails in particular with a meaningful error message? Is there perhaps some verbose mode you can try?

I’m sorry, but you haven’t provided much information other than doesn’t work, so as much as I’d like to help you, there’s very little to go on with.

did you observe any denials in the logs?

Which logs do you mean?

I tried snappy-debug and it shows only

= Seccomp =
Time: Jun 18 12:27:59
Log: auid=1000 uid=1000 gid=1000 ses=2 subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 pid=58776 comm="bt-test" exe="/snap/bt-test/x1/bin/bt-test" sig=0 arch=c000003e 203(sched_setaffinity) compat=0 ip=0x7f53514db6f1 code=0x50000
Syscall: sched_setaffinity
Suggestion:
* ignore the denial if the program otherwise works correctly (unconditional sched_setaffinity is often just noise)

Is there perhaps some verbose mode you can try?

Starting the app with QT_LOGGING_RULES=“*.debug=true” it shows only unrelated messages. The only related to Bluetooth is the already posted above “qt.bluetooth.bluez: Bluez 5 detected.” - which is missing with kde-neon.

I made a litte test package if somebody wants to try itself.

It contains a simple app

#include <QApplication>
#include <QMessageBox>
#include <QBluetoothLocalDevice>

int main(int argc, char *argv[])
{
        QApplication app(argc, argv);

        QList <QBluetoothHostInfo> bhil = QBluetoothLocalDevice::allDevices();

        if(bhil.count())
        {
                QMessageBox::information(NULL, "Snap BT-Test", QString("%1 Bluetooth controller found.").arg(bhil.count()));
        }
        else
        {
                QMessageBox::warning(NULL, "Snap BT-Test", "No Bluetooth controller found!");
        }

        return 0;
}

and the snapcraft.yaml

name: bt-test
version: 1.0
summary: BT-Test
description: Bluetooth Test for KDE-Neon
grade: stable
base: core24
confinement: strict

parts:

  bt-test:
    plugin: nil
    override-build: |
      export PATH=/snap/kde-qt6-core24-sdk/current/usr/bin/qt6:$PATH
      qmake
      make
      install -Dt $SNAPCRAFT_PART_INSTALL/bin bt-test
    source: bt-test
    source-type: local

apps:

  bt-test:
    command: bin/bt-test
    extensions:
      - kde-neon-6
    plugs:
      - bluez
      - bluetooth-control

to build the snap.

It simply shows the count of detected Bluetooth controllers and works fine native, as flatpak and snap without kde-neon.

Thanks!