Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Sending "bluez" error to GUI
Forum Updated to NodeBB v4.3 + New Features

Sending "bluez" error to GUI

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 4 Posters 505 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Anonymous_Banned275
    wrote on last edited by
    #1

    I am trying to capture "blueZ" library errors to GUI.

    I have this connect code and like to at least acknowledge the error.
    I have the text = QBluetoothDeviceDiscoveryAgent::errorString(error); wrong.

    1. can I emulate the "agentService" error?
    2. What is the correct code to get "humanly readable " error to display on GUI?

    However, I am not sure which code is actually generating the "blueZ" error.
    (last line in debug output)

    It may not be coming from "agent" code....

    f4e2dc93-1dd2-4387-88b0-d32fc94cbfcd-image.png

    Pl45m4P 1 Reply Last reply
    0
    • A Anonymous_Banned275

      I am trying to capture "blueZ" library errors to GUI.

      I have this connect code and like to at least acknowledge the error.
      I have the text = QBluetoothDeviceDiscoveryAgent::errorString(error); wrong.

      1. can I emulate the "agentService" error?
      2. What is the correct code to get "humanly readable " error to display on GUI?

      However, I am not sure which code is actually generating the "blueZ" error.
      (last line in debug output)

      It may not be coming from "agent" code....

      f4e2dc93-1dd2-4387-88b0-d32fc94cbfcd-image.png

      Pl45m4P Offline
      Pl45m4P Offline
      Pl45m4
      wrote on last edited by Pl45m4
      #2

      @AnneRanch said in Sending "bluez" error to GUI:

      can I emulate the "agentService" error?

      Hard to say... You could create a QBluetoothServiceAgentError, but since it's just an enum, it's not more than an int value

      https://doc.qt.io/qt-6/qbluetoothservicediscoveryagent.html#Error-enum

      What is the correct code to get "humanly readable " error to display on GUI?

      Something like this might work (not tested)

      connect(agentService, &QBluetoothServiceDiscoveryAgent::errorOccured, [=](){
      
      QString errMsg = agentService->errorString();
      ui->chat_7->append(errMsg);
      
      }
      

      If debugging is the process of removing software bugs, then programming must be the process of putting them in.

      ~E. W. Dijkstra

      1 Reply Last reply
      0
      • C Offline
        C Offline
        ChrisW67
        wrote on last edited by ChrisW67
        #3

        @AnneRanch Could you please learn how to copy and paste the text of your source code and output into the forum. Unsearchable, truncated fragments of screen shots are not nearly as useful.

        However, I am not sure which code is actually generating the "blueZ" error.
        (last line in debug output)

        The last line in the debug output is precisely that, debug output (a warning) to stderr from the Qt Bluetooth module.
        /src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp

        The text of this debug output may not bear any relationship to the text returned by errorString(error).

        You can intercept all such (enabled) categorised debug output by installing a global message handler. Doing something useful with that is another thing altogether.

        A 1 Reply Last reply
        4
        • C ChrisW67

          @AnneRanch Could you please learn how to copy and paste the text of your source code and output into the forum. Unsearchable, truncated fragments of screen shots are not nearly as useful.

          However, I am not sure which code is actually generating the "blueZ" error.
          (last line in debug output)

          The last line in the debug output is precisely that, debug output (a warning) to stderr from the Qt Bluetooth module.
          /src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp

          The text of this debug output may not bear any relationship to the text returned by errorString(error).

          You can intercept all such (enabled) categorised debug output by installing a global message handler. Doing something useful with that is another thing altogether.

          A Offline
          A Offline
          Anonymous_Banned275
          wrote on last edited by
          #4

          @ChrisW67

          I have an opportunity to verify the "copy from buez to GUI"... my latest OS update deleted bluez !!

          So - here is my attempt to do that and it is failing even trying to just qDebug a test errMsg.....

          I am not asking for RTFM - I need somebody to help me to actually WRITE the correct code.

           localAdapters = QBluetoothLocalDevice::allDevices();
          
                      connect(localAdapters,&QBluetoothLocalDevice::error,
                              [=](){
                  QString errMsg = "TEST ";
                  qDebug() << errMsg;
              }
              );
          
          

          ...and the error is....

          /mnt/07b7c3f8-0efb-45ab-8df8-2a468771de1f/PROJECTS/BT_JAN18_/CCC_SOURCE/btchat/chat.cpp:118: error: no matching member function for call to 'connect'
          chat.cpp:118:13: error: no matching member function for call to 'connect'
                      connect(localAdapters,&QBluetoothLocalDevice::error,
                      ^~~~~~~
          /home/nov25-1/Qt/Nov26/5.15.2/gcc_64/include/QtCore/qobject.h:314:13: note: candidate function [with Func1 = void (QBluetoothLocalDevice::*)(QBluetoothLocalDevice::Error), Func2 = (lambda at chat.cpp:119:21)] not viable: no known conversion from 'QList<QBluetoothHostInfo>' to 'const typename QtPrivate::FunctionPointer<void (QBluetoothLocalDevice::*)(Error)>::Object *' (aka 'const QBluetoothLocalDevice *') for 1st argument
                      connect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, Func1 signal, Func2 slot)
                      ^
          /home/nov25-1/Qt/Nov26/5.15.2/gcc_64/include/QtCore/qobject.h:481:41: note: candidate function not viable: no known conversion from 'QList<QBluetoothHostInfo>' to 'const QObject *' for 1st argument
          inline QMetaObject::Connection QObject::connect(const QObject *asender, const char *asignal,
                                                  ^
          /home/nov25-1/Qt/Nov26/5.15.2/gcc_64/include/QtCore/qobject.h:274:13: note: candidate template ignored: requirement 'int(QtPrivate::FunctionPointer<(lambda at chat.cpp:119:21)>::ArgumentCount) >= 0' was not satisfied [with Func1 = void (QBluetoothLocalDevice::*)(QBluetoothLocalDevice::Error), Func2 = (lambda at chat.cpp:119:21)]
                      connect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, Func1 signal, Func2 slot)
                      ^
          /home/nov25-1/Qt/Nov26/5.15.2/gcc_64/include/QtCore/qobject.h:222:36: note: candidate function not viable: requires at least 4 arguments, but 3 were provided
              static QMetaObject::Connection connect(const QObject *sender, const char *signal,
                                             ^
          /home/nov25-1/Qt/Nov26/5.15.2/gcc_64/include/QtCore/qobject.h:225:36: note: candidate function not viable: requires at least 4 arguments, but 3 were provided
              static QMetaObject::Connection connect(const QObject *sender, const QMetaMethod &signal,
                                             ^
          /home/nov25-1/Qt/Nov26/5.15.2/gcc_64/include/QtCore/qobject.h:242:43: note: candidate function template not viable: requires at least 4 arguments, but 3 were provided
              static inline QMetaObject::Connection connect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, Func1 signal,
                                                    ^
          /home/nov25-1/Qt/Nov26/5.15.2/gcc_64/include/QtCore/qobject.h:283:13: note: candidate function template not viable: requires at least 4 arguments, but 3 were provided
                      connect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, Func1 signal, const QObject *context, Func2 slot,
                      ^
          /home/nov25-1/Qt/Nov26/5.15.2/gcc_64/include/QtCore/qobject.h:322:13: note: candidate function template not viable: requires at least 4 arguments, but 3 were provided
                      connect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, Func1 signal, const QObject *context, Func2 slot,
                      ^
          
          1 Reply Last reply
          0
          • Christian EhrlicherC Offline
            Christian EhrlicherC Offline
            Christian Ehrlicher
            Lifetime Qt Champion
            wrote on last edited by
            #5

            localAdapters is a QList of QBluetoothHostInfo . Neither QList nor QBluetoothHostInfo is a QObject so connect() will not work, esp. since the function/signal you're trying to connect is of type QBluetoothLocalDevice::error

            Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
            Visit the Qt Academy at https://academy.qt.io/catalog

            A 1 Reply Last reply
            1
            • Christian EhrlicherC Christian Ehrlicher

              localAdapters is a QList of QBluetoothHostInfo . Neither QList nor QBluetoothHostInfo is a QObject so connect() will not work, esp. since the function/signal you're trying to connect is of type QBluetoothLocalDevice::error

              A Offline
              A Offline
              Anonymous_Banned275
              wrote on last edited by
              #6

              @Christian-Ehrlicher ...here is the error "created " by updated OS

              "int Chat::AutoConnect() \n @line 363"
              Cannot find a running Bluez. Please check the Bluez installation.
              ASSERT failure in QList<T>::at: "index out of range", file /home/nov25-1/Qt/Nov26/5.15.2/gcc_64/include/QtCore/qlist.h, line 571
              10:55:50: /mnt/07b7c3f8-0efb-45ab-8df8-2a468771de1f/PROJECTS/BT_JAN18_/CCC_SOURCE/btchat/btchat crashed.

              are you saying I cannot display this particular error on GUI ?

              The "missing bluez' is causing the "index out of range " - the app won't run at all.
              I am reinstalling "bluez"....

              1 Reply Last reply
              0
              • Christian EhrlicherC Offline
                Christian EhrlicherC Offline
                Christian Ehrlicher
                Lifetime Qt Champion
                wrote on last edited by
                #7

                Don't see what this has to do with your connect() problem above but when you get an assertion you will use a debugger to see where it come from (as already told you many times)

                Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                Visit the Qt Academy at https://academy.qt.io/catalog

                1 Reply Last reply
                1

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved